diff --git a/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch b/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch index 5ad66808e1..ae88eca2fb 100644 --- a/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch +++ b/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registries.BIOME)); + return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registries.BIOME), world); // Paper - Anti-Xray - Add parameters } + // Paper start diff --git a/patches/unapplied/server/Anti-Xray.patch b/patches/server/Anti-Xray.patch similarity index 96% rename from patches/unapplied/server/Anti-Xray.patch rename to patches/server/Anti-Xray.patch index 570bfe23b2..98300adcc2 100644 --- a/patches/unapplied/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -173,7 +173,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + } + -+ public BlockState[] getPresetBlockStates(Level level, ChunkPos chunkPos, int bottomBlockY) { ++ public BlockState[] getPresetBlockStates(Level level, ChunkPos chunkPos, int chunkSectionY) { + return null; + } + @@ -349,8 +349,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public BlockState[] getPresetBlockStates(Level level, ChunkPos chunkPos, int bottomBlockY) { ++ public BlockState[] getPresetBlockStates(Level level, ChunkPos chunkPos, int chunkSectionY) { + // Return the block states to be added to the paletted containers so that they can be used for obfuscation ++ int bottomBlockY = chunkSectionY << 4; ++ + if (bottomBlockY < maxBlockHeight) { + if (engineMode == EngineMode.HIDE) { + return switch (level.getWorld().getEnvironment()) { @@ -999,11 +1001,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java @@ -0,0 +0,0 @@ public record ClientboundChunksBiomesPacket(List chunkPacketInfo) { ++ int chunkSectionIndex = 0; ++ for(LevelChunkSection levelChunkSection : chunk.getSections()) { - levelChunkSection.write(buf); -+ levelChunkSection.write(buf, chunkPacketInfo); ++ levelChunkSection.write(buf, chunkPacketInfo, chunkSectionIndex); ++ chunkSectionIndex++; + // Paper end } @@ -1065,7 +1073,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Async-Anti-Xray - Ready flag for the connection + private volatile boolean ready; -- public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet skyBits, @Nullable BitSet blockBits, boolean nonEdge) { +- public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet skyBits, @Nullable BitSet blockBits) { + @Override + public boolean isReady() { + return this.ready; @@ -1077,8 +1085,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + + // Paper start - Anti-Xray - Add chunk packet info -+ @Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet skyBits, @Nullable BitSet blockBits, boolean nonEdge) { this(chunk, lightProvider, skyBits, blockBits, nonEdge, true); } -+ public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet skyBits, @Nullable BitSet blockBits, boolean nonEdge, boolean modifyBlocks) { ++ @Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet skyBits, @Nullable BitSet blockBits) { this(chunk, lightProvider, skyBits, blockBits, true); } ++ public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet skyBits, @Nullable BitSet blockBits, boolean modifyBlocks) { ChunkPos chunkPos = chunk.getPos(); this.x = chunkPos.x; this.z = chunkPos.z; @@ -1086,7 +1094,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo = modifyBlocks ? chunk.getLevel().chunkPacketBlockController.getChunkPacketInfo(this, chunk) : null; + this.chunkData = new ClientboundLevelChunkPacketData(chunk, chunkPacketInfo); + // Paper end - this.lightData = new ClientboundLightUpdatePacketData(chunkPos, lightProvider, skyBits, blockBits, nonEdge); + this.lightData = new ClientboundLightUpdatePacketData(chunkPos, lightProvider, skyBits, blockBits); + chunk.getLevel().chunkPacketBlockController.modifyBlocks(this, chunkPacketInfo); // Paper - Anti-Xray - Modify blocks } @@ -1101,16 +1109,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - public void updateChunkTracking(ServerPlayer player, ChunkPos pos, MutableObject packet, boolean oldWithinViewDistance, boolean newWithinViewDistance) { // Paper - public + public void updateChunkTracking(ServerPlayer player, ChunkPos pos, MutableObject> packet, boolean oldWithinViewDistance, boolean newWithinViewDistance) { // Paper - public // Paper - Anti-Xray - Bypass - if (player.level == this.level) { - if (newWithinViewDistance && !oldWithinViewDistance) { - ChunkHolder playerchunk = this.getVisibleChunkIfPresent(pos.toLong()); + io.papermc.paper.util.TickThread.ensureTickThread(this.level, pos, "May not update chunk tracking for chunk async"); // Paper - replace chunk loader system + io.papermc.paper.util.TickThread.ensureTickThread(player, "May not update chunk tracking for player async"); // Paper - replace chunk loader system + if (player.level() == this.level) { @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider }); } - private void playerLoadedChunk(ServerPlayer player, MutableObject cachedDataPacket, LevelChunk chunk) { - if (cachedDataPacket.getValue() == null) { -- cachedDataPacket.setValue(new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null, true)); +- cachedDataPacket.setValue(new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null)); + // Paper start - Anti-Xray - Bypass + private void playerLoadedChunk(ServerPlayer player, MutableObject> cachedDataPackets, LevelChunk chunk) { + if (cachedDataPackets.getValue() == null) { @@ -1120,7 +1128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - player.trackChunk(chunk.getPos(), (Packet) cachedDataPacket.getValue()); + Boolean shouldModify = chunk.getLevel().chunkPacketBlockController.shouldModify(player, chunk); + player.trackChunk(chunk.getPos(), (Packet) cachedDataPackets.getValue().computeIfAbsent(shouldModify, (s) -> { -+ return new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null, true, (Boolean) s); ++ return new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null, (Boolean) s); + })); + // Paper end DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos()); @@ -1206,22 +1214,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -- ChunkAccess.replaceMissingSections(heightLimitView, biome, this.sections); -+ ChunkAccess.replaceMissingSections(heightLimitView, biome, this.sections, pos); // Paper - Anti-Xray - Add parameters +- ChunkAccess.replaceMissingSections(biomeRegistry, this.sections); ++ this.replaceMissingSections(biomeRegistry, this.sections); // Paper - Anti-Xray - make it a non-static method // CraftBukkit start - this.biomeRegistry = biome; + this.biomeRegistry = biomeRegistry; } public final Registry biomeRegistry; // CraftBukkit end -- private static void replaceMissingSections(LevelHeightAccessor world, Registry biome, LevelChunkSection[] sectionArray) { -+ // Paper start - Anti-Xray - Add parameters -+ private static void replaceMissingSections(LevelHeightAccessor world, Registry biome, LevelChunkSection[] sectionArray, ChunkPos pos) { +- private static void replaceMissingSections(Registry biomeRegistry, LevelChunkSection[] sectionArray) { ++ private void replaceMissingSections(Registry biomeRegistry, LevelChunkSection[] sectionArray) { // Paper - Anti-Xray - static -> non-static for (int i = 0; i < sectionArray.length; ++i) { if (sectionArray[i] == null) { -- sectionArray[i] = new LevelChunkSection(world.getSectionYFromSectionIndex(i), biome); -+ sectionArray[i] = new LevelChunkSection(world.getSectionYFromSectionIndex(i), biome, pos, world instanceof net.minecraft.world.level.Level ? (net.minecraft.world.level.Level) world : null); -+ // Paper end +- sectionArray[i] = new LevelChunkSection(biomeRegistry); ++ sectionArray[i] = new LevelChunkSection(biomeRegistry, this.levelHeightAccessor instanceof net.minecraft.world.level.Level ? (net.minecraft.world.level.Level) this.levelHeightAccessor : null, this.chunkPos, this.levelHeightAccessor.getSectionYFromSectionIndex(i)); // Paper start - Anti-Xray - Add parameters } } @@ -1246,32 +1252,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.recalcBlockCounts(); } -- public LevelChunkSection(int chunkPos, Registry biomeRegistry) { -+ // Paper start - Anti-Xray - Add parameters -+ @Deprecated @io.papermc.paper.annotation.DoNotUse public LevelChunkSection(int chunkPos, Registry biomeRegistry) { this(chunkPos, biomeRegistry, null, null); } -+ public LevelChunkSection(int chunkPos, Registry biomeRegistry, net.minecraft.world.level.ChunkPos pos, net.minecraft.world.level.Level level) { -+ // Paper end - this.bottomBlockY = LevelChunkSection.getBottomBlockY(chunkPos); +- public LevelChunkSection(Registry biomeRegistry) { - this.states = new PalettedContainer<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES); - this.biomes = new PalettedContainer<>(biomeRegistry.asHolderIdMap(), biomeRegistry.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); -+ this.states = new PalettedContainer<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES, level == null || level.chunkPacketBlockController == null ? null : level.chunkPacketBlockController.getPresetBlockStates(level, pos, this.bottomBlockY())); // Paper - Anti-Xray - Add preset block states ++ // Paper start - Anti-Xray - Add parameters ++ @Deprecated @io.papermc.paper.annotation.DoNotUse public LevelChunkSection(Registry biomeRegistry) { this(biomeRegistry, null, null, 0); } ++ public LevelChunkSection(Registry biomeRegistry, net.minecraft.world.level.Level level, net.minecraft.world.level.ChunkPos chunkPos, int chunkSectionY) { ++ // Paper end ++ this.states = new PalettedContainer<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES, level == null || level.chunkPacketBlockController == null ? null : level.chunkPacketBlockController.getPresetBlockStates(level, chunkPos, chunkSectionY)); // Paper - Anti-Xray - Add preset block states + this.biomes = new PalettedContainer<>(biomeRegistry.asHolderIdMap(), biomeRegistry.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES, null); // Paper - Anti-Xray - Add preset biomes } - public static int getBottomBlockY(int chunkPos) { + public BlockState getBlockState(int x, int y, int z) { @@ -0,0 +0,0 @@ public class LevelChunkSection { this.biomes = datapaletteblock; } - public void write(FriendlyByteBuf buf) { + // Paper start - Anti-Xray - Add chunk packet info -+ @Deprecated @io.papermc.paper.annotation.DoNotUse public void write(FriendlyByteBuf buf) { this.write(buf, null); } -+ public void write(FriendlyByteBuf buf, com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo) { ++ @Deprecated @io.papermc.paper.annotation.DoNotUse public void write(FriendlyByteBuf buf) { this.write(buf, null, 0); } ++ public void write(FriendlyByteBuf buf, com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { buf.writeShort(this.nonEmptyBlockCount); - this.states.write(buf); - this.biomes.write(buf); -+ this.states.write(buf, chunkPacketInfo, this.bottomBlockY()); -+ this.biomes.write(buf, null, this.bottomBlockY()); ++ this.states.write(buf, chunkPacketInfo, chunkSectionIndex); ++ this.biomes.write(buf, null, chunkSectionIndex); + // Paper end } @@ -1418,16 +1423,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated @io.papermc.paper.annotation.DoNotUse public void write(FriendlyByteBuf buf) { this.write(buf, null, 0); } @Override - public void write(FriendlyByteBuf buf) { -+ public void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int bottomBlockY) { ++ public void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { this.acquire(); try { - this.data.write(buf); -+ this.data.write(buf, chunkPacketInfo, bottomBlockY); ++ this.data.write(buf, chunkPacketInfo, chunkSectionIndex); + + if (chunkPacketInfo != null) { -+ // Bottom block to 0 based chunk section index -+ int chunkSectionIndex = (bottomBlockY >> 4) - chunkPacketInfo.getChunk().getMinSection(); + chunkPacketInfo.setPresetValues(chunkSectionIndex, this.presetValues); + } + // Paper end @@ -1472,13 +1475,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - public void write(FriendlyByteBuf buf) { + // Paper start - Anti-Xray - Add chunk packet info -+ public void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int bottomBlockY) { ++ public void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { buf.writeByte(this.storage.getBits()); this.palette.write(buf); + + if (chunkPacketInfo != null) { -+ // Bottom block to 0 based chunk section index -+ int chunkSectionIndex = (bottomBlockY >> 4) - chunkPacketInfo.getChunk().getMinSection(); + chunkPacketInfo.setBits(chunkSectionIndex, this.configuration.bits()); + chunkPacketInfo.setPalette(chunkSectionIndex, this.palette); + chunkPacketInfo.setIndex(chunkSectionIndex, buf.writerIndex() + FriendlyByteBuf.getVarIntSize(this.storage.getRaw().length)); @@ -1499,7 +1500,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - void write(FriendlyByteBuf buf); + // Paper start - Anti-Xray - Add chunk packet info + @Deprecated @io.papermc.paper.annotation.DoNotUse void write(FriendlyByteBuf buf); -+ void write(FriendlyByteBuf buf, @javax.annotation.Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int bottomBlockY); ++ void write(FriendlyByteBuf buf, @javax.annotation.Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex); + // Paper end int getSerializedSize(); @@ -1522,7 +1523,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Logger logger; PalettedContainer datapaletteblock; + // Paper start - Anti-Xray - Add preset block states -+ BlockState[] presetBlockStates = world.chunkPacketBlockController.getPresetBlockStates(world, chunkPos, b0 << 4); ++ BlockState[] presetBlockStates = world.chunkPacketBlockController.getPresetBlockStates(world, chunkPos, b0); if (nbttagcompound1.contains("block_states", 10)) { - dataresult = ChunkSerializer.BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, nbttagcompound1.getCompound("block_states")).promotePartial((s) -> { @@ -1548,7 +1549,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + object = new PalettedContainer<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES, null); // Paper - Anti-Xray - Add preset biomes } - LevelChunkSection chunksection = new LevelChunkSection(b0, datapaletteblock, (PalettedContainer) object); // CraftBukkit - read/write + LevelChunkSection chunksection = new LevelChunkSection(datapaletteblock, (PalettedContainer) object); // CraftBukkit - read/write @@ -0,0 +0,0 @@ public class ChunkSerializer { // CraftBukkit start - read/write @@ -1592,7 +1593,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 List playersInRange = playerChunk.playerProvider.getPlayers(playerChunk.getPos(), false); if (playersInRange.isEmpty()) return true; // Paper - rewrite player chunk loader -- ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, this.world.getLightEngine(), null, null, true); +- ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, this.world.getLightEngine(), null, null); + // Paper start - Anti-Xray - Bypass + Map refreshPackets = new HashMap<>(); for (ServerPlayer player : playersInRange) { @@ -1601,7 +1602,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - player.connection.send(refreshPacket); + Boolean shouldModify = chunk.getLevel().chunkPacketBlockController.shouldModify(player, chunk); + 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, (Boolean) s); + })); + // Paper end } @@ -1630,8 +1631,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 int offset = (y - this.minHeight) >> 4; LevelChunkSection section = this.sections[offset]; if (create && section == null) { -- this.sections[offset] = section = new LevelChunkSection(offset + (this.minHeight >> 4), this.biomes); -+ this.sections[offset] = section = new LevelChunkSection(offset + (this.minHeight >> 4), this.biomes, null, this.world instanceof org.bukkit.craftbukkit.CraftWorld ? ((org.bukkit.craftbukkit.CraftWorld) this.world).getHandle() : null); // Paper - Anti-Xray - Add parameters +- this.sections[offset] = section = new LevelChunkSection(this.biomes); ++ this.sections[offset] = section = new LevelChunkSection(this.biomes, this.world instanceof org.bukkit.craftbukkit.CraftWorld ? ((org.bukkit.craftbukkit.CraftWorld) this.world).getHandle() : null, null, offset + (this.minHeight >> 4)); // Paper - Anti-Xray - Add parameters } return section; } diff --git a/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index 6cfd78acc2..ad5c67b2f8 100644 --- a/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - public static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState()); + public static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), null); // Paper - Anti-Xray - Add preset block states private static final Logger LOGGER = LogUtils.getLogger(); @@ -0,0 +0,0 @@ public class ChunkSerializer { nbttagcompound.putInt("xPos", chunkcoordintpair.x); diff --git a/patches/server/Force-close-world-loading-screen.patch b/patches/server/Force-close-world-loading-screen.patch index 6fe139314a..4506087f71 100644 --- a/patches/server/Force-close-world-loading-screen.patch +++ b/patches/server/Force-close-world-loading-screen.patch @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + .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) ++ worldserver1.getLightEngine(), null, null, false) + ); + } + // Paper end diff --git a/patches/server/Highly-optimise-single-and-multi-AABB-VoxelShapes-an.patch b/patches/server/Highly-optimise-single-and-multi-AABB-VoxelShapes-an.patch index fe13d22315..3516863448 100644 --- a/patches/server/Highly-optimise-single-and-multi-AABB-VoxelShapes-an.patch +++ b/patches/server/Highly-optimise-single-and-multi-AABB-VoxelShapes-an.patch @@ -1551,7 +1551,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -0,0 +0,0 @@ public class LevelChunkSection { - this.biomes = new PalettedContainer<>(biomeRegistry.asHolderIdMap(), biomeRegistry.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); + this.biomes = new PalettedContainer<>(biomeRegistry.asHolderIdMap(), biomeRegistry.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES, null); // Paper - Anti-Xray - Add preset biomes } + // Paper start diff --git a/patches/server/Optimise-random-block-ticking.patch b/patches/server/Optimise-random-block-ticking.patch index c67ac08bc5..cd6f831a3c 100644 --- a/patches/server/Optimise-random-block-ticking.patch +++ b/patches/server/Optimise-random-block-ticking.patch @@ -421,9 +421,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - } - } -- -- a a0 = new a(); +- a a0 = new a(); +- - this.states.count(a0); - this.nonEmptyBlockCount = (short) a0.nonEmptyBlockCount; - this.tickingBlockCount = (short) a0.tickingBlockCount; diff --git a/patches/server/Synchronize-PalettedContainer-instead-of-ThreadingDe.patch b/patches/server/Synchronize-PalettedContainer-instead-of-ThreadingDe.patch index 1685367dfe..61d806d98a 100644 --- a/patches/server/Synchronize-PalettedContainer-instead-of-ThreadingDe.patch +++ b/patches/server/Synchronize-PalettedContainer-instead-of-ThreadingDe.patch @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java @@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - public final IdMap registry; + private final T @org.jetbrains.annotations.Nullable [] presetValues; // Paper - Anti-Xray - Add preset values private volatile PalettedContainer.Data data; private final PalettedContainer.Strategy strategy; - private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); @@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // this.threadingDetector.checkAndUnlock(); // Paper - disable this } - public static Codec> codecRW(IdMap idList, Codec entryCodec, PalettedContainer.Strategy paletteProvider, T defaultValue) { + // Paper start - Anti-Xray - Add preset values @@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize, PalettedContainer } @@ -42,8 +42,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - public int onResize(int newBits, T object) { + public synchronized int onResize(int newBits, T object) { // Paper - synchronize PalettedContainer.Data data = this.data; - PalettedContainer.Data data2 = this.createOrReuseData(data, newBits); - data2.copyFrom(data.palette, data.storage); + + // Paper start - Anti-Xray - Add preset values @@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize, PalettedContainer return this.getAndSet(this.strategy.getIndex(x, y, z), value); } @@ -72,11 +72,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 try { @@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - } - @Override -- public void write(FriendlyByteBuf buf) { -+ public synchronized void write(FriendlyByteBuf buf) { // Paper - synchronize + @Deprecated @io.papermc.paper.annotation.DoNotUse public void write(FriendlyByteBuf buf) { this.write(buf, null, 0); } + @Override +- public void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { ++ public synchronized void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int chunkSectionIndex) { // Paper - synchronize this.acquire(); try { diff --git a/patches/server/Use-distance-map-to-optimise-entity-tracker.patch b/patches/server/Use-distance-map-to-optimise-entity-tracker.patch index e29b38d7e5..76b9ae43a7 100644 --- a/patches/server/Use-distance-map-to-optimise-entity-tracker.patch +++ b/patches/server/Use-distance-map-to-optimise-entity-tracker.patch @@ -188,8 +188,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 List list1 = this.level.players(); ObjectIterator objectiterator = this.entityMap.values().iterator(); @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - - player.trackChunk(chunk.getPos(), (Packet) cachedDataPacket.getValue()); + })); + // Paper end DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos()); - List list = Lists.newArrayList(); - List list1 = Lists.newArrayList(); diff --git a/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch b/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch index 6fadb1fc8f..196e898ad3 100644 --- a/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch +++ b/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch @@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public abstract ResourceKey getTypeKey(); - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator) { // Paper + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java