Add TickThread check to ServerChunkCache#getChunkNow
We shouldn't be using the currently loading chunk unless we are on the main thread.
This commit is contained in:
@@ -199,7 +199,7 @@ abstract class LevelMixin implements ChunkSystemLevel, ChunkSystemEntityGetter,
|
||||
|
||||
@Override
|
||||
public LevelChunk moonrise$getFullChunkIfLoaded(final int chunkX, final int chunkZ) {
|
||||
return this.getChunkSource().getChunk(chunkX, chunkZ, false);
|
||||
return (LevelChunk)this.getChunkSource().getChunk(chunkX, chunkZ, ChunkStatus.FULL, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -106,8 +106,10 @@ abstract class ServerChunkCacheMixin extends ChunkSource implements ChunkSystemS
|
||||
return ifPresent;
|
||||
}
|
||||
|
||||
if (currentChunk != null) {
|
||||
final ChunkAccess loading = PlatformHooks.get().getCurrentlyLoadingChunk(currentChunk.vanillaChunkHolder);
|
||||
final PlatformHooks platformHooks = PlatformHooks.get();
|
||||
|
||||
if (platformHooks.hasCurrentlyLoadingChunk() && currentChunk != null) {
|
||||
final ChunkAccess loading = platformHooks.getCurrentlyLoadingChunk(currentChunk.vanillaChunkHolder);
|
||||
if (loading != null && TickThread.isTickThread()) {
|
||||
return loading;
|
||||
}
|
||||
@@ -149,7 +151,7 @@ abstract class ServerChunkCacheMixin extends ChunkSource implements ChunkSystemS
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret != null) {
|
||||
if (ret != null || !TickThread.isTickThread()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -437,7 +437,6 @@ abstract class ExplosionMixin {
|
||||
}
|
||||
|
||||
final double diameter = (double)this.radius * 2.0;
|
||||
// use null predicate to avoid indirection on test(), but we need to move the spectator check into the loop itself
|
||||
final List<Entity> entities = this.level.getEntities(this.source,
|
||||
new AABB(
|
||||
(double)Mth.floor(this.x - (diameter + 1.0)),
|
||||
|
||||
@@ -1119,24 +1119,6 @@ public final class NewChunkHolder {
|
||||
private static final long CHUNK_LOADED_MASK_RAD1 = getLoadedMask(1);
|
||||
private static final long CHUNK_LOADED_MASK_RAD2 = getLoadedMask(2);
|
||||
|
||||
public static boolean areNeighboursFullLoaded(final long bitset, final int radius) {
|
||||
switch (radius) {
|
||||
case 0: {
|
||||
return (bitset & CHUNK_LOADED_MASK_RAD0) == CHUNK_LOADED_MASK_RAD0;
|
||||
}
|
||||
case 1: {
|
||||
return (bitset & CHUNK_LOADED_MASK_RAD1) == CHUNK_LOADED_MASK_RAD1;
|
||||
}
|
||||
case 2: {
|
||||
return (bitset & CHUNK_LOADED_MASK_RAD2) == CHUNK_LOADED_MASK_RAD2;
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new IllegalArgumentException("Radius not recognized: " + radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only updated while holding scheduling lock
|
||||
private FullChunkStatus pendingFullChunkStatus = FullChunkStatus.INACCESSIBLE;
|
||||
// updated while holding no locks, but adds a ticket before to prevent pending status from dropping
|
||||
|
||||
Reference in New Issue
Block a user