Fix chunkgenerate on Forge 1.21.6

This commit is contained in:
Mike Primm 2026-01-09 15:07:07 -05:00
parent 4daa33f540
commit 798a22f99b
3 changed files with 41 additions and 48 deletions

View file

@ -43,9 +43,10 @@ public class ChunkStatusHDShader implements HDShader {
new ChunkStatusMap("carvers", 0xFFEFD5);
new ChunkStatusMap("liquid_carvers", 0xF0E68C);
new ChunkStatusMap("features", 0xBDB76B);
new ChunkStatusMap("initialize_light", 0xAAA0AA);
new ChunkStatusMap("light", 0xDDA0DD);
new ChunkStatusMap("spawn", 0xFF00FF);
new ChunkStatusMap("heightmaps", 0x9370DB);
new ChunkStatusMap("spawn", 0xFF00FF);
new ChunkStatusMap("full", 0x32CD32);
}

View file

@ -2,7 +2,7 @@ arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
connection.project.dir=../forge-1.21.6
connection.project.dir=..
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home

View file

@ -54,9 +54,7 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunk;
@ -125,7 +123,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraft.world.level.EmptyBlockGetter;
public class DynmapPlugin
@ -1730,7 +1727,35 @@ public class DynmapPlugin
}
}
@SubscribeEvent(priority=EventPriority.LOWEST)
private void touchChunk(ForgeWorld fw, ChunkAccess c, String cause) {
int ymax = Integer.MIN_VALUE;
int ymin = Integer.MAX_VALUE;
LevelChunkSection[] sections = c.getSections();
// If no sections, assume all
if (sections.length == 0) {
ymax = (c.getMaxSection()+1) << 4;
ymin = c.getMinSection() << 4;
}
else {
for(int i = 0; i < sections.length; i++) {
if((sections[i] != null) && (sections[i].hasOnlyAir() == false)) {
int sy = c.getSectionYFromSectionIndex(i) << 4;
if (sy < ymin) ymin = sy;
if ((sy+16) > ymax) ymax = sy + 16;
}
}
}
ChunkPos cp = c.getPos();
int x = cp.x << 4;
int z = cp.z << 4;
Log.info(String.format("ymin=%d, ymax=%d", ymin, ymax));
// If not empty AND not initial scan
if (ymax != Integer.MIN_VALUE) {
mapManager.touchVolume(fw.getName(), x, ymin, z, x+15, ymax, z+15, "chunkgenerate");
}
}
@SubscribeEvent(priority=EventPriority.MONITOR)
public void handleChunkLoad(ChunkEvent.Load event) {
if(!onchunkgenerate) return;
@ -1744,7 +1769,7 @@ public class DynmapPlugin
}
}
}
@SubscribeEvent(priority=EventPriority.LOWEST)
@SubscribeEvent(priority=EventPriority.MONITOR)
public void handleChunkUnload(ChunkEvent.Unload event) {
if(!onchunkgenerate) return;
@ -1756,29 +1781,13 @@ public class DynmapPlugin
ChunkPos cp = c.getPos();
if (fw != null) {
if (!checkIfKnownChunk(fw, cp)) {
int ymax = Integer.MIN_VALUE;
int ymin = Integer.MAX_VALUE;
LevelChunkSection[] sections = c.getSections();
for(int i = 0; i < sections.length; i++) {
if((sections[i] != null) && (sections[i].hasOnlyAir() == false)) {
int sy = c.getSectionYFromSectionIndex(i);
if (sy < ymin) ymin = sy;
if ((sy+16) > ymax) ymax = sy + 16;
}
}
int x = cp.x << 4;
int z = cp.z << 4;
// If not empty AND not initial scan
if (ymax != Integer.MIN_VALUE) {
//Log.info(String.format("chunkkeyerate(unload)(%s,%d,%d,%d,%d,%d,%s)", fw.getName(), x, ymin, z, x+15, ymax, z+15));
mapManager.touchVolume(fw.getName(), x, ymin, z, x+15, ymax, z+15, "chunkgenerate");
}
touchChunk(fw, c, "unload");
}
removeKnownChunk(fw, cp);
}
}
}
@SubscribeEvent(priority=EventPriority.LOWEST)
@SubscribeEvent(priority=EventPriority.MONITOR)
public void handleChunkDataSave(ChunkDataEvent.Save event) {
if(!onchunkgenerate) return;
@ -1789,33 +1798,16 @@ public class DynmapPlugin
ForgeWorld fw = getWorld((ServerLevel)w, false);
ChunkPos cp = c.getPos();
if (fw != null) {
if (!checkIfKnownChunk(fw, cp)) {
int ymax = Integer.MIN_VALUE;
int ymin = Integer.MAX_VALUE;
LevelChunkSection[] sections = c.getSections();
for(int i = 0; i < sections.length; i++) {
if((sections[i] != null) && (sections[i].hasOnlyAir() == false)) {
int sy = c.getSectionYFromSectionIndex(i);
if (sy < ymin) ymin = sy;
if ((sy+16) > ymax) ymax = sy + 16;
}
}
int x = cp.x << 4;
int z = cp.z << 4;
// If not empty AND not initial scan
if (ymax != Integer.MIN_VALUE) {
//Log.info(String.format("chunkkeyerate(save)(%s,%d,%d,%d,%d,%d,%s)", fw.getName(), x, ymin, z, x+15, ymax, z+15));
mapManager.touchVolume(fw.getName(), x, ymin, z, x+15, ymax, z+15, "chunkgenerate");
}
touchChunk(fw, c, "datasave");
// If cooked, add to known
if ((c.getStatus() == ChunkStatus.FULL) && (c instanceof LevelChunk)) {
if (c.getStatus() == ChunkStatus.FULL) {
addKnownChunk(fw, cp);
}
}
}
}
}
@SubscribeEvent(priority=EventPriority.LOWEST)
@SubscribeEvent(priority=EventPriority.MONITOR, receiveCanceled=false)
public void handleBlockEvent(BlockEvent event) {
if(!core_enabled) return;
if(!onblockchange) return;