summaryrefslogtreecommitdiff
path: root/src/main/java/co/fantabos
diff options
context:
space:
mode:
author dev@ftbsc <dev@fantabos.co>2023-01-29 00:59:06 +0100
committer dev@ftbsc <dev@fantabos.co>2023-01-29 00:59:06 +0100
commit93ceec462e6750929c25a2606d4b601171939dac (patch)
treed0bb536f9e4d3b4c96181582ff7d0703a202c938 /src/main/java/co/fantabos
parent1d152324f638f6a8313d2ab05b0c82d6a185eb2d (diff)
fix: restore abilities when toggling
Diffstat (limited to 'src/main/java/co/fantabos')
-rw-r--r--src/main/java/co/fantabos/bscv/modules/VanillaFlight.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/main/java/co/fantabos/bscv/modules/VanillaFlight.java b/src/main/java/co/fantabos/bscv/modules/VanillaFlight.java
index f8e2312..767bfff 100644
--- a/src/main/java/co/fantabos/bscv/modules/VanillaFlight.java
+++ b/src/main/java/co/fantabos/bscv/modules/VanillaFlight.java
@@ -4,7 +4,6 @@ import com.mojang.brigadier.CommandDispatcher;
import co.fantabos.bscv.BoSCoVicino;
import co.fantabos.bscv.Module;
-import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.command.CommandSource;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent;
@@ -16,11 +15,26 @@ public class VanillaFlight extends Module {
super("VanillaFlight", Group.CORE, builder, dispatcher);
}
+ private boolean couldFlyBefore = false;
+
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- ClientPlayerEntity player = BoSCoVicino.minecraft.player;
- if (player != null) {
- player.abilities.mayfly = true;
+ if (BoSCoVicino.minecraft.player != null) {
+ BoSCoVicino.minecraft.player.abilities.mayfly = true;
+ }
+ }
+
+ @Override
+ protected void onEnabled() {
+ if (BoSCoVicino.minecraft.player != null) {
+ this.couldFlyBefore = BoSCoVicino.minecraft.player.abilities.mayfly;
+ }
+ }
+
+ @Override
+ protected void onDisabled() {
+ if (BoSCoVicino.minecraft.player != null) {
+ BoSCoVicino.minecraft.player.abilities.mayfly = this.couldFlyBefore;
}
}
}