geforkt von Mirrors/Paper
b68b282439
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 Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes:c4a67eed
SPIGOT-4556: Fix plugins closing inventory during drop events5be2ddcb
Replace version constants with methods to prevent compiler inlininga5b9c7b3
Use API method to create offset command completions2bc7d1df
SPIGOT-3747: Add API for force loaded chunksa408f375
SPIGOT-3538: Add getHitBlockFace for ProjectileHitEventb54b9409
SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock79ded7a8
SPIGOT-1811: Death message not shown on respawn screenb4a4f15d
SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory0afed592
SPIGOT-794: Call EntityPlaceEvent for Minecart placement2b2d084a
Add InventoryView#getSlotType01a9959a
Do not use deprecated ItemSpawnEvent constructor9642498d
SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event963f4a5f
Add PlayerItemDamageEvent63db0445
Add API to get / set base arrow damage531c25d7
Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS pluginsd05c8b14
Mappings Updatebd36e200
SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
206 Zeilen
9.8 KiB
Diff
206 Zeilen
9.8 KiB
Diff
From 7ed9ceeb7d35c46ef914426bf9944bd1dda34c57 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 5843ef65a..4c7793f86 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 75a0f1386..507c93804 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
@@ -300,6 +300,16 @@ public class BlockPosition extends BaseBlockPosition {
|
|
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 dcb036f31..182a637ad 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -425,12 +425,24 @@ public class Chunk implements IChunkAccess {
|
|
return this.getBlockData(i, j, k).b(this.world, new BlockPosition(i, j, k));
|
|
}
|
|
|
|
- public IBlockData getBlockData(BlockPosition blockposition) { return getType(blockposition); } // Paper
|
|
- public IBlockData getType(BlockPosition blockposition) {
|
|
+ // Paper start - Optimize getBlockData to reduce instructions
|
|
+ public final IBlockData getBlockData(BlockPosition pos) { return getBlockData(pos.getX(), pos.getY(), pos.getZ()); } // Paper
|
|
+ public final IBlockData getType(BlockPosition blockposition) {
|
|
return this.getBlockData(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
}
|
|
|
|
- public IBlockData getBlockData(int i, int j, int k) {
|
|
+ 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.S() == 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 3c5f10ad4..621ed1fc5 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkSection.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
|
|
@@ -7,7 +7,7 @@ public class ChunkSection {
|
|
private int nonEmptyBlockCount;
|
|
private int tickingBlockCount;
|
|
private int e;
|
|
- private final DataPaletteBlock<IBlockData> blockIds;
|
|
+ final DataPaletteBlock<IBlockData> blockIds; // Paper - package
|
|
private NibbleArray emittedLight;
|
|
private NibbleArray skyLight;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 96442ad7d..502738b90 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -258,11 +258,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
}
|
|
|
|
public static boolean isValidLocation(BlockPosition blockposition) {
|
|
- return !k(blockposition) && blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000;
|
|
+ return blockposition.isValidLocation(); // Paper
|
|
}
|
|
|
|
public static boolean k(BlockPosition blockposition) {
|
|
- return blockposition.getY() < 0 || blockposition.getY() >= 256;
|
|
+ return blockposition.isInvalidYLocation(); // Paper
|
|
}
|
|
|
|
public boolean isEmpty(BlockPosition blockposition) {
|
|
@@ -279,7 +279,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
// test if meets light level, return faster
|
|
// logic copied from below
|
|
public boolean isLightLevel(BlockPosition blockposition, int level) {
|
|
- if (isValidLocation(blockposition)) {
|
|
+ if (blockposition.isValidLocation()) {
|
|
if (this.getType(blockposition).c(this, blockposition)) {
|
|
int sky = getSkylightSubtracted();
|
|
if (this.getLightLevel(blockposition.up(), sky) >= level) {
|
|
@@ -326,7 +326,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
// CraftBukkit end
|
|
Chunk chunk = this.getChunkIfLoaded(blockposition);
|
|
if (chunk != null) {
|
|
- return isValidLocation(blockposition) ? chunk.getBlockData(blockposition) : Blocks.AIR.getBlockData();
|
|
+ return blockposition.isValidLocation() ? chunk.getBlockData(blockposition) : Blocks.AIR.getBlockData(); // Paper
|
|
}
|
|
return null;
|
|
}
|
|
@@ -381,7 +381,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
return true;
|
|
}
|
|
// CraftBukkit end
|
|
- if (k(blockposition)) {
|
|
+ if (blockposition.isInvalidYLocation()) { // Paper
|
|
return false;
|
|
} else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
|
|
return false;
|
|
@@ -702,11 +702,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
blockposition = new BlockPosition(blockposition.getX(), 0, blockposition.getZ());
|
|
}
|
|
|
|
- return !isValidLocation(blockposition) ? enumskyblock.c : (!this.isLoaded(blockposition) ? enumskyblock.c : this.getChunkAtWorldCoords(blockposition).getBrightness(enumskyblock, blockposition));
|
|
+ return !blockposition.isValidLocation() ? enumskyblock.c : (!this.isLoaded(blockposition) ? enumskyblock.c : this.getChunkAtWorldCoords(blockposition).getBrightness(enumskyblock, blockposition)); // Paper
|
|
}
|
|
|
|
public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) {
|
|
- if (isValidLocation(blockposition)) {
|
|
+ if (blockposition.isValidLocation()) { // Paper
|
|
if (this.isLoaded(blockposition)) {
|
|
this.getChunkAtWorldCoords(blockposition).a(enumskyblock, blockposition, i);
|
|
this.m(blockposition);
|
|
@@ -733,7 +733,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
}
|
|
}
|
|
// CraftBukkit end
|
|
- if (k(blockposition)) {
|
|
+ if (blockposition.isInvalidYLocation()) { // Paper
|
|
return Blocks.VOID_AIR.getBlockData();
|
|
} else {
|
|
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
|
|
@@ -743,7 +743,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
}
|
|
|
|
public Fluid getFluid(BlockPosition blockposition) {
|
|
- if (k(blockposition)) {
|
|
+ if (blockposition.isInvalidYLocation()) { // Paper
|
|
return FluidTypes.EMPTY.i();
|
|
} else {
|
|
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
|
|
@@ -1761,7 +1761,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
public Map<BlockPosition, TileEntity> capturedTileEntities = Maps.newHashMap();
|
|
@Nullable
|
|
public TileEntity getTileEntity(BlockPosition blockposition) {
|
|
- if (k(blockposition)) {
|
|
+ if (blockposition.isInvalidYLocation()) { // Paper
|
|
return null;
|
|
} else {
|
|
// CraftBukkit start
|
|
@@ -1802,7 +1802,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
}
|
|
|
|
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
|
|
- if (!k(blockposition)) {
|
|
+ if (!blockposition.isInvalidYLocation()) { // Paper
|
|
if (tileentity != null && !tileentity.x()) {
|
|
// CraftBukkit start
|
|
if (captureBlockStates) {
|
|
@@ -1863,7 +1863,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
}
|
|
|
|
public boolean p(BlockPosition blockposition) {
|
|
- if (k(blockposition)) {
|
|
+ if (blockposition.isInvalidYLocation()) { // Paper
|
|
return false;
|
|
} else {
|
|
Chunk chunk = this.chunkProvider.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4, false, false);
|
|
--
|
|
2.20.1
|
|
|