mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
Some minecraft patches work
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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:
|
||||
"net/caffeinemc/mods/lithium/mixin/cached_hashcode/FlowingFluid$BlockStatePairKeyMixin.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/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java
|
||||
index ab8babd32b7d71bc14049c8778525499e715bd12..95ffd0195b9e0792c6b84115d1a1196231b39cec 100644
|
||||
--- a/net/minecraft/world/level/material/FlowingFluid.java
|
||||
+++ b/net/minecraft/world/level/material/FlowingFluid.java
|
||||
@@ -484,7 +484,26 @@ public abstract class FlowingFluid extends Fluid {
|
||||
: this.shapes.computeIfAbsent(state, fluidState -> Shapes.box(0.0, 0.0, 0.0, 1.0, fluidState.getHeight(level, pos), 1.0));
|
||||
}
|
||||
|
||||
- record BlockStatePairKey(BlockState first, BlockState second, Direction direction) {
|
||||
+ // Gale start - Lithium - cache BlockStatePairKey hash
|
||||
+ static class BlockStatePairKey {
|
||||
+
|
||||
+ private final BlockState first;
|
||||
+ private final BlockState second;
|
||||
+ private final Direction direction;
|
||||
+ private final int hash;
|
||||
+
|
||||
+ private BlockStatePairKey(BlockState first, BlockState second, Direction direction) {
|
||||
+ this.first = first;
|
||||
+ this.second = second;
|
||||
+ this.direction = direction;
|
||||
+ int hash = System.identityHashCode(this.first);
|
||||
+
|
||||
+ hash = 31 * hash + System.identityHashCode(this.second);
|
||||
+ hash = 31 * hash + this.direction.hashCode();
|
||||
+ this.hash = hash;
|
||||
+ }
|
||||
+ // Gale end - Lithium - cache BlockStatePairKey hash
|
||||
+
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof FlowingFluid.BlockStatePairKey blockStatePairKey
|
||||
@@ -495,9 +514,7 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
- int i = System.identityHashCode(this.first);
|
||||
- i = 31 * i + System.identityHashCode(this.second);
|
||||
- return 31 * i + this.direction.hashCode();
|
||||
+ return this.hash; // Gale - Lithium - cache BlockStatePairKey hash
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user