geforkt von Mirrors/Paper
Re-add BlocksPos inlining patch
Dieser Commit ist enthalten in:
Ursprung
a05bf5ab9f
Commit
abc4f8df61
@ -1,9 +1,108 @@
|
||||
From 541eaa4579cd06028863b58078500cdcb86fab6d Mon Sep 17 00:00:00 2001
|
||||
From 064eacc5931529fab242e2faed8e34f57eb6933f Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Mon, 29 Feb 2016 21:09:10 -0600
|
||||
Subject: [PATCH] mc-dev imports
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
new file mode 100644
|
||||
index 0000000..e54e7b7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
@@ -0,0 +1,93 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+import com.google.common.base.Objects;
|
||||
+
|
||||
+public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
||||
+
|
||||
+ public static final BaseBlockPosition ZERO = new BaseBlockPosition(0, 0, 0);
|
||||
+ private final int a;
|
||||
+ private final int c;
|
||||
+ private final int d;
|
||||
+
|
||||
+ public BaseBlockPosition(int i, int j, int k) {
|
||||
+ this.a = i;
|
||||
+ this.c = j;
|
||||
+ this.d = k;
|
||||
+ }
|
||||
+
|
||||
+ public BaseBlockPosition(double d0, double d1, double d2) {
|
||||
+ this(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2));
|
||||
+ }
|
||||
+
|
||||
+ public boolean equals(Object object) {
|
||||
+ if (this == object) {
|
||||
+ return true;
|
||||
+ } else if (!(object instanceof BaseBlockPosition)) {
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ BaseBlockPosition baseblockposition = (BaseBlockPosition) object;
|
||||
+
|
||||
+ return this.getX() != baseblockposition.getX() ? false : (this.getY() != baseblockposition.getY() ? false : this.getZ() == baseblockposition.getZ());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public int hashCode() {
|
||||
+ return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
||||
+ }
|
||||
+
|
||||
+ public int i(BaseBlockPosition baseblockposition) {
|
||||
+ return this.getY() == baseblockposition.getY() ? (this.getZ() == baseblockposition.getZ() ? this.getX() - baseblockposition.getX() : this.getZ() - baseblockposition.getZ()) : this.getY() - baseblockposition.getY();
|
||||
+ }
|
||||
+
|
||||
+ public int getX() {
|
||||
+ return this.a;
|
||||
+ }
|
||||
+
|
||||
+ public int getY() {
|
||||
+ return this.c;
|
||||
+ }
|
||||
+
|
||||
+ public int getZ() {
|
||||
+ return this.d;
|
||||
+ }
|
||||
+
|
||||
+ public BaseBlockPosition d(BaseBlockPosition baseblockposition) {
|
||||
+ return new BaseBlockPosition(this.getY() * baseblockposition.getZ() - this.getZ() * baseblockposition.getY(), this.getZ() * baseblockposition.getX() - this.getX() * baseblockposition.getZ(), this.getX() * baseblockposition.getY() - this.getY() * baseblockposition.getX());
|
||||
+ }
|
||||
+
|
||||
+ public double f(int i, int j, int k) {
|
||||
+ double d0 = (double) (this.getX() - i);
|
||||
+ double d1 = (double) (this.getY() - j);
|
||||
+ double d2 = (double) (this.getZ() - k);
|
||||
+
|
||||
+ return Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
||||
+ }
|
||||
+
|
||||
+ public double distanceSquared(double d0, double d1, double d2) {
|
||||
+ double d3 = (double) this.getX() - d0;
|
||||
+ double d4 = (double) this.getY() - d1;
|
||||
+ double d5 = (double) this.getZ() - d2;
|
||||
+
|
||||
+ return d3 * d3 + d4 * d4 + d5 * d5;
|
||||
+ }
|
||||
+
|
||||
+ public double f(double d0, double d1, double d2) {
|
||||
+ double d3 = (double) this.getX() + 0.5D - d0;
|
||||
+ double d4 = (double) this.getY() + 0.5D - d1;
|
||||
+ double d5 = (double) this.getZ() + 0.5D - d2;
|
||||
+
|
||||
+ return d3 * d3 + d4 * d4 + d5 * d5;
|
||||
+ }
|
||||
+
|
||||
+ public double k(BaseBlockPosition baseblockposition) {
|
||||
+ return this.distanceSquared((double) baseblockposition.getX(), (double) baseblockposition.getY(), (double) baseblockposition.getZ());
|
||||
+ }
|
||||
+
|
||||
+ public String toString() {
|
||||
+ return Objects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
|
||||
+ }
|
||||
+
|
||||
+ public int compareTo(Object object) {
|
||||
+ return this.i((BaseBlockPosition) object);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java
|
||||
new file mode 100644
|
||||
index 0000000..be4b871
|
||||
@ -1500,6 +1599,393 @@ index 0000000..675cdc0
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
new file mode 100644
|
||||
index 0000000..e7a95f3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -0,0 +1,381 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+import com.google.common.collect.AbstractIterator;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.List;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+
|
||||
+public class BlockPosition extends BaseBlockPosition {
|
||||
+
|
||||
+ private static final Logger c = LogManager.getLogger();
|
||||
+ public static final BlockPosition ZERO = new BlockPosition(0, 0, 0);
|
||||
+ private static final int d = 1 + MathHelper.e(MathHelper.c(30000000));
|
||||
+ private static final int e = BlockPosition.d;
|
||||
+ private static final int f = 64 - BlockPosition.d - BlockPosition.e;
|
||||
+ private static final int g = 0 + BlockPosition.e;
|
||||
+ private static final int h = BlockPosition.g + BlockPosition.f;
|
||||
+ private static final long i = (1L << BlockPosition.d) - 1L;
|
||||
+ private static final long j = (1L << BlockPosition.f) - 1L;
|
||||
+ private static final long k = (1L << BlockPosition.e) - 1L;
|
||||
+
|
||||
+ public BlockPosition(int i, int j, int k) {
|
||||
+ super(i, j, k);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition(double d0, double d1, double d2) {
|
||||
+ super(d0, d1, d2);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition(Entity entity) {
|
||||
+ this(entity.locX, entity.locY, entity.locZ);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition(Vec3D vec3d) {
|
||||
+ this(vec3d.x, vec3d.y, vec3d.z);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition(BaseBlockPosition baseblockposition) {
|
||||
+ this(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ());
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition a(double d0, double d1, double d2) {
|
||||
+ return d0 == 0.0D && d1 == 0.0D && d2 == 0.0D ? this : new BlockPosition((double) this.getX() + d0, (double) this.getY() + d1, (double) this.getZ() + d2);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition a(int i, int j, int k) {
|
||||
+ return i == 0 && j == 0 && k == 0 ? this : new BlockPosition(this.getX() + i, this.getY() + j, this.getZ() + k);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition a(BaseBlockPosition baseblockposition) {
|
||||
+ return baseblockposition.getX() == 0 && baseblockposition.getY() == 0 && baseblockposition.getZ() == 0 ? this : new BlockPosition(this.getX() + baseblockposition.getX(), this.getY() + baseblockposition.getY(), this.getZ() + baseblockposition.getZ());
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition b(BaseBlockPosition baseblockposition) {
|
||||
+ return baseblockposition.getX() == 0 && baseblockposition.getY() == 0 && baseblockposition.getZ() == 0 ? this : new BlockPosition(this.getX() - baseblockposition.getX(), this.getY() - baseblockposition.getY(), this.getZ() - baseblockposition.getZ());
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition up() {
|
||||
+ return this.up(1);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition up(int i) {
|
||||
+ return this.shift(EnumDirection.UP, i);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition down() {
|
||||
+ return this.down(1);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition down(int i) {
|
||||
+ return this.shift(EnumDirection.DOWN, i);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition north() {
|
||||
+ return this.north(1);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition north(int i) {
|
||||
+ return this.shift(EnumDirection.NORTH, i);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition south() {
|
||||
+ return this.south(1);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition south(int i) {
|
||||
+ return this.shift(EnumDirection.SOUTH, i);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition west() {
|
||||
+ return this.west(1);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition west(int i) {
|
||||
+ return this.shift(EnumDirection.WEST, i);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition east() {
|
||||
+ return this.east(1);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition east(int i) {
|
||||
+ return this.shift(EnumDirection.EAST, i);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition shift(EnumDirection enumdirection) {
|
||||
+ return this.shift(enumdirection, 1);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition shift(EnumDirection enumdirection, int i) {
|
||||
+ return i == 0 ? this : new BlockPosition(this.getX() + enumdirection.getAdjacentX() * i, this.getY() + enumdirection.getAdjacentY() * i, this.getZ() + enumdirection.getAdjacentZ() * i);
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition c(BaseBlockPosition baseblockposition) {
|
||||
+ return new BlockPosition(this.getY() * baseblockposition.getZ() - this.getZ() * baseblockposition.getY(), this.getZ() * baseblockposition.getX() - this.getX() * baseblockposition.getZ(), this.getX() * baseblockposition.getY() - this.getY() * baseblockposition.getX());
|
||||
+ }
|
||||
+
|
||||
+ public long asLong() {
|
||||
+ return ((long) this.getX() & BlockPosition.i) << BlockPosition.h | ((long) this.getY() & BlockPosition.j) << BlockPosition.g | ((long) this.getZ() & BlockPosition.k) << 0;
|
||||
+ }
|
||||
+
|
||||
+ public static BlockPosition fromLong(long i) {
|
||||
+ int j = (int) (i << 64 - BlockPosition.h - BlockPosition.d >> 64 - BlockPosition.d);
|
||||
+ int k = (int) (i << 64 - BlockPosition.g - BlockPosition.f >> 64 - BlockPosition.f);
|
||||
+ int l = (int) (i << 64 - BlockPosition.e >> 64 - BlockPosition.e);
|
||||
+
|
||||
+ return new BlockPosition(j, k, l);
|
||||
+ }
|
||||
+
|
||||
+ public static Iterable<BlockPosition> a(BlockPosition blockposition, BlockPosition blockposition1) {
|
||||
+ final BlockPosition blockposition2 = new BlockPosition(Math.min(blockposition.getX(), blockposition1.getX()), Math.min(blockposition.getY(), blockposition1.getY()), Math.min(blockposition.getZ(), blockposition1.getZ()));
|
||||
+ final BlockPosition blockposition3 = new BlockPosition(Math.max(blockposition.getX(), blockposition1.getX()), Math.max(blockposition.getY(), blockposition1.getY()), Math.max(blockposition.getZ(), blockposition1.getZ()));
|
||||
+
|
||||
+ return new Iterable() {
|
||||
+ public Iterator<BlockPosition> iterator() {
|
||||
+ return new AbstractIterator() {
|
||||
+ private BlockPosition b = null;
|
||||
+
|
||||
+ protected BlockPosition a() {
|
||||
+ if (this.b == null) {
|
||||
+ this.b = blockposition;
|
||||
+ return this.b;
|
||||
+ } else if (this.b.equals(blockposition1)) {
|
||||
+ return (BlockPosition) this.endOfData();
|
||||
+ } else {
|
||||
+ int i = this.b.getX();
|
||||
+ int j = this.b.getY();
|
||||
+ int k = this.b.getZ();
|
||||
+
|
||||
+ if (i < blockposition1.getX()) {
|
||||
+ ++i;
|
||||
+ } else if (j < blockposition1.getY()) {
|
||||
+ i = blockposition.getX();
|
||||
+ ++j;
|
||||
+ } else if (k < blockposition1.getZ()) {
|
||||
+ i = blockposition.getX();
|
||||
+ j = blockposition.getY();
|
||||
+ ++k;
|
||||
+ }
|
||||
+
|
||||
+ this.b = new BlockPosition(i, j, k);
|
||||
+ return this.b;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ protected Object computeNext() {
|
||||
+ return this.a();
|
||||
+ }
|
||||
+ };
|
||||
+ }
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition h() {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ public static Iterable<BlockPosition.MutableBlockPosition> b(BlockPosition blockposition, BlockPosition blockposition1) {
|
||||
+ final BlockPosition blockposition2 = new BlockPosition(Math.min(blockposition.getX(), blockposition1.getX()), Math.min(blockposition.getY(), blockposition1.getY()), Math.min(blockposition.getZ(), blockposition1.getZ()));
|
||||
+ final BlockPosition blockposition3 = new BlockPosition(Math.max(blockposition.getX(), blockposition1.getX()), Math.max(blockposition.getY(), blockposition1.getY()), Math.max(blockposition.getZ(), blockposition1.getZ()));
|
||||
+
|
||||
+ return new Iterable() {
|
||||
+ public Iterator<BlockPosition.MutableBlockPosition> iterator() {
|
||||
+ return new AbstractIterator() {
|
||||
+ private BlockPosition.MutableBlockPosition b = null;
|
||||
+
|
||||
+ protected BlockPosition.MutableBlockPosition a() {
|
||||
+ if (this.b == null) {
|
||||
+ this.b = new BlockPosition.MutableBlockPosition(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ return this.b;
|
||||
+ } else if (this.b.equals(blockposition1)) {
|
||||
+ return (BlockPosition.MutableBlockPosition) this.endOfData();
|
||||
+ } else {
|
||||
+ int i = this.b.getX();
|
||||
+ int j = this.b.getY();
|
||||
+ int k = this.b.getZ();
|
||||
+
|
||||
+ if (i < blockposition1.getX()) {
|
||||
+ ++i;
|
||||
+ } else if (j < blockposition1.getY()) {
|
||||
+ i = blockposition.getX();
|
||||
+ ++j;
|
||||
+ } else if (k < blockposition1.getZ()) {
|
||||
+ i = blockposition.getX();
|
||||
+ j = blockposition.getY();
|
||||
+ ++k;
|
||||
+ }
|
||||
+
|
||||
+ this.b.c = i;
|
||||
+ this.b.d = j;
|
||||
+ this.b.e = k;
|
||||
+ return this.b;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ protected Object computeNext() {
|
||||
+ return this.a();
|
||||
+ }
|
||||
+ };
|
||||
+ }
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ public BaseBlockPosition d(BaseBlockPosition baseblockposition) {
|
||||
+ return this.c(baseblockposition);
|
||||
+ }
|
||||
+
|
||||
+ public static final class PooledBlockPosition extends BlockPosition {
|
||||
+
|
||||
+ private int c;
|
||||
+ private int d;
|
||||
+ private int e;
|
||||
+ private boolean f;
|
||||
+ private static final List<BlockPosition.PooledBlockPosition> g = Lists.newArrayList();
|
||||
+
|
||||
+ private PooledBlockPosition(int i, int j, int k) {
|
||||
+ super(0, 0, 0);
|
||||
+ this.c = i;
|
||||
+ this.d = j;
|
||||
+ this.e = k;
|
||||
+ }
|
||||
+
|
||||
+ public static BlockPosition.PooledBlockPosition s() {
|
||||
+ return c(0, 0, 0);
|
||||
+ }
|
||||
+
|
||||
+ public static BlockPosition.PooledBlockPosition c(double d0, double d1, double d2) {
|
||||
+ return c(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2));
|
||||
+ }
|
||||
+
|
||||
+ public static BlockPosition.PooledBlockPosition c(int i, int j, int k) {
|
||||
+ List list = BlockPosition.PooledBlockPosition.g;
|
||||
+
|
||||
+ synchronized (BlockPosition.PooledBlockPosition.g) {
|
||||
+ if (!BlockPosition.PooledBlockPosition.g.isEmpty()) {
|
||||
+ BlockPosition.PooledBlockPosition blockposition_pooledblockposition = (BlockPosition.PooledBlockPosition) BlockPosition.PooledBlockPosition.g.remove(BlockPosition.PooledBlockPosition.g.size() - 1);
|
||||
+
|
||||
+ if (blockposition_pooledblockposition != null && blockposition_pooledblockposition.f) {
|
||||
+ blockposition_pooledblockposition.f = false;
|
||||
+ blockposition_pooledblockposition.d(i, j, k);
|
||||
+ return blockposition_pooledblockposition;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return new BlockPosition.PooledBlockPosition(i, j, k);
|
||||
+ }
|
||||
+
|
||||
+ public void t() {
|
||||
+ List list = BlockPosition.PooledBlockPosition.g;
|
||||
+
|
||||
+ synchronized (BlockPosition.PooledBlockPosition.g) {
|
||||
+ if (BlockPosition.PooledBlockPosition.g.size() < 100) {
|
||||
+ BlockPosition.PooledBlockPosition.g.add(this);
|
||||
+ }
|
||||
+
|
||||
+ this.f = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public int getX() {
|
||||
+ return this.c;
|
||||
+ }
|
||||
+
|
||||
+ public int getY() {
|
||||
+ return this.d;
|
||||
+ }
|
||||
+
|
||||
+ public int getZ() {
|
||||
+ return this.e;
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition.PooledBlockPosition d(int i, int j, int k) {
|
||||
+ if (this.f) {
|
||||
+ BlockPosition.c.error("PooledMutableBlockPosition modified after it was released.", new Throwable());
|
||||
+ this.f = false;
|
||||
+ }
|
||||
+
|
||||
+ this.c = i;
|
||||
+ this.d = j;
|
||||
+ this.e = k;
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition.PooledBlockPosition d(double d0, double d1, double d2) {
|
||||
+ return this.d(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2));
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition.PooledBlockPosition h(BaseBlockPosition baseblockposition) {
|
||||
+ return this.d(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ());
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition.PooledBlockPosition c(EnumDirection enumdirection) {
|
||||
+ return this.d(this.c + enumdirection.getAdjacentX(), this.d + enumdirection.getAdjacentY(), this.e + enumdirection.getAdjacentZ());
|
||||
+ }
|
||||
+
|
||||
+ public BaseBlockPosition d(BaseBlockPosition baseblockposition) {
|
||||
+ return super.c(baseblockposition);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static final class MutableBlockPosition extends BlockPosition {
|
||||
+
|
||||
+ private int c;
|
||||
+ private int d;
|
||||
+ private int e;
|
||||
+
|
||||
+ public MutableBlockPosition() {
|
||||
+ this(0, 0, 0);
|
||||
+ }
|
||||
+
|
||||
+ public MutableBlockPosition(BlockPosition blockposition) {
|
||||
+ this(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ }
|
||||
+
|
||||
+ public MutableBlockPosition(int i, int j, int k) {
|
||||
+ super(0, 0, 0);
|
||||
+ this.c = i;
|
||||
+ this.d = j;
|
||||
+ this.e = k;
|
||||
+ }
|
||||
+
|
||||
+ public int getX() {
|
||||
+ return this.c;
|
||||
+ }
|
||||
+
|
||||
+ public int getY() {
|
||||
+ return this.d;
|
||||
+ }
|
||||
+
|
||||
+ public int getZ() {
|
||||
+ return this.e;
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition.MutableBlockPosition c(int i, int j, int k) {
|
||||
+ this.c = i;
|
||||
+ this.d = j;
|
||||
+ this.e = k;
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ public void c(EnumDirection enumdirection) {
|
||||
+ this.c += enumdirection.getAdjacentX();
|
||||
+ this.d += enumdirection.getAdjacentY();
|
||||
+ this.e += enumdirection.getAdjacentZ();
|
||||
+ }
|
||||
+
|
||||
+ public void p(int i) {
|
||||
+ this.d = i;
|
||||
+ }
|
||||
+
|
||||
+ public BlockPosition h() {
|
||||
+ return new BlockPosition(this);
|
||||
+ }
|
||||
+
|
||||
+ public BaseBlockPosition d(BaseBlockPosition baseblockposition) {
|
||||
+ return super.c(baseblockposition);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderFlat.java b/src/main/java/net/minecraft/server/ChunkProviderFlat.java
|
||||
new file mode 100644
|
||||
index 0000000..17e0b8e
|
||||
|
232
Spigot-Server-Patches/0077-Speedup-BlockPos-by-fixing-inlining.patch
Normale Datei
232
Spigot-Server-Patches/0077-Speedup-BlockPos-by-fixing-inlining.patch
Normale Datei
@ -0,0 +1,232 @@
|
||||
From 0a11215975146d80e77d2b32dcca515391a2db9c Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Mon, 7 Mar 2016 12:51:01 -0700
|
||||
Subject: [PATCH] Speedup BlockPos by fixing inlining
|
||||
|
||||
Normally the JVM can inline virtual getters by having two sets of code, one is the 'optimized' code and the other is the 'deoptimized' code.
|
||||
If a single type is used 99% of the time, then its worth it to inline, and to revert to 'deoptimized' the 1% of the time we encounter other types.
|
||||
But if two types are encountered commonly, then the JVM can't inline them both, and the call overhead remains.
|
||||
|
||||
This scenario also occurs with BlockPos and MutableBlockPos.
|
||||
The variables in BlockPos are final, so MutableBlockPos can't modify them.
|
||||
MutableBlockPos fixes this by adding custom mutable variables, and overriding the getters to access them.
|
||||
|
||||
This approach with utility methods that operate on MutableBlockPos and BlockPos.
|
||||
Specific examples are BlockPosition.up(), and World.isValidLocation().
|
||||
It makes these simple methods much slower than they need to be.
|
||||
|
||||
This should result in an across the board speedup in anything that accesses blocks or does logic with positions.
|
||||
|
||||
This is based upon conclusions drawn from inspecting the assenmbly generated bythe JIT compiler on my mircorbenchmarks.
|
||||
They had 'callq' (invoke) instead of 'mov' (get from memory) instructions.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
index e54e7b7..f0908a2 100644
|
||||
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
@@ -5,9 +5,11 @@ import com.google.common.base.Objects;
|
||||
public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
||||
|
||||
public static final BaseBlockPosition ZERO = new BaseBlockPosition(0, 0, 0);
|
||||
- private final int a;
|
||||
- private final int c;
|
||||
- private final int d;
|
||||
+ // Paper start - make mutable and protected for MutableBlockPos and PooledBlockPos
|
||||
+ protected int a;
|
||||
+ protected int c;
|
||||
+ protected int d;
|
||||
+ // Paper end
|
||||
|
||||
public BaseBlockPosition(int i, int j, int k) {
|
||||
this.a = i;
|
||||
@@ -39,17 +41,19 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
||||
return this.getY() == baseblockposition.getY() ? (this.getZ() == baseblockposition.getZ() ? this.getX() - baseblockposition.getX() : this.getZ() - baseblockposition.getZ()) : this.getY() - baseblockposition.getY();
|
||||
}
|
||||
|
||||
- public int getX() {
|
||||
+ // Paper start - Only allow one implementation of these methods (make final)
|
||||
+ public final int getX() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
- public int getY() {
|
||||
+ public final int getY() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
- public int getZ() {
|
||||
+ public final int getZ() {
|
||||
return this.d;
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
public BaseBlockPosition d(BaseBlockPosition baseblockposition) {
|
||||
return new BaseBlockPosition(this.getY() * baseblockposition.getZ() - this.getZ() * baseblockposition.getY(), this.getZ() * baseblockposition.getX() - this.getX() * baseblockposition.getZ(), this.getX() * baseblockposition.getY() - this.getY() * baseblockposition.getX());
|
||||
@@ -87,7 +91,7 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
||||
return Objects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
|
||||
}
|
||||
|
||||
- public int compareTo(Object object) {
|
||||
+ public int compareTo(BaseBlockPosition object) { // Paper - correct decompile error
|
||||
return this.i((BaseBlockPosition) object);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
index e7a95f3..2d56f02 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -207,9 +207,10 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
++k;
|
||||
}
|
||||
|
||||
- this.b.c = i;
|
||||
- this.b.d = j;
|
||||
- this.b.e = k;
|
||||
+ // Paper start - modify base position variables
|
||||
+ ((BaseBlockPosition) this.b).a = i;
|
||||
+ ((BaseBlockPosition) this.b).c = j;
|
||||
+ ((BaseBlockPosition) this.b).d = k;
|
||||
return this.b;
|
||||
}
|
||||
}
|
||||
@@ -228,17 +229,23 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
|
||||
public static final class PooledBlockPosition extends BlockPosition {
|
||||
|
||||
+ // Paper start - remove variables
|
||||
+ /*
|
||||
private int c;
|
||||
private int d;
|
||||
private int e;
|
||||
+ */
|
||||
+ // Paper end
|
||||
private boolean f;
|
||||
private static final List<BlockPosition.PooledBlockPosition> g = Lists.newArrayList();
|
||||
|
||||
private PooledBlockPosition(int i, int j, int k) {
|
||||
super(0, 0, 0);
|
||||
- this.c = i;
|
||||
- this.d = j;
|
||||
- this.e = k;
|
||||
+ // Paper start - modify base position variables
|
||||
+ ((BaseBlockPosition) this).a = i;
|
||||
+ ((BaseBlockPosition) this).c = j;
|
||||
+ ((BaseBlockPosition) this).d = k;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public static BlockPosition.PooledBlockPosition s() {
|
||||
@@ -279,6 +286,8 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - use superclass methods
|
||||
+ /*
|
||||
public int getX() {
|
||||
return this.c;
|
||||
}
|
||||
@@ -290,6 +299,8 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
public int getZ() {
|
||||
return this.e;
|
||||
}
|
||||
+ */
|
||||
+ // Paper end
|
||||
|
||||
public BlockPosition.PooledBlockPosition d(int i, int j, int k) {
|
||||
if (this.f) {
|
||||
@@ -297,9 +308,11 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
this.f = false;
|
||||
}
|
||||
|
||||
- this.c = i;
|
||||
- this.d = j;
|
||||
- this.e = k;
|
||||
+ // Paper start - modify base position variables
|
||||
+ ((BaseBlockPosition) this).a = i;
|
||||
+ ((BaseBlockPosition) this).c = j;
|
||||
+ ((BaseBlockPosition) this).d = k;
|
||||
+ // Paper end
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -312,7 +325,7 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public BlockPosition.PooledBlockPosition c(EnumDirection enumdirection) {
|
||||
- return this.d(this.c + enumdirection.getAdjacentX(), this.d + enumdirection.getAdjacentY(), this.e + enumdirection.getAdjacentZ());
|
||||
+ return this.d(this.getX() + enumdirection.getAdjacentX(), this.getY() + enumdirection.getAdjacentY(), this.getZ() + enumdirection.getAdjacentZ()); // Paper - use getters
|
||||
}
|
||||
|
||||
public BaseBlockPosition d(BaseBlockPosition baseblockposition) {
|
||||
@@ -322,9 +335,13 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
|
||||
public static final class MutableBlockPosition extends BlockPosition {
|
||||
|
||||
+ // Paper start - remove variables
|
||||
+ /*
|
||||
private int c;
|
||||
private int d;
|
||||
private int e;
|
||||
+ */
|
||||
+ // Paper end
|
||||
|
||||
public MutableBlockPosition() {
|
||||
this(0, 0, 0);
|
||||
@@ -336,11 +353,15 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
|
||||
public MutableBlockPosition(int i, int j, int k) {
|
||||
super(0, 0, 0);
|
||||
- this.c = i;
|
||||
- this.d = j;
|
||||
- this.e = k;
|
||||
+ // Paper start - modify base position variables
|
||||
+ ((BaseBlockPosition) this).a = i;
|
||||
+ ((BaseBlockPosition) this).c = j;
|
||||
+ ((BaseBlockPosition) this).d = k;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
+ // Paper start - use superclass methods
|
||||
+ /*
|
||||
public int getX() {
|
||||
return this.c;
|
||||
}
|
||||
@@ -352,22 +373,28 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
public int getZ() {
|
||||
return this.e;
|
||||
}
|
||||
+ */
|
||||
+ // Paper end
|
||||
|
||||
public BlockPosition.MutableBlockPosition c(int i, int j, int k) {
|
||||
- this.c = i;
|
||||
- this.d = j;
|
||||
- this.e = k;
|
||||
+ // Paper start - modify base position variables
|
||||
+ ((BaseBlockPosition) this).a = i;
|
||||
+ ((BaseBlockPosition) this).c = j;
|
||||
+ ((BaseBlockPosition) this).d = k;
|
||||
+ // Paper end
|
||||
return this;
|
||||
}
|
||||
|
||||
public void c(EnumDirection enumdirection) {
|
||||
- this.c += enumdirection.getAdjacentX();
|
||||
- this.d += enumdirection.getAdjacentY();
|
||||
- this.e += enumdirection.getAdjacentZ();
|
||||
+ // Paper start - modify base position variables
|
||||
+ ((BaseBlockPosition) this).a += enumdirection.getAdjacentX();
|
||||
+ ((BaseBlockPosition) this).c += enumdirection.getAdjacentY();
|
||||
+ ((BaseBlockPosition) this).d += enumdirection.getAdjacentZ();
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public void p(int i) {
|
||||
- this.d = i;
|
||||
+ ((BaseBlockPosition) this).c = i; // Paper - modify base variable
|
||||
}
|
||||
|
||||
public BlockPosition h() {
|
||||
--
|
||||
2.7.2
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren