-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheat.java
More file actions
36 lines (31 loc) · 1.37 KB
/
Copy pathcheat.java
File metadata and controls
36 lines (31 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
public class CheatMod implements ModInitializer {
private static KeyBinding flyKeyBinding;
private static boolean isFlyEnabled = false;
@override
public void onInitialize() {
flyKeyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.cheatmod.fly",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_G,
"category.cheatmod.keys"
));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (flyKeyBinding.wasPressed()) {
isFlyEnabled = !isFlyEnabled;
if (client.player != null) {
client.player.getAbilities().allowFlying = isFlyEnabled;
client.player.getAbilities().flying = isFlyEnabled;
String status = isFlyEnabled ? "enabled" : "disabled";
client.player.sendMessage(Text.of("Fly mode " + status), true);
}
});
}
}