Skip to content

Commit 84eb007

Browse files
committed
Fix compile deprecation warnings
1 parent 05f0c54 commit 84eb007

5 files changed

Lines changed: 42 additions & 15 deletions

File tree

src/main/java/net/wurstclient/hacks/BaseFinderHack.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.ArrayList;
1515
import java.util.HashSet;
1616
import net.minecraft.core.BlockPos;
17+
import net.minecraft.core.SectionPos;
1718
import net.wurstclient.Category;
1819
import net.wurstclient.SearchTags;
1920
import net.wurstclient.WurstRenderLayers;
@@ -506,7 +507,7 @@ public void onUpdate()
506507

507508
// Unloaded chunks can return placeholder states and cause
508509
// large false positives in the air/void.
509-
if(!MC.level.hasChunkAt(pos))
510+
if(!hasLoadedChunk(pos))
510511
continue;
511512

512513
String idFull = BlockUtils.getName(pos);
@@ -595,4 +596,10 @@ private static boolean containsNormalized(String haystack, String needle)
595596
return haystack != null
596597
&& haystack.toLowerCase(java.util.Locale.ROOT).contains(needle);
597598
}
599+
600+
private static boolean hasLoadedChunk(BlockPos pos)
601+
{
602+
return MC.level.hasChunk(SectionPos.blockToSectionCoord(pos.getX()),
603+
SectionPos.blockToSectionCoord(pos.getZ()));
604+
}
598605
}

src/main/java/net/wurstclient/hacks/BedrockEscapeHack.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.mojang.blaze3d.vertex.PoseStack;
2020
import net.minecraft.client.gui.Font;
2121
import net.minecraft.client.gui.GuiGraphics;
22+
import net.minecraft.core.SectionPos;
2223
import net.minecraft.world.level.ChunkPos;
2324
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
2425
import net.minecraft.world.entity.player.Player;
@@ -531,8 +532,8 @@ private boolean isFluidClear(BlockPos pos)
531532
BlockPos below = pos.below();
532533
BlockPos above = pos.above();
533534
// 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))
536537
{
537538
return false;
538539
}
@@ -781,7 +782,7 @@ private boolean hasBedrockWithinDepth(int x, int z, int startY, int minY,
781782
for(int y = startY; y >= endY; y--)
782783
{
783784
pos.set(x, y, z);
784-
if(!MC.level.hasChunkAt(pos))
785+
if(!hasLoadedChunk(pos))
785786
return true;
786787
if(MC.level.getBlockState(pos).is(Blocks.BEDROCK))
787788
return true;
@@ -917,8 +918,8 @@ private void tryAddShaftCandidate(ArrayList<ShaftCandidate> candidates,
917918

918919
BlockPos above = new BlockPos(x, y + 1, z);
919920
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);
922923
if(!hasAbove)
923924
return;
924925
if(fromAbove && !hasBelow)
@@ -1021,7 +1022,7 @@ private boolean hasBedrockWithinDepthUp(int x, int z, int startY, int maxY,
10211022
for(int y = startY; y <= endY; y++)
10221023
{
10231024
pos.set(x, y, z);
1024-
if(!MC.level.hasChunkAt(pos))
1025+
if(!hasLoadedChunk(pos))
10251026
return true;
10261027
if(MC.level.getBlockState(pos).is(Blocks.BEDROCK))
10271028
return true;
@@ -1101,6 +1102,12 @@ private boolean isSideAllowed(boolean fromAbove)
11011102
return !playerAboveSideBoundary;
11021103
}
11031104

1105+
private static boolean hasLoadedChunk(BlockPos pos)
1106+
{
1107+
return MC.level.hasChunk(SectionPos.blockToSectionCoord(pos.getX()),
1108+
SectionPos.blockToSectionCoord(pos.getZ()));
1109+
}
1110+
11041111
private record ShaftCandidate(BlockPos surfacePos, boolean safe,
11051112
boolean fromAbove)
11061113
{}

src/main/java/net/wurstclient/hacks/BedrockStashHack.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.util.List;
1717
import net.minecraft.core.Direction;
1818
import net.minecraft.core.BlockPos;
19+
import net.minecraft.core.SectionPos;
1920
import net.minecraft.world.level.ChunkPos;
2021
import net.minecraft.world.level.Level;
2122
import net.minecraft.world.level.block.Blocks;
@@ -261,7 +262,7 @@ private void tryAddPocket(BlockPos start, ArrayList<StashHit> hits)
261262
while(!queue.isEmpty())
262263
{
263264
BlockPos current = queue.removeFirst();
264-
if(!MC.level.hasChunkAt(current))
265+
if(!hasLoadedChunk(current))
265266
{
266267
leaked = true;
267268
continue;
@@ -284,7 +285,7 @@ private void tryAddPocket(BlockPos start, ArrayList<StashHit> hits)
284285
for(Direction dir : DIRECTIONS)
285286
{
286287
BlockPos neighbor = current.relative(dir);
287-
if(!MC.level.hasChunkAt(neighbor))
288+
if(!hasLoadedChunk(neighbor))
288289
{
289290
leaked = true;
290291
continue;
@@ -330,7 +331,7 @@ private boolean isEnclosedByBedrock(ArrayList<BlockPos> component,
330331
if(componentSet.contains(neighbor.asLong()))
331332
continue;
332333

333-
if(!MC.level.hasChunkAt(neighbor))
334+
if(!hasLoadedChunk(neighbor))
334335
return false;
335336
if(!MC.level.getBlockState(neighbor).is(Blocks.BEDROCK))
336337
return false;
@@ -347,7 +348,7 @@ private boolean hasAdjacentBedrock(BlockPos pos)
347348
for(Direction dir : DIRECTIONS)
348349
{
349350
BlockPos neighbor = pos.relative(dir);
350-
if(!MC.level.hasChunkAt(neighbor))
351+
if(!hasLoadedChunk(neighbor))
351352
continue;
352353
if(MC.level.getBlockState(neighbor).is(Blocks.BEDROCK))
353354
return true;
@@ -535,6 +536,12 @@ private boolean isHitOnPlayerSide(AABB box)
535536
return box.maxY <= sideBoundaryY;
536537
}
537538

539+
private static boolean hasLoadedChunk(BlockPos pos)
540+
{
541+
return MC.level.hasChunk(SectionPos.blockToSectionCoord(pos.getX()),
542+
SectionPos.blockToSectionCoord(pos.getZ()));
543+
}
544+
538545
private record StashHit(AABB box, boolean air)
539546
{}
540547
}

src/main/java/net/wurstclient/hacks/TeleportHack.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import net.minecraft.client.gui.Font;
1414
import net.minecraft.client.gui.GuiGraphics;
1515
import net.minecraft.core.BlockPos;
16+
import net.minecraft.core.SectionPos;
1617
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
1718
import net.minecraft.world.level.ClipContext;
1819
import net.minecraft.world.level.block.state.BlockState;
@@ -342,8 +343,8 @@ private boolean isValidLanding(BlockPos pos)
342343
if(!allowLiquids.isChecked())
343344
{
344345
// Don't trust unknown chunk data for liquid safety checks.
345-
if(!MC.level.hasChunkAt(pos) || !MC.level.hasChunkAt(abovePos)
346-
|| !MC.level.hasChunkAt(belowPos))
346+
if(!hasLoadedChunk(pos) || !hasLoadedChunk(abovePos)
347+
|| !hasLoadedChunk(belowPos))
347348
{
348349
return false;
349350
}
@@ -476,4 +477,10 @@ private int blendColor(Color from, Color to, float t)
476477
int b = (int)(from.getBlue() + (to.getBlue() - from.getBlue()) * t);
477478
return (255 << 24) | (r << 16) | (g << 8) | b;
478479
}
480+
481+
private static boolean hasLoadedChunk(BlockPos pos)
482+
{
483+
return MC.level.hasChunk(SectionPos.blockToSectionCoord(pos.getX()),
484+
SectionPos.blockToSectionCoord(pos.getZ()));
485+
}
479486
}

src/main/java/net/wurstclient/xpgui/XpGuiScreen.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.awt.image.BufferedImage;
2121
import java.nio.file.Files;
2222
import java.nio.file.Path;
23-
import java.net.URL;
2423
import java.net.http.HttpClient;
2524
import java.net.http.HttpRequest;
2625
import java.net.http.HttpResponse;
@@ -3245,7 +3244,7 @@ private byte[] readUrlBytes(String url) throws IOException
32453244
// Fallback below.
32463245
}
32473246

3248-
var conn = new URL(url).openConnection();
3247+
var conn = java.net.URI.create(url).toURL().openConnection();
32493248
conn.setConnectTimeout(15_000);
32503249
conn.setReadTimeout(30_000);
32513250
conn.setRequestProperty("User-Agent",

0 commit comments

Comments
 (0)