diff --git a/gradle.properties b/gradle.properties index a0763827d..59e7c07af 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=com.lokamc.slice version=1.19.4-R0.1-SNAPSHOT mcVersion=1.19.4 -paperRef=9846d0d89e7598fc28a8c8534d80d4c5dc42021c +paperRef=688409279f45ec4e88b7c1f91dc62ce377a71caf org.gradle.caching=true org.gradle.parallel=true diff --git a/patches/api/0017-Add-PlayerPreSendChunkPacketEvent.patch b/patches/api/0017-Add-PlayerPreSendChunkPacketEvent.patch new file mode 100644 index 000000000..a09aaa760 --- /dev/null +++ b/patches/api/0017-Add-PlayerPreSendChunkPacketEvent.patch @@ -0,0 +1,55 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite +Date: Wed, 10 May 2023 08:58:30 -0500 +Subject: [PATCH] Add PlayerPreSendChunkPacketEvent + + +diff --git a/src/main/java/io/papermc/paper/event/player/PlayerPreSendChunkPacketEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerPreSendChunkPacketEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..b91799676d0e178bf974aa52217e551270ba500c +--- /dev/null ++++ b/src/main/java/io/papermc/paper/event/player/PlayerPreSendChunkPacketEvent.java +@@ -0,0 +1,43 @@ ++package io.papermc.paper.event.player; ++ ++import org.bukkit.Chunk; ++import org.bukkit.entity.Entity; ++import org.bukkit.entity.Player; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++ ++public class PlayerPreSendChunkPacketEvent extends PlayerEvent { ++ private static final HandlerList HANDLER_LIST = new HandlerList(); ++ private final Chunk chunk; ++ private boolean useMode2; ++ ++ public PlayerPreSendChunkPacketEvent(@NotNull final Player player, final Chunk chunk) { ++ super(player); ++ this.chunk = chunk; ++ } ++ ++ public Chunk getChunk() { ++ return chunk; ++ } ++ ++ public boolean isUseMode2() { ++ return useMode2; ++ } ++ ++ public void setUseMode2(boolean useMode2) { ++ this.useMode2 = useMode2; ++ } ++ ++ @NotNull ++ @Override ++ public HandlerList getHandlers() { ++ return HANDLER_LIST; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return HANDLER_LIST; ++ } ++} diff --git a/patches/server/0030-Maybe-can-t-tostring.patch b/patches/server/0030-Maybe-can-t-tostring.patch new file mode 100644 index 000000000..1588db8d5 --- /dev/null +++ b/patches/server/0030-Maybe-can-t-tostring.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite +Date: Sat, 6 May 2023 18:14:26 -0500 +Subject: [PATCH] Maybe can't tostring? + + +diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java +index 7e94ebe06fc62293e665d6db19e42d947e7eb30f..158c012b8a6808ca0f820c2997af282529148c7c 100644 +--- a/src/main/java/net/minecraft/nbt/CompoundTag.java ++++ b/src/main/java/net/minecraft/nbt/CompoundTag.java +@@ -466,6 +466,9 @@ public class CompoundTag implements Tag { + @Override + public CompoundTag copy() { + // Paper start - reduce memory footprint of NBTTagCompound ++ if (this.tags.size() < 0) { ++ net.minecraft.server.MinecraftServer.LOGGER.debug("Tried to copy an invalid item with negative tags: {}, {}, {}, {}", this.tags, this.tags.getClass().getName()); ++ } + it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap ret = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(this.tags.size(), 0.8f); + java.util.Iterator> iterator = (this.tags instanceof it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) ? ((it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)this.tags).object2ObjectEntrySet().fastIterator() : this.tags.entrySet().iterator(); + while (iterator.hasNext()) { +diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java +index 588a4fdcb294b9b1a92ef9969ef64f999bf529cc..431ea53e4fb9c26c24003da7e216a1f5fe070985 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -719,7 +719,11 @@ public final class ItemStack { + + itemstack.setPopTime(this.getPopTime()); + if (this.tag != null) { +- itemstack.tag = this.tag.copy(); ++ if (this.tag.tags.size() < 0) { ++ ItemStack.LOGGER.debug("Tried to copy an invalid item with negative tags: {}, {}, {}, {}", this.tag, this.tag.tags, this.tag.tags.getClass().getName()); ++ } else { ++ itemstack.tag = this.tag.copy(); ++ } + } + + return itemstack; diff --git a/patches/server/0031-Add-PlayerPreSendChunkPacketEvent.patch b/patches/server/0031-Add-PlayerPreSendChunkPacketEvent.patch new file mode 100644 index 000000000..7761ddbee --- /dev/null +++ b/patches/server/0031-Add-PlayerPreSendChunkPacketEvent.patch @@ -0,0 +1,123 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite +Date: Wed, 10 May 2023 08:58:29 -0500 +Subject: [PATCH] Add PlayerPreSendChunkPacketEvent + + +diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java +index f90f27d9d9a4043198c33d65efa7068b76b58818..b8181bc872034dcab9272d5890f565800cfdb8f8 100644 +--- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java ++++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java +@@ -53,10 +53,10 @@ public final class ChunkPacketBlockControllerAntiXray extends ChunkPacketBlockCo + private final LevelChunkSection[] emptyNearbyChunkSections = {EMPTY_SECTION, EMPTY_SECTION, EMPTY_SECTION, EMPTY_SECTION}; + private final int maxBlockHeightUpdatePosition; + +- public ChunkPacketBlockControllerAntiXray(Level level, Executor executor) { ++ public ChunkPacketBlockControllerAntiXray(Level level, Executor executor, EngineMode providedMode) { // Slice + this.executor = executor; + WorldConfiguration.Anticheat.AntiXray paperWorldConfig = level.paperConfig().anticheat.antiXray; +- engineMode = paperWorldConfig.engineMode; ++ engineMode = providedMode != null ? providedMode : paperWorldConfig.engineMode; // Slice + maxBlockHeight = paperWorldConfig.maxBlockHeight >> 4 << 4; + updateRadius = paperWorldConfig.updateRadius; + usePermission = paperWorldConfig.usePermission; +diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +index 000853110c7a89f2d0403a7a2737025a5ac28240..919493a3d23ccd9eb1894f8510f96b1ad2aae2ff 100644 +--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java ++++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +@@ -27,17 +27,21 @@ public class ClientboundLevelChunkWithLightPacket implements Packet chunkPacketInfo = modifyBlocks ? chunk.getLevel().chunkPacketBlockController.getChunkPacketInfo(this, chunk) : null; ++ ++ com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController = mode2 ? chunk.getLevel().chunkPacketBlockControllerMode2 : chunk.getLevel().chunkPacketBlockController; ++ com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo = modifyBlocks ? chunkPacketBlockController.getChunkPacketInfo(this, chunk) : null; + this.chunkData = new ClientboundLevelChunkPacketData(chunk, chunkPacketInfo); + // Paper end + this.lightData = new ClientboundLightUpdatePacketData(chunkPos, lightProvider, skyBits, blockBits, nonEdge); +- chunk.getLevel().chunkPacketBlockController.modifyBlocks(this, chunkPacketInfo); // Paper - Anti-Xray - Modify blocks ++ chunkPacketBlockController.modifyBlocks(this, chunkPacketInfo); // Paper - Anti-Xray - Modify blocks + } ++ // Slice end + + public ClientboundLevelChunkWithLightPacket(FriendlyByteBuf buf) { + this.x = buf.readInt(); +diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java +index 67a8b0145e4ed096b4fc520202098b9b1d259bd6..ae3d1baa28ab591501b270fa57d7c00886109aee 100644 +--- a/src/main/java/net/minecraft/server/level/ChunkMap.java ++++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +@@ -1463,7 +1463,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + } + } + // Paper end - Fix MC-162253 +- return new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null, true, (Boolean) s); ++ // Slice start ++ io.papermc.paper.event.player.PlayerPreSendChunkPacketEvent event = new io.papermc.paper.event.player.PlayerPreSendChunkPacketEvent(player.getBukkitEntity().getPlayer(), new org.bukkit.craftbukkit.CraftChunk(chunk)); ++ event.callEvent(); ++ return new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null, true, (Boolean) s, event.isUseMode2()); ++ // Slice end + })); + // Paper end + DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos()); +diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java +index e0bd18ac70a93d41762fb23e7442d06355384d59..30978f9a40cd4744e99f4c596cd9bfa9531d7eda 100644 +--- a/src/main/java/net/minecraft/server/players/PlayerList.java ++++ b/src/main/java/net/minecraft/server/players/PlayerList.java +@@ -399,7 +399,7 @@ public abstract class PlayerList { + .getHolderOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS); + player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket( + new net.minecraft.world.level.chunk.EmptyLevelChunk(worldserver1, player.chunkPosition(), plains), +- worldserver1.getLightEngine(), null, null, true, false) ++ worldserver1.getLightEngine(), null, null, true, false, false) // Slice + ); + } + // Paper end +diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java +index 23630e4ab396158d8f3f77bf9aa05f66c6b27a9d..d301de59501ddfbf6f5da66191a871089242250c 100644 +--- a/src/main/java/net/minecraft/world/level/Level.java ++++ b/src/main/java/net/minecraft/world/level/Level.java +@@ -177,6 +177,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + // Paper end + + public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray ++ public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockControllerMode2; // Paper - Anti-Xray + public final co.aikar.timings.WorldTimingsHandler timings; // Paper + public static BlockPos lastPhysicsProblem; // Spigot + private org.spigotmc.TickLimiter entityLimiter; +@@ -381,7 +382,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper + this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); + this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); +- this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray ++ this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor, null) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray ++ this.chunkPacketBlockControllerMode2 = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor, io.papermc.paper.configuration.type.EngineMode.OBFUSCATE) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray // Slice + } + + // Paper start +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +index 3e45551d8d677ccfb362e3039d7dee10018206d6..b13a55624365a72d323292259c1974dba0b4a76c 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +@@ -524,8 +524,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { + if (player.connection == null) continue; + + Boolean shouldModify = chunk.getLevel().chunkPacketBlockController.shouldModify(player, chunk); ++ // Slice start ++ io.papermc.paper.event.player.PlayerPreSendChunkPacketEvent event = new io.papermc.paper.event.player.PlayerPreSendChunkPacketEvent(player.getBukkitEntity().getPlayer(), new CraftChunk(chunk)); ++ event.callEvent(); ++ // Slice end + player.connection.send(refreshPackets.computeIfAbsent(shouldModify, s -> { // Use connection to prevent creating firing event +- return new ClientboundLevelChunkWithLightPacket(chunk, this.world.getLightEngine(), null, null, true, (Boolean) s); ++ return new ClientboundLevelChunkWithLightPacket(chunk, this.world.getLightEngine(), null, null, true, (Boolean) s, event.isUseMode2()); // Slice + })); + // Paper end + }