Switch to using ForgeFlower for Paper Only mc-dev imports

ForgeFlower is better than Spigots FernFlower at decompiling the source.

However, in order to maintain the CraftBukkit patches, we must keep
using spigots for the primary.

However, for any file that we import on top of Spigots imported files
there is nothing stopping us from using better decompiled files.

So these changes will use ForgeFlower to maintain a better set of
decomped files, so anything we add on top of Paper can start off
in a better spot.
This commit is contained in:
Aikar
2018-08-31 18:56:57 -04:00
parent bd4da1aea0
commit e82ef9ec05
74 changed files with 987 additions and 1045 deletions

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
index 19f4c61cd..3acb1ff9f 100644
index 19f4c61cdc..3acb1ff9fd 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@
@@ -49,7 +49,7 @@ index 19f4c61cd..3acb1ff9f 100644
}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java
new file mode 100644
index 000000000..1ba8477bf
index 0000000000..1ba8477bf9
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java
@@ -0,0 +0,0 @@
@@ -100,7 +100,7 @@ index 000000000..1ba8477bf
+}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
new file mode 100644
index 000000000..65d3e88c3
index 0000000000..65d3e88c3b
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
@@ -0,0 +0,0 @@
@@ -776,7 +776,7 @@ index 000000000..65d3e88c3
+}
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
index 000000000..41618994b
index 0000000000..41618994b4
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java
@@ -0,0 +0,0 @@
@@ -863,7 +863,7 @@ index 000000000..41618994b
+}
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
index 000000000..e255a45fa
index 0000000000..e255a45fa3
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java
@@ -0,0 +0,0 @@
@@ -898,7 +898,7 @@ index 000000000..e255a45fa
+}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java
new file mode 100644
index 000000000..cc586827a
index 0000000000..cc586827aa
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java
@@ -0,0 +0,0 @@
@@ -960,7 +960,7 @@ index 000000000..cc586827a
+}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java
new file mode 100644
index 000000000..37093419c
index 0000000000..37093419cf
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java
@@ -0,0 +0,0 @@
@@ -1049,7 +1049,7 @@ index 000000000..37093419c
+ }
+}
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 56c378341..f3d9211ba 100644
index 56c3783412..f3d9211baa 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
@@ -1071,7 +1071,7 @@ index 56c378341..f3d9211ba 100644
this.initLighting();
}
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 867b0db77..06968974c 100644
index 867b0db770..06968974c5 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
@@ -1093,7 +1093,7 @@ index 867b0db77..06968974c 100644
chunksection.getBlocks().a(nbttagcompound, "Palette", "BlockStates");
chunksection.a(new NibbleArray(nbttagcompound.getByteArray("BlockLight")));
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
index 233cbb6d6..8c116b74c 100644
index 7e4c79a1ce..bdfc7d81ff 100644
--- a/src/main/java/net/minecraft/server/ChunkSection.java
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
@@ -0,0 +0,0 @@ public class ChunkSection {
@@ -1108,13 +1108,13 @@ index 233cbb6d6..8c116b74c 100644
+
+ public ChunkSection(int i, boolean flag, IChunkAccess chunk, IWorldReader world, boolean initializeBlocks) { // Paper - Anti-Xray
this.yPos = i;
- this.blockIds = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // Paper - Decompile error
+ this.blockIds = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData(), world instanceof GeneratorAccess ? ((GeneratorAccess) world).getMinecraftWorld().chunkPacketBlockController.getPredefinedBlockData(world, chunk, this, flag, initializeBlocks) : null, initializeBlocks); // Paper - Decompile error // Paper - Anti-Xray - Add predefined block data
- this.blockIds = new DataPaletteBlock<IBlockData>(GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData());
+ this.blockIds = new DataPaletteBlock<IBlockData>(GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData(), world instanceof GeneratorAccess ? ((GeneratorAccess) world).getMinecraftWorld().chunkPacketBlockController.getPredefinedBlockData(world, chunk, this, flag, initializeBlocks) : null, initializeBlocks); // Paper - Anti-Xray - Add predefined block data
this.emittedLight = new NibbleArray();
if (flag) {
this.skyLight = new NibbleArray();
diff --git a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
index 95eb1a84a..34019bd1b 100644
index 95eb1a84ac..34019bd1b3 100644
--- a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
+++ b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
@@ -0,0 +0,0 @@ public class ChunkTaskScheduler extends Scheduler<ChunkCoordIntPair, ChunkStatus
@@ -1136,7 +1136,7 @@ index 95eb1a84a..34019bd1b 100644
}) : (Scheduler.a) this.progressCache.get(chunkcoordintpair.a());
}
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
index 575f9b558..5d2561a94 100644
index 6e7454b134..af4b41d976 100644
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
@@ -0,0 +0,0 @@
@@ -1155,21 +1155,20 @@ index 575f9b558..5d2561a94 100644
private DataPalette<T> h; private DataPalette<T> getDataPalette() { return this.h; } // Paper - OBFHELPER
private int i; private int getBitsPerObject() { return this.i; } // Paper - OBFHELPER
@@ -0,0 +0,0 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
this.j.unlock();
}
+ // Paper start - Anti-Xray - Support default constructor
public DataPaletteBlock(DataPalette<T> datapalette, RegistryBlockID<T> registryblockid, Function<NBTTagCompound, T> function, Function<T, NBTTagCompound> function1, T t0) {
+ this(datapalette, registryblockid, function, function1, t0, null, true);
public DataPaletteBlock(DataPalette<T> datapalette, RegistryBlockID<T> registryblockid, Function<NBTTagCompound, T> function, Function<T, NBTTagCompound> function1, T object) {
+ // Paper start - Anti-Xray - Support default constructor
+ this(datapalette, registryblockid, function, function1, object, null, true);
+ }
+ // Paper end
+
+ public DataPaletteBlock(DataPalette<T> datapalette, RegistryBlockID<T> registryblockid, Function<NBTTagCompound, T> function, Function<T, NBTTagCompound> function1, T t0, T[] predefinedObjects, boolean initialize) { // Paper - Anti-Xray - Add predefined objects
+ public DataPaletteBlock(DataPalette<T> datapalette, RegistryBlockID<T> registryblockid, Function<NBTTagCompound, T> function, Function<T, NBTTagCompound> function1, T object, T[] predefinedObjects, boolean initialize) {
+ // Paper end - Anti-Xray - Add predefined objects
this.b = datapalette;
this.d = registryblockid;
this.e = function;
this.f = function1;
this.g = t0;
this.g = (T)object;
- this.b(4);
+ // Paper start - Anti-Xray - Add predefined objects
+ this.predefinedObjects = predefinedObjects;
@@ -1199,7 +1198,7 @@ index 575f9b558..5d2561a94 100644
+ // Paper end
}
private static int b(int i, int j, int k) {
private static int b(int ix, int jx, int k) {
@@ -0,0 +0,0 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
}
}
@@ -1213,19 +1212,18 @@ index 575f9b558..5d2561a94 100644
+ }
+ }
+ // Paper end
+
public int onResize(int i, T t0) {
public int onResize(int ix, T object) {
this.b();
DataBits databits = this.a;
DataPalette<T> datapalette = this.h; // Paper - decompile fix
this.b(ix);
this.b(i);
+ this.addPredefinedObjects(); // Paper - Anti-Xray - Add predefined objects
int j;
for(int jx = 0; jx < databits.b(); ++jx) {
T object1 = datapalette.a(databits.a(jx)); // Paper - decompile fix
if (object1 != null) {
@@ -0,0 +0,0 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
return object == null ? this.g : object;
return (T)(object == null ? this.g : object);
}
- public void writeDataPaletteBlock(PacketDataSerializer packetDataSerializer) { this.b(packetDataSerializer); } // Paper - OBFHELPER
@@ -1258,22 +1256,22 @@ index 575f9b558..5d2561a94 100644
public void a(NBTTagCompound nbttagcompound, String s, String s1) {
this.b();
NBTTagList nbttaglist = nbttagcompound.getList(s, 10);
- int i = Math.max(4, MathHelper.d(nbttaglist.size()));
- int ix = Math.max(4, MathHelper.d(nbttaglist.size()));
- if (ix != this.i) {
+ // 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)?
+ int i = Math.max(4, MathHelper.d(nbttaglist.size() + (this.predefinedObjects == null ? 0 : this.predefinedObjects.length))); // Paper - Anti-Xray - Calculate the size with predefined objects
- if (i != this.i) {
+ if (true || i != this.i) { // Paper - Anti-Xray - Not initialized yet
this.b(i);
+ int ix = Math.max(4, MathHelper.d(nbttaglist.size() + (this.predefinedObjects == null ? 0 : this.predefinedObjects.length))); // Paper - Anti-Xray - Calculate the size with predefined objects
+
+ if (true || ix != this.i) { // Paper - Anti-Xray - Not initialized yet
this.b(ix);
}
this.h.a(nbttaglist);
+ this.addPredefinedObjects(); // Paper - Anti-Xray - Add predefined objects
long[] along = nbttagcompound.o(s1);
int j = along.length * 64 / 4096;
int jx = along.length * 64 / 4096;
if (this.h == this.b) {
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index f8facddb4..b2afec5e4 100644
index f8facddb40..b2afec5e4b 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
@@ -1334,7 +1332,7 @@ index f8facddb4..b2afec5e4 100644
public void a() {
this.o();
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
index 632101024..d0ff96812 100644
index 22a262bb60..40ec398eef 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
@@ -0,0 +0,0 @@
@@ -1350,20 +1348,16 @@ index 632101024..d0ff96812 100644
private boolean f;
+ private volatile boolean ready = false; // Paper - Async-Anti-Xray - Ready flag for the network manager
- public PacketPlayOutMapChunk() {}
+ // Paper start - Async-Anti-Xray - Set the ready flag to true
+ public PacketPlayOutMapChunk() {
+ this.ready = true;
+ }
+ // Paper end
public PacketPlayOutMapChunk() {
+ this.ready = true; // Paper - Async-Anti-Xray - Set the ready flag to true
}
public PacketPlayOutMapChunk(Chunk chunk, int i) {
+ ChunkPacketInfo<IBlockData> chunkPacketInfo = chunk.world.chunkPacketBlockController.getChunkPacketInfo(this, chunk, i); // Paper - Anti-Xray - Add chunk packet info
this.a = chunk.locX;
this.b = chunk.locZ;
this.f = i == '\uffff';
this.f = i == 65535;
boolean flag = chunk.getWorld().worldProvider.g();
this.d = new byte[this.a(chunk, flag, i)];
- this.c = this.a(new PacketDataSerializer(this.h()), chunk, flag, i);
+
@@ -1375,8 +1369,8 @@ index 632101024..d0ff96812 100644
+
+ this.c = this.writeChunk(new PacketDataSerializer(this.h()), chunk, flag, i, chunkPacketInfo); // Paper - Anti-Xray - Add chunk packet info
this.e = Lists.newArrayList();
Iterator iterator = chunk.getTileEntities().entrySet().iterator();
for(Entry entry : chunk.getTileEntities().entrySet()) {
@@ -0,0 +0,0 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
}
}
@@ -1387,15 +1381,16 @@ index 632101024..d0ff96812 100644
+ // Paper start - Async-Anti-Xray - Getter and Setter for the ready flag
+ public boolean isReady() {
+ return this.ready;
+ }
+
}
+ public void setReady(boolean ready) {
+ this.ready = ready;
}
+ }
+ // Paper end
+
public void a(PacketDataSerializer packetdataserializer) throws IOException {
this.a = packetdataserializer.readInt();
this.b = packetdataserializer.readInt();
@@ -0,0 +0,0 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
return bytebuf;
}
@@ -1414,7 +1409,7 @@ index 632101024..d0ff96812 100644
ChunkSection[] achunksection = chunk.getSections();
int k = 0;
@@ -0,0 +0,0 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
ChunkSection chunksection = achunksection[k];
if (chunksection != Chunk.a && (!this.f() || !chunksection.a()) && (i & 1 << k) != 0) {
j |= 1 << k;
- chunksection.getBlocks().b(packetdataserializer);
@@ -1423,7 +1418,7 @@ index 632101024..d0ff96812 100644
if (flag) {
packetdataserializer.writeBytes(chunksection.getSkyLightArray().asBytes());
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index f8d8a44a8..e7d465fb8 100644
index f8d8a44a88..e7d465fb8a 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -0,0 +0,0 @@ public class PlayerChunk {
@@ -1454,7 +1449,7 @@ index f8d8a44a8..e7d465fb8 100644
} else {
this.a((Packet) (new PacketPlayOutMultiBlockChange(this.dirtyCount, this.dirtyBlocks, this.chunk)));
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
index cae24961f..a9690fb1c 100644
index cae24961fd..a9690fb1c3 100644
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
@@ -0,0 +0,0 @@ public class PlayerInteractManager {
@@ -1467,7 +1462,7 @@ index cae24961f..a9690fb1c 100644
public void a(BlockPosition blockposition) {
diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java
index 541435d3e..0b4f0d241 100644
index 688b4ab8be..f78d5fbb86 100644
--- a/src/main/java/net/minecraft/server/ProtoChunk.java
+++ b/src/main/java/net/minecraft/server/ProtoChunk.java
@@ -0,0 +0,0 @@ public class ProtoChunk implements IChunkAccess {
@@ -1476,10 +1471,11 @@ index 541435d3e..0b4f0d241 100644
private boolean u;
+ private final GeneratorAccess world; // Paper - Anti-Xray
+
+ // Paper start - Anti-Xray - Support default constructors
public ProtoChunk(int i, int j, ChunkConverter chunkconverter) {
- this(new ChunkCoordIntPair(i, j), chunkconverter);
+ this(i, j, chunkconverter, null);
public ProtoChunk(int ix, int jx, ChunkConverter chunkconverter) {
- this(new ChunkCoordIntPair(ix, jx), chunkconverter);
+ this(ix, jx, chunkconverter, null);
}
public ProtoChunk(ChunkCoordIntPair chunkcoordintpair, ChunkConverter chunkconverter) {
@@ -1496,33 +1492,15 @@ index 541435d3e..0b4f0d241 100644
this.d = new AtomicInteger();
this.f = Maps.newEnumMap(HeightMap.Type.class);
this.g = ChunkStatus.EMPTY;
@@ -0,0 +0,0 @@ public class ProtoChunk implements IChunkAccess {
IRegistry iregistry1 = IRegistry.BLOCK;
IRegistry.BLOCK.getClass();
- this.q = new ProtoChunkTickList(predicate, function, iregistry1::getOrDefault, chunkcoordintpair);
+ this.q = new ProtoChunkTickList<Block>(predicate, function, IRegistry.BLOCK::getOrDefault, chunkcoordintpair); // Paper - decompile fix
predicate = (fluidtype) -> {
return fluidtype == null || fluidtype == FluidTypes.a;
};
@@ -0,0 +0,0 @@ public class ProtoChunk implements IChunkAccess {
function = iregistry::getKey;
iregistry1 = IRegistry.FLUID;
IRegistry.FLUID.getClass();
- this.r = new ProtoChunkTickList(predicate, function, iregistry1::getOrDefault, chunkcoordintpair);
+ this.r = new ProtoChunkTickList<FluidType>(predicate, function, IRegistry.FLUID::getOrDefault, chunkcoordintpair); // Paper - decompile fix
}
public static ShortList a(ShortList[] ashortlist, int i) {
@@ -0,0 +0,0 @@ public class ProtoChunk implements IChunkAccess {
return iblockdata;
}
- this.j[j >> 4] = new ChunkSection(j >> 4 << 4, this.x());
+ this.j[j >> 4] = new ChunkSection(j >> 4 << 4, this.x(), this, this.world, true); // Paper - Anti-Xray
- this.j[jx >> 4] = new ChunkSection(jx >> 4 << 4, this.x());
+ this.j[jx >> 4] = new ChunkSection(jx >> 4 << 4, this.x(), this, this.world, true); // Paper - Anti-Xray
}
IBlockData iblockdata1 = this.j[j >> 4].getType(i & 15, j & 15, k & 15);
IBlockData iblockdata1 = this.j[jx >> 4].getType(ix & 15, jx & 15, kx & 15);
@@ -0,0 +0,0 @@ public class ProtoChunk implements IChunkAccess {
return;
}
@@ -1533,7 +1511,7 @@ index 541435d3e..0b4f0d241 100644
if (enumskyblock == EnumSkyBlock.SKY) {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 20bead54b..49809372d 100644
index 20bead54bf..49809372d8 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -0,0 +0,0 @@
@@ -1570,7 +1548,7 @@ index 20bead54b..49809372d 100644
if (iblockdata1 == null) {
// CraftBukkit start - remove blockstate if failed
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
index c26f0ed16..f6915d32a 100644
index c26f0ed16b..f6915d32ab 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
@@ -0,0 +0,0 @@ import org.bukkit.material.MaterialData;