Optimize Light Engine
Massive update to light to improve performance and chunk loading/generation. 1) Massive bit packing/unpacking optimizations and inlining. A lot of performance has to do with constant packing and unpacking of bits. We now inline a most bit operations, and re-use base x/y/z bits in many places. This helps with cpu level processing to just do all the math at once instead of having to jump in and out of function calls. This much logic also is likely over the JVM Inline limit for JIT too. 2) Applied a few of JellySquid's Phosphor mod optimizations such as - ensuring we don't notify neighbor chunks when neighbor chunk doesn't need to be notified - reduce hasLight checks in initializing light, and prob some more, they are tagged JellySquid where phosphor influence was used. 3) Optimize hot path accesses to getting updating chunk to have less branching 4) Optimize getBlock accesses to have less branching, and less unpacking 5) Have a separate urgent bucket for chunk light tasks. These tasks will always cut in line over non blocking light tasks. 6) Retain chunk priority while light tasks are enqueued. So if a task comes in at high priority but the queue is full of tasks already at a lower priority, before the task was simply added to the end. Now it can cut in line to the front. this applies for both urgent and non urgent tasks. 7) Buffer non urgent tasks even if queueUpdate is called multiple times to improve efficiency. 8) Fix NPE risk that crashes server in getting nibble data Fixes #3489 Fixes #3363
This commit is contained in:
parent
dfd3848ee6
commit
9fa6ba267c
18 changed files with 1659 additions and 148 deletions
|
@ -1,7 +1,8 @@
|
|||
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 inling
|
||||
Subject: [PATCH] Optimize isValidLocation, getType and getBlockData for
|
||||
inlining
|
||||
|
||||
Hot methods, so reduce # of instructions for the method.
|
||||
|
||||
|
@ -31,10 +32,10 @@ index 3f09c24e1cd1bba2809b70b1fa6e89773537d834..7b05bb9edcd059a134cef12cc9fea570
|
|||
public BaseBlockPosition(int i, int j, int k) {
|
||||
this.a = i;
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index b85e21202eb8bb9446989aa1d6889eed784762a4..324cd78f8c896d300d1e74acde3db6a81dab2b0d 100644
|
||||
index b85e21202eb8bb9446989aa1d6889eed784762a4..671bcc763c78114f38d2b9b0320d7b168a756e21 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -307,12 +307,24 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -307,12 +307,27 @@ public class Chunk implements IChunkAccess {
|
||||
return this.sections;
|
||||
}
|
||||
|
||||
|
@ -47,28 +48,60 @@ index b85e21202eb8bb9446989aa1d6889eed784762a4..324cd78f8c896d300d1e74acde3db6a8
|
|||
- 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) {
|
||||
+ // Inlined ChunkSection.getType() and DataPaletteBlock.a(int,int,int)
|
||||
+ return this.sections[i].blockIds.a((y & 15) << 8 | (z & 15) << 4 | x & 15);
|
||||
+ if (y < 0 || i >= this.sections.length || this.sections[i] == null || this.sections[i].nonEmptyBlockCount == 0) {
|
||||
+ return Blocks.AIR.getBlockData();
|
||||
+ }
|
||||
+ 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.P() == WorldType.DEBUG_ALL_BLOCK_STATES) {
|
||||
IBlockData iblockdata = null;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkEmpty.java b/src/main/java/net/minecraft/server/ChunkEmpty.java
|
||||
index 82fdd3db6f698f8b77c8bbd1f17cb21980ecfeec..fd49438961451987bd102a85484be24b341d946b 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 = (BiomeBase[]) SystemUtils.a((new BiomeBase[BiomeStorage.a]), (abiomebase) -> { // Paper - decompile error
|
||||
Arrays.fill(abiomebase, Biomes.PLAINS);
|
||||
});
|
||||
|
||||
@@ -15,6 +15,11 @@ public class ChunkEmpty extends Chunk {
|
||||
super(world, chunkcoordintpair, new BiomeStorage(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 638b0e39798a3f75566fcf9ea48b81024e60b471..e056fbcb216977401fd2778fcd3ee7ed5f020214 100644
|
||||
index 638b0e39798a3f75566fcf9ea48b81024e60b471..e72d1386feb59e4a4c27466da96ffd29222bea18 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
@@ -9,7 +9,7 @@ public class ChunkSection {
|
||||
private short nonEmptyBlockCount;
|
||||
@@ -6,10 +6,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;
|
||||
|
@ -76,8 +109,89 @@ index 638b0e39798a3f75566fcf9ea48b81024e60b471..e056fbcb216977401fd2778fcd3ee7ed
|
|||
|
||||
public ChunkSection(int i) {
|
||||
this(i, (short) 0, (short) 0, (short) 0);
|
||||
@@ -23,8 +23,8 @@ public class ChunkSection {
|
||||
this.blockIds = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, 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 d5f5a51872dfabdbb828b6c20d61893aed2efec7..3586fe065f21fbf1e71b602c372a690ef603f377 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
@@ -125,7 +125,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 6f25c37658e8e4b31fec2d9e8b69616f073e0b30..2de4796946e79c5fc7a36a1e26cbcad7bca6e12a 100644
|
||||
--- a/src/main/java/net/minecraft/server/IChunkAccess.java
|
||||
+++ b/src/main/java/net/minecraft/server/IChunkAccess.java
|
||||
@@ -13,6 +13,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 39339fa27551b06a9bfd8ea67b1ec8c66726f488..51a5b9cb36c4325df8d1434dcf28d27abefdfede 100644
|
||||
--- a/src/main/java/net/minecraft/server/ProtoChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/ProtoChunk.java
|
||||
@@ -94,16 +94,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 01bf28dc34dd69dbcee5f470cc71ec2fbb2fcc12..b740e82622e282bdf543a84a559af69dd5b8568c 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 a721ad8addfd5a47608e304b372762d3ca89fa65..40a51633ed509ca7ae6131e11276f8f3cb7c03ce 100644
|
||||
index 7f1f0111373fa409e52894e59ac49d5278d0bd58..50c2c4b0dc6256d5fbc361ba9b89b4e17bef8acb 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -172,11 +172,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
|
|
|
@ -30,10 +30,10 @@ index 6ef0e1399e9ff260712db1a044068c125b1316d3..5872e6b171416686b11678ac9f65706b
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 324cd78f8c896d300d1e74acde3db6a81dab2b0d..f5298a2fa911a18a5d390666c92155dd618666c5 100644
|
||||
index 671bcc763c78114f38d2b9b0320d7b168a756e21..2c1570c89026a5dbbe76ab00c6a89919e566a5f6 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -973,7 +973,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -976,7 +976,7 @@ public class Chunk implements IChunkAccess {
|
||||
|
||||
@Override
|
||||
public long getInhabitedTime() {
|
||||
|
|
|
@ -19,10 +19,10 @@ index 8cf3076f4e0d8d7e81158881c763f89ebda7e678..721eceeffc843da8b9da1ccc2d07f3bc
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index f5298a2fa911a18a5d390666c92155dd618666c5..23bce1c192f6c354b7fe8858515be5f98a8fe6c3 100644
|
||||
index 2c1570c89026a5dbbe76ab00c6a89919e566a5f6..87e94693f6db07d1273854ad55e5f263f2f2239e 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -633,6 +633,12 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -636,6 +636,12 @@ public class Chunk implements IChunkAccess {
|
||||
"Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16));
|
||||
e.printStackTrace();
|
||||
ServerInternalException.reportInternalException(e);
|
||||
|
|
|
@ -6,10 +6,10 @@ Subject: [PATCH] Mark chunk dirty anytime entities change to guarantee it
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 23bce1c192f6c354b7fe8858515be5f98a8fe6c3..0b62004422108e126d80a879c203fab0455e1451 100644
|
||||
index 87e94693f6db07d1273854ad55e5f263f2f2239e..f0a8142b7477fde211b522e3982e614fc94e20f8 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -515,6 +515,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -518,6 +518,7 @@ public class Chunk implements IChunkAccess {
|
||||
entity.chunkZ = this.loc.z;
|
||||
this.entities.add(entity); // Paper - per chunk entity list
|
||||
this.entitySlices[k].add(entity);
|
||||
|
@ -17,7 +17,7 @@ index 23bce1c192f6c354b7fe8858515be5f98a8fe6c3..0b62004422108e126d80a879c203fab0
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -542,6 +543,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -545,6 +546,7 @@ public class Chunk implements IChunkAccess {
|
||||
return;
|
||||
}
|
||||
entityCounts.decrement(entity.getMinecraftKeyString());
|
||||
|
|
|
@ -9,10 +9,10 @@ This should hopefully avoid duplicate entities ever being created
|
|||
if the entity was to end up in 2 different chunk slices
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 0b62004422108e126d80a879c203fab0455e1451..4e7f3065694c8811d5c98bcda64ae32b220e0d7a 100644
|
||||
index f0a8142b7477fde211b522e3982e614fc94e20f8..9f369f932ca0a63bde246420cfde7949f3e78ca2 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -506,6 +506,25 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -509,6 +509,25 @@ public class Chunk implements IChunkAccess {
|
||||
if (k >= this.entitySlices.length) {
|
||||
k = this.entitySlices.length - 1;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ index 0b62004422108e126d80a879c203fab0455e1451..4e7f3065694c8811d5c98bcda64ae32b
|
|||
|
||||
if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper
|
||||
entity.inChunk = true;
|
||||
@@ -515,6 +534,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -518,6 +537,7 @@ public class Chunk implements IChunkAccess {
|
||||
entity.chunkZ = this.loc.z;
|
||||
this.entities.add(entity); // Paper - per chunk entity list
|
||||
this.entitySlices[k].add(entity);
|
||||
|
@ -46,7 +46,7 @@ index 0b62004422108e126d80a879c203fab0455e1451..4e7f3065694c8811d5c98bcda64ae32b
|
|||
this.markDirty(); // Paper
|
||||
}
|
||||
|
||||
@@ -539,6 +559,10 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -542,6 +562,10 @@ public class Chunk implements IChunkAccess {
|
||||
|
||||
// Paper start
|
||||
if (entity.currentChunk != null && entity.currentChunk.get() == this) entity.setCurrentChunk(null);
|
||||
|
|
|
@ -23,10 +23,10 @@ index b839769ceae8932bb121a0b96fde1e7d129a1f63..5acad8e44f024d3ddf5ef4fd320460ac
|
|||
MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
|
||||
ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 4e7f3065694c8811d5c98bcda64ae32b220e0d7a..5453eaae5b165a76b55a085d70081159b8e66770 100644
|
||||
index 9f369f932ca0a63bde246420cfde7949f3e78ca2..c84d90a9a0c67b5ff518ce3fbc21344c808a3cf1 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -813,6 +813,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -816,6 +816,7 @@ public class Chunk implements IChunkAccess {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity1 = (Entity) iterator.next();
|
||||
|
@ -34,7 +34,7 @@ index 4e7f3065694c8811d5c98bcda64ae32b220e0d7a..5453eaae5b165a76b55a085d70081159
|
|||
|
||||
if (entity1.getBoundingBox().c(axisalignedbb) && entity1 != entity) {
|
||||
if (predicate == null || predicate.test(entity1)) {
|
||||
@@ -850,6 +851,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -853,6 +854,7 @@ public class Chunk implements IChunkAccess {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T entity = (T) iterator.next(); // CraftBukkit - decompile error
|
||||
|
@ -42,7 +42,7 @@ index 4e7f3065694c8811d5c98bcda64ae32b220e0d7a..5453eaae5b165a76b55a085d70081159
|
|||
|
||||
if ((entitytypes == null || entity.getEntityType() == entitytypes) && entity.getBoundingBox().c(axisalignedbb) && predicate.test(entity)) {
|
||||
list.add(entity);
|
||||
@@ -871,6 +873,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -874,6 +876,7 @@ public class Chunk implements IChunkAccess {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = (T) iterator.next(); // CraftBukkit - decompile error
|
||||
|
|
|
@ -81,10 +81,10 @@ index 4ba72275b965693f3650f9b4fb138d3320d1b88b..572679e4d1ca0d84a08a5c48542fa40d
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 5453eaae5b165a76b55a085d70081159b8e66770..4f05468590e30f4b11599d3841418c76519255e4 100644
|
||||
index c84d90a9a0c67b5ff518ce3fbc21344c808a3cf1..962f425bbb7165740e77664dc543f976ef3d9c4a 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -495,6 +495,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -498,6 +498,7 @@ public class Chunk implements IChunkAccess {
|
||||
if (i != this.loc.x || j != this.loc.z) {
|
||||
Chunk.LOGGER.warn("Wrong location! ({}, {}) should be ({}, {}), {}", i, j, this.loc.x, this.loc.z, entity);
|
||||
entity.dead = true;
|
||||
|
|
|
@ -1008,10 +1008,10 @@ index 0000000000000000000000000000000000000000..2eff19f6aaa31245f80910c6fbb541e3
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 820033289cbeb782429b26b6bcabc3835b0101a3..b855589d978d06e9883daff97c9e702d5a9461cc 100644
|
||||
index dd3857bb6a002d8432ecbc6c6b52a39e5d55e6a6..08b3cbabc482d71862d90fcd9acd32d28f44a6e2 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -419,7 +419,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -422,7 +422,7 @@ public class Chunk implements IChunkAccess {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1043,7 +1043,7 @@ index 8e4b3e52cbc95e24b1d72aed9ec8c32b94a91561..d287ea55c550dbebbbc1d5f815296ae7
|
|||
protochunk.a(biomestorage);
|
||||
object = protochunk;
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
index e056fbcb216977401fd2778fcd3ee7ed5f020214..eeb7eee925d31d1ed8e6bbd55888cb5ebe54afa2 100644
|
||||
index e72d1386feb59e4a4c27466da96ffd29222bea18..c180d44bed91c86838d3be8c19be954b4412534e 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
@@ -1,5 +1,6 @@
|
||||
|
@ -1079,7 +1079,7 @@ index e056fbcb216977401fd2778fcd3ee7ed5f020214..eeb7eee925d31d1ed8e6bbd55888cb5e
|
|||
+ this.blockIds = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData(), world == null ? null : world.chunkPacketBlockController.getPredefinedBlockData(world, chunk, this, initializeBlocks), initializeBlocks); // Paper - Anti-Xray - Add predefined block data
|
||||
}
|
||||
|
||||
public IBlockData getType(int i, int j, int k) {
|
||||
public final IBlockData getType(int i, int j, int k) { // Paper
|
||||
@@ -132,10 +139,14 @@ public class ChunkSection {
|
||||
return this.blockIds;
|
||||
}
|
||||
|
@ -1099,7 +1099,7 @@ index e056fbcb216977401fd2778fcd3ee7ed5f020214..eeb7eee925d31d1ed8e6bbd55888cb5e
|
|||
|
||||
public int j() {
|
||||
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
index 3da575929fcf878ebfe18e3240fac84325159225..abe86b4607e014e280e29daae6e1617763c53131 100644
|
||||
index 44310efd63b0a460e9dcdc1c8ad0abec78052061..a5ea0e34ec181ad9f98f9ee2f644c3ec1eb1cd3c 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.server;
|
||||
|
@ -1338,7 +1338,7 @@ index ed3f3362b640746649455f8dd2255ac2da03df7c..f11ef84df85c1e7ada9c62247b7882f1
|
|||
|
||||
public void a(BlockPosition blockposition, PacketPlayInBlockDig.EnumPlayerDigType packetplayinblockdig_enumplayerdigtype, String s) {
|
||||
diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java
|
||||
index 39339fa27551b06a9bfd8ea67b1ec8c66726f488..deb7fb090196c4a33c0bb224f1c4e899aa3cd8c3 100644
|
||||
index 51a5b9cb36c4325df8d1434dcf28d27abefdfede..a78b240621e0407fff67b018224c39fc4f97f4e5 100644
|
||||
--- a/src/main/java/net/minecraft/server/ProtoChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/ProtoChunk.java
|
||||
@@ -45,16 +45,24 @@ public class ProtoChunk implements IChunkAccess {
|
||||
|
@ -1369,7 +1369,7 @@ index 39339fa27551b06a9bfd8ea67b1ec8c66726f488..deb7fb090196c4a33c0bb224f1c4e899
|
|||
this.f = Maps.newEnumMap(HeightMap.Type.class);
|
||||
this.g = ChunkStatus.EMPTY;
|
||||
this.h = Maps.newHashMap();
|
||||
@@ -207,7 +215,7 @@ public class ProtoChunk implements IChunkAccess {
|
||||
@@ -209,7 +217,7 @@ public class ProtoChunk implements IChunkAccess {
|
||||
|
||||
public ChunkSection a(int i) {
|
||||
if (this.j[i] == Chunk.a) {
|
||||
|
@ -1379,7 +1379,7 @@ index 39339fa27551b06a9bfd8ea67b1ec8c66726f488..deb7fb090196c4a33c0bb224f1c4e899
|
|||
|
||||
return this.j[i];
|
||||
diff --git a/src/main/java/net/minecraft/server/ProtoChunkExtension.java b/src/main/java/net/minecraft/server/ProtoChunkExtension.java
|
||||
index 01bf28dc34dd69dbcee5f470cc71ec2fbb2fcc12..caa18b046cd4231b1caa9c70e766ab60e11b3164 100644
|
||||
index b740e82622e282bdf543a84a559af69dd5b8568c..6db6e74886943559e3582c350ffae54857ad8b84 100644
|
||||
--- a/src/main/java/net/minecraft/server/ProtoChunkExtension.java
|
||||
+++ b/src/main/java/net/minecraft/server/ProtoChunkExtension.java
|
||||
@@ -11,7 +11,7 @@ public class ProtoChunkExtension extends ProtoChunk {
|
||||
|
|
|
@ -14,7 +14,7 @@ And since minecart hoppers are used _very_ rarely near we can avoid alot of sear
|
|||
Combined, this adds up a lot.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index b855589d978d06e9883daff97c9e702d5a9461cc..9f0758aff6588736d500b6e202fc1a5f6a577e7f 100644
|
||||
index 08b3cbabc482d71862d90fcd9acd32d28f44a6e2..af9a195f6d0f966133577d00d30e8b4ad812aaeb 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -84,6 +84,10 @@ public class Chunk implements IChunkAccess {
|
||||
|
@ -28,7 +28,7 @@ index b855589d978d06e9883daff97c9e702d5a9461cc..9f0758aff6588736d500b6e202fc1a5f
|
|||
// Paper end
|
||||
|
||||
public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeStorage biomestorage, ChunkConverter chunkconverter, TickList<Block> ticklist, TickList<FluidType> ticklist1, long i, @Nullable ChunkSection[] achunksection, @Nullable Consumer<Chunk> consumer) {
|
||||
@@ -535,6 +539,13 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -538,6 +542,13 @@ public class Chunk implements IChunkAccess {
|
||||
entity.chunkZ = this.loc.z;
|
||||
this.entities.add(entity); // Paper - per chunk entity list
|
||||
this.entitySlices[k].add(entity);
|
||||
|
@ -42,7 +42,7 @@ index b855589d978d06e9883daff97c9e702d5a9461cc..9f0758aff6588736d500b6e202fc1a5f
|
|||
entity.entitySlice = this.entitySlices[k]; // Paper
|
||||
this.markDirty(); // Paper
|
||||
}
|
||||
@@ -567,6 +578,11 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -570,6 +581,11 @@ public class Chunk implements IChunkAccess {
|
||||
if (!this.entitySlices[i].remove(entity)) {
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ index b855589d978d06e9883daff97c9e702d5a9461cc..9f0758aff6588736d500b6e202fc1a5f
|
|||
entityCounts.decrement(entity.getMinecraftKeyString());
|
||||
this.markDirty(); // Paper
|
||||
// Paper end
|
||||
@@ -850,6 +866,14 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -853,6 +869,14 @@ public class Chunk implements IChunkAccess {
|
||||
for (int k = i; k <= j; ++k) {
|
||||
Iterator iterator = this.entitySlices[k].iterator(); // Spigot
|
||||
|
||||
|
@ -69,7 +69,7 @@ index b855589d978d06e9883daff97c9e702d5a9461cc..9f0758aff6588736d500b6e202fc1a5f
|
|||
while (iterator.hasNext()) {
|
||||
T entity = (T) iterator.next(); // CraftBukkit - decompile error
|
||||
if (entity.shouldBeRemoved) continue; // Paper
|
||||
@@ -869,9 +893,29 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -872,9 +896,29 @@ public class Chunk implements IChunkAccess {
|
||||
i = MathHelper.clamp(i, 0, this.entitySlices.length - 1);
|
||||
j = MathHelper.clamp(j, 0, this.entitySlices.length - 1);
|
||||
|
||||
|
|
|
@ -111,10 +111,10 @@ index a3a376e35eaf17b128048bd26a22eef713e7d535..3fcfe416d26808fa1c9bfdc5b413b149
|
|||
return this.d(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ());
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 9f0758aff6588736d500b6e202fc1a5f6a577e7f..2cb0005909e9a77d2bd594cab0a75b259882cadb 100644
|
||||
index af9a195f6d0f966133577d00d30e8b4ad812aaeb..cfdf6ea55dedeaf6b96566b72ca0015350c13e92 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -589,8 +589,8 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -592,8 +592,8 @@ public class Chunk implements IChunkAccess {
|
||||
this.entities.remove(entity); // Paper
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ index 9f0758aff6588736d500b6e202fc1a5f6a577e7f..2cb0005909e9a77d2bd594cab0a75b25
|
|||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
index eeb7eee925d31d1ed8e6bbd55888cb5ebe54afa2..64b625e988f6bb6dc7129b4cb70e266015ab0867 100644
|
||||
index c180d44bed91c86838d3be8c19be954b4412534e..4eb7c1a9b5afced4be79a263e6a918f39c4b51be 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
@@ -6,12 +6,14 @@ import javax.annotation.Nullable;
|
||||
|
@ -135,7 +135,7 @@ index eeb7eee925d31d1ed8e6bbd55888cb5ebe54afa2..64b625e988f6bb6dc7129b4cb70e2660
|
|||
public static final DataPalette<IBlockData> GLOBAL_PALETTE = new DataPaletteGlobal<>(Block.REGISTRY_ID, Blocks.AIR.getBlockData());
|
||||
- private final int yPos;
|
||||
+ final int yPos; // Paper - private -> package-private
|
||||
private short nonEmptyBlockCount;
|
||||
short nonEmptyBlockCount; // Paper - package-private
|
||||
- private short tickingBlockCount;
|
||||
+ short tickingBlockCount; // Paper - private -> package-private
|
||||
private short e;
|
||||
|
@ -253,7 +253,7 @@ index f9680b6830c77f31e1eb8b6845dd6d58d04f624a..a61cffa3f494be5fea785a573b0faf05
|
|||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
index abe86b4607e014e280e29daae6e1617763c53131..c9a13c865b332a5b6dbea9f23c00b0c9d66f3798 100644
|
||||
index a5ea0e34ec181ad9f98f9ee2f644c3ec1eb1cd3c..81362de5430f9cd045ee7cbefa4a28e4c6bc0457 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
@@ -278,6 +278,14 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
|
||||
|
@ -338,7 +338,7 @@ index 321eae23c575528788b1b575f17593580d6ba737..b19bbbbc81376177751396a2de9452ce
|
|||
|
||||
public final SoundEffectType getStepSound() { return this.r(); } // Paper - OBFHELPER
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index d8eb8a59da36215334582ae73822e1fd4a5b2df1..ac8b21e69b198612427a81a16fc1a3ff0b0cb558 100644
|
||||
index dab9d36dfcda6f363fb78ad6be6a0306786945ae..6f7da0a79bbbb2be354796033baa498845aaea7c 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -1564,10 +1564,19 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
|
|
|
@ -8,10 +8,10 @@ faster on its own, however removing the try catch makes it
|
|||
easier to inline due to code size
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 2cb0005909e9a77d2bd594cab0a75b259882cadb..234770236fdc8d37996fb8b7e0b4ed2491e31633 100644
|
||||
index cfdf6ea55dedeaf6b96566b72ca0015350c13e92..74d110874d0a9c1603d6b2d77753179ba49811ea 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -382,17 +382,20 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -385,17 +385,20 @@ public class Chunk implements IChunkAccess {
|
||||
}
|
||||
|
||||
public Fluid a(int i, int j, int k) {
|
||||
|
@ -39,7 +39,7 @@ index 2cb0005909e9a77d2bd594cab0a75b259882cadb..234770236fdc8d37996fb8b7e0b4ed24
|
|||
CrashReport crashreport = CrashReport.a(throwable, "Getting fluid state");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being got");
|
||||
|
||||
@@ -401,6 +404,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -404,6 +407,7 @@ public class Chunk implements IChunkAccess {
|
||||
});
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ index 2cb0005909e9a77d2bd594cab0a75b259882cadb..234770236fdc8d37996fb8b7e0b4ed24
|
|||
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
index 64b625e988f6bb6dc7129b4cb70e266015ab0867..b7b06e082e59f8518be2036637385c7710d524ea 100644
|
||||
index 4eb7c1a9b5afced4be79a263e6a918f39c4b51be..f6df85c6bf27bfa7a16967259a6016c9473201a5 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
|
||||
@@ -37,7 +37,7 @@ public class ChunkSection {
|
||||
|
|
|
@ -11,7 +11,7 @@ Less crammed entities are likely to show significantly less benefit.
|
|||
Effectively, this patch optimises crammed entity situations.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 234770236fdc8d37996fb8b7e0b4ed2491e31633..d73987ffc416f47eb6231013a76420bc71c34f0e 100644
|
||||
index 74d110874d0a9c1603d6b2d77753179ba49811ea..cf86ce24e12068d6ff7ae43cb1fd6fe665c24932 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -90,6 +90,54 @@ public class Chunk implements IChunkAccess {
|
||||
|
@ -69,7 +69,7 @@ index 234770236fdc8d37996fb8b7e0b4ed2491e31633..d73987ffc416f47eb6231013a76420bc
|
|||
public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeStorage biomestorage, ChunkConverter chunkconverter, TickList<Block> ticklist, TickList<FluidType> ticklist1, long i, @Nullable ChunkSection[] achunksection, @Nullable Consumer<Chunk> consumer) {
|
||||
this.sections = new ChunkSection[16];
|
||||
this.e = Maps.newHashMap();
|
||||
@@ -542,7 +590,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -545,7 +593,7 @@ public class Chunk implements IChunkAccess {
|
||||
entity.chunkY = k;
|
||||
entity.chunkZ = this.loc.z;
|
||||
this.entities.add(entity); // Paper - per chunk entity list
|
||||
|
@ -78,7 +78,7 @@ index 234770236fdc8d37996fb8b7e0b4ed2491e31633..d73987ffc416f47eb6231013a76420bc
|
|||
// Paper start
|
||||
if (entity instanceof EntityItem) {
|
||||
itemCounts[k]++;
|
||||
@@ -579,7 +627,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -582,7 +630,7 @@ public class Chunk implements IChunkAccess {
|
||||
entity.entitySlice = null;
|
||||
entity.inChunk = false;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ index 4157e50e4d99c029759bffcb48a8d645487554c8..5135308fb6137a34ed6fd061f0a210de
|
|||
|
||||
return stream.filter(axisalignedbb1::c).map(VoxelShapes::a);
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 42be4edb36200626913fa99b1e67956933022531..4dc03c27bba5cd2dd1d6cb2e82087ef834f41d81 100644
|
||||
index 8cf191ec7f7c825e3d0996b7e224956a569ab2ba..9f4268202653f6f0ebed49cd67ae691a8b18ccd2 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -1179,6 +1179,32 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
|
|
|
@ -63,7 +63,7 @@ index a3f919816eb2a742ed09b553995e6508684e5ea5..88277d23c36696fdd5363e41a130c9a4
|
|||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/LightEngineStorageArray.java b/src/main/java/net/minecraft/server/LightEngineStorageArray.java
|
||||
index b978723a66d001f70325df0c7521025e079d7cfa..d441c4e4744d68b3d934ca6034c32966e486327a 100644
|
||||
index b978723a66d001f70325df0c7521025e079d7cfa..53199595da71a25710bd1ff8ee2868ee63edc0e1 100644
|
||||
--- a/src/main/java/net/minecraft/server/LightEngineStorageArray.java
|
||||
+++ b/src/main/java/net/minecraft/server/LightEngineStorageArray.java
|
||||
@@ -8,10 +8,23 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||
|
@ -94,7 +94,7 @@ index b978723a66d001f70325df0c7521025e079d7cfa..d441c4e4744d68b3d934ca6034c32966
|
|||
this.c();
|
||||
this.d = true;
|
||||
}
|
||||
@@ -19,26 +32,32 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||
@@ -19,16 +32,17 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||
public abstract M b();
|
||||
|
||||
public void a(long i) {
|
||||
|
@ -112,34 +112,19 @@ index b978723a66d001f70325df0c7521025e079d7cfa..d441c4e4744d68b3d934ca6034c32966
|
|||
@Nullable
|
||||
- public NibbleArray c(long i) {
|
||||
+ public final NibbleArray c(long i) { // Paper - final
|
||||
+ // Paper start - remove cache - not thread safe
|
||||
+ /*
|
||||
if (this.d) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
if (i == this.b[j]) {
|
||||
return this.c[j];
|
||||
}
|
||||
@@ -37,7 +51,7 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||
}
|
||||
- }
|
||||
+ }*/
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
- NibbleArray nibblearray = (NibbleArray) this.a.get(i);
|
||||
+ return lookup.apply(i); // Paper - avoid copying light data
|
||||
+ NibbleArray nibblearray = lookup.apply(i); // Paper - avoid copying light data
|
||||
|
||||
+ // Paper start - remove cache - not thread safe
|
||||
+ /*
|
||||
if (nibblearray == null) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -53,24 +72,28 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||
}
|
||||
|
||||
return nibblearray;
|
||||
- }
|
||||
+ }*/
|
||||
+ // Paper end
|
||||
}
|
||||
@@ -58,11 +72,13 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||
|
||||
@Nullable
|
||||
public NibbleArray d(long i) {
|
||||
|
@ -155,13 +140,11 @@ index b978723a66d001f70325df0c7521025e079d7cfa..d441c4e4744d68b3d934ca6034c32966
|
|||
}
|
||||
|
||||
public void c() {
|
||||
+ /* // Paper - remove cache
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
@@ -70,7 +86,6 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||
this.b[i] = Long.MAX_VALUE;
|
||||
this.c[i] = null;
|
||||
}
|
||||
-
|
||||
+ */
|
||||
}
|
||||
|
||||
public void d() {
|
||||
|
|
|
@ -27,7 +27,7 @@ index e625842e524f18e469f7695b27d52d4d04892266..d752e793f13a9caf5d255293f7ce9d56
|
|||
|
||||
nbttaglist.add(nbttagcompound2);
|
||||
diff --git a/src/main/java/net/minecraft/server/LightEngineStorage.java b/src/main/java/net/minecraft/server/LightEngineStorage.java
|
||||
index 88277d23c36696fdd5363e41a130c9a443fac2c0..fa8039d38d5b3110fd85abf850248ba7948374c3 100644
|
||||
index 88277d23c36696fdd5363e41a130c9a443fac2c0..b0b7544592981bcff22c8acee7230a211918ef28 100644
|
||||
--- a/src/main/java/net/minecraft/server/LightEngineStorage.java
|
||||
+++ b/src/main/java/net/minecraft/server/LightEngineStorage.java
|
||||
@@ -148,7 +148,7 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
|
||||
|
@ -39,9 +39,12 @@ index 88277d23c36696fdd5363e41a130c9a443fac2c0..fa8039d38d5b3110fd85abf850248ba7
|
|||
}
|
||||
|
||||
protected void a(LightEngineLayer<?, ?> lightenginelayer, long i) {
|
||||
@@ -319,7 +319,7 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
|
||||
@@ -317,9 +317,9 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
|
||||
|
||||
protected void a(long i, @Nullable NibbleArray nibblearray) {
|
||||
if (nibblearray != null) {
|
||||
this.i.put(i, nibblearray);
|
||||
- this.i.put(i, nibblearray);
|
||||
+ NibbleArray remove = this.i.put(i, nibblearray); if (remove != null && remove.cleaner != null) remove.cleaner.run(); // Paper - clean up when removed
|
||||
} else {
|
||||
- this.i.remove(i);
|
||||
+ NibbleArray remove = this.i.remove(i); if (remove != null && remove.cleaner != null) remove.cleaner.run(); // Paper - clean up when removed
|
||||
|
@ -49,7 +52,7 @@ index 88277d23c36696fdd5363e41a130c9a443fac2c0..fa8039d38d5b3110fd85abf850248ba7
|
|||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/LightEngineStorageArray.java b/src/main/java/net/minecraft/server/LightEngineStorageArray.java
|
||||
index d441c4e4744d68b3d934ca6034c32966e486327a..cc6d3f000e2ea1c519cd0342a67b545fa9d71871 100644
|
||||
index 53199595da71a25710bd1ff8ee2868ee63edc0e1..d5702b22f06ba4ad787fe2fcf788c3d4d147c927 100644
|
||||
--- a/src/main/java/net/minecraft/server/LightEngineStorageArray.java
|
||||
+++ b/src/main/java/net/minecraft/server/LightEngineStorageArray.java
|
||||
@@ -33,7 +33,9 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||
|
@ -59,7 +62,7 @@ index d441c4e4744d68b3d934ca6034c32966e486327a..cc6d3f000e2ea1c519cd0342a67b545f
|
|||
- this.data.queueUpdate(i, ((NibbleArray) this.data.getUpdating(i)).b()); // Paper - avoid copying light data
|
||||
+ NibbleArray updating = this.data.getUpdating(i); // Paper - pool nibbles
|
||||
+ this.data.queueUpdate(i, new NibbleArray().markPoolSafe(updating.getCloneIfSet())); // Paper - avoid copying light data - pool safe clone
|
||||
+ if (updating.cleaner != null) updating.cleaner.run(); // Paper
|
||||
+ if (updating.cleaner != null) MCUtil.scheduleTask(2, updating.cleaner); // Paper - delay clean incase anything holding ref was still using it
|
||||
this.c();
|
||||
}
|
||||
|
||||
|
@ -241,7 +244,7 @@ index 67c960292db9d99ac85b5d0dda50ae48ef942c1b..5e3efa1fa6c089df35971ce5c83da384
|
|||
for (int i = 0; i < 16; ++i) {
|
||||
System.arraycopy(this.a, 0, abyte, i * 128, 128);
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutLightUpdate.java b/src/main/java/net/minecraft/server/PacketPlayOutLightUpdate.java
|
||||
index cd1ad45469aa163b9bc41774ae80adfa617fd97b..1946aae7424593100279834baa89c19f2522437f 100644
|
||||
index cd1ad45469aa163b9bc41774ae80adfa617fd97b..4b090757fceab6310f70ce34ba1041f890ddfd8f 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutLightUpdate.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutLightUpdate.java
|
||||
@@ -16,13 +16,42 @@ public class PacketPlayOutLightUpdate implements Packet<PacketListenerPlayOut> {
|
||||
|
@ -262,7 +265,7 @@ index cd1ad45469aa163b9bc41774ae80adfa617fd97b..1946aae7424593100279834baa89c19f
|
|||
+ public void onPacketDispatchFinish(EntityPlayer player, io.netty.channel.ChannelFuture future) {
|
||||
+ if (remainingSends.decrementAndGet() <= 0) {
|
||||
+ // incase of any race conditions, schedule this delayed
|
||||
+ MCUtil.scheduleTask(1, () -> {
|
||||
+ MCUtil.scheduleTask(5, () -> {
|
||||
+ if (remainingSends.get() == 0) {
|
||||
+ cleaner1.run();
|
||||
+ cleaner2.run();
|
||||
|
|
|
@ -3,58 +3,48 @@ From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
|||
Date: Mon, 27 Apr 2020 02:48:06 -0700
|
||||
Subject: [PATCH] Reduce MutableInt allocations from light engine
|
||||
|
||||
We can abuse the fact light is single threaded and share an instance
|
||||
per light engine instance
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/LightEngineBlock.java b/src/main/java/net/minecraft/server/LightEngineBlock.java
|
||||
index 93a972605c26aa757b9c915876f847da04fcb496..c9e91eb4ef538485620aedaee4843b779fede809 100644
|
||||
index 93a972605c26aa757b9c915876f847da04fcb496..07fadc21ee12138b52cc77c50da536fec5b032f5 100644
|
||||
--- a/src/main/java/net/minecraft/server/LightEngineBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/LightEngineBlock.java
|
||||
@@ -37,7 +37,10 @@ public final class LightEngineBlock extends LightEngineLayer<LightEngineStorageB
|
||||
@@ -6,6 +6,7 @@ public final class LightEngineBlock extends LightEngineLayer<LightEngineStorageB
|
||||
|
||||
private static final EnumDirection[] e = EnumDirection.values();
|
||||
private final BlockPosition.MutableBlockPosition f = new BlockPosition.MutableBlockPosition();
|
||||
+ private final MutableInt mutableint = new MutableInt(); // Paper
|
||||
|
||||
public LightEngineBlock(ILightAccess ilightaccess) {
|
||||
super(ilightaccess, EnumSkyBlock.BLOCK, new LightEngineStorageBlock(ilightaccess));
|
||||
@@ -37,7 +38,7 @@ public final class LightEngineBlock extends LightEngineLayer<LightEngineStorageB
|
||||
if (enumdirection == null) {
|
||||
return 15;
|
||||
} else {
|
||||
- MutableInt mutableint = new MutableInt();
|
||||
+ // Paper start - reduce mutableint allocations
|
||||
+ MutableInt mutableint = com.destroystokyo.paper.util.pooled.PooledObjects.POOLED_MUTABLE_INTEGERS.acquire();
|
||||
+ try {
|
||||
+ // Paper end - reduce mutableint allocations
|
||||
+ //MutableInt mutableint = new MutableInt(); // Paper - share mutableint, single threaded
|
||||
IBlockData iblockdata = this.a(j, mutableint);
|
||||
|
||||
if (mutableint.getValue() >= 15) {
|
||||
@@ -49,6 +52,10 @@ public final class LightEngineBlock extends LightEngineLayer<LightEngineStorageB
|
||||
|
||||
return VoxelShapes.b(voxelshape, voxelshape1) ? 15 : k + Math.max(1, mutableint.getValue());
|
||||
}
|
||||
+ } finally { // Paper start - reduce mutableint allocations
|
||||
+ com.destroystokyo.paper.util.pooled.PooledObjects.POOLED_MUTABLE_INTEGERS.release(mutableint);
|
||||
+ }
|
||||
+ // Paper end - reduce mutableint allocations
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/LightEngineSky.java b/src/main/java/net/minecraft/server/LightEngineSky.java
|
||||
index 2301a982e17ab9568e3da9ca84c4a024c7c1b214..57c2880ea23dc7ff55826858240bd13b7d3c24f2 100644
|
||||
index 2301a982e17ab9568e3da9ca84c4a024c7c1b214..f0b57784006752e031800a12a1a3c1a5945c636b 100644
|
||||
--- a/src/main/java/net/minecraft/server/LightEngineSky.java
|
||||
+++ b/src/main/java/net/minecraft/server/LightEngineSky.java
|
||||
@@ -27,7 +27,10 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
|
||||
@@ -6,6 +6,7 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
|
||||
|
||||
private static final EnumDirection[] e = EnumDirection.values();
|
||||
private static final EnumDirection[] f = new EnumDirection[]{EnumDirection.NORTH, EnumDirection.SOUTH, EnumDirection.WEST, EnumDirection.EAST};
|
||||
+ private final MutableInt mutableint = new MutableInt(); // Paper
|
||||
|
||||
public LightEngineSky(ILightAccess ilightaccess) {
|
||||
super(ilightaccess, EnumSkyBlock.SKY, new LightEngineStorageSky(ilightaccess));
|
||||
@@ -27,7 +28,7 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
|
||||
if (k >= 15) {
|
||||
return k;
|
||||
} else {
|
||||
- MutableInt mutableint = new MutableInt();
|
||||
+ // Paper start - reduce mutableint allocations
|
||||
+ MutableInt mutableint = com.destroystokyo.paper.util.pooled.PooledObjects.POOLED_MUTABLE_INTEGERS.acquire();
|
||||
+ try {
|
||||
+ // Paper end - reduce mutableint allocations
|
||||
+ //MutableInt mutableint = new MutableInt(); // Paper - share mutableint, single threaded
|
||||
IBlockData iblockdata = this.a(j, mutableint);
|
||||
|
||||
if (mutableint.getValue() >= 15) {
|
||||
@@ -85,6 +88,10 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
|
||||
|
||||
return flag1 && k == 0 && mutableint.getValue() == 0 ? 0 : k + Math.max(1, mutableint.getValue());
|
||||
}
|
||||
+ } finally { // Paper start - reduce mutableint allocations
|
||||
+ com.destroystokyo.paper.util.pooled.PooledObjects.POOLED_MUTABLE_INTEGERS.release(mutableint);
|
||||
+ }
|
||||
+ // Paper end - reduce mutableint allocations
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,32 +392,6 @@ index 07a6fc3d88e7d44bfab7f3d6a0eef7dc132ab422..c88177b77607519453bb349a8e960d22
|
|||
|
||||
for (int i = 0; i < this.inventory.getSize(); ++i) {
|
||||
ItemStack itemstack = this.inventory.getItem(i);
|
||||
diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||
index 8776799de033f02b0f87e9ea7e4a4ce912e94dd4..e16eac92d072cbb3a6a4934e336898f5b8ca0658 100644
|
||||
--- a/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||
+++ b/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||
@@ -134,7 +134,11 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
||||
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||
|
||||
ichunkaccess.b(false);
|
||||
- this.a(chunkcoordintpair.x, chunkcoordintpair.z, LightEngineThreaded.Update.PRE_UPDATE, SystemUtils.a(() -> {
|
||||
+ // Paper start
|
||||
+ IntSupplier defSupplier = this.d.c(chunkcoordintpair.pair());
|
||||
+ IntSupplier priority = () -> Math.max(defSupplier.getAsInt() - 1, 1);
|
||||
+ // Paper end
|
||||
+ this.a(chunkcoordintpair.x, chunkcoordintpair.z, priority, LightEngineThreaded.Update.PRE_UPDATE, SystemUtils.a(() -> { // Paper - boost light priority
|
||||
ChunkSection[] achunksection = ichunkaccess.getSections();
|
||||
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
@@ -161,7 +165,7 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
||||
super.b(chunkcoordintpair, false);
|
||||
return ichunkaccess;
|
||||
}, (runnable) -> {
|
||||
- this.a(chunkcoordintpair.x, chunkcoordintpair.z, LightEngineThreaded.Update.POST_UPDATE, runnable);
|
||||
+ this.a(chunkcoordintpair.x, chunkcoordintpair.z, priority, LightEngineThreaded.Update.POST_UPDATE, runnable); // Paper - boost light priority
|
||||
});
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
index 0d1065688b19ceca9440bc8bf2bf65910f03fa46..8a349964578e07e5ed13f801c57de68459220da9 100644
|
||||
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
||||
|
|
|
@ -0,0 +1,234 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 4 Jun 2020 02:24:49 -0400
|
||||
Subject: [PATCH] Optimize Bit Operations by inlining
|
||||
|
||||
Inline bit operations and reduce instruction count to make these hot
|
||||
operations faster
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
index 3bf17ccdaef21322b787db538d569e0bc614ef22..4c64798fbc50f4d8b08502ba865c5fde5c968e62 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -75,38 +75,34 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
|
||||
return dynamicops.createIntList(IntStream.of(new int[]{this.getX(), this.getY(), this.getZ()}));
|
||||
}
|
||||
|
||||
+ public static long getAdjacent(int baseX, int baseY, int baseZ, EnumDirection enumdirection) { return asLong(baseX + enumdirection.getAdjacentX(), baseY + enumdirection.getAdjacentY(), baseZ + enumdirection.getAdjacentZ()); } // Paper
|
||||
public static long a(long i, EnumDirection enumdirection) {
|
||||
return a(i, enumdirection.getAdjacentX(), enumdirection.getAdjacentY(), enumdirection.getAdjacentZ());
|
||||
}
|
||||
|
||||
public static long a(long i, int j, int k, int l) {
|
||||
- return a(b(i) + j, c(i) + k, d(i) + l);
|
||||
+ return a((int) (i >> 38) + j, (int) ((i << 52) >> 52) + k, (int) ((i << 26) >> 38) + l); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static int b(long i) {
|
||||
- return (int) (i << 64 - BlockPosition.k - BlockPosition.c >> 64 - BlockPosition.c);
|
||||
+ return (int) (i >> 38); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static int c(long i) {
|
||||
- return (int) (i << 64 - BlockPosition.f >> 64 - BlockPosition.f);
|
||||
+ return (int) ((i << 52) >> 52); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static int d(long i) {
|
||||
- return (int) (i << 64 - BlockPosition.j - BlockPosition.d >> 64 - BlockPosition.d);
|
||||
+ return (int) ((i << 26) >> 38); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static BlockPosition fromLong(long i) {
|
||||
- return new BlockPosition(b(i), c(i), d(i));
|
||||
+ return new BlockPosition((int) (i >> 38), (int) ((i << 52) >> 52), (int) ((i << 26) >> 38)); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static long asLong(int x, int y, int z) { return a(x, y, z); } // Paper - OBFHELPER
|
||||
public static long a(int i, int j, int k) {
|
||||
- long l = 0L;
|
||||
-
|
||||
- l |= ((long) i & BlockPosition.g) << BlockPosition.k;
|
||||
- l |= ((long) j & BlockPosition.h) << 0;
|
||||
- l |= ((long) k & BlockPosition.i) << BlockPosition.j;
|
||||
- return l;
|
||||
+ return (((long) i & (long) 67108863) << 38) | (((long) j & (long) 4095)) | (((long) k & (long) 67108863) << 12); // Paper - inline constants and simplify
|
||||
}
|
||||
|
||||
public static long f(long i) {
|
||||
diff --git a/src/main/java/net/minecraft/server/SectionPosition.java b/src/main/java/net/minecraft/server/SectionPosition.java
|
||||
index ca3f63f5e5e4e926de562b4bfbbf72ad8a6b943f..c415736282de6d4d0f87135c24999c4bbf993901 100644
|
||||
--- a/src/main/java/net/minecraft/server/SectionPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/SectionPosition.java
|
||||
@@ -16,7 +16,7 @@ public class SectionPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public static SectionPosition a(BlockPosition blockposition) {
|
||||
- return new SectionPosition(a(blockposition.getX()), a(blockposition.getY()), a(blockposition.getZ()));
|
||||
+ return new SectionPosition(blockposition.getX() >> 4, blockposition.getY() >> 4, blockposition.getZ() >> 4); // Paper
|
||||
}
|
||||
|
||||
public static SectionPosition a(ChunkCoordIntPair chunkcoordintpair, int i) {
|
||||
@@ -28,7 +28,7 @@ public class SectionPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public static SectionPosition a(long i) {
|
||||
- return new SectionPosition(b(i), c(i), d(i));
|
||||
+ return new SectionPosition((int) (i >> 42), (int) (i << 44 >> 44), (int) (i << 22 >> 42)); // Paper
|
||||
}
|
||||
|
||||
public static long a(long i, EnumDirection enumdirection) {
|
||||
@@ -36,7 +36,7 @@ public class SectionPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public static long a(long i, int j, int k, int l) {
|
||||
- return b(b(i) + j, c(i) + k, d(i) + l);
|
||||
+ return (((long) ((int) (i >> 42) + j) & 4194303L) << 42) | (((long) ((int) (i << 44 >> 44) + k) & 1048575L)) | (((long) ((int) (i << 22 >> 42) + l) & 4194303L) << 20); // Simplify to reduce instruction count
|
||||
}
|
||||
|
||||
public static int a(int i) {
|
||||
@@ -48,11 +48,7 @@ public class SectionPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public static short b(BlockPosition blockposition) {
|
||||
- int i = b(blockposition.getX());
|
||||
- int j = b(blockposition.getY());
|
||||
- int k = b(blockposition.getZ());
|
||||
-
|
||||
- return (short) (i << 8 | k << 4 | j);
|
||||
+ return (short) ((blockposition.x & 15) << 8 | (blockposition.z & 15) << 4 | blockposition.y & 15); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static int c(int i) {
|
||||
@@ -60,7 +56,7 @@ public class SectionPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public static int b(long i) {
|
||||
- return (int) (i << 0 >> 42);
|
||||
+ return (int) (i >> 42); // Paper
|
||||
}
|
||||
|
||||
public static int c(long i) {
|
||||
@@ -71,44 +67,46 @@ public class SectionPosition extends BaseBlockPosition {
|
||||
return (int) (i << 22 >> 42);
|
||||
}
|
||||
|
||||
- public int a() {
|
||||
- return this.getX();
|
||||
+ public final int a() { // Paper
|
||||
+ return x; // Paper
|
||||
}
|
||||
|
||||
- public int b() {
|
||||
- return this.getY();
|
||||
+ public final int b() { // Paper
|
||||
+ return y; // Paper
|
||||
}
|
||||
|
||||
- public int c() {
|
||||
- return this.getZ();
|
||||
+ public final int c() { // Paper
|
||||
+ return z; // Paper
|
||||
}
|
||||
|
||||
- public int d() {
|
||||
- return this.a() << 4;
|
||||
+ public final int d() { // Paper
|
||||
+ return x << 4; // Paper
|
||||
}
|
||||
|
||||
- public int e() {
|
||||
- return this.b() << 4;
|
||||
+ public final int e() { // Paper
|
||||
+ return y << 4; // Paper
|
||||
}
|
||||
|
||||
- public int f() {
|
||||
- return this.c() << 4;
|
||||
+ public final int f() { // Paper
|
||||
+ return z << 4; // Paper
|
||||
}
|
||||
|
||||
- public int g() {
|
||||
- return (this.a() << 4) + 15;
|
||||
+ public final int g() { // Paper
|
||||
+ return (x << 4) + 15; // Paper
|
||||
}
|
||||
|
||||
- public int h() {
|
||||
- return (this.b() << 4) + 15;
|
||||
+ public final int h() { // Paper
|
||||
+ return (y << 4) + 15; // Paper
|
||||
}
|
||||
|
||||
- public int r() {
|
||||
- return (this.c() << 4) + 15;
|
||||
+ public final int r() { // Paper
|
||||
+ return (z << 4) + 15; // Paper
|
||||
}
|
||||
|
||||
+ public static long blockToSection(long i) { return e(i); } // Paper - OBFHELPER
|
||||
public static long e(long i) {
|
||||
- return b(a(BlockPosition.b(i)), a(BlockPosition.c(i)), a(BlockPosition.d(i)));
|
||||
+ // b(a(BlockPosition.b(i)), a(BlockPosition.c(i)), a(BlockPosition.d(i)));
|
||||
+ return (((long) (int) (i >> 42) & 4194303L) << 42) | (((long) (int) ((i << 52) >> 56) & 1048575L)) | (((long) (int) ((i << 26) >> 42) & 4194303L) << 20); // Simplify to reduce instruction count
|
||||
}
|
||||
|
||||
public static long f(long i) {
|
||||
@@ -116,7 +114,7 @@ public class SectionPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public BlockPosition s() {
|
||||
- return new BlockPosition(c(this.a()), c(this.b()), c(this.c()));
|
||||
+ return new BlockPosition(x << 4, y << 4, z << 4); // Paper
|
||||
}
|
||||
|
||||
public BlockPosition t() {
|
||||
@@ -129,36 +127,30 @@ public class SectionPosition extends BaseBlockPosition {
|
||||
return new ChunkCoordIntPair(this.a(), this.c());
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static long blockPosAsSectionLong(int i, int j, int k) {
|
||||
+ return (((long) (i >> 4) & 4194303L) << 42) | (((long) (j >> 4) & 1048575L)) | (((long) (k >> 4) & 4194303L) << 20);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ public static long asLong(int i, int j, int k) { return b(i, j, k); } // Paper - OBFHELPER
|
||||
public static long b(int i, int j, int k) {
|
||||
- long l = 0L;
|
||||
-
|
||||
- l |= ((long) i & 4194303L) << 42;
|
||||
- l |= ((long) j & 1048575L) << 0;
|
||||
- l |= ((long) k & 4194303L) << 20;
|
||||
- return l;
|
||||
+ return (((long) i & 4194303L) << 42) | (((long) j & 1048575L)) | (((long) k & 4194303L) << 20); // Paper - Simplify to reduce instruction count
|
||||
}
|
||||
|
||||
public long v() {
|
||||
- return b(this.a(), this.b(), this.c());
|
||||
+ return (((long) x & 4194303L) << 42) | (((long) y & 1048575L)) | (((long) z & 4194303L) << 20); // Paper - Simplify to reduce instruction count
|
||||
}
|
||||
|
||||
public Stream<BlockPosition> w() {
|
||||
- return BlockPosition.a(this.d(), this.e(), this.f(), this.g(), this.h(), this.r());
|
||||
+ return BlockPosition.a(x << 4, y << 4, z << 4, (x << 4) + 15, (y << 4) + 15, (z << 4) + 15); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static Stream<SectionPosition> a(SectionPosition sectionposition, int i) {
|
||||
- int j = sectionposition.a();
|
||||
- int k = sectionposition.b();
|
||||
- int l = sectionposition.c();
|
||||
-
|
||||
- return a(j - i, k - i, l - i, j + i, k + i, l + i);
|
||||
+ return a(sectionposition.x - i, sectionposition.y - i, sectionposition.z - i, sectionposition.x + i, sectionposition.y + i, sectionposition.z + i); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static Stream<SectionPosition> b(ChunkCoordIntPair chunkcoordintpair, int i) {
|
||||
- int j = chunkcoordintpair.x;
|
||||
- int k = chunkcoordintpair.z;
|
||||
-
|
||||
- return a(j - i, 0, k - i, j + i, 15, k + i);
|
||||
+ return a(chunkcoordintpair.x - i, 0, chunkcoordintpair.z - i, chunkcoordintpair.x + i, 15, chunkcoordintpair.z + i); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static Stream<SectionPosition> a(final int i, final int j, final int k, final int l, final int i1, final int j1) {
|
1213
Spigot-Server-Patches/0538-Optimize-Light-Engine.patch
Normal file
1213
Spigot-Server-Patches/0538-Optimize-Light-Engine.patch
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue