mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-22 00:19:33 +00:00
Remove some performance
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Tue, 18 Jul 2023 14:43:18 +0800
|
||||
Subject: [PATCH] Cache CubeVoxelShape shape array
|
||||
|
||||
This patch is Powered by Gale(https://github.com/GaleMC/Gale)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||
index d812949c7329ae2696b38dc792fa011ba87decb9..17781089b96a8ba54e06a4c8ead58cc31151be47 100644
|
||||
--- a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||
+++ b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java
|
||||
@@ -5,13 +5,28 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public final class CubeVoxelShape extends VoxelShape {
|
||||
+
|
||||
+ private DoubleList[] list = null; // Leaves - cache CubeVoxelShape shape array
|
||||
+
|
||||
protected CubeVoxelShape(DiscreteVoxelShape voxels) {
|
||||
super(voxels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoubleList getCoords(Direction.Axis axis) {
|
||||
- return new CubePointRange(this.shape.getSize(axis));
|
||||
+ // Leaves start - cache CubeVoxelShape shape array
|
||||
+ if (!org.leavesmc.leaves.LeavesConfig.cacheCubeVoxelShapeShapeArray) {
|
||||
+ return new CubePointRange(this.shape.getSize(axis));
|
||||
+ } else {
|
||||
+ if (this.list == null) {
|
||||
+ this.list = new DoubleList[Direction.Axis.VALUES.length];
|
||||
+ for (Direction.Axis existingAxis : Direction.Axis.VALUES) {
|
||||
+ this.list[existingAxis.ordinal()] = new CubePointRange(this.shape.getSize(axis));
|
||||
+ }
|
||||
+ }
|
||||
+ return this.list[axis.ordinal()];
|
||||
+ }
|
||||
+ // Leaves end - cache CubeVoxelShape shape array
|
||||
}
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user