diff --git a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java index ee1674c..7485645 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java @@ -13,17 +13,16 @@ import lotr.common.enchant.LOTREnchantmentHelper; import lotr.common.item.*; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBow; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; +import net.minecraft.item.*; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ChatComponentText; +import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -87,12 +86,75 @@ public class CinderEventHandler implements IFuelHandler { } } } - - @SubscribeEvent(priority = EventPriority.HIGH) + @SubscribeEvent public void onLivingHurt(LivingHurtEvent event) { 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()) { + EntityPlayerMP player = (EntityPlayerMP) event.entity; + ItemStack sword = player.getHeldItem(); + + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Player Yaw " + player.getRotationYawHead())); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Attacker Yaw " + attacker.getRotationYawHead())); + + float playerYaw = player.getRotationYawHead(); + float attackerYaw = attacker.getRotationYawHead(); + +// Normalize both angles to be within 0 - 360 + playerYaw = (playerYaw + 360) % 360; + attackerYaw = (attackerYaw + 360) % 360; + +// Calculate the angle difference + float angleDifference = Math.abs(playerYaw - attackerYaw); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Player Yaw " + playerYaw)); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Attacker Yaw " + attackerYaw)); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "Angle Difference " + angleDifference)); + + + if (angleDifference > 180) { + angleDifference = 360 - angleDifference; + } + + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Initial Damage: " + event.ammount)); + ItemStack weapon = attacker.getHeldItem(); + if (weapon != null) { + if (player.isBlocking() && angleDifference >= 135 && angleDifference <=225) { + + float additionalDamage = 0.0f; + if (weapon.getItem() instanceof ItemAxe || weapon.getItem() instanceof LOTRItemAxe || weapon.getItem() instanceof LOTRItemBattleaxe) { + sword.damageItem((int) event.ammount, player); + world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F); + additionalDamage = 0.75f; + } else if (weapon.getItem() instanceof LOTRItemHammer) { + sword.damageItem((int) event.ammount, player); + world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F); + additionalDamage = 0.5f; // 20% more damage per piece + } else { + additionalDamage = 0.0f; + sword.damageItem((int) event.ammount, player); + world.playSoundAtEntity(player, "random.anvil_land", 1F, 2F); + } + + float newDamage = event.ammount * (additionalDamage); // Calculate new damage + float newHealth = player.getHealth() - (newDamage - event.ammount); // Calculate health after applying extra damage + + if (newHealth > 0) { + player.setHealth(newHealth); + event.setCanceled(true); + } else { + event.ammount = player.getHealth(); // Ensure player dies if health reaches 0 or below + } + + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Total Additional Damage: " + newDamage)); + + } + } + } + + + // Negative Arrow Protection Handler if (!event.entityLiving.worldObj.isRemote && event.source.isProjectile() && event.entityLiving instanceof EntityPlayerMP player) { diff --git a/src/main/java/com/zivilon/cinder_loe/items/unitLevelTool.java b/src/main/java/com/zivilon/cinder_loe/items/unitLevelTool.java index a8abbdb..cadb92f 100644 --- a/src/main/java/com/zivilon/cinder_loe/items/unitLevelTool.java +++ b/src/main/java/com/zivilon/cinder_loe/items/unitLevelTool.java @@ -70,7 +70,7 @@ public class unitLevelTool extends Item { LOTREntityNPC npc = (LOTREntityNPC) entity; // Check if the player has sufficient permission level (admin tool usage) - if (npc.hiredNPCInfo != null && player.canCommandSenderUseCommand(2, "")) { + if (npc.hiredNPCInfo.getHiringPlayerUUID() != null && player.canCommandSenderUseCommand(2, "")) { nearbyHiredNPCs.add(npc); } } 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 bf6791a..91cad7a 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 @@ -34,9 +34,7 @@ public class MixinLOTRHiredNPCInfo { @Overwrite(remap = false) public void onLevelUp() { EntityPlayer hirer; - if (this.theEntity.getMaxHealth() >= 60) { - this.addLevelUpHealthGain((EntityLivingBase) this.theEntity); - } + this.addLevelUpHealthGain((EntityLivingBase) this.theEntity); Entity mount = this.theEntity.ridingEntity; if (mount instanceof EntityLivingBase && !(mount instanceof LOTREntityNPC)) { this.addLevelUpHealthGain((EntityLivingBase)mount); diff --git a/src/main/resources/assets/cinder_loe/sounds/boss/Battle.ogg b/src/main/resources/assets/lotr/sounds/boss/battle.ogg similarity index 100% rename from src/main/resources/assets/cinder_loe/sounds/boss/Battle.ogg rename to src/main/resources/assets/lotr/sounds/boss/battle.ogg diff --git a/src/main/resources/assets/cinder_loe/sounds/boss/Battle2.ogg b/src/main/resources/assets/lotr/sounds/boss/combat.ogg similarity index 100% rename from src/main/resources/assets/cinder_loe/sounds/boss/Battle2.ogg rename to src/main/resources/assets/lotr/sounds/boss/combat.ogg diff --git a/src/main/resources/assets/cinder_loe/sounds/boss/Spiders.ogg b/src/main/resources/assets/lotr/sounds/boss/spiders.ogg similarity index 100% rename from src/main/resources/assets/cinder_loe/sounds/boss/Spiders.ogg rename to src/main/resources/assets/lotr/sounds/boss/spiders.ogg diff --git a/src/main/resources/assets/cinder_loe/sounds/boss/Victory.ogg b/src/main/resources/assets/lotr/sounds/boss/victory.ogg similarity index 100% rename from src/main/resources/assets/cinder_loe/sounds/boss/Victory.ogg rename to src/main/resources/assets/lotr/sounds/boss/victory.ogg diff --git a/src/main/resources/mixins.cinder_loe.json b/src/main/resources/mixins.cinder_loe.json index 8c513cd..9dec57c 100644 --- a/src/main/resources/mixins.cinder_loe.json +++ b/src/main/resources/mixins.cinder_loe.json @@ -43,6 +43,7 @@ "overrides.MixinLOTREntityWarg", "overrides.MixinLOTRHiredNPCInfo", "overrides.MixinLOTRReplacedMethods", + "overrides.MixinLOTRItemEntDraught", "overrides.MixinLOTRUnitTradeEntries" ], "client": []