From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Sat, 8 Apr 2023 01:40:11 +0300 Subject: [PATCH] lithium: cached_hashcode 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 773162c3456945605fb664114508622f7d2fcec8..cc4a2bafc319fb54e8d1168cba85746c5dfafbc2 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java @@ -663,11 +663,18 @@ public class Block extends BlockBehaviour implements ItemLike { private final BlockState first; private final BlockState second; private final Direction direction; + private final int hash; // DivineMC - lithium: cached_hashcode public BlockStatePairKey(BlockState self, BlockState other, Direction facing) { this.first = self; this.second = other; this.direction = facing; + // DivineMC start - lithium: cached_hashcode + int hash = this.first.hashCode(); + hash = 31 * hash + this.second.hashCode(); + hash = 31 * hash + this.direction.hashCode(); + this.hash = hash; + // DivineMC end } public boolean equals(Object object) { @@ -683,11 +690,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; // DivineMC - lithium: cached_hashcode } } }