SPIGOT-4396: Improve vehicle movement

This commit is contained in:
Aikar 2018-09-26 17:19:16 +10:00 committed by md_5
parent 020b495274
commit 40aed54d11
4 changed files with 115 additions and 65 deletions

View file

@ -107,7 +107,15 @@
this.yaw = f % 360.0F; this.yaw = f % 360.0F;
this.pitch = f1 % 360.0F; this.pitch = f1 % 360.0F;
} }
@@ -234,6 +318,51 @@ @@ -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 @@
this.W(); this.W();
} }
@ -159,7 +167,7 @@
public void W() { public void W() {
this.world.methodProfiler.a("entityBaseTick"); this.world.methodProfiler.a("entityBaseTick");
if (this.isPassenger() && this.getVehicle().dead) { if (this.isPassenger() && this.getVehicle().dead) {
@@ -250,6 +379,8 @@ @@ -250,6 +380,8 @@
this.lastZ = this.locZ; this.lastZ = this.locZ;
this.lastPitch = this.pitch; this.lastPitch = this.pitch;
this.lastYaw = this.yaw; this.lastYaw = this.yaw;
@ -168,7 +176,7 @@
if (!this.world.isClientSide && this.world instanceof WorldServer) { if (!this.world.isClientSide && this.world instanceof WorldServer) {
this.world.methodProfiler.a("portal"); this.world.methodProfiler.a("portal");
if (this.an) { if (this.an) {
@@ -289,6 +420,7 @@ @@ -289,6 +421,7 @@
this.E(); this.E();
this.world.methodProfiler.e(); this.world.methodProfiler.e();
} }
@ -176,7 +184,7 @@
this.av(); this.av();
this.r(); this.r();
@@ -339,7 +471,23 @@ @@ -339,7 +472,23 @@
protected void burnFromLava() { protected void burnFromLava() {
if (!this.fireProof) { if (!this.fireProof) {
@ -201,7 +209,7 @@
this.damageEntity(DamageSource.LAVA, 4.0F); this.damageEntity(DamageSource.LAVA, 4.0F);
} }
} }
@@ -505,7 +653,7 @@ @@ -505,7 +654,7 @@
} }
} }
@ -210,7 +218,7 @@
double d11; double d11;
if (this.Q > 0.0F && flag && (d7 != d0 || d9 != d2)) { if (this.Q > 0.0F && flag && (d7 != d0 || d9 != d2)) {
@@ -592,7 +740,7 @@ @@ -592,7 +741,7 @@
this.world.methodProfiler.a("rest"); this.world.methodProfiler.a("rest");
this.recalcPosition(); this.recalcPosition();
this.positionChanged = d7 != d0 || d9 != d2; this.positionChanged = d7 != d0 || d9 != d2;
@ -219,7 +227,7 @@
this.onGround = this.C && d8 < 0.0D; this.onGround = this.C && d8 < 0.0D;
this.D = this.positionChanged || this.C; this.D = this.positionChanged || this.C;
int k = MathHelper.floor(this.locX); int k = MathHelper.floor(this.locX);
@@ -627,6 +775,28 @@ @@ -627,6 +776,28 @@
block1.a((IBlockAccess) this.world, this); block1.a((IBlockAccess) this.world, this);
} }
@ -248,7 +256,7 @@
if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) { if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) {
double d22 = this.locX - d4; double d22 = this.locX - d4;
double d23 = this.locY - d5; double d23 = this.locY - d5;
@@ -678,7 +848,14 @@ @@ -678,7 +849,14 @@
if (!flag1) { if (!flag1) {
++this.fireTicks; ++this.fireTicks;
if (this.fireTicks == 0) { if (this.fireTicks == 0) {
@ -264,7 +272,15 @@
} }
} }
@@ -876,7 +1053,7 @@ @@ -706,6 +884,7 @@
this.locX = (axisalignedbb.a + axisalignedbb.d) / 2.0D;
this.locY = axisalignedbb.b;
this.locZ = (axisalignedbb.c + axisalignedbb.f) / 2.0D;
+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit
}
protected SoundEffect ad() {
@@ -876,7 +1055,7 @@
return null; return null;
} }
@ -273,7 +289,7 @@
if (!this.fireProof) { if (!this.fireProof) {
this.damageEntity(DamageSource.FIRE, (float) i); this.damageEntity(DamageSource.FIRE, (float) i);
} }
@@ -1095,6 +1272,13 @@ @@ -1095,6 +1274,13 @@
} }
public void spawnIn(World world) { public void spawnIn(World world) {
@ -287,7 +303,15 @@
this.world = world; this.world = world;
} }
@@ -1302,7 +1486,7 @@ @@ -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 @@
public boolean c(NBTTagCompound nbttagcompound) { public boolean c(NBTTagCompound nbttagcompound) {
String s = this.getSaveID(); String s = this.getSaveID();
@ -296,7 +320,7 @@
nbttagcompound.setString("id", s); nbttagcompound.setString("id", s);
this.save(nbttagcompound); this.save(nbttagcompound);
return true; return true;
@@ -1319,6 +1503,18 @@ @@ -1319,6 +1506,18 @@
try { try {
nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ})); 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})); nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ}));
@ -315,7 +339,7 @@
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch})); nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setFloat("FallDistance", this.fallDistance);
nbttagcompound.setShort("Fire", (short) this.fireTicks); nbttagcompound.setShort("Fire", (short) this.fireTicks);
@@ -1328,6 +1524,12 @@ @@ -1328,6 +1527,12 @@
nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
nbttagcompound.a("UUID", this.getUniqueID()); nbttagcompound.a("UUID", this.getUniqueID());
@ -328,7 +352,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName(); IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) { if (ichatbasecomponent != null) {
@@ -1404,6 +1606,8 @@ @@ -1404,6 +1609,8 @@
this.motX = nbttaglist1.k(0); this.motX = nbttaglist1.k(0);
this.motY = nbttaglist1.k(1); this.motY = nbttaglist1.k(1);
this.motZ = nbttaglist1.k(2); this.motZ = nbttaglist1.k(2);
@ -337,7 +361,7 @@
if (Math.abs(this.motX) > 10.0D) { if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D; this.motX = 0.0D;
} }
@@ -1415,6 +1619,7 @@ @@ -1415,6 +1622,7 @@
if (Math.abs(this.motZ) > 10.0D) { if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D; this.motZ = 0.0D;
} }
@ -345,7 +369,7 @@
this.locX = nbttaglist.k(0); this.locX = nbttaglist.k(0);
this.locY = nbttaglist.k(1); this.locY = nbttaglist.k(1);
@@ -1471,6 +1676,56 @@ @@ -1471,6 +1679,56 @@
this.setPosition(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
} }
@ -402,7 +426,7 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
@@ -1544,9 +1799,22 @@ @@ -1544,9 +1802,22 @@
if (itemstack.isEmpty()) { if (itemstack.isEmpty()) {
return null; return null;
} else { } else {
@ -425,7 +449,7 @@
this.world.addEntity(entityitem); this.world.addEntity(entityitem);
return entityitem; return entityitem;
} }
@@ -1658,7 +1926,7 @@ @@ -1658,7 +1929,7 @@
} }
this.vehicle = entity; this.vehicle = entity;
@ -434,7 +458,7 @@
return true; return true;
} }
} }
@@ -1679,15 +1947,33 @@ @@ -1679,15 +1950,33 @@
Entity entity = this.vehicle; Entity entity = this.vehicle;
this.vehicle = null; this.vehicle = null;
@ -470,7 +494,7 @@
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) { if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) {
this.passengers.add(0, entity); this.passengers.add(0, entity);
} else { } else {
@@ -1695,15 +1981,33 @@ @@ -1695,15 +1984,33 @@
} }
} }
@ -505,7 +529,7 @@
} }
protected boolean q(Entity entity) { protected boolean q(Entity entity) {
@@ -1800,6 +2104,13 @@ @@ -1800,6 +2107,13 @@
} }
public void setSwimming(boolean flag) { public void setSwimming(boolean flag) {
@ -519,7 +543,7 @@
this.setFlag(4, flag); this.setFlag(4, flag);
} }
@@ -1860,16 +2171,53 @@ @@ -1860,16 +2174,53 @@
} }
public void setAirTicks(int i) { public void setAirTicks(int i) {
@ -576,7 +600,7 @@
} }
public void j(boolean flag) { public void j(boolean flag) {
@@ -2036,19 +2384,72 @@ @@ -2036,19 +2387,72 @@
if (!this.world.isClientSide && !this.dead) { if (!this.world.isClientSide && !this.dead) {
this.world.methodProfiler.a("changeDimension"); this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = this.bK(); MinecraftServer minecraftserver = this.bK();
@ -652,7 +676,7 @@
BlockPosition blockposition; BlockPosition blockposition;
if (dimensionmanager == DimensionManager.THE_END) { if (dimensionmanager == DimensionManager.THE_END) {
@@ -2077,12 +2478,18 @@ @@ -2077,12 +2481,18 @@
blockposition = new BlockPosition(this); blockposition = new BlockPosition(this);
} }
@ -672,7 +696,7 @@
if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) { if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) {
BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()); BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
@@ -2090,6 +2497,7 @@ @@ -2090,6 +2500,7 @@
} else { } else {
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
} }
@ -680,7 +704,7 @@
boolean flag = entity.attachedToPlayer; boolean flag = entity.attachedToPlayer;
@@ -2097,13 +2505,21 @@ @@ -2097,13 +2508,21 @@
worldserver1.addEntity(entity); worldserver1.addEntity(entity);
entity.attachedToPlayer = flag; entity.attachedToPlayer = flag;
worldserver1.entityJoinedWorld(entity, false); worldserver1.entityJoinedWorld(entity, false);
@ -703,7 +727,7 @@
return entity; return entity;
} else { } else {
return null; return null;
@@ -2243,7 +2659,26 @@ @@ -2243,7 +2662,26 @@
} }
public void a(AxisAlignedBB axisalignedbb) { public void a(AxisAlignedBB axisalignedbb) {

View file

@ -8,7 +8,15 @@
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -67,22 +69,42 @@ @@ -29,6 +31,7 @@
this.locX = (double) this.blockPosition.getX() + 0.5D;
this.locY = (double) this.blockPosition.getY() + 0.5D;
this.locZ = (double) this.blockPosition.getZ() + 0.5D;
+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit
}
public void setDirection(EnumDirection enumdirection) {}
@@ -67,22 +70,42 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next(); entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) { if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) {

View file

@ -31,3 +31,11 @@
break; break;
} }
} }
@@ -372,6 +385,7 @@
this.locX = (double) blockposition.getX() + 0.5D;
this.locY = (double) blockposition.getY();
this.locZ = (double) blockposition.getZ() + 0.5D;
+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;

View file

@ -212,7 +212,17 @@
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)); PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8));
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
return; return;
@@ -230,6 +366,62 @@ @@ -222,14 +358,72 @@
}
entity.setLocation(d3, d4, d5, f, f1);
+ player.setLocation(d3, d4, d5, f, f1); // CraftBukkit
boolean flag2 = worldserver.getCubes(entity, entity.getBoundingBox().shrink(0.0625D));
if (flag && (flag1 || !flag2)) {
entity.setLocation(d0, d1, d2, f, f1);
+ player.setLocation(d0, d1, d2, f, f1); // CraftBukkit
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
return; return;
} }
@ -275,7 +285,7 @@
this.minecraftServer.getPlayerList().d(this.player); this.minecraftServer.getPlayerList().d(this.player);
this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2); this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2);
this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.a(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.a(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
@@ -243,7 +435,7 @@ @@ -243,7 +437,7 @@
public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) { public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) {
PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer());
@ -284,7 +294,7 @@
this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
this.o = this.teleportPos.x; this.o = this.teleportPos.x;
this.p = this.teleportPos.y; this.p = this.teleportPos.y;
@@ -253,6 +445,7 @@ @@ -253,6 +447,7 @@
} }
this.teleportPos = null; this.teleportPos = null;
@ -292,7 +302,7 @@
} }
} }
@@ -289,6 +482,12 @@ @@ -289,6 +484,12 @@
public void a(PacketPlayInTabComplete packetplayintabcomplete) { public void a(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer());
@ -305,7 +315,7 @@
StringReader stringreader = new StringReader(packetplayintabcomplete.c()); StringReader stringreader = new StringReader(packetplayintabcomplete.c());
if (stringreader.canRead() && stringreader.peek() == 47) { if (stringreader.canRead() && stringreader.peek() == 47) {
@@ -298,7 +497,8 @@ @@ -298,7 +499,8 @@
ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener()); ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener());
this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@ -315,7 +325,7 @@
}); });
} }
@@ -492,6 +692,15 @@ @@ -492,6 +694,15 @@
} }
public void a(PacketPlayInBEdit packetplayinbedit) { public void a(PacketPlayInBEdit packetplayinbedit) {
@ -331,7 +341,7 @@
ItemStack itemstack = packetplayinbedit.b(); ItemStack itemstack = packetplayinbedit.b();
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
@@ -516,11 +725,13 @@ @@ -516,11 +727,13 @@
} }
itemstack2.a("pages", (NBTBase) nbttaglist); itemstack2.a("pages", (NBTBase) nbttaglist);
@ -347,7 +357,7 @@
} }
} }
@@ -560,7 +771,7 @@ @@ -560,7 +773,7 @@
} else { } else {
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@ -356,7 +366,7 @@
if (this.e == 0) { if (this.e == 0) {
this.syncPosition(); this.syncPosition();
} }
@@ -570,13 +781,21 @@ @@ -570,13 +783,21 @@
this.A = this.e; this.A = this.e;
this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
} }
@ -379,7 +389,7 @@
double d0 = this.player.locX; double d0 = this.player.locX;
double d1 = this.player.locY; double d1 = this.player.locY;
double d2 = this.player.locZ; double d2 = this.player.locZ;
@@ -601,15 +820,33 @@ @@ -601,15 +822,33 @@
++this.receivedMovePackets; ++this.receivedMovePackets;
int i = this.receivedMovePackets - this.processedMovePackets; int i = this.receivedMovePackets - this.processedMovePackets;
@ -415,7 +425,7 @@
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9)); PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9));
this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch); this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch);
return; return;
@@ -655,6 +892,69 @@ @@ -655,6 +894,69 @@
} }
} }
@ -485,7 +495,7 @@
this.B = d12 >= -0.03125D; this.B = d12 >= -0.03125D;
this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly; this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly;
this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.dc() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.dc() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
@@ -672,10 +972,76 @@ @@ -672,10 +974,76 @@
} }
public void a(double d0, double d1, double d2, float f, float f1) { public void a(double d0, double d1, double d2, float f, float f1) {
@ -563,7 +573,7 @@
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D; double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D;
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D; double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D;
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D; double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D;
@@ -687,6 +1053,14 @@ @@ -687,6 +1055,14 @@
this.teleportAwait = 0; this.teleportAwait = 0;
} }
@ -578,7 +588,7 @@
this.A = this.e; this.A = this.e;
this.player.setLocation(d0, d1, d2, f, f1); this.player.setLocation(d0, d1, d2, f, f1);
this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait)); this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait));
@@ -694,6 +1068,7 @@ @@ -694,6 +1070,7 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) { public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer());
@ -586,7 +596,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinblockdig.b(); BlockPosition blockposition = packetplayinblockdig.b();
@@ -703,14 +1078,46 @@ @@ -703,14 +1080,46 @@
if (!this.player.isSpectator()) { if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
@ -635,7 +645,7 @@
this.player.a(false); this.player.a(false);
} }
@@ -744,7 +1151,15 @@ @@ -744,7 +1153,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c()); this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c());
} else { } else {
@ -651,7 +661,7 @@
} }
} else { } else {
if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
@@ -764,10 +1179,12 @@ @@ -764,10 +1181,12 @@
default: default:
throw new IllegalArgumentException("Invalid player action"); throw new IllegalArgumentException("Invalid player action");
} }
@ -664,7 +674,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
EnumHand enumhand = packetplayinuseitem.d(); EnumHand enumhand = packetplayinuseitem.d();
ItemStack itemstack = this.player.b(enumhand); ItemStack itemstack = this.player.b(enumhand);
@@ -780,6 +1197,13 @@ @@ -780,6 +1199,13 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO)); this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO));
} else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { } else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
@ -678,7 +688,7 @@
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.e(), packetplayinuseitem.f(), packetplayinuseitem.g()); this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.e(), packetplayinuseitem.f(), packetplayinuseitem.g());
} }
@@ -789,13 +1213,52 @@ @@ -789,13 +1215,52 @@
public void a(PacketPlayInBlockPlace packetplayinblockplace) { public void a(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer());
@ -732,7 +742,7 @@
} }
} }
@@ -815,13 +1278,18 @@ @@ -815,13 +1280,18 @@
} }
if (entity != null) { if (entity != null) {
@ -753,7 +763,7 @@
public void a(PacketPlayInBoatMove packetplayinboatmove) { public void a(PacketPlayInBoatMove packetplayinboatmove) {
PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.getWorldServer());
@@ -834,11 +1302,26 @@ @@ -834,11 +1304,26 @@
} }
public void a(IChatBaseComponent ichatbasecomponent) { public void a(IChatBaseComponent ichatbasecomponent) {
@ -781,7 +791,7 @@
if (this.minecraftServer.H() && this.player.getDisplayName().getString().equals(this.minecraftServer.G())) { if (this.minecraftServer.H() && this.player.getDisplayName().getString().equals(this.minecraftServer.G())) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown(); this.minecraftServer.safeShutdown();
@@ -864,6 +1347,15 @@ @@ -864,6 +1349,15 @@
} }
} }
@ -797,7 +807,7 @@
try { try {
this.networkManager.sendPacket(packet, genericfuturelistener); this.networkManager.sendPacket(packet, genericfuturelistener);
} catch (Throwable throwable) { } catch (Throwable throwable) {
@@ -879,17 +1371,37 @@ @@ -879,17 +1373,37 @@
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
@ -837,7 +847,7 @@
this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED))); this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED)));
} else { } else {
this.player.resetIdleTimer(); this.player.resetIdleTimer();
@@ -899,39 +1411,249 @@ @@ -899,39 +1413,249 @@
for (int i = 0; i < s.length(); ++i) { for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@ -1094,7 +1104,7 @@
this.player.resetIdleTimer(); this.player.resetIdleTimer();
IJumpable ijumpable; IJumpable ijumpable;
@@ -1003,6 +1725,7 @@ @@ -1003,6 +1727,7 @@
public void a(PacketPlayInUseEntity packetplayinuseentity) { public void a(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer());
@ -1102,7 +1112,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver); Entity entity = packetplayinuseentity.a((World) worldserver);
@@ -1018,20 +1741,73 @@ @@ -1018,20 +1743,73 @@
if (this.player.h(entity) < d0) { if (this.player.h(entity) < d0) {
EnumHand enumhand; EnumHand enumhand;
@ -1177,7 +1187,7 @@
} }
} }
} }
@@ -1047,7 +1823,8 @@ @@ -1047,7 +1825,8 @@
case PERFORM_RESPAWN: case PERFORM_RESPAWN:
if (this.player.viewingCredits) { if (this.player.viewingCredits) {
this.player.viewingCredits = false; this.player.viewingCredits = false;
@ -1187,7 +1197,7 @@
CriterionTriggers.v.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD); CriterionTriggers.v.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD);
} else { } else {
if (this.player.getHealth() > 0.0F) { if (this.player.getHealth() > 0.0F) {
@@ -1070,14 +1847,20 @@ @@ -1070,14 +1849,20 @@
public void a(PacketPlayInCloseWindow packetplayinclosewindow) { public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
@ -1210,7 +1220,7 @@
NonNullList nonnulllist = NonNullList.a(); NonNullList nonnulllist = NonNullList.a();
for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) { for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) {
@@ -1086,8 +1869,274 @@ @@ -1086,8 +1871,274 @@
this.player.a(this.player.activeContainer, nonnulllist); this.player.a(this.player.activeContainer, nonnulllist);
} else { } else {
@ -1486,7 +1496,7 @@
if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) { if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true)); this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true));
this.player.f = true; this.player.f = true;
@@ -1130,6 +2179,7 @@ @@ -1130,6 +2181,7 @@
public void a(PacketPlayInEnchantItem packetplayinenchantitem) { public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
@ -1494,7 +1504,7 @@
this.player.resetIdleTimer(); this.player.resetIdleTimer();
if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
this.player.activeContainer.a(this.player, packetplayinenchantitem.c()); this.player.activeContainer.a(this.player, packetplayinenchantitem.c());
@@ -1161,6 +2211,43 @@ @@ -1161,6 +2213,43 @@
boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@ -1538,7 +1548,7 @@
if (flag1 && flag2) { if (flag1 && flag2) {
if (itemstack.isEmpty()) { if (itemstack.isEmpty()) {
@@ -1184,6 +2271,7 @@ @@ -1184,6 +2273,7 @@
public void a(PacketPlayInTransaction packetplayintransaction) { public void a(PacketPlayInTransaction packetplayintransaction) {
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer());
@ -1546,7 +1556,7 @@
Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
if (oshort != null && packetplayintransaction.c() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.b() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { if (oshort != null && packetplayintransaction.c() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.b() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
@@ -1194,6 +2282,7 @@ @@ -1194,6 +2284,7 @@
public void a(PacketPlayInUpdateSign packetplayinupdatesign) { public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer());
@ -1554,7 +1564,7 @@
this.player.resetIdleTimer(); this.player.resetIdleTimer();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinupdatesign.b(); BlockPosition blockposition = packetplayinupdatesign.b();
@@ -1210,14 +2299,30 @@ @@ -1210,14 +2301,30 @@
if (!tileentitysign.d() || tileentitysign.e() != this.player) { if (!tileentitysign.d() || tileentitysign.e() != this.player) {
this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign"); this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign");
@ -1586,7 +1596,7 @@
tileentitysign.update(); tileentitysign.update();
worldserver.notify(blockposition, iblockdata, iblockdata, 3); worldserver.notify(blockposition, iblockdata, iblockdata, 3);
@@ -1226,6 +2331,7 @@ @@ -1226,6 +2333,7 @@
} }
public void a(PacketPlayInKeepAlive packetplayinkeepalive) { public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
@ -1594,7 +1604,7 @@
if (this.g && packetplayinkeepalive.b() == this.h) { if (this.g && packetplayinkeepalive.b() == this.h) {
int i = (int) (SystemUtils.b() - this.f); int i = (int) (SystemUtils.b() - this.f);
@@ -1239,7 +2345,17 @@ @@ -1239,7 +2347,17 @@
public void a(PacketPlayInAbilities packetplayinabilities) { public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
@ -1613,7 +1623,7 @@
} }
public void a(PacketPlayInSettings packetplayinsettings) { public void a(PacketPlayInSettings packetplayinsettings) {
@@ -1247,5 +2363,47 @@ @@ -1247,5 +2365,47 @@
this.player.a(packetplayinsettings); this.player.a(packetplayinsettings);
} }