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 9b94d8bf3415734776c81297d5d34eea46ad7e78..65d8ac795282117ba88003e7a703ee649a359473 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 @@ -1438,6 +1438,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; @@ -1451,7 +1455,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; @@ -1464,7 +1468,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) {