9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-21 16:09:19 +00:00
Files
Leaf/patches/server/0126-Cache-blockstate-cache.patch
Kobe ⑧ 848fb2dc4d Smart sorting & Remove streams & Throttle hopper (#157)
* =-=

* Reuse comparator

* Cleanup DAB patch
2024-11-10 09:25:58 -05:00

40 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
Date: Tue, 22 Oct 2024 17:07:36 +0800
Subject: [PATCH] Cache blockstate cache
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index cdaa5a8af0c6a8a78e587141b9ab1c84766589e9..de299465937074a1067a6adfc208eaaa24bcae67 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -1379,6 +1379,10 @@ public abstract class BlockBehaviour implements FeatureElement {
private static final Direction[] DIRECTIONS = Direction.values();
private static final int SUPPORT_TYPE_COUNT = SupportType.values().length;
+ // Leaf start - Cache blockstate cache array
+ private static final SupportType[] SUPPORT_TYPE_VALUES = SupportType.values();
+ private static final Direction.Axis[] DIRECTION_AXIS_VALUES = Direction.Axis.values();
+ // Leaf end - Cache blockstate cache array
protected final boolean solidRender;
final boolean propagatesSkylightDown;
final int lightBlock;
@@ -1418,7 +1422,7 @@ public abstract class BlockBehaviour implements FeatureElement {
throw new IllegalStateException(String.format(Locale.ROOT, "%s has a collision shape and an offset type, but is not marked as dynamicShape in its properties.", BuiltInRegistries.BLOCK.getKey(block)));
} else {
// Leaf start - Remove stream
- for (Direction.Axis axis : Direction.Axis.values()) {
+ for (Direction.Axis axis : DIRECTION_AXIS_VALUES) { // Leaf - Cache blockstate cache array
if (this.collisionShape.min(axis) < 0.0D || this.collisionShape.max(axis) > 1.0D) {
this.largeCollisionShape = true;
break;
@@ -1431,7 +1435,7 @@ public abstract class BlockBehaviour implements FeatureElement {
for (i = 0; i < k; ++i) {
Direction enumdirection1 = aenumdirection1[i];
- SupportType[] aenumblocksupport = SupportType.values();
+ SupportType[] aenumblocksupport = SUPPORT_TYPE_VALUES; // Leaf - Cache blockstate cache array
int l = aenumblocksupport.length;
for (int i1 = 0; i1 < l; ++i1) {