Java Code Examples for net.minecraft.entity.ai.EntityAINearestAttackableTarget#Sorter

The following examples show how to use net.minecraft.entity.ai.EntityAINearestAttackableTarget#Sorter . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityAINearestAttackableCivTarget.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
public EntityAINearestAttackableCivTarget(EntityToroNpc npc) {
	super(npc, false, false);

	this.taskOwner = npc;
	this.theNearestAttackableTargetSorter = new EntityAINearestAttackableTarget.Sorter(npc);
	this.setMutexBits(1);

	this.targetEntitySelector = new Predicate<EntityPlayer>() {
		public boolean apply(@Nullable EntityPlayer target) {

			if (target == null) {
				return false;
			}

			if (!EntitySelectors.NOT_SPECTATING.apply(target)) {
				return false;
			}

			if (!isSuitableTarget(taskOwner, target, false, true)) {
				return false;
			}

			return shouldAttackPlayerBasedOnCivilization(target);
		}
	};
}
 
Example 2
Source File: EntityAINearestAttackableTargetFiltered.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public EntityAINearestAttackableTargetFiltered(EntityCreature creature, Class<T> classTarget, int chance, boolean checkSight, boolean onlyNearby, @Nullable final Predicate<? super T> targetSelector) {
	super(creature, checkSight, onlyNearby);
	this.targetClass = classTarget;
	this.targetChance = chance;
	this.sorter = new EntityAINearestAttackableTarget.Sorter(creature);
	this.setMutexBits(1);

	UUID exclude = creature.getEntityData().getUniqueId("owner");

	this.targetEntitySelector = (Predicate<T>) entity -> (entity != null && !entity.getUniqueID().equals(exclude)) && (targetSelector == null || targetSelector.apply(entity) && (EntitySelectors.NOT_SPECTATING.apply(entity) && EntityAINearestAttackableTargetFiltered.this.isSuitableTarget(entity, false)));
}
 
Example 3
Source File: EntityEndermite.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
public EntityEndermite(World world) {
	super(world);
	sorter = new EntityAINearestAttackableTarget.Sorter(this);

	experienceValue = 3;
	setSize(0.4F, 0.3F);
	tasks.addTask(1, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
	tasks.addTask(3, new EntityAIWander(this, 1.0D));
	tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(8, new EntityAILookIdle(this));
	targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
	targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 10, true));
}
 
Example 4
Source File: DroneAINearestAttackableTarget.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public DroneAINearestAttackableTarget(EntityDrone drone, boolean checkSight, boolean easyTargetsOnly,
        ProgWidget widget){
    super(drone, checkSight, easyTargetsOnly);
    this.drone = drone;
    this.widget = widget;
    theNearestAttackableTargetSorter = new EntityAINearestAttackableTarget.Sorter(drone);
    setMutexBits(1);
}