From efd533027208e5c27e954b7083f16616578b8471 Mon Sep 17 00:00:00 2001 From: s Date: Sat, 5 Apr 2025 23:08:21 +0300 Subject: [PATCH] Added fireArmor modifier --- .gitignore | 2 + .../enchants/LOTREnchantmentArmorSpecial.java | 80 +++++++++++++++++++ .../mixins/MixinLOTREnchantment.java | 19 ++++- .../zivilon/cinder_loe/util/DamageEvent.java | 22 ++++- 4 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/zivilon/cinder_loe/enchants/LOTREnchantmentArmorSpecial.java diff --git a/.gitignore b/.gitignore index 91ea741..3f5959c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build .gradle +.vs +.git diff --git a/src/main/java/com/zivilon/cinder_loe/enchants/LOTREnchantmentArmorSpecial.java b/src/main/java/com/zivilon/cinder_loe/enchants/LOTREnchantmentArmorSpecial.java new file mode 100644 index 0000000..5c47a42 --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/enchants/LOTREnchantmentArmorSpecial.java @@ -0,0 +1,80 @@ +package com.zivilon.cinder_loe.enchants; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import lotr.common.LOTRDamage; +import lotr.common.enchant.LOTREnchantment; +import lotr.common.enchant.LOTREnchantmentBane; +import lotr.common.enchant.LOTREnchantmentType; +import lotr.common.item.LOTRWeaponStats; +import lotr.common.network.LOTRPacketHandler; +import lotr.common.network.LOTRPacketWeaponFX; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.StatCollector; +import net.minecraft.item.ItemStack; + +public class LOTREnchantmentArmorSpecial extends LOTREnchantment { + private boolean compatibleBane = true; + + private boolean compatibleOtherSpecial = false; + + public LOTREnchantmentArmorSpecial(String s) { + super(s, new LOTREnchantmentType[] { LOTREnchantmentType.ARMOR, LOTREnchantmentType.ARMOR_FEET, LOTREnchantmentType.ARMOR_LEGS, LOTREnchantmentType.ARMOR_BODY, LOTREnchantmentType.ARMOR_HEAD, }); + setValueModifier(3.0F); + setBypassAnvilLimit(); + } + + public LOTREnchantmentArmorSpecial setIncompatibleBane() { + this.compatibleBane = false; + return this; + } + + public LOTREnchantmentArmorSpecial setCompatibleOtherSpecial() { + this.compatibleOtherSpecial = true; + return this; + } + + public String getDescription(ItemStack itemstack) { + return StatCollector.translateToLocalFormatted("lotr.enchant." + this.enchantName + ".desc", new Object[0]); +} + + public boolean isBeneficial() { + return true; + } + + public boolean canApply(ItemStack itemstack, boolean considering) { + if (super.canApply(itemstack, considering)) { + Item item = itemstack.getItem(); + /*if (item instanceof lotr.common.item.LOTRItemBalrogWhip && (this == LOTREnchantment.fire || this == LOTREnchantment.chill))*/ + return true; + } + return false; + } + + public boolean isCompatibleWith(LOTREnchantment other) { + if (!this.compatibleBane) + if (other instanceof LOTREnchantmentBane) + return false; + if (!this.compatibleOtherSpecial) + if (other instanceof LOTREnchantmentArmorSpecial && !((LOTREnchantmentArmorSpecial)other).compatibleOtherSpecial) + return false; + return true; + } + + public static int getFireAmount() { + return 2; + } + + /*public static void doChillAttack(EntityLivingBase entity) { + if (entity instanceof EntityPlayerMP) + LOTRDamage.doFrostDamage((EntityPlayerMP)entity); + int duration = 5; + entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, duration * 20, 1)); + LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.CHILLING, (Entity)entity); + LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)entity, 64.0D));*/ + } \ No newline at end of file diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREnchantment.java b/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREnchantment.java index 936dfb6..c08d748 100644 --- a/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREnchantment.java +++ b/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREnchantment.java @@ -1,8 +1,10 @@ package com.zivilon.cinder_loe.mixins; import com.zivilon.cinder_loe.enchants.LOTREnchantmentWeakProtectionRanged; +import com.zivilon.cinder_loe.enchants.LOTREnchantmentArmorSpecial; import com.zivilon.cinder_loe.util.Utilities; import lotr.common.enchant.*; +import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @@ -30,6 +32,11 @@ public class MixinLOTREnchantment { LOTREnchantment rangedStrong4 = new LOTREnchantmentRangedDamage("rangedStrong4", 1.4f).setEnchantWeight(0).setSkilful(); LOTREnchantment meleeReach2 = new LOTREnchantmentMeleeReach("meleeReach2", 1.33f).setEnchantWeight(0).setSkilful(); LOTREnchantment meleeSpeed2 = new LOTREnchantmentMeleeSpeed("meleeSpeed2", 1.33f).setEnchantWeight(0).setSkilful(); + LOTREnchantment Shinare = new LOTREnchantmentArmorSpecial("Shinare").setEnchantWeight(0).setSkilful(); + LOTREnchantment swiftness = new LOTREnchantmentArmorSpecial("swiftness").setEnchantWeight(0).setSkilful(); + LOTREnchantment fireRepair = new LOTREnchantmentArmorSpecial("fireRepair").setEnchantWeight(0).setSkilful(); + LOTREnchantment mountArmor = new LOTREnchantmentArmorSpecial("mountArmor").setEnchantWeight(0).setSkilful(); + LOTREnchantment stealth = new LOTREnchantmentArmorSpecial("stealth").setEnchantWeight(0).setSkilful(); LOTREnchantment.allEnchantments.add(protectRangedWeak1); @@ -40,6 +47,11 @@ public class MixinLOTREnchantment { LOTREnchantment.allEnchantments.add(rangedStrong4); LOTREnchantment.allEnchantments.add(meleeReach2); LOTREnchantment.allEnchantments.add(meleeSpeed2); + LOTREnchantment.allEnchantments.add(Shinare); + LOTREnchantment.allEnchantments.add(swiftness); + LOTREnchantment.allEnchantments.add(fireRepair); + LOTREnchantment.allEnchantments.add(mountArmor); + LOTREnchantment.allEnchantments.add(stealth); Field enchantsByNameField = LOTREnchantment.class.getDeclaredField("enchantsByName"); enchantsByNameField.setAccessible(true); @@ -54,6 +66,11 @@ public class MixinLOTREnchantment { enchantsByName.put(rangedStrong4.enchantName, rangedStrong4); enchantsByName.put(meleeReach2.enchantName, meleeReach2); enchantsByName.put(meleeSpeed2.enchantName, meleeSpeed2); + enchantsByName.put(Shinare.enchantName, Shinare); + enchantsByName.put(swiftness.enchantName, swiftness); + enchantsByName.put(fireRepair.enchantName, fireRepair); + enchantsByName.put(mountArmor.enchantName, mountArmor); + enchantsByName.put(stealth.enchantName, stealth); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); @@ -61,7 +78,7 @@ public class MixinLOTREnchantment { } /** - * @author Shinare + * @author MrJeep20 * @reason Bad enchantments will not count towards 3 modifier limit now **/ @Overwrite(remap = false) diff --git a/src/main/java/com/zivilon/cinder_loe/util/DamageEvent.java b/src/main/java/com/zivilon/cinder_loe/util/DamageEvent.java index 7cef160..7ca0df4 100644 --- a/src/main/java/com/zivilon/cinder_loe/util/DamageEvent.java +++ b/src/main/java/com/zivilon/cinder_loe/util/DamageEvent.java @@ -3,6 +3,11 @@ package com.zivilon.cinder_loe.util; import net.minecraft.entity.*; import net.minecraft.entity.player.*; import net.minecraft.util.DamageSource; + +import com.zivilon.cinder_loe.mixins.MixinLOTREnchantment; +import lotr.common.enchant.LOTREnchantment; +import lotr.common.enchant.LOTREnchantmentHelper; + import lotr.common.item.*; import net.minecraft.item.*; import net.minecraft.world.World; @@ -67,7 +72,22 @@ public class DamageEvent { } } } - + if (event.source.isFireDamage() && event.defender instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.defender; + for (ItemStack armor : player.inventory.armorInventory) { + if (armor != null && LOTREnchantmentHelper.hasEnchant(armor, LOTREnchantment.getEnchantmentByName("fireRepair"))) { + int currentDamage = armor.getItemDamage(); + int reduction = (int) event.damage; + int newDamage = currentDamage - reduction; + + if (newDamage < 0) { + newDamage = 0; + } + + armor.setItemDamage(newDamage); + } + } + } return new Pair<>(event, cancel); } }