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:
CraftBukkit/Spigot
2021-08-22 13:23:40 +02:00
parent 80b1ef0c8e
commit 44cc499340
4 changed files with 66 additions and 16 deletions

View File

@@ -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;

View File

@@ -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();