Refactor Anti-Xray and make some fixes to it (#5938)

This commit is contained in:
stonar96 2021-06-23 10:39:02 +02:00 committed by GitHub
parent b1f6e2698e
commit 4e2f0be270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 545 additions and 578 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Allow delegation to vanilla chunk gen
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 434a46dca55453815772eeb50ef412b02af2c0a1..ac7034a922facb772a67580100627a7c85510693 100644
index 30552c2dcb2b8e648ee6519478e830f3e86a10b9..17468c082e9d56193b0c7e5ae1713a1e8da8ad23 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2028,6 +2028,32 @@ public final class CraftServer implements Server {
@ -42,7 +42,7 @@ index 434a46dca55453815772eeb50ef412b02af2c0a1..ac7034a922facb772a67580100627a7c
public BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) {
return new CraftBossBar(title, color, style, flags);
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
index fe7851476636dfed02339d4d9f93824b96086769..24a2e88d083f90375c46cf948c7c89dccc6e4aa0 100644
index c4d5349f515d5c0ffad4db15ecca1431c830b824..4645303efa716442b14e5c1e767b0d94dbb50170 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
@@ -20,7 +20,7 @@ import org.bukkit.material.MaterialData;
@ -52,7 +52,7 @@ index fe7851476636dfed02339d4d9f93824b96086769..24a2e88d083f90375c46cf948c7c89dc
- private final LevelChunkSection[] sections;
+ private LevelChunkSection[] sections; // Paper - remove final
private Set<BlockPos> tiles;
private World world; // Paper - Anti-Xray - Add world
private World world; // Paper - Anti-Xray - Add parameters
@@ -173,6 +173,12 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
return this.sections;

View File

@ -13,7 +13,7 @@ contention situations.
And this is extremely a low contention situation.
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
index 4a6981f8bacdeca1069e1ddfe44ac9c4217ce624..f2307f81c399867585ffdefc0db835c6f5e2f42a 100644
index ac51089aae57a5f1d2411367ff177e058702894c..554474d4b2e57d8a005b3c3b9b23f32a62243058 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -37,16 +37,18 @@ public class PalettedContainer<T> implements PaletteResize<T> {
@ -35,8 +35,8 @@ index 4a6981f8bacdeca1069e1ddfe44ac9c4217ce624..f2307f81c399867585ffdefc0db835c6
+ //this.lock.release(); // Paper - disable this
}
// Paper start - Anti-Xray - Add predefined objects
@@ -133,7 +135,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
// Paper start - Anti-Xray - Add preset values
@@ -129,7 +131,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
return this.palette.idFor(objectAdded);
}
@ -45,7 +45,7 @@ index 4a6981f8bacdeca1069e1ddfe44ac9c4217ce624..f2307f81c399867585ffdefc0db835c6
Object var6;
try {
this.acquire();
@@ -157,7 +159,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
@@ -153,7 +155,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
return (T)(object == null ? this.defaultValue : object);
}
@ -54,7 +54,7 @@ index 4a6981f8bacdeca1069e1ddfe44ac9c4217ce624..f2307f81c399867585ffdefc0db835c6
try {
this.acquire();
this.set(getIndex(i, j, k), object);
@@ -181,7 +183,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
@@ -177,7 +179,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
return (T)(object == null ? this.defaultValue : object);
}
@ -64,15 +64,15 @@ index 4a6981f8bacdeca1069e1ddfe44ac9c4217ce624..f2307f81c399867585ffdefc0db835c6
this.acquire();
int i = buf.readByte();
@@ -201,7 +203,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
@Deprecated public void write(FriendlyByteBuf buf) {
write(buf, null, 0);
}
// Paper start - Anti-Xray - Add chunk packet info
@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 synchronized void write(FriendlyByteBuf buf, com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) { // Paper - synchronize
// Paper end
try {
this.acquire();
@@ -224,7 +226,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
@@ -226,7 +228,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
}
@ -80,8 +80,8 @@ index 4a6981f8bacdeca1069e1ddfe44ac9c4217ce624..f2307f81c399867585ffdefc0db835c6
+ public synchronized void read(ListTag paletteNbt, long[] data) { // Paper - synchronize
try {
this.acquire();
// Paper - Anti-Xray - TODO: Should this.predefinedObjects.length just be added here (faster) or should the contents be compared to calculate the size (less RAM)?
@@ -259,7 +261,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
// 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)?
@@ -261,7 +263,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
}