|  |  |  | @ -10,6 +10,8 @@ import cpw.mods.fml.common.IFuelHandler; | 
		
	
		
			
				|  |  |  |  | import cpw.mods.fml.common.eventhandler.SubscribeEvent; | 
		
	
		
			
				|  |  |  |  | import cpw.mods.fml.common.gameevent.TickEvent; | 
		
	
		
			
				|  |  |  |  | import cpw.mods.fml.common.registry.GameRegistry; | 
		
	
		
			
				|  |  |  |  | import lotr.common.LOTRAchievement; | 
		
	
		
			
				|  |  |  |  | import lotr.common.LOTRLevelData; | 
		
	
		
			
				|  |  |  |  | import lotr.common.LOTRMod; | 
		
	
		
			
				|  |  |  |  | import lotr.common.LOTRDimension; | 
		
	
		
			
				|  |  |  |  | import lotr.common.enchant.LOTREnchantment; | 
		
	
	
		
			
				
					|  |  |  | @ -17,6 +19,7 @@ import lotr.common.enchant.LOTREnchantmentHelper; | 
		
	
		
			
				|  |  |  |  | import lotr.common.entity.npc.LOTREntityOrc; | 
		
	
		
			
				|  |  |  |  | import lotr.common.entity.projectile.LOTREntityCrossbowBolt; | 
		
	
		
			
				|  |  |  |  | import lotr.common.entity.projectile.LOTREntityDart; | 
		
	
		
			
				|  |  |  |  | import lotr.common.entity.projectile.LOTREntitySpear; | 
		
	
		
			
				|  |  |  |  | import lotr.common.item.*; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.entity.Entity; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.entity.EntityLivingBase; | 
		
	
	
		
			
				
					|  |  |  | @ -42,13 +45,7 @@ import net.minecraftforge.event.entity.player.ArrowLooseEvent; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import java.util.Random; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import static com.zivilon.cinder_loe.CinderLoE.getLOTRMaterialByName; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | public class CinderEventHandler implements IFuelHandler { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     private static final ItemArmor.ArmorMaterial MATERIAL_GILDEDGALVORN = | 
		
	
		
			
				|  |  |  |  |             getLOTRMaterialByName("GILDEDGALVORN").toArmorMaterial(); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     private static final Random random = new Random(); | 
		
	
		
			
				|  |  |  |  |     public  CinderEventHandler() { | 
		
	
		
			
				|  |  |  |  |         FMLCommonHandler.instance().bus().register(this); | 
		
	
	
		
			
				
					|  |  |  | @ -95,40 +92,45 @@ public class CinderEventHandler implements IFuelHandler { | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     private void cancelAttackEvent(LivingAttackEvent event) { | 
		
	
		
			
				|  |  |  |  |         event.setCanceled(true); | 
		
	
		
			
				|  |  |  |  |         DamageSource source = event.source; | 
		
	
		
			
				|  |  |  |  |         if (source instanceof EntityDamageSourceIndirect) { | 
		
	
		
			
				|  |  |  |  |             Entity entity = source.getSourceOfDamage(); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     @SubscribeEvent | 
		
	
		
			
				|  |  |  |  |     public void onLivingAttack(LivingAttackEvent event) { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     public void onLivingAttacked(LivingAttackEvent event) { | 
		
	
		
			
				|  |  |  |  |         EntityLivingBase entity = event.entityLiving; | 
		
	
		
			
				|  |  |  |  |         EntityLivingBase attacker = event.source.getEntity() instanceof EntityLivingBase ? (EntityLivingBase)event.source.getEntity() : null; | 
		
	
		
			
				|  |  |  |  |         World world = entity.worldObj; | 
		
	
		
			
				|  |  |  |  |         if (event.entityLiving.worldObj.isRemote) return; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         if (!(event.source instanceof EntityDamageSourceIndirect)) return; | 
		
	
		
			
				|  |  |  |  |         Entity projectile = event.source.getSourceOfDamage(); | 
		
	
		
			
				|  |  |  |  |         if (!(projectile instanceof EntityArrow | 
		
	
		
			
				|  |  |  |  |                 || projectile instanceof LOTREntityCrossbowBolt | 
		
	
		
			
				|  |  |  |  |                 || projectile instanceof LOTREntityDart)) { | 
		
	
		
			
				|  |  |  |  |             boolean wearingAllGalvorn = true; | 
		
	
		
			
				|  |  |  |  |             for (int slot = 1; slot <= 4; slot++) { | 
		
	
		
			
				|  |  |  |  |                 ItemStack armour = entity.getEquipmentInSlot(slot); | 
		
	
		
			
				|  |  |  |  |                 if (armour != null && armour.getItem() instanceof ItemArmor && ((ItemArmor)armour.getItem()).getArmorMaterial() == MATERIAL_GILDEDGALVORN) continue; | 
		
	
		
			
				|  |  |  |  |                 wearingAllGalvorn = false; | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |             if (wearingAllGalvorn) { | 
		
	
		
			
				|  |  |  |  |         if (event.source instanceof EntityDamageSourceIndirect) { | 
		
	
		
			
				|  |  |  |  |             ItemStack chestplate; | 
		
	
		
			
				|  |  |  |  |             Entity projectile = event.source.getSourceOfDamage(); | 
		
	
		
			
				|  |  |  |  |             if (projectile instanceof EntityArrow || projectile instanceof LOTREntityCrossbowBolt || projectile instanceof LOTREntityDart) { | 
		
	
		
			
				|  |  |  |  |                 boolean wearingAllGalvorn = true; | 
		
	
		
			
				|  |  |  |  |                 for (int i = 0; i < 4; ++i) { | 
		
	
		
			
				|  |  |  |  |                     ItemStack armour = entity.getEquipmentInSlot(i + 1); | 
		
	
		
			
				|  |  |  |  |                     if (armour != null && armour.getItem() instanceof ItemArmor && ((ItemArmor)armour.getItem()).getArmorMaterial() == LOTRMaterial.GALVORN.toArmorMaterial()) continue; | 
		
	
		
			
				|  |  |  |  |                     wearingAllGalvorn = false; | 
		
	
		
			
				|  |  |  |  |                     break; | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
		
			
				|  |  |  |  |                 if (wearingAllGalvorn) { | 
		
	
		
			
				|  |  |  |  |                     if (!world.isRemote && entity instanceof EntityPlayer) { | 
		
	
		
			
				|  |  |  |  |                         ((EntityPlayer)entity).inventory.damageArmor(event.ammount); | 
		
	
		
			
				|  |  |  |  |                     } | 
		
	
		
			
				|  |  |  |  |                     this.cancelAttackEvent(event); | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |             if (!world.isRemote && entity instanceof EntityPlayer && attacker instanceof LOTREntityOrc && projectile instanceof LOTREntitySpear && (chestplate = entity.getEquipmentInSlot(3)) != null && chestplate.getItem() == LOTRMod.bodyMithril) { | 
		
	
		
			
				|  |  |  |  |                 LOTRLevelData.getData((EntityPlayer)entity).addAchievement(LOTRAchievement.hitByOrcSpear); | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     private void cancelAttackEvent(LivingAttackEvent event) { | 
		
	
		
			
				|  |  |  |  |         event.setCanceled(true); | 
		
	
		
			
				|  |  |  |  |         DamageSource source = event.source; | 
		
	
		
			
				|  |  |  |  |         if (source instanceof EntityDamageSourceIndirect) { | 
		
	
		
			
				|  |  |  |  |             Entity entity = source.getSourceOfDamage(); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     @SubscribeEvent | 
		
	
		
			
				|  |  |  |  |     public void onLivingAttack(LivingAttackEvent event) { | 
		
	
		
			
				|  |  |  |  |         Entity attacker = event.source.getEntity(); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         if (!(attacker instanceof EntityPlayerMP player)) return; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         ItemStack weapon = player.getHeldItem(); | 
		
	
	
		
			
				
					|  |  |  | 
 |