9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 08:59:23 +00:00
Files
Leaf/patches/server/0113-Cache-blockstate-cache.patch
2024-12-14 01:21:12 -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 ca2b57d13128717ebb772dd6523d2909f12560cd..cabb4b79248725ea8f831d5f1b27902c3c9ea262 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
@@ -1446,6 +1446,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 VoxelShape collisionShape;
protected boolean largeCollisionShape; // Leaf - not final
private final boolean[] faceSturdy;
@@ -1459,7 +1463,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;
@@ -1472,7 +1476,7 @@ public abstract class BlockBehaviour implements FeatureElement {
for (int j = 0; j < i; ++j) {
Direction enumdirection = aenumdirection[j];
- SupportType[] aenumblocksupport = SupportType.values();
+ SupportType[] aenumblocksupport = SUPPORT_TYPE_VALUES; // Leaf - Cache blockstate cache array
int k = aenumblocksupport.length;
for (int l = 0; l < k; ++l) {