2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/Entity.java
|
|
|
|
+++ b/net/minecraft/server/Entity.java
|
2018-07-31 02:06:06 +02:00
|
|
|
@@ -19,8 +19,55 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.Location;
|
|
|
|
+import org.bukkit.Server;
|
|
|
|
+import org.bukkit.TravelAgent;
|
|
|
|
+import org.bukkit.block.BlockFace;
|
2018-07-15 02:00:00 +02:00
|
|
|
+import org.bukkit.command.CommandSender;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.entity.Hanging;
|
|
|
|
+import org.bukkit.entity.LivingEntity;
|
|
|
|
+import org.bukkit.entity.Vehicle;
|
|
|
|
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
|
|
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleEnterEvent;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleExitEvent;
|
|
|
|
+import org.bukkit.craftbukkit.CraftWorld;
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftEntity;
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2016-08-08 10:24:21 +02:00
|
|
|
+import org.bukkit.event.entity.EntityAirChangeEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.EntityCombustEvent;
|
2018-07-31 02:06:06 +02:00
|
|
|
+import org.bukkit.event.entity.EntityDropItemEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.EntityPortalEvent;
|
|
|
|
+import org.bukkit.plugin.PluginManager;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
public abstract class Entity implements INamableTileEntity, ICommandListener {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private static final int CURRENT_LEVEL = 2;
|
|
|
|
+ static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
|
|
|
|
+ return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
|
|
|
+ protected CraftEntity bukkitEntity;
|
|
|
|
+
|
|
|
|
+ public CraftEntity getBukkitEntity() {
|
|
|
|
+ if (bukkitEntity == null) {
|
|
|
|
+ bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
|
|
|
|
+ }
|
|
|
|
+ return bukkitEntity;
|
|
|
|
+ }
|
2018-07-15 02:00:00 +02:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
|
|
|
+ return getBukkitEntity();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
protected static final Logger i = LogManager.getLogger();
|
|
|
|
private static final List<ItemStack> a = Collections.emptyList();
|
|
|
|
private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
|
2018-07-31 02:06:06 +02:00
|
|
|
@@ -107,6 +154,16 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
private boolean aK;
|
|
|
|
private final double[] aL;
|
|
|
|
private long aM;
|
2017-11-07 07:21:38 +01:00
|
|
|
+ // CraftBukkit start
|
2018-06-14 19:59:21 +02:00
|
|
|
+ public boolean persist = true;
|
2017-11-07 07:21:38 +01:00
|
|
|
+ public boolean valid;
|
|
|
|
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
|
|
|
+ public boolean forceExplosionKnockback; // SPIGOT-949
|
|
|
|
+
|
|
|
|
+ public float getBukkitYaw() {
|
|
|
|
+ return this.yaw;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
public Entity(EntityTypes<?> entitytypes, World world) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.id = Entity.entityCount++;
|
2018-07-31 02:06:06 +02:00
|
|
|
@@ -212,6 +269,33 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void setYawPitch(float f, float f1) {
|
|
|
|
+ // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
|
|
|
|
+ if (Float.isNaN(f)) {
|
|
|
|
+ f = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) {
|
|
|
|
+ if (this instanceof EntityPlayer) {
|
|
|
|
+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw");
|
|
|
|
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
|
|
|
|
+ }
|
|
|
|
+ f = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // pitch was sometimes set to NaN, so we need to set it back to 0
|
|
|
|
+ if (Float.isNaN(f1)) {
|
|
|
|
+ f1 = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) {
|
|
|
|
+ if (this instanceof EntityPlayer) {
|
|
|
|
+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch");
|
|
|
|
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
|
|
|
|
+ }
|
|
|
|
+ f1 = 0;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
this.yaw = f % 360.0F;
|
|
|
|
this.pitch = f1 % 360.0F;
|
|
|
|
}
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -224,6 +308,7 @@
|
|
|
|
float f1 = this.length;
|
|
|
|
|
|
|
|
this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f));
|
|
|
|
+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public void tick() {
|
|
|
|
@@ -234,6 +319,51 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
this.W();
|
2017-03-20 05:41:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public void postTick() {
|
|
|
|
+ // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
|
|
|
|
+ if (!this.world.isClientSide && this.world instanceof WorldServer) {
|
2018-12-13 01:00:00 +01:00
|
|
|
+ this.world.methodProfiler.enter("portal");
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (this.an) {
|
2017-03-20 05:41:15 +01:00
|
|
|
+ MinecraftServer minecraftserver = this.world.getMinecraftServer();
|
|
|
|
+
|
|
|
|
+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit
|
|
|
|
+ if (!this.isPassenger()) {
|
2018-07-15 02:00:00 +02:00
|
|
|
+ int i = this.X();
|
2017-03-20 05:41:15 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (this.ao++ >= i) {
|
|
|
|
+ this.ao = i;
|
|
|
|
+ this.portalCooldown = this.aQ();
|
2018-08-26 04:00:00 +02:00
|
|
|
+ DimensionManager dimensionmanager;
|
2017-03-20 05:41:15 +01:00
|
|
|
+
|
2018-08-26 04:00:00 +02:00
|
|
|
+ if (this.world.worldProvider.getDimensionManager() == DimensionManager.NETHER) {
|
|
|
|
+ dimensionmanager = DimensionManager.OVERWORLD;
|
2017-03-20 05:41:15 +01:00
|
|
|
+ } else {
|
2018-08-26 04:00:00 +02:00
|
|
|
+ dimensionmanager = DimensionManager.NETHER;
|
2017-03-20 05:41:15 +01:00
|
|
|
+ }
|
|
|
|
+
|
2018-08-26 04:00:00 +02:00
|
|
|
+ this.a(dimensionmanager);
|
2017-03-20 05:41:15 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ this.an = false;
|
2017-03-20 05:41:15 +01:00
|
|
|
+ }
|
|
|
|
+ } else {
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (this.ao > 0) {
|
|
|
|
+ this.ao -= 4;
|
2017-03-20 05:41:15 +01:00
|
|
|
+ }
|
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (this.ao < 0) {
|
|
|
|
+ this.ao = 0;
|
2017-03-20 05:41:15 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ this.E();
|
2018-12-13 01:00:00 +01:00
|
|
|
+ this.world.methodProfiler.exit();
|
2017-03-20 05:41:15 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
public void W() {
|
2018-12-13 01:00:00 +01:00
|
|
|
this.world.methodProfiler.enter("entityBaseTick");
|
2018-07-15 02:00:00 +02:00
|
|
|
if (this.isPassenger() && this.getVehicle().dead) {
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -250,6 +380,8 @@
|
2017-03-20 05:41:15 +01:00
|
|
|
this.lastZ = this.locZ;
|
|
|
|
this.lastPitch = this.pitch;
|
|
|
|
this.lastYaw = this.yaw;
|
|
|
|
+ // Moved up to postTick
|
|
|
|
+ /*
|
|
|
|
if (!this.world.isClientSide && this.world instanceof WorldServer) {
|
2018-12-13 01:00:00 +01:00
|
|
|
this.world.methodProfiler.enter("portal");
|
2018-07-15 02:00:00 +02:00
|
|
|
if (this.an) {
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -289,6 +421,7 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
this.E();
|
2018-12-13 01:00:00 +01:00
|
|
|
this.world.methodProfiler.exit();
|
2017-03-20 05:41:15 +01:00
|
|
|
}
|
|
|
|
+ */
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
this.av();
|
|
|
|
this.r();
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -339,7 +472,23 @@
|
2018-08-26 04:00:00 +02:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
protected void burnFromLava() {
|
|
|
|
if (!this.fireProof) {
|
2018-08-26 04:00:00 +02:00
|
|
|
- this.setOnFire(15);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Fallen in lava TODO: this event spams!
|
2018-08-26 04:00:00 +02:00
|
|
|
+ if (this instanceof EntityLiving && fireTicks <= 0) {
|
|
|
|
+ // not on fire yet
|
|
|
|
+ // TODO: shouldn't be sending null for the block
|
|
|
|
+ org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
|
|
|
|
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
|
|
|
+ EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(combustEvent);
|
|
|
|
+
|
|
|
|
+ if (!combustEvent.isCancelled()) {
|
|
|
|
+ this.setOnFire(combustEvent.getDuration());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2018-08-26 04:00:00 +02:00
|
|
|
+ } else {
|
|
|
|
+ // This will be called every single tick the entity is in lava, so don't throw an event
|
|
|
|
+ this.setOnFire(15);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
|
2018-08-26 04:00:00 +02:00
|
|
|
this.damageEntity(DamageSource.LAVA, 4.0F);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -505,7 +654,7 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-20 21:00:00 +01:00
|
|
|
- boolean flag = this.onGround || d1 != d1 && d1 < 0.0D;
|
|
|
|
+ boolean flag = this.onGround || d1 != d8 && d1 < 0.0D; // CraftBukkit - decompile error
|
|
|
|
double d11;
|
2016-11-17 02:41:03 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
if (this.Q > 0.0F && flag && (d7 != d0 || d9 != d2)) {
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -592,7 +741,7 @@
|
2018-12-13 01:00:00 +01:00
|
|
|
this.world.methodProfiler.enter("rest");
|
2016-11-17 02:41:03 +01:00
|
|
|
this.recalcPosition();
|
2016-12-20 21:00:00 +01:00
|
|
|
this.positionChanged = d7 != d0 || d9 != d2;
|
2018-07-15 02:00:00 +02:00
|
|
|
- this.C = d1 != d1;
|
|
|
|
+ this.C = d1 != d8; // CraftBukkit - decompile error
|
|
|
|
this.onGround = this.C && d8 < 0.0D;
|
|
|
|
this.D = this.positionChanged || this.C;
|
|
|
|
int k = MathHelper.floor(this.locX);
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -627,6 +776,28 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
block1.a((IBlockAccess) this.world, this);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (positionChanged && getBukkitEntity() instanceof Vehicle) {
|
|
|
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
2015-01-04 21:00:42 +01:00
|
|
|
+ org.bukkit.block.Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2017-05-21 02:24:47 +02:00
|
|
|
+ if (d7 > d0) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ bl = bl.getRelative(BlockFace.EAST);
|
2017-05-21 02:24:47 +02:00
|
|
|
+ } else if (d7 < d0) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ bl = bl.getRelative(BlockFace.WEST);
|
2017-05-21 02:24:47 +02:00
|
|
|
+ } else if (d9 > d2) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ bl = bl.getRelative(BlockFace.SOUTH);
|
2017-05-21 02:24:47 +02:00
|
|
|
+ } else if (d9 < d2) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ bl = bl.getRelative(BlockFace.NORTH);
|
|
|
|
+ }
|
|
|
|
+
|
2016-10-12 10:47:14 +02:00
|
|
|
+ if (bl.getType() != org.bukkit.Material.AIR) {
|
|
|
|
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2016-12-20 21:00:00 +01:00
|
|
|
if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) {
|
|
|
|
double d22 = this.locX - d4;
|
|
|
|
double d23 = this.locY - d5;
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -678,7 +849,14 @@
|
2016-12-20 21:00:00 +01:00
|
|
|
if (!flag1) {
|
2014-11-25 22:32:16 +01:00
|
|
|
++this.fireTicks;
|
2016-09-03 08:39:21 +02:00
|
|
|
if (this.fireTicks == 0) {
|
|
|
|
- this.setOnFire(8);
|
|
|
|
+ // CraftBukkit start
|
2016-06-15 05:31:35 +02:00
|
|
|
+ EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(null, getBukkitEntity(), 8);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
2016-09-03 08:39:21 +02:00
|
|
|
+ this.setOnFire(event.getDuration());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
2018-08-26 04:00:00 +02:00
|
|
|
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -706,6 +884,7 @@
|
2018-10-22 21:00:00 +02:00
|
|
|
this.locX = (axisalignedbb.minX + axisalignedbb.maxX) / 2.0D;
|
|
|
|
this.locY = axisalignedbb.minY;
|
|
|
|
this.locZ = (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D;
|
2018-09-26 09:19:16 +02:00
|
|
|
+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
protected SoundEffect ad() {
|
|
|
|
@@ -876,7 +1055,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
- protected void burn(int i) {
|
|
|
|
+ protected void burn(float i) { // CraftBukkit - int -> float
|
|
|
|
if (!this.fireProof) {
|
|
|
|
this.damageEntity(DamageSource.FIRE, (float) i);
|
|
|
|
}
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1095,6 +1274,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void spawnIn(World world) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (world == null) {
|
|
|
|
+ die();
|
|
|
|
+ this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.world = world;
|
|
|
|
}
|
|
|
|
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1120,6 +1306,7 @@
|
|
|
|
this.lastYaw -= 360.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ world.getChunkAt((int) Math.floor(this.locX) >> 4, (int) Math.floor(this.locZ) >> 4); // CraftBukkit
|
|
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
|
|
|
this.setYawPitch(f, f1);
|
|
|
|
}
|
|
|
|
@@ -1302,7 +1489,7 @@
|
2018-07-30 05:25:02 +02:00
|
|
|
public boolean c(NBTTagCompound nbttagcompound) {
|
|
|
|
String s = this.getSaveID();
|
2018-06-14 19:59:21 +02:00
|
|
|
|
2018-07-30 05:25:02 +02:00
|
|
|
- if (!this.dead && s != null) {
|
|
|
|
+ if (this.persist && !this.dead && s != null) { // CraftBukkit - persist flag
|
|
|
|
nbttagcompound.setString("id", s);
|
|
|
|
this.save(nbttagcompound);
|
|
|
|
return true;
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1319,6 +1506,18 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
try {
|
2018-12-06 00:00:00 +01:00
|
|
|
nbttagcompound.set("Pos", this.a(this.locX, this.locY, this.locZ));
|
|
|
|
nbttagcompound.set("Motion", this.a(this.motX, this.motY, this.motZ));
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
|
|
|
|
+ // TODO: make sure this is the best way to address this.
|
|
|
|
+ if (Float.isNaN(this.yaw)) {
|
|
|
|
+ this.yaw = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Float.isNaN(this.pitch)) {
|
|
|
|
+ this.pitch = 0;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2018-12-06 00:00:00 +01:00
|
|
|
nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch));
|
2014-11-25 22:32:16 +01:00
|
|
|
nbttagcompound.setFloat("FallDistance", this.fallDistance);
|
|
|
|
nbttagcompound.setShort("Fire", (short) this.fireTicks);
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1328,6 +1527,12 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
|
2014-11-25 22:32:16 +01:00
|
|
|
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
|
2016-02-29 22:32:46 +01:00
|
|
|
nbttagcompound.a("UUID", this.getUniqueID());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast
|
2014-11-25 22:32:16 +01:00
|
|
|
+ nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits());
|
|
|
|
+ nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits());
|
|
|
|
+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
|
|
|
|
+ // CraftBukkit end
|
2018-07-15 02:00:00 +02:00
|
|
|
IChatBaseComponent ichatbasecomponent = this.getCustomName();
|
|
|
|
|
|
|
|
if (ichatbasecomponent != null) {
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1404,6 +1609,8 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
this.motX = nbttaglist1.k(0);
|
|
|
|
this.motY = nbttaglist1.k(1);
|
|
|
|
this.motZ = nbttaglist1.k(2);
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ /* CraftBukkit start - Moved section down
|
|
|
|
if (Math.abs(this.motX) > 10.0D) {
|
|
|
|
this.motX = 0.0D;
|
|
|
|
}
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1415,6 +1622,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (Math.abs(this.motZ) > 10.0D) {
|
|
|
|
this.motZ = 0.0D;
|
|
|
|
}
|
|
|
|
+ // CraftBukkit end */
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
this.locX = nbttaglist.k(0);
|
|
|
|
this.locY = nbttaglist.k(1);
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1471,6 +1679,56 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (this instanceof EntityLiving) {
|
|
|
|
+ EntityLiving entity = (EntityLiving) this;
|
|
|
|
+
|
|
|
|
+ // Reset the persistence for tamed animals
|
|
|
|
+ if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
|
|
|
|
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
|
|
|
|
+ entityinsentient.persistent = !entityinsentient.isTypeNotPersistent();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2018-02-18 23:52:00 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ double limit = getBukkitEntity() instanceof Vehicle ? 100.0D : 10.0D;
|
|
|
|
+ if (Math.abs(this.motX) > limit) {
|
|
|
|
+ this.motX = 0.0D;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-02-18 23:52:00 +01:00
|
|
|
+ if (Math.abs(this.motY) > limit) {
|
|
|
|
+ this.motY = 0.0D;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-02-18 23:52:00 +01:00
|
|
|
+ if (Math.abs(this.motZ) > limit) {
|
|
|
|
+ this.motZ = 0.0D;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-01-09 06:59:18 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Reset world
|
|
|
|
+ if (this instanceof EntityPlayer) {
|
|
|
|
+ Server server = Bukkit.getServer();
|
|
|
|
+ org.bukkit.World bworld = null;
|
2014-12-21 17:30:42 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // TODO: Remove World related checks, replaced with WorldUID
|
|
|
|
+ String worldName = nbttagcompound.getString("world");
|
|
|
|
+
|
|
|
|
+ if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) {
|
|
|
|
+ UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast"));
|
|
|
|
+ bworld = server.getWorld(uid);
|
|
|
|
+ } else {
|
|
|
|
+ bworld = server.getWorld(worldName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (bworld == null) {
|
2018-08-26 04:00:00 +02:00
|
|
|
+ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(DimensionManager.OVERWORLD).getWorld();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ spawnIn(bworld == null? null : ((CraftWorld) bworld).getHandle());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1544,9 +1802,22 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
if (itemstack.isEmpty()) {
|
|
|
|
return null;
|
|
|
|
} else {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Capture drops for death event
|
2016-03-08 07:58:52 +01:00
|
|
|
+ if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
entityitem.n();
|
2018-07-31 02:06:06 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
|
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.world.addEntity(entityitem);
|
|
|
|
return entityitem;
|
|
|
|
}
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1658,7 +1929,7 @@
|
2018-09-09 01:32:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.vehicle = entity;
|
2018-10-22 21:00:00 +02:00
|
|
|
- this.vehicle.addPassenger(this);
|
|
|
|
+ if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit
|
2018-09-09 01:32:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1679,15 +1950,33 @@
|
2018-08-26 04:00:00 +02:00
|
|
|
Entity entity = this.vehicle;
|
2018-07-28 02:10:17 +02:00
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
this.vehicle = null;
|
|
|
|
- entity.removePassenger(this);
|
|
|
|
+ if (!entity.removePassenger(this)) this.vehicle = entity; // CraftBukkit
|
2018-07-28 02:10:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-09-09 01:32:11 +02:00
|
|
|
|
2018-10-22 21:00:00 +02:00
|
|
|
- protected void addPassenger(Entity entity) {
|
|
|
|
+ protected boolean addPassenger(Entity entity) { // CraftBukkit
|
2018-07-15 02:00:00 +02:00
|
|
|
if (entity.getVehicle() != this) {
|
2016-02-29 22:32:46 +01:00
|
|
|
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start
|
2016-03-15 05:09:39 +01:00
|
|
|
+ com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity);
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
|
|
|
+ Entity orig = craft == null ? null : craft.getHandle();
|
2016-03-25 23:19:03 +01:00
|
|
|
+ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, false)) { // Boolean not used
|
2016-02-29 22:32:46 +01:00
|
|
|
+ VehicleEnterEvent event = new VehicleEnterEvent(
|
|
|
|
+ (Vehicle) getBukkitEntity(),
|
|
|
|
+ entity.getBukkitEntity()
|
|
|
|
+ );
|
|
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
|
|
+ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
|
|
|
+ Entity n = craftn == null ? null : craftn.getHandle();
|
|
|
|
+ if (event.isCancelled() || n != orig) {
|
2018-09-09 01:32:11 +02:00
|
|
|
+ return false;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-07-15 02:00:00 +02:00
|
|
|
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.passengers.add(0, entity);
|
|
|
|
} else {
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1695,15 +1984,33 @@
|
2018-09-09 01:32:11 +02:00
|
|
|
}
|
|
|
|
|
2018-07-28 02:10:17 +02:00
|
|
|
}
|
2018-09-09 01:32:11 +02:00
|
|
|
+ return true; // CraftBukkit
|
2018-07-28 02:10:17 +02:00
|
|
|
}
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
- protected void removePassenger(Entity entity) {
|
|
|
|
+ protected boolean removePassenger(Entity entity) { // CraftBukkit
|
2018-07-15 02:00:00 +02:00
|
|
|
if (entity.getVehicle() == this) {
|
2016-02-29 22:32:46 +01:00
|
|
|
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
|
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
|
|
|
+ Entity orig = craft == null ? null : craft.getHandle();
|
|
|
|
+ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
|
|
|
|
+ VehicleExitEvent event = new VehicleExitEvent(
|
|
|
|
+ (Vehicle) getBukkitEntity(),
|
|
|
|
+ (LivingEntity) entity.getBukkitEntity()
|
|
|
|
+ );
|
|
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
|
|
+ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
|
|
|
+ Entity n = craftn == null ? null : craftn.getHandle();
|
|
|
|
+ if (event.isCancelled() || n != orig) {
|
2018-07-28 02:10:17 +02:00
|
|
|
+ return false;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
this.passengers.remove(entity);
|
2018-07-15 02:00:00 +02:00
|
|
|
entity.k = 60;
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
2018-07-28 02:10:17 +02:00
|
|
|
+ return true; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean q(Entity entity) {
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1800,6 +2107,13 @@
|
2018-07-15 08:17:35 +02:00
|
|
|
}
|
|
|
|
|
2018-07-22 04:00:00 +02:00
|
|
|
public void setSwimming(boolean flag) {
|
2018-07-15 08:17:35 +02:00
|
|
|
+ // CraftBukkit start
|
2018-07-22 04:00:00 +02:00
|
|
|
+ if (this.isSwimming() != flag && this instanceof EntityLiving) {
|
2018-07-15 08:17:35 +02:00
|
|
|
+ if (CraftEventFactory.callToggleSwimEvent((EntityLiving) this, flag).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.setFlag(4, flag);
|
|
|
|
}
|
|
|
|
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -1860,16 +2174,53 @@
|
2016-08-08 10:24:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setAirTicks(int i) {
|
2018-12-06 00:00:00 +01:00
|
|
|
- this.datawatcher.set(Entity.aD, i);
|
2016-08-08 10:24:21 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i);
|
2017-02-14 00:34:56 +01:00
|
|
|
+ event.getEntity().getServer().getPluginManager().callEvent(event);
|
2016-08-08 10:24:21 +02:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2018-12-06 00:00:00 +01:00
|
|
|
+ this.datawatcher.set(Entity.aD, event.getAmount());
|
2016-08-08 10:24:21 +02:00
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onLightningStrike(EntityLightning entitylightning) {
|
2018-08-26 04:00:00 +02:00
|
|
|
++this.fireTicks;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
|
|
|
|
+ final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
|
|
|
|
+ final PluginManager pluginManager = Bukkit.getPluginManager();
|
2018-08-26 04:00:00 +02:00
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-08-26 04:00:00 +02:00
|
|
|
if (this.fireTicks == 0) {
|
|
|
|
- this.setOnFire(8);
|
|
|
|
+ // CraftBukkit start - Call a combust event when lightning strikes
|
|
|
|
+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
|
|
|
|
+ pluginManager.callEvent(entityCombustEvent);
|
|
|
|
+ if (!entityCombustEvent.isCancelled()) {
|
|
|
|
+ this.setOnFire(entityCombustEvent.getDuration());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
- this.damageEntity(DamageSource.LIGHTNING, 5.0F);
|
|
|
|
+ // CraftBukkit start
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (thisBukkitEntity instanceof Hanging) {
|
|
|
|
+ HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
|
|
|
|
+ pluginManager.callEvent(hangingEvent);
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (hangingEvent.isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.fireProof) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ CraftEventFactory.entityDamage = entitylightning;
|
|
|
|
+ if (!this.damageEntity(DamageSource.LIGHTNING, 5.0F)) {
|
|
|
|
+ CraftEventFactory.entityDamage = null;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2018-08-26 04:00:00 +02:00
|
|
|
|
|
|
|
public void j(boolean flag) {
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -2036,19 +2387,72 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!this.world.isClientSide && !this.dead) {
|
2018-12-13 01:00:00 +01:00
|
|
|
this.world.methodProfiler.enter("changeDimension");
|
2018-07-15 02:00:00 +02:00
|
|
|
MinecraftServer minecraftserver = this.bK();
|
2018-08-26 04:00:00 +02:00
|
|
|
- DimensionManager dimensionmanager1 = this.dimension;
|
|
|
|
- WorldServer worldserver = minecraftserver.getWorldServer(dimensionmanager1);
|
|
|
|
- WorldServer worldserver1 = minecraftserver.getWorldServer(dimensionmanager);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start - Move logic into new function "teleportTo(Location,boolean)"
|
2018-08-26 04:00:00 +02:00
|
|
|
+ // DimensionManager dimensionmanager1 = this.dimension;
|
|
|
|
+ // WorldServer worldserver = minecraftserver.getWorldServer(dimensionmanager1);
|
|
|
|
+ // WorldServer worldserver1 = minecraftserver.getWorldServer(dimensionmanager);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ WorldServer exitWorld = null;
|
2018-08-26 04:00:00 +02:00
|
|
|
+ if (this.dimension.getDimensionID() < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // Plugins must specify exit from custom Bukkit worlds
|
|
|
|
+ exitWorld = minecraftserver.getWorldServer(dimensionmanager);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ BlockPosition blockposition = null; // PAIL: CHECK
|
2014-11-25 22:32:16 +01:00
|
|
|
+ Location enter = this.getBukkitEntity().getLocation();
|
2016-02-29 22:32:46 +01:00
|
|
|
+ Location exit;
|
|
|
|
+ if (exitWorld != null) {
|
|
|
|
+ if (blockposition != null) {
|
|
|
|
+ exit = new Location(exitWorld.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+ } else {
|
2018-08-26 04:00:00 +02:00
|
|
|
+ exit = minecraftserver.getPlayerList().calculateTarget(enter, exitWorld);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ exit = null;
|
|
|
|
+ }
|
2018-08-26 04:00:00 +02:00
|
|
|
+ boolean useTravelAgent = exitWorld != null && !(this.dimension == DimensionManager.THE_END && exitWorld.dimension == DimensionManager.THE_END); // don't use agent for custom worlds or return from THE_END
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
|
2017-07-22 08:40:10 +02:00
|
|
|
+ boolean oldCanCreate = agent.getCanCreatePortal();
|
|
|
|
+ agent.setCanCreatePortal(false); // General entities cannot create portals
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent);
|
|
|
|
+ event.useTravelAgent(useTravelAgent);
|
|
|
|
+ event.getEntity().getServer().getPluginManager().callEvent(event);
|
|
|
|
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) {
|
2017-08-08 12:35:29 +02:00
|
|
|
+ agent.setCanCreatePortal(oldCanCreate);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return null;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
|
2017-07-22 08:40:10 +02:00
|
|
|
+ agent.setCanCreatePortal(oldCanCreate);
|
|
|
|
+
|
2017-01-19 02:42:35 +01:00
|
|
|
+ // Need to make sure the profiler state is reset afterwards (but we still want to time the call)
|
|
|
|
+ Entity entity = this.teleportTo(exit, true);
|
2018-12-13 01:00:00 +01:00
|
|
|
+ this.world.methodProfiler.exit();
|
2017-01-19 02:42:35 +01:00
|
|
|
+ return entity;
|
2018-08-26 04:00:00 +02:00
|
|
|
+ } else {
|
|
|
|
+ return null;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ public Entity teleportTo(Location exit, boolean portal) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (true) {
|
|
|
|
+ WorldServer worldserver = ((CraftWorld) getBukkitEntity().getLocation().getWorld()).getHandle();
|
|
|
|
+ WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle();
|
2018-08-26 04:00:00 +02:00
|
|
|
+ DimensionManager dimensionmanager = worldserver1.dimension;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
this.dimension = dimensionmanager;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ /* CraftBukkit start - TODO: Check if we need this
|
2018-08-26 04:00:00 +02:00
|
|
|
if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) {
|
|
|
|
worldserver1 = minecraftserver.getWorldServer(DimensionManager.OVERWORLD);
|
|
|
|
this.dimension = DimensionManager.OVERWORLD;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
+ // CraftBukkit end */
|
|
|
|
|
|
|
|
this.world.kill(this);
|
|
|
|
this.dead = false;
|
2018-12-13 01:00:00 +01:00
|
|
|
this.world.methodProfiler.enter("reposition");
|
2016-02-29 22:32:46 +01:00
|
|
|
+ /* CraftBukkit start - Handled in calculateTarget
|
|
|
|
BlockPosition blockposition;
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
if (dimensionmanager == DimensionManager.THE_END) {
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -2077,12 +2481,18 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
blockposition = new BlockPosition(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
- worldserver.entityJoinedWorld(this, false);
|
|
|
|
+ // CraftBukkit end */
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create
|
|
|
|
+ // minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1);
|
|
|
|
+ worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2018-12-13 01:00:00 +01:00
|
|
|
this.world.methodProfiler.exitEnter("reloading");
|
2018-07-15 02:00:00 +02:00
|
|
|
Entity entity = this.P().a((World) worldserver1);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
if (entity != null) {
|
2018-07-15 02:00:00 +02:00
|
|
|
entity.v(this);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ /* CraftBukkit start - We need to do this...
|
2018-08-26 04:00:00 +02:00
|
|
|
if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) {
|
2018-07-15 02:00:00 +02:00
|
|
|
BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -2090,6 +2500,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
} else {
|
2014-11-25 22:32:16 +01:00
|
|
|
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
|
|
|
|
}
|
|
|
|
+ // CraftBukkit end */
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
boolean flag = entity.attachedToPlayer;
|
|
|
|
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -2097,13 +2508,21 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
worldserver1.addEntity(entity);
|
2016-02-29 22:32:46 +01:00
|
|
|
entity.attachedToPlayer = flag;
|
|
|
|
worldserver1.entityJoinedWorld(entity, false);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Forward the CraftEntity to the new entity
|
|
|
|
+ this.getBukkitEntity().setHandle(entity);
|
|
|
|
+ entity.bukkitEntity = this.getBukkitEntity();
|
2014-12-21 17:30:42 +01:00
|
|
|
+
|
|
|
|
+ if (this instanceof EntityInsentient) {
|
|
|
|
+ ((EntityInsentient)this).unleash(true, false); // Unleash to prevent duping of leads.
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
this.dead = true;
|
2018-12-13 01:00:00 +01:00
|
|
|
this.world.methodProfiler.exit();
|
2018-08-26 04:00:00 +02:00
|
|
|
worldserver.p();
|
|
|
|
worldserver1.p();
|
2018-12-13 01:00:00 +01:00
|
|
|
- this.world.methodProfiler.exit();
|
|
|
|
+ // this.world.methodProfiler.exit(); // CraftBukkit: Moved up to keep balanced
|
2017-01-19 02:42:35 +01:00
|
|
|
return entity;
|
|
|
|
} else {
|
|
|
|
return null;
|
2018-09-26 09:19:16 +02:00
|
|
|
@@ -2243,7 +2662,26 @@
|
2014-12-02 18:53:34 +01:00
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
public void a(AxisAlignedBB axisalignedbb) {
|
2014-12-02 18:53:34 +01:00
|
|
|
- this.boundingBox = axisalignedbb;
|
|
|
|
+ // CraftBukkit start - block invalid bounding boxes
|
2018-10-22 21:00:00 +02:00
|
|
|
+ double minX = axisalignedbb.minX,
|
|
|
|
+ minY = axisalignedbb.minY,
|
|
|
|
+ minZ = axisalignedbb.minZ,
|
|
|
|
+ maxX = axisalignedbb.maxX,
|
|
|
|
+ maxY = axisalignedbb.maxY,
|
|
|
|
+ maxZ = axisalignedbb.maxZ;
|
|
|
|
+ double len = axisalignedbb.maxX - axisalignedbb.minX;
|
|
|
|
+ if (len < 0) maxX = minX;
|
|
|
|
+ if (len > 64) maxX = minX + 64.0;
|
|
|
|
+
|
|
|
|
+ len = axisalignedbb.maxY - axisalignedbb.minY;
|
|
|
|
+ if (len < 0) maxY = minY;
|
|
|
|
+ if (len > 64) maxY = minY + 64.0;
|
|
|
|
+
|
|
|
|
+ len = axisalignedbb.maxZ - axisalignedbb.minZ;
|
|
|
|
+ if (len < 0) maxZ = minZ;
|
|
|
|
+ if (len > 64) maxZ = minZ + 64.0;
|
|
|
|
+ this.boundingBox = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
2014-12-02 18:53:34 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getHeadHeight() {
|