diff --git a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java index 18ecdf3..ebcb6ab 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java @@ -19,6 +19,7 @@ import net.minecraft.item.*; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import net.minecraft.network.play.server.S04PacketEntityEquipment; import net.minecraft.network.play.server.S19PacketEntityStatus; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -89,11 +90,17 @@ public class CinderEventHandler implements IFuelHandler { } @SubscribeEvent public void onLivingHurt(LivingHurtEvent event) { + + if (event.entityLiving == null || event.source.getEntity() == null) { + return; + } + EntityLivingBase entity = event.entityLiving; EntityLivingBase attacker = event.source.getEntity() instanceof EntityLivingBase ? (EntityLivingBase) event.source.getEntity() : null; World world = entity.worldObj; DamageSource source = event.source; - if (event.entity instanceof EntityPlayer && !source.isUnblockable() || event.entity instanceof EntityPlayer && !source.isExplosion()) { + + if (event.entity instanceof EntityPlayer && !source.isUnblockable()) { EntityPlayerMP player = (EntityPlayerMP) event.entity; ItemStack sword = player.getHeldItem(); @@ -120,14 +127,14 @@ public class CinderEventHandler implements IFuelHandler { sword.damageItem((int) (event.ammount *1.5), player); // Axes deal 150% the Durability damage ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S19PacketEntityStatus(player, (byte) 29)); world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F); - additionalDamage = 0.75f; + additionalDamage = 0.75f; // Only 25% Passes through } else if (weapon.getItem() instanceof LOTRItemHammer) { sword.damageItem((int) event.ammount, player); // Hammers bypass the block better, but only deal 100% of the durability damage ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S19PacketEntityStatus(player, (byte) 29)); world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F); - additionalDamage = 0.5f; // 20% more damage per piece + additionalDamage = 0.5f; // Only 50% Passes through } else { - additionalDamage = 0.0f; + additionalDamage = 0.0f; // 0% Damage Passes through sword.damageItem((int) (event.ammount/2), player); //Swords only deal 50% of durability damage ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S19PacketEntityStatus(player, (byte) 29)); world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F); diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRHiredNPCInfo.java b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRHiredNPCInfo.java index 91cad7a..cf9c4db 100644 --- a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRHiredNPCInfo.java +++ b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRHiredNPCInfo.java @@ -5,7 +5,9 @@ import lotr.common.entity.npc.LOTRHiredNPCInfo; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttribute; import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.ai.attributes.RangedAttribute; import net.minecraft.entity.item.EntityFireworkRocket; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -19,6 +21,7 @@ import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import java.util.UUID; @@ -30,11 +33,18 @@ public class MixinLOTRHiredNPCInfo { private UUID hiringPlayerUUID; @Shadow public int xpLevel = 1; + @Unique + public int levelUpCounter = 0; + /** + * @author + * @reason + */ @Overwrite(remap = false) public void onLevelUp() { EntityPlayer hirer; - this.addLevelUpHealthGain((EntityLivingBase) this.theEntity); + rotateLevelUpStat(); + Entity mount = this.theEntity.ridingEntity; if (mount instanceof EntityLivingBase && !(mount instanceof LOTREntityNPC)) { this.addLevelUpHealthGain((EntityLivingBase)mount); @@ -45,6 +55,35 @@ public class MixinLOTRHiredNPCInfo { this.spawnLevelUpFireworks(); } + + public void rotateLevelUpStat() { + EntityLivingBase entity = (EntityLivingBase) this.theEntity; + + switch (levelUpCounter) { + case 0: + // +1 HP + this.addLevelUpHealthGain(entity); + break; + case 1: + // +0.25 Damage + this.increaseDamageGain(entity); + break; + case 2: + // +0.005 movement Speed + this.increaseMovementGain(entity); + break; + case 3: + // +0.1 knockback resistance + this.increaseKnockbackGain(entity); + break; + } + levelUpCounter = (levelUpCounter +1) % 4; + } + + /** + * @author + * @reason + */ @Overwrite(remap = false) public void addLevelUpHealthGain(EntityLivingBase gainingEntity) { float healthBoost = 1.0f; @@ -53,6 +92,28 @@ public class MixinLOTRHiredNPCInfo { gainingEntity.heal(healthBoost); } + public void increaseDamageGain(EntityLivingBase gainingEntity) { + float damageBoost = 0.25f; + IAttributeInstance attribute = gainingEntity.getEntityAttribute(LOTREntityNPC.npcAttackDamage); + attribute.setBaseValue(attribute.getBaseValue() + (double)damageBoost); + } + + public void increaseMovementGain(EntityLivingBase gainingEntity) { + float movementBoost = 0.005f; + IAttributeInstance attribute = gainingEntity.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + attribute.setBaseValue(attribute.getBaseValue() + (double)movementBoost); + } + + public void increaseKnockbackGain(EntityLivingBase gainingEntity) { + float kbResBoost = 0.1f; + IAttributeInstance attribute = gainingEntity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance); + attribute.setBaseValue(attribute.getBaseValue() + (double)kbResBoost); + } + + /** + * @author + * @reason + */ @Overwrite(remap = false) public EntityPlayer getHiringPlayer() { if (this.hiringPlayerUUID == null) {