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.
Dieser Commit ist enthalten in:
md_5 2017-03-20 15:41:15 +11:00
Ursprung b80055abfb
Commit 257d6cd04f
2 geänderte Dateien mit 115 neuen und 40 gelöschten Zeilen

Datei anzeigen

@ -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())) {

Datei anzeigen

@ -460,7 +460,15 @@
entity.M = entity.locX;
entity.N = entity.locY;
entity.O = entity.locZ;
@@ -1547,11 +1799,18 @@
@@ -1255,6 +1507,7 @@
entity.aw();
} else {
entity.A_();
+ entity.postTick(); // CraftBukkit
}
}
@@ -1547,11 +1800,18 @@
}
}
@ -479,7 +487,7 @@
TileEntity tileentity = null;
if (this.M) {
@@ -1586,6 +1845,14 @@
@@ -1586,6 +1846,14 @@
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
if (!this.E(blockposition)) {
if (tileentity != null && !tileentity.y()) {
@ -494,7 +502,7 @@
if (this.M) {
tileentity.setPosition(blockposition);
Iterator iterator = this.b.iterator();
@@ -1745,6 +2012,14 @@
@@ -1745,6 +2013,14 @@
}
this.o = MathHelper.a(this.o, 0.0F, 1.0F);
@ -509,7 +517,7 @@
}
}
}
@@ -1876,7 +2151,10 @@
@@ -1876,7 +2152,10 @@
}
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
@ -521,7 +529,7 @@
return false;
} else {
int i = 0;
@@ -2043,7 +2321,7 @@
@@ -2043,7 +2322,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@ -530,7 +538,7 @@
arraylist.add(entity);
}
}
@@ -2058,7 +2336,7 @@
@@ -2058,7 +2337,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@ -539,7 +547,7 @@
arraylist.add(entity);
}
}
@@ -2107,7 +2385,7 @@
@@ -2107,7 +2386,7 @@
}
}
@ -548,7 +556,7 @@
}
@Nullable
@@ -2128,8 +2406,17 @@
@@ -2128,8 +2407,17 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@ -568,7 +576,7 @@
++i;
}
}
@@ -2138,12 +2425,18 @@
@@ -2138,12 +2426,18 @@
}
public void a(Collection<Entity> collection) {
@ -588,7 +596,7 @@
this.b(entity);
}
@@ -2157,7 +2450,13 @@
@@ -2157,7 +2451,13 @@
IBlockData iblockdata = this.getType(blockposition);
AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().c(this, blockposition);
@ -603,7 +611,7 @@
}
public int K() {
@@ -2267,6 +2566,11 @@
@@ -2267,6 +2567,11 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
@ -615,7 +623,7 @@
if (predicate.apply(entityhuman1)) {
double d5 = entityhuman1.d(d0, d1, d2);
@@ -2435,6 +2739,16 @@
@@ -2435,6 +2740,16 @@
public void everyoneSleeping() {}
@ -632,7 +640,7 @@
public float h(float f) {
return (this.p + (this.q - this.p) * f) * this.j(f);
}
@@ -2652,7 +2966,7 @@
@@ -2652,7 +2967,7 @@
int l = j * 16 + 8 - blockposition.getZ();
boolean flag = true;