fix: restore abilities when toggling
This commit is contained in:
parent
1d152324f6
commit
93ceec462e
1 changed files with 18 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue