下面列出了net.minecraft.util.org.apache.commons.lang3.StringUtils#isNotEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public boolean isSuitableTarget(EntityLiving entityliving, boolean flag) {
if (entityliving == null) {
return false;
} else if (entityliving == this.getHandle()) {
return false;
} else if (!entityliving.isAlive()) {
return false;
} else if (!this.canAttackClass(entityliving.getClass())) {
return false;
} else {
if (this.getHandle() instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.getHandle()).getOwnerName())) {
if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.getHandle()).getOwnerName().equals(((EntityOwnable) entityliving).getOwnerName())) {
return false;
}
if (entityliving == ((EntityOwnable) this.getHandle()).getOwner()) {
return false;
}
} else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) {
return false;
}
if (!NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) {
return false;
} else if (this.checkSenses && !NMSEntityUtil.getEntitySenses(this.getHandle()).canSee(entityliving)) {
return false;
} else {
if (this.useMelee) {
if (--this.ticksAfterLastAttack <= 0) {
this.shouldAttack = 0;
}
if (this.shouldAttack == 0) {
this.shouldAttack = this.attack(entityliving) ? 1 : 2;
}
if (this.shouldAttack == 2) {
return false;
}
}
// CraftBukkit start - Check all the different target goals for the reason, default to RANDOM_TARGET
EntityTargetEvent.TargetReason reason = EntityTargetEvent.TargetReason.RANDOM_TARGET;
if (this instanceof BehaviourGoalDefendVillage) {
reason = EntityTargetEvent.TargetReason.DEFEND_VILLAGE;
} else if (this instanceof BehaviourGoalHurtByTarget) {
reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY;
} else if (this instanceof BehaviourGoalMoveTowardsNearestAttackableTarget) {
if (entityliving instanceof EntityHuman) {
reason = EntityTargetEvent.TargetReason.CLOSEST_PLAYER;
}
} else if (this instanceof BehaviourGoalDefendTamer) {
reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER;
} else if (this instanceof BehaviourGoalHelpTamerTarget) {
reason = EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET;
}
org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetLivingEvent(this.getHandle(), entityliving, reason);
if (event.isCancelled() || event.getTarget() == null) {
this.getControllableEntity().setTarget(null);
return false;
} else if (entityliving.getBukkitEntity() != event.getTarget()) {
this.getControllableEntity().setTarget(event.getTarget());
}
if (this.getHandle() instanceof EntityCreature) {
((EntityCreature) this.getHandle()).target = ((CraftEntity) event.getTarget()).getHandle();
}
// CraftBukkit end
return true;
}
}
}
public boolean isSuitableTarget(EntityLiving entityliving, boolean flag) {
if (entityliving == null) {
return false;
} else if (entityliving == this.getHandle()) {
return false;
} else if (!entityliving.isAlive()) {
return false;
} else if (!this.canAttackClass(entityliving.getClass())) {
return false;
} else {
if (this.getHandle() instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.getHandle()).getOwnerName())) {
if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.getHandle()).getOwnerName().equals(((EntityOwnable) entityliving).getOwnerName())) {
return false;
}
if (entityliving == ((EntityOwnable) this.getHandle()).getOwner()) {
return false;
}
} else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) {
return false;
}
if (!NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) {
return false;
} else if (this.checkSenses && !NMSEntityUtil.getEntitySenses(this.getHandle()).canSee(entityliving)) {
return false;
} else {
if (this.useMelee) {
if (--this.ticksAfterLastAttack <= 0) {
this.shouldAttack = 0;
}
if (this.shouldAttack == 0) {
this.shouldAttack = this.attack(entityliving) ? 1 : 2;
}
if (this.shouldAttack == 2) {
return false;
}
}
// CraftBukkit start - Check all the different target goals for the reason, default to RANDOM_TARGET
EntityTargetEvent.TargetReason reason = EntityTargetEvent.TargetReason.RANDOM_TARGET;
if (this instanceof BehaviourGoalDefendVillage) {
reason = EntityTargetEvent.TargetReason.DEFEND_VILLAGE;
} else if (this instanceof BehaviourGoalHurtByTarget) {
reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY;
} else if (this instanceof BehaviourGoalMoveTowardsNearestAttackableTarget) {
if (entityliving instanceof EntityHuman) {
reason = EntityTargetEvent.TargetReason.CLOSEST_PLAYER;
}
} else if (this instanceof BehaviourGoalDefendTamer) {
reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER;
} else if (this instanceof BehaviourGoalHelpTamerTarget) {
reason = EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET;
}
org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetLivingEvent(this.getHandle(), entityliving, reason);
if (event.isCancelled() || event.getTarget() == null) {
this.getControllableEntity().setTarget(null);
return false;
} else if (entityliving.getBukkitEntity() != event.getTarget()) {
this.getControllableEntity().setTarget(event.getTarget());
}
if (this.getHandle() instanceof EntityCreature) {
((EntityCreature) this.getHandle()).target = ((CraftEntity) event.getTarget()).getHandle();
}
// CraftBukkit end
return true;
}
}
}
public boolean isSuitableTarget(EntityLiving entityliving, boolean flag) {
if (entityliving == null) {
return false;
} else if (entityliving == this.getHandle()) {
return false;
} else if (!entityliving.isAlive()) {
return false;
} else if (!this.canAttackClass(entityliving.getClass())) {
return false;
} else {
if (this.getHandle() instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.getHandle()).getOwnerName())) {
if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.getHandle()).getOwnerName().equals(((EntityOwnable) entityliving).getOwnerName())) {
return false;
}
if (entityliving == ((EntityOwnable) this.getHandle()).getOwner()) {
return false;
}
} else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) {
return false;
}
if (!NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) {
return false;
} else if (this.checkSenses && !NMSEntityUtil.getEntitySenses(this.getHandle()).canSee(entityliving)) {
return false;
} else {
if (this.useMelee) {
if (--this.ticksAfterLastAttack <= 0) {
this.shouldAttack = 0;
}
if (this.shouldAttack == 0) {
this.shouldAttack = this.attack(entityliving) ? 1 : 2;
}
if (this.shouldAttack == 2) {
return false;
}
}
// CraftBukkit start - Check all the different target goals for the reason, default to RANDOM_TARGET
EntityTargetEvent.TargetReason reason = EntityTargetEvent.TargetReason.RANDOM_TARGET;
if (this instanceof BehaviourGoalDefendVillage) {
reason = EntityTargetEvent.TargetReason.DEFEND_VILLAGE;
} else if (this instanceof BehaviourGoalHurtByTarget) {
reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY;
} else if (this instanceof BehaviourGoalMoveTowardsNearestAttackableTarget) {
if (entityliving instanceof EntityHuman) {
reason = EntityTargetEvent.TargetReason.CLOSEST_PLAYER;
}
} else if (this instanceof BehaviourGoalDefendTamer) {
reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER;
} else if (this instanceof BehaviourGoalHelpTamerTarget) {
reason = EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET;
}
org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callEntityTargetLivingEvent(this.getHandle(), entityliving, reason);
if (event.isCancelled() || event.getTarget() == null) {
this.getControllableEntity().setTarget(null);
return false;
} else if (entityliving.getBukkitEntity() != event.getTarget()) {
this.getControllableEntity().setTarget(event.getTarget());
}
if (this.getHandle() instanceof EntityCreature) {
((EntityCreature) this.getHandle()).target = ((CraftEntity) event.getTarget()).getHandle();
}
// CraftBukkit end
return true;
}
}
}
public boolean isSuitableTarget(EntityLiving entityliving, boolean flag) {
if (entityliving == null) {
return false;
} else if (entityliving == this.getHandle()) {
return false;
} else if (!entityliving.isAlive()) {
return false;
} else if (!this.canAttackClass(entityliving.getClass())) {
return false;
} else {
if (this.getHandle() instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.getHandle()).getOwnerName())) {
if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.getHandle()).getOwnerName().equals(((EntityOwnable) entityliving).getOwnerName())) {
return false;
}
if (entityliving == ((EntityOwnable) this.getHandle()).getOwner()) {
return false;
}
} else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) {
return false;
}
if (!NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) {
return false;
} else if (this.checkSenses && !NMSEntityUtil.getEntitySenses(this.getHandle()).canSee(entityliving)) {
return false;
} else {
if (this.useMelee) {
if (--this.ticksAfterLastAttack <= 0) {
this.shouldAttack = 0;
}
if (this.shouldAttack == 0) {
this.shouldAttack = this.attack(entityliving) ? 1 : 2;
}
if (this.shouldAttack == 2) {
return false;
}
}
// CraftBukkit start - Check all the different target goals for the reason, default to RANDOM_TARGET
EntityTargetEvent.TargetReason reason = EntityTargetEvent.TargetReason.RANDOM_TARGET;
if (this instanceof BehaviourGoalDefendVillage) {
reason = EntityTargetEvent.TargetReason.DEFEND_VILLAGE;
} else if (this instanceof BehaviourGoalHurtByTarget) {
reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY;
} else if (this instanceof BehaviourGoalMoveTowardsNearestAttackableTarget) {
if (entityliving instanceof EntityHuman) {
reason = EntityTargetEvent.TargetReason.CLOSEST_PLAYER;
}
} else if (this instanceof BehaviourGoalDefendTamer) {
reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER;
} else if (this instanceof BehaviourGoalHelpTamerTarget) {
reason = EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET;
}
org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetLivingEvent(this.getHandle(), entityliving, reason);
if (event.isCancelled() || event.getTarget() == null) {
this.getControllableEntity().setTarget(null);
return false;
} else if (entityliving.getBukkitEntity() != event.getTarget()) {
this.getControllableEntity().setTarget(event.getTarget());
}
if (this.getHandle() instanceof EntityCreature) {
((EntityCreature) this.getHandle()).target = ((CraftEntity) event.getTarget()).getHandle();
}
// CraftBukkit end
return true;
}
}
}
public boolean isSuitableTarget(EntityLiving entityliving, boolean flag) {
if (entityliving == null) {
return false;
} else if (entityliving == this.handle) {
return false;
} else if (!entityliving.isAlive()) {
return false;
} else if (!this.canAttackClass(entityliving.getClass())) {
return false;
} else {
if (this.handle instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.handle).getOwnerUUID())) {
if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.handle).getOwnerUUID().equals(((EntityOwnable) entityliving).getOwnerUUID())) {
return false;
}
if (entityliving == ((EntityOwnable) this.handle).getOwner()) {
return false;
}
} else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) {
return false;
}
if (!NMSEntityUtil.isInGuardedAreaOf(this.handle, MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) {
return false;
} else if (this.checkSenses && !NMSEntityUtil.getEntitySenses(this.handle).canSee(entityliving)) {
return false;
} else {
if (this.useMelee) {
if (--this.ticksAfterLastAttack <= 0) {
this.shouldAttack = 0;
}
if (this.shouldAttack == 0) {
this.shouldAttack = this.attack(entityliving) ? 1 : 2;
}
if (this.shouldAttack == 2) {
return false;
}
}
return true;
}
}
}
public boolean isSuitableTarget(EntityLiving entityliving, boolean flag) {
if (entityliving == null) {
return false;
} else if (entityliving == this.handle) {
return false;
} else if (!entityliving.isAlive()) {
return false;
} else if (!this.canAttackClass(entityliving.getClass())) {
return false;
} else {
if (this.handle instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.handle).getOwnerUUID())) {
if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.handle).getOwnerUUID().equals(((EntityOwnable) entityliving).getOwnerUUID())) {
return false;
}
if (entityliving == ((EntityOwnable) this.handle).getOwner()) {
return false;
}
} else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) {
return false;
}
if (!NMSEntityUtil.isInGuardedAreaOf(this.handle, MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) {
return false;
} else if (this.checkSenses && !NMSEntityUtil.getEntitySenses(this.handle).canSee(entityliving)) {
return false;
} else {
if (this.useMelee) {
if (--this.ticksAfterLastAttack <= 0) {
this.shouldAttack = 0;
}
if (this.shouldAttack == 0) {
this.shouldAttack = this.attack(entityliving) ? 1 : 2;
}
if (this.shouldAttack == 2) {
return false;
}
}
return true;
}
}
}
public boolean isSuitableTarget(EntityLiving entityliving, boolean flag) {
if (entityliving == null) {
return false;
} else if (entityliving == this.handle) {
return false;
} else if (!entityliving.isAlive()) {
return false;
} else if (!this.canAttackClass(entityliving.getClass())) {
return false;
} else {
if (this.handle instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.handle).getOwnerName())) {
if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.handle).getOwnerName().equals(((EntityOwnable) entityliving).getOwnerName())) {
return false;
}
if (entityliving == ((EntityOwnable) this.handle).getOwner()) {
return false;
}
} else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) {
return false;
}
if (!NMSEntityUtil.isInGuardedAreaOf(this.handle, MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) {
return false;
} else if (this.checkSenses && !NMSEntityUtil.getEntitySenses(this.handle).canSee(entityliving)) {
return false;
} else {
if (this.useMelee) {
if (--this.ticksAfterLastAttack <= 0) {
this.shouldAttack = 0;
}
if (this.shouldAttack == 0) {
this.shouldAttack = this.attack(entityliving) ? 1 : 2;
}
if (this.shouldAttack == 2) {
return false;
}
}
return true;
}
}
}
public boolean isSuitableTarget(EntityLiving entityliving, boolean flag) {
if (entityliving == null) {
return false;
} else if (entityliving == this.handle) {
return false;
} else if (!entityliving.isAlive()) {
return false;
} else if (!this.canAttackClass(entityliving.getClass())) {
return false;
} else {
if (this.handle instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.handle).getOwnerName())) {
if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.handle).getOwnerName().equals(((EntityOwnable) entityliving).getOwnerName())) {
return false;
}
if (entityliving == ((EntityOwnable) this.handle).getOwner()) {
return false;
}
} else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) {
return false;
}
if (!NMSEntityUtil.isInGuardedAreaOf(this.handle, MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) {
return false;
} else if (this.checkSenses && !NMSEntityUtil.getEntitySenses(this.handle).canSee(entityliving)) {
return false;
} else {
if (this.useMelee) {
if (--this.ticksAfterLastAttack <= 0) {
this.shouldAttack = 0;
}
if (this.shouldAttack == 0) {
this.shouldAttack = this.attack(entityliving) ? 1 : 2;
}
if (this.shouldAttack == 2) {
return false;
}
}
return true;
}
}
}