Search in sources :

Example 1 with IKeybindable

use of WayofTime.bloodmagic.client.key.IKeybindable in project BloodMagic by WayofTime.

the class KeyProcessor method onMessage.

@Override
public IMessage onMessage(KeyProcessor msg, MessageContext ctx) {
    EntityPlayer entityPlayer = ctx.getServerHandler().player;
    if (entityPlayer != null) {
        ItemStack heldStack = entityPlayer.getHeldItemMainhand();
        if (heldStack.getItem() instanceof IKeybindable) {
            if (msg.keyId < 0 || msg.keyId >= KeyBindings.values().length) {
                return null;
            }
            KeyBindings key = KeyBindings.values()[msg.keyId];
            ((IKeybindable) heldStack.getItem()).onKeyPressed(heldStack, entityPlayer, key, msg.showInChat);
        }
    }
    return null;
}
Also used : IKeybindable(WayofTime.bloodmagic.client.key.IKeybindable) KeyBindings(WayofTime.bloodmagic.client.key.KeyBindings) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IKeybindable (WayofTime.bloodmagic.client.key.IKeybindable)1 KeyBindings (WayofTime.bloodmagic.client.key.KeyBindings)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1