mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-15 07:01:36 +08:00
5c7081fecc
* Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories CraftBukkit Changes:4090d01f
SPIGOT-5047: Correct slot types for 1.14 inventoriese8c08362
SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.d445af3b
SPIGOT-5067: Add item meta for 1.14 spawn eggs * Bring Chunk load checks in-line with spigot As of the last upstream merge spigot now checks ticket level status when returning loaded chunks for a world from api. Now our checks will respect that decision. * Fix spawn ticket levels Vanilla would keep the inner chunks of spawn available for ticking, however my changes made all chunks non-ticking. Resolve by changing ticket levels for spawn chunks inside the border to respect this behavior. * Make World#getChunkIfLoadedImmediately return only entity ticking chunks Mojang appears to be using chunks with level > 33 (non-ticking chunks) as cached chunks and not actually loaded chunks. * Bring all loaded checks in line with spigot Loaded chunks must be at least border chunks, or level <= 33
121 lines
5.2 KiB
Diff
121 lines
5.2 KiB
Diff
From 1e467dc2623f673dff4cf5fe4849bdef81bc2ac4 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
|
|
|
|
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 2852a17f23..7cb46d7a9c 100644
|
|
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
@@ -10,6 +10,14 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
|
private final int a;
|
|
private final int b;
|
|
private final int c;
|
|
+ // Paper start
|
|
+ public boolean isValidLocation() {
|
|
+ return a >= -30000000 && c >= -30000000 && a < 30000000 && c < 30000000 && b >= 0 && b < 256;
|
|
+ }
|
|
+ public boolean isInvalidYLocation() {
|
|
+ return b < 0 || b >= 256;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public BaseBlockPosition(int i, int j, int k) {
|
|
this.a = i;
|
|
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
index b56a044b3a..edd60a3d7f 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
@@ -339,6 +339,16 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
|
|
protected int b;
|
|
protected int c;
|
|
protected int d;
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public boolean isValidLocation() {
|
|
+ return b >= -30000000 && d >= -30000000 && b < 30000000 && d < 30000000 && c >= 0 && c < 256;
|
|
+ }
|
|
+ @Override
|
|
+ public boolean isInvalidYLocation() {
|
|
+ return c < 0 || c >= 256;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public MutableBlockPosition() {
|
|
this(0, 0, 0);
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
|
index fba176745f..d06e8dbc11 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -203,12 +203,24 @@ 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 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);
|
|
+ }
|
|
+ return Blocks.AIR.getBlockData();
|
|
+ }
|
|
+
|
|
+ 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/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
|
|
index 30701fd7f3..43f75fc837 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;
|
|
private short tickingBlockCount;
|
|
private short e;
|
|
- private final DataPaletteBlock<IBlockData> blockIds;
|
|
+ final DataPaletteBlock<IBlockData> blockIds; // Paper - package
|
|
|
|
public ChunkSection(int i) {
|
|
this(i, (short) 0, (short) 0, (short) 0);
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index f06b7047a0..4ec6a860d5 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -197,11 +197,11 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
|
|
}
|
|
|
|
public static boolean isValidLocation(BlockPosition blockposition) {
|
|
- return !isOutsideWorld(blockposition) && blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000;
|
|
+ return blockposition.isValidLocation(); // Paper
|
|
}
|
|
|
|
public static boolean isOutsideWorld(BlockPosition blockposition) {
|
|
- return b(blockposition.getY());
|
|
+ return blockposition.isInvalidYLocation(); // Paper
|
|
}
|
|
|
|
public static boolean b(int i) {
|
|
--
|
|
2.21.0
|
|
|