mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
57dd397155
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: b999860d SPIGOT-2304: Add LootGenerateEvent CraftBukkit Changes:77fd87e4
SPIGOT-2304: Implement LootGenerateEventa1a705ee
SPIGOT-5566: Doused campfires & fires should call EntityChangeBlockEvent41712edd
SPIGOT-5707: PersistentDataHolder not Persistent on API dropped Item
102 lines
4.4 KiB
Diff
102 lines
4.4 KiB
Diff
From 6a84b31821280f6e8e2fdf3083bd6cc4b6ebf45a Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Wed, 15 Aug 2018 12:05:12 -0700
|
|
Subject: [PATCH] Optimize BlockPosition helper methods
|
|
|
|
Resolves #1338
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
index e9ea232a78..e76528f199 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
@@ -134,57 +134,74 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
|
|
}
|
|
|
|
public BlockPosition up() {
|
|
- return this.shift(EnumDirection.UP);
|
|
+ return new BlockPosition(this.getX(), this.getY() + 1, this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition up(int i) {
|
|
- return this.shift(EnumDirection.UP, i);
|
|
+ return i == 0 ? this : new BlockPosition(this.getX(), this.getY() + i, this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
@Override
|
|
public BlockPosition down() {
|
|
- return this.shift(EnumDirection.DOWN);
|
|
+ return new BlockPosition(this.getX(), this.getY() - 1, this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
@Override
|
|
public BlockPosition down(int i) {
|
|
- return this.shift(EnumDirection.DOWN, i);
|
|
+ return i == 0 ? this : new BlockPosition(this.getX(), this.getY() - i, this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition north() {
|
|
- return this.shift(EnumDirection.NORTH);
|
|
+ return new BlockPosition(this.getX(), this.getY(), this.getZ() - 1); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition north(int i) {
|
|
- return this.shift(EnumDirection.NORTH, i);
|
|
+ return i == 0 ? this : new BlockPosition(this.getX(), this.getY(), this.getZ() - i); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition south() {
|
|
- return this.shift(EnumDirection.SOUTH);
|
|
+ return new BlockPosition(this.getX(), this.getY(), this.getZ() + 1); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition south(int i) {
|
|
- return this.shift(EnumDirection.SOUTH, i);
|
|
+ return i == 0 ? this : new BlockPosition(this.getX(), this.getY(), this.getZ() + i); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition west() {
|
|
- return this.shift(EnumDirection.WEST);
|
|
+ return new BlockPosition(this.getX() - 1, this.getY(), this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition west(int i) {
|
|
- return this.shift(EnumDirection.WEST, i);
|
|
+ return i == 0 ? this : new BlockPosition(this.getX() - i, this.getY(), this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition east() {
|
|
- return this.shift(EnumDirection.EAST);
|
|
+ return new BlockPosition(this.getX() + 1, this.getY(), this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition east(int i) {
|
|
- return this.shift(EnumDirection.EAST, i);
|
|
+ return i == 0 ? this : new BlockPosition(this.getX() + i, this.getY(), this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
public BlockPosition shift(EnumDirection enumdirection) {
|
|
- return new BlockPosition(this.getX() + enumdirection.getAdjacentX(), this.getY() + enumdirection.getAdjacentY(), this.getZ() + enumdirection.getAdjacentZ());
|
|
+ // Paper Start - Optimize BlockPosition
|
|
+ switch(enumdirection) {
|
|
+ case UP:
|
|
+ return new BlockPosition(this.getX(), this.getY() + 1, this.getZ());
|
|
+ case DOWN:
|
|
+ return new BlockPosition(this.getX(), this.getY() - 1, this.getZ());
|
|
+ case NORTH:
|
|
+ return new BlockPosition(this.getX(), this.getY(), this.getZ() - 1);
|
|
+ case SOUTH:
|
|
+ return new BlockPosition(this.getX(), this.getY(), this.getZ() + 1);
|
|
+ case WEST:
|
|
+ return new BlockPosition(this.getX() - 1, this.getY(), this.getZ());
|
|
+ case EAST:
|
|
+ return new BlockPosition(this.getX() + 1, this.getY(), this.getZ());
|
|
+ default:
|
|
+ return new BlockPosition(this.getX() + enumdirection.getAdjacentX(), this.getY() + enumdirection.getAdjacentY(), this.getZ() + enumdirection.getAdjacentZ());
|
|
+ }
|
|
+ // Paper End
|
|
}
|
|
|
|
@Override
|
|
--
|
|
2.26.2
|
|
|