Per discussions with TqLxQuanZ, and the following:
|
return level.hasChunkAt(pos); |
not working as expected when c2me is present. The value returned from here will be unreliable as that chunk may be being worked on in another thread, to get around it you need to directly query the chunk building future to see if it has a value or not:
private static boolean isChunkLoaded(Level level, BlockPos pos) {
if (level instanceof ServerLevel serverLevel) {
ServerChunkCache chunkSource = serverLevel.getChunkSource();
int x = SectionPos.blockToSectionCoord(pos.getX());
int z = SectionPos.blockToSectionCoord(pos.getZ());
if (chunkSource.mainThread != Thread.currentThread()) return chunkSource.hasChunk(x, z);
return chunkSource.getChunkFutureMainThread(x, z, ChunkStatus.FULL, false).isDone();
}
return level.isLoaded(pos);
}
now of course mainThread and getChunkFutureMainThread are not exposed so you need to use mixin, access transformation or reflection to access these and it does not appear that your build setup allows for mixins or ATs as far as I can tell, I would PR otherwise but I am not overly familiar with your build setup and don't really want to mess with it to allow the necessary access transformation. Reflection is also noticeably slow given the number of times this path is invoked.
I have implemented a fix as a mixin in another mod but it'd be best if this was a part of the main mod: https://github.com/Bawnorton/DCFixes/blob/2163f4bd74157db207617138661b0203a466213a/src/main/java/com/bawnorton/dcfixes/mixin/hazardous/HazardManagerMixin.java
Per discussions with TqLxQuanZ, and the following:
Hazardous/src/main/java/mcjty/hazardous/data/HazardManager.java
Line 133 in 0c19424
now of course
mainThreadandgetChunkFutureMainThreadare not exposed so you need to use mixin, access transformation or reflection to access these and it does not appear that your build setup allows for mixins or ATs as far as I can tell, I would PR otherwise but I am not overly familiar with your build setup and don't really want to mess with it to allow the necessary access transformation. Reflection is also noticeably slow given the number of times this path is invoked.I have implemented a fix as a mixin in another mod but it'd be best if this was a part of the main mod: https://github.com/Bawnorton/DCFixes/blob/2163f4bd74157db207617138661b0203a466213a/src/main/java/com/bawnorton/dcfixes/mixin/hazardous/HazardManagerMixin.java