Search in sources :

Example 1 with MessageSetFlight

use of net.silentchaos512.gems.network.message.MessageSetFlight in project SilentGems by SilentChaos512.

the class ChaosBuff method removeFromPlayer.

public void removeFromPlayer(EntityPlayer player, int level, ItemStack stack) {
    if (potion != null) {
        player.removePotionEffect(potion);
    }
    if (this == FLIGHT && !player.capabilities.isCreativeMode) {
        player.capabilities.allowFlying = false;
        player.capabilities.isFlying = false;
        player.fallDistance = 0;
        if (!player.world.isRemote) {
            NetworkHandler.INSTANCE.sendTo(new MessageSetFlight(false), (EntityPlayerMP) player);
        }
    }
}
Also used : MessageSetFlight(net.silentchaos512.gems.network.message.MessageSetFlight)

Example 2 with MessageSetFlight

use of net.silentchaos512.gems.network.message.MessageSetFlight in project SilentGems by SilentChaos512.

the class ChaosBuff method applyToPlayer.

public void applyToPlayer(EntityPlayer player, int level, ItemStack stack) {
    if (potion != null) {
        int duration = getApplyDuration(player, level);
        if (duration > 0) {
            player.addPotionEffect(new PotionEffect(potion, duration, level - 1, false, false));
            // (Tough As Nails) Remove hyper/hypothermia when using heat/cold resistance.
            if (this == HEAT_RESISTANCE)
                player.removeActivePotionEffect(hyperthermia);
            else if (this == COLD_RESISTANCE)
                player.removeActivePotionEffect(hypothermia);
        }
    }
    if (this == FLIGHT) {
        player.capabilities.allowFlying = true;
        PlayerData data = PlayerDataHandler.get(player);
        if (data != null)
            data.flightTime = 100;
        if (!player.world.isRemote && player.world.getTotalWorldTime() % 20 == 0) {
            NetworkHandler.INSTANCE.sendTo(new MessageSetFlight(true), (EntityPlayerMP) player);
        }
    }
}
Also used : MessageSetFlight(net.silentchaos512.gems.network.message.MessageSetFlight) PotionEffect(net.minecraft.potion.PotionEffect) PlayerData(net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData)

Aggregations

MessageSetFlight (net.silentchaos512.gems.network.message.MessageSetFlight)2 PotionEffect (net.minecraft.potion.PotionEffect)1 PlayerData (net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData)1