mirror of
https://github.com/BX-Team/DivineMC.git
synced 2026-01-06 15:41:52 +00:00
add lithium: combined_heightmap_update
This commit is contained in:
@@ -38,6 +38,7 @@ public net.minecraft.world.level.levelgen.DensityFunctions$TwoArgumentSimpleFunc
|
||||
public net.minecraft.world.level.levelgen.DensityFunctions$WeirdScaledSampler
|
||||
public net.minecraft.world.level.levelgen.DensityFunctions$WeirdScaledSampler$RarityValueMapper mapper
|
||||
public net.minecraft.world.level.levelgen.DensityFunctions$YClampedGradient
|
||||
public net.minecraft.world.level.levelgen.Heightmap setHeight(III)V
|
||||
public net.minecraft.world.level.levelgen.NoiseChunk$BlendAlpha
|
||||
public net.minecraft.world.level.levelgen.NoiseChunk$BlendOffset
|
||||
public net.minecraft.world.level.levelgen.NoiseRouterData$QuantizedSpaghettiRarity
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Wed, 27 Aug 2025 22:48:22 +0300
|
||||
Subject: [PATCH] lithium: combined_heightmap_update
|
||||
|
||||
This patch is based on the following mixins:
|
||||
* "net/caffeinemc/mods/lithium/mixin/world/combined_heightmap_update/LevelChunkMixin"
|
||||
By: 2No2Name <2No2Name@web.de>
|
||||
As part of: Lithium (https://github.com/CaffeineMC/lithium)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 404ed7c6ebe2364b9404df6e29d07a0aed83ed08..853b7459bd6b62bc9eb98953b1ab9435b38de844 100644
|
||||
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -380,10 +380,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
return null;
|
||||
} else {
|
||||
Block block = state.getBlock();
|
||||
- this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(i, y, i2, state);
|
||||
- this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(i, y, i2, state);
|
||||
- this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR).update(i, y, i2, state);
|
||||
- this.heightmaps.get(Heightmap.Types.WORLD_SURFACE).update(i, y, i2, state);
|
||||
+ // DivineMC start - lithium: combined_heightmap_update
|
||||
+ Heightmap heightmap0 = this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING);
|
||||
+ Heightmap heightmap1 = this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES);
|
||||
+ Heightmap heightmap2 = this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR);
|
||||
+ Heightmap heightmap3 = this.heightmaps.get(Heightmap.Types.WORLD_SURFACE);
|
||||
+ net.caffeinemc.mods.lithium.common.world.chunk.heightmap.CombinedHeightmapUpdate.updateHeightmaps(heightmap0, heightmap1, heightmap2, heightmap3, this, i, y, i2, state);
|
||||
+ // DivineMC end - lithium: combined_heightmap_update
|
||||
boolean hasOnlyAir1 = section.hasOnlyAir();
|
||||
if (hasOnlyAir != hasOnlyAir1) {
|
||||
this.level.getChunkSource().getLightEngine().updateSectionStatus(pos, hasOnlyAir1);
|
||||
diff --git a/net/minecraft/world/level/levelgen/Heightmap.java b/net/minecraft/world/level/levelgen/Heightmap.java
|
||||
index 5fc80f67cd76bb557e2f629d91b5c6538b660d28..28681630564fa4c4527280537e334c9e62c274a7 100644
|
||||
--- a/net/minecraft/world/level/levelgen/Heightmap.java
|
||||
+++ b/net/minecraft/world/level/levelgen/Heightmap.java
|
||||
@@ -123,6 +123,12 @@ public class Heightmap {
|
||||
this.data.set(getIndex(x, z), value - this.chunk.getMinY());
|
||||
}
|
||||
|
||||
+ // DivineMC start - lithium: combined_heightmap_update
|
||||
+ public final Predicate<BlockState> isOpaque() {
|
||||
+ return this.isOpaque;
|
||||
+ }
|
||||
+ // DivineMC end - lithium: combined_heightmap_update
|
||||
+
|
||||
public void setRawData(ChunkAccess chunk, Heightmap.Types type, long[] data) {
|
||||
long[] raw = this.data.getRaw();
|
||||
if (raw.length == data.length) {
|
||||
@@ -0,0 +1,138 @@
|
||||
package net.caffeinemc.mods.lithium.common.world.chunk.heightmap;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class CombinedHeightmapUpdate {
|
||||
public static void updateHeightmaps(Heightmap heightmap0, Heightmap heightmap1, Heightmap heightmap2, Heightmap heightmap3, LevelChunk worldChunk, final int x, final int y, final int z, BlockState state) {
|
||||
final int height0 = heightmap0.getFirstAvailable(x, z);
|
||||
final int height1 = heightmap1.getFirstAvailable(x, z);
|
||||
final int height2 = heightmap2.getFirstAvailable(x, z);
|
||||
final int height3 = heightmap3.getFirstAvailable(x, z);
|
||||
int heightmapsToUpdate = 4;
|
||||
if (y + 2 <= height0) {
|
||||
heightmap0 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
if (y + 2 <= height1) {
|
||||
heightmap1 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
if (y + 2 <= height2) {
|
||||
heightmap2 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
if (y + 2 <= height3) {
|
||||
heightmap3 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
|
||||
if (heightmapsToUpdate == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Predicate<BlockState> blockPredicate0 = heightmap0 == null ? null : Objects.requireNonNull(heightmap0.isOpaque());
|
||||
Predicate<BlockState> blockPredicate1 = heightmap1 == null ? null : Objects.requireNonNull(heightmap1.isOpaque());
|
||||
Predicate<BlockState> blockPredicate2 = heightmap2 == null ? null : Objects.requireNonNull(heightmap2.isOpaque());
|
||||
Predicate<BlockState> blockPredicate3 = heightmap3 == null ? null : Objects.requireNonNull(heightmap3.isOpaque());
|
||||
|
||||
if (heightmap0 != null) {
|
||||
if (blockPredicate0.test(state)) {
|
||||
if (y >= height0) {
|
||||
heightmap0.setHeight(x, z, y + 1);
|
||||
}
|
||||
heightmap0 = null;
|
||||
heightmapsToUpdate--;
|
||||
} else if (height0 != y + 1) {
|
||||
heightmap0 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
}
|
||||
if (heightmap1 != null) {
|
||||
if (blockPredicate1.test(state)) {
|
||||
if (y >= height1) {
|
||||
heightmap1.setHeight(x, z, y + 1);
|
||||
}
|
||||
heightmap1 = null;
|
||||
heightmapsToUpdate--;
|
||||
} else if (height1 != y + 1) {
|
||||
heightmap1 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
}
|
||||
if (heightmap2 != null) {
|
||||
if (blockPredicate2.test(state)) {
|
||||
if (y >= height2) {
|
||||
heightmap2.setHeight(x, z, y + 1);
|
||||
}
|
||||
heightmap2 = null;
|
||||
heightmapsToUpdate--;
|
||||
} else if (height2 != y + 1) {
|
||||
heightmap2 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
}
|
||||
if (heightmap3 != null) {
|
||||
if (blockPredicate3.test(state)) {
|
||||
if (y >= height3) {
|
||||
heightmap3.setHeight(x, z, y + 1);
|
||||
}
|
||||
heightmap3 = null;
|
||||
heightmapsToUpdate--;
|
||||
} else if (height3 != y + 1) {
|
||||
heightmap3 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (heightmapsToUpdate == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
|
||||
int bottomY = worldChunk.getMinY();
|
||||
|
||||
for (int searchY = y - 1; searchY >= bottomY && heightmapsToUpdate > 0; --searchY) {
|
||||
mutable.set(x, searchY, z);
|
||||
BlockState blockState = worldChunk.getBlockState(mutable);
|
||||
if (heightmap0 != null && blockPredicate0.test(blockState)) {
|
||||
heightmap0.setHeight(x, z, searchY + 1);
|
||||
heightmap0 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
if (heightmap1 != null && blockPredicate1.test(blockState)) {
|
||||
heightmap1.setHeight(x, z, searchY + 1);
|
||||
heightmap1 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
if (heightmap2 != null && blockPredicate2.test(blockState)) {
|
||||
heightmap2.setHeight(x, z, searchY + 1);
|
||||
heightmap2 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
if (heightmap3 != null && blockPredicate3.test(blockState)) {
|
||||
heightmap3.setHeight(x, z, searchY + 1);
|
||||
heightmap3 = null;
|
||||
heightmapsToUpdate--;
|
||||
}
|
||||
}
|
||||
if (heightmap0 != null) {
|
||||
heightmap0.setHeight(x, z, bottomY);
|
||||
}
|
||||
if (heightmap1 != null) {
|
||||
heightmap1.setHeight(x, z, bottomY);
|
||||
}
|
||||
if (heightmap2 != null) {
|
||||
heightmap2.setHeight(x, z, bottomY);
|
||||
}
|
||||
if (heightmap3 != null) {
|
||||
heightmap3.setHeight(x, z, bottomY);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user