|
|
|
|
@ -9,6 +9,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|
|
|
|
import lotr.common.LOTRMod;
|
|
|
|
|
import lotr.common.enchant.LOTREnchantment;
|
|
|
|
|
import lotr.common.enchant.LOTREnchantmentHelper;
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
|
import net.minecraft.entity.IEntityLivingData;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
|
@ -23,6 +24,7 @@ import net.minecraft.util.ChatComponentText;
|
|
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
|
|
|
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
|
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
@ -35,31 +37,40 @@ public class CinderEventHandler implements IFuelHandler {
|
|
|
|
|
MinecraftForge.TERRAIN_GEN_BUS.register(this);
|
|
|
|
|
GameRegistry.registerFuelHandler(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onLivingHurt(LivingHurtEvent event) {
|
|
|
|
|
EntityLivingBase entity = event.entityLiving;
|
|
|
|
|
EntityLivingBase attacker = event.source.getEntity() instanceof EntityLivingBase ? (EntityLivingBase) event.source.getEntity() : null;
|
|
|
|
|
public void onLivingAttack(LivingAttackEvent event) {
|
|
|
|
|
EntityLivingBase entity = event.entityLiving;;
|
|
|
|
|
Entity sourceEntity = event.source.getEntity();
|
|
|
|
|
World world = entity.worldObj;
|
|
|
|
|
|
|
|
|
|
// Negative Arrow Protection Handler
|
|
|
|
|
// Negative Arrow Protection Handle
|
|
|
|
|
if (event.source.isProjectile() && entity instanceof EntityPlayerMP) {
|
|
|
|
|
EntityPlayerMP player = (EntityPlayerMP) entity;
|
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "DEBUG: Original Damage: " + (event.ammount)));
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
ItemStack armor = entity.getEquipmentInSlot(i + 1);
|
|
|
|
|
|
|
|
|
|
if (armor != null) {
|
|
|
|
|
LOTREnchantment enchantment = LOTREnchantment.getEnchantmentByName("protectRangedWeak1");
|
|
|
|
|
if (LOTREnchantmentHelper.hasEnchant(armor, enchantment)) {
|
|
|
|
|
float level = enchantment.getValueModifier();
|
|
|
|
|
if (level > 0) {
|
|
|
|
|
float additionalDamage = level * 0.2f; // 20% more damage per level
|
|
|
|
|
event.ammount += additionalDamage;
|
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Your armor has received a negative modifier!"));
|
|
|
|
|
float additionalDamage = level * 0.2f; //20% more damage per level
|
|
|
|
|
event.setCanceled(true);
|
|
|
|
|
entity.attackEntityFrom(event.source, event.ammount + additionalDamage);
|
|
|
|
|
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: damage received, total damage: " + (event.ammount + additionalDamage)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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;
|
|
|
|
|
|
|
|
|
|
// Broken Halo Event handler
|
|
|
|
|
if (attacker != null && event.source.getSourceOfDamage() == attacker) {
|
|
|
|
|
|