summaryrefslogtreecommitdiffstats
path: root/nms-patches/Entity.patch
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2017-03-20 15:41:15 +1100
committermd_5 <git@md-5.net>2017-03-20 15:41:15 +1100
commit257d6cd04f7d669a4000b81ca78624f6501787c1 (patch)
tree1d4a8c594d2b98af83424b5ae6e61602c82bed79 /nms-patches/Entity.patch
parentb80055abfba170378fb945b743b945db718b3fbd (diff)
downloadcraftbukkit-257d6cd04f7d669a4000b81ca78624f6501787c1.tar
craftbukkit-257d6cd04f7d669a4000b81ca78624f6501787c1.tar.gz
craftbukkit-257d6cd04f7d669a4000b81ca78624f6501787c1.tar.lz
craftbukkit-257d6cd04f7d669a4000b81ca78624f6501787c1.tar.xz
craftbukkit-257d6cd04f7d669a4000b81ca78624f6501787c1.zip
Process entity portalling towards the end of a tick.
Cross world teleportation works by taking a copy of an entity and moving it to a new world. After this happens the original entity is marked as dead so as to be removed from the original world, however it still undergoes one further tick in the main world, but with some information from the new world. It is not so easy to break out of this tick cycle if needed, so instead we move the portalling process towards the end of an existing tick. This ensures that the entity will not be spuriously ticked.
Diffstat (limited to 'nms-patches/Entity.patch')
-rw-r--r--nms-patches/Entity.patch121
1 files changed, 94 insertions, 27 deletions
diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch
index a947ff74..92e5b892 100644
--- a/nms-patches/Entity.patch
+++ b/nms-patches/Entity.patch
@@ -93,7 +93,66 @@
this.yaw = f % 360.0F;
this.pitch = f1 % 360.0F;
}
-@@ -249,7 +319,7 @@
+@@ -228,6 +298,51 @@
+ this.U();
+ }
+
++ // 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) {
++ this.world.methodProfiler.a("portal");
++ if (this.ak) {
++ MinecraftServer minecraftserver = this.world.getMinecraftServer();
++
++ if (true || minecraftserver.getAllowNether()) { // CraftBukkit
++ if (!this.isPassenger()) {
++ int i = this.V();
++
++ if (this.al++ >= i) {
++ this.al = i;
++ this.portalCooldown = this.aE();
++ byte b0;
++
++ if (this.world.worldProvider.getDimensionManager().getDimensionID() == -1) {
++ b0 = 0;
++ } else {
++ b0 = -1;
++ }
++
++ this.c(b0);
++ }
++ }
++
++ this.ak = false;
++ }
++ } else {
++ if (this.al > 0) {
++ this.al -= 4;
++ }
++
++ if (this.al < 0) {
++ this.al = 0;
++ }
++ }
++
++ this.H();
++ this.world.methodProfiler.b();
++ }
++ }
++ // CraftBukkit end
++
+ public void U() {
+ this.world.methodProfiler.a("entityBaseTick");
+ if (this.isPassenger() && this.bB().dead) {
+@@ -244,12 +359,14 @@
+ this.lastZ = this.locZ;
+ this.lastPitch = this.pitch;
+ this.lastYaw = this.yaw;
++ // Moved up to postTick
++ /*
+ if (!this.world.isClientSide && this.world instanceof WorldServer) {
+ this.world.methodProfiler.a("portal");
if (this.ak) {
MinecraftServer minecraftserver = this.world.getMinecraftServer();
@@ -102,7 +161,15 @@
if (!this.isPassenger()) {
int i = this.V();
-@@ -334,6 +404,27 @@
+@@ -283,6 +400,7 @@
+ this.H();
+ this.world.methodProfiler.b();
+ }
++ */
+
+ this.am();
+ this.ak();
+@@ -334,6 +452,27 @@
protected void burnFromLava() {
if (!this.fireProof) {
this.damageEntity(DamageSource.LAVA, 4.0F);
@@ -130,7 +197,7 @@
this.setOnFire(15);
}
}
-@@ -374,6 +465,22 @@
+@@ -374,6 +513,22 @@
this.a(this.getBoundingBox().d(d0, d1, d2));
this.recalcPosition();
} else {
@@ -153,7 +220,7 @@
if (enummovetype == EnumMoveType.PISTON) {
long i = this.world.getTime();
-@@ -515,7 +622,7 @@
+@@ -515,7 +670,7 @@
}
}
@@ -162,7 +229,7 @@
double d11;
if (this.P > 0.0F && flag && (d7 != d0 || d9 != d2)) {
-@@ -613,7 +720,7 @@
+@@ -613,7 +768,7 @@
this.world.methodProfiler.a("rest");
this.recalcPosition();
this.positionChanged = d7 != d0 || d9 != d2;
@@ -171,7 +238,7 @@
this.onGround = this.B && d8 < 0.0D;
this.C = this.positionChanged || this.B;
l = MathHelper.floor(this.locX);
-@@ -648,6 +755,28 @@
+@@ -648,6 +803,28 @@
block1.a(this.world, this);
}
@@ -200,7 +267,7 @@
if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) {
double d22 = this.locX - d4;
double d23 = this.locY - d5;
-@@ -681,6 +810,8 @@
+@@ -681,6 +858,8 @@
}
}
@@ -209,7 +276,7 @@
try {
this.checkBlockCollisions();
} catch (Throwable throwable) {
-@@ -690,6 +821,8 @@
+@@ -690,6 +869,8 @@
this.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
@@ -218,7 +285,7 @@
boolean flag1 = this.ai();
-@@ -698,7 +831,14 @@
+@@ -698,7 +879,14 @@
if (!flag1) {
++this.fireTicks;
if (this.fireTicks == 0) {
@@ -234,7 +301,7 @@
}
}
} else if (this.fireTicks <= 0) {
-@@ -819,7 +959,7 @@
+@@ -819,7 +1007,7 @@
return null;
}
@@ -243,7 +310,7 @@
if (!this.fireProof) {
this.damageEntity(DamageSource.FIRE, (float) i);
}
-@@ -987,6 +1127,13 @@
+@@ -987,6 +1175,13 @@
}
public void spawnIn(World world) {
@@ -257,7 +324,7 @@
this.world = world;
}
-@@ -1219,6 +1366,18 @@
+@@ -1219,6 +1414,18 @@
try {
nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ}));
nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ}));
@@ -276,7 +343,7 @@
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
nbttagcompound.setFloat("FallDistance", this.fallDistance);
nbttagcompound.setShort("Fire", (short) this.fireTicks);
-@@ -1228,6 +1387,12 @@
+@@ -1228,6 +1435,12 @@
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
nbttagcompound.a("UUID", this.getUniqueID());
@@ -289,7 +356,7 @@
if (this.hasCustomName()) {
nbttagcompound.setString("CustomName", this.getCustomName());
}
-@@ -1303,6 +1468,8 @@
+@@ -1303,6 +1516,8 @@
this.motX = nbttaglist1.e(0);
this.motY = nbttaglist1.e(1);
this.motZ = nbttaglist1.e(2);
@@ -298,7 +365,7 @@
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
-@@ -1314,6 +1481,7 @@
+@@ -1314,6 +1529,7 @@
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
@@ -306,7 +373,7 @@
this.locX = nbttaglist.e(0);
this.locY = nbttaglist.e(1);
-@@ -1371,6 +1539,58 @@
+@@ -1371,6 +1587,58 @@
this.setPosition(this.locX, this.locY, this.locZ);
}
@@ -365,7 +432,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
-@@ -1438,6 +1658,12 @@
+@@ -1438,6 +1706,12 @@
if (itemstack.isEmpty()) {
return null;
} else {
@@ -378,7 +445,7 @@
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
entityitem.q();
-@@ -1563,6 +1789,24 @@
+@@ -1563,6 +1837,24 @@
if (entity.bB() != this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
} else {
@@ -403,7 +470,7 @@
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bw() instanceof EntityHuman)) {
this.passengers.add(0, entity);
} else {
-@@ -1576,6 +1820,22 @@
+@@ -1576,6 +1868,22 @@
if (entity.bB() == this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
@@ -426,7 +493,7 @@
this.passengers.remove(entity);
entity.j = 60;
}
-@@ -1715,14 +1975,49 @@
+@@ -1715,14 +2023,49 @@
}
public void setAirTicks(int i) {
@@ -479,7 +546,7 @@
}
}
-@@ -1867,19 +2162,70 @@
+@@ -1867,19 +2210,70 @@
if (!this.world.isClientSide && !this.dead) {
this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = this.B_();
@@ -553,7 +620,7 @@
BlockPosition blockposition;
if (i == 1) {
-@@ -1908,12 +2254,18 @@
+@@ -1908,12 +2302,18 @@
blockposition = new BlockPosition(this);
}
@@ -573,7 +640,7 @@
if (j == 1 && i == 1) {
BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn());
-@@ -1921,6 +2273,7 @@
+@@ -1921,6 +2321,7 @@
} else {
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
}
@@ -581,7 +648,7 @@
boolean flag = entity.attachedToPlayer;
-@@ -1928,13 +2281,21 @@
+@@ -1928,13 +2329,21 @@
worldserver1.addEntity(entity);
entity.attachedToPlayer = flag;
worldserver1.entityJoinedWorld(entity, false);
@@ -604,7 +671,7 @@
return entity;
} else {
return null;
-@@ -2038,6 +2399,11 @@
+@@ -2038,6 +2447,11 @@
}
public void setCustomName(String s) {
@@ -616,7 +683,7 @@
this.datawatcher.set(Entity.aA, s);
}
-@@ -2095,7 +2461,26 @@
+@@ -2095,7 +2509,26 @@
}
public void a(AxisAlignedBB axisalignedbb) {
@@ -644,7 +711,7 @@
}
public float getHeadHeight() {
-@@ -2269,7 +2654,7 @@
+@@ -2269,7 +2702,7 @@
for (Iterator iterator = this.bx().iterator(); iterator.hasNext(); entity.a(oclass, set)) {
entity = (Entity) iterator.next();
if (oclass.isAssignableFrom(entity.getClass())) {