From fe2fa3c1e4cf84fc18082cffe337120beba479e1 Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Fri, 13 Sep 2024 21:58:57 +0200 Subject: [PATCH 1/2] Powered creeper drop --- .../mobsinfo/api/IChanceModifier.java | 19 ++++++++++++++ .../loader/extras/ElectroMagicTools.java | 26 ++----------------- .../mobsinfo/loader/extras/Reliquarry.java | 12 ++++++--- .../mobsinfo/loader/extras/Translations.java | 2 +- .../resources/assets/mobsinfo/lang/en_US.lang | 2 +- .../resources/assets/mobsinfo/lang/ru_RU.lang | 2 +- .../resources/assets/mobsinfo/lang/zh_CN.lang | 2 +- 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/kuba6000/mobsinfo/api/IChanceModifier.java b/src/main/java/com/kuba6000/mobsinfo/api/IChanceModifier.java index 990d9ee..1eafeab 100644 --- a/src/main/java/com/kuba6000/mobsinfo/api/IChanceModifier.java +++ b/src/main/java/com/kuba6000/mobsinfo/api/IChanceModifier.java @@ -11,6 +11,7 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -417,4 +418,22 @@ public void readFromByteBuf(ByteBuf byteBuf) { change = byteBuf.readDouble(); } } + + class PoweredCreeper implements IChanceModifier { + + @Override + public String getDescription() { + return Translations.POWERED_CREEPER.get(); + } + + @Override + public double apply(double chance, @Nonnull World world, @Nonnull List drops, Entity attacker, + EntityLiving victim) { + if (chance == 0d) return 0d; + if (victim == null) return 0d; + if (victim instanceof EntityCreeper && ((EntityCreeper) victim).getPowered()) return chance; + return 0d; + } + + } } diff --git a/src/main/java/com/kuba6000/mobsinfo/loader/extras/ElectroMagicTools.java b/src/main/java/com/kuba6000/mobsinfo/loader/extras/ElectroMagicTools.java index c1755ed..0060c07 100644 --- a/src/main/java/com/kuba6000/mobsinfo/loader/extras/ElectroMagicTools.java +++ b/src/main/java/com/kuba6000/mobsinfo/loader/extras/ElectroMagicTools.java @@ -2,15 +2,9 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.List; -import javax.annotation.Nonnull; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import com.kuba6000.mobsinfo.api.IChanceModifier; import com.kuba6000.mobsinfo.api.MobDrop; @@ -33,7 +27,8 @@ public void process(String k, ArrayList drops, MobRecipe recipe) { false, false); drop.variableChance = true; - drop.chanceModifiers.addAll(Arrays.asList(new IChanceModifier.NormalChance(100d), new EMTCreeper())); + drop.chanceModifiers + .addAll(Arrays.asList(new IChanceModifier.NormalChance(100d), new IChanceModifier.PoweredCreeper())); drops.add(drop); } if (recipe.entity instanceof EntityTaintChicken) { @@ -50,21 +45,4 @@ public void process(String k, ArrayList drops, MobRecipe recipe) { } } - private static class EMTCreeper implements IChanceModifier { - - @Override - public String getDescription() { - return Translations.EMT_CREEPER.get(); - } - - @Override - public double apply(double chance, @Nonnull World world, @Nonnull List drops, Entity attacker, - EntityLiving victim) { - if (chance == 0d) return 0d; - if (victim == null) return 0d; - if (victim instanceof EntityCreeper && ((EntityCreeper) victim).getPowered()) return chance; - return 0d; - } - - } } diff --git a/src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java b/src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java index 37f81e8..1c01594 100644 --- a/src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java +++ b/src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java @@ -20,6 +20,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import com.kuba6000.mobsinfo.api.IChanceModifier; import com.kuba6000.mobsinfo.api.MobDrop; import com.kuba6000.mobsinfo.api.MobRecipe; @@ -67,9 +68,11 @@ public void process(String k, ArrayList drops, MobRecipe recipe) { addDrop(drops, XRRecipes.ingredient(Reference.CREEPER_INGREDIENT_META), Names.ghast_gland); } else if (recipe.entity instanceof EntityCreeper) { addDrop(drops, XRRecipes.ingredient(Reference.CREEPER_INGREDIENT_META), Names.creeper_gland); - if (((EntityCreeper) recipe.entity).getPowered()) { - addDrop(drops, XRRecipes.ingredient(Reference.STORM_INGREDIENT_META), Names.eye_of_the_storm); - } + MobDrop drop = addDrop( + drops, + XRRecipes.ingredient(Reference.STORM_INGREDIENT_META), + Names.eye_of_the_storm); + drop.withChanceModifiers(new IChanceModifier.NormalChance(drop.chance * 0.01d)); } else if (recipe.entity instanceof EntityEnderman) { addDrop(drops, XRRecipes.ingredient(Reference.ENDER_INGREDIENT_META), Names.ender_heart); } else if (recipe.entity instanceof EntityBat) { @@ -79,7 +82,7 @@ public void process(String k, ArrayList drops, MobRecipe recipe) { } } - private void addDrop(ArrayList drops, ItemStack item, String name) { + private MobDrop addDrop(ArrayList drops, ItemStack item, String name) { MobDrop drop = new MobDrop( item, MobDrop.DropType.Normal, @@ -89,5 +92,6 @@ private void addDrop(ArrayList drops, ItemStack item, String name) { eventHandler.getLootingDrop(name) > 0.01f, false); drops.add(drop); + return drop; } } diff --git a/src/main/java/com/kuba6000/mobsinfo/loader/extras/Translations.java b/src/main/java/com/kuba6000/mobsinfo/loader/extras/Translations.java index 11465b6..c3f9d51 100644 --- a/src/main/java/com/kuba6000/mobsinfo/loader/extras/Translations.java +++ b/src/main/java/com/kuba6000/mobsinfo/loader/extras/Translations.java @@ -31,7 +31,7 @@ public enum Translations { DRACONIC_EVOLUTION_MOB_SOUL_3, DRACONIC_EVOLUTION_MOB_SOUL_4, DRACONIC_EVOLUTION_MOB_SOUL_5, - EMT_CREEPER, + POWERED_CREEPER, FORBIDDEN_MAGIC_NON_PLAYER, OPEN_BLOCKS_SMALL_CHANCE, TINKERS_CONSTRUCT_BEHEADING, diff --git a/src/main/resources/assets/mobsinfo/lang/en_US.lang b/src/main/resources/assets/mobsinfo/lang/en_US.lang index 87b9567..9693cff 100644 --- a/src/main/resources/assets/mobsinfo/lang/en_US.lang +++ b/src/main/resources/assets/mobsinfo/lang/en_US.lang @@ -72,7 +72,7 @@ mobsinfo.extras.draconic_evolution_mob_soul_2=Any/None | %.2f%% | %.2f%% | %.2f% mobsinfo.extras.draconic_evolution_mob_soul_3=Wyvern Sword/Bow | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% mobsinfo.extras.draconic_evolution_mob_soul_4=Draconic Sword/Bow | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% mobsinfo.extras.draconic_evolution_mob_soul_5=Draconic Staff of Power | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% -mobsinfo.extras.emt_creeper=Drops only when Creeper is powered +mobsinfo.extras.powered_creeper=Drops only when Creeper is powered mobsinfo.extras.forbidden_magic_non_player=Drops only when killed by non player entity mobsinfo.extras.open_blocks_small_chance=Chance: Small mobsinfo.extras.tinkers_construct_beheading=Each level of beheading on your weapon gives additional %.2f%% diff --git a/src/main/resources/assets/mobsinfo/lang/ru_RU.lang b/src/main/resources/assets/mobsinfo/lang/ru_RU.lang index 6c87a95..ede9627 100644 --- a/src/main/resources/assets/mobsinfo/lang/ru_RU.lang +++ b/src/main/resources/assets/mobsinfo/lang/ru_RU.lang @@ -72,7 +72,7 @@ mobsinfo.extras.draconic_evolution_mob_soul_2=Любой/Нет | %.2f mobsinfo.extras.draconic_evolution_mob_soul_3=Меч виверны/Лук | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | mobsinfo.extras.draconic_evolution_mob_soul_4=Драконий меч/лук | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | mobsinfo.extras.draconic_evolution_mob_soul_5=Драконий посох силы | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | | %.2f%% | -mobsinfo.extras.emt_creeper=Выпадает только если крипер заряжен +mobsinfo.extras.powered_creeper=Выпадает только если крипер заряжен mobsinfo.extras.forbidden_magic_non_player=Выпадает только при убийстве не игроком mobsinfo.extras.open_blocks_small_chance=Шанс: малый mobsinfo.extras.tinkers_construct_beheading=Каждый уровень обезглавливания на вашем оружии дает дополнительные %.2f%% diff --git a/src/main/resources/assets/mobsinfo/lang/zh_CN.lang b/src/main/resources/assets/mobsinfo/lang/zh_CN.lang index 3d1bd6f..e61d2c5 100644 --- a/src/main/resources/assets/mobsinfo/lang/zh_CN.lang +++ b/src/main/resources/assets/mobsinfo/lang/zh_CN.lang @@ -53,7 +53,7 @@ mobsinfo.extras.draconic_evolution_mob_soul_2=任意/没有 | %.2f%% | %.2f%% | mobsinfo.extras.draconic_evolution_mob_soul_3=双足飞龙剑/双足飞龙弓 | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% mobsinfo.extras.draconic_evolution_mob_soul_4=神龙剑/神龙弓 | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% mobsinfo.extras.draconic_evolution_mob_soul_5=神龙物品的能力 | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% | %.2f%% -mobsinfo.extras.emt_creeper=当且仅当被苦力怕炸飞时,才会掉落。 +mobsinfo.extras.powered_creeper=当且仅当被苦力怕炸飞时,才会掉落。 mobsinfo.extras.forbidden_magic_non_player=当且仅当被非玩家实体干掉时候,才会掉落。 mobsinfo.extras.open_blocks_small_chance=几率:小 mobsinfo.extras.tinkers_construct_beheading=每一级斩首强化都会增加%.2f%%的几率。 From 41bde1acc347df21ab3bc483a9a1c9176fb051a8 Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Fri, 13 Sep 2024 22:01:27 +0200 Subject: [PATCH 2/2] Update Reliquarry.java --- .../java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java b/src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java index 1c01594..001276b 100644 --- a/src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java +++ b/src/main/java/com/kuba6000/mobsinfo/loader/extras/Reliquarry.java @@ -72,7 +72,9 @@ public void process(String k, ArrayList drops, MobRecipe recipe) { drops, XRRecipes.ingredient(Reference.STORM_INGREDIENT_META), Names.eye_of_the_storm); - drop.withChanceModifiers(new IChanceModifier.NormalChance(drop.chance * 0.01d)); + drop.withChanceModifiers( + new IChanceModifier.NormalChance(drop.chance * 0.01d), + new IChanceModifier.PoweredCreeper()); } else if (recipe.entity instanceof EntityEnderman) { addDrop(drops, XRRecipes.ingredient(Reference.ENDER_INGREDIENT_META), Names.ender_heart); } else if (recipe.entity instanceof EntityBat) {