geforkt von Mirrors/Paper
Fix Pathfinding and obscure glitchy buggy 0 tick farms
I swear the crap that stuff will abuse to make stuff happen is insane.
Hash codes apparently changing behavior of stuff based on its value, so
reverting e9fcee1190
Fixes #3346
Fixes #3341
Dieser Commit ist enthalten in:
Ursprung
c0441b6262
Commit
92497a1b5d
@ -1,7 +1,7 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Wed, 30 Nov 2016 20:56:58 -0600
|
||||
Subject: [PATCH] Improve BlockPosition inline and hashCode/equals
|
||||
Subject: [PATCH] Improve BlockPosition 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.
|
||||
@ -20,10 +20,6 @@ This should result in an across the board speedup in anything that accesses bloc
|
||||
This is based upon conclusions drawn from inspecting the assenmbly generated bythe JIT compiler on my microbenchmarks.
|
||||
They had 'callq' (invoke) instead of 'mov' (get from memory) instructions.
|
||||
|
||||
Co-Authored-By: Aikar <aikar@aikar.co>
|
||||
for:
|
||||
Also cache the hashCode and long values to use it for speeding up hashmap usage
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
@ -41,11 +37,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
// Paper start
|
||||
- public boolean isValidLocation() {
|
||||
- return a >= -30000000 && c >= -30000000 && a < 30000000 && c < 30000000 && b >= 0 && b < 256;
|
||||
+ protected int x; // If these ever become non final, review this entire patch, look for places need to rehash on write
|
||||
+ protected int x;
|
||||
+ protected int y;
|
||||
+ protected int z;
|
||||
+ private int hashCodeCached = 0;
|
||||
+ private long cachedLong = Long.MAX_VALUE;
|
||||
+
|
||||
+ public final boolean isValidLocation() {
|
||||
+ return x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000 && y >= 0 && y < 256;
|
||||
@ -80,32 +74,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
BaseBlockPosition baseblockposition = (BaseBlockPosition) object;
|
||||
|
||||
- return this.getX() != baseblockposition.getX() ? false : (this.getY() != baseblockposition.getY() ? false : this.getZ() == baseblockposition.getZ());
|
||||
+ return this.asLong() == baseblockposition.asLong(); // Paper
|
||||
+ return x == baseblockposition.x && z == baseblockposition.z && y == baseblockposition.y; // Paper
|
||||
}
|
||||
}
|
||||
|
||||
- public int hashCode() {
|
||||
- return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
||||
+ public final int hashCode() {
|
||||
+ // Paper start
|
||||
+ if (this.cachedLong == Long.MAX_VALUE) {
|
||||
+ rebuildCache();
|
||||
+ }
|
||||
+ return this.hashCodeCached;
|
||||
+ }
|
||||
+ private void rebuildCache() {
|
||||
+ this.cachedLong = BlockPosition.asLong(getX(), getY(), getZ());
|
||||
+ this.hashCodeCached = (this.getY() + this.getZ() * 1031) * 1031 + this.getX();
|
||||
+ }
|
||||
+ public final long asLong() {
|
||||
+ if (this.cachedLong == Long.MAX_VALUE) {
|
||||
+ rebuildCache();
|
||||
+ }
|
||||
+ return this.cachedLong;
|
||||
+ }
|
||||
+ public final void rehash() {
|
||||
+ this.cachedLong = Long.MAX_VALUE;
|
||||
+ // Paper end
|
||||
+ public final int hashCode() { // Paper
|
||||
+ return (this.y + this.z * 31) * 31 + this.x; // Paper
|
||||
}
|
||||
|
||||
public int compareTo(BaseBlockPosition baseblockposition) {
|
||||
@ -176,14 +152,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
long l = 0L;
|
||||
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
|
||||
return i & -16L;
|
||||
}
|
||||
|
||||
- public long asLong() {
|
||||
+ public long asLong_unused() { // Paper - moved to parent
|
||||
return a(this.getX(), this.getY(), this.getZ());
|
||||
public long asLong() {
|
||||
- return a(this.getX(), this.getY(), this.getZ());
|
||||
+ return a(this.x, this.y, this.z); // Paper
|
||||
}
|
||||
|
||||
public BlockPosition a(double d0, double d1, double d2) {
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
|
||||
}
|
||||
|
||||
@ -243,7 +219,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ this.x = i;
|
||||
+ this.y = j;
|
||||
+ this.z = k;
|
||||
+ rehash();
|
||||
+ // Paper end
|
||||
return this;
|
||||
}
|
||||
@ -265,21 +240,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public void o(int i) {
|
||||
- this.b = i;
|
||||
+ this.x = i; // Paper change to x
|
||||
+ rehash(); // Paper
|
||||
}
|
||||
|
||||
public final void setY(final int y) { this.p(y); } // Paper - OBFHELPER
|
||||
public void p(int i) {
|
||||
- this.c = i;
|
||||
+ this.y = i; // Paper change to y
|
||||
+ rehash(); // Paper
|
||||
}
|
||||
|
||||
public final void setZ(final int z) { this.q(z); } // Paper - OBFHELPER
|
||||
public void q(int i) {
|
||||
- this.d = i;
|
||||
+ this.z = i; // Paper change to z
|
||||
+ rehash(); // Paper
|
||||
}
|
||||
|
||||
@Override
|
@ -155,7 +155,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
- for (Iterator iterator = set.iterator(); iterator.hasNext(); f = Math.min(f1, f)) {
|
||||
- PathDestination pathdestination = (PathDestination) iterator.next();
|
||||
+ for (int i = 0, listSize = list.size(); i < listSize; i++) { // Paper
|
||||
+ for (int i = 0, listSize = list.size(); i < listSize; f = Math.min(f1, f), i++) { // Paper
|
||||
+ PathDestination pathdestination = list.get(i).getKey(); // Paper
|
||||
|
||||
f1 = pathpoint.a(pathdestination);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren