diff options
Diffstat (limited to 'nms-patches/PlayerConnection.patch')
-rw-r--r-- | nms-patches/PlayerConnection.patch | 136 |
1 files changed, 67 insertions, 69 deletions
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index 42e0d82e..f2f7b896 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerConnection.java +++ b/net/minecraft/server/PlayerConnection.java -@@ -15,6 +15,50 @@ +@@ -17,6 +17,50 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -51,7 +51,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { private static final Logger LOGGER = LogManager.getLogger(); -@@ -25,7 +69,10 @@ +@@ -27,7 +71,10 @@ private long f; private boolean g; private long h; @@ -63,7 +63,7 @@ private int j; private final IntHashMap<Short> k = new IntHashMap(); private double l; -@@ -57,7 +104,33 @@ +@@ -59,7 +106,33 @@ networkmanager.setPacketListener(this); this.player = entityplayer; entityplayer.playerConnection = this; @@ -97,7 +97,7 @@ public void Y_() { this.syncPosition(); -@@ -103,7 +176,7 @@ +@@ -105,7 +178,7 @@ this.minecraftServer.methodProfiler.a("keepAlive"); long i = SystemUtils.b(); @@ -106,7 +106,7 @@ if (this.g) { this.disconnect(new ChatMessage("disconnect.timeout", new Object[0])); } else { -@@ -115,15 +188,21 @@ +@@ -117,15 +190,21 @@ } this.minecraftServer.methodProfiler.e(); @@ -128,7 +128,7 @@ this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0])); } -@@ -142,16 +221,46 @@ +@@ -144,16 +223,46 @@ return this.networkManager; } @@ -176,11 +176,11 @@ } public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) { -@@ -190,7 +299,34 @@ +@@ -192,7 +301,34 @@ double d9 = entity.motX * entity.motX + entity.motY * entity.motY + entity.motZ * entity.motZ; double d10 = d6 * d6 + d7 * d7 + d8 * d8; -- if (d10 - d9 > 100.0D && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(entity.getDisplayName().getString()))) { +- if (d10 - d9 > 100.0D && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(entity.getDisplayName().getString()))) { + + // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; @@ -207,12 +207,12 @@ + } + speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + -+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(entity.getDisplayName().getString()))) { ++ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(entity.getDisplayName().getString()))) { + // CraftBukkit end 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)); return; -@@ -228,6 +364,62 @@ +@@ -230,6 +366,62 @@ return; } @@ -275,16 +275,16 @@ this.minecraftServer.getPlayerList().d(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)); -@@ -241,7 +433,7 @@ +@@ -243,7 +435,7 @@ public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) { PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer()); - if (packetplayinteleportaccept.b() == this.teleportAwait) { + if (packetplayinteleportaccept.b() == this.teleportAwait && this.teleportPos != null) { // CraftBukkit this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); - if (this.player.H()) { - this.o = this.teleportPos.x; -@@ -287,10 +479,17 @@ + this.o = this.teleportPos.x; + this.p = this.teleportPos.y; +@@ -289,6 +481,12 @@ public void a(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); @@ -294,7 +294,11 @@ + return; + } + // CraftBukkit end - ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(packetplayintabcomplete.c(), this.player.getCommandListener()); + StringReader stringreader = new StringReader(packetplayintabcomplete.c()); + + if (stringreader.canRead() && stringreader.peek() == 47) { +@@ -298,7 +496,8 @@ + ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener()); this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { - this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions)); @@ -303,7 +307,7 @@ }); } -@@ -484,6 +683,14 @@ +@@ -492,6 +691,15 @@ } public void a(PacketPlayInBEdit packetplayinbedit) { @@ -314,23 +318,28 @@ + return; + } + this.lastBookTick = MinecraftServer.currentTick; ++ EnumItemSlot enumitemslot = packetplayinbedit.d() == EnumHand.MAIN_HAND ? EnumItemSlot.MAINHAND : EnumItemSlot.OFFHAND; + // CraftBukkit end ItemStack itemstack = packetplayinbedit.b(); if (!itemstack.isEmpty()) { -@@ -508,9 +715,10 @@ +@@ -516,11 +724,13 @@ } itemstack2.a("pages", (NBTBase) nbttaglist); -- this.player.setSlot(EnumItemSlot.MAINHAND, itemstack2); -+ CraftEventFactory.handleEditBookEvent(player, itemstack2); // CraftBukkit +- EnumItemSlot enumitemslot = packetplayinbedit.d() == EnumHand.MAIN_HAND ? EnumItemSlot.MAINHAND : EnumItemSlot.OFFHAND; ++ // EnumItemSlot enumitemslot = packetplayinbedit.d() == EnumHand.MAIN_HAND ? EnumItemSlot.MAINHAND : EnumItemSlot.OFFHAND; // CraftBukkit - Moved up + +- this.player.setSlot(enumitemslot, itemstack2); ++ this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, itemstack2)); // CraftBukkit } else { ++ ItemStack old = itemstack1.cloneItemStack(); // CraftBukkit itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8)); -+ CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit ++ CraftEventFactory.handleEditBookEvent(player, enumitemslot, old, itemstack1); // CraftBukkit } } -@@ -550,7 +758,7 @@ +@@ -560,7 +770,7 @@ } else { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); @@ -339,7 +348,7 @@ if (this.e == 0) { this.syncPosition(); } -@@ -560,13 +768,21 @@ +@@ -570,13 +780,21 @@ this.A = this.e; this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); } @@ -362,7 +371,7 @@ double d0 = this.player.locX; double d1 = this.player.locY; double d2 = this.player.locZ; -@@ -591,15 +807,33 @@ +@@ -601,15 +819,33 @@ ++this.receivedMovePackets; int i = this.receivedMovePackets - this.processedMovePackets; @@ -392,13 +401,13 @@ if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.dc())) { float f2 = this.player.dc() ? 300.0F : 100.0F; -- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(this.player.getProfile().getName()))) { -+ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(this.player.getProfile().getName()))) { +- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(this.player.getProfile().getName()))) { ++ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(this.player.getProfile().getName()))) { + // CraftBukkit end 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); return; -@@ -645,6 +879,69 @@ +@@ -655,6 +891,69 @@ } } @@ -468,7 +477,7 @@ this.B = d12 >= -0.03125D; 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)); -@@ -662,10 +959,76 @@ +@@ -672,10 +971,76 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -546,7 +555,7 @@ 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; -@@ -677,6 +1040,14 @@ +@@ -687,6 +1052,14 @@ this.teleportAwait = 0; } @@ -561,7 +570,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)); -@@ -684,6 +1055,7 @@ +@@ -694,6 +1067,7 @@ public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer()); @@ -569,7 +578,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinblockdig.b(); -@@ -693,14 +1065,46 @@ +@@ -703,14 +1077,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); @@ -618,7 +627,7 @@ this.player.a(false); } -@@ -734,7 +1138,15 @@ +@@ -744,7 +1150,15 @@ if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c()); } else { @@ -634,7 +643,7 @@ } } else { if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { -@@ -754,10 +1166,12 @@ +@@ -764,10 +1178,12 @@ default: throw new IllegalArgumentException("Invalid player action"); } @@ -647,7 +656,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); EnumHand enumhand = packetplayinuseitem.d(); ItemStack itemstack = this.player.b(enumhand); -@@ -770,6 +1184,13 @@ +@@ -780,6 +1196,13 @@ 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)) { @@ -661,7 +670,7 @@ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.e(), packetplayinuseitem.f(), packetplayinuseitem.g()); } -@@ -779,13 +1200,52 @@ +@@ -789,13 +1212,52 @@ public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); @@ -715,18 +724,7 @@ } } -@@ -796,8 +1256,8 @@ - WorldServer[] aworldserver = this.minecraftServer.worldServer; - int i = aworldserver.length; - -- for (int j = 0; j < i; ++j) { -- WorldServer worldserver = aworldserver[j]; -+ // CraftBukkit - use the worlds array list -+ for (WorldServer worldserver : minecraftServer.worlds) { - - if (worldserver != null) { - entity = packetplayinspectate.a(worldserver); -@@ -808,13 +1268,18 @@ +@@ -815,13 +1277,18 @@ } if (entity != null) { @@ -747,7 +745,7 @@ public void a(PacketPlayInBoatMove packetplayinboatmove) { PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.getWorldServer()); -@@ -827,11 +1292,26 @@ +@@ -834,11 +1301,26 @@ } public void a(IChatBaseComponent ichatbasecomponent) { @@ -761,7 +759,7 @@ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getDisplayName().getString(), ichatbasecomponent.getString()); + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* - this.minecraftServer.av(); + this.minecraftServer.at(); this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW)); + */ + @@ -772,10 +770,10 @@ + this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); + } + // CraftBukkit end - if (this.minecraftServer.J() && this.player.getDisplayName().getString().equals(this.minecraftServer.I())) { + if (this.minecraftServer.H() && this.player.getDisplayName().getString().equals(this.minecraftServer.G())) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); -@@ -857,6 +1337,15 @@ +@@ -864,6 +1346,15 @@ } } @@ -791,7 +789,7 @@ try { this.networkManager.sendPacket(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -872,17 +1361,37 @@ +@@ -879,17 +1370,37 @@ public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer()); @@ -831,7 +829,7 @@ this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED))); } else { this.player.resetIdleTimer(); -@@ -892,39 +1401,249 @@ +@@ -899,39 +1410,249 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -1088,7 +1086,7 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -996,6 +1715,7 @@ +@@ -1003,6 +1724,7 @@ public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer()); @@ -1096,7 +1094,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -1011,20 +1731,73 @@ +@@ -1018,20 +1740,73 @@ if (this.player.h(entity) < d0) { EnumHand enumhand; @@ -1171,17 +1169,17 @@ } } } -@@ -1040,7 +1813,8 @@ +@@ -1047,7 +1822,8 @@ case PERFORM_RESPAWN: if (this.player.viewingCredits) { this.player.viewingCredits = false; -- this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true); -+ // this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true); -+ this.minecraftServer.getPlayerList().changeDimension(this.player, 0, PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - reroute logic through custom portal management +- this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, DimensionManager.OVERWORLD, true); ++ // this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, DimensionManager.OVERWORLD, true); ++ this.minecraftServer.getPlayerList().changeDimension(this.player, DimensionManager.OVERWORLD, PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - reroute logic through custom portal management CriterionTriggers.v.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD); } else { if (this.player.getHealth() > 0.0F) { -@@ -1063,14 +1837,20 @@ +@@ -1070,14 +1846,20 @@ public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); @@ -1204,7 +1202,7 @@ NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) { -@@ -1079,8 +1859,274 @@ +@@ -1086,8 +1868,274 @@ this.player.a(this.player.activeContainer, nonnulllist); } else { @@ -1480,7 +1478,7 @@ if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true)); this.player.f = true; -@@ -1123,6 +2169,7 @@ +@@ -1130,6 +2178,7 @@ public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); @@ -1488,7 +1486,7 @@ this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { this.player.activeContainer.a(this.player, packetplayinenchantitem.c()); -@@ -1154,6 +2201,43 @@ +@@ -1161,6 +2210,43 @@ boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1532,7 +1530,7 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -1177,6 +2261,7 @@ +@@ -1184,6 +2270,7 @@ public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer()); @@ -1540,7 +1538,7 @@ 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()) { -@@ -1187,6 +2272,7 @@ +@@ -1194,6 +2281,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer()); @@ -1548,7 +1546,7 @@ this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinupdatesign.b(); -@@ -1203,14 +2289,30 @@ +@@ -1210,14 +2298,30 @@ if (!tileentitysign.d() || tileentitysign.e() != this.player) { this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign"); @@ -1566,7 +1564,7 @@ + String[] lines = new String[4]; + for (int i = 0; i < astring.length; ++i) { -- tileentitysign.lines[i] = new ChatComponentText(EnumChatFormat.b(astring[i])); +- tileentitysign.a(i, new ChatComponentText(EnumChatFormat.b(astring[i]))); + lines[i] = EnumChatFormat.b(new ChatComponentText(EnumChatFormat.b(astring[i])).getString()); } + SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); @@ -1580,7 +1578,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -1219,6 +2321,7 @@ +@@ -1226,6 +2330,7 @@ } public void a(PacketPlayInKeepAlive packetplayinkeepalive) { @@ -1588,7 +1586,7 @@ if (this.g && packetplayinkeepalive.b() == this.h) { int i = (int) (SystemUtils.b() - this.f); -@@ -1232,7 +2335,17 @@ +@@ -1239,7 +2344,17 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); @@ -1607,7 +1605,7 @@ } public void a(PacketPlayInSettings packetplayinsettings) { -@@ -1240,5 +2353,47 @@ +@@ -1247,5 +2362,47 @@ this.player.a(packetplayinsettings); } |