mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
69 lines
3.5 KiB
Diff
69 lines
3.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sun, 6 Jul 2025 01:55:37 +0300
|
|
Subject: [PATCH] C2ME: Optimize world gen math
|
|
|
|
This patch is based on following mixins:
|
|
* "com/ishland/c2me/opts/math/mixin/MixinChunkPos.java"
|
|
* "com/ishland/c2me/opts/worldgen/vanilla/mixin/structure_weight_sampler/MixinStructureWeightSampler.java"
|
|
By: ishland <ishlandmc@yeah.net>
|
|
As part of: C2ME-fabric (https://github.com/RelativityMC/C2ME-fabric)
|
|
Licensed under: MIT
|
|
|
|
diff --git a/net/minecraft/world/level/ChunkPos.java b/net/minecraft/world/level/ChunkPos.java
|
|
index 55ce935a2fab7e32904d9ff599867269035d703f..7770e2aacaa7772a1710172f143452f076c6eef2 100644
|
|
--- a/net/minecraft/world/level/ChunkPos.java
|
|
+++ b/net/minecraft/world/level/ChunkPos.java
|
|
@@ -110,7 +110,12 @@ public class ChunkPos {
|
|
|
|
@Override
|
|
public boolean equals(Object other) {
|
|
- return this == other || other instanceof ChunkPos chunkPos && this.x == chunkPos.x && this.z == chunkPos.z;
|
|
+ // DivineMC start - C2ME: Optimize world gen math
|
|
+ if (other == this) return true;
|
|
+ if (other == null || other.getClass() != this.getClass()) return false;
|
|
+ ChunkPos thatPos = (ChunkPos) other;
|
|
+ return this.x == thatPos.x && this.z == thatPos.z;
|
|
+ // DivineMC end - C2ME: Optimize world gen math
|
|
}
|
|
|
|
public int getMiddleBlockX() {
|
|
diff --git a/net/minecraft/world/level/levelgen/Beardifier.java b/net/minecraft/world/level/levelgen/Beardifier.java
|
|
index 74d8202b5c9bb2a3ee832be70f95c0b5cbecb460..86c15d2d90e63d21cb83622a7b29e11151a4f64a 100644
|
|
--- a/net/minecraft/world/level/levelgen/Beardifier.java
|
|
+++ b/net/minecraft/world/level/levelgen/Beardifier.java
|
|
@@ -131,8 +131,14 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
|
|
}
|
|
|
|
private static double getBuryContribution(double x, double y, double z) {
|
|
- double len = Mth.length(x, y, z);
|
|
- return Mth.clampedMap(len, 0.0, 6.0, 1.0, 0.0);
|
|
+ // DivineMC start - C2ME: Optimize world gen math
|
|
+ double len = Math.sqrt(x * x + y * y + z * z);
|
|
+ if (len > 6.0) {
|
|
+ return 0.0;
|
|
+ } else {
|
|
+ return 1.0 - len / 6.0;
|
|
+ }
|
|
+ // DivineMC end - C2ME: Optimize world gen math
|
|
}
|
|
|
|
private static double getBeardContribution(int x, int y, int z, int height) {
|
|
diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
index 65728ef17e63d71833677fdcbd5bb90794b4822b..5716e80ba386f113d02f5d6a4848914d4bf9600f 100644
|
|
--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
+++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
@@ -68,8 +68,10 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
|
Aquifer.FluidStatus fluidStatus = new Aquifer.FluidStatus(-54, Blocks.LAVA.defaultBlockState());
|
|
int seaLevel = settings.seaLevel();
|
|
Aquifer.FluidStatus fluidStatus1 = new Aquifer.FluidStatus(seaLevel, settings.defaultFluid());
|
|
- Aquifer.FluidStatus fluidStatus2 = new Aquifer.FluidStatus(DimensionType.MIN_Y * 2, Blocks.AIR.defaultBlockState());
|
|
- return (x, y, z) -> y < Math.min(-54, seaLevel) ? fluidStatus : fluidStatus1;
|
|
+ // DivineMC start - C2ME: Optimize world gen math
|
|
+ final int min = Math.min(-54, seaLevel);
|
|
+ return (x, y, z) -> y < min ? fluidStatus : fluidStatus1;
|
|
+ // DivineMC end - C2ME: Optimize world gen math
|
|
}
|
|
|
|
@Override
|