check chunk load in sepples

This commit is contained in:
Leijurv 2023-08-20 11:53:54 -07:00
parent e063475ebd
commit c4f33b72c2
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 7 additions and 2 deletions

View File

@ -77,7 +77,7 @@ allprojects {
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.17.1+build.32:v2"
//launchImplementation('dev.babbaj:nether-pathfinder:1.3.0')
implementation 'dev.babbaj:nether-pathfinder:1.3.0'
implementation 'dev.babbaj:nether-pathfinder:1.4'
}
tasks.withType(JavaCompile).configureEach {

View File

@ -42,6 +42,7 @@ import net.minecraft.world.entity.projectile.FireworkRocketEntity;
import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.LevelChunk;
@ -302,7 +303,7 @@ public final class ElytraBehavior implements Helper {
int rangeStartIncl = playerNear;
int rangeEndExcl = playerNear;
while (rangeEndExcl < path.size() && ctx.world().isLoaded(path.get(rangeEndExcl))) {
while (rangeEndExcl < path.size() && context.hasChunk(new ChunkPos(path.get(rangeEndExcl)))) {
rangeEndExcl++;
}
// rangeEndExcl now represents an index either not in the path, or just outside render distance

View File

@ -60,6 +60,10 @@ public final class NetherPathfinderContext {
this.executor = Executors.newSingleThreadExecutor();
}
public boolean hasChunk(ChunkPos pos) {
return NetherPathfinder.hasChunkFromJava(this.context, pos.x, pos.z);
}
public void queueCacheCulling(int chunkX, int chunkZ, int maxDistanceBlocks, BlockStateOctreeInterface boi) {
this.executor.execute(() -> {
synchronized (this.cullingLock) {