9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-21 15:59:33 +00:00
Files
LeavesMC/patches/server/0093-Optimized-CubePointRange.patch
violetc f40d340092 1.20.6 (#216)
---------

Co-authored-by: MC_XiaoHei <xiaohei.xor7studio@foxmail.com>
Co-authored-by: Bluemangoo <chenfy2006@qq.com>
2024-05-20 23:03:56 +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..d913151417ea72dcb2419d691b869fbf75be8aaa 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 (!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
}
}