Update to Minecraft 1.15

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-12-11 09:00:00 +11:00
parent 1400103b2f
commit 0e142c7f03
293 changed files with 2875 additions and 2648 deletions

View File

@@ -95,7 +95,7 @@
public void tick() {
this.syncPosition();
@@ -106,7 +177,7 @@
@@ -109,7 +180,7 @@
this.minecraftServer.getMethodProfiler().enter("keepAlive");
long i = SystemUtils.getMonotonicMillis();
@@ -104,7 +104,7 @@
if (this.awaitingKeepAlive) {
this.disconnect(new ChatMessage("disconnect.timeout", new Object[0]));
} else {
@@ -118,15 +189,21 @@
@@ -121,15 +192,21 @@
}
this.minecraftServer.getMethodProfiler().exit();
@@ -126,8 +126,8 @@
this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0]));
}
@@ -150,16 +227,46 @@
return this.minecraftServer.b(this.player.getProfile());
@@ -153,16 +230,46 @@
return this.minecraftServer.a(this.player.getProfile());
}
+ // CraftBukkit start
@@ -174,7 +174,7 @@
}
@Override
@@ -200,7 +307,34 @@
@@ -203,7 +310,34 @@
double d9 = entity.getMot().g();
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@@ -210,7 +210,7 @@
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), d6, d7, d8);
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
return;
@@ -230,14 +364,72 @@
@@ -233,14 +367,72 @@
}
entity.setLocation(d3, d4, d5, f, f1);
@@ -281,9 +281,9 @@
+ // CraftBukkit end
+
this.player.getWorldServer().getChunkProvider().movePlayer(this.player);
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));
@@ -252,7 +444,7 @@
this.player.checkMovement(this.player.locX() - d0, this.player.locY() - d1, this.player.locZ() - d2);
this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.b(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
@@ -255,7 +447,7 @@
@Override
public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) {
PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer());
@@ -292,7 +292,7 @@
this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
this.o = this.teleportPos.x;
this.p = this.teleportPos.y;
@@ -262,6 +454,7 @@
@@ -265,6 +457,7 @@
}
this.teleportPos = null;
@@ -300,7 +300,7 @@
}
}
@@ -270,7 +463,7 @@
@@ -273,7 +466,7 @@
public void a(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
PlayerConnectionUtils.ensureMainThread(packetplayinrecipedisplayed, this, this.player.getWorldServer());
if (packetplayinrecipedisplayed.b() == PacketPlayInRecipeDisplayed.Status.SHOWN) {
@@ -309,7 +309,7 @@
RecipeBookServer recipebookserver = this.player.B();
optional.ifPresent(recipebookserver::e);
@@ -304,6 +497,12 @@
@@ -307,6 +500,12 @@
@Override
public void a(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer());
@@ -322,7 +322,7 @@
StringReader stringreader = new StringReader(packetplayintabcomplete.c());
if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -313,7 +512,8 @@
@@ -316,7 +515,8 @@
ParseResults<CommandListenerWrapper> parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener());
this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@@ -332,7 +332,7 @@
});
}
@@ -518,6 +718,7 @@
@@ -526,6 +726,7 @@
if (container instanceof ContainerMerchant) {
ContainerMerchant containermerchant = (ContainerMerchant) container;
@@ -340,12 +340,11 @@
containermerchant.d(i);
containermerchant.g(i);
@@ -527,6 +728,15 @@
@@ -536,6 +737,14 @@
@Override
public void a(PacketPlayInBEdit packetplayinbedit) {
PlayerConnectionUtils.ensureMainThread(packetplayinbedit, this, this.player.getWorldServer());
+ // CraftBukkit start
+ PlayerConnectionUtils.ensureMainThread(packetplayinbedit, this, this.player.getWorldServer());
+ if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
+ this.disconnect("Book edited too quickly!");
+ return;
@@ -356,7 +355,7 @@
ItemStack itemstack = packetplayinbedit.b();
if (!itemstack.isEmpty()) {
@@ -555,9 +765,11 @@
@@ -564,9 +773,11 @@
}
itemstack2.a("pages", (NBTBase) nbttaglist);
@@ -369,7 +368,7 @@
}
}
@@ -599,7 +811,7 @@
@@ -608,7 +819,7 @@
} else {
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@@ -378,7 +377,7 @@
if (this.e == 0) {
this.syncPosition();
}
@@ -609,13 +821,21 @@
@@ -618,13 +829,21 @@
this.A = this.e;
this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
}
@@ -387,21 +386,21 @@
} else {
this.A = this.e;
if (this.player.isPassenger()) {
this.player.setLocation(this.player.locX, this.player.locY, this.player.locZ, packetplayinflying.a(this.player.yaw), packetplayinflying.b(this.player.pitch));
this.player.setLocation(this.player.locX(), this.player.locY(), this.player.locZ(), packetplayinflying.a(this.player.yaw), packetplayinflying.b(this.player.pitch));
this.player.getWorldServer().getChunkProvider().movePlayer(this.player);
+ this.allowedPlayerTicks = 20; // CraftBukkit
} else {
+ // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify
+ double prevX = player.locX;
+ double prevY = player.locY;
+ double prevZ = player.locZ;
+ double prevX = player.locX();
+ double prevY = player.locY();
+ double prevZ = player.locZ();
+ float prevYaw = player.yaw;
+ float prevPitch = player.pitch;
+ // CraftBukkit end
double d0 = this.player.locX;
double d1 = this.player.locY;
double d2 = this.player.locZ;
@@ -640,15 +860,33 @@
double d0 = this.player.locX();
double d1 = this.player.locY();
double d2 = this.player.locZ();
@@ -649,15 +868,33 @@
++this.receivedMovePackets;
int i = this.receivedMovePackets - this.processedMovePackets;
@@ -435,9 +434,9 @@
+ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isExemptPlayer()) {
+ // CraftBukkit end
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, 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;
@@ -694,6 +932,69 @@
@@ -707,6 +944,69 @@
}
}
@@ -504,10 +503,10 @@
+ this.player.setLocation(d4, d5, d6, f, f1); // Copied from above
+ // CraftBukkit end
+
this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && !worldserver.b(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
this.player.onGround = packetplayinflying.b();
this.player.getWorldServer().getChunkProvider().movePlayer(this.player);
@@ -713,10 +1014,66 @@
@@ -726,10 +1026,66 @@
}
public void a(double d0, double d1, double d2, float f, float f1) {
@@ -572,10 +571,10 @@
+
+ this.justTeleported = true;
+ // CraftBukkit end
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 d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D;
@@ -728,6 +1085,14 @@
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 d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ() : 0.0D;
@@ -741,6 +1097,14 @@
this.teleportAwait = 0;
}
@@ -590,7 +589,7 @@
this.A = this.e;
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));
@@ -736,6 +1101,7 @@
@@ -749,6 +1113,7 @@
@Override
public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer());
@@ -598,7 +597,7 @@
BlockPosition blockposition = packetplayinblockdig.b();
this.player.resetIdleTimer();
@@ -746,13 +1112,45 @@
@@ -759,13 +1124,45 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
@@ -646,7 +645,7 @@
this.player.n(false);
}
@@ -779,6 +1177,7 @@
@@ -792,6 +1189,7 @@
@Override
public void a(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer());
@@ -654,10 +653,10 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
EnumHand enumhand = packetplayinuseitem.b();
ItemStack itemstack = this.player.b(enumhand);
@@ -792,6 +1191,14 @@
@@ -805,6 +1203,14 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO));
} else if (this.teleportPos == null && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) {
} else if (this.teleportPos == null && this.player.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) {
+ // CraftBukkit start - Check if we can actually do something over this large a distance
+ Location eyeLoc = this.getPlayer().getEyeLocation();
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
@@ -666,10 +665,10 @@
+ }
+ this.player.clearActiveItem(); // SPIGOT-4706
+ // CraftBukkit end
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
}
EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
@@ -802,13 +1209,53 @@
if (enuminteractionresult.b()) {
@@ -819,13 +1225,53 @@
@Override
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer());
@@ -685,9 +684,9 @@
+ // Raytrace to look for 'rogue armswings'
+ float f1 = this.player.pitch;
+ float f2 = this.player.yaw;
+ double d0 = this.player.locX;
+ double d1 = this.player.locY + (double) this.player.getHeadHeight();
+ double d2 = this.player.locZ;
+ double d0 = this.player.locX();
+ double d1 = this.player.locY() + (double) this.player.getHeadHeight();
+ double d2 = this.player.locZ();
+ Vec3D vec3d = new Vec3D(d0, d1, d2);
+
+ float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
@@ -724,16 +723,16 @@
}
}
@@ -823,7 +1270,7 @@
@@ -840,7 +1286,7 @@
Entity entity = packetplayinspectate.a(worldserver);
if (entity != null) {
- this.player.a(worldserver, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
+ this.player.a(worldserver, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
- this.player.a(worldserver, entity.locX(), entity.locY(), entity.locZ(), entity.yaw, entity.pitch);
+ this.player.a(worldserver, entity.locX(), entity.locY(), entity.locZ(), entity.yaw, entity.pitch, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
return;
}
}
@@ -832,7 +1279,12 @@
@@ -849,7 +1295,12 @@
}
@Override
@@ -747,7 +746,7 @@
@Override
public void a(PacketPlayInBoatMove packetplayinboatmove) {
@@ -847,11 +1299,26 @@
@@ -864,11 +1315,26 @@
@Override
public void a(IChatBaseComponent ichatbasecomponent) {
@@ -775,7 +774,7 @@
if (this.isExemptPlayer()) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown(false);
@@ -877,6 +1344,15 @@
@@ -894,6 +1360,15 @@
}
}
@@ -791,7 +790,7 @@
try {
this.networkManager.sendPacket(packet, genericfuturelistener);
} catch (Throwable throwable) {
@@ -893,18 +1369,38 @@
@@ -910,18 +1385,38 @@
@Override
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
@@ -832,7 +831,7 @@
this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED)));
} else {
this.player.resetIdleTimer();
@@ -914,41 +1410,257 @@
@@ -931,41 +1426,257 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@@ -1040,9 +1039,9 @@
+ // CraftBukkit start - Raytrace to look for 'rogue armswings'
+ float f1 = this.player.pitch;
+ float f2 = this.player.yaw;
+ double d0 = this.player.locX;
+ double d1 = this.player.locY + (double) this.player.getHeadHeight();
+ double d2 = this.player.locZ;
+ double d0 = this.player.locX();
+ double d1 = this.player.locY() + (double) this.player.getHeadHeight();
+ double d2 = this.player.locZ();
+ Vec3D vec3d = new Vec3D(d0, d1, d2);
+
+ float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
@@ -1074,9 +1073,9 @@
+ // CraftBukkit start
+ if (this.player.dead) return;
+ switch (packetplayinentityaction.c()) {
+ case START_SNEAKING:
+ case STOP_SNEAKING:
+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.START_SNEAKING);
+ case PRESS_SHIFT_KEY:
+ case RELEASE_SHIFT_KEY:
+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY);
+ this.server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
@@ -1097,7 +1096,7 @@
this.player.resetIdleTimer();
IJumpable ijumpable;
@@ -1012,6 +1724,7 @@
@@ -1023,6 +1734,7 @@
@Override
public void a(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer());
@@ -1105,7 +1104,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
@@ -1027,20 +1740,74 @@
@@ -1038,9 +1750,52 @@
if (this.player.h(entity) < d0) {
EnumHand enumhand;
@@ -1157,7 +1156,11 @@
+ // CraftBukkit end
} else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
enumhand = packetplayinuseentity.c();
entity.a((EntityHuman) this.player, packetplayinuseentity.d(), enumhand);
EnumInteractionResult enuminteractionresult = entity.a((EntityHuman) this.player, packetplayinuseentity.d(), enumhand);
@@ -1048,14 +1803,25 @@
if (enuminteractionresult.b()) {
this.player.a(enumhand, true);
}
+ // CraftBukkit start
+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
+ this.player.updateInventory(this.player.activeContainer);
@@ -1181,7 +1184,7 @@
}
}
}
@@ -1080,15 +1847,21 @@
@@ -1095,15 +1861,21 @@
@Override
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
@@ -1205,7 +1208,7 @@
NonNullList<ItemStack> nonnulllist = NonNullList.a();
for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) {
@@ -1097,8 +1870,274 @@
@@ -1112,8 +1884,274 @@
this.player.a(this.player.activeContainer, nonnulllist);
} else {
@@ -1481,7 +1484,7 @@
if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true));
this.player.e = true;
@@ -1138,6 +2177,7 @@
@@ -1153,6 +2191,7 @@
@Override
public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
@@ -1489,7 +1492,7 @@
this.player.resetIdleTimer();
if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
this.player.activeContainer.a((EntityHuman) this.player, packetplayinenchantitem.c());
@@ -1170,6 +2210,43 @@
@@ -1185,6 +2224,43 @@
boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@@ -1533,7 +1536,7 @@
if (flag1 && flag2) {
if (itemstack.isEmpty()) {
@@ -1195,6 +2272,7 @@
@@ -1206,6 +2282,7 @@
@Override
public void a(PacketPlayInTransaction packetplayintransaction) {
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer());
@@ -1541,7 +1544,7 @@
int i = this.player.activeContainer.windowId;
if (i == packetplayintransaction.b() && this.k.getOrDefault(i, (short) (packetplayintransaction.c() + 1)) == packetplayintransaction.c() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
@@ -1206,6 +2284,7 @@
@@ -1217,6 +2294,7 @@
@Override
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer());
@@ -1549,7 +1552,7 @@
this.player.resetIdleTimer();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinupdatesign.b();
@@ -1222,14 +2301,30 @@
@@ -1233,14 +2311,30 @@
if (!tileentitysign.d() || tileentitysign.f() != this.player) {
this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign");
@@ -1581,7 +1584,7 @@
tileentitysign.update();
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
@@ -1239,6 +2334,7 @@
@@ -1250,6 +2344,7 @@
@Override
public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
@@ -1589,7 +1592,7 @@
if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) {
int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive);
@@ -1253,7 +2349,17 @@
@@ -1264,7 +2359,17 @@
@Override
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
@@ -1608,7 +1611,7 @@
}
@Override
@@ -1262,8 +2368,50 @@
@@ -1273,8 +2378,50 @@
this.player.a(packetplayinsettings);
}