Skip to content

Commit be1495d

Browse files
committed
Update PlayerSonar
1 parent a2c8796 commit be1495d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public void onReceivedPacket(PacketInputEvent event)
130130
{
131131
if(MC.player == null || MC.level == null)
132132
return;
133+
134+
// In local singleplayer worlds there are no remote players, so block
135+
// updates are almost always natural/server-simulated changes.
136+
if(MC.isLocalServer())
137+
return;
133138

134139
Packet<?> packet = event.getPacket();
135140
if(packet instanceof ClientboundBlockUpdatePacket blockUpdate)
@@ -180,6 +185,8 @@ private DetectionResult classifyRelevantTransition(BlockState oldState,
180185
boolean newFluid = !newState.getFluidState().isEmpty();
181186
String oldId = getBlockId(oldState);
182187
String newId = getBlockId(newState);
188+
if(isLikelyNaturalTransition(oldId, newId))
189+
return DetectionResult.NONE;
183190

184191
if(isFluidOrFireState(oldState) || isFluidOrFireState(newState))
185192
return DetectionResult.NONE;
@@ -205,6 +212,31 @@ private DetectionResult classifyRelevantTransition(BlockState oldState,
205212
return DetectionResult.NONE;
206213
}
207214

215+
private boolean isLikelyNaturalTransition(String oldId, String newId)
216+
{
217+
return isLikelyNaturalBlock(oldId) || isLikelyNaturalBlock(newId);
218+
}
219+
220+
private boolean isLikelyNaturalBlock(String blockId)
221+
{
222+
if(blockId == null)
223+
return false;
224+
225+
if("minecraft:air".equals(blockId))
226+
return false;
227+
228+
return blockId.contains("vine") || blockId.contains("amethyst_bud")
229+
|| blockId.contains("mushroom") || blockId.contains("short_grass")
230+
|| blockId.contains("tall_grass") || blockId.contains("fern")
231+
|| blockId.contains("lichen") || blockId.contains("moss")
232+
|| blockId.contains("seagrass") || blockId.contains("kelp")
233+
|| blockId.contains("sugar_cane") || blockId.contains("cactus")
234+
|| blockId.contains("bamboo") || blockId.contains("dripleaf")
235+
|| blockId.contains("dripstone") || blockId.contains("cocoa")
236+
|| blockId.contains("nether_wart") || blockId.contains("crop")
237+
|| blockId.contains("sweet_berry_bush");
238+
}
239+
208240
private boolean hasInteractiveFlip(BlockState oldState, BlockState newState)
209241
{
210242
try

0 commit comments

Comments
 (0)