mirror of
https://github.com/PaperMC/Paper.git
synced 2024-08-26 22:50:23 +02:00
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues. Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong. This is now resolved. Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me. Please as always, backup your worlds and test before updating to 1.16.2! If you update to 1.16.2, there is no going back to an older build than this. --------------------------------- Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com> Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com> Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com> Co-authored-by: stonar96 <minecraft.stonar96@gmail.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Jason <jasonpenilla2@me.com> Co-authored-by: kashike <kashike@vq.lc> Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: KennyTV <kennytv@t-online.de> Co-authored-by: commandblockguy <commandblockguy1@gmail.com> Co-authored-by: DigitalRegent <misterwener@gmail.com> Co-authored-by: ishland <ishlandmc@yeah.net>
207 lines
9.9 KiB
Diff
207 lines
9.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 3 Mar 2016 02:07:55 -0600
|
|
Subject: [PATCH] Optimize isValidLocation, getType and getBlockData for
|
|
inlining
|
|
|
|
Hot methods, so reduce # of instructions for the method.
|
|
|
|
Move is valid location test to the BlockPosition class so that it can access local variables.
|
|
|
|
Replace all calls to the new place to the unnecessary forward.
|
|
|
|
Optimize getType and getBlockData to manually inline and optimize the calls
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
index 6b6ea0b33b10a9517b7af55fb8292fe245e3ca1e..e126f9d1d03de085f2d09d53fe8bcc1972aedeff 100644
|
|
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
@@ -20,6 +20,15 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
|
private int b;public final void setY(final int y) { this.b = y; } // Paper - OBFHELPER
|
|
private int e;public final void setZ(final int z) { this.e = z; } // Paper - OBFHELPER
|
|
|
|
+ // Paper start
|
|
+ public boolean isValidLocation() {
|
|
+ return getX() >= -30000000 && getZ() >= -30000000 && getX() < 30000000 && getZ() < 30000000 && getY() >= 0 && getY() < 256;
|
|
+ }
|
|
+ public boolean isInvalidYLocation() {
|
|
+ return b < 0 || b >= 256;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public BaseBlockPosition(int i, int j, int k) {
|
|
this.a = i;
|
|
this.b = j;
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
|
index 330492e918efa42717ef2208947e8be927df5398..8d13c2fab572428d61777699d5463f0678d9ad7c 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -308,12 +308,27 @@ public class Chunk implements IChunkAccess {
|
|
return this.sections;
|
|
}
|
|
|
|
- @Override
|
|
+ // Paper start - Optimize getBlockData to reduce instructions
|
|
+ public final IBlockData getBlockData(BlockPosition pos) { return getBlockData(pos.getX(), pos.getY(), pos.getZ()); } // Paper
|
|
public IBlockData getType(BlockPosition blockposition) {
|
|
- int i = blockposition.getX();
|
|
- int j = blockposition.getY();
|
|
- int k = blockposition.getZ();
|
|
+ return this.getBlockData(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
+ }
|
|
+
|
|
+ public IBlockData getType(final int x, final int y, final int z) {
|
|
+ return getBlockData(x, y, z);
|
|
+ }
|
|
+ public final IBlockData getBlockData(final int x, final int y, final int z) {
|
|
+ // Method body / logic copied from below
|
|
+ final int i = y >> 4;
|
|
+ if (y < 0 || i >= this.sections.length || this.sections[i] == null || this.sections[i].nonEmptyBlockCount == 0) {
|
|
+ return Blocks.AIR.getBlockData();
|
|
+ }
|
|
+ // Inlined ChunkSection.getType() and DataPaletteBlock.a(int,int,int)
|
|
+ return this.sections[i].blockIds.a((y & 15) << 8 | (z & 15) << 4 | x & 15);
|
|
+ }
|
|
|
|
+ public IBlockData getBlockData_unused(int i, int j, int k) {
|
|
+ // Paper end
|
|
if (this.world.isDebugWorld()) {
|
|
IBlockData iblockdata = null;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkEmpty.java b/src/main/java/net/minecraft/server/ChunkEmpty.java
|
|
index 84207e7da6df97246f756940142a2af9eb9ca815..ed22ff28ea6c0978ec0d9d1ecf7baa3f422ed677 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkEmpty.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkEmpty.java
|
|
@@ -7,7 +7,7 @@ import javax.annotation.Nullable;
|
|
|
|
public class ChunkEmpty extends Chunk {
|
|
|
|
- private static final BiomeBase[] b = (BiomeBase[]) SystemUtils.a((Object) (new BiomeBase[BiomeStorage.a]), (abiomebase) -> {
|
|
+ private static final BiomeBase[] b = SystemUtils.a((new BiomeBase[BiomeStorage.a]), (abiomebase) -> { // Paper - decompile error
|
|
Arrays.fill(abiomebase, BiomeRegistry.a);
|
|
});
|
|
|
|
@@ -15,6 +15,11 @@ public class ChunkEmpty extends Chunk {
|
|
super(world, chunkcoordintpair, new BiomeStorage(world.r().b(IRegistry.ay), ChunkEmpty.b));
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override public IBlockData getType(int x, int y, int z) {
|
|
+ return Blocks.VOID_AIR.getBlockData();
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public IBlockData getType(BlockPosition blockposition) {
|
|
return Blocks.VOID_AIR.getBlockData();
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
|
|
index 882c2733beaff1df68b892d44fc77cacf4364ff4..5c7068cd93806d67c643ed6aabdfcab8888ed94e 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkSection.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
|
|
@@ -7,10 +7,10 @@ public class ChunkSection {
|
|
|
|
public static final DataPalette<IBlockData> GLOBAL_PALETTE = new DataPaletteGlobal<>(Block.REGISTRY_ID, Blocks.AIR.getBlockData());
|
|
private final int yPos;
|
|
- private short nonEmptyBlockCount;
|
|
+ short nonEmptyBlockCount; // Paper - package-private
|
|
private short tickingBlockCount;
|
|
private short e;
|
|
- private final DataPaletteBlock<IBlockData> blockIds;
|
|
+ final DataPaletteBlock<IBlockData> blockIds; // Paper - package-private
|
|
|
|
public ChunkSection(int i) {
|
|
this(i, (short) 0, (short) 0, (short) 0);
|
|
@@ -24,8 +24,8 @@ public class ChunkSection {
|
|
this.blockIds = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::c, GameProfileSerializer::a, Blocks.AIR.getBlockData());
|
|
}
|
|
|
|
- public IBlockData getType(int i, int j, int k) {
|
|
- return (IBlockData) this.blockIds.a(i, j, k);
|
|
+ public final IBlockData getType(int i, int j, int k) { // Paper
|
|
+ return this.blockIds.a(j << 8 | k << 4 | i); // Paper - inline
|
|
}
|
|
|
|
public Fluid b(int i, int j, int k) {
|
|
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
|
index 32849e360a396128bd228db269ad1a8f7c6583a8..eabc9d7b934f27c823e012f3f10fffc23b461292 100644
|
|
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
|
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
|
@@ -124,7 +124,7 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
|
|
}
|
|
|
|
public T a(int i, int j, int k) {
|
|
- return this.a(b(i, j, k));
|
|
+ return this.a(j << 8 | k << 4 | i); // Paper - inline
|
|
}
|
|
|
|
protected T a(int i) {
|
|
diff --git a/src/main/java/net/minecraft/server/IChunkAccess.java b/src/main/java/net/minecraft/server/IChunkAccess.java
|
|
index e0672c3c0bf30d88ea1cc609459050499a7271f3..887366f4c2ab608974113e75760b58c47f2afa00 100644
|
|
--- a/src/main/java/net/minecraft/server/IChunkAccess.java
|
|
+++ b/src/main/java/net/minecraft/server/IChunkAccess.java
|
|
@@ -12,6 +12,7 @@ import org.apache.logging.log4j.LogManager;
|
|
|
|
public interface IChunkAccess extends IBlockAccess, IStructureAccess {
|
|
|
|
+ IBlockData getType(final int x, final int y, final int z); // Paper
|
|
@Nullable
|
|
IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag);
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java
|
|
index e356bd73901ac7f230492e654af579d21c8fc086..2bcd26ccccf4503241c6b77600ed6ce1d94ccfcc 100644
|
|
--- a/src/main/java/net/minecraft/server/ProtoChunk.java
|
|
+++ b/src/main/java/net/minecraft/server/ProtoChunk.java
|
|
@@ -95,16 +95,18 @@ public class ProtoChunk implements IChunkAccess {
|
|
|
|
@Override
|
|
public IBlockData getType(BlockPosition blockposition) {
|
|
- int i = blockposition.getY();
|
|
-
|
|
- if (World.b(i)) {
|
|
+ return getType(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
+ }
|
|
+ // Paper start
|
|
+ public IBlockData getType(final int x, final int y, final int z) {
|
|
+ if (y < 0 || y >= 256) {
|
|
return Blocks.VOID_AIR.getBlockData();
|
|
} else {
|
|
- ChunkSection chunksection = this.getSections()[i >> 4];
|
|
-
|
|
- return ChunkSection.a(chunksection) ? Blocks.AIR.getBlockData() : chunksection.getType(blockposition.getX() & 15, i & 15, blockposition.getZ() & 15);
|
|
+ ChunkSection chunksection = this.getSections()[y >> 4];
|
|
+ return chunksection == Chunk.EMPTY_CHUNK_SECTION || chunksection.c() ? Blocks.AIR.getBlockData() : chunksection.getType(x & 15, y & 15, z & 15);
|
|
}
|
|
}
|
|
+ // Paper end
|
|
|
|
@Override
|
|
public Fluid getFluid(BlockPosition blockposition) {
|
|
diff --git a/src/main/java/net/minecraft/server/ProtoChunkExtension.java b/src/main/java/net/minecraft/server/ProtoChunkExtension.java
|
|
index 065eeed71075bb8f4069cb172ea7fca54793ddc0..09da0cc8f02c504191dfec8be93e6cf67c6afb78 100644
|
|
--- a/src/main/java/net/minecraft/server/ProtoChunkExtension.java
|
|
+++ b/src/main/java/net/minecraft/server/ProtoChunkExtension.java
|
|
@@ -26,6 +26,11 @@ public class ProtoChunkExtension extends ProtoChunk {
|
|
public IBlockData getType(BlockPosition blockposition) {
|
|
return this.a.getType(blockposition);
|
|
}
|
|
+ // Paper start
|
|
+ public final IBlockData getType(final int x, final int y, final int z) {
|
|
+ return this.a.getBlockData(x, y, z);
|
|
+ }
|
|
+ // Paper end
|
|
|
|
@Override
|
|
public Fluid getFluid(BlockPosition blockposition) {
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 1d0238566d8cef75c28389c5b7084019d25c8f72..b5a6e6152b020201de631a924c8fd077eb1b546a 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -187,7 +187,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
}
|
|
|
|
public static boolean isValidLocation(BlockPosition blockposition) {
|
|
- return !isOutsideWorld(blockposition) && D(blockposition);
|
|
+ return blockposition.isValidLocation(); // Paper - use better/optimized check
|
|
}
|
|
|
|
public static boolean l(BlockPosition blockposition) {
|