geforkt von Mirrors/Paper
c97ce029e9
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues. Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong. This is now resolved. Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me. Please as always, backup your worlds and test before updating to 1.16.2! If you update to 1.16.2, there is no going back to an older build than this. --------------------------------- Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com> Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com> Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com> Co-authored-by: stonar96 <minecraft.stonar96@gmail.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Jason <jasonpenilla2@me.com> Co-authored-by: kashike <kashike@vq.lc> Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: KennyTV <kennytv@t-online.de> Co-authored-by: commandblockguy <commandblockguy1@gmail.com> Co-authored-by: DigitalRegent <misterwener@gmail.com> Co-authored-by: ishland <ishlandmc@yeah.net>
101 Zeilen
4.4 KiB
Diff
101 Zeilen
4.4 KiB
Diff
From 0000000000000000000000000000000000000000 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 f112fe95cb89f6196a41252193e9eb44008cfc5f..f068436960c96b0df427bcdf337a4dcc6a9f66f5 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
@@ -115,58 +115,75 @@ public class BlockPosition extends BaseBlockPosition {
|
|
|
|
@Override
|
|
public BlockPosition up() {
|
|
- return this.shift(EnumDirection.UP);
|
|
+ return new BlockPosition(this.getX(), this.getY() + 1, this.getZ()); // Paper - Optimize BlockPosition
|
|
}
|
|
|
|
@Override
|
|
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
|