|
19 | 19 | import com.mojang.blaze3d.vertex.PoseStack; |
20 | 20 | import net.minecraft.client.gui.Font; |
21 | 21 | import net.minecraft.client.gui.GuiGraphics; |
| 22 | +import net.minecraft.core.SectionPos; |
22 | 23 | import net.minecraft.world.level.ChunkPos; |
23 | 24 | import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; |
24 | 25 | import net.minecraft.world.entity.player.Player; |
@@ -531,8 +532,8 @@ private boolean isFluidClear(BlockPos pos) |
531 | 532 | BlockPos below = pos.below(); |
532 | 533 | BlockPos above = pos.above(); |
533 | 534 | // Don't trust unknown chunk data for liquid safety checks. |
534 | | - if(!MC.level.hasChunkAt(pos) || !MC.level.hasChunkAt(above) |
535 | | - || !MC.level.hasChunkAt(below)) |
| 535 | + if(!hasLoadedChunk(pos) || !hasLoadedChunk(above) |
| 536 | + || !hasLoadedChunk(below)) |
536 | 537 | { |
537 | 538 | return false; |
538 | 539 | } |
@@ -781,7 +782,7 @@ private boolean hasBedrockWithinDepth(int x, int z, int startY, int minY, |
781 | 782 | for(int y = startY; y >= endY; y--) |
782 | 783 | { |
783 | 784 | pos.set(x, y, z); |
784 | | - if(!MC.level.hasChunkAt(pos)) |
| 785 | + if(!hasLoadedChunk(pos)) |
785 | 786 | return true; |
786 | 787 | if(MC.level.getBlockState(pos).is(Blocks.BEDROCK)) |
787 | 788 | return true; |
@@ -917,8 +918,8 @@ private void tryAddShaftCandidate(ArrayList<ShaftCandidate> candidates, |
917 | 918 |
|
918 | 919 | BlockPos above = new BlockPos(x, y + 1, z); |
919 | 920 | BlockPos below = new BlockPos(x, y - 1, z); |
920 | | - boolean hasAbove = MC.level.hasChunkAt(above); |
921 | | - boolean hasBelow = MC.level.hasChunkAt(below); |
| 921 | + boolean hasAbove = hasLoadedChunk(above); |
| 922 | + boolean hasBelow = hasLoadedChunk(below); |
922 | 923 | if(!hasAbove) |
923 | 924 | return; |
924 | 925 | if(fromAbove && !hasBelow) |
@@ -1021,7 +1022,7 @@ private boolean hasBedrockWithinDepthUp(int x, int z, int startY, int maxY, |
1021 | 1022 | for(int y = startY; y <= endY; y++) |
1022 | 1023 | { |
1023 | 1024 | pos.set(x, y, z); |
1024 | | - if(!MC.level.hasChunkAt(pos)) |
| 1025 | + if(!hasLoadedChunk(pos)) |
1025 | 1026 | return true; |
1026 | 1027 | if(MC.level.getBlockState(pos).is(Blocks.BEDROCK)) |
1027 | 1028 | return true; |
@@ -1101,6 +1102,12 @@ private boolean isSideAllowed(boolean fromAbove) |
1101 | 1102 | return !playerAboveSideBoundary; |
1102 | 1103 | } |
1103 | 1104 |
|
| 1105 | + private static boolean hasLoadedChunk(BlockPos pos) |
| 1106 | + { |
| 1107 | + return MC.level.hasChunk(SectionPos.blockToSectionCoord(pos.getX()), |
| 1108 | + SectionPos.blockToSectionCoord(pos.getZ())); |
| 1109 | + } |
| 1110 | + |
1104 | 1111 | private record ShaftCandidate(BlockPos surfacePos, boolean safe, |
1105 | 1112 | boolean fromAbove) |
1106 | 1113 | {} |
|
0 commit comments