Fix ChunkDataEvent.Load not firing, it now fires in the aync thread. Be careful. Closes #6471

This commit is contained in:
LexManos 2020-01-29 12:18:13 -08:00
parent 69ae178bf4
commit c72d6e9122
2 changed files with 29 additions and 3 deletions

View file

@ -17,7 +17,24 @@
chunkprimer.func_201637_h(blockpos);
}
}
@@ -294,12 +295,22 @@
@@ -182,6 +183,7 @@
}
if (chunkstatus$type == ChunkStatus.Type.LEVELCHUNK) {
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(ichunk, compoundnbt, chunkstatus$type));
return new ChunkPrimerWrapper((Chunk)ichunk);
} else {
ChunkPrimer chunkprimer1 = (ChunkPrimer)ichunk;
@@ -215,6 +217,8 @@
chunkprimer1.func_205767_a(generationstage$carving, BitSet.valueOf(compoundnbt5.func_74770_j(s1)));
}
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(ichunk, compoundnbt, chunkstatus$type));
+
return chunkprimer1;
}
}
@@ -294,12 +298,22 @@
for(int k = 0; k < chunk.func_177429_s().length; ++k) {
for(Entity entity : chunk.func_177429_s()[k]) {
CompoundNBT compoundnbt3 = new CompoundNBT();

View file

@ -22,6 +22,7 @@ package net.minecraftforge.event.world;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
@ -54,7 +55,7 @@ public class ChunkDataEvent extends ChunkEvent
/**
* ChunkDataEvent.Load is fired when vanilla Minecraft attempts to load Chunk data.<br>
* This event is fired during chunk loading in
* {@link net.minecraftforge.common.chunkio.ChunkIOProvider#syncCallback()}.<br>
* {@link net.minecraft.world.chunk.storage.ChunkSerializer.read(ServerWorld, TemplateManager, PointOfInterestManager, ChunkPos, CompoundNBT)} which means it is async, so be careful.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
@ -64,9 +65,17 @@ public class ChunkDataEvent extends ChunkEvent
**/
public static class Load extends ChunkDataEvent
{
public Load(IChunk chunk, CompoundNBT data)
private ChunkStatus.Type status;
public Load(IChunk chunk, CompoundNBT data, ChunkStatus.Type status)
{
super(chunk, data);
this.status = status;
}
public ChunkStatus.Type getStatus()
{
return this.status;
}
}