Skip to content

Commit ab48ca0

Browse files
committed
Fix TunnelHoleStairESP
1 parent acee8f8 commit ab48ca0

File tree

1 file changed

+51
-27
lines changed

1 file changed

+51
-27
lines changed

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

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ public final class TunnelHoleStairEspHack extends Hack
208208
private final ArrayList<AABB> bubbleColumnBoxes = new ArrayList<>();
209209
private final ArrayList<AABB> waterColumnBoxes = new ArrayList<>();
210210

211-
private int scanConfigHash;
212-
private int refreshTimerTicks;
211+
private int scanConfigHash;
212+
private int refreshTimerTicks;
213+
private Level activeLevel;
213214

214215
public TunnelHoleStairEspHack()
215216
{
@@ -273,35 +274,58 @@ public String getRenderName()
273274
}
274275

275276
@Override
276-
protected void onEnable()
277-
{
278-
scanConfigHash = getScanConfigHash();
279-
refreshTimerTicks = 0;
280-
lastAreaSelection = area.getSelected();
281-
clearRuntimeState();
282-
EVENTS.add(UpdateListener.class, this);
283-
EVENTS.add(RenderListener.class, this);
284-
EVENTS.add(CameraTransformViewBobbingListener.class, this);
285-
EVENTS.add(PacketInputListener.class, this);
277+
protected void onEnable()
278+
{
279+
scanConfigHash = getScanConfigHash();
280+
refreshTimerTicks = 0;
281+
lastAreaSelection = area.getSelected();
282+
activeLevel = null;
283+
clearRuntimeState();
284+
EVENTS.add(UpdateListener.class, this);
285+
EVENTS.add(RenderListener.class, this);
286+
EVENTS.add(CameraTransformViewBobbingListener.class, this);
287+
EVENTS.add(PacketInputListener.class, this);
286288
}
287289

288290
@Override
289-
protected void onDisable()
290-
{
291-
EVENTS.remove(UpdateListener.class, this);
292-
EVENTS.remove(RenderListener.class, this);
293-
EVENTS.remove(CameraTransformViewBobbingListener.class, this);
294-
EVENTS.remove(PacketInputListener.class, this);
295-
clearRuntimeState();
296-
}
291+
protected void onDisable()
292+
{
293+
EVENTS.remove(UpdateListener.class, this);
294+
EVENTS.remove(RenderListener.class, this);
295+
EVENTS.remove(CameraTransformViewBobbingListener.class, this);
296+
EVENTS.remove(PacketInputListener.class, this);
297+
activeLevel = null;
298+
clearRuntimeState();
299+
}
297300

298-
@Override
299-
public void onUpdate()
300-
{
301-
if(MC.player == null || MC.level == null)
302-
return;
303-
304-
ChunkAreaSetting.ChunkArea currentAreaSelection = area.getSelected();
301+
@Override
302+
public void onUpdate()
303+
{
304+
if(MC.player == null || MC.level == null)
305+
{
306+
// Clear stale detections while disconnecting or switching worlds.
307+
if(activeLevel != null || !detectionsByChunk.isEmpty()
308+
|| !holeBoxes.isEmpty() || !tunnelBoxes.isEmpty()
309+
|| !stairBoxes.isEmpty() || !ladderBoxes.isEmpty()
310+
|| !bubbleColumnBoxes.isEmpty()
311+
|| !waterColumnBoxes.isEmpty())
312+
{
313+
activeLevel = null;
314+
clearRuntimeState();
315+
}
316+
return;
317+
}
318+
319+
if(activeLevel != MC.level)
320+
{
321+
activeLevel = MC.level;
322+
refreshTimerTicks = 0;
323+
lastAreaSelection = area.getSelected();
324+
scanConfigHash = getScanConfigHash();
325+
clearRuntimeState();
326+
}
327+
328+
ChunkAreaSetting.ChunkArea currentAreaSelection = area.getSelected();
305329

306330
if(currentAreaSelection != lastAreaSelection)
307331
{

0 commit comments

Comments
 (0)