Rebase fixups

This commit is contained in:
Spottedleaf 2024-10-25 12:24:15 -07:00
parent 62e3bcdc3b
commit b711764991
90 changed files with 3448 additions and 10434 deletions

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Optimize BlockPosition helper methods
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
index 83e7c141d947f8f8096fed1da716560494bc5c62..eea8bea0f40db8d36c59e628babf788fa920df94 100644
index 83e7c141d947f8f8096fed1da716560494bc5c62..8e00fd1a1fb0d73e800395f4b9fffdbdb6c6b5cb 100644
--- a/src/main/java/net/minecraft/core/BlockPos.java
+++ b/src/main/java/net/minecraft/core/BlockPos.java
@@ -157,67 +157,84 @@ public class BlockPos extends Vec3i {
@ -19,7 +19,7 @@ index 83e7c141d947f8f8096fed1da716560494bc5c62..eea8bea0f40db8d36c59e628babf788f
@Override
public BlockPos above(int distance) {
- return this.relative(Direction.UP, distance);
+ return distance == 0 ? this : new BlockPos(this.getX(), this.getY() + distance, this.getZ()); // Paper - Perf: Optimize BlockPosition
+ return distance == 0 ? this.immutable() : new BlockPos(this.getX(), this.getY() + distance, this.getZ()); // Paper - Perf: Optimize BlockPosition
}
@Override
@ -31,7 +31,7 @@ index 83e7c141d947f8f8096fed1da716560494bc5c62..eea8bea0f40db8d36c59e628babf788f
@Override
public BlockPos below(int i) {
- return this.relative(Direction.DOWN, i);
+ return i == 0 ? this : new BlockPos(this.getX(), this.getY() - i, this.getZ()); // Paper - Perf: Optimize BlockPosition
+ return i == 0 ? this.immutable() : new BlockPos(this.getX(), this.getY() - i, this.getZ()); // Paper - Perf: Optimize BlockPosition
}
@Override
@ -43,7 +43,7 @@ index 83e7c141d947f8f8096fed1da716560494bc5c62..eea8bea0f40db8d36c59e628babf788f
@Override
public BlockPos north(int distance) {
- return this.relative(Direction.NORTH, distance);
+ return distance == 0 ? this : new BlockPos(this.getX(), this.getY(), this.getZ() - distance); // Paper - Perf: Optimize BlockPosition
+ return distance == 0 ? this.immutable() : new BlockPos(this.getX(), this.getY(), this.getZ() - distance); // Paper - Perf: Optimize BlockPosition
}
@Override
@ -55,7 +55,7 @@ index 83e7c141d947f8f8096fed1da716560494bc5c62..eea8bea0f40db8d36c59e628babf788f
@Override
public BlockPos south(int distance) {
- return this.relative(Direction.SOUTH, distance);
+ return distance == 0 ? this : new BlockPos(this.getX(), this.getY(), this.getZ() + distance); // Paper - Perf: Optimize BlockPosition
+ return distance == 0 ? this.immutable() : new BlockPos(this.getX(), this.getY(), this.getZ() + distance); // Paper - Perf: Optimize BlockPosition
}
@Override
@ -67,7 +67,7 @@ index 83e7c141d947f8f8096fed1da716560494bc5c62..eea8bea0f40db8d36c59e628babf788f
@Override
public BlockPos west(int distance) {
- return this.relative(Direction.WEST, distance);
+ return distance == 0 ? this : new BlockPos(this.getX() - distance, this.getY(), this.getZ()); // Paper - Perf: Optimize BlockPosition
+ return distance == 0 ? this.immutable() : new BlockPos(this.getX() - distance, this.getY(), this.getZ()); // Paper - Perf: Optimize BlockPosition
}
@Override
@ -79,7 +79,7 @@ index 83e7c141d947f8f8096fed1da716560494bc5c62..eea8bea0f40db8d36c59e628babf788f
@Override
public BlockPos east(int distance) {
- return this.relative(Direction.EAST, distance);
+ return distance == 0 ? this : new BlockPos(this.getX() + distance, this.getY(), this.getZ()); // Paper - Perf: Optimize BlockPosition
+ return distance == 0 ? this.immutable() : new BlockPos(this.getX() + distance, this.getY(), this.getZ()); // Paper - Perf: Optimize BlockPosition
}
@Override