9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-28 03:19:21 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0140-Remove-stream-in-BlockBehaviour-cache-blockstate.patch
Dreeam 9a4efaa230 Drop patch that causes performance regression
Originally vanilla logic is to use stream, and Mojang switched it to Guava's Collections2
since 1.21.4. It is much faster than using stream or manually adding to a new ArrayList.
Manually adding to a new ArrayList requires allocating a new object array. However, the Collections2
lazy handles filter condition on iteration, so much better.
2025-08-04 19:25:56 +08:00

28 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Fri, 7 Jun 2024 17:43:43 +0800
Subject: [PATCH] Remove stream in BlockBehaviour cache blockstate
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index 3741afd1b2a5cb5cfce5e14cb78aa5ff5c3b218e..331474bb33c8612283a0ec478c1ae8768180b22d 100644
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -1064,8 +1064,14 @@ public abstract class BlockBehaviour implements FeatureElement {
)
);
} else {
- this.largeCollisionShape = Arrays.stream(Direction.Axis.values())
- .anyMatch(dir -> this.collisionShape.min(dir) < 0.0 || this.collisionShape.max(dir) > 1.0);
+ // Leaf start - Remove stream in BlockBehaviour cache blockstate
+ for (Direction.Axis axis : Direction.Axis.values()) {
+ if (this.collisionShape.min(axis) < 0.0 || this.collisionShape.max(axis) > 1.0) {
+ this.largeCollisionShape = true;
+ break;
+ }
+ }
+ // Leaf end - Remove stream in BlockBehaviour cache blockstate
this.faceSturdy = new boolean[DIRECTIONS.length * SUPPORT_TYPE_COUNT];
for (Direction direction : DIRECTIONS) {