hey, look ma, am doing my part!

This commit is contained in:
MiniDigger 2021-11-24 08:37:09 +01:00 committed by MiniDigger | Martin
parent 1d74ffcb7c
commit 6ac2614a5f
16 changed files with 281 additions and 353 deletions

View file

@ -5,7 +5,7 @@ Subject: [PATCH] PlayerDeathEvent#shouldDropExperience
diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
index 8c46eaebf004823c1c31eb2c7304181487cb1332..3d45d2e41aad6992b40a22030f2a63baeec78757 100644 index 61d12cb8f0a924abf696b6da7258f34dbb7b51b6..8175e5329f7fb6da4c7faf695162b51492114dc3 100644
--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java --- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
+++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
@@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add effect to block break naturally
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index 5ac36e0f90d0889853736390877aa92ec0ca181b..25294bd8c4faa05af1429d934c5666742e3ee23c 100644 index 5e92f8f6ba5368ae934c24154ab13fbc6a46272f..20463f92d83dea3130d4a3f0ac70e5f399c97711 100644
--- a/src/main/java/org/bukkit/block/Block.java --- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java
@@ -470,6 +470,26 @@ public interface Block extends Metadatable { @@ -470,6 +470,26 @@ public interface Block extends Metadatable {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index ade858610c76be24576fe60d509e4a8f2531f442..367bea78d479b73b35a324c58f8f9b981d9c8ccf 100644 index 7a97a4a395f20680bc3b028586c9a17b84783d99..75f6915e2a2cc7328cf51b953edcc3ee6f9e7fbd 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -1,10 +1,12 @@ @@ -1,10 +1,12 @@
@ -21,7 +21,7 @@ index ade858610c76be24576fe60d509e4a8f2531f442..367bea78d479b73b35a324c58f8f9b98
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.spigotmc.SpigotWorldConfig; import org.spigotmc.SpigotWorldConfig;
@@ -528,5 +530,40 @@ public class PaperWorldConfig { @@ -518,5 +520,40 @@ public class PaperWorldConfig {
private void lightQueueSize() { private void lightQueueSize() {
lightQueueSize = getInt("light-queue-size", lightQueueSize); lightQueueSize = getInt("light-queue-size", lightQueueSize);
} }
@ -258,7 +258,7 @@ index 0000000000000000000000000000000000000000..280ece653cdda74e9c8fab4e9e5b3a95
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java 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 new file mode 100644
index 0000000000000000000000000000000000000000..58052a5f773b5882acd90bc0214a36e8a512817c index 0000000000000000000000000000000000000000..f9ed88082f1a58a0572acc22761fad4340185aeb
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
@@ -0,0 +1,635 @@ @@ -0,0 +1,635 @@
@ -268,7 +268,7 @@ index 0000000000000000000000000000000000000000..58052a5f773b5882acd90bc0214a36e8
+import net.minecraft.core.BlockPos; +import net.minecraft.core.BlockPos;
+import net.minecraft.core.Direction; +import net.minecraft.core.Direction;
+import net.minecraft.core.Registry; +import net.minecraft.core.Registry;
+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacket; +import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
+import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
+import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MinecraftServer; +import net.minecraft.server.MinecraftServer;
@ -420,7 +420,7 @@ index 0000000000000000000000000000000000000000..58052a5f773b5882acd90bc0214a36e8
+ } + }
+ +
+ @Override + @Override
+ public ChunkPacketInfoAntiXray getChunkPacketInfo(ClientboundLevelChunkPacket chunkPacket, LevelChunk chunk) { + public ChunkPacketInfoAntiXray getChunkPacketInfo(ClientboundLevelChunkPacketData chunkPacket, LevelChunk chunk) {
+ // Return a new instance to collect data and objects in the right state while creating the chunk packet for thread safe access later + // Return a new instance to collect data and objects in the right state while creating the chunk packet for thread safe access later
+ return new ChunkPacketInfoAntiXray(chunkPacket, chunk, this); + return new ChunkPacketInfoAntiXray(chunkPacket, chunk, this);
+ } + }
@ -899,19 +899,19 @@ index 0000000000000000000000000000000000000000..58052a5f773b5882acd90bc0214a36e8
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java 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 new file mode 100644
index 0000000000000000000000000000000000000000..7bc2d4daffa8e9e71c3bf496d2cf1a2b7f3c6a4b index 0000000000000000000000000000000000000000..351ab20ba506cca55ee198f06346bad8b1593d0a
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java
@@ -0,0 +1,80 @@ @@ -0,0 +1,80 @@
+package com.destroystokyo.paper.antixray; +package com.destroystokyo.paper.antixray;
+ +
+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacket; +import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
+import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunk;
+import net.minecraft.world.level.chunk.Palette; +import net.minecraft.world.level.chunk.Palette;
+ +
+public class ChunkPacketInfo<T> { +public class ChunkPacketInfo<T> {
+ +
+ private final ClientboundLevelChunkPacket chunkPacket; + private final ClientboundLevelChunkPacketData chunkPacket;
+ private final LevelChunk chunk; + private final LevelChunk chunk;
+ private final int[] bits; + private final int[] bits;
+ private final Object[] palettes; + private final Object[] palettes;
@ -919,26 +919,26 @@ index 0000000000000000000000000000000000000000..7bc2d4daffa8e9e71c3bf496d2cf1a2b
+ private final Object[][] presetValues; + private final Object[][] presetValues;
+ private byte[] buffer; + private byte[] buffer;
+ +
+ public ChunkPacketInfo(ClientboundLevelChunkPacket chunkPacket, LevelChunk chunk) { + public ChunkPacketInfo(ClientboundLevelChunkPacketData chunkPacket, LevelChunk chunk) {
+ this.chunkPacket = chunkPacket; + this.chunkPacket = chunkPacket;
+ this.chunk = chunk; + this.chunk = chunk;
+ int sections = chunk.getSectionsCount(); + int sections = chunk.getSectionsCount();
+ bits = new int[sections]; + this.bits = new int[sections];
+ palettes = new Object[sections]; + this.palettes = new Object[sections];
+ indexes = new int[sections]; + this.indexes = new int[sections];
+ presetValues = new Object[sections][]; + this.presetValues = new Object[sections][];
+ } + }
+ +
+ public ClientboundLevelChunkPacket getChunkPacket() { + public ClientboundLevelChunkPacketData getChunkPacket() {
+ return chunkPacket; + return this.chunkPacket;
+ } + }
+ +
+ public LevelChunk getChunk() { + public LevelChunk getChunk() {
+ return chunk; + return this.chunk;
+ } + }
+ +
+ public byte[] getBuffer() { + public byte[] getBuffer() {
+ return buffer; + return this.buffer;
+ } + }
+ +
+ public void setBuffer(byte[] buffer) { + public void setBuffer(byte[] buffer) {
@ -946,7 +946,7 @@ index 0000000000000000000000000000000000000000..7bc2d4daffa8e9e71c3bf496d2cf1a2b
+ } + }
+ +
+ public int getBits(int chunkSectionIndex) { + public int getBits(int chunkSectionIndex) {
+ return bits[chunkSectionIndex]; + return this.bits[chunkSectionIndex];
+ } + }
+ +
+ public void setBits(int chunkSectionIndex, int bits) { + public void setBits(int chunkSectionIndex, int bits) {
@ -955,24 +955,24 @@ index 0000000000000000000000000000000000000000..7bc2d4daffa8e9e71c3bf496d2cf1a2b
+ +
+ @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked")
+ public Palette<T> getPalette(int chunkSectionIndex) { + public Palette<T> getPalette(int chunkSectionIndex) {
+ return (Palette<T>) palettes[chunkSectionIndex]; + return (Palette<T>) this.palettes[chunkSectionIndex];
+ } + }
+ +
+ public void setPalette(int chunkSectionIndex, Palette<T> palette) { + public void setPalette(int chunkSectionIndex, Palette<T> palette) {
+ palettes[chunkSectionIndex] = palette; + this.palettes[chunkSectionIndex] = palette;
+ } + }
+ +
+ public int getIndex(int chunkSectionIndex) { + public int getIndex(int chunkSectionIndex) {
+ return indexes[chunkSectionIndex]; + return this.indexes[chunkSectionIndex];
+ } + }
+ +
+ public void setIndex(int chunkSectionIndex, int index) { + public void setIndex(int chunkSectionIndex, int index) {
+ indexes[chunkSectionIndex] = index; + this.indexes[chunkSectionIndex] = index;
+ } + }
+ +
+ @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked")
+ public T[] getPresetValues(int chunkSectionIndex) { + public T[] getPresetValues(int chunkSectionIndex) {
+ return (T[]) presetValues[chunkSectionIndex]; + return (T[]) this.presetValues[chunkSectionIndex];
+ } + }
+ +
+ public void setPresetValues(int chunkSectionIndex, T[] presetValues) { + public void setPresetValues(int chunkSectionIndex, T[] presetValues) {
@ -980,18 +980,18 @@ index 0000000000000000000000000000000000000000..7bc2d4daffa8e9e71c3bf496d2cf1a2b
+ } + }
+ +
+ public boolean isWritten(int chunkSectionIndex) { + public boolean isWritten(int chunkSectionIndex) {
+ return bits[chunkSectionIndex] != 0; + return this.bits[chunkSectionIndex] != 0;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..02324a59ac21db5349fe2a74248b2c6f92fa8233 index 0000000000000000000000000000000000000000..a3ee0cf08076848806912b983d386caadf762acc
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
+package com.destroystokyo.paper.antixray; +package com.destroystokyo.paper.antixray;
+ +
+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacket; +import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
+import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunk;
+ +
@ -1000,13 +1000,13 @@ index 0000000000000000000000000000000000000000..02324a59ac21db5349fe2a74248b2c6f
+ private final ChunkPacketBlockControllerAntiXray chunkPacketBlockControllerAntiXray; + private final ChunkPacketBlockControllerAntiXray chunkPacketBlockControllerAntiXray;
+ private LevelChunk[] nearbyChunks; + private LevelChunk[] nearbyChunks;
+ +
+ public ChunkPacketInfoAntiXray(ClientboundLevelChunkPacket chunkPacket, LevelChunk chunk, ChunkPacketBlockControllerAntiXray chunkPacketBlockControllerAntiXray) { + public ChunkPacketInfoAntiXray(ClientboundLevelChunkPacketData chunkPacket, LevelChunk chunk, ChunkPacketBlockControllerAntiXray chunkPacketBlockControllerAntiXray) {
+ super(chunkPacket, chunk); + super(chunkPacket, chunk);
+ this.chunkPacketBlockControllerAntiXray = chunkPacketBlockControllerAntiXray; + this.chunkPacketBlockControllerAntiXray = chunkPacketBlockControllerAntiXray;
+ } + }
+ +
+ public LevelChunk[] getNearbyChunks() { + public LevelChunk[] getNearbyChunks() {
+ return nearbyChunks; + return this.nearbyChunks;
+ } + }
+ +
+ public void setNearbyChunks(LevelChunk... nearbyChunks) { + public void setNearbyChunks(LevelChunk... nearbyChunks) {
@ -1015,18 +1015,18 @@ index 0000000000000000000000000000000000000000..02324a59ac21db5349fe2a74248b2c6f
+ +
+ @Override + @Override
+ public void run() { + public void run() {
+ chunkPacketBlockControllerAntiXray.obfuscate(this); + this.chunkPacketBlockControllerAntiXray.obfuscate(this);
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java 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 c28879f32b004f36ff746ea2274f91ddd9501e71..60d72e488bc77cd913328be400ca374a873b4561 100644 index dba11f277f3703e1ee7f5a62f021d319e4ab18fc..a6f693ee925b03aa591720864d6b493dfe89e4e8 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
@@ -37,7 +37,24 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe @@ -33,7 +33,24 @@ public class ClientboundLevelChunkPacketData {
} }
// Paper end // Paper end
- public ClientboundLevelChunkPacket(LevelChunk chunk) { - public ClientboundLevelChunkPacketData(LevelChunk chunk) {
+ // Paper start - Async-Anti-Xray - Ready flag for the connection + // Paper start - Async-Anti-Xray - Ready flag for the connection
+ private volatile boolean ready; + private volatile boolean ready;
+ +
@ -1041,76 +1041,87 @@ index c28879f32b004f36ff746ea2274f91ddd9501e71..60d72e488bc77cd913328be400ca374a
+ // Paper end + // Paper end
+ +
+ // Paper start - Anti-Xray - Add chunk packet info + // Paper start - Anti-Xray - Add chunk packet info
+ @Deprecated public ClientboundLevelChunkPacket(LevelChunk chunk) { this(chunk, true); } // Notice for updates: Please make sure this constructor isn't used anywhere + @Deprecated public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, true); } // Notice for updates: Please make sure this constructor isn't used anywhere
+ public ClientboundLevelChunkPacket(LevelChunk chunk, boolean modifyBlocks) { + public ClientboundLevelChunkPacketData(LevelChunk chunk, boolean modifyBlocks) {
+ com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo = modifyBlocks ? chunk.level.chunkPacketBlockController.getChunkPacketInfo(this, chunk) : null; + com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo = modifyBlocks ? chunk.level.chunkPacketBlockController.getChunkPacketInfo(this, chunk) : null;
+ // Paper end + // Paper end
ChunkPos chunkPos = chunk.getPos(); this.heightmaps = new CompoundTag();
this.x = chunkPos.x;
this.z = chunkPos.z;
@@ -51,7 +68,14 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe
this.biomes = chunk.getBiomes().writeBiomes(); for(Entry<Heightmap.Types, Heightmap> entry : chunk.getHeightmaps()) {
this.buffer = new byte[this.calculateChunkSize(chunk)]; @@ -43,7 +60,13 @@ public class ClientboundLevelChunkPacketData {
- this.availableSections = this.extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), chunk); }
+
this.buffer = new byte[calculateChunkSize(chunk)];
- extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), chunk);
+ // Paper start - Anti-Xray - Add chunk packet info + // Paper start - Anti-Xray - Add chunk packet info
+ if (chunkPacketInfo != null) { + if (chunkPacketInfo != null) {
+ chunkPacketInfo.setBuffer(this.buffer); + chunkPacketInfo.setBuffer(this.buffer);
+ } + }
+ +
+ this.availableSections = this.extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), chunk, chunkPacketInfo); + this.extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), chunk, chunkPacketInfo);
+ // Paper end + // Paper end
this.blockEntitiesTags = Lists.newArrayList(); this.blockEntitiesData = Lists.newArrayList();
int totalTileEntities = 0; // Paper int totalTileEntities = 0; // Paper
@@ -71,6 +95,7 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe @@ -60,6 +83,7 @@ public class ClientboundLevelChunkPacketData {
this.blockEntitiesTags.add(compoundTag); this.blockEntitiesData.add(ClientboundLevelChunkPacketData.BlockEntityInfo.create(entry2.getValue()));
} }
+ chunk.level.chunkPacketBlockController.modifyBlocks(this, chunkPacketInfo); // Paper - Anti-Xray - Modify blocks + chunk.level.chunkPacketBlockController.modifyBlocks(this, chunkPacketInfo); // Paper - Anti-Xray - Modify blocks
} }
public ClientboundLevelChunkPacket(FriendlyByteBuf buf) { public ClientboundLevelChunkPacketData(FriendlyByteBuf buf, int x, int z) {
@@ -120,7 +145,10 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe @@ -103,9 +127,11 @@ public class ClientboundLevelChunkPacketData {
return byteBuf; return byteBuf;
} }
- public BitSet extractChunkData(FriendlyByteBuf buf, LevelChunk chunk) { - public static void extractChunkData(FriendlyByteBuf buf, LevelChunk chunk) {
+ // Paper start - Anti-Xray - Add chunk packet info + // Paper start - Anti-Xray - Add chunk packet info
+ @Deprecated public BitSet extractChunkData(FriendlyByteBuf buf, LevelChunk chunk) { return extractChunkData(buf, chunk, null); } // Notice for updates: Please make sure this method isn't used anywhere + @Deprecated public static void extractChunkData(FriendlyByteBuf buf, LevelChunk chunk) { extractChunkData(buf, chunk, null); } // Notice for updates: Please make sure this method isn't used anywhere
+ public BitSet extractChunkData(FriendlyByteBuf buf, LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo) { + public static void extractChunkData(FriendlyByteBuf buf, LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo) {
+ // Paper end for(LevelChunkSection levelChunkSection : chunk.getSections()) {
BitSet bitSet = new BitSet(); - levelChunkSection.write(buf);
LevelChunkSection[] levelChunkSections = chunk.getSections(); + levelChunkSection.write(buf, chunkPacketInfo);
int i = 0;
@@ -129,7 +157,7 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe
LevelChunkSection levelChunkSection = levelChunkSections[i];
if (levelChunkSection != LevelChunk.EMPTY_SECTION && !levelChunkSection.isEmpty()) {
bitSet.set(i);
- levelChunkSection.write(buf);
+ levelChunkSection.write(buf, chunkPacketInfo); // Paper - Anti-Xray - Add chunk packet info
}
} }
}
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 079734654c0fd421561b5f9003cd318bad5787a9..dc8ff27a3851982b0a798274ddb5e13af6917794 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java
@@ -14,11 +14,12 @@ public class ClientboundLevelChunkWithLightPacket implements Packet<ClientGamePa
private final ClientboundLevelChunkPacketData chunkData;
private final ClientboundLightUpdatePacketData lightData;
- public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet bitSet, @Nullable BitSet bitSet2, boolean bl) {
+ @Deprecated public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet bitSet, @Nullable BitSet bitSet2, boolean bl) { this(chunk, lightProvider, bitSet, bitSet2, bl, true); } // Paper - anti xray - make sure this isn't called anywhere
+ public ClientboundLevelChunkWithLightPacket(LevelChunk chunk, LevelLightEngine lightProvider, @Nullable BitSet bitSet, @Nullable BitSet bitSet2, boolean bl, boolean modifyBlocks) { // Paper - anti xray
ChunkPos chunkPos = chunk.getPos();
this.x = chunkPos.x;
this.z = chunkPos.z;
- this.chunkData = new ClientboundLevelChunkPacketData(chunk);
+ this.chunkData = new ClientboundLevelChunkPacketData(chunk, modifyBlocks); // Paper - anti xray
this.lightData = new ClientboundLightUpdatePacketData(chunkPos, lightProvider, bitSet, bitSet2, bl);
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 1197c510211b725742d48152443178eea94058a8..5bbdf56179d2e5fd0b42c37c84c9d4bc5faaee24 100644 index f3f6fc973cd75a42594f1ec222c220e3894e11ee..b70cabde8408c9876255bd939f9f77d61e5392df 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1534,7 +1534,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1648,7 +1648,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public void playerLoadedChunk(ServerPlayer player, Packet<?>[] packets, LevelChunk chunk) { private void playerLoadedChunk(ServerPlayer player, MutableObject<ClientboundLevelChunkWithLightPacket> cachedDataPacket, LevelChunk chunk) {
if (packets[0] == null) { if (cachedDataPacket.getValue() == null) {
- packets[0] = new ClientboundLevelChunkPacket(chunk); - cachedDataPacket.setValue(new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null, true));
+ packets[0] = new ClientboundLevelChunkPacket(chunk, chunk.level.chunkPacketBlockController.shouldModify(player, chunk)); // Paper - Ani-Xray - Bypass + cachedDataPacket.setValue(new ClientboundLevelChunkWithLightPacket(chunk, this.lightEngine, (BitSet) null, (BitSet) null, true, chunk.level.chunkPacketBlockController.shouldModify(player, chunk))); // Paper - Ani-Xray - Bypass
packets[1] = new ClientboundLightUpdatePacket(chunk.getPos(), this.lightEngine, (BitSet) null, (BitSet) null, true);
} }
player.trackChunk(chunk.getPos(), (Packet) cachedDataPacket.getValue());
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 085d807881e92149c3b31b6f76b2a5539ee629fa..1b342701b410a508323286944508e7faa175ab43 100644 index 09deaa9badf53bdc1292796c643751d8d92ac585..6c4f1fa1d96f906f3b4e1e352c919155a1092530 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -378,7 +378,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -391,7 +391,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Add env and gen to constructor, WorldData -> WorldDataServer // Add env and gen to constructor, WorldData -> WorldDataServer
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, ServerLevelData iworlddataserver, ResourceKey<Level> resourcekey, DimensionType dimensionmanager, ChunkProgressListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<CustomSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, ServerLevelData iworlddataserver, ResourceKey<Level> resourcekey, DimensionType dimensionmanager, ChunkProgressListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<CustomSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
// Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
@ -1120,10 +1131,10 @@ index 085d807881e92149c3b31b6f76b2a5539ee629fa..1b342701b410a508323286944508e7fa
this.convertable = convertable_conversionsession; this.convertable = convertable_conversionsession;
this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile()); this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile());
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 6219634a57976a6a0a9b32ed08d56107d6b5d1c3..31e3534d6e15f91d781fabb0670e53ef66cb8977 100644 index 44e5ab0b545de41b937c7ce304ce643f78a43734..a85b89a0d525e623e154c8b1bea55470d2072dcb 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/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; @@ -48,7 +48,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
public class ServerPlayerGameMode { public class ServerPlayerGameMode {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@ -1132,7 +1143,7 @@ index 6219634a57976a6a0a9b32ed08d56107d6b5d1c3..31e3534d6e15f91d781fabb0670e53ef
protected final ServerPlayer player; protected final ServerPlayer player;
private GameType gameModeForPlayer; private GameType gameModeForPlayer;
@Nullable @Nullable
@@ -315,6 +315,8 @@ public class ServerPlayerGameMode { @@ -314,6 +314,8 @@ public class ServerPlayerGameMode {
} }
} }
@ -1142,10 +1153,10 @@ index 6219634a57976a6a0a9b32ed08d56107d6b5d1c3..31e3534d6e15f91d781fabb0670e53ef
public void destroyAndAck(BlockPos pos, ServerboundPlayerActionPacket.Action action, String reason) { public void destroyAndAck(BlockPos pos, ServerboundPlayerActionPacket.Action action, String reason) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a8772b168eedca4933b4b4132ea81afd6bcaafa2..35209090439d5ab3bf5c37de28a39e60d482b64c 100644 index de7abae207b0a565a25fa4ed2f66b94c6b0cdcf9..69ac5ec34b6eb95036b679ed299e11766093935c 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -166,6 +166,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -167,6 +167,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
@ -1153,16 +1164,16 @@ index a8772b168eedca4933b4b4132ea81afd6bcaafa2..35209090439d5ab3bf5c37de28a39e60
public final co.aikar.timings.WorldTimingsHandler timings; // Paper public final co.aikar.timings.WorldTimingsHandler timings; // Paper
public static BlockPos lastPhysicsProblem; // Spigot public static BlockPos lastPhysicsProblem; // Spigot
@@ -187,7 +188,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -186,7 +187,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.typeKey;
} public abstract ResourceKey<LevelStem> getTypeKey();
- protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, final DimensionType dimensionmanager, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) { - protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, final DimensionType dimensionmanager, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) {
+ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, final DimensionType dimensionmanager, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper - Anti-Xray - Pass executor + protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, final DimensionType dimensionmanager, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper - Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), this.spigotConfig); // Paper this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), this.spigotConfig); // Paper
this.generator = gen; this.generator = gen;
@@ -261,6 +262,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -262,6 +263,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
this.keepSpawnInMemory = this.paperConfig.keepSpawnInMemory; // Paper this.keepSpawnInMemory = this.paperConfig.keepSpawnInMemory; // Paper
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
@ -1172,89 +1183,20 @@ index a8772b168eedca4933b4b4132ea81afd6bcaafa2..35209090439d5ab3bf5c37de28a39e60
} }
// Paper start // Paper start
@@ -440,6 +444,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -441,6 +445,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// CraftBukkit end // CraftBukkit end
BlockState iblockdata1 = chunk.setType(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag BlockState iblockdata1 = chunk.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag
+ this.chunkPacketBlockController.onBlockChange(this, pos, state, iblockdata1, flags, maxUpdateDepth); // Paper - Anti-Xray + this.chunkPacketBlockController.onBlockChange(this, pos, state, iblockdata1, flags, maxUpdateDepth); // Paper - Anti-Xray
if (iblockdata1 == null) { if (iblockdata1 == null) {
// CraftBukkit start - remove blockstate if failed (or the same) // 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 149ac5ec368b53a9a5e9208bd49a3c9453625d9c..12d11a249c759e99568a76c791cc0d65adfcfe94 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -74,7 +74,7 @@ public interface ChunkAccess extends BlockGetter, FeatureAccess {
default LevelChunkSection getOrCreateSection(int yIndex) {
LevelChunkSection[] levelChunkSections = this.getSections();
if (levelChunkSections[yIndex] == LevelChunk.EMPTY_SECTION) {
- levelChunkSections[yIndex] = new LevelChunkSection(this.getSectionYFromSectionIndex(yIndex));
+ levelChunkSections[yIndex] = new LevelChunkSection(this.getSectionYFromSectionIndex(yIndex), this, this.getLevel(), true); // Paper - Anti-Xray - Add parameters
}
return levelChunkSections[yIndex];
diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
index 69c2454533e6f21c70792b555ec02c6bc6d169b3..f9e0e109497d685a9d88d2fa8892287b9fa97443 100644
--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
@@ -86,7 +86,7 @@ public class EmptyLevelChunk extends LevelChunk {
private static final Biome[] EMPTY_BIOMES = new Biome[0];
public EmptyChunkBiomeContainer(Level world) {
- super(world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), world, EMPTY_BIOMES);
+ super(net.minecraft.server.MinecraftServer.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), world, EMPTY_BIOMES); // Paper - Anti-Xray - The world isnt ready yet, use server singleton for registry
}
@Override
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 8141935e2ee58bbb58c6b5cfdef5a9a88d7658ec..515e28eea8cbab261320352ee0db9b877807f3ed 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -456,7 +456,7 @@ public class LevelChunk implements ChunkAccess {
return null;
}
- chunksection = new LevelChunkSection(SectionPos.blockToSectionCoord(i));
+ chunksection = new LevelChunkSection(SectionPos.blockToSectionCoord(i), this, this.level, true); // Paper - Anti-Xray - Add parameters
this.sections[j] = chunksection;
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java 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 5fd66020a937b641e2a060cf38df731a43f3bf55..c9fefeef19bd46ade51b23eadb5eef3a88024ea1 100644 index 92a42aea3f54c49e2055e8000645d91da9471e09..2e651fcf0227dcf0d36fba6bf6e4ba6a5e21dfd7 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -20,16 +20,25 @@ public class LevelChunkSection { @@ -158,9 +158,12 @@ public class LevelChunkSection {
private short tickingFluidCount; this.biomes.read(buf);
final PalettedContainer<BlockState> states; // Paper - package-private
- public LevelChunkSection(int yOffset) {
- this(yOffset, (short)0, (short)0, (short)0);
+ // Paper start - Anti-Xray - Add parameters
+ @Deprecated public LevelChunkSection(int yOffset) { this(yOffset, null, null, true); } // Notice for updates: Please make sure this constructor isn't used anywhere
+ public LevelChunkSection(int yOffset, ChunkAccess chunk, net.minecraft.world.level.Level level, boolean initializeBlocks) {
+ this(yOffset, (short) 0, (short) 0, (short) 0, chunk, level, initializeBlocks);
+ // Paper end
}
- public LevelChunkSection(int yOffset, short nonEmptyBlockCount, short randomTickableBlockCount, short nonEmptyFluidCount) {
+ // Paper start - Anti-Xray - Add parameters
+ @Deprecated public LevelChunkSection(int yOffset, short nonEmptyBlockCount, short randomTickableBlockCount, short nonEmptyFluidCount) { // Notice for updates: Please make sure this constructor isn't used anywhere
+ this(yOffset, nonEmptyBlockCount, randomTickableBlockCount, nonEmptyFluidCount, null, null, true);
+ }
+ public LevelChunkSection(int yOffset, short nonEmptyBlockCount, short randomTickableBlockCount, short nonEmptyFluidCount, ChunkAccess chunk, net.minecraft.world.level.Level level, boolean initializeBlocks) {
+ // Paper end
this.bottomBlockY = getBottomBlockY(yOffset);
this.nonEmptyBlockCount = nonEmptyBlockCount;
this.tickingBlockCount = randomTickableBlockCount;
this.tickingFluidCount = nonEmptyFluidCount;
- this.states = new PalettedContainer<>(GLOBAL_BLOCKSTATE_PALETTE, Block.BLOCK_STATE_REGISTRY, NbtUtils::readBlockState, NbtUtils::writeBlockState, Blocks.AIR.defaultBlockState());
+ this.states = new PalettedContainer<>(GLOBAL_BLOCKSTATE_PALETTE, Block.BLOCK_STATE_REGISTRY, NbtUtils::readBlockState, NbtUtils::writeBlockState, Blocks.AIR.defaultBlockState(),
+ level == null ? null : level.chunkPacketBlockController.getPresetBlockStates(level, chunk, this, initializeBlocks), initializeBlocks); // Paper - Anti-Xray - Add preset block states
}
public static int getBottomBlockY(int chunkPos) {
@@ -147,9 +156,12 @@ public class LevelChunkSection {
this.states.read(buf);
} }
- public void write(FriendlyByteBuf buf) { - public void write(FriendlyByteBuf buf) {
@ -1265,43 +1207,42 @@ index 5fd66020a937b641e2a060cf38df731a43f3bf55..c9fefeef19bd46ade51b23eadb5eef3a
buf.writeShort(this.nonEmptyBlockCount); buf.writeShort(this.nonEmptyBlockCount);
- this.states.write(buf); - this.states.write(buf);
+ this.states.write(buf, chunkPacketInfo, this.bottomBlockY); // Paper - Anti-Xray - Add chunk packet info + this.states.write(buf, chunkPacketInfo, this.bottomBlockY); // Paper - Anti-Xray - Add chunk packet info
this.biomes.write(buf);
} }
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 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 bb8fd88aebb550edec8c679622a02a595cbc6694..ac51089aae57a5f1d2411367ff177e058702894c 100644 index b7b81cbdb36b0041177e012cb932d4267638d9c9..803b75e88e96d4bdcde002fde4000d136d6f07e5 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -28,6 +28,7 @@ public class PalettedContainer<T> implements PaletteResize<T> { @@ -33,6 +33,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
private final Function<CompoundTag, T> reader; return 0;
private final Function<T, CompoundTag> writer; };
private final T defaultValue; public final IdMap<T> registry;
+ private final T[] presetValues; // Paper - Anti-Xray - Add preset values + private final T[] presetValues; // Paper - Anti-Xray - Add preset values
protected BitStorage storage; private volatile PalettedContainer.Data<T> data;
private Palette<T> palette; private final PalettedContainer.Strategy strategy;
private int bits; private final Semaphore lock = new Semaphore(1);
@@ -48,14 +49,46 @@ public class PalettedContainer<T> implements PaletteResize<T> { @@ -63,14 +64,47 @@ public class PalettedContainer<T> implements PaletteResize<T> {
this.lock.release(); });
} }
- public PalettedContainer(Palette<T> fallbackPalette, IdMapper<T> idList, Function<CompoundTag, T> elementDeserializer, Function<T, CompoundTag> elementSerializer, T defaultElement) { - public PalettedContainer(IdMap<T> idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Configuration<T> dataProvider, BitStorage storage, List<T> list) {
+ // Paper start - Anti-Xray - Add preset values + // Paper start - Anti-Xray - Add preset values
+ @Deprecated public PalettedContainer(Palette<T> fallbackPalette, IdMapper<T> idList, Function<CompoundTag, T> elementDeserializer, Function<T, CompoundTag> elementSerializer, T defaultElement) { // Notice for updates: Please make sure this constructor isn't used anywhere + @Deprecated public PalettedContainer(IdMap<T> idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Configuration<T> dataProvider, BitStorage storage, List<T> list) { // Notice for updates: Please make sure this constructor isn't used anywhere
+ this(fallbackPalette, idList, elementDeserializer, elementSerializer, defaultElement, null, true); + this(idList, paletteProvider, dataProvider, storage, list, null, true);
+ } + }
+ public PalettedContainer(Palette<T> fallbackPalette, IdMapper<T> idList, Function<CompoundTag, T> elementDeserializer, Function<T, CompoundTag> elementSerializer, T defaultElement, T[] presetValues, boolean initialize) { + public PalettedContainer(IdMap<T> idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Configuration<T> dataProvider, BitStorage storage, List<T> list, T[] presetValues, boolean initialize) {
+ // Paper end + // Paper end
this.globalPalette = fallbackPalette;
this.registry = idList; this.registry = idList;
this.reader = elementDeserializer; this.strategy = paletteProvider;
this.writer = elementSerializer; Palette<T> datapalette = dataProvider.factory().create(dataProvider.bits(), idList, this, list);
this.defaultValue = defaultElement;
- this.setBits(4); this.data = new PalettedContainer.Data(dataProvider, storage, datapalette);
+ // Paper start - Anti-Xray - Add preset values + // Paper start - Anti-Xray - Add preset values
+ this.presetValues = presetValues; + this.presetValues = presetValues;
+ +
+ if (initialize) { + if(initialize) {
+ if (presetValues == null) { + if(presetValues == null) {
+ // Default + // Default
+ this.setBits(4); + this.setBits(4);
+ } else { + } else {
@ -1315,8 +1256,8 @@ index bb8fd88aebb550edec8c679622a02a595cbc6694..ac51089aae57a5f1d2411367ff177e05
+ } + }
+ } + }
+ // Paper end + // Paper end
+ } }
+
+ // Paper start - Anti-Xray - Add preset values + // Paper start - Anti-Xray - Add preset values
+ private void addPresetValues() { + private void addPresetValues() {
+ if (this.presetValues != null && this.palette != this.globalPalette) { + if (this.presetValues != null && this.palette != this.globalPalette) {
@ -1324,23 +1265,24 @@ index bb8fd88aebb550edec8c679622a02a595cbc6694..ac51089aae57a5f1d2411367ff177e05
+ this.palette.idFor(presetValue); + this.palette.idFor(presetValue);
+ } + }
+ } + }
} + }
+ // Paper end + // Paper end
+
private static int getIndex(int x, int y, int z) { public PalettedContainer(IdMap<T> idList, T object, PalettedContainer.Strategy paletteProvider) {
return y << 8 | z << 4 | x; this.strategy = paletteProvider;
@@ -84,6 +117,7 @@ public class PalettedContainer<T> implements PaletteResize<T> { this.registry = idList;
BitStorage bitStorage = this.storage; @@ -88,6 +122,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
Palette<T> palette = this.palette; public int onResize(int newBits, T object) {
this.setBits(newSize); PalettedContainer.Data<T> datapaletteblock_c = this.data;
PalettedContainer.Data<T> datapaletteblock_c1 = this.createOrReuseData(datapaletteblock_c, newBits);
+ this.addPresetValues(); // Paper - Anti-Xray - Add preset values + this.addPresetValues(); // Paper - Anti-Xray - Add preset values
for(int i = 0; i < bitStorage.getSize(); ++i) { datapaletteblock_c1.copyFrom(datapaletteblock_c.palette, datapaletteblock_c.storage);
T object = palette.valueFor(bitStorage.get(i)); this.data = datapaletteblock_c1;
@@ -153,17 +187,38 @@ public class PalettedContainer<T> implements PaletteResize<T> { @@ -168,17 +203,26 @@ public class PalettedContainer<T> implements PaletteResize<T> {
datapaletteblock_c.palette.read(buf);
this.palette.read(buf); buf.readLongArray(datapaletteblock_c.storage.getRaw());
buf.readLongArray(this.storage.getRaw()); this.data = datapaletteblock_c;
+ // Paper start - Anti-Xray - Add preset values + // Paper start - Anti-Xray - Add preset values
+ // If there are many preset values this may require several resize operations + // If there are many preset values this may require several resize operations
+ // This can be avoided by calculating the required bits in advance, as it is done in #read(ListTag, long[]) + // This can be avoided by calculating the required bits in advance, as it is done in #read(ListTag, long[])
@ -1358,99 +1300,96 @@ index bb8fd88aebb550edec8c679622a02a595cbc6694..ac51089aae57a5f1d2411367ff177e05
+ @Deprecated public void write(FriendlyByteBuf buf) { write(buf, null, 0); } // Notice for updates: Please make sure this method isn't used anywhere + @Deprecated public void write(FriendlyByteBuf buf) { write(buf, null, 0); } // Notice for updates: Please make sure this method isn't used anywhere
+ public void write(FriendlyByteBuf buf, com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) { + public void write(FriendlyByteBuf buf, com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) {
+ // Paper end + // Paper end
this.acquire();
try { try {
this.acquire(); - this.data.write(buf);
buf.writeByte(this.bits); + this.data.write(buf, chunkPacketInfo, bottomBlockY);
} finally {
this.release();
}
@@ -188,6 +232,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
private static <T> DataResult<PalettedContainer<T>> read(IdMap<T> idList, PalettedContainer.Strategy provider, PalettedContainer.DiscData<T> serialized) {
List<T> list = serialized.paletteEntries();
int i = provider.size();
+ // TODO I think we need to inject the old code into the calculateBitsForSerialization method
int j = provider.calculateBitsForSerialization(idList, list.size());
PalettedContainer.Configuration<T> datapaletteblock_a = provider.getConfiguration(idList, j);
Object object;
@@ -224,7 +269,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
}
}
- return DataResult.success(new PalettedContainer<>(idList, provider, datapaletteblock_a, (BitStorage) object, list));
+ return DataResult.success(new PalettedContainer<>(idList, provider, datapaletteblock_a, (BitStorage) object, list, this.presetValues, true));
}
private PalettedContainer.DiscData<T> write(IdMap<T> idList, PalettedContainer.Strategy provider) {
@@ -450,9 +495,22 @@ public class PalettedContainer<T> implements PaletteResize<T> {
return 1 + this.palette.getSerializedSize() + FriendlyByteBuf.getVarIntSize(this.storage.getSize()) + this.storage.getRaw().length * 8;
}
- public void write(FriendlyByteBuf buf) {
+ // Paper start - Anti-Xray - Add chunk packet info
+ @Deprecated public void write(FriendlyByteBuf buf) { this.write(buf, null, 0);} // Notice for updates: Please make sure this method isn't used anywhere - it is used for biomes now
+ public void write(FriendlyByteBuf buf, com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) {
+ // Paper end
buf.writeByte(this.storage.getBits());
this.palette.write(buf); this.palette.write(buf);
+
+ // Paper start - Anti-Xray - Add chunk packet info + // Paper start - Anti-Xray - Add chunk packet info
+ if (chunkPacketInfo != null) { + if (chunkPacketInfo != null) {
+ // Bottom block to 0 based chunk section index + // Bottom block to 0 based chunk section index
+ int chunkSectionIndex = (bottomBlockY >> 4) - chunkPacketInfo.getChunk().getMinSection(); + int chunkSectionIndex = (bottomBlockY >> 4) - chunkPacketInfo.getChunk().getMinSection();
+ chunkPacketInfo.setBits(chunkSectionIndex, this.bits); + chunkPacketInfo.setBits(chunkSectionIndex, this.storage.getBits());
+ chunkPacketInfo.setPalette(chunkSectionIndex, this.palette); + chunkPacketInfo.setPalette(chunkSectionIndex, this.palette);
+ chunkPacketInfo.setIndex(chunkSectionIndex, buf.writerIndex() + FriendlyByteBuf.getVarIntSize(this.storage.getRaw().length)); + chunkPacketInfo.setIndex(chunkSectionIndex, buf.writerIndex() + FriendlyByteBuf.getVarIntSize(this.storage.getRaw().length));
+ chunkPacketInfo.setPresetValues(chunkSectionIndex, this.presetValues); + chunkPacketInfo.setPresetValues(chunkSectionIndex, this.presetValues); // TODO where do we get this from?
+ } + }
+ // Paper end + // Paper end
+
buf.writeLongArray(this.storage.getRaw()); buf.writeLongArray(this.storage.getRaw());
} finally { }
this.release();
@@ -174,12 +229,14 @@ public class PalettedContainer<T> implements PaletteResize<T> {
public void read(ListTag paletteNbt, long[] data) {
try {
this.acquire();
- int i = Math.max(4, Mth.ceillog2(paletteNbt.size()));
- if (i != this.bits) {
+ // Paper - Anti-Xray - TODO: Should this.presetValues.length just be added here (faster) or should the contents be compared to calculate the size (less RAM)?
+ int i = Math.max(4, Mth.ceillog2(paletteNbt.size() + (this.presetValues == null ? 0 : this.presetValues.length))); // Paper - Anti-Xray - Calculate the size with preset values
+ if (true || i != this.bits) { // Paper - Anti-Xray - Not initialized yet
this.setBits(i);
}
this.palette.read(paletteNbt); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+ this.addPresetValues(); // Paper - Anti-Xray - Add preset values index 8d1cbefc82f64a120eeea8c6bdd6361ffa513099..e8cb57d79c73f115679ddc2e6f579b5e1b5e482b 100644
int j = data.length * 64 / 4096; --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
if (this.palette == this.globalPalette) { +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
Palette<T> palette = new HashMapPalette<>(this.registry, i, this.dummyPaletteResize, this.reader, this.writer); @@ -2204,7 +2204,7 @@ public final class CraftServer implements Server {
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 public ChunkGenerator.ChunkData createChunkData(World world) {
index 670e4f65680ca36fba1c84cb334c470ea8fa9b60..79f2b3942a3ccccd8fe8719db12de458212e8659 100644 Validate.notNull(world, "World cannot be null");
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java ServerLevel handle = ((CraftWorld) world).getHandle();
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java - return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY));
@@ -134,7 +134,7 @@ public class ChunkSerializer { + return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY). world); // Paper - anti xray - add parameters
byte b0 = nbttagcompound2.getByte("Y"); }
if (nbttagcompound2.contains("Palette", 9) && nbttagcompound2.contains("BlockStates", 12)) { @Override
- LevelChunkSection chunksection = new LevelChunkSection(b0);
+ LevelChunkSection chunksection = new LevelChunkSection(b0, null, world, false); // Paper - Anti-Xray - Add parameters and don't initialize because it's done in the line below internally
chunksection.getStates().read(nbttagcompound2.getList("Palette", 10), nbttagcompound2.getLongArray("BlockStates"));
chunksection.recalcBlockCounts();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index 7467de2da7cbe79df49d9bd95df1891810a1431b..46136c5daa1b4ea9103c736cc4b035195177368e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -51,7 +51,7 @@ public class CraftChunk implements Chunk {
private final ServerLevel worldServer;
private final int x;
private final int z;
- private static final PalettedContainer<net.minecraft.world.level.block.state.BlockState> emptyBlockIDs = new LevelChunkSection(0).getStates();
+ private static final PalettedContainer<net.minecraft.world.level.block.state.BlockState> emptyBlockIDs = new LevelChunkSection(0, null, null, true).getStates(); // Paper - Anti-Xray - Add parameters
private static final byte[] emptyLight = new byte[2048];
public CraftChunk(net.minecraft.world.level.chunk.LevelChunk chunk) {
@@ -332,7 +332,7 @@ public class CraftChunk implements Chunk {
CompoundTag data = new CompoundTag();
cs[i].getStates().write(data, "Palette", "BlockStates");
- PalettedContainer blockids = new PalettedContainer<>(LevelChunkSection.GLOBAL_BLOCKSTATE_PALETTE, net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, NbtUtils::readBlockState, NbtUtils::writeBlockState, Blocks.AIR.defaultBlockState()); // TODO: snapshot whole ChunkSection
+ PalettedContainer blockids = new PalettedContainer<>(LevelChunkSection.GLOBAL_BLOCKSTATE_PALETTE, net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, NbtUtils::readBlockState, NbtUtils::writeBlockState, Blocks.AIR.defaultBlockState(), null, false); // TODO: snapshot whole ChunkSection // Paper - Anti-Xray - Add no preset block states and don't initialize because it's done in the line below internally
blockids.read(data.getList("Palette", CraftMagicNumbers.NBT.TAG_COMPOUND), data.getLongArray("BlockStates"));
sectionBlockIDs[i] = blockids;
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java diff --git a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
index 7bfd803d11976dba9ace79edc76bb083a2eccf38..a48c659c02c6c33a8efdac6daf9c9a0708f05071 100644 index 960405935e395a31c0300773c41413801cf0d290..7acf5e6e7e038895d49a0d01d319eb7c8ba809bf 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java --- a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
@@ -25,9 +25,11 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData { @@ -27,8 +27,13 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
private final LevelChunkSection[] sections; private final Registry<net.minecraft.world.level.biome.Biome> biomes;
private Set<BlockPos> tiles; private Set<BlockPos> tiles;
private final Set<BlockPos> lights = new HashSet<>(); private final Set<BlockPos> lights = new HashSet<>();
+ private World world; // Paper - Anti-Xray - Add parameters + private World world; // Paper - Anti-Xray - Add parameters
public OldCraftChunkData(World world) { - public OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes) {
this(world.getMinHeight(), world.getMaxHeight()); +// Paper start - Anti-Xray - Add parameters
+ this.world = world; // Paper - Anti-Xray - Add parameters + @Deprecated OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes) { this(minHeight, maxHeight, biomes, null); } // Only used in tests
} + public OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes, World world) {
+ this.world = world;
/* pp for tests */ OldCraftChunkData(int minHeight, int maxHeight) { + // Paper end
@@ -177,7 +179,7 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData { this.minHeight = minHeight;
this.maxHeight = maxHeight;
this.biomes = biomes;
@@ -176,7 +181,11 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
int offset = (y - this.minHeight) >> 4; int offset = (y - this.minHeight) >> 4;
LevelChunkSection section = this.sections[offset]; LevelChunkSection section = this.sections[offset];
if (create && section == null) { if (create && section == null) {
- this.sections[offset] = section = new LevelChunkSection(offset + (this.minHeight >> 4)); +<<<<<<< HEAD
+ this.sections[offset] = section = new LevelChunkSection(offset + (this.minHeight >> 4), null, world instanceof org.bukkit.craftbukkit.CraftWorld ? ((org.bukkit.craftbukkit.CraftWorld) this.world).getHandle() : null, true); // Paper - Anti-Xray - Add parameters 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, world instanceof org.bukkit.craftbukkit.CraftWorld ? ((org.bukkit.craftbukkit.CraftWorld) this.world).getHandle() : null, true); // Paper - Anti-Xray - Add parameters
+>>>>>>> Anti-Xray
} }
return section; return section;
} }

View file

@ -5,10 +5,10 @@ Subject: [PATCH] PlayerDeathEvent#shouldDropExperience
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 3e3582742792858c2b8328676faed68ddb6da674..363d86e4a35b87c3fabf7a0e4b6d9e6c2caaf3de 100644 index ea73914ec8fb877de3f34cf7d5a0d60d547733fe..b193f8dfbe7b61c919ad5eb452d29885982e25e4 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -846,7 +846,7 @@ public class ServerPlayer extends Player { @@ -884,7 +884,7 @@ public class ServerPlayer extends Player {
this.tellNeutralMobsThatIDied(); this.tellNeutralMobsThatIDied();
} }
// SPIGOT-5478 must be called manually now // SPIGOT-5478 must be called manually now

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Prevent bees loading chunks checking hive position
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
index c5317683e6e78f2956637a6ca5fb9a477e85ed03..47be3e33f89bdd633aba381c8c3052cfebf64d48 100644 index 4d335a725506cbf54604ea3e76ca39ef0f3ca013..d5d61129d72f061ef1e45d39778072ee1e51fc2d 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java --- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java +++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
@@ -495,6 +495,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { @@ -497,6 +497,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
if (!this.hasHive()) { if (!this.hasHive()) {
return false; return false;
} else { } else {

View file

@ -6,39 +6,36 @@ Subject: [PATCH] Guard against serializing mismatching chunk coordinate
Should help if something dumb happens Should help if something dumb happens
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 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 83fa00de1a7cb690c763cec9c8d4b3fcd44e7c74..670e4f65680ca36fba1c84cb334c470ea8fa9b60 100644 index 992a7d6c4372942711a1381ac08ee13910a62cb0..37855d2183212cb043b30418740c0fd047dbc07f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
@@ -67,6 +67,13 @@ public class ChunkSerializer { @@ -75,6 +75,12 @@ public class ChunkSerializer {
public ChunkSerializer() {} public ChunkSerializer() {}
+ // Paper start - guard against serializing mismatching coordinates + // Paper start - guard against serializing mismatching coordinates
+ // TODO Note: This needs to be re-checked each update + // TODO Note: This needs to be re-checked each update
+ public static ChunkPos getChunkCoordinate(CompoundTag chunkData) { + public static ChunkPos getChunkCoordinate(CompoundTag chunkData) {
+ CompoundTag levelData = chunkData.getCompound("Level"); + return new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos"));
+ return new ChunkPos(levelData.getInt("xPos"), levelData.getInt("zPos"));
+ } + }
+ // Paper end + // Paper end
// Paper start // Paper start
public static final class InProgressChunkHolder { public static final class InProgressChunkHolder {
@@ -93,8 +100,8 @@ public class ChunkSerializer { @@ -100,7 +106,7 @@ public class ChunkSerializer {
public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) {
java.util.ArrayDeque<Runnable> tasksToExecuteOnMain = new java.util.ArrayDeque<>();
// Paper end // Paper end
ChunkGenerator chunkgenerator = world.getChunkSource().getGenerator(); - ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos"));
BiomeSource worldchunkmanager = chunkgenerator.getBiomeSource(); + ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate
- CompoundTag nbttagcompound1 = nbt.getCompound("Level");
- ChunkPos chunkcoordintpair1 = new ChunkPos(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
+ CompoundTag nbttagcompound1 = nbt.getCompound("Level"); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate
+ ChunkPos chunkcoordintpair1 = new ChunkPos(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate
if (!Objects.equals(pos, chunkcoordintpair1)) { if (!Objects.equals(chunkPos, chunkcoordintpair1)) {
ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", pos, pos, chunkcoordintpair1); ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", chunkPos, chunkPos, chunkcoordintpair1);
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
index 6f13c7adce7d4b3d170045ea5ef2a841d34ae7b0..176610b31f66b890afe61f4de46c412382bb8d22 100644 index 1fc202caf9051f12192ed479898b01b0a02eebbd..0631a5b1af38ace5ad167d1986271081bd2ee7a6 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
@@ -117,6 +117,13 @@ public class ChunkStorage implements AutoCloseable { @@ -132,6 +132,13 @@ public class ChunkStorage implements AutoCloseable {
// Paper start - async chunk io // Paper start - async chunk io
public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException { public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException {

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Optimise IEntityAccess#getPlayerByUUID
Use the world entity map instead of iterating over all players Use the world entity map instead of iterating over all players
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b3d54c90e87347cb7c709059c090371a40c7b047..fa5aa491c3ed6bf50b7f34c9f32a0b146e6c0aef 100644 index 53067edd56a4b7571f693c593c0f103567d589ec..3b43e64766e7b9e0444ebee12deee7f12fe5ddb8 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -370,6 +370,14 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -382,6 +382,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
public final com.destroystokyo.paper.io.chunk.ChunkTaskManager asyncChunkTaskManager; public final com.destroystokyo.paper.io.chunk.ChunkTaskManager asyncChunkTaskManager;
// Paper end // Paper end

View file

@ -15,10 +15,10 @@ This patch resolves the conflict by offsetting checking an item's
move method from Spigot's entity activation range check. move method from Spigot's entity activation range check.
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index 82ffe3624943d2e931e2cc2f85ede94f369bd06b..9ee1dc89dd4c6b9453e1f6f92208d454877d23c9 100644 index f3991a30f634122020ca6334bc6f2ca84e93ecac..1378c8ab35b3828f7c0ad504e64bb72484a1026d 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -135,7 +135,7 @@ public class ItemEntity extends Entity { @@ -134,7 +134,7 @@ public class ItemEntity extends Entity {
} }
} }

View file

@ -7,10 +7,10 @@ When the server is lagging, players will wait longer when eating.
Change to also use a time check instead if it passes. Change to also use a time check instead if it passes.
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 55ac5e8cad4c7eee3d8b165698200e9afcd44594..50d180daff7258795d476b9cd43412fba2fba50f 100644 index 077e5f4f787cdf4b8e7ba08dbc0c7bf04a6e5b93..8217a8e2c170aa78586ae0054a35fc9158f70bae 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3498,6 +3498,11 @@ public abstract class LivingEntity extends Entity { @@ -3501,6 +3501,11 @@ public abstract class LivingEntity extends Entity {
return ((Byte) this.entityData.get(LivingEntity.DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; return ((Byte) this.entityData.get(LivingEntity.DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
} }
@ -22,7 +22,7 @@ index 55ac5e8cad4c7eee3d8b165698200e9afcd44594..50d180daff7258795d476b9cd43412fb
private void updatingUsingItem() { private void updatingUsingItem() {
if (this.isUsingItem()) { if (this.isUsingItem()) {
if (ItemStack.isSameIgnoreDurability(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { if (ItemStack.isSameIgnoreDurability(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
@@ -3515,8 +3520,12 @@ public abstract class LivingEntity extends Entity { @@ -3518,8 +3523,12 @@ public abstract class LivingEntity extends Entity {
if (this.shouldTriggerItemUseEffects()) { if (this.shouldTriggerItemUseEffects()) {
this.triggerItemUseEffects(stack, 5); this.triggerItemUseEffects(stack, 5);
} }
@ -37,7 +37,7 @@ index 55ac5e8cad4c7eee3d8b165698200e9afcd44594..50d180daff7258795d476b9cd43412fb
this.completeUsingItem(); this.completeUsingItem();
} }
@@ -3562,7 +3571,10 @@ public abstract class LivingEntity extends Entity { @@ -3567,7 +3576,10 @@ public abstract class LivingEntity extends Entity {
if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag
this.useItem = itemstack; this.useItem = itemstack;
@ -48,8 +48,8 @@ index 55ac5e8cad4c7eee3d8b165698200e9afcd44594..50d180daff7258795d476b9cd43412fb
+ // Paper end + // Paper end
if (!this.level.isClientSide) { if (!this.level.isClientSide) {
this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(1, true);
this.setLivingEntityFlag(2, enumhand == InteractionHand.OFF_HAND); this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
@@ -3586,7 +3598,10 @@ public abstract class LivingEntity extends Entity { @@ -3591,7 +3603,10 @@ public abstract class LivingEntity extends Entity {
} }
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) { } else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
this.useItem = ItemStack.EMPTY; this.useItem = ItemStack.EMPTY;
@ -61,7 +61,7 @@ index 55ac5e8cad4c7eee3d8b165698200e9afcd44594..50d180daff7258795d476b9cd43412fb
} }
} }
@@ -3712,7 +3727,10 @@ public abstract class LivingEntity extends Entity { @@ -3717,7 +3732,10 @@ public abstract class LivingEntity extends Entity {
} }
this.useItem = ItemStack.EMPTY; this.useItem = ItemStack.EMPTY;

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Optimize call to getFluid for explosions
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 35ea80a18234d8125397edb5bab9e86ea526d3ca..a861b4b55862b1c5583101fe7f28a3a43c547468 100644 index 32c8403d6a5f5fbd52679b12b07936147744b8a4..548f103e648d9670d7434182c6598dc29ae77b57 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java --- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -174,7 +174,7 @@ public class Explosion { @@ -173,7 +173,7 @@ public class Explosion {
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) { for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
BlockPos blockposition = new BlockPos(d4, d5, d6); BlockPos blockposition = new BlockPos(d4, d5, d6);
BlockState iblockdata = this.level.getBlockState(blockposition); BlockState iblockdata = this.level.getBlockState(blockposition);

View file

@ -9,10 +9,10 @@ dispensed. The resulting item would have size == 0 and therefore
be convertered to air, hence why the effects disappeared. be convertered to air, hence why the effects disappeared.
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
index 442845d1aa26cf888c88536c6a7db510807b2855..c5c8a889b745f36c2dce9dbb5d0b6edaefafdd22 100644 index ba28fdc1a7ed2bc9d55489a8aeb3f786d31c732e..89921ffeae7cc715aa18cbf8687e7c8e612e5612 100644
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
@@ -513,7 +513,7 @@ public interface DispenseItemBehavior { @@ -510,7 +510,7 @@ public interface DispenseItemBehavior {
} }
itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); itemstack1 = CraftItemStack.asNMSCopy(event.getItem());

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add effect to block break naturally
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 71b5ef18e6b0ef48834c125d9503f70359a2dfd0..5f9f35c25a6247b6cd1ba31888a0afb8cea31da2 100644 index 0408a72e801178375426edf3e1c1880774ca5478..00056d5b3426df121242de2ae01fca492d20089a 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -465,6 +465,18 @@ public class CraftBlock implements Block { @@ -468,6 +468,18 @@ public class CraftBlock implements Block {
@Override @Override
public boolean breakNaturally(ItemStack item) { public boolean breakNaturally(ItemStack item) {
@ -27,7 +27,7 @@ index 71b5ef18e6b0ef48834c125d9503f70359a2dfd0..5f9f35c25a6247b6cd1ba31888a0afb8
// Order matters here, need to drop before setting to air so skulls can get their data // Order matters here, need to drop before setting to air so skulls can get their data
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS(); net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
net.minecraft.world.level.block.Block block = iblockdata.getBlock(); net.minecraft.world.level.block.Block block = iblockdata.getBlock();
@@ -474,6 +486,7 @@ public class CraftBlock implements Block { @@ -477,6 +489,7 @@ public class CraftBlock implements Block {
// Modelled off EntityHuman#hasBlock // Modelled off EntityHuman#hasBlock
if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) { if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) {
net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), position, this.world.getBlockEntity(position), null, nmsItem); net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), position, this.world.getBlockEntity(position), null, nmsItem);

View file

@ -14,7 +14,7 @@ Adds flying monsters to control ghast and phantoms
Adds villagers as separate config Adds villagers as separate config
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 6fb49058cd958a394870dc527342be4cd94135c9..4c45110320004eb1c6f8c73d5c67880110e6ef08 100644 index 3b43e64766e7b9e0444ebee12deee7f12fe5ddb8..09deaa9badf53bdc1292796c643751d8d92ac585 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2,7 +2,6 @@ package net.minecraft.server.level; @@ -2,7 +2,6 @@ package net.minecraft.server.level;
@ -33,15 +33,7 @@ index 6fb49058cd958a394870dc527342be4cd94135c9..4c45110320004eb1c6f8c73d5c678801
import it.unimi.dsi.fastutil.objects.ObjectIterator; import it.unimi.dsi.fastutil.objects.ObjectIterator;
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
@@ -122,7 +120,6 @@ import net.minecraft.world.level.chunk.LevelChunkSection; @@ -964,17 +962,17 @@ public class ServerLevel extends Level implements WorldGenLevel {
import net.minecraft.world.level.chunk.storage.EntityStorage;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.end.EndDragonFight;
-import net.minecraft.world.level.entity.EntityAccess;
import net.minecraft.world.level.entity.EntityPersistentStorage;
import net.minecraft.world.level.entity.EntityTickList;
import net.minecraft.world.level.entity.EntityTypeTest;
@@ -943,17 +940,17 @@ public class ServerLevel extends Level implements WorldGenLevel {
++TimingHistory.entityTicks; // Paper - timings ++TimingHistory.entityTicks; // Paper - timings
// Spigot start // Spigot start
co.aikar.timings.Timing timer; // Paper co.aikar.timings.Timing timer; // Paper
@ -63,7 +55,7 @@ index 6fb49058cd958a394870dc527342be4cd94135c9..4c45110320004eb1c6f8c73d5c678801
try { try {
// Paper end - timings // Paper end - timings
entity.setOldPosAndRot(); entity.setOldPosAndRot();
@@ -964,9 +961,13 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -985,9 +983,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
return Registry.ENTITY_TYPE.getKey(entity.getType()).toString(); return Registry.ENTITY_TYPE.getKey(entity.getType()).toString();
}); });
gameprofilerfiller.incrementCounter("tickNonPassenger"); gameprofilerfiller.incrementCounter("tickNonPassenger");
@ -77,7 +69,7 @@ index 6fb49058cd958a394870dc527342be4cd94135c9..4c45110320004eb1c6f8c73d5c678801
Iterator iterator = entity.getPassengers().iterator(); Iterator iterator = entity.getPassengers().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@@ -974,13 +975,18 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -995,13 +997,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.tickPassenger(entity, entity1); this.tickPassenger(entity, entity1);
} }
@ -97,7 +89,7 @@ index 6fb49058cd958a394870dc527342be4cd94135c9..4c45110320004eb1c6f8c73d5c678801
passenger.setOldPosAndRot(); passenger.setOldPosAndRot();
++passenger.tickCount; ++passenger.tickCount;
ProfilerFiller gameprofilerfiller = this.getProfiler(); ProfilerFiller gameprofilerfiller = this.getProfiler();
@@ -989,8 +995,17 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1010,8 +1017,17 @@ public class ServerLevel extends Level implements WorldGenLevel {
return Registry.ENTITY_TYPE.getKey(passenger.getType()).toString(); return Registry.ENTITY_TYPE.getKey(passenger.getType()).toString();
}); });
gameprofilerfiller.incrementCounter("tickPassenger"); gameprofilerfiller.incrementCounter("tickPassenger");
@ -115,7 +107,7 @@ index 6fb49058cd958a394870dc527342be4cd94135c9..4c45110320004eb1c6f8c73d5c678801
gameprofilerfiller.pop(); gameprofilerfiller.pop();
Iterator iterator = passenger.getPassengers().iterator(); Iterator iterator = passenger.getPassengers().iterator();
@@ -1000,6 +1015,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1021,6 +1037,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.tickPassenger(passenger, entity2); this.tickPassenger(passenger, entity2);
} }
@ -124,10 +116,10 @@ index 6fb49058cd958a394870dc527342be4cd94135c9..4c45110320004eb1c6f8c73d5c678801
} else { } else {
passenger.stopRiding(); passenger.stopRiding();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 8e30a0d42d422fea6bda77d16d5eae8bab01224d..3268187f77b78a04191628b06dc7693b08b8d642 100644 index d9feae255354f5577b5fa2b202f33bbc7e645867..d789a9068353c8e7be774c275d4d099283bf826c 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -327,6 +327,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n @@ -331,6 +331,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this); public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState; public final boolean defaultActivationState;
public long activatedTick = Integer.MIN_VALUE; public long activatedTick = Integer.MIN_VALUE;
@ -136,7 +128,7 @@ index 8e30a0d42d422fea6bda77d16d5eae8bab01224d..3268187f77b78a04191628b06dc7693b
public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one
protected int numCollisions = 0; // Paper protected int numCollisions = 0; // Paper
public void inactiveTick() { } public void inactiveTick() { }
@@ -773,6 +775,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n @@ -779,6 +781,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
} else { } else {
this.wasOnFire = this.isOnFire(); this.wasOnFire = this.isOnFire();
if (movementType == MoverType.PISTON) { if (movementType == MoverType.PISTON) {
@ -145,7 +137,7 @@ index 8e30a0d42d422fea6bda77d16d5eae8bab01224d..3268187f77b78a04191628b06dc7693b
movement = this.limitPistonMovement(movement); movement = this.limitPistonMovement(movement);
if (movement.equals(Vec3.ZERO)) { if (movement.equals(Vec3.ZERO)) {
return; return;
@@ -785,6 +789,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n @@ -791,6 +795,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
this.stuckSpeedMultiplier = Vec3.ZERO; this.stuckSpeedMultiplier = Vec3.ZERO;
this.setDeltaMovement(Vec3.ZERO); this.setDeltaMovement(Vec3.ZERO);
} }
@ -160,10 +152,10 @@ index 8e30a0d42d422fea6bda77d16d5eae8bab01224d..3268187f77b78a04191628b06dc7693b
movement = this.maybeBackOffFromEdge(movement, movementType); movement = this.maybeBackOffFromEdge(movement, movementType);
Vec3 vec3d1 = this.collide(movement); Vec3 vec3d1 = this.collide(movement);
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 6e5682fed08a41c7e573e6611fca93bf85019b9f..976dbf40292b10364f9e80bebe96ec9c4dfb657e 100644 index ad2ef9460d85b2182f6af35733daadcedbd15e4c..63b0044a86e6830ccf9d6da8e29989de1402dff4 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -203,6 +203,19 @@ public abstract class Mob extends LivingEntity { @@ -206,6 +206,19 @@ public abstract class Mob extends LivingEntity {
return this.lookControl; return this.lookControl;
} }
@ -184,22 +176,22 @@ index 6e5682fed08a41c7e573e6611fca93bf85019b9f..976dbf40292b10364f9e80bebe96ec9c
if (this.isPassenger() && this.getVehicle() instanceof Mob) { if (this.isPassenger() && this.getVehicle() instanceof Mob) {
Mob entityinsentient = (Mob) this.getVehicle(); Mob entityinsentient = (Mob) this.getVehicle();
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
index 920ae9af8985705a0ada7da5b7085a1ed8ca7f27..7c82d453388a27b69207d051dec316fc14715e2b 100644 index ff458abb221daaddaa734811eaaa35ea43883343..d1ab31d03ae421e628448fe2492ff138dc57c00f 100644
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java --- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java +++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
@@ -13,6 +13,7 @@ import org.bukkit.event.entity.EntityUnleashEvent; @@ -19,6 +19,7 @@ public abstract class PathfinderMob extends Mob {
public abstract class PathfinderMob extends Mob { }
public org.bukkit.craftbukkit.entity.CraftCreature getBukkitCreature() { return (org.bukkit.craftbukkit.entity.CraftCreature) super.getBukkitEntity(); } // Paper public org.bukkit.craftbukkit.entity.CraftCreature getBukkitCreature() { return (org.bukkit.craftbukkit.entity.CraftCreature) super.getBukkitEntity(); } // Paper
+ public BlockPos movingTarget = null; public BlockPos getMovingTarget() { return movingTarget; } // Paper + public BlockPos movingTarget = null; public BlockPos getMovingTarget() { return movingTarget; } // Paper
protected PathfinderMob(EntityType<? extends PathfinderMob> type, Level world) { public float getWalkTargetValue(BlockPos pos) {
super(type, world); return this.getWalkTargetValue(pos, this.level);
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
index dc7da3b806d1c759958d7c51b05efbc4b6c42653..69bf112655615337e0df3ea56b9e42fa5ff70430 100644 index 30bf98ad7fad6c6fdc8bc48e9f4caa0443cdb31c..2bb32378b19a21c94ff3ec8ed32fc9d6f0ad0fdb 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
@@ -31,6 +31,7 @@ public class GoalSelector { @@ -33,6 +33,7 @@ public class GoalSelector {
private final EnumSet<Goal.Flag> disabledFlags = EnumSet.noneOf(Goal.Flag.class); private final EnumSet<Goal.Flag> disabledFlags = EnumSet.noneOf(Goal.Flag.class);
private int tickCount; private int tickCount;
private int newGoalRate = 3; private int newGoalRate = 3;
@ -207,7 +199,7 @@ index dc7da3b806d1c759958d7c51b05efbc4b6c42653..69bf112655615337e0df3ea56b9e42fa
public GoalSelector(Supplier<ProfilerFiller> profiler) { public GoalSelector(Supplier<ProfilerFiller> profiler) {
this.profiler = profiler; this.profiler = profiler;
@@ -45,6 +46,20 @@ public class GoalSelector { @@ -47,6 +48,20 @@ public class GoalSelector {
this.availableGoals.clear(); this.availableGoals.clear();
} }
@ -229,7 +221,7 @@ index dc7da3b806d1c759958d7c51b05efbc4b6c42653..69bf112655615337e0df3ea56b9e42fa
this.availableGoals.stream().filter((wrappedGoal) -> { this.availableGoals.stream().filter((wrappedGoal) -> {
return wrappedGoal.getGoal() == goal; return wrappedGoal.getGoal() == goal;
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
index 27ea9c10b7f66c2133b0829c0b1c37143dd80b56..c28ade67f6a59146064a57bf016a646197f47ac4 100644 index 8d8cce87acc5a93afb4b8925a5a5dbf71d371fcd..7fc40bb5fb6265b283c7c611f63aae76302c0eaf 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java --- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
@@ -14,7 +14,7 @@ public abstract class MoveToBlockGoal extends Goal { @@ -14,7 +14,7 @@ public abstract class MoveToBlockGoal extends Goal {
@ -255,7 +247,7 @@ index 27ea9c10b7f66c2133b0829c0b1c37143dd80b56..c28ade67f6a59146064a57bf016a6461
public MoveToBlockGoal(PathfinderMob mob, double speed, int range, int maxYDifference) { public MoveToBlockGoal(PathfinderMob mob, double speed, int range, int maxYDifference) {
this.mob = mob; this.mob = mob;
@@ -109,6 +116,7 @@ public abstract class MoveToBlockGoal extends Goal { @@ -114,6 +121,7 @@ public abstract class MoveToBlockGoal extends Goal {
mutableBlockPos.setWithOffset(blockPos, m, k - 1, n); mutableBlockPos.setWithOffset(blockPos, m, k - 1, n);
if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level, mutableBlockPos)) { if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level, mutableBlockPos)) {
this.blockPos = mutableBlockPos; this.blockPos = mutableBlockPos;
@ -264,10 +256,10 @@ index 27ea9c10b7f66c2133b0829c0b1c37143dd80b56..c28ade67f6a59146064a57bf016a6461
} }
} }
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index 206aee8bf14ffc4ddbb8a7001bc3baae6a2ea849..64d5ddb8ce06e17e1a4dee284ba4c6ecfcdae11e 100644 index 55e4e7fcefc60e66239035e72ad44e0c796bf300..785fcb94d707b6790ef2191f7c9db77d253e9c6d 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -227,17 +227,29 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @@ -223,17 +223,29 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@Override @Override
public void inactiveTick() { public void inactiveTick() {
// SPIGOT-3874, SPIGOT-3894, SPIGOT-3846, SPIGOT-5286 :( // SPIGOT-3874, SPIGOT-3894, SPIGOT-3846, SPIGOT-5286 :(
@ -296,12 +288,12 @@ index 206aee8bf14ffc4ddbb8a7001bc3baae6a2ea849..64d5ddb8ce06e17e1a4dee284ba4c6ec
+ protected void customServerAiStep() { mobTick(false); } + protected void customServerAiStep() { mobTick(false); }
+ protected void mobTick(boolean inactive) { + protected void mobTick(boolean inactive) {
this.level.getProfiler().push("villagerBrain"); this.level.getProfiler().push("villagerBrain");
- this.getBrain().tick((ServerLevel) this.level, this); // CraftBukkit - decompile error - this.getBrain().tick((ServerLevel) this.level, this);
+ if (!inactive) this.getBrain().tick((ServerLevel) this.level, this); // CraftBukkit - decompile error // Paper + if (!inactive) this.getBrain().tick((ServerLevel) this.level, this); // Paper
this.level.getProfiler().pop(); this.level.getProfiler().pop();
if (this.assignProfessionWhenSpawned) { if (this.assignProfessionWhenSpawned) {
this.assignProfessionWhenSpawned = false; this.assignProfessionWhenSpawned = false;
@@ -261,7 +273,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @@ -257,7 +269,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
this.lastTradedPlayer = null; this.lastTradedPlayer = null;
} }
@ -310,7 +302,7 @@ index 206aee8bf14ffc4ddbb8a7001bc3baae6a2ea849..64d5ddb8ce06e17e1a4dee284ba4c6ec
Raid raid = ((ServerLevel) this.level).getRaidAt(this.blockPosition()); Raid raid = ((ServerLevel) this.level).getRaidAt(this.blockPosition());
if (raid != null && raid.isActive() && !raid.isOver()) { if (raid != null && raid.isActive() && !raid.isOver()) {
@@ -272,6 +284,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @@ -268,6 +280,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
if (this.getVillagerData().getProfession() == VillagerProfession.NONE && this.isTrading()) { if (this.getVillagerData().getProfession() == VillagerProfession.NONE && this.isTrading()) {
this.stopTrading(); this.stopTrading();
} }
@ -319,10 +311,10 @@ index 206aee8bf14ffc4ddbb8a7001bc3baae6a2ea849..64d5ddb8ce06e17e1a4dee284ba4c6ec
super.customServerAiStep(); super.customServerAiStep();
} }
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index f4163020d09b221625d9f49fddefe9544018cc17..13efcae91a863f9c7255472d1c45ce16be371c6d 100644 index faaa93e77523fbb942690491687410df48899ddb..de7abae207b0a565a25fa4ed2f66b94c6b0cdcf9 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -156,6 +156,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -157,6 +157,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public long ticksPerWaterAmbientSpawns; public long ticksPerWaterAmbientSpawns;
public long ticksPerWaterUndergroundCreatureSpawns; public long ticksPerWaterUndergroundCreatureSpawns;
public long ticksPerAmbientSpawns; public long ticksPerAmbientSpawns;
@ -336,7 +328,7 @@ index f4163020d09b221625d9f49fddefe9544018cc17..13efcae91a863f9c7255472d1c45ce16
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index 9b631698d1c736f61e07a5a1253127f4081dc90d..54020a3f2b18c4f42008f5d5f4541ef1a1efbcd7 100644 index 03b82d12325d54b9e5ac66b357d7995970c4cd4b..e2ea913f9e5ae2351f10e0ebedba89d2a6e62d96 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -140,6 +140,10 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -140,6 +140,10 @@ public class PistonMovingBlockEntity extends BlockEntity {
@ -698,10 +690,10 @@ index 84ce3d38d5decb4a2f9fae78e0ef5d715860dc7d..e0302f82356e8cba848aa8cec1e821e0
isActive = false; isActive = false;
} }
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 45be7d1821497f13ab0da3c4bbff7585238e902e..769a492305a3ce83e0da0b3de4ebd73859d1e1d9 100644 index ee8c84770b9b7fb9f3763e378f399da58f042b06..6d36aa5006d3adc3ff30d196bdfd287ad38a564a 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -180,13 +180,59 @@ public class SpigotWorldConfig @@ -193,13 +193,59 @@ public class SpigotWorldConfig
public int monsterActivationRange = 32; public int monsterActivationRange = 32;
public int raiderActivationRange = 48; public int raiderActivationRange = 48;
public int miscActivationRange = 16; public int miscActivationRange = 16;

View file

@ -14,10 +14,10 @@ light engine on shutdown...
The queue size only puts a cap on max loss, doesn't solve that problem. The queue size only puts a cap on max loss, doesn't solve that problem.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index e8746656ac12d3498e78cb603c14d4c31abbc023..ade858610c76be24576fe60d509e4a8f2531f442 100644 index 1dba00531e909214119219e928b2875676c00e75..7a97a4a395f20680bc3b028586c9a17b84783d99 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -523,5 +523,10 @@ public class PaperWorldConfig { @@ -513,5 +513,10 @@ public class PaperWorldConfig {
hoppersIgnoreOccludingBlocks = getBoolean("hopper.ignore-occluding-blocks", hoppersIgnoreOccludingBlocks); hoppersIgnoreOccludingBlocks = getBoolean("hopper.ignore-occluding-blocks", hoppersIgnoreOccludingBlocks);
log("Hopper Ignore Occluding Blocks: " + (hoppersIgnoreOccludingBlocks ? "enabled" : "disabled")); log("Hopper Ignore Occluding Blocks: " + (hoppersIgnoreOccludingBlocks ? "enabled" : "disabled"));
} }
@ -29,15 +29,15 @@ index e8746656ac12d3498e78cb603c14d4c31abbc023..ade858610c76be24576fe60d509e4a8f
} }
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index bf08c45525cd898ad12d70bec5de3762063af2e0..28066e92531d2d8834686f075169007e25caa73d 100644 index 4661d571cd4047c6b7d76de7ba0cb34ada348d63..758a972589b607447dc507c6c4f4b2a62f6a2832 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -845,7 +845,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -812,7 +812,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.executeModerately(); this.executeModerately();
// CraftBukkit end // CraftBukkit end
if (worldserver.getWorld().getKeepSpawnInMemory()) worldloadlistener.stop(); // Paper if (worldserver.getWorld().getKeepSpawnInMemory()) worldloadlistener.stop(); // Paper
- chunkproviderserver.getLightEngine().setTaskPerBatch(5); - chunkproviderserver.getLightEngine().setTaskPerBatch(5);
+ chunkproviderserver.getLightEngine().setTaskPerBatch(worldserver.paperConfig.lightQueueSize); // Paper - increase light queue size + chunkproviderserver.getLightEngine().setTaskPerBatch(worldserver.paperConfig.lightQueueSize); // Paper - increase light queue size
// CraftBukkit start // CraftBukkit start
// this.updateSpawnFlags(); // this.updateMobSpawningFlags();
worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals()); worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());

View file

@ -134,10 +134,10 @@ index 005361c38b02713fb823d0be40954400d59f0c4d..3091c100eaf5a86ba270ef0d96de1852
+ } + }
} }
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 20a9d213b977cf8d8ada3815931bb0603d5571c9..2e17c387ca132c5ec7312a4f008d93d2bc8f2138 100644 index 969401d1c4a506111ad212950bca42fdac59ad1f..f3f6fc973cd75a42594f1ec222c220e3894e11ee 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -128,6 +128,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -132,6 +132,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private final ChunkTaskPriorityQueueSorter queueSorter; private final ChunkTaskPriorityQueueSorter queueSorter;
private final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> worldgenMailbox; private final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> worldgenMailbox;
public final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> mainThreadMailbox; public final ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> mainThreadMailbox;
@ -150,7 +150,7 @@ index 20a9d213b977cf8d8ada3815931bb0603d5571c9..2e17c387ca132c5ec7312a4f008d93d2
public final ChunkProgressListener progressListener; public final ChunkProgressListener progressListener;
private final ChunkStatusUpdateListener chunkStatusListener; private final ChunkStatusUpdateListener chunkStatusListener;
public final ChunkMap.ChunkDistanceManager distanceManager; public final ChunkMap.ChunkDistanceManager distanceManager;
@@ -236,11 +242,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -240,11 +246,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.progressListener = worldGenerationProgressListener; this.progressListener = worldGenerationProgressListener;
this.chunkStatusListener = chunkStatusChangeListener; this.chunkStatusListener = chunkStatusChangeListener;