9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-21 07:49:22 +00:00
Files
Gale/patches/server/0073-Cache-BlockStatePairKey-hash.patch
Dreeam a4ed88543a Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@681c013 Bundle spark (#11093)
PaperMC/Paper@5fee9c6 Move configuration option to a system property
PaperMC/Paper@aa3b356 Improve server startup logging (#11110)
PaperMC/Paper@9aea240 Properly lookup plugin classes when looked up by spark
PaperMC/Paper@7e91a2c Update the bundled spark version
2024-07-21 07:11:14 +08:00

51 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 15:51:59 +0100
Subject: [PATCH] Cache BlockStatePairKey hash
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
Gale - https://galemc.org
This patch is based on the following mixin:
"me/jellysquid/mods/lithium/mixin/cached_hashcode/BlockNeighborGroupMixin.java"
By: Angeline <jellysquid3@users.noreply.github.com>
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
index a7108b2be0746aa1f0e574d8c6f5ffad6d369835..94246e6e05a83758059e933a036558eb47d2e84b 100644
--- a/src/main/java/net/minecraft/world/level/block/Block.java
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
@@ -601,11 +601,18 @@ public class Block extends BlockBehaviour implements ItemLike {
private final BlockState first;
private final BlockState second;
private final Direction direction;
+ private final int hash; // Gale - Lithium - cache BlockStatePairKey hash
public BlockStatePairKey(BlockState self, BlockState other, Direction facing) {
this.first = self;
this.second = other;
this.direction = facing;
+ // Gale start - Lithium - cache BlockStatePairKey hash
+ int hash = this.first.hashCode();
+ hash = 31 * hash + this.second.hashCode();
+ hash = 31 * hash + this.direction.hashCode();
+ this.hash = hash;
+ // Gale end - Lithium - cache BlockStatePairKey hash
}
public boolean equals(Object object) {
@@ -621,11 +628,7 @@ public class Block extends BlockBehaviour implements ItemLike {
}
public int hashCode() {
- int i = this.first.hashCode();
-
- i = 31 * i + this.second.hashCode();
- i = 31 * i + this.direction.hashCode();
- return i;
+ return this.hash; // Gale - Lithium - cache BlockStatePairKey hash
}
}
}