9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-21 15:59:33 +00:00
Files
LeavesMC/patches/server/0097-Optimized-CubePointRange.patch
2023-09-28 18:12:42 +08:00

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 a544db042c8d2ecec8d323770552c4f10ca758a6..81d18ce2ee4342b466c6623bcad7840c929eb79d 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
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 (!top.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 !top.leavesmc.leaves.LeavesConfig.optimizedCubePointRange ? this.parts + 1 : size; // Leaves - replace parts by size in CubePointRange
}
}