Skip to content

Commit 8a8575c

Browse files
committed
Chunk Energy: Prevent infinitely recursive Chunk loading
-- Only attempt to mark the Chunk as dirty if it's already loaded, not when it's still loading -- Only mark the Chunk as dirty on the server, there's no reason to do so on the client
1 parent 97c5450 commit 8a8575c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/choonster/testmod3/capability/chunkenergy/ChunkEnergy.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ protected void onEnergyChanged() {
9494
final World world = getWorld();
9595
final ChunkPos chunkPos = getChunkPos();
9696

97-
world.getChunkFromChunkCoords(chunkPos.x, chunkPos.z).markDirty();
98-
9997
if (world.isRemote) return;
10098

99+
if (world.isBlockLoaded(chunkPos.getBlock(0, 0, 0))) {
100+
world.getChunkFromChunkCoords(chunkPos.x, chunkPos.z).markDirty();
101+
}
102+
101103
final PlayerChunkMapEntry playerChunkMapEntry = ((WorldServer) world).getPlayerChunkMap().getEntry(chunkPos.x, chunkPos.z);
102104
if (playerChunkMapEntry == null) return;
103105

0 commit comments

Comments
 (0)