Files
src
build.gradle
gradle.properties
settings.gradle
Code
40 2,127
src/main/java/net/dragonborne/heroes/DragonBorneHeroesClient.java
package net.dragonborne.heroes;
import net.dragonborne.heroes.network.NetworkHandler;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;
public class DragonBorneHeroesClient implements ClientModInitializer {
public static KeyBinding transformKey;
public static KeyBinding abilityKey1;
public static KeyBinding abilityKey2;
public static KeyBinding abilityKey3;
public static KeyBinding kiChargeKey;
public static KeyBinding flyToggleKey;
@Override
public void onInitializeClient() {
transformKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.dragonborneheroes.transform",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_V,
"category.dragonborneheroes.keys"
));
abilityKey1 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.dragonborneheroes.ability1",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_R,
"category.dragonborneheroes.keys"
));
abilityKey2 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.dragonborneheroes.ability2",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_F,
"category.dragonborneheroes.keys"
));
abilityKey3 = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.dragonborneheroes.ability3",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_G,
"category.dragonborneheroes.keys"
));
kiChargeKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.dragonborneheroes.charge_ki",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_C,
"category.dragonborneheroes.keys"
));
flyToggleKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.dragonborneheroes.fly",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_X,
"category.dragonborneheroes.keys"
));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (transformKey.wasPressed()) {
NetworkHandler.sendTransformPacket();
}
if (abilityKey1.wasPressed()) {
NetworkHandler.sendAbilityPacket(0);
}
if (abilityKey2.wasPressed()) {
NetworkHandler.sendAbilityPacket(1);
}
if (abilityKey3.wasPressed()) {
NetworkHandler.sendAbilityPacket(2);
}
if (kiChargeKey.isPressed()) {
NetworkHandler.sendKiChargePacket();
}
if (flyToggleKey.wasPressed()) {
NetworkHandler.sendFlyTogglePacket();
}
});
NetworkHandler.registerClientPackets();
}
}