Fix enchantment occurances and remove the curse rank from clingy. Fixes #306

This commit is contained in:
Sollace 2024-03-20 21:32:02 +00:00
parent 3b4639d5da
commit 7d59e1e0bf
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 63 additions and 26 deletions

View file

@ -59,7 +59,7 @@ public class SimpleEnchantment extends Enchantment {
@Override
public final boolean isAvailableForRandomSelection() {
return options.looted;
return options.table;
}
public static class Data {
@ -77,8 +77,8 @@ public class SimpleEnchantment extends Enchantment {
public static class Options {
private boolean cursed;
private boolean treasured;
private boolean traded = true;
private boolean looted = true;
private boolean traded;
private boolean table;
private Rarity rarity;
private int maxLevel = 1;
private EquipmentSlot[] slots;
@ -102,6 +102,9 @@ public class SimpleEnchantment extends Enchantment {
this.target = target;
}
/**
* Sets the enchantment to apply to all items.
*/
public Options ignoreTarget() {
allItems = true;
return this;
@ -128,8 +131,7 @@ public class SimpleEnchantment extends Enchantment {
}
/**
* Treasure enchantments only generate in loot tables with high-value items or by trading with villagers.
* They do not appear in the enchanting table.
* Whether this enchantment should be limited to high value trades or leveled up enchanting table offers.
*/
public Options treasure() {
treasured = true;
@ -137,25 +139,24 @@ public class SimpleEnchantment extends Enchantment {
}
/**
* Loot-Only enchantments do not appear in villager trades.
* They may still appear in loot table generation and can be found in the enchanting table.
* Set whether this enchantment should appear in villager trades.
*/
public Options lootedOnly() {
traded = false;
looted = true;
public Options traded() {
this.traded = true;
return this;
}
/**
* Trade-Only enchantments are excluded from loot table generation and do not appear in the enchanting table.
* They can only be found by trading with villagers.
* Sets whether the enchantment should appear in enchanting table draws.
*/
public Options tradedOnly() {
looted = false;
traded = true;
public Options table() {
this.table = true;
return this;
}
/**
* Sets the maximum level for the enchantment.
*/
public Options maxLevel(int level) {
maxLevel = level;
return this;

View file

@ -24,18 +24,30 @@ public interface UEnchantments {
/**
* Makes a sound when there are interesting blocks in your area.
*
* Appears in:
* - Trades
* - Enchanting Table
*/
Enchantment GEM_FINDER = register("gem_finder", new GemFindingEnchantment(Options.create(EnchantmentTarget.DIGGER, UEnchantmentValidSlots.HANDS).rarity(Rarity.RARE).maxLevel(3).treasure()));
Enchantment GEM_FINDER = register("gem_finder", new GemFindingEnchantment(Options.create(EnchantmentTarget.DIGGER, UEnchantmentValidSlots.HANDS).rarity(Rarity.RARE).maxLevel(3).treasure().traded().table()));
/**
* Protects against wall collisions and earth pony attacks!
*
* Appears in:
* - Trades
* - Enchanting Table
*/
Enchantment PADDED = register("padded", new SimpleEnchantment(Options.armor().rarity(Rarity.UNCOMMON).maxLevel(3)));
Enchantment PADDED = register("padded", new SimpleEnchantment(Options.armor().rarity(Rarity.UNCOMMON).maxLevel(3).traded().table()));
/**
* Heavy players move more slowly but are less likely to be flung around wildly.
*
* Appears in:
* - Trades
* - Enchanting Table
*/
Enchantment HEAVY = register("heavy", new AttributedEnchantment(Options.armor().rarity(Rarity.RARE).maxLevel(4)))
Enchantment HEAVY = register("heavy", new AttributedEnchantment(Options.armor().rarity(Rarity.RARE).maxLevel(4).traded().table()))
.addModifier(EntityAttributes.GENERIC_MOVEMENT_SPEED, (user, level) -> {
return new EntityAttributeModifier(UUID.fromString("a3d5a94f-4c40-48f6-a343-558502a13e10"), "Heavyness", (1 - level/(float)10) - 1, Operation.MULTIPLY_TOTAL);
});
@ -44,13 +56,20 @@ public interface UEnchantments {
* It's dangerous to go alone, take this!
*
* Weapons will become stronger the more allies you have around.
*
* Appears in:
* - Trades
* - Enchanting Table
*/
Enchantment HERDS = register("herds", new CollaboratorEnchantment(Options.create(EnchantmentTarget.WEAPON, EquipmentSlot.MAINHAND).rarity(Rarity.RARE).maxLevel(3)));
Enchantment HERDS = register("herds", new CollaboratorEnchantment(Options.create(EnchantmentTarget.WEAPON, EquipmentSlot.MAINHAND).rarity(Rarity.RARE).maxLevel(3).treasure().traded().table()));
/**
* Alters gravity
*
* Appears in:
* - Trades
*/
Enchantment REPULSION = register("repulsion", new AttributedEnchantment(Options.create(EnchantmentTarget.ARMOR_FEET, EquipmentSlot.FEET).rarity(Rarity.VERY_RARE).maxLevel(3)))
Enchantment REPULSION = register("repulsion", new AttributedEnchantment(Options.create(EnchantmentTarget.ARMOR_FEET, EquipmentSlot.FEET).rarity(Rarity.VERY_RARE).maxLevel(3).treasure().traded()))
.addModifier(UEntityAttributes.ENTITY_GRAVITY_MODIFIER, (user, level) -> {
return new EntityAttributeModifier(UUID.fromString("1734bbd6-1916-4124-b710-5450ea70fbdb"), "Anti Grav", (0.5F - (0.375 * (level - 1))) - 1, Operation.MULTIPLY_TOTAL);
});
@ -60,35 +79,52 @@ public interface UEnchantments {
*
* Mobs really want your candy. You'd better give it to them.
*/
Enchantment WANT_IT_NEED_IT = register("want_it_need_it", new WantItNeedItEnchantment(Options.allItems().rarity(Rarity.VERY_RARE).curse().treasure()));
Enchantment WANT_IT_NEED_IT = register("want_it_need_it", new WantItNeedItEnchantment(Options.allItems().rarity(Rarity.VERY_RARE).curse().treasure().traded()));
/**
* Hahaha geddit?
*
* Random things happen.
*
* Appears in:
* - Trades
*/
PoisonedJokeEnchantment POISONED_JOKE = register("poisoned_joke", new PoisonedJokeEnchantment(Options.allItems().rarity(Rarity.VERY_RARE).curse().tradedOnly()));
PoisonedJokeEnchantment POISONED_JOKE = register("poisoned_joke", new PoisonedJokeEnchantment(Options.allItems().rarity(Rarity.VERY_RARE).curse().traded()));
/**
* Who doesn't like a good freakout?
*
* Appears in:
* - Trades
*/
Enchantment STRESSED = register("stressed", new StressfulEnchantment(Options.allItems().rarity(Rarity.VERY_RARE).curse().treasure().maxLevel(3)));
Enchantment STRESSED = register("stressed", new StressfulEnchantment(Options.allItems().rarity(Rarity.VERY_RARE).curse().treasure().traded().maxLevel(3)));
/**
* This item just wants to be held.
*
* Appears in:
* - Trades
* - Enchanting Table
*/
Enchantment CLINGY = register("clingy", new SimpleEnchantment(Options.allItems().rarity(Rarity.VERY_RARE).curse().maxLevel(6)));
Enchantment CLINGY = register("clingy", new SimpleEnchantment(Options.allItems().rarity(Rarity.VERY_RARE).maxLevel(6).traded().table().treasure()));
/**
* Items with loyalty are kept after death.
* Only works if they don't also have curse of binding.
*
* Appears in:
* - Enchanting Table
*/
Enchantment HEART_BOUND = register("heart_bound", new SimpleEnchantment(Options.create(EnchantmentTarget.VANISHABLE, UEnchantmentValidSlots.ANY).rarity(Rarity.UNCOMMON).maxLevel(5)));
Enchantment HEART_BOUND = register("heart_bound", new SimpleEnchantment(Options.create(EnchantmentTarget.VANISHABLE, UEnchantmentValidSlots.ANY).rarity(Rarity.UNCOMMON).maxLevel(5).treasure().table()));
/**
* Consumes drops whilst mining and produces experience instead
*
* Appears in:
* - Trades
* - Enchanting Table
*/
Enchantment CONSUMPTION = register("consumption", new ConsumptionEnchantment(Options.create(EnchantmentTarget.DIGGER, UEnchantmentValidSlots.HANDS).rarity(Rarity.VERY_RARE)));
Enchantment CONSUMPTION = register("consumption", new ConsumptionEnchantment(Options.create(EnchantmentTarget.DIGGER, UEnchantmentValidSlots.HANDS).rarity(Rarity.VERY_RARE).treasure().table().traded()));
static void bootstrap() { }