fix: 服务器关闭线程阻塞
All checks were successful
Release for 1.20.1 / Publish release JAR for Ex Deorum (push) Has been skipped

This commit is contained in:
叁玖领域 2026-06-22 08:39:09 +08:00
parent 5fd96df998
commit 0c5da1275d

View File

@ -19,6 +19,7 @@
package thedarkcolour.exdeorum.block;
import net.minecraft.core.BlockPos;
import net.minecraft.core.SectionPos;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.BlockGetter;
@ -50,6 +51,16 @@ public abstract class AbstractCrucibleBlock extends ETankBlock {
@Override
public int getLightEmission(BlockState state, BlockGetter level, BlockPos pos) {
// Only attempt to access the block entity if the chunk is already loaded.
// This prevents getExistingBlockEntity from triggering asynchronous chunk
// loading, which can cause the server to hang during shutdown.
if (level instanceof Level world) {
int chunkX = SectionPos.blockToSectionCoord(pos.getX());
int chunkZ = SectionPos.blockToSectionCoord(pos.getZ());
if (!world.hasChunk(chunkX, chunkZ)) {
return 0;
}
}
if (level.getExistingBlockEntity(pos) instanceof AbstractCrucibleBlockEntity crucible) {
return crucible.getTank().getFluid().getFluid().getFluidType().getLightLevel();
}