All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.PathfinderGoalHurtByTarget Maven / Gradle / Ivy

package net.minecraft.server;

import java.util.List;

public class PathfinderGoalHurtByTarget extends PathfinderGoalTarget {
	
	private final Class[] c;
	private final boolean a;
	private int b;
	
	public PathfinderGoalHurtByTarget(EntityCreature entitycreature, boolean flag, Class... aclass) {
		super(entitycreature, false);
		this.a = flag;
		this.c = aclass;
		this.setMutexBits(1);
	}
	
	public boolean a() {
		int i = this.e.getHurtTimestamp();
		
		return i != this.b && this.a(this.e.getLastDamager(), false);
	}
	
	public void c() {
		this.e.setGoalTarget(this.e.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
		this.b = this.e.getHurtTimestamp();
		if (this.a) {
			double d0 = this.f();
			List list = this.e.world.a(this.e.getClass(), (new AxisAlignedBB(this.e.locX, this.e.locY, this.e.locZ, this.e.locX + 1.0D, this.e.locY + 1.0D, this.e.locZ + 1.0D)).grow(d0, 10.0D, d0));
			
			for (EntityCreature entitycreature : list) {
				if (this.e != entitycreature && entitycreature.getGoalTarget() == null && !entitycreature.isOnSameTeam(this.e.getLastDamager())) {
					boolean flag = false;
					Class[] aclass = this.c;
					int i = aclass.length;
					
					for (Class oclass : aclass) {
						if (entitycreature.getClass() == oclass) {
							flag = true;
							break;
						}
					}
					
					if (!flag) {
						this.a(entitycreature, this.e.getLastDamager());
					}
				}
			}
		}
		
		super.c();
	}
	
	protected void a(EntityCreature entitycreature, EntityLiving entityliving) {
		entitycreature.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy