Upstream has released updates that appears to apply and compile correctly Paper Changes: 26fb7cc35 Fix Chunk Post Processing deadlock risk ffecc4e26 Revert "Optimize entity list iteration requiring entities be in" 0a4286cc4 Prevent Fire from loading chunks 07915ea18 Add Player Client Options API (#2883) bc48a3172 Optimize entity list iteration requiring entities be in loaded chunks 88092fef1 Optimize ChunkProviderServer's chunk level checking helper methods 01e8ce8d2 Forced Watchdog Crash support and Improve Async Shutdown fdb8fe780 Be less strict with vanilla teleport command limits 0f06d3806 Restrict vanilla teleport command to within worldborder 24d93aafa Fix Optional null issue - Fixes #3155 eb71c5fa3 Fix incorect timing of mspt 1ca804342 Optimise entity hard collision checking b67a42376 Don't run entity collision code if not needed bd9aa547d Optimise ArraySetSorted#removeIf
73 lines
3.1 KiB
Diff
73 lines
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Sotr <i@omc.hk>
|
|
Date: Wed, 15 Apr 2020 04:28:25 +0700
|
|
Subject: [PATCH] Cache hashcode for BlockPosition
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
index c439a8d0191c8667c881b2111b8c640ca13e5e7c..cc18560431d65f13f28b45025a702afe13c86cdd 100644
|
|
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
|
@@ -18,6 +18,7 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
|
return y < 0 || y >= 256;
|
|
}
|
|
// Paper end
|
|
+ protected int hash; // Akarin - cache hashcode
|
|
|
|
public BaseBlockPosition(int i, int j, int k) {
|
|
this.x = i;
|
|
@@ -42,8 +43,20 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
|
}
|
|
|
|
public int hashCode() {
|
|
- return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
|
+ // Akarin start - cache hashcode
|
|
+ int result = hash; // Make the situation not too bad when it is modified by multiple threads
|
|
+ if (result == 0) {
|
|
+ result = (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
|
+ hash = result;
|
|
+ }
|
|
+ return result;
|
|
+ // return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
|
+ }
|
|
+
|
|
+ public void recalcHashCode() {
|
|
+ hash = 0;
|
|
}
|
|
+ // Akarin end
|
|
|
|
public int compareTo(BaseBlockPosition baseblockposition) {
|
|
return this.getY() == baseblockposition.getY() ? (this.getZ() == baseblockposition.getZ() ? this.getX() - baseblockposition.getX() : this.getZ() - baseblockposition.getZ()) : this.getY() - baseblockposition.getY();
|
|
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
index 2d07d350d2b73197b6ea73cf90ff59679da7e0e7..43e7e5c27b454db3289407f14f6568d1d8944b69 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
|
@@ -439,6 +439,7 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
|
|
this.y = j;
|
|
this.z = k;
|
|
// Paper end
|
|
+ this.recalcHashCode(); // Akarin - cache hashcode
|
|
return this;
|
|
}
|
|
|
|
@@ -479,16 +480,19 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
|
|
public final void setX(final int x) { this.o(x); } // Paper - OBFHELPER
|
|
public void o(int i) {
|
|
this.x = i; // Paper change to x
|
|
+ this.recalcHashCode(); // Akarin - cache hashcode
|
|
}
|
|
|
|
public final void setY(final int y) { this.p(y); } // Paper - OBFHELPER
|
|
public void p(int i) {
|
|
this.y = i; // Paper change to y
|
|
+ this.recalcHashCode(); // Akarin - cache hashcode
|
|
}
|
|
|
|
public final void setZ(final int z) { this.q(z); } // Paper - OBFHELPER
|
|
public void q(int i) {
|
|
this.z = i; // Paper change to z
|
|
+ this.recalcHashCode(); // Akarin - cache hashcode
|
|
}
|
|
|
|
@Override
|