Skip to content

Commit 798a22f

Browse files
committed
Fix chunkgenerate on Forge 1.21.6
1 parent 4daa33f commit 798a22f

File tree

3 files changed

+41
-48
lines changed

3 files changed

+41
-48
lines changed

DynmapCore/src/main/java/org/dynmap/hdmap/ChunkStatusHDShader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ private static class ChunkStatusMap {
4343
new ChunkStatusMap("carvers", 0xFFEFD5);
4444
new ChunkStatusMap("liquid_carvers", 0xF0E68C);
4545
new ChunkStatusMap("features", 0xBDB76B);
46+
new ChunkStatusMap("initialize_light", 0xAAA0AA);
4647
new ChunkStatusMap("light", 0xDDA0DD);
47-
new ChunkStatusMap("spawn", 0xFF00FF);
4848
new ChunkStatusMap("heightmaps", 0x9370DB);
49+
new ChunkStatusMap("spawn", 0xFF00FF);
4950
new ChunkStatusMap("full", 0x32CD32);
5051
}
5152

bukkit-helper/.settings/org.eclipse.buildship.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ arguments=
22
auto.sync=false
33
build.scans.enabled=false
44
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
5-
connection.project.dir=../forge-1.21.6
5+
connection.project.dir=..
66
eclipse.preferences.version=1
77
gradle.user.home=
88
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home

forge-1.20.6/src/main/java/org/dynmap/forge_1_20_6/DynmapPlugin.java

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
import net.minecraft.world.level.LevelAccessor;
5555
import net.minecraft.world.level.biome.Biome;
5656
import net.minecraft.world.level.block.Block;
57-
import net.minecraft.world.level.block.LeavesBlock;
5857
import net.minecraft.world.level.block.LiquidBlock;
59-
import net.minecraft.world.level.block.SoundType;
6058
import net.minecraft.world.level.block.state.BlockState;
6159
import net.minecraft.world.level.chunk.ChunkAccess;
6260
import net.minecraft.world.level.chunk.LevelChunk;
@@ -125,7 +123,6 @@
125123
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
126124
import net.minecraftforge.eventbus.api.EventPriority;
127125
import net.minecraftforge.eventbus.api.SubscribeEvent;
128-
129126
import net.minecraft.world.level.EmptyBlockGetter;
130127

131128
public class DynmapPlugin
@@ -1730,7 +1727,35 @@ public void run() {
17301727
}
17311728
}
17321729

1733-
@SubscribeEvent(priority=EventPriority.LOWEST)
1730+
private void touchChunk(ForgeWorld fw, ChunkAccess c, String cause) {
1731+
int ymax = Integer.MIN_VALUE;
1732+
int ymin = Integer.MAX_VALUE;
1733+
LevelChunkSection[] sections = c.getSections();
1734+
// If no sections, assume all
1735+
if (sections.length == 0) {
1736+
ymax = (c.getMaxSection()+1) << 4;
1737+
ymin = c.getMinSection() << 4;
1738+
}
1739+
else {
1740+
for(int i = 0; i < sections.length; i++) {
1741+
if((sections[i] != null) && (sections[i].hasOnlyAir() == false)) {
1742+
int sy = c.getSectionYFromSectionIndex(i) << 4;
1743+
if (sy < ymin) ymin = sy;
1744+
if ((sy+16) > ymax) ymax = sy + 16;
1745+
}
1746+
}
1747+
}
1748+
ChunkPos cp = c.getPos();
1749+
int x = cp.x << 4;
1750+
int z = cp.z << 4;
1751+
Log.info(String.format("ymin=%d, ymax=%d", ymin, ymax));
1752+
// If not empty AND not initial scan
1753+
if (ymax != Integer.MIN_VALUE) {
1754+
mapManager.touchVolume(fw.getName(), x, ymin, z, x+15, ymax, z+15, "chunkgenerate");
1755+
}
1756+
}
1757+
1758+
@SubscribeEvent(priority=EventPriority.MONITOR)
17341759
public void handleChunkLoad(ChunkEvent.Load event) {
17351760
if(!onchunkgenerate) return;
17361761

@@ -1744,7 +1769,7 @@ public void handleChunkLoad(ChunkEvent.Load event) {
17441769
}
17451770
}
17461771
}
1747-
@SubscribeEvent(priority=EventPriority.LOWEST)
1772+
@SubscribeEvent(priority=EventPriority.MONITOR)
17481773
public void handleChunkUnload(ChunkEvent.Unload event) {
17491774
if(!onchunkgenerate) return;
17501775

@@ -1756,29 +1781,13 @@ public void handleChunkUnload(ChunkEvent.Unload event) {
17561781
ChunkPos cp = c.getPos();
17571782
if (fw != null) {
17581783
if (!checkIfKnownChunk(fw, cp)) {
1759-
int ymax = Integer.MIN_VALUE;
1760-
int ymin = Integer.MAX_VALUE;
1761-
LevelChunkSection[] sections = c.getSections();
1762-
for(int i = 0; i < sections.length; i++) {
1763-
if((sections[i] != null) && (sections[i].hasOnlyAir() == false)) {
1764-
int sy = c.getSectionYFromSectionIndex(i);
1765-
if (sy < ymin) ymin = sy;
1766-
if ((sy+16) > ymax) ymax = sy + 16;
1767-
}
1768-
}
1769-
int x = cp.x << 4;
1770-
int z = cp.z << 4;
1771-
// If not empty AND not initial scan
1772-
if (ymax != Integer.MIN_VALUE) {
1773-
//Log.info(String.format("chunkkeyerate(unload)(%s,%d,%d,%d,%d,%d,%s)", fw.getName(), x, ymin, z, x+15, ymax, z+15));
1774-
mapManager.touchVolume(fw.getName(), x, ymin, z, x+15, ymax, z+15, "chunkgenerate");
1775-
}
1784+
touchChunk(fw, c, "unload");
17761785
}
17771786
removeKnownChunk(fw, cp);
17781787
}
17791788
}
17801789
}
1781-
@SubscribeEvent(priority=EventPriority.LOWEST)
1790+
@SubscribeEvent(priority=EventPriority.MONITOR)
17821791
public void handleChunkDataSave(ChunkDataEvent.Save event) {
17831792
if(!onchunkgenerate) return;
17841793

@@ -1789,33 +1798,16 @@ public void handleChunkDataSave(ChunkDataEvent.Save event) {
17891798
ForgeWorld fw = getWorld((ServerLevel)w, false);
17901799
ChunkPos cp = c.getPos();
17911800
if (fw != null) {
1792-
if (!checkIfKnownChunk(fw, cp)) {
1793-
int ymax = Integer.MIN_VALUE;
1794-
int ymin = Integer.MAX_VALUE;
1795-
LevelChunkSection[] sections = c.getSections();
1796-
for(int i = 0; i < sections.length; i++) {
1797-
if((sections[i] != null) && (sections[i].hasOnlyAir() == false)) {
1798-
int sy = c.getSectionYFromSectionIndex(i);
1799-
if (sy < ymin) ymin = sy;
1800-
if ((sy+16) > ymax) ymax = sy + 16;
1801-
}
1802-
}
1803-
int x = cp.x << 4;
1804-
int z = cp.z << 4;
1805-
// If not empty AND not initial scan
1806-
if (ymax != Integer.MIN_VALUE) {
1807-
//Log.info(String.format("chunkkeyerate(save)(%s,%d,%d,%d,%d,%d,%s)", fw.getName(), x, ymin, z, x+15, ymax, z+15));
1808-
mapManager.touchVolume(fw.getName(), x, ymin, z, x+15, ymax, z+15, "chunkgenerate");
1809-
}
1810-
// If cooked, add to known
1811-
if ((c.getStatus() == ChunkStatus.FULL) && (c instanceof LevelChunk)) {
1812-
addKnownChunk(fw, cp);
1813-
}
1801+
touchChunk(fw, c, "datasave");
1802+
// If cooked, add to known
1803+
if (c.getStatus() == ChunkStatus.FULL) {
1804+
addKnownChunk(fw, cp);
18141805
}
18151806
}
18161807
}
18171808
}
1818-
@SubscribeEvent(priority=EventPriority.LOWEST)
1809+
1810+
@SubscribeEvent(priority=EventPriority.MONITOR, receiveCanceled=false)
18191811
public void handleBlockEvent(BlockEvent event) {
18201812
if(!core_enabled) return;
18211813
if(!onblockchange) return;

0 commit comments

Comments
 (0)