@@ -1,17 +1,17 @@
|
||||
--- a/net/minecraft/server/EntityInsentient.java
|
||||
+++ b/net/minecraft/server/EntityInsentient.java
|
||||
@@ -9,6 +9,18 @@
|
||||
@@ -10,6 +10,18 @@
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+import org.bukkit.event.entity.EntityUnleashEvent;
|
||||
+import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
|
||||
+// CraftBukkit end
|
||||
@@ -19,25 +19,25 @@
|
||||
public abstract class EntityInsentient extends EntityLiving {
|
||||
|
||||
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a);
|
||||
@@ -27,7 +39,7 @@
|
||||
@@ -28,7 +40,7 @@
|
||||
public final float[] dropChanceHand;
|
||||
private final NonNullList<ItemStack> by;
|
||||
private final NonNullList<ItemStack> bx;
|
||||
public final float[] dropChanceArmor;
|
||||
- private boolean canPickUpLoot;
|
||||
+ // private boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving
|
||||
public boolean persistent;
|
||||
private final Map<PathType, Float> bB;
|
||||
private final Map<PathType, Float> bA;
|
||||
public MinecraftKey lootTableKey;
|
||||
@@ -40,6 +52,8 @@
|
||||
private BlockPosition bH;
|
||||
private float bI;
|
||||
@@ -41,6 +53,8 @@
|
||||
private BlockPosition bG;
|
||||
private float bH;
|
||||
|
||||
+ 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.bw = NonNullList.a(2, ItemStack.b);
|
||||
@@ -64,6 +78,9 @@
|
||||
this.initPathfinder();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
}
|
||||
|
||||
protected void initPathfinder() {}
|
||||
@@ -130,7 +147,38 @@
|
||||
@@ -144,7 +161,38 @@
|
||||
}
|
||||
|
||||
public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
||||
@@ -86,7 +86,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -343,16 +391,26 @@
|
||||
@@ -361,16 +409,26 @@
|
||||
nbttagcompound.setBoolean("NoAI", this.isNoAI());
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
super.a(nbttagcompound);
|
||||
public void loadData(NBTTagCompound nbttagcompound) {
|
||||
super.loadData(nbttagcompound);
|
||||
+
|
||||
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
|
||||
if (nbttagcompound.hasKeyOfType("CanPickUpLoot", 1)) {
|
||||
@@ -115,7 +115,7 @@
|
||||
NBTTagList nbttaglist;
|
||||
int i;
|
||||
|
||||
@@ -399,6 +457,11 @@
|
||||
@@ -417,6 +475,11 @@
|
||||
}
|
||||
|
||||
this.setNoAI(nbttagcompound.getBoolean("NoAI"));
|
||||
@@ -127,7 +127,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -406,6 +469,11 @@
|
||||
@@ -424,6 +487,11 @@
|
||||
super.a(damagesource, flag);
|
||||
this.lootTableKey = null;
|
||||
}
|
||||
@@ -139,17 +139,38 @@
|
||||
|
||||
@Override
|
||||
protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) {
|
||||
@@ -465,11 +533,17 @@
|
||||
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
||||
boolean flag = this.a(itemstack, itemstack1, enumitemslot);
|
||||
@@ -480,7 +548,7 @@
|
||||
protected void b(EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
|
||||
- if (flag && this.g(itemstack)) {
|
||||
- if (this.g(itemstack)) {
|
||||
+ if (this.g(itemstack, entityitem)) { // CraftBukkit - add item
|
||||
this.a(entityitem);
|
||||
this.receive(entityitem, itemstack.getCount());
|
||||
entityitem.die();
|
||||
@@ -489,15 +557,29 @@
|
||||
}
|
||||
|
||||
public boolean g(ItemStack itemstack) {
|
||||
+ // CraftBukkit start - add item
|
||||
+ return this.g(itemstack, null);
|
||||
+ }
|
||||
+
|
||||
+ public boolean g(ItemStack itemstack, EntityItem entityitem) {
|
||||
+ // CraftBukkit end
|
||||
EnumItemSlot enumitemslot = j(itemstack);
|
||||
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
||||
boolean flag = this.a(itemstack, itemstack1);
|
||||
|
||||
- if (flag && this.canPickup(itemstack)) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean canPickup = flag && this.g(itemstack);
|
||||
+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled();
|
||||
+ boolean canPickup = flag && this.canPickup(itemstack);
|
||||
+ if (entityitem != null) {
|
||||
+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled();
|
||||
+ }
|
||||
+ if (canPickup) {
|
||||
+ // CraftBukkit end
|
||||
double d0 = (double) this.d(enumitemslot);
|
||||
double d0 = (double) this.e(enumitemslot);
|
||||
|
||||
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
@@ -157,55 +178,96 @@
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
this.setSlot(enumitemslot, itemstack);
|
||||
@@ -554,11 +628,11 @@
|
||||
if (entityhuman != null) {
|
||||
double d0 = entityhuman.h(this);
|
||||
this.b(enumitemslot, itemstack);
|
||||
@@ -610,18 +692,18 @@
|
||||
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
||||
|
||||
- if (d0 > 16384.0D && this.isTypeNotPersistent(d0)) {
|
||||
+ if (d0 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check
|
||||
if (entityhuman != null) {
|
||||
- double d0 = entityhuman.h(this);
|
||||
+ double d0 = entityhuman.h((Entity) this); // CraftBukkit - decompile error
|
||||
int i = this.getEntityType().e().f();
|
||||
int j = i * i;
|
||||
|
||||
- if (d0 > (double) j && this.isTypeNotPersistent(d0)) {
|
||||
+ if (d0 > (double) j) { // CraftBukkit - remove isTypeNotPersistent() check
|
||||
this.die();
|
||||
}
|
||||
|
||||
- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > 1024.0D && this.isTypeNotPersistent(d0)) {
|
||||
+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check
|
||||
int k = this.getEntityType().e().g();
|
||||
int l = k * k;
|
||||
|
||||
- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.isTypeNotPersistent(d0)) {
|
||||
+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check
|
||||
this.die();
|
||||
} else if (d0 < 1024.0D) {
|
||||
} else if (d0 < (double) l) {
|
||||
this.ticksFarFromPlayer = 0;
|
||||
@@ -573,6 +647,7 @@
|
||||
@@ -636,6 +718,7 @@
|
||||
@Override
|
||||
protected final void doTick() {
|
||||
++this.ticksFarFromPlayer;
|
||||
+ if (!this.aware) return; // CraftBukkit
|
||||
this.world.getMethodProfiler().enter("sensing");
|
||||
this.bw.a();
|
||||
this.bv.a();
|
||||
this.world.getMethodProfiler().exit();
|
||||
@@ -951,12 +1026,24 @@
|
||||
@@ -1014,6 +1097,12 @@
|
||||
if (!this.isAlive()) {
|
||||
return false;
|
||||
return EnumInteractionResult.PASS;
|
||||
} else if (this.getLeashHolder() == entityhuman) {
|
||||
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
|
||||
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ return false;
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.unleash(true, !entityhuman.abilities.canInstantlyBuild);
|
||||
return true;
|
||||
return EnumInteractionResult.a(this.world.isClientSide);
|
||||
} else {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
@@ -1032,6 +1121,12 @@
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) {
|
||||
+ // CraftBukkit start - fire PlayerLeashEntityEvent
|
||||
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setLeashHolder(entityhuman, true);
|
||||
itemstack.subtract(1);
|
||||
return true;
|
||||
@@ -1002,6 +1089,7 @@
|
||||
if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) {
|
||||
+ // CraftBukkit start - fire PlayerLeashEntityEvent
|
||||
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setLeashHolder(entityhuman, true);
|
||||
itemstack.subtract(1);
|
||||
return EnumInteractionResult.a(this.world.isClientSide);
|
||||
@@ -1047,7 +1142,7 @@
|
||||
if (itemstack.getItem() instanceof ItemMonsterEgg) {
|
||||
if (!this.world.isClientSide) {
|
||||
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
|
||||
- Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), this.world, this.getPositionVector(), itemstack);
|
||||
+ Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getEntityType(), this.world, this.getPositionVector(), itemstack); // CraftBukkit - decompile error
|
||||
|
||||
optional.ifPresent((entityinsentient) -> {
|
||||
this.a(entityhuman, entityinsentient);
|
||||
@@ -1098,7 +1193,7 @@
|
||||
if (this.dead) {
|
||||
return null;
|
||||
} else {
|
||||
- T t0 = (EntityInsentient) entitytypes.a(this.world);
|
||||
+ T t0 = entitytypes.a(this.world); // CraftBukkit - decompile error
|
||||
|
||||
t0.u(this);
|
||||
t0.setCanPickupLoot(this.canPickupLoot());
|
||||
@@ -1128,7 +1223,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- this.world.addEntity(t0);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, EntityTransformEvent.TransformReason.DROWNED).isCancelled()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ this.world.addEntity(t0, CreatureSpawnEvent.SpawnReason.DROWNED);
|
||||
+ // CraftBukkit end
|
||||
this.die();
|
||||
return t0;
|
||||
}
|
||||
@@ -1141,6 +1241,7 @@
|
||||
|
||||
if (this.leashHolder != null) {
|
||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||
@@ -213,9 +275,9 @@
|
||||
this.unleash(true, true);
|
||||
}
|
||||
|
||||
@@ -1017,7 +1105,9 @@
|
||||
|
||||
@@ -1157,7 +1258,9 @@
|
||||
this.leashHolder = null;
|
||||
this.bF = null;
|
||||
if (!this.world.isClientSide && flag1) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.a((IMaterial) Items.LEAD);
|
||||
@@ -223,15 +285,15 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide && flag && this.world instanceof WorldServer) {
|
||||
@@ -1086,6 +1176,7 @@
|
||||
@@ -1207,6 +1310,7 @@
|
||||
boolean flag1 = super.a(entity, flag);
|
||||
|
||||
this.setLeashHolder(EntityLeash.a(this.world, blockposition), true);
|
||||
} else {
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
this.unleash(false, true);
|
||||
}
|
||||
if (flag1 && this.isLeashed()) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
}
|
||||
|
||||
@@ -1193,7 +1284,14 @@
|
||||
@@ -1339,7 +1443,14 @@
|
||||
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
||||
|
||||
if (i > 0) {
|
||||
@@ -247,3 +309,11 @@
|
||||
}
|
||||
|
||||
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f);
|
||||
@@ -1401,6 +1512,7 @@
|
||||
@Override
|
||||
protected void bJ() {
|
||||
super.bJ();
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
this.unleash(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user