9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-23 00:39:22 +00:00

Include hardware specs in timings

This commit is contained in:
Martijn Muijsers
2022-12-24 21:38:06 +01:00
parent 1e5ad9710b
commit b7e35d62ca
122 changed files with 194 additions and 62 deletions

View File

@@ -0,0 +1,50 @@
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 0a3fff9fc22f76dcef9f108bceea4da39145745c..39981cd0003eb7ee416d887ffec70fb049599320 100644
--- a/src/main/java/net/minecraft/world/level/block/Block.java
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
@@ -609,11 +609,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) {
@@ -629,11 +636,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
}
}
}