2
0
Fork 0

Blocking Change

frozen
KeyLime17 1 year ago
parent 310ca6220c
commit 8e5cf0d0fc

@ -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) {

@ -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);
}
}

@ -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);

@ -43,6 +43,7 @@
"overrides.MixinLOTREntityWarg",
"overrides.MixinLOTRHiredNPCInfo",
"overrides.MixinLOTRReplacedMethods",
"overrides.MixinLOTRItemEntDraught",
"overrides.MixinLOTRUnitTradeEntries"
],
"client": []

Loading…
Cancel
Save