2016-04-02 04:08:40 +02:00
|
|
|
From eaa70396911818f37f9a29242382e293a28e2828 Mon Sep 17 00:00:00 2001
|
2016-03-23 04:44:46 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Tue, 22 Mar 2016 23:41:34 -0400
|
|
|
|
Subject: [PATCH] Optimize isValidLocation for inlining
|
|
|
|
|
|
|
|
Move test to the blockPosition class so that it can access local variables.
|
|
|
|
|
|
|
|
Replace all calls to the new place to the unnecessary forward.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
2016-03-31 02:50:23 +02:00
|
|
|
index c5b6a34..17bbfb0 100644
|
2016-03-23 04:44:46 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
|
|
@@ -9,6 +9,9 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
|
|
|
protected int a;
|
|
|
|
protected int c;
|
|
|
|
protected int d;
|
|
|
|
+ public boolean isValidLocation() {
|
|
|
|
+ return a >= -30000000 && d >= -30000000 && a < 30000000 && d < 30000000 && c >= 0 && c < 256;
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
public BaseBlockPosition(int i, int j, int k) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2016-04-01 06:35:44 +02:00
|
|
|
index c1cb133..1a9a847 100644
|
2016-03-23 04:44:46 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -278,8 +278,8 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
return this.getType(blockposition1);
|
|
|
|
}
|
|
|
|
|
|
|
|
- private boolean isValidLocation(BlockPosition blockposition) {
|
|
|
|
- return blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000 && blockposition.getY() >= 0 && blockposition.getY() < 256;
|
|
|
|
+ private static boolean isValidLocation(BlockPosition blockposition) { // Paper
|
|
|
|
+ return blockposition.isValidLocation(); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEmpty(BlockPosition blockposition) {
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -291,7 +291,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(BlockPosition blockposition, boolean flag) {
|
|
|
|
- return !this.isValidLocation(blockposition) ? false : this.isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4, flag);
|
|
|
|
+ return !blockposition.isValidLocation() ? false : this.isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4, flag); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean areChunksLoaded(BlockPosition blockposition, int i) {
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -371,7 +371,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
- if (!this.isValidLocation(blockposition)) {
|
|
|
|
+ if (!blockposition.isValidLocation()) { // Paper
|
|
|
|
return false;
|
|
|
|
} else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
|
|
|
|
return false;
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -649,7 +649,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
// Paper start - 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).f()) {
|
|
|
|
if (this.c(blockposition.up(), false) >= level) {
|
|
|
|
return true;
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -762,7 +762,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
blockposition = new BlockPosition(blockposition.getX(), 0, blockposition.getZ());
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (!this.isValidLocation(blockposition)) {
|
|
|
|
+ if (!blockposition.isValidLocation()) { // Paper
|
|
|
|
return enumskyblock.c;
|
|
|
|
} else if (!this.isLoaded(blockposition)) {
|
|
|
|
return enumskyblock.c;
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -774,7 +774,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) {
|
|
|
|
- if (this.isValidLocation(blockposition)) {
|
|
|
|
+ if (blockposition.isValidLocation()) { // Paper
|
|
|
|
if (this.isLoaded(blockposition)) {
|
|
|
|
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
|
|
|
|
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -810,7 +810,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
Chunk chunk = this.getChunkIfLoaded(blockposition);
|
|
|
|
if (chunk != null) {
|
|
|
|
- return this.isValidLocation(blockposition) ? chunk.getBlockData(blockposition) : Blocks.AIR.getBlockData();
|
|
|
|
+ return blockposition.isValidLocation() ? chunk.getBlockData(blockposition) : Blocks.AIR.getBlockData();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -828,7 +828,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
- if (!this.isValidLocation(blockposition)) {
|
|
|
|
+ if (!blockposition.isValidLocation()) { // Paper
|
|
|
|
return Blocks.AIR.getBlockData();
|
|
|
|
} else {
|
|
|
|
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -2057,7 +2057,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
public Map<BlockPosition, TileEntity> capturedTileEntities = Maps.newHashMap();
|
|
|
|
|
|
|
|
public TileEntity getTileEntity(BlockPosition blockposition) {
|
|
|
|
- if (!this.isValidLocation(blockposition)) {
|
|
|
|
+ if (!blockposition.isValidLocation()) { // Paper
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
// CraftBukkit start
|
2016-04-01 06:35:44 +02:00
|
|
|
@@ -2160,7 +2160,7 @@ public abstract class World implements IBlockAccess {
|
2016-03-23 04:44:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean d(BlockPosition blockposition, boolean flag) {
|
|
|
|
- if (!this.isValidLocation(blockposition)) {
|
|
|
|
+ if (!blockposition.isValidLocation()) { // Paper
|
|
|
|
return flag;
|
|
|
|
} else {
|
|
|
|
Chunk chunk = this.chunkProvider.getLoadedChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
|
|
--
|
2016-03-31 02:50:23 +02:00
|
|
|
2.8.0
|
2016-03-23 04:44:46 +01:00
|
|
|
|