mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
46 lines
2.0 KiB
Diff
46 lines
2.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Thu, 20 Jul 2023 20:22:47 +0800
|
|
Subject: [PATCH] Optimized CubePointRange
|
|
|
|
This patch is Powered by Gale(https://github.com/GaleMC/Gale)
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java
|
|
index ad02cdb00360165f6405eb3044bd8320f01a7ef1..99ddf5419833244338d349a32e576d21198cef54 100644
|
|
--- a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java
|
|
+++ b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java
|
|
@@ -3,21 +3,31 @@ package net.minecraft.world.phys.shapes;
|
|
import it.unimi.dsi.fastutil.doubles.AbstractDoubleList;
|
|
|
|
public class CubePointRange extends AbstractDoubleList {
|
|
+ private final int size; // Leaves - replace parts by size in CubePointRange
|
|
private final int parts;
|
|
+ private final double scale; // Leaves - replace division by multiplication in CubePointRange
|
|
|
|
public CubePointRange(int sectionCount) {
|
|
if (sectionCount <= 0) {
|
|
throw new IllegalArgumentException("Need at least 1 part");
|
|
} else {
|
|
this.parts = sectionCount;
|
|
+ this.size = sectionCount + 1;
|
|
}
|
|
+ this.scale = 1.0D / sectionCount; // Leaves - replace division by multiplication in CubePointRange
|
|
}
|
|
|
|
public double getDouble(int i) {
|
|
- return (double)i / (double)this.parts;
|
|
+ // Leaves start - replace division by multiplication in CubePointRange
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.optimizedCubePointRange) {
|
|
+ return (double)i / (double)this.parts;
|
|
+ } else {
|
|
+ return i * this.scale;
|
|
+ }
|
|
+ // Leaves start - replace division by multiplication in CubePointRange
|
|
}
|
|
|
|
public int size() {
|
|
- return this.parts + 1;
|
|
+ return !org.leavesmc.leaves.LeavesConfig.optimizedCubePointRange ? this.parts + 1 : size; // Leaves - replace parts by size in CubePointRange
|
|
}
|
|
}
|