|
9 | 9 |
|
10 | 10 | import net.wurstclient.Category; |
11 | 11 | import net.wurstclient.SearchTags; |
| 12 | +import net.wurstclient.events.IsPlayerInLavaListener; |
| 13 | +import net.wurstclient.events.IsPlayerInLavaListener.IsPlayerInLavaEvent; |
| 14 | +import net.wurstclient.events.VelocityFromFluidListener; |
| 15 | +import net.wurstclient.events.VelocityFromFluidListener.VelocityFromFluidEvent; |
12 | 16 | import net.wurstclient.hack.Hack; |
| 17 | +import net.wurstclient.settings.CheckboxSetting; |
13 | 18 |
|
14 | 19 | @SearchTags({"no slowdown", "no slow down"}) |
15 | 20 | public final class NoSlowdownHack extends Hack |
| 21 | + implements IsPlayerInLavaListener, VelocityFromFluidListener |
16 | 22 | { |
| 23 | + private final CheckboxSetting lavaSpeed = new CheckboxSetting( |
| 24 | + "No lava slowdown", "Removes lava movement penalties.\n" |
| 25 | + + "Some servers treat this like a speedhack.", |
| 26 | + false); |
| 27 | + |
| 28 | + private boolean bypassingLava; |
| 29 | + |
17 | 30 | public NoSlowdownHack() |
18 | 31 | { |
19 | 32 | super("NoSlowdown"); |
20 | 33 | setCategory(Category.MOVEMENT); |
| 34 | + addSetting(lavaSpeed); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + protected void onEnable() |
| 39 | + { |
| 40 | + EVENTS.add(IsPlayerInLavaListener.class, this); |
| 41 | + EVENTS.add(VelocityFromFluidListener.class, this); |
| 42 | + } |
| 43 | + |
| 44 | + @Override |
| 45 | + protected void onDisable() |
| 46 | + { |
| 47 | + EVENTS.remove(IsPlayerInLavaListener.class, this); |
| 48 | + EVENTS.remove(VelocityFromFluidListener.class, this); |
| 49 | + bypassingLava = false; |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + public void onIsPlayerInLava(IsPlayerInLavaEvent event) |
| 54 | + { |
| 55 | + if(!lavaSpeed.isChecked()) |
| 56 | + { |
| 57 | + bypassingLava = false; |
| 58 | + return; |
| 59 | + } |
| 60 | + |
| 61 | + if(event.isNormallyInLava()) |
| 62 | + { |
| 63 | + bypassingLava = true; |
| 64 | + event.setInLava(false); |
| 65 | + return; |
| 66 | + } |
| 67 | + |
| 68 | + bypassingLava = false; |
| 69 | + } |
| 70 | + |
| 71 | + @Override |
| 72 | + public void onVelocityFromFluid(VelocityFromFluidEvent event) |
| 73 | + { |
| 74 | + if(!lavaSpeed.isChecked() || !bypassingLava) |
| 75 | + return; |
| 76 | + |
| 77 | + if(event.getEntity() == MC.player) |
| 78 | + event.cancel(); |
21 | 79 | } |
22 | 80 |
|
23 | 81 | // See BlockMixin.onGetVelocityMultiplier() and |
|
0 commit comments