From ebeba451f24caaaaf017e18d005a5b57e33c86d6 Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 23 Oct 2018 21:13:58 -0400 Subject: [PATCH] Fix "prevent players from moving into unloaded chunks" it used public method instead of private, and moved to world config also improved the implementation to not use obfuscated stuff Also removed the Fix Double chest conversion patch since its fixed in other ways in vanilla --- ...event-players-from-moving-into-unloa.patch | 32 ++++++--- ...15-Fix-Double-Chest-Conversion-Error.patch | 65 ------------------- ...e-area-unicode-characters-from-signs.patch | 2 +- 3 files changed, 23 insertions(+), 76 deletions(-) delete mode 100644 Spigot-Server-Patches/MC-134115-Fix-Double-Chest-Conversion-Error.patch diff --git a/Spigot-Server-Patches/Add-option-to-prevent-players-from-moving-into-unloa.patch b/Spigot-Server-Patches/Add-option-to-prevent-players-from-moving-into-unloa.patch index 109f8fc657..1c4891a1cf 100644 --- a/Spigot-Server-Patches/Add-option-to-prevent-players-from-moving-into-unloa.patch +++ b/Spigot-Server-Patches/Add-option-to-prevent-players-from-moving-into-unloa.patch @@ -5,17 +5,17 @@ Subject: [PATCH] Add option to prevent players from moving into unloaded chunks #1551 -diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java +diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 7ac07ac07ac0..7ac07ac07ac0 100644 ---- a/src/main/java/com/destroystokyo/paper/PaperConfig.java -+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java -@@ -0,0 +0,0 @@ public class PaperConfig { - velocitySecretKey = secret.getBytes(StandardCharsets.UTF_8); - } +--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java ++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +@@ -0,0 +0,0 @@ public class PaperWorldConfig { + replacementBlocks = getList("anti-xray.replacement-blocks", Arrays.asList("stone", "planks")); + log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Chunk Edge Mode: " + chunkEdgeMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks / Update Radius: " + updateRadius); } + -+ public static boolean preventMovingIntoUnloadedChunks = false; -+ public static void preventMovingIntoUnloadedChunks() { ++ public boolean preventMovingIntoUnloadedChunks = false; ++ private void preventMovingIntoUnloadedChunks() { + preventMovingIntoUnloadedChunks = getBoolean("settings.prevent-moving-into-unloaded-chunks", false); + } } @@ -28,7 +28,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644 speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + // Paper start - Prevent moving into unloaded chunks -+ if(com.destroystokyo.paper.PaperConfig.preventMovingIntoUnloadedChunks && !worldserver.isChunkLoaded((int) Math.floor(d4) >> 4, (int) Math.floor(d6) >> 4, false)) { ++ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && !worldserver.isChunkLoaded((int) Math.floor(packetplayinvehiclemove.getX()) >> 4, (int) Math.floor(packetplayinvehiclemove.getZ()) >> 4, false)) { + this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); + return; + } @@ -37,12 +37,24 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644 if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (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)); +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { + double d1 = this.player.locY; + double d2 = this.player.locZ; + double d3 = this.player.locY; +- double d4 = packetplayinflying.a(this.player.locX); ++ double d4 = packetplayinflying.a(this.player.locX);double toX = d4; // Paper - OBFHELPER + double d5 = packetplayinflying.b(this.player.locY); +- double d6 = packetplayinflying.c(this.player.locZ); ++ double d6 = packetplayinflying.c(this.player.locZ);double toZ = d6; // Paper - OBFHELPER + float f = packetplayinflying.a(this.player.yaw); + float f1 = packetplayinflying.b(this.player.pitch); + double d7 = d4 - this.l; @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { speed = player.abilities.walkSpeed * 10f; } + // Paper start - Prevent moving into unloaded chunks -+ if(com.destroystokyo.paper.PaperConfig.preventMovingIntoUnloadedChunks && !worldserver.isChunkLoaded((int) Math.floor(d4) >> 4, (int) Math.floor(d6) >> 4, false)) { ++ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && (this.player.locX != toX || this.player.locZ != toZ) && !worldserver.isChunkLoaded((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4, false)) { + this.internalTeleport(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch, Collections.emptySet()); + return; + } diff --git a/Spigot-Server-Patches/MC-134115-Fix-Double-Chest-Conversion-Error.patch b/Spigot-Server-Patches/MC-134115-Fix-Double-Chest-Conversion-Error.patch deleted file mode 100644 index d7e963be60..0000000000 --- a/Spigot-Server-Patches/MC-134115-Fix-Double-Chest-Conversion-Error.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Thu, 20 Sep 2018 19:11:33 -0400 -Subject: [PATCH] MC-134115: Fix Double Chest Conversion Error - -A bug with double chest conversion would lead to data -loss from chunks if they crossed chunk boundries. - -This fixes the issue. - -diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 7ac07ac07ac0..7ac07ac07ac0 100644 ---- a/src/main/java/net/minecraft/server/Chunk.java -+++ b/src/main/java/net/minecraft/server/Chunk.java -@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - return this.setType(blockposition, iblockdata, flag, true); - } - -+ // Paper start -+ public void setTypeDirect(BlockPosition blockposition, IBlockData iblockdata) { -+ int i = blockposition.getX() & 15; -+ int j = blockposition.getY(); -+ int k = blockposition.getZ() & 15; -+ ChunkSection section = this.sections[j >> 4]; -+ -+ if (section == Chunk.EMPTY_CHUNK_SECTION) { -+ if (iblockdata.isAir()) { -+ return; -+ } -+ -+ section = new ChunkSection(j >> 4 << 4, this.world.worldProvider.g(), this, this.world, true); // Paper - Anti-Xray -+ this.sections[j >> 4] = section; -+ } -+ -+ section.setType(i, j & 15, k, iblockdata); -+ } -+ // Paper end -+ - @Nullable - public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) { - // CraftBukkit end -diff --git a/src/main/java/net/minecraft/server/ChunkConverter.java b/src/main/java/net/minecraft/server/ChunkConverter.java -index 7ac07ac07ac0..7ac07ac07ac0 100644 ---- a/src/main/java/net/minecraft/server/ChunkConverter.java -+++ b/src/main/java/net/minecraft/server/ChunkConverter.java -@@ -0,0 +0,0 @@ public class ChunkConverter { - EnumDirection enumdirection1 = (EnumDirection)iblockdata.get(BlockChest.FACING); - if (enumdirection.k() != enumdirection1.k() && enumdirection1 == iblockdata1.get(BlockChest.FACING)) { - BlockPropertyChestType blockpropertychesttype = enumdirection == enumdirection1.e() ? BlockPropertyChestType.LEFT : BlockPropertyChestType.RIGHT; -- generatoraccess.setTypeAndData(blockposition1, (IBlockData)iblockdata1.set(BlockChest.b, blockpropertychesttype.a()), 18); -+ // Paper start -+ Chunk chunk = ((World) generatoraccess.getMinecraftWorld()).getChunkAtWorldCoords(blockposition); -+ Chunk chunk1 = ((World) generatoraccess.getMinecraftWorld()).getChunkAtWorldCoords(blockposition1); -+ chunk1.setTypeDirect(blockposition1, (IBlockData)iblockdata1.set(BlockChest.b, blockpropertychesttype.a())); -+ - if (enumdirection1 == EnumDirection.NORTH || enumdirection1 == EnumDirection.EAST) { -- TileEntity tileentity = generatoraccess.getTileEntity(blockposition); -- TileEntity tileentity1 = generatoraccess.getTileEntity(blockposition1); -+ TileEntity tileentity = chunk.getTileEntity(blockposition); -+ TileEntity tileentity1 = chunk1.getTileEntity(blockposition1); -+ // Paper end - if (tileentity instanceof TileEntityChest && tileentity1 instanceof TileEntityChest) { - TileEntityChest.a((TileEntityChest)tileentity, (TileEntityChest)tileentity1); - } --- \ No newline at end of file diff --git a/Spigot-Server-Patches/Strip-private-area-unicode-characters-from-signs.patch b/Spigot-Server-Patches/Strip-private-area-unicode-characters-from-signs.patch index b624929876..320e6009a1 100644 --- a/Spigot-Server-Patches/Strip-private-area-unicode-characters-from-signs.patch +++ b/Spigot-Server-Patches/Strip-private-area-unicode-characters-from-signs.patch @@ -20,7 +20,7 @@ think of no reason to use it. Fixes GH-1571 diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java -index 20dc3f272..3c712fc93 100644 +index 7ac07ac07ac0..7ac07ac07ac0 100644 --- a/src/main/java/net/minecraft/server/TileEntitySign.java +++ b/src/main/java/net/minecraft/server/TileEntitySign.java @@ -0,0 +0,0 @@ public class TileEntitySign extends TileEntity implements ICommandListener {