testserver/Spigot-Server-Patches/0100-Optimize-isValidLocati...

80 lines
3.6 KiB
Diff

From e678b0cd49904fd62192a607e2444dd4c8eae5d4 Mon Sep 17 00:00:00 2001
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
index d60e755..9114388 100644
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
@@ -10,6 +10,11 @@ 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;
+ }
+ // Paper end
public BaseBlockPosition(int i, int j, int k) {
this.a = i;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 3bdf072..ecf3a38 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -274,8 +274,8 @@ public abstract class World implements IBlockAccess {
return this.getType(blockposition1);
}
- private boolean isValidLocation(BlockPosition blockposition) {
- return !this.E(blockposition) && blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000;
+ private static boolean isValidLocation(BlockPosition blockposition) { // Paper
+ return blockposition.isValidLocation(); // Paper
}
private boolean E(BlockPosition blockposition) {
@@ -649,7 +649,7 @@ public abstract class World implements IBlockAccess {
// 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;
@@ -763,7 +763,7 @@ public abstract class World implements IBlockAccess {
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;
@@ -775,7 +775,7 @@ public abstract class World implements IBlockAccess {
}
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);
@@ -811,7 +811,7 @@ public abstract class World implements IBlockAccess {
// 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;
}
--
2.8.2