|  |  |  | @ -11,6 +11,7 @@ import lotr.common.entity.ai.LOTREntityAINearestAttackableTargetBasic; | 
		
	
		
			
				|  |  |  |  | import lotr.common.entity.ai.LOTREntityAINearestAttackableTargetBasic.TargetSorter; | 
		
	
		
			
				|  |  |  |  | import lotr.common.entity.npc.LOTREntityNPC; | 
		
	
		
			
				|  |  |  |  | import lotr.common.entity.npc.LOTREntityNPCRideable; | 
		
	
		
			
				|  |  |  |  | import lotr.common.item.LOTRItemArmor; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import net.minecraft.command.IEntitySelector; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.entity.Entity; | 
		
	
	
		
			
				
					|  |  |  | @ -18,32 +19,32 @@ import net.minecraft.entity.EntityCreature; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.entity.EntityLivingBase; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.entity.ai.EntityAITarget; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.entity.player.EntityPlayer; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.item.ItemStack; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.world.World; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import org.spongepowered.asm.mixin.*; | 
		
	
		
			
				|  |  |  |  | import org.spongepowered.asm.mixin.injection.*; | 
		
	
		
			
				|  |  |  |  | import org.spongepowered.asm.mixin.injection.callback.*; | 
		
	
		
			
				|  |  |  |  | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import java.util.UUID; | 
		
	
		
			
				|  |  |  |  | import java.util.Collections; | 
		
	
		
			
				|  |  |  |  | import java.util.List; | 
		
	
		
			
				|  |  |  |  | import java.util.UUID; | 
		
	
		
			
				|  |  |  |  | import net.minecraft.util.ChatComponentText; | 
		
	
		
			
				|  |  |  |  | import lotr.common.enchant.LOTREnchantment; | 
		
	
		
			
				|  |  |  |  | import lotr.common.enchant.LOTREnchantmentHelper; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | @Mixin(LOTREntityAINearestAttackableTargetBasic.class) | 
		
	
		
			
				|  |  |  |  | public abstract class MixinLOTREntityAINearestAttackableTargetBasic extends EntityAITarget { | 
		
	
		
			
				|  |  |  |  |     @Shadow | 
		
	
		
			
				|  |  |  |  |     private final Class targetClass; | 
		
	
		
			
				|  |  |  |  |     @Shadow | 
		
	
		
			
				|  |  |  |  |     private EntityLivingBase targetEntity; | 
		
	
		
			
				|  |  |  |  |     @Shadow | 
		
	
		
			
				|  |  |  |  |     private final TargetSorter targetSorter; | 
		
	
		
			
				|  |  |  |  |     @Shadow | 
		
	
		
			
				|  |  |  |  |     private final IEntitySelector targetSelector; | 
		
	
		
			
				|  |  |  |  |     @Shadow | 
		
	
		
			
				|  |  |  |  |     private final int targetChance; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Shadow private final Class targetClass; | 
		
	
		
			
				|  |  |  |  |     @Shadow private EntityLivingBase targetEntity; | 
		
	
		
			
				|  |  |  |  |     @Shadow private final TargetSorter targetSorter; | 
		
	
		
			
				|  |  |  |  |     @Shadow private final IEntitySelector targetSelector; | 
		
	
		
			
				|  |  |  |  |     @Shadow private final int targetChance; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     public MixinLOTREntityAINearestAttackableTargetBasic(EntityCreature p_i1669_1_, boolean p_i1669_2_) { | 
		
	
		
			
				|  |  |  |  |         super(p_i1669_1_, p_i1669_2_); | 
		
	
		
			
				|  |  |  |  |         targetClass = null; // Should never get applied because constructors can't be overwritten
 | 
		
	
		
			
				|  |  |  |  |         targetClass = null; | 
		
	
		
			
				|  |  |  |  |         targetEntity = null; | 
		
	
		
			
				|  |  |  |  |         targetSorter = null; | 
		
	
		
			
				|  |  |  |  |         targetSelector = null; | 
		
	
	
		
			
				
					|  |  |  | @ -109,7 +110,44 @@ public abstract class MixinLOTREntityAINearestAttackableTargetBasic extends Enti | 
		
	
		
			
				|  |  |  |  |     protected boolean isPlayerSuitableAlignmentTarget(EntityPlayer entityplayer) { | 
		
	
		
			
				|  |  |  |  |         float alignment = LOTRLevelData.getData(entityplayer).getAlignment(LOTRMod.getNPCFaction((Entity)this.taskOwner)); | 
		
	
		
			
				|  |  |  |  |         if (entityplayer == null || LoEPotions.corrupting == null) return alignment < 0.0F; | 
		
	
		
			
				|  |  |  |  |         boolean corrupting = entityplayer.isPotionActive(LoEPotions.corrupting); // Needs to be implemented
 | 
		
	
		
			
				|  |  |  |  |         boolean corrupting = entityplayer.isPotionActive(LoEPotions.corrupting); | 
		
	
		
			
				|  |  |  |  |         return (alignment < 0.0F || corrupting); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Inject(method = "isPlayerSuitableTarget", at = @At("HEAD"), cancellable = true, remap = false) | 
		
	
		
			
				|  |  |  |  | private void cinderloe$applyStealthModifier(EntityPlayer player, CallbackInfoReturnable<Boolean> cir) { | 
		
	
		
			
				|  |  |  |  |     int stealthPieces = 0; | 
		
	
		
			
				|  |  |  |  |     System.out.println("Test 1"); | 
		
	
		
			
				|  |  |  |  | ((EntityPlayer)player).addChatMessage(new ChatComponentText("Tested detection")); // Only if there is a player or target instance to refer to.
 | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | for (ItemStack armor : player.inventory.armorInventory) { | 
		
	
		
			
				|  |  |  |  |     System.out.println("Checking armor piece"); | 
		
	
		
			
				|  |  |  |  |     if (armor != null && armor.getItem() instanceof LOTRItemArmor && armor.stackTagCompound != null) { | 
		
	
		
			
				|  |  |  |  |         System.out.println("Found armor piece, testing if it has stealth modifier"); | 
		
	
		
			
				|  |  |  |  |         if (LOTREnchantmentHelper.hasEnchant(armor, LOTREnchantment.getEnchantmentByName("stealth"))) { | 
		
	
		
			
				|  |  |  |  |             System.out.println("Found modifier on armor piece"); | 
		
	
		
			
				|  |  |  |  |             stealthPieces++; | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     System.out.println("Test 2"); | 
		
	
		
			
				|  |  |  |  |     ((EntityPlayer)player).addChatMessage(new ChatComponentText("Tested detection1")); // Only if there is a player or target instance to refer to.
 | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     if (stealthPieces > 0 && taskOwner != null) { | 
		
	
		
			
				|  |  |  |  |         double baseDetectionRange = taskOwner.getEntityAttribute(net.minecraft.entity.SharedMonsterAttributes.followRange).getAttributeValue(); | 
		
	
		
			
				|  |  |  |  |         double multiplier = 1.0 - (0.15 * stealthPieces); | 
		
	
		
			
				|  |  |  |  |         double effectiveRangeSq = (baseDetectionRange * multiplier) * (baseDetectionRange * multiplier); | 
		
	
		
			
				|  |  |  |  |         double distanceSq = taskOwner.getDistanceSqToEntity(player); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         System.out.println("Test 3"); | 
		
	
		
			
				|  |  |  |  | ((EntityPlayer)player).addChatMessage(new ChatComponentText("Tested detection3")); // Only if there is a player or target instance to refer to.
 | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         if (distanceSq > effectiveRangeSq) { | 
		
	
		
			
				|  |  |  |  |             cir.setReturnValue(false); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     System.out.println("Test 4"); | 
		
	
		
			
				|  |  |  |  | ((EntityPlayer)player).addChatMessage(new ChatComponentText("Tested detection4")); // Only if there is a player or target instance to refer to.
 | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
	
		
			
				
					|  |  |  | 
 |