Fix async entity add due to fungus trees

This commit is contained in:
Jake Potrebic 2022-03-18 21:30:00 -07:00
parent 012c32fac7
commit 0e9f28fe68
2 changed files with 16 additions and 15 deletions

View file

@ -1,14 +1,12 @@
--- a/net/minecraft/server/level/WorldGenRegion.java --- a/net/minecraft/server/level/WorldGenRegion.java
+++ b/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java
@@ -167,7 +167,27 @@ @@ -169,7 +169,27 @@
int k = this.center.getPos().getChessboardDistance(chunkX, chunkZ);
return k < this.generatingStep.directDependencies().size(); return k < this.generatingStep.directDependencies().size();
+ } }
+
+ // Paper start - if loaded util + // Paper start - if loaded util
+ @Nullable + @Nullable
+ @Override @Override
+ public ChunkAccess getChunkIfLoadedImmediately(int x, int z) { + public ChunkAccess getChunkIfLoadedImmediately(int x, int z) {
+ return this.getChunk(x, z, ChunkStatus.FULL, false); + return this.getChunk(x, z, ChunkStatus.FULL, false);
+ } + }
@ -23,21 +21,24 @@
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) { + public final FluidState getFluidIfLoaded(BlockPos blockposition) {
+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); + ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ return chunk == null ? null : chunk.getFluidState(blockposition); + return chunk == null ? null : chunk.getFluidState(blockposition);
} + }
+ // Paper end + // Paper end
+
@Override + @Override
public BlockState getBlockState(BlockPos pos) { public BlockState getBlockState(BlockPos pos) {
@@ -217,7 +237,7 @@ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos);
}
@@ -217,7 +237,8 @@
if (iblockdata.isAir()) { if (iblockdata.isAir()) {
return false; return false;
} else { } else {
- if (drop) { - if (drop) {
+ if (drop) LOGGER.warn("Potential async entity add during worldgen", new Throwable()); // Paper - Fix async entity add due to fungus trees; log when this happens
+ if (false) { // CraftBukkit - SPIGOT-6833: Do not drop during world generation + if (false) { // CraftBukkit - SPIGOT-6833: Do not drop during world generation
BlockEntity tileentity = iblockdata.hasBlockEntity() ? this.getBlockEntity(pos) : null; BlockEntity tileentity = iblockdata.hasBlockEntity() ? this.getBlockEntity(pos) : null;
Block.dropResources(iblockdata, this.level, pos, tileentity, breakingEntity, ItemStack.EMPTY); Block.dropResources(iblockdata, this.level, pos, tileentity, breakingEntity, ItemStack.EMPTY);
@@ -264,6 +284,7 @@ @@ -264,6 +285,7 @@
} }
} }
@ -45,7 +46,7 @@
@Override @Override
public boolean ensureCanWrite(BlockPos pos) { public boolean ensureCanWrite(BlockPos pos) {
int i = SectionPos.blockToSectionCoord(pos.getX()); int i = SectionPos.blockToSectionCoord(pos.getX());
@@ -283,7 +304,15 @@ @@ -283,7 +305,15 @@
return true; return true;
} else { } else {
@ -61,7 +62,7 @@
return false; return false;
} }
} }
@@ -336,6 +365,13 @@ @@ -336,6 +366,13 @@
@Override @Override
public boolean addFreshEntity(Entity entity) { public boolean addFreshEntity(Entity entity) {

View file

@ -261,10 +261,10 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
((ChorusFlowerBlock) Blocks.CHORUS_FLOWER).generatePlant(access, pos, random, 8); ((ChorusFlowerBlock) Blocks.CHORUS_FLOWER).generatePlant(access, pos, random, 8);
return true; return true;
case CRIMSON_FUNGUS: case CRIMSON_FUNGUS:
gen = TreeFeatures.CRIMSON_FUNGUS_PLANTED; gen = this.isNormalWorld() ? TreeFeatures.CRIMSON_FUNGUS_PLANTED : TreeFeatures.CRIMSON_FUNGUS; // Paper - Fix async entity add due to fungus trees; if world gen, don't use planted version
break; break;
case WARPED_FUNGUS: case WARPED_FUNGUS:
gen = TreeFeatures.WARPED_FUNGUS_PLANTED; gen = this.isNormalWorld() ? TreeFeatures.WARPED_FUNGUS_PLANTED : TreeFeatures.WARPED_FUNGUS; // Paper - Fix async entity add due to fungus trees; if world gen, don't use planted version
break; break;
case AZALEA: case AZALEA:
gen = TreeFeatures.AZALEA_TREE; gen = TreeFeatures.AZALEA_TREE;