use of com.lying.variousoddities.network.PacketAbilityActivate in project VariousOddities by Lyinginbedmon.
the class KeyBindings method handleAbilityKey.
private static void handleAbilityKey(int index) {
LivingData data = LivingData.forEntity(Minecraft.getInstance().player);
ResourceLocation mapName = data.getAbilities().getFavourite(index);
if (mapName != null) {
ActivatedAbility ability = (ActivatedAbility) AbilityRegistry.getAbilityByName(Minecraft.getInstance().player, mapName);
if (ability != null && ability.canTrigger(Minecraft.getInstance().player)) {
ability.trigger(Minecraft.getInstance().player, Dist.CLIENT);
PacketHandler.sendToServer(new PacketAbilityActivate(mapName));
}
}
}
use of com.lying.variousoddities.network.PacketAbilityActivate in project VariousOddities by Lyinginbedmon.
the class ScreenAbilityMenu method activateAbility.
public void activateAbility(@Nonnull ActivatedAbility ability, boolean favourite, LivingData data) {
if (ability == null)
return;
if (!favourite) {
if (ability.canTrigger(thePlayer)) {
ability.trigger(thePlayer, Dist.CLIENT);
PacketHandler.sendToServer(new PacketAbilityActivate(ability.getMapName()));
closeScreen();
}
} else {
boolean isFavourite = data.getAbilities().isFavourite(ability.getMapName());
PacketHandler.sendToServer(new PacketAbilityFavourite(ability.getMapName(), !isFavourite));
}
}
Aggregations