Search in sources :

Example 1 with PacketAbilityActivate

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));
        }
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ActivatedAbility(com.lying.variousoddities.species.abilities.ActivatedAbility) LivingData(com.lying.variousoddities.capabilities.LivingData) PacketAbilityActivate(com.lying.variousoddities.network.PacketAbilityActivate)

Example 2 with PacketAbilityActivate

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));
    }
}
Also used : PacketAbilityFavourite(com.lying.variousoddities.network.PacketAbilityFavourite) PacketAbilityActivate(com.lying.variousoddities.network.PacketAbilityActivate)

Aggregations

PacketAbilityActivate (com.lying.variousoddities.network.PacketAbilityActivate)2 LivingData (com.lying.variousoddities.capabilities.LivingData)1 PacketAbilityFavourite (com.lying.variousoddities.network.PacketAbilityFavourite)1 ActivatedAbility (com.lying.variousoddities.species.abilities.ActivatedAbility)1 ResourceLocation (net.minecraft.util.ResourceLocation)1