Fix issues with new ChunkGenerator API
- RegionAccessor#setType / RegionAccessor#setBlockData doesn't run entity removal logic - RegionAccessor#generateTree crashes by bee nest (TreeType#TALL_BIRCH) By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -41,6 +41,10 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
||||
this.load(snapshot);
|
||||
}
|
||||
|
||||
public void refreshSnapshot() {
|
||||
this.load(tileEntity);
|
||||
}
|
||||
|
||||
private T createSnapshot(T tileEntity) {
|
||||
if (tileEntity == null) {
|
||||
return null;
|
||||
|
||||
@@ -34,12 +34,7 @@ public class CraftBlockState implements BlockState {
|
||||
this.data = ((CraftBlock) block).getNMS();
|
||||
this.flag = 3;
|
||||
|
||||
GeneratorAccess generatorAccess = ((CraftBlock) block).getHandle();
|
||||
if (generatorAccess instanceof net.minecraft.world.level.World) {
|
||||
this.weakWorld = null;
|
||||
} else {
|
||||
this.weakWorld = new WeakReference<>(generatorAccess);
|
||||
}
|
||||
setWorldHandle(((CraftBlock) block).getHandle());
|
||||
}
|
||||
|
||||
public CraftBlockState(final Block block, int flag) {
|
||||
@@ -62,6 +57,14 @@ public class CraftBlockState implements BlockState {
|
||||
return new CraftBlockState(CraftBlock.at(world, pos), flag);
|
||||
}
|
||||
|
||||
public void setWorldHandle(GeneratorAccess generatorAccess) {
|
||||
if (generatorAccess instanceof net.minecraft.world.level.World) {
|
||||
this.weakWorld = null;
|
||||
} else {
|
||||
this.weakWorld = new WeakReference<>(generatorAccess);
|
||||
}
|
||||
}
|
||||
|
||||
public GeneratorAccess getWorldHandle() {
|
||||
if (weakWorld == null) {
|
||||
return world.getHandle();
|
||||
|
||||
Reference in New Issue
Block a user