1.19 Anti-Xray cleanup (#8104)

This commit is contained in:
stonar96 2022-07-18 12:30:31 +02:00 committed by GitHub
parent fdd910e0cf
commit 90836d0da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 256 additions and 227 deletions

View File

@ -898,10 +898,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1
+}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
new file mode 100644
index 0000000000000000000000000000000000000000..fa191f418079a8ee24326c5952d12d4481f57aef
index 0000000000000000000000000000000000000000..e446542ff64670e368c8515d1716af5407f98c7a
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -0,0 +1,412 @@
@@ -0,0 +1,414 @@
+package io.papermc.paper.configuration;
+
+import com.google.common.base.Suppliers;
@ -925,6 +925,7 @@ index 0000000000000000000000000000000000000000..fa191f418079a8ee24326c5952d12d44
+import io.papermc.paper.configuration.type.BooleanOrDefault;
+import io.papermc.paper.configuration.type.DoubleOrDefault;
+import io.papermc.paper.configuration.type.Duration;
+import io.papermc.paper.configuration.type.EngineMode;
+import io.papermc.paper.configuration.type.IntOrDefault;
+import io.papermc.paper.configuration.type.fallback.FallbackValueSerializer;
+import it.unimi.dsi.fastutil.objects.Reference2IntMap;
@ -1105,6 +1106,7 @@ index 0000000000000000000000000000000000000000..fa191f418079a8ee24326c5952d12d44
+ .register(DoubleOrDefault.SERIALIZER)
+ .register(BooleanOrDefault.SERIALIZER)
+ .register(Duration.SERIALIZER)
+ .register(EngineMode.SERIALIZER)
+ .register(FallbackValueSerializer.create(contextMap.require(SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), MinecraftServer::getServer))
+ .register(new RegistryValueSerializer<>(new TypeToken<EntityType<?>>() {}, Registry.ENTITY_TYPE_REGISTRY, true))
+ .register(new RegistryValueSerializer<>(Item.class, Registry.ITEM_REGISTRY, true))
@ -1385,13 +1387,12 @@ index 0000000000000000000000000000000000000000..1bb16fc7598cd53e822d84b69d6a9727
+}
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..32f0cd29d1198fe320d10ccfe0b02f8632ac12aa
index 0000000000000000000000000000000000000000..e2c612dd55fcb2769fb06f7878b8d0873f2be139
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -0,0 +1,467 @@
+package io.papermc.paper.configuration;
+
+import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.Table;
+import com.mojang.logging.LogUtils;
@ -1404,6 +1405,7 @@ index 0000000000000000000000000000000000000000..32f0cd29d1198fe320d10ccfe0b02f86
+import io.papermc.paper.configuration.type.BooleanOrDefault;
+import io.papermc.paper.configuration.type.DoubleOrDefault;
+import io.papermc.paper.configuration.type.Duration;
+import io.papermc.paper.configuration.type.EngineMode;
+import io.papermc.paper.configuration.type.IntOrDefault;
+import io.papermc.paper.configuration.type.fallback.ArrowDespawnRate;
+import io.papermc.paper.configuration.type.fallback.AutosavePeriod;
@ -1455,9 +1457,9 @@ index 0000000000000000000000000000000000000000..32f0cd29d1198fe320d10ccfe0b02f86
+ @Setting(Configuration.VERSION_FIELD)
+ public int version = CURRENT_VERSION;
+
+ public AntiCheat anticheat;
+ public Anticheat anticheat;
+
+ public class AntiCheat extends ConfigurationPart {
+ public class Anticheat extends ConfigurationPart {
+
+ public Obfuscation obfuscation;
+
@ -1469,11 +1471,11 @@ index 0000000000000000000000000000000000000000..32f0cd29d1198fe320d10ccfe0b02f86
+ }
+ }
+
+ public AntiXRay antiXray;
+ public AntiXray antiXray;
+
+ public class AntiXRay extends ConfigurationPart {
+ public class AntiXray extends ConfigurationPart {
+ public boolean enabled = false;
+ public ChunkPacketBlockControllerAntiXray.EngineMode engineMode = ChunkPacketBlockControllerAntiXray.EngineMode.HIDE;
+ public EngineMode engineMode = EngineMode.HIDE;
+ public int maxBlockHeight = 64;
+ public int updateRadius = 2;
+ public boolean lavaObscures = false;
@ -2141,6 +2143,45 @@ index 0000000000000000000000000000000000000000..9c339ef178ebc3b0251095f320e4a7a3
+ return MiniMessage.miniMessage().serialize(component);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/serializer/EngineModeSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/EngineModeSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..27c0679d376bb31ab52131dfea74b3b580ca92b5
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/serializer/EngineModeSerializer.java
@@ -0,0 +1,33 @@
+package io.papermc.paper.configuration.serializer;
+
+import io.papermc.paper.configuration.type.EngineMode;
+import org.spongepowered.configurate.serialize.ScalarSerializer;
+import org.spongepowered.configurate.serialize.SerializationException;
+
+import java.lang.reflect.Type;
+import java.util.function.Predicate;
+
+public final class EngineModeSerializer extends ScalarSerializer<EngineMode> {
+
+ public EngineModeSerializer() {
+ super(EngineMode.class);
+ }
+
+ @Override
+ public EngineMode deserialize(Type type, Object obj) throws SerializationException {
+ if (obj instanceof Integer id) {
+ try {
+ return EngineMode.valueOf(id);
+ } catch (IllegalArgumentException e) {
+ throw new SerializationException(id + " is not a valid id for type " + type + " for this node");
+ }
+ }
+
+ throw new SerializationException(obj + " is not of a valid type " + type + " for this node");
+ }
+
+ @Override
+ protected Object serialize(EngineMode item, Predicate<Class<?>> typeSupported) {
+ return item.getId();
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/serializer/EnumValueSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/EnumValueSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..2afb9268447792e3cdb46172b2050dbce066c59a
@ -3730,6 +3771,49 @@ index 0000000000000000000000000000000000000000..fdc906b106a5c6fff2675d5399650f5b
+ }
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/type/EngineMode.java b/src/main/java/io/papermc/paper/configuration/type/EngineMode.java
new file mode 100644
index 0000000000000000000000000000000000000000..99e90636051fa0c770ee2eafb7f0d29c8195f9ae
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/type/EngineMode.java
@@ -0,0 +1,37 @@
+package io.papermc.paper.configuration.type;
+
+import io.papermc.paper.configuration.serializer.EngineModeSerializer;
+import org.spongepowered.configurate.serialize.ScalarSerializer;
+
+public enum EngineMode {
+
+ HIDE(1, "hide ores"), OBFUSCATE(2, "obfuscate");
+
+ public static final ScalarSerializer<EngineMode> SERIALIZER = new EngineModeSerializer();
+
+ private final int id;
+ private final String description;
+
+ EngineMode(int id, String description) {
+ this.id = id;
+ this.description = description;
+ }
+
+ public static EngineMode valueOf(int id) {
+ for (EngineMode engineMode : values()) {
+ if (engineMode.getId() == id) {
+ return engineMode;
+ }
+ }
+
+ throw new IllegalArgumentException("No enum constant with id " + id);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/type/IntOrDefault.java b/src/main/java/io/papermc/paper/configuration/type/IntOrDefault.java
new file mode 100644
index 0000000000000000000000000000000000000000..3278045dbf081cc4099e2eac3a6c4fac3012be4b

View File

@ -148,7 +148,7 @@ index 0000000000000000000000000000000000000000..e4540ea278f2dc871cb6a3cb8897559b
+}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java
new file mode 100644
index 0000000000000000000000000000000000000000..aabad39d13ead83042ec2e4dd7f4ed4966af650d
index 0000000000000000000000000000000000000000..bd86dc2ad2f87969da4add06de2a629f69d4b5de
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java
@@ -0,0 +1,45 @@
@ -193,19 +193,20 @@ index 0000000000000000000000000000000000000000..aabad39d13ead83042ec2e4dd7f4ed49
+
+ }
+
+ public void onPlayerLeftClickBlock(ServerPlayerGameMode serverPlayerGameMode, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight) {
+ public void onPlayerLeftClickBlock(ServerPlayerGameMode serverPlayerGameMode, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) {
+
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
new file mode 100644
index 0000000000000000000000000000000000000000..a5d43901595f864c8a5dd5d013aa42d7f294e489
index 0000000000000000000000000000000000000000..dabd93c35bdbac6a8b668a82d5f3d4173a1baa4a
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
@@ -0,0 +1,692 @@
@@ -0,0 +1,635 @@
+package com.destroystokyo.paper.antixray;
+
+import io.papermc.paper.configuration.WorldConfiguration;
+import io.papermc.paper.configuration.type.EngineMode;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.Direction;
+import net.minecraft.core.Registry;
@ -225,15 +226,11 @@ index 0000000000000000000000000000000000000000..a5d43901595f864c8a5dd5d013aa42d7
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.*;
+import org.bukkit.Bukkit;
+import org.spongepowered.configurate.serialize.ScalarSerializer;
+import org.spongepowered.configurate.serialize.SerializationException;
+
+import java.lang.reflect.Type;
+import java.util.*;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.function.IntSupplier;
+import java.util.function.Predicate;
+
+public final class ChunkPacketBlockControllerAntiXray extends ChunkPacketBlockController {
+
@ -262,7 +259,7 @@ index 0000000000000000000000000000000000000000..a5d43901595f864c8a5dd5d013aa42d7
+
+ public ChunkPacketBlockControllerAntiXray(Level level, Executor executor) {
+ this.executor = executor;
+ WorldConfiguration.AntiCheat.AntiXRay paperWorldConfig = level.paperConfig().anticheat.antiXray;
+ WorldConfiguration.Anticheat.AntiXray paperWorldConfig = level.paperConfig().anticheat.antiXray;
+ engineMode = paperWorldConfig.engineMode;
+ maxBlockHeight = paperWorldConfig.maxBlockHeight >> 4 << 4;
+ updateRadius = paperWorldConfig.updateRadius;
@ -337,7 +334,7 @@ index 0000000000000000000000000000000000000000..a5d43901595f864c8a5dd5d013aa42d7
+
+ if (blockState != null) {
+ solidGlobal[i] = blockState.isRedstoneConductor(emptyChunk, zeroPos)
+ && blockState.getBlock() != Blocks.SPAWNER && blockState.getBlock() != Blocks.BARRIER && blockState.getBlock() != Blocks.SHULKER_BOX && blockState.getBlock() != Blocks.SLIME_BLOCK || paperWorldConfig.lavaObscures && blockState == Blocks.LAVA.defaultBlockState();
+ && blockState.getBlock() != Blocks.SPAWNER && blockState.getBlock() != Blocks.BARRIER && blockState.getBlock() != Blocks.SHULKER_BOX && blockState.getBlock() != Blocks.SLIME_BLOCK && blockState.getBlock() != Blocks.MANGROVE_ROOTS || paperWorldConfig.lavaObscures && blockState == Blocks.LAVA.defaultBlockState();
+ // Comparing blockState == Blocks.LAVA.defaultBlockState() instead of blockState.getBlock() == Blocks.LAVA ensures that only "stationary lava" is used
+ // shulker box checks TE.
+ }
@ -788,7 +785,7 @@ index 0000000000000000000000000000000000000000..a5d43901595f864c8a5dd5d013aa42d7
+ }
+
+ @Override
+ public void onPlayerLeftClickBlock(ServerPlayerGameMode serverPlayerGameMode, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight) {
+ public void onPlayerLeftClickBlock(ServerPlayerGameMode serverPlayerGameMode, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) {
+ if (blockPos.getY() <= maxBlockHeightUpdatePosition) {
+ updateNearbyBlocks(serverPlayerGameMode.level, blockPos);
+ }
@ -840,60 +837,6 @@ index 0000000000000000000000000000000000000000..a5d43901595f864c8a5dd5d013aa42d7
+ ((ServerLevel) level).getChunkSource().blockChanged(blockPos);
+ }
+ }
+
+ public enum EngineMode {
+
+ HIDE(1, "hide ores"),
+ OBFUSCATE(2, "obfuscate");
+
+ public static final ScalarSerializer<EngineMode> SERIALIZER = new Serializer();
+
+ private final int id;
+ private final String description;
+
+ EngineMode(int id, String description) {
+ this.id = id;
+ this.description = description;
+ }
+
+ public static EngineMode getById(int id) {
+ for (EngineMode engineMode : values()) {
+ if (engineMode.id == id) {
+ return engineMode;
+ }
+ }
+
+ return null;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ static class Serializer extends ScalarSerializer<EngineMode> {
+
+ Serializer() {
+ super(EngineMode.class);
+ }
+
+ @Override
+ public EngineMode deserialize(Type type, Object obj) throws SerializationException {
+ if (obj instanceof Integer num) {
+ return Objects.requireNonNullElse(EngineMode.getById(num), HIDE);
+ }
+ throw new SerializationException(obj + " is not of a valid type (" + type + ") for this node");
+ }
+
+ @Override
+ protected Object serialize(EngineMode item, Predicate<Class<?>> typeSupported) {
+ return item.getId();
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java
new file mode 100644
@ -1016,27 +959,8 @@ index 0000000000000000000000000000000000000000..80a2dfb266ae1221680a7b24fee2f7e2
+ chunkPacketBlockControllerAntiXray.obfuscate(this);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
index fa191f418079a8ee24326c5952d12d4481f57aef..28c54542f8c4168c6da8e9d897d33569fc145caf 100644
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -1,5 +1,6 @@
package io.papermc.paper.configuration;
+import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray;
import com.google.common.base.Suppliers;
import com.google.common.collect.Table;
import com.mojang.logging.LogUtils;
@@ -201,6 +202,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
.register(DoubleOrDefault.SERIALIZER)
.register(BooleanOrDefault.SERIALIZER)
.register(Duration.SERIALIZER)
+ .register(ChunkPacketBlockControllerAntiXray.EngineMode.SERIALIZER)
.register(FallbackValueSerializer.create(contextMap.require(SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), MinecraftServer::getServer))
.register(new RegistryValueSerializer<>(new TypeToken<EntityType<?>>() {}, Registry.ENTITY_TYPE_REGISTRY, true))
.register(new RegistryValueSerializer<>(Item.class, Registry.ITEM_REGISTRY, true))
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
index 568ac283baf40e2a89f5b002ffd899eba8008ef2..23d76eb74a88610472aa0288559efbaa5cd916dc 100644
index 568ac283baf40e2a89f5b002ffd899eba8008ef2..2b35059cfe7a27238e0a74df058733897a26ac1c 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
@@ -33,7 +33,10 @@ public class ClientboundLevelChunkPacketData {
@ -1045,17 +969,18 @@ index 568ac283baf40e2a89f5b002ffd899eba8008ef2..23d76eb74a88610472aa0288559efbaa
- public ClientboundLevelChunkPacketData(LevelChunk chunk) {
+ // Paper start - Anti-Xray - Add chunk packet info
+ @Deprecated public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, null); } // Notice for updates: Please make sure this constructor isn't used anywhere
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, null); }
+ public ClientboundLevelChunkPacketData(LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo) {
+ // Paper end
this.heightmaps = new CompoundTag();
for(Map.Entry<Heightmap.Types, Heightmap> entry : chunk.getHeightmaps()) {
@@ -43,7 +46,13 @@ public class ClientboundLevelChunkPacketData {
@@ -43,7 +46,14 @@ public class ClientboundLevelChunkPacketData {
}
this.buffer = new byte[calculateChunkSize(chunk)];
- extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), chunk);
+
+ // Paper start - Anti-Xray - Add chunk packet info
+ if (chunkPacketInfo != null) {
+ chunkPacketInfo.setBuffer(this.buffer);
@ -1066,13 +991,13 @@ index 568ac283baf40e2a89f5b002ffd899eba8008ef2..23d76eb74a88610472aa0288559efbaa
this.blockEntitiesData = Lists.newArrayList();
int totalTileEntities = 0; // Paper
@@ -103,9 +112,12 @@ public class ClientboundLevelChunkPacketData {
@@ -103,9 +113,12 @@ public class ClientboundLevelChunkPacketData {
return byteBuf;
}
- public static void extractChunkData(FriendlyByteBuf buf, LevelChunk chunk) {
+ // Paper start - Anti-Xray - Add chunk packet info
+ @Deprecated public static void extractChunkData(FriendlyByteBuf buf, LevelChunk chunk) { ClientboundLevelChunkPacketData.extractChunkData(buf, chunk, null); } // Notice for updates: Please make sure this function isn't used anywhere
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public static void extractChunkData(FriendlyByteBuf buf, LevelChunk chunk) { ClientboundLevelChunkPacketData.extractChunkData(buf, chunk, null); }
+ public static void extractChunkData(FriendlyByteBuf buf, LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo) {
for(LevelChunkSection levelChunkSection : chunk.getSections()) {
- levelChunkSection.write(buf);
@ -1082,7 +1007,7 @@ index 568ac283baf40e2a89f5b002ffd899eba8008ef2..23d76eb74a88610472aa0288559efbaa
}
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 7825d6f0fdcfda6212cff8033ec55fb7db236154..2072aa8710f6e285f7c8f76c63b7bcf85cc11030 100644
index 7825d6f0fdcfda6212cff8033ec55fb7db236154..000853110c7a89f2d0403a7a2737025a5ac28240 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java
@@ -13,13 +13,30 @@ public class ClientboundLevelChunkWithLightPacket implements Packet<ClientGamePa
@ -1104,13 +1029,13 @@ index 7825d6f0fdcfda6212cff8033ec55fb7db236154..2072aa8710f6e285f7c8f76c63b7bcf8
+ // Paper end
+
+ // Paper start - Anti-Xray - Add chunk packet info
+ @Deprecated public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet skyBits, @Nullable BitSet blockBits, boolean nonEdge) { this(chunk, lightProvider, skyBits, blockBits, nonEdge, true); } // Notice for updates: Please make sure this constructor isn't used anywhere
+ @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) {
+ com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo = modifyBlocks ? chunk.getLevel().chunkPacketBlockController.getChunkPacketInfo(this, chunk) : null;
ChunkPos chunkPos = chunk.getPos();
this.x = chunkPos.x;
this.z = chunkPos.z;
- this.chunkData = new ClientboundLevelChunkPacketData(chunk);
+ com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> 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);
@ -1119,7 +1044,7 @@ index 7825d6f0fdcfda6212cff8033ec55fb7db236154..2072aa8710f6e285f7c8f76c63b7bcf8
public ClientboundLevelChunkWithLightPacket(FriendlyByteBuf buf) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d95db45e21861eb9f1623c44dd797429ae158760..1c3dacd12ff5f26dd5559d0b99c917a0be3b4d6a 100644
index d95db45e21861eb9f1623c44dd797429ae158760..f15ad47696574d7668374729de44286258a36f3b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -997,7 +997,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -1164,7 +1089,7 @@ index d95db45e21861eb9f1623c44dd797429ae158760..1c3dacd12ff5f26dd5559d0b99c917a0
- player.trackChunk(chunk.getPos(), (Packet) cachedDataPacket.getValue());
+ Boolean shouldModify = chunk.getLevel().chunkPacketBlockController.shouldModify(player, chunk);
+ player.trackChunk(chunk.getPos(), cachedDataPackets.getValue().computeIfAbsent(shouldModify, (s) -> {
+ player.trackChunk(chunk.getPos(), (Packet) cachedDataPackets.getValue().computeIfAbsent(shouldModify, (s) -> {
+ return new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null, true, (Boolean) s);
+ }));
+ // Paper end
@ -1185,7 +1110,7 @@ index ff902ae5a96616bb70897d9326fc65a3261b07d9..57abbcd9d59ea29e2feb238ee342f28a
this.convertable = convertable_conversionsession;
this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 3fadf6b46cc722ad81cf810c0761cf717e9f9b78..312768054e02847bbc7d2ec7fa6198dad52b86d2 100644
index 3fadf6b46cc722ad81cf810c0761cf717e9f9b78..af00442931f9f6cf878bd61137c2f29fc7c8d0b1 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -49,7 +49,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
@ -1202,24 +1127,23 @@ index 3fadf6b46cc722ad81cf810c0761cf717e9f9b78..312768054e02847bbc7d2ec7fa6198da
}
+
+ this.level.chunkPacketBlockController.onPlayerLeftClickBlock(this, pos, action, direction, worldHeight); // Paper - Anti-Xray
+ this.level.chunkPacketBlockController.onPlayerLeftClickBlock(this, pos, action, direction, worldHeight, sequence); // Paper - Anti-Xray
}
public void destroyAndAck(BlockPos pos, int sequence, String reason) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 4c1d34bd274d8e2a4003a286536652367da9488a..c57f400bf1fcfa1a24259ced1821aa43c428d90b 100644
index 4c1d34bd274d8e2a4003a286536652367da9488a..8e5e773fffcb17d20328903d1b1fc9d9e0aefa3e 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -173,6 +173,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -173,6 +173,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}
// Paper end
+ public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
+
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
public static BlockPos lastPhysicsProblem; // Spigot
private org.spigotmc.TickLimiter entityLimiter;
@@ -191,7 +193,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -191,7 +192,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract ResourceKey<LevelStem> getTypeKey();
@ -1228,7 +1152,7 @@ index 4c1d34bd274d8e2a4003a286536652367da9488a..c57f400bf1fcfa1a24259ced1821aa43
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
this.generator = gen;
@@ -275,6 +277,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -275,6 +276,7 @@ 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);
@ -1236,7 +1160,7 @@ index 4c1d34bd274d8e2a4003a286536652367da9488a..c57f400bf1fcfa1a24259ced1821aa43
}
// Paper start
@@ -455,6 +458,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -455,6 +457,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// CraftBukkit end
BlockState iblockdata1 = chunk.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag
@ -1245,20 +1169,34 @@ index 4c1d34bd274d8e2a4003a286536652367da9488a..c57f400bf1fcfa1a24259ced1821aa43
if (iblockdata1 == null) {
// CraftBukkit start - remove blockstate if failed (or the same)
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
index 0d815a39d50bb8c06f81e3386764db6a00d84985..a5160f0336f1ab50e415bddaa958616e8a08dfee 100644
index 0d815a39d50bb8c06f81e3386764db6a00d84985..8dd9879d52ba9bd816fcfa5413ef3bfc25d562c7 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -109,7 +109,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
private static void replaceMissingSections(LevelHeightAccessor world, Registry<Biome> biome, LevelChunkSection[] sectionArray) {
@@ -99,17 +99,19 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
}
}
- ChunkAccess.replaceMissingSections(heightLimitView, biome, this.sections);
+ ChunkAccess.replaceMissingSections(heightLimitView, biome, this.sections, pos); // Paper - Anti-Xray - Add parameters
// CraftBukkit start
this.biomeRegistry = biome;
}
public final Registry<Biome> biomeRegistry;
// CraftBukkit end
- private static void replaceMissingSections(LevelHeightAccessor world, Registry<Biome> biome, LevelChunkSection[] sectionArray) {
+ // Paper start - Anti-Xray - Add parameters
+ private static void replaceMissingSections(LevelHeightAccessor world, Registry<Biome> biome, LevelChunkSection[] sectionArray, ChunkPos pos) {
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, null, world instanceof net.minecraft.world.level.Level ? (net.minecraft.world.level.Level) world : null); // Paper - Anti-Xray - Add parameters
+ 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
}
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index e9fae214f60fe682087d41cfaa55a1b25e5f4331..1a28b3a60bd568cba7c96152fa8dd2a64dd56801 100644
index e9fae214f60fe682087d41cfaa55a1b25e5f4331..ee7296eb561b59a4c0fce200f1a59f66a6526cc2 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -93,7 +93,7 @@ public class LevelChunk extends ChunkAccess {
@ -1266,12 +1204,12 @@ index e9fae214f60fe682087d41cfaa55a1b25e5f4331..1a28b3a60bd568cba7c96152fa8dd2a6
public LevelChunk(Level world, ChunkPos pos, UpgradeData upgradeData, LevelChunkTicks<Block> blockTickScheduler, LevelChunkTicks<Fluid> fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable LevelChunk.PostLoadProcessor entityLoader, @Nullable BlendingData blendingData) {
- super(pos, upgradeData, world, world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), inhabitedTime, sectionArrayInitializer, blendingData);
+ super(pos, upgradeData, world, net.minecraft.server.MinecraftServer.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), inhabitedTime, sectionArrayInitializer, blendingData); // Paper - Anti-Xray - The world isnt ready yet, use server singleton for registry
+ super(pos, upgradeData, world, net.minecraft.server.MinecraftServer.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), inhabitedTime, sectionArrayInitializer, blendingData); // Paper - Anti-Xray - The world isn't ready yet, use server singleton for registry
this.tickersInLevel = Maps.newHashMap();
this.clientLightReady = false;
this.level = (ServerLevel) world; // CraftBukkit - type
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
index ae37e97e52557b48f129cc02eeea395378a48444..ba4da27861236eb62d208f2a660e232a143232ac 100644
index ae37e97e52557b48f129cc02eeea395378a48444..785fbcf9bafcdec1c5be213de3d8512690023415 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -36,10 +36,13 @@ public class LevelChunkSection {
@ -1280,7 +1218,7 @@ index ae37e97e52557b48f129cc02eeea395378a48444..ba4da27861236eb62d208f2a660e232a
- public LevelChunkSection(int chunkPos, Registry<Biome> biomeRegistry) {
+ // Paper start - Anti-Xray - Add parameters
+ @Deprecated public LevelChunkSection(int chunkPos, Registry<Biome> biomeRegistry) { this(chunkPos, biomeRegistry, null, null); } // Notice for updates: Please make sure this constructor isn't used anywhere
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public LevelChunkSection(int chunkPos, Registry<Biome> biomeRegistry) { this(chunkPos, biomeRegistry, null, null); }
+ public LevelChunkSection(int chunkPos, Registry<Biome> biomeRegistry, net.minecraft.world.level.ChunkPos pos, net.minecraft.world.level.Level level) {
+ // Paper end
this.bottomBlockY = LevelChunkSection.getBottomBlockY(chunkPos);
@ -1297,7 +1235,7 @@ index ae37e97e52557b48f129cc02eeea395378a48444..ba4da27861236eb62d208f2a660e232a
- public void write(FriendlyByteBuf buf) {
+ // Paper start - Anti-Xray - Add chunk packet info
+ @Deprecated public void write(FriendlyByteBuf buf) { this.write(buf, null); } // Notice for updates: Please make sure this method isn't used anywhere
+ @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<BlockState> chunkPacketInfo) {
buf.writeShort(this.nonEmptyBlockCount);
- this.states.write(buf);
@ -1309,7 +1247,7 @@ index ae37e97e52557b48f129cc02eeea395378a48444..ba4da27861236eb62d208f2a660e232a
public int getSerializedSize() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
index 1152bf7f7a7784457c778b215db91b9e02066fba..0a174b07e58f638e75a013552c964a9fb833d4cb 100644
index 1152bf7f7a7784457c778b215db91b9e02066fba..c36de77b3124a519b3f324c5a187337884fe9e28 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -29,6 +29,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@ -1320,52 +1258,36 @@ index 1152bf7f7a7784457c778b215db91b9e02066fba..0a174b07e58f638e75a013552c964a9f
private volatile PalettedContainer.Data<T> data;
private final PalettedContainer.Strategy strategy;
private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer");
@@ -41,43 +42,82 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -41,14 +42,19 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
this.threadingDetector.checkAndUnlock();
}
- public static <T> Codec<PalettedContainer<T>> codecRW(IdMap<T> idMap, Codec<T> codec, PalettedContainer.Strategy strategy, T object) {
- PalettedContainerRO.Unpacker<T, PalettedContainer<T>> unpacker = PalettedContainer::unpack;
- return codec(idMap, codec, strategy, object, unpacker);
+ // Paper start
+ public interface UnpackerPaper<T, C extends PalettedContainerRO<T>> {
+ DataResult<C> read(IdMap<T> idMap, PalettedContainer.Strategy strategy, PalettedContainerRO.PackedData<T> packedData, T defaultValue, T @org.jetbrains.annotations.Nullable [] presetValues);
+ // Paper start - Anti-Xray - Add preset values
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public static <T> Codec<PalettedContainer<T>> codecRW(IdMap<T> idMap, Codec<T> codec, PalettedContainer.Strategy strategy, T object) { return PalettedContainer.codecRW(idMap, codec, strategy, object, null); }
+ public static <T> Codec<PalettedContainer<T>> codecRW(IdMap<T> idMap, Codec<T> codec, PalettedContainer.Strategy strategy, T object, T @org.jetbrains.annotations.Nullable [] presetValues) {
+ PalettedContainerRO.Unpacker<T, PalettedContainer<T>> unpacker = (idMapx, strategyx, packedData) -> {
+ return unpack(idMapx, strategyx, packedData, object, presetValues);
+ };
+ // Paper end
return codec(idMap, codec, strategy, object, unpacker);
}
+ // Paper end
- public static <T> Codec<PalettedContainerRO<T>> codecRO(IdMap<T> idMap, Codec<T> codec, PalettedContainer.Strategy strategy, T object) {
- PalettedContainerRO.Unpacker<T, PalettedContainerRO<T>> unpacker = (idMapx, strategyx, packedData) -> {
public static <T> Codec<PalettedContainerRO<T>> codecRO(IdMap<T> idMap, Codec<T> codec, PalettedContainer.Strategy strategy, T object) {
PalettedContainerRO.Unpacker<T, PalettedContainerRO<T>> unpacker = (idMapx, strategyx, packedData) -> {
- return unpack(idMapx, strategyx, packedData).map((palettedContainer) -> {
+ public static <T> Codec<PalettedContainer<T>> codecRW(IdMap<T> idMap, Codec<T> codec, PalettedContainer.Strategy strategy, T object, T @org.jetbrains.annotations.Nullable [] presetValues) { // Paper - add preset values, paper unpacker
+ UnpackerPaper<T, PalettedContainer<T>> unpacker = PalettedContainer::unpack; // Paper - add preset values, paper unpacker
+ return codec(idMap, codec, strategy, object, unpacker, presetValues); // Paper - add preset values, paper unpacker
+ }
+
+ public static <T> Codec<PalettedContainerRO<T>> codecRO(IdMap<T> idMap, Codec<T> codec, PalettedContainer.Strategy strategy, T object) { // Paper - add preset values, paper unpacker
+ UnpackerPaper<T, PalettedContainerRO<T>> unpacker = (idMapx, strategyx, packedData, object2, presetvalues) -> { // Paper - add preset values, paper unpacker
+ return unpack(idMapx, strategyx, packedData, object, presetvalues).map((palettedContainer) -> { // Paper - add preset values, paper unpacker
+ return unpack(idMapx, strategyx, packedData, object, null).map((palettedContainer) -> { // Paper - Anti-Xray - Add preset values
return palettedContainer;
});
};
- return codec(idMap, codec, strategy, object, unpacker);
+ return codec(idMap, codec, strategy, object, unpacker, null); // Paper - add preset values, paper unpacker
}
- private static <T, C extends PalettedContainerRO<T>> Codec<C> codec(IdMap<T> idMap, Codec<T> entryCodec, PalettedContainer.Strategy provider, T object, PalettedContainerRO.Unpacker<T, C> unpacker) {
+ private static <T, C extends PalettedContainerRO<T>> Codec<C> codec(IdMap<T> idMap, Codec<T> entryCodec, PalettedContainer.Strategy provider, T object, UnpackerPaper<T, C> unpacker, T @org.jetbrains.annotations.Nullable [] presetValues) { // Paper - add preset values, paper unpacker
return RecordCodecBuilder.<PackedData<T>>create((instance) -> { // Paper - decompile fix
return instance.group(entryCodec.mapResult(ExtraCodecs.orElsePartial(object)).listOf().fieldOf("palette").forGetter(PalettedContainerRO.PackedData::paletteEntries), Codec.LONG_STREAM.optionalFieldOf("data").forGetter(PalettedContainerRO.PackedData::storage)).apply(instance, PalettedContainerRO.PackedData::new);
}).comapFlatMap((packedData) -> {
- return unpacker.read(idMap, provider, packedData);
+ return unpacker.read(idMap, provider, packedData, object ,presetValues); // Paper - add preset values
}, (palettedContainerRO) -> {
return palettedContainerRO.pack(idMap, provider);
@@ -65,19 +71,52 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
});
}
- public PalettedContainer(IdMap<T> idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Configuration<T> dataProvider, BitStorage storage, List<T> paletteEntries) {
+ // Paper start - Anti-Xray - Add preset values
+ @Deprecated public PalettedContainer(IdMap<T> idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Configuration<T> dataProvider, BitStorage storage, List<T> paletteEntries) { this(idList, paletteProvider, dataProvider, storage, paletteEntries, null, null); } // Notice for updates: Please make sure this constructor isn't used anywhere
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public PalettedContainer(IdMap<T> idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Configuration<T> dataProvider, BitStorage storage, List<T> paletteEntries) { this(idList, paletteProvider, dataProvider, storage, paletteEntries, null, null); }
+ public PalettedContainer(IdMap<T> idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Configuration<T> dataProvider, BitStorage storage, List<T> paletteEntries, T defaultValue, T @org.jetbrains.annotations.Nullable [] presetValues) {
+ this.presetValues = presetValues;
this.registry = idList;
@ -1408,14 +1330,14 @@ index 1152bf7f7a7784457c778b215db91b9e02066fba..0a174b07e58f638e75a013552c964a9f
- public PalettedContainer(IdMap<T> idList, T object, PalettedContainer.Strategy paletteProvider) {
+ // Paper start - Anti-Xray - Add preset values
+ @Deprecated public PalettedContainer(IdMap<T> idList, T object, PalettedContainer.Strategy paletteProvider) { this(idList, object, paletteProvider, null); } // Notice for updates: Please make sure this constructor isn't used anywhere
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public PalettedContainer(IdMap<T> idList, T object, PalettedContainer.Strategy paletteProvider) { this(idList, object, paletteProvider, null); }
+ public PalettedContainer(IdMap<T> idList, T object, PalettedContainer.Strategy paletteProvider, T @org.jetbrains.annotations.Nullable [] presetValues) {
+ this.presetValues = presetValues;
+ // Paper end
this.strategy = paletteProvider;
this.registry = idList;
this.data = this.createOrReuseData((PalettedContainer.Data<T>)null, 0);
@@ -92,11 +132,33 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -92,11 +131,33 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@Override
public int onResize(int newBits, T object) {
PalettedContainer.Data<T> data = this.data;
@ -1450,21 +1372,22 @@ index 1152bf7f7a7784457c778b215db91b9e02066fba..0a174b07e58f638e75a013552c964a9f
public T getAndSet(int x, int y, int z, T value) {
this.acquire();
@@ -166,25 +228,34 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -166,25 +227,36 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
data.palette.read(buf);
buf.readLongArray(data.storage.getRaw());
this.data = data;
+ this.addPresetValues(); // Paper - Anti-Xray - Add preset values (inefficient, but this not used by the server)
+ this.addPresetValues(); // Paper - Anti-Xray - Add preset values (inefficient, but this isn't used by the server)
} finally {
this.release();
}
}
- @Override
- public void write(FriendlyByteBuf buf) {
+ // Paper start - Anti-Xray - Add chunk packet info
+ @Override @Deprecated public void write(FriendlyByteBuf buf) { this.write(buf, null, 0); } // Notice for updates: Please make sure this method isn't used anywhere
+ @Override
+ @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<T> chunkPacketInfo, int bottomBlockY) {
this.acquire();
@ -1485,11 +1408,11 @@ index 1152bf7f7a7784457c778b215db91b9e02066fba..0a174b07e58f638e75a013552c964a9f
}
- private static <T> DataResult<PalettedContainer<T>> unpack(IdMap<T> idMap, PalettedContainer.Strategy strategy, PalettedContainerRO.PackedData<T> packedData) {
+ private static <T> DataResult<PalettedContainer<T>> unpack(IdMap<T> idMap, PalettedContainer.Strategy strategy, PalettedContainerRO.PackedData<T> packedData, T defaultValue, T @org.jetbrains.annotations.Nullable [] presetValues) { // Paper - Anti-Xray - Add preset values) {
+ private static <T> DataResult<PalettedContainer<T>> unpack(IdMap<T> idMap, PalettedContainer.Strategy strategy, PalettedContainerRO.PackedData<T> packedData, T defaultValue, T @org.jetbrains.annotations.Nullable [] presetValues) { // Paper - Anti-Xray - Add preset values
List<T> list = packedData.paletteEntries();
int i = strategy.size();
int j = strategy.calculateBitsForSerialization(idMap, list.size());
@@ -220,7 +291,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -220,7 +292,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
}
}
@ -1498,7 +1421,7 @@ index 1152bf7f7a7784457c778b215db91b9e02066fba..0a174b07e58f638e75a013552c964a9f
}
@Override
@@ -280,7 +351,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -280,12 +352,12 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
}
public PalettedContainer<T> copy() {
@ -1507,7 +1430,13 @@ index 1152bf7f7a7784457c778b215db91b9e02066fba..0a174b07e58f638e75a013552c964a9f
}
@Override
@@ -329,9 +400,20 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
public PalettedContainer<T> recreate() {
- return new PalettedContainer<>(this.registry, this.data.palette.valueFor(0), this.strategy);
+ return new PalettedContainer<>(this.registry, this.data.palette.valueFor(0), this.strategy, this.presetValues); // Paper - Anti-Xray - Add preset values
}
@Override
@@ -329,9 +401,20 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
return 1 + this.palette.getSerializedSize() + FriendlyByteBuf.getVarIntSize(this.storage.getSize()) + this.storage.getRaw().length * 8;
}
@ -1529,6 +1458,22 @@ index 1152bf7f7a7784457c778b215db91b9e02066fba..0a174b07e58f638e75a013552c964a9f
buf.writeLongArray(this.storage.getRaw());
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainerRO.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainerRO.java
index e1c7a5909be7b8bf1156fc62b3965f3562c729e6..e561a45c5115c3c3930999b2a10108bc4fab99af 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainerRO.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainerRO.java
@@ -14,7 +14,10 @@ public interface PalettedContainerRO<T> {
void getAll(Consumer<T> consumer);
- 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<T> chunkPacketInfo, int bottomBlockY);
+ // Paper end
int getSerializedSize();
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
index 864e591b10360b0f12fe5c5a650da372555ebd10..f26a08f81495dde6205b34254d159b042e5a6ea9 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
@ -1642,7 +1587,7 @@ index cd70aa0fa7a575c3c1f6434db74c1cc8342fddb4..21927118d1762302dc560b385fd3a432
});
});
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
index 960405935e395a31c0300773c41413801cf0d290..6f6bf950cd15b34031618782c82824cf0b191ff8 100644
index 960405935e395a31c0300773c41413801cf0d290..4a23d03757e1735b9ebb8c003adcc0374a7d672d 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
@@ -27,8 +27,13 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
@ -1653,7 +1598,7 @@ index 960405935e395a31c0300773c41413801cf0d290..6f6bf950cd15b34031618782c82824cf
+ private final World world;
- public OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes) {
+ @Deprecated public OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes) { this(minHeight, maxHeight, biomes, null); } // Notice for updates: Please make sure this constructor isn't used anywhere
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes) { this(minHeight, maxHeight, biomes, null); }
+ public OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes, World world) {
+ this.world = world;
+ // Paper end

View File

@ -14,10 +14,10 @@ And since minecart hoppers are used _very_ rarely near we can avoid alot of sear
Combined, this adds up a lot.
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index c57f400bf1fcfa1a24259ced1821aa43c428d90b..e4dbc1118d6bf3c1958f893de5dbd975af0ce5bc 100644
index 8e5e773fffcb17d20328903d1b1fc9d9e0aefa3e..11a02c8259a039bbe229c5626055bceef9308b5a 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -966,7 +966,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -965,7 +965,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}
}

View File

@ -269,7 +269,7 @@ index f33f38c3c8c277d208b00b64e1d0fa7bb5eda7ec..e585cdd8a598df2b04c265d5568f8ba8
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 8d99c45e10da9d8a54a12b1039515da05bd56f6b..42645114b270b1e7c2b3112abd7eaa90d0e4451c 100644
index 07e397061420556b9f44314f0c459f5cdd30aad3..3afadbd25cb002966869db6e07cd26cf6d52646b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -592,6 +592,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -306,10 +306,10 @@ index 6fefa619299d3202158490630d62c16aef71e831..7a4ade1a4190bf4fbb048919ae2be230
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index e4dbc1118d6bf3c1958f893de5dbd975af0ce5bc..59f387fd4e7e4e02ce5759829b3121a9a7e3aff0 100644
index 11a02c8259a039bbe229c5626055bceef9308b5a..c488e069a19d4bf082c94032571fcc77c0bada50 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -794,6 +794,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -793,6 +793,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
try {
tickConsumer.accept(entity);
} catch (Throwable throwable) {
@ -318,7 +318,7 @@ index e4dbc1118d6bf3c1958f893de5dbd975af0ce5bc..59f387fd4e7e4e02ce5759829b3121a9
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
MinecraftServer.LOGGER.error(msg, throwable);
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 89f4ea65b20e773bd3782c41db3a2af7b5b405f3..3fe94e580d2aaae9616ba83c0d3a44687505b249 100644
index 5f65aa89dfb21fced457a3a9fef6ba05385b6b76..291bcca206722c86bca6d13058d18c413c38d256 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -1083,6 +1083,7 @@ public class LevelChunk extends ChunkAccess {

View File

@ -34,10 +34,10 @@ index 38bb502e9f1272020a23a3ef8ebb0cb1a5a251ef..b18b0e1b5e059f08fd3117eaa0fb28a1
this.level.getProfiler().push("explosion_blocks");
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 59f387fd4e7e4e02ce5759829b3121a9a7e3aff0..7481f7828d66623c9d606761ca37e53138eacb26 100644
index c488e069a19d4bf082c94032571fcc77c0bada50..d5e80a0d953e7792669f21011bc685adaec78464 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -430,6 +430,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -429,6 +429,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
// CraftBukkit start - tree generation
if (this.captureTreeGeneration) {

View File

@ -120,7 +120,7 @@ index 4e8a79f2d3b6f52c6284bc9b0ce2423dc43a154f..36a9d52d9af3bc398010c52dc16ab23e
for (int i = 0; i < this.futures.length(); ++i) {
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = (CompletableFuture) this.futures.get(i);
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 10ef89963ad805c775b9c649f4e17c9d4ec7f4b7..eb74a831fc439c56fe1ac2d4769ebefa1e5759a3 100644
index 86cdc8951544c16f8dc5148bc2c7bf9bbf920c60..c468b012197b2c3444ad8bb0d8a9f41c7ab17b10 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -106,6 +106,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
@ -346,10 +346,10 @@ index 4b9e030016bef762c01ace5181ade7d1480b8702..c1e62a0d1655993430da7e4cbd8075cd
MinecraftTimings.savePlayers.stopTiming(); // Paper
return null; }); // Paper - ensure main
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
index a5160f0336f1ab50e415bddaa958616e8a08dfee..bef890d2e8d883165a48a7f5b39a865198749a0b 100644
index 8dd9879d52ba9bd816fcfa5413ef3bfc25d562c7..44e1fdbf6798034b9092fe151568ff392da8af08 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -455,6 +455,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
@@ -457,6 +457,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
public LevelHeightAccessor getHeightAccessorForGeneration() {
return this;
}
@ -358,7 +358,7 @@ index a5160f0336f1ab50e415bddaa958616e8a08dfee..bef890d2e8d883165a48a7f5b39a8651
public static record TicksToSave(SerializableTickContainer<Block> blocks, SerializableTickContainer<Fluid> fluids) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 3fe94e580d2aaae9616ba83c0d3a44687505b249..797ff36295412ac8429d573e039d870fd85eb569 100644
index 291bcca206722c86bca6d13058d18c413c38d256..f8a3048fa80758d82f2e92d48bd3cd2c585ae6c2 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -87,6 +87,12 @@ public class LevelChunk extends ChunkAccess {

View File

@ -303,10 +303,10 @@ index f73f16ffc65467db8fa370beddffb7cae054a13c..4ad7c5377c67fd156353166145b1edd3
if (dimensionKey == LevelStem.OVERWORLD) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index bd04c33ae31bfaed508ac5d39db7cb1fd5cf2913..646e40b01a4df143802dc981a5594a17c37e5d10 100644
index d9a88b29cfefcdbce7bfc477b6c1af0e51079102..c21274a72dca31c9160ecbcfa7eb42de64e91454 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -183,6 +183,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -182,6 +182,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
@ -356,7 +356,7 @@ index a96a6af2bcec3134b7caa32299bd07af50e83b89..0d96d1c0b66c57c680759f3567ef1b0c
return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()));
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b38265b4077f37aaab2701663f6740dd8fd729b4..6ca513be5b3a0c158364487118d25f145f990df5 100644
index 887bf340b56177099bc5c55ac185fb66d8a080f7..cb2a03fa0fab132db498be708cb2870a6a8549ef 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1202,12 +1202,7 @@ public final class CraftServer implements Server {

View File

@ -14,7 +14,7 @@ contention situations.
And this is extremely a low contention situation.
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
index 0a174b07e58f638e75a013552c964a9fb833d4cb..6800452604e0db660e8d5dca9778abd6e2f66478 100644
index c36de77b3124a519b3f324c5a187337884fe9e28..0c309a2f10ca75dc90076156b2d666deb37f72ba 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -32,14 +32,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@ -34,8 +34,8 @@ index 0a174b07e58f638e75a013552c964a9fb833d4cb..6800452604e0db660e8d5dca9778abd6
+ // this.threadingDetector.checkAndUnlock(); // Paper - disable this
}
// Paper start
@@ -130,7 +130,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
// Paper start - Anti-Xray - Add preset values
@@ -129,7 +129,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
}
@Override
@ -44,7 +44,7 @@ index 0a174b07e58f638e75a013552c964a9fb833d4cb..6800452604e0db660e8d5dca9778abd6
PalettedContainer.Data<T> data = this.data;
// Paper start - Anti-Xray - Add preset values
@@ -177,7 +177,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -176,7 +176,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
return this.getAndSet(this.strategy.getIndex(x, y, z), value);
}
@ -53,7 +53,7 @@ index 0a174b07e58f638e75a013552c964a9fb833d4cb..6800452604e0db660e8d5dca9778abd6
int i = this.data.palette.idFor(value);
int j = this.data.storage.getAndSet(index, i);
return this.data.palette.valueFor(j);
@@ -194,7 +194,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -193,7 +193,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
}
@ -62,7 +62,7 @@ index 0a174b07e58f638e75a013552c964a9fb833d4cb..6800452604e0db660e8d5dca9778abd6
int i = this.data.palette.idFor(value);
this.data.storage.set(index, i);
}
@@ -219,7 +219,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -218,7 +218,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
});
}
@ -71,16 +71,16 @@ index 0a174b07e58f638e75a013552c964a9fb833d4cb..6800452604e0db660e8d5dca9778abd6
this.acquire();
try {
@@ -237,7 +237,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
// Paper start - Anti-Xray - Add chunk packet info
@Override @Deprecated public void write(FriendlyByteBuf buf) { this.write(buf, null, 0); } // Notice for updates: Please make sure this method isn't used anywhere
@@ -238,7 +238,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@Override
@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<T> chunkPacketInfo, int bottomBlockY) {
+ public synchronized void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) { // Paper - synchronize
this.acquire();
try {
@@ -295,7 +295,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -296,7 +296,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
}
@Override

View File

@ -30,10 +30,10 @@ index a19be39c5b4552ebfa74634c0cc004f9de0a9eff..8c61dc53f4874ab7013938abdf5d65a6
if (chunk != null) {
for (int j2 = k; j2 <= j1; ++j2) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 646e40b01a4df143802dc981a5594a17c37e5d10..91a36884e10c278f6e0efb4fbed1352492b38200 100644
index c21274a72dca31c9160ecbcfa7eb42de64e91454..2a4e6c6f732d9cd2567352b7fca2c284b0bb9c1b 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -200,6 +200,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -199,6 +199,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return (CraftServer) Bukkit.getServer();
}

View File

@ -1051,10 +1051,10 @@ index 1a3be6f0570c7c746eafa36544debe90d7629432..c0817ef8927f00e2fd3fbf3289f8041f
<T extends Entity> List<T> getEntities(EntityTypeTest<Entity, T> filter, AABB box, Predicate<? super T> predicate);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 91a36884e10c278f6e0efb4fbed1352492b38200..ff118d658d52a4ac5d261727c6e23a3b663ecae9 100644
index 2a4e6c6f732d9cd2567352b7fca2c284b0bb9c1b..4f484e71c93a5243d242e116e2f204ead407f598 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -294,6 +294,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -293,6 +293,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
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
@ -1062,7 +1062,7 @@ index 91a36884e10c278f6e0efb4fbed1352492b38200..ff118d658d52a4ac5d261727c6e23a3b
}
// Paper start
@@ -968,26 +969,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -967,26 +968,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public List<Entity> getEntities(@Nullable Entity except, AABB box, Predicate<? super Entity> predicate) {
this.getProfiler().incrementCounter("getEntities");
List<Entity> list = Lists.newArrayList();
@ -1090,7 +1090,7 @@ index 91a36884e10c278f6e0efb4fbed1352492b38200..ff118d658d52a4ac5d261727c6e23a3b
return list;
}
@@ -996,27 +978,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -995,27 +977,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
this.getProfiler().incrementCounter("getEntities");
List<T> list = Lists.newArrayList();
@ -1133,7 +1133,7 @@ index 91a36884e10c278f6e0efb4fbed1352492b38200..ff118d658d52a4ac5d261727c6e23a3b
return list;
}
@@ -1343,4 +1320,46 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1342,4 +1319,46 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public long nextSubTickCount() {
return (long) (this.subTickCount++);
}

View File

@ -126,7 +126,7 @@ index 438406936633b9c67d21b26527c3d1654118c744..2de322ffc2eedae9efe39f9b771c447d
}
// Paper start - optimise chunk tick iteration
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 5aa9c963d0d66c506f0abf821367d1b78f3bf58c..2c1b2521b995a926c85e58d21926d9a3b8743304 100644
index dc00bbc9642c9c112f930e669e84c11de7375414..a82c81f8a4178fc049ffaa2e5a837836ef5b42a6 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -210,6 +210,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -154,10 +154,10 @@ index 5aa9c963d0d66c506f0abf821367d1b78f3bf58c..2c1b2521b995a926c85e58d21926d9a3
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index ff118d658d52a4ac5d261727c6e23a3b663ecae9..0d41b56519db354b730527b28e0294469ff11db9 100644
index 4f484e71c93a5243d242e116e2f204ead407f598..7c4ec47829bb0818f489544f2b396852d42a35d3 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -800,6 +800,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -799,6 +799,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Spigot end
} else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) {
tickingblockentity.tick();
@ -169,7 +169,7 @@ index ff118d658d52a4ac5d261727c6e23a3b663ecae9..0d41b56519db354b730527b28e029446
}
}
this.blockEntityTickers.removeAll(toRemove);
@@ -814,6 +819,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -813,6 +818,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
try {
tickConsumer.accept(entity);

View File

@ -13,10 +13,10 @@ Paper recently reverted this optimisation, so it's been reintroduced
here.
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 0d41b56519db354b730527b28e0294469ff11db9..5e8d303133a2cd8b748c127e2b6aa4d279d4df4d 100644
index 7c4ec47829bb0818f489544f2b396852d42a35d3..e7487e0a21727666889cc2ec8841cca2b2c965d5 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -369,6 +369,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -368,6 +368,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@Override
public final LevelChunk getChunk(int chunkX, int chunkZ) { // Paper - final to help inline

View File

@ -90,7 +90,7 @@ index 0000000000000000000000000000000000000000..7d93652c1abbb6aee6eb7c26cf35d4d0
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b2c6d72beefe48189aa36f453f8950209b7e3ee1..1fc9cafbec488240a242b0de5eb2582cef86f413 100644
index 9ab6f7df04b56012413f2485dd5a8785f95390dc..a856089e292580d20876603efda688d7ab18b3d5 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -665,6 +665,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -312,10 +312,10 @@ index 69c98c2cb2fd8f149a39bbddcbfe0c5c5adc3904..5575730aa6f77a91467c394fa8465c33
public BlockPos getHomePos() {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 5e8d303133a2cd8b748c127e2b6aa4d279d4df4d..504455c626a9d22f552144a38861dc356fb02b99 100644
index e7487e0a21727666889cc2ec8841cca2b2c965d5..45be0dc44b98ca90b68e6ff3278e4de21934d7a2 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1302,10 +1302,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1301,10 +1301,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract RecipeManager getRecipeManager();
public BlockPos getBlockRandomPos(int x, int y, int z, int l) {
@ -429,10 +429,10 @@ index 2ad73237f4664535c3d5120a54b713f44cddb793..c2e3df8331cec5fe5650501a4dc4ac47
public PalettedContainer<BlockState> getStates() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
index 6800452604e0db660e8d5dca9778abd6e2f66478..6fb87dcdc4fab4b430a5c9003548c874e6b26734 100644
index f4b3284d1ad93ca3328fc1c1ddcbcb14296e1545..7b0c3cff4a5048db5ca52d5ea1711a5e5d959af2 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -382,6 +382,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -383,6 +383,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
}
}

View File

@ -39,7 +39,7 @@ index 8bea90cb57f38f33e8b3162e24e353993a98ebbf..5b4c3ca92dffff876af18db106310cb1
// Paper end - optimise anyPlayerCloseEnoughForSpawning
long lastAutoSaveTime; // Paper - incremental autosave
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index f77c2eeb6c367df4d72e5908071eb079ee6f0def..17b6c6ee8c2754e1f98badebf506390c0bb7ce87 100644
index 603b5275221494b146b0f30680362d695c55f30b..640b87d6acb4faf78bb4d6930bf0ac17691f89f7 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -168,6 +168,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -105,7 +105,7 @@ index f77c2eeb6c367df4d72e5908071eb079ee6f0def..17b6c6ee8c2754e1f98badebf506390c
protected ChunkGenerator generator() {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b0c971df2ae296b2ae4516ff121052b3b4526103..2c61c756764bc8d2830294ca0c8be8e0e8fb1828 100644
index a856089e292580d20876603efda688d7ab18b3d5..ecd025798205691892819863a50d7767f663d3d1 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -405,6 +405,83 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -226,10 +226,10 @@ index a49dfe4f81d449c5dd7ba5b8f9af7fec5c54f5de..3646b969fa51b9683ab4137e530c3a6f
if (entityhuman != null) {
double d0 = entityhuman.distanceToSqr((Entity) this);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 504455c626a9d22f552144a38861dc356fb02b99..13c4b7aee9b9802edbaf7e4df9e9355667e727bb 100644
index 45be0dc44b98ca90b68e6ff3278e4de21934d7a2..17c0110fd5ccb8399af797cc892ca285b1fb7964 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -206,6 +206,69 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -205,6 +205,69 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.getChunkIfLoaded(chunkX, chunkZ) != null;
}
// Paper end
@ -322,7 +322,7 @@ index 4150e8cd7197eac53042d56f0a53a4951f8824ce..e31a2eea9a62ab2c0bed1a97dab6bae2
private static Boolean isValidSpawnPostitionForType(ServerLevel world, MobCategory group, StructureManager structureAccessor, ChunkGenerator chunkGenerator, MobSpawnSettings.SpawnerData spawnEntry, BlockPos.MutableBlockPos pos, double squaredDistance) { // Paper
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 3591ac3b7823e109e01ebfa54ac70aa4deabd4f6..1a64558f8ebedbc4c47ad34787a45c0d89159360 100644
index 2981ba61e347b8660082ff946521fc7f219d2c0d..c85380c3bf3bf4448a28a91af78f41c235a583e4 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -235,6 +235,98 @@ public class LevelChunk extends ChunkAccess {

View File

@ -4469,7 +4469,7 @@ index 5b4c3ca92dffff876af18db106310cb14e8612b1..5482be03a667939ff009b6810d5cc90c
private final DebugBuffer<ChunkHolder.ChunkSaveDebug> chunkToSaveHistory;
public int oldTicketLevel;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 595d414f633e3183147fb4b137a149e948dab332..457cd717d6fce598d4cfc41ea59af601ce2c0a85 100644
index 0b06da8a9d83d7adc6edad721ca167ae6f7d3e4b..d5c3bd389d36f4d8be167bd6a9a15c329b0fb453 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -136,7 +136,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -4863,7 +4863,7 @@ index 254ac28e692cf06c3286c8f4c6edb9de412851a2..b8541b54886fc1f48b4c99cf449284ff
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
index bef890d2e8d883165a48a7f5b39a865198749a0b..8d7d10f620b30c35d2ef580ea914f2c62054a785 100644
index 44e1fdbf6798034b9092fe151568ff392da8af08..c15cedaca3a3dc921ac758580b165d28ee3a945f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -81,6 +81,47 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
@ -5011,13 +5011,13 @@ index ca46ed27fdc1eef979829d19b9e90db6d5c59e09..c37bb3125334a3a4c6c05e57289d758f
super(wrapped.getPos(), UpgradeData.EMPTY, wrapped.levelHeightAccessor, wrapped.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), wrapped.getBlendingData());
this.wrapped = wrapped;
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 1a64558f8ebedbc4c47ad34787a45c0d89159360..0de0519c01886a39399233b275db44b95e2f3d96 100644
index c85380c3bf3bf4448a28a91af78f41c235a583e4..d870cefbe5b7485f423817f4f639e3e2a304640c 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -100,6 +100,10 @@ public class LevelChunk extends ChunkAccess {
public LevelChunk(Level world, ChunkPos pos, UpgradeData upgradeData, LevelChunkTicks<Block> blockTickScheduler, LevelChunkTicks<Fluid> fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable LevelChunk.PostLoadProcessor entityLoader, @Nullable BlendingData blendingData) {
super(pos, upgradeData, world, net.minecraft.server.MinecraftServer.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), inhabitedTime, sectionArrayInitializer, blendingData); // Paper - Anti-Xray - The world isnt ready yet, use server singleton for registry
super(pos, upgradeData, world, net.minecraft.server.MinecraftServer.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), inhabitedTime, sectionArrayInitializer, blendingData); // Paper - Anti-Xray - The world isn't ready yet, use server singleton for registry
+ // Paper start - rewrite light engine
+ this.setBlockNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world));
+ this.setSkyNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world));
@ -5039,10 +5039,10 @@ index 1a64558f8ebedbc4c47ad34787a45c0d89159360..0de0519c01886a39399233b275db44b9
while (iterator.hasNext()) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
index 6fb87dcdc4fab4b430a5c9003548c874e6b26734..08e1309e618377d170c446a1568c21b7bf4e5683 100644
index 7b0c3cff4a5048db5ca52d5ea1711a5e5d959af2..022412285ad63b4bc26e109956f8263310ae64b4 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -204,7 +204,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -203,7 +203,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
return this.get(this.strategy.getIndex(x, y, z));
}

View File

@ -1369,7 +1369,7 @@ index 5482be03a667939ff009b6810d5cc90c8601e983..11cd31691307749e925930c4b6e10e3f
public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getOrScheduleFuture(ChunkStatus targetStatus, ChunkMap chunkStorage) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 4f6473398edd9987dfbb6cef79ed1bc93c3dd809..d98c489a58c8c2e657a8879b991aa57ef78f5015 100644
index 4cbe5dbb1909de40153e3757cfff8d8c36cf66f3..638d438824918bf410d66286f3b738c1c1e3311b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -221,6 +221,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -1984,10 +1984,10 @@ index 0b3e9e4ed162a6d9e1f3f55b9522b75c94d13254..fa1ff2e79954089552974cefedfcbff2
double deltaZ = soundPos.getZ() - player.getZ();
double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 13c4b7aee9b9802edbaf7e4df9e9355667e727bb..9c036f7be422fd8447726478eee15a77637fdb9c 100644
index 17c0110fd5ccb8399af797cc892ca285b1fb7964..c118efaadd0e3e29f9adcd65c11ecabfc6d76216 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -628,6 +628,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -627,6 +627,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement
this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i);
@ -2000,7 +2000,7 @@ index 13c4b7aee9b9802edbaf7e4df9e9355667e727bb..9c036f7be422fd8447726478eee15a77
if ((i & 1) != 0) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 0de0519c01886a39399233b275db44b95e2f3d96..c46cbbf9ac4c5661933b03bc0b2559f7ade8c798 100644
index d870cefbe5b7485f423817f4f639e3e2a304640c..2292cb0e0c1a3e0ed34b941f028136bfb0bff13e 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -191,6 +191,43 @@ public class LevelChunk extends ChunkAccess {

View File

@ -18,10 +18,10 @@ index 12d7cb0eb485987d245454fa2d9fef67ea7e9c76..b1e326cf4f7fe447f81b588dcb0eda9a
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) {
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
index 23d76eb74a88610472aa0288559efbaa5cd916dc..6c30f3bf85ec0e0dfbae1b5ed192b43b1dbd48be 100644
index 0016d99020d9e9ef9cf0763b81e33be571d511ac..b606f73cd5778c5b987ba4be57667ca1800a3f68 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
@@ -182,6 +182,7 @@ public class ClientboundLevelChunkPacketData {
@@ -183,6 +183,7 @@ public class ClientboundLevelChunkPacketData {
CompoundTag compoundTag = blockEntity.getUpdateTag();
BlockPos blockPos = blockEntity.getBlockPos();
int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ());

View File

@ -2034,10 +2034,10 @@ index 458ebb5dabd1f24ea3d49ef57eea687ce61f0fc0..aa3c6f18d817826e9af2a3047b0b683d
EntityCallbacks() {}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 9c036f7be422fd8447726478eee15a77637fdb9c..d59dea221ba0f1b9c14f403d3c6ea61b2c454316 100644
index c118efaadd0e3e29f9adcd65c11ecabfc6d76216..9467ccaa1d73e1913495a46919aee530e749977d 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1453,4 +1453,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1452,4 +1452,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return ret;
}
// Paper end