I have a simple event that when a chat message is sent the player gains the ability of flight. The PlayerAbility does not exist, how can I make this run correctly?
package net.anthony.modtest;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = modtest.MOD_ID)
public class modevents {
public final String flyCom = ">_fly";
public void clientChatFly(ClientChatEvent event) {
String msg = event.getMessage();
if(msg.startsWith(flyCom)) {
Minecraft mc = Minecraft.getInstance();
PlayerAbilities abilities = mc.player.abilities;
boolean canFly = !abilities.allowFlying;
abilities.allowFlying = canFly;
abilities.isFlying = canFly;
}
}
}