9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-25 01:49:16 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0052-Cache-FluidOcclusionCacheKey-hash.patch
Dreeam 3c25377465 Drop some unused patches
ClassInstanceMultiMap belongs to Minecraft vanilla entity storage.
And is unused, since replaced by spottedleaf's entity storage (rewrite chunk system).
However these patches might be useful for vanilla entity storage if is used.
2025-07-09 04:20:02 +08:00

75 lines
2.6 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 FluidOcclusionCacheKey hash
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
Gale - https://galemc.org
The JMH benchmark of this patch can be found in SunBox's `RecordHashCode`
diff --git a/ca/spottedleaf/moonrise/patches/collisions/util/FluidOcclusionCacheKey.java b/ca/spottedleaf/moonrise/patches/collisions/util/FluidOcclusionCacheKey.java
index cf9ffdeff6bf0b62a45f7a44dbfe0dd7d17dc4f4..f1480625eaece1553d4a96ec54138a463a6fc1ca 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/util/FluidOcclusionCacheKey.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/util/FluidOcclusionCacheKey.java
@@ -3,5 +3,58 @@ package ca.spottedleaf.moonrise.patches.collisions.util;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
-public record FluidOcclusionCacheKey(BlockState first, BlockState second, Direction direction, boolean result) {
+// Gale start - Lithium - cache FluidOcclusionCacheKey hash
+public final class FluidOcclusionCacheKey {
+ private final BlockState first;
+ private final BlockState second;
+ private final Direction direction;
+ private final boolean result;
+ private final int hash;
+
+ public FluidOcclusionCacheKey(BlockState first, BlockState second, Direction direction, boolean result) {
+ this.first = first;
+ this.second = second;
+ this.direction = direction;
+ this.result = result;
+ this.hash = java.util.Objects.hash(first, second, direction, result);
+ }
+
+ public BlockState first() {
+ return first;
+ }
+
+ public BlockState second() {
+ return second;
+ }
+
+ public Direction direction() {
+ return direction;
+ }
+
+ public boolean result() {
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof FluidOcclusionCacheKey fluidOcclusionCacheKey
+ && this.first == fluidOcclusionCacheKey.first
+ && this.second == fluidOcclusionCacheKey.second
+ && this.direction == fluidOcclusionCacheKey.direction;
+ }
+
+ @Override
+ public int hashCode() {
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ return "FluidOcclusionCacheKey[" +
+ "first=" + first + ", " +
+ "second=" + second + ", " +
+ "direction=" + direction + ", " +
+ "result=" + result + ']';
+ }
+ // Gale end - Lithium - cache FluidOcclusionCacheKey hash
}