mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 15:04:06 +01:00
Add set/isAware to disable Vanilla AI components of a Mob
This commit is contained in:
parent
918061b75c
commit
ab85433d7f
@ -28,7 +28,16 @@
|
|||||||
public boolean persistent;
|
public boolean persistent;
|
||||||
private final Map<PathType, Float> bB;
|
private final Map<PathType, Float> bB;
|
||||||
public MinecraftKey lootTableKey;
|
public MinecraftKey lootTableKey;
|
||||||
@@ -63,6 +75,9 @@
|
@@ -40,6 +52,8 @@
|
||||||
|
private BlockPosition bH;
|
||||||
|
private float bI;
|
||||||
|
|
||||||
|
+ public boolean aware = true; // CraftBukkit
|
||||||
|
+
|
||||||
|
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
|
||||||
|
super(entitytypes, world);
|
||||||
|
this.bx = NonNullList.a(2, ItemStack.a);
|
||||||
|
@@ -63,6 +77,9 @@
|
||||||
this.initPathfinder();
|
this.initPathfinder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void initPathfinder() {}
|
protected void initPathfinder() {}
|
||||||
@@ -130,7 +145,38 @@
|
@@ -130,7 +147,38 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
||||||
@ -77,7 +86,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -348,11 +394,20 @@
|
@@ -348,11 +396,20 @@
|
||||||
@Override
|
@Override
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
super.a(nbttagcompound);
|
super.a(nbttagcompound);
|
||||||
@ -100,7 +109,7 @@
|
|||||||
NBTTagList nbttaglist;
|
NBTTagList nbttaglist;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -406,6 +461,11 @@
|
@@ -406,6 +463,11 @@
|
||||||
super.a(damagesource, flag);
|
super.a(damagesource, flag);
|
||||||
this.lootTableKey = null;
|
this.lootTableKey = null;
|
||||||
}
|
}
|
||||||
@ -112,7 +121,7 @@
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) {
|
protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) {
|
||||||
@@ -465,11 +525,17 @@
|
@@ -465,11 +527,17 @@
|
||||||
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
||||||
boolean flag = this.a(itemstack, itemstack1, enumitemslot);
|
boolean flag = this.a(itemstack, itemstack1, enumitemslot);
|
||||||
|
|
||||||
@ -131,7 +140,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setSlot(enumitemslot, itemstack);
|
this.setSlot(enumitemslot, itemstack);
|
||||||
@@ -554,11 +620,11 @@
|
@@ -554,11 +622,11 @@
|
||||||
if (entityhuman != null) {
|
if (entityhuman != null) {
|
||||||
double d0 = entityhuman.h(this);
|
double d0 = entityhuman.h(this);
|
||||||
|
|
||||||
@ -145,7 +154,15 @@
|
|||||||
this.die();
|
this.die();
|
||||||
} else if (d0 < 1024.0D) {
|
} else if (d0 < 1024.0D) {
|
||||||
this.ticksFarFromPlayer = 0;
|
this.ticksFarFromPlayer = 0;
|
||||||
@@ -951,12 +1017,24 @@
|
@@ -573,6 +641,7 @@
|
||||||
|
@Override
|
||||||
|
protected final void doTick() {
|
||||||
|
++this.ticksFarFromPlayer;
|
||||||
|
+ if (!this.aware) return; // CraftBukkit
|
||||||
|
this.world.getMethodProfiler().enter("sensing");
|
||||||
|
this.bw.a();
|
||||||
|
this.world.getMethodProfiler().exit();
|
||||||
|
@@ -951,12 +1020,24 @@
|
||||||
if (!this.isAlive()) {
|
if (!this.isAlive()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (this.getLeashHolder() == entityhuman) {
|
} else if (this.getLeashHolder() == entityhuman) {
|
||||||
@ -170,7 +187,7 @@
|
|||||||
this.setLeashHolder(entityhuman, true);
|
this.setLeashHolder(entityhuman, true);
|
||||||
itemstack.subtract(1);
|
itemstack.subtract(1);
|
||||||
return true;
|
return true;
|
||||||
@@ -1002,6 +1080,7 @@
|
@@ -1002,6 +1083,7 @@
|
||||||
|
|
||||||
if (this.leashHolder != null) {
|
if (this.leashHolder != null) {
|
||||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||||
@ -178,7 +195,7 @@
|
|||||||
this.unleash(true, true);
|
this.unleash(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1017,7 +1096,9 @@
|
@@ -1017,7 +1099,9 @@
|
||||||
|
|
||||||
this.leashHolder = null;
|
this.leashHolder = null;
|
||||||
if (!this.world.isClientSide && flag1) {
|
if (!this.world.isClientSide && flag1) {
|
||||||
@ -188,7 +205,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.world.isClientSide && flag && this.world instanceof WorldServer) {
|
if (!this.world.isClientSide && flag && this.world instanceof WorldServer) {
|
||||||
@@ -1086,6 +1167,7 @@
|
@@ -1086,6 +1170,7 @@
|
||||||
|
|
||||||
this.setLeashHolder(EntityLeash.a(this.world, blockposition), true);
|
this.setLeashHolder(EntityLeash.a(this.world, blockposition), true);
|
||||||
} else {
|
} else {
|
||||||
@ -196,7 +213,7 @@
|
|||||||
this.unleash(false, true);
|
this.unleash(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1193,7 +1275,14 @@
|
@@ -1193,7 +1278,14 @@
|
||||||
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
@ -212,3 +229,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f);
|
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f);
|
||||||
|
@@ -1252,4 +1344,23 @@
|
||||||
|
public boolean a(Item item) {
|
||||||
|
return this.getItemInMainHand().getItem() == item || this.getItemInOffHand().getItem() == item;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ @Override
|
||||||
|
+ public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||||
|
+ super.save(nbttagcompound);
|
||||||
|
+
|
||||||
|
+ nbttagcompound.setBoolean("Bukkit.Aware", this.aware);
|
||||||
|
+ return nbttagcompound;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void f(NBTTagCompound nbttagcompound) { // PAIL rename load
|
||||||
|
+ super.f(nbttagcompound);
|
||||||
|
+
|
||||||
|
+ if (nbttagcompound.hasKey("Bukkit.Aware")) {
|
||||||
|
+ this.aware = nbttagcompound.getBoolean("Bukkit.Aware");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
}
|
||||||
|
@ -31,6 +31,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
|||||||
return (CraftLivingEntity) getHandle().getGoalTarget().getBukkitEntity();
|
return (CraftLivingEntity) getHandle().getGoalTarget().getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAware(boolean aware) {
|
||||||
|
getHandle().aware = aware;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAware() {
|
||||||
|
return getHandle().aware;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityInsentient getHandle() {
|
public EntityInsentient getHandle() {
|
||||||
return (EntityInsentient) entity;
|
return (EntityInsentient) entity;
|
||||||
|
Loading…
Reference in New Issue
Block a user