|  |  | @ -11,7 +11,6 @@ import lotr.common.entity.ai.LOTREntityAINearestAttackableTargetBasic; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lotr.common.entity.ai.LOTREntityAINearestAttackableTargetBasic.TargetSorter; |  |  |  | import lotr.common.entity.ai.LOTREntityAINearestAttackableTargetBasic.TargetSorter; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lotr.common.entity.npc.LOTREntityNPC; |  |  |  | import lotr.common.entity.npc.LOTREntityNPC; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lotr.common.entity.npc.LOTREntityNPCRideable; |  |  |  | import lotr.common.entity.npc.LOTREntityNPCRideable; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lotr.common.item.LOTRItemArmor; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.minecraft.command.IEntitySelector; |  |  |  | import net.minecraft.command.IEntitySelector; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.minecraft.entity.Entity; |  |  |  | import net.minecraft.entity.Entity; | 
			
		
	
	
		
		
			
				
					|  |  | @ -19,32 +18,32 @@ import net.minecraft.entity.EntityCreature; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.minecraft.entity.EntityLivingBase; |  |  |  | import net.minecraft.entity.EntityLivingBase; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.minecraft.entity.ai.EntityAITarget; |  |  |  | import net.minecraft.entity.ai.EntityAITarget; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.minecraft.entity.player.EntityPlayer; |  |  |  | import net.minecraft.entity.player.EntityPlayer; | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.minecraft.item.ItemStack; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import net.minecraft.world.World; |  |  |  | import net.minecraft.world.World; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.spongepowered.asm.mixin.*; |  |  |  | import org.spongepowered.asm.mixin.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.spongepowered.asm.mixin.injection.*; |  |  |  | import org.spongepowered.asm.mixin.injection.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |  |  |  | import org.spongepowered.asm.mixin.injection.callback.*; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.util.UUID; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Collections; |  |  |  | import java.util.Collections; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.List; |  |  |  | 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) |  |  |  | @Mixin(LOTREntityAINearestAttackableTargetBasic.class) | 
			
		
	
		
		
			
				
					
					|  |  |  | public abstract class MixinLOTREntityAINearestAttackableTargetBasic extends EntityAITarget { |  |  |  | public abstract class MixinLOTREntityAINearestAttackableTargetBasic extends EntityAITarget { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |     @Shadow | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     @Shadow private final Class targetClass; |  |  |  |     private final Class targetClass; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     @Shadow private EntityLivingBase targetEntity; |  |  |  |     @Shadow | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     @Shadow private final TargetSorter targetSorter; |  |  |  |     private EntityLivingBase targetEntity; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     @Shadow private final IEntitySelector targetSelector; |  |  |  |     @Shadow | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     @Shadow private final int targetChance; |  |  |  |     private final TargetSorter targetSorter; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Shadow | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private final IEntitySelector targetSelector; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Shadow | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private final int targetChance; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public MixinLOTREntityAINearestAttackableTargetBasic(EntityCreature p_i1669_1_, boolean p_i1669_2_) { |  |  |  |     public MixinLOTREntityAINearestAttackableTargetBasic(EntityCreature p_i1669_1_, boolean p_i1669_2_) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         super(p_i1669_1_, p_i1669_2_); |  |  |  |         super(p_i1669_1_, p_i1669_2_); | 
			
		
	
		
		
			
				
					
					|  |  |  |         targetClass = null; |  |  |  |         targetClass = null; // Should never get applied because constructors can't be overwritten
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         targetEntity = null; |  |  |  |         targetEntity = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |         targetSorter = null; |  |  |  |         targetSorter = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |         targetSelector = null; |  |  |  |         targetSelector = null; | 
			
		
	
	
		
		
			
				
					|  |  | @ -103,51 +102,14 @@ public abstract class MixinLOTREntityAINearestAttackableTargetBasic extends Enti | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @author Shinare |  |  |  |     * @author Shinare | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |      * @reason Added corrupting potion effect that makes all NPCs hostile |  |  |  |     * @reason Added corrupting potion effect that makes all NPCs hostile | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |     */ | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     @Overwrite(remap = false) |  |  |  |     @Overwrite(remap = false) | 
			
		
	
		
		
			
				
					
					|  |  |  |     protected boolean isPlayerSuitableAlignmentTarget(EntityPlayer entityplayer) { |  |  |  |     protected boolean isPlayerSuitableAlignmentTarget(EntityPlayer entityplayer) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         float alignment = LOTRLevelData.getData(entityplayer).getAlignment(LOTRMod.getNPCFaction((Entity)this.taskOwner)); |  |  |  |         float alignment = LOTRLevelData.getData(entityplayer).getAlignment(LOTRMod.getNPCFaction((Entity)this.taskOwner)); | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (entityplayer == null || LoEPotions.corrupting == null) return alignment < 0.0F; |  |  |  |         if (entityplayer == null || LoEPotions.corrupting == null) return alignment < 0.0F; | 
			
		
	
		
		
			
				
					
					|  |  |  |         boolean corrupting = entityplayer.isPotionActive(LoEPotions.corrupting); |  |  |  |         boolean corrupting = entityplayer.isPotionActive(LoEPotions.corrupting); // Needs to be implemented
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         return (alignment < 0.0F || 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.
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |