Search in sources :

Example 1 with MagicCancelMessage

use of cavern.network.client.MagicCancelMessage in project Cavern2 by kegare.

the class MagicBookMessage method process.

@Override
public IMessage process(EntityPlayerMP player) {
    MagicBook book = MagicBook.get(player);
    Magic magic = EnumType.byItemStack(player.getHeldItem(hand)).createMagic(player.getServerWorld(), player, hand);
    if (magic == null) {
        return new MagicCancelMessage();
    }
    book.setSpellingMagic(magic);
    return null;
}
Also used : Magic(cavern.magic.Magic) MagicCancelMessage(cavern.network.client.MagicCancelMessage) MagicBook(cavern.magic.MagicBook)

Example 2 with MagicCancelMessage

use of cavern.network.client.MagicCancelMessage in project Cavern2 by kegare.

the class MagicInvisibleMessage method process.

@Override
public IMessage process(EntityPlayerMP player) {
    MagicBook book = MagicBook.get(player);
    Magic magic = book.getSpellingMagic();
    if (magic != null) {
        if (magic.getMana() < magic.getCost()) {
            return new MagicCancelMessage();
        }
        player.setInvisible(true);
        SoundEvent sound = magic.getSuccessSound();
        if (sound != null) {
            player.world.playSound(null, player.posX, player.posY + 0.25D, player.posZ, sound, SoundCategory.PLAYERS, 1.0F, 1.0F);
        }
    }
    return null;
}
Also used : SoundEvent(net.minecraft.util.SoundEvent) Magic(cavern.magic.Magic) MagicCancelMessage(cavern.network.client.MagicCancelMessage) MagicBook(cavern.magic.MagicBook)

Aggregations

Magic (cavern.magic.Magic)2 MagicBook (cavern.magic.MagicBook)2 MagicCancelMessage (cavern.network.client.MagicCancelMessage)2 SoundEvent (net.minecraft.util.SoundEvent)1