Search in sources :

Example 1 with BootsItem

use of ml.northwestwind.moreboots.init.item.BootsItem in project MoreBoots by North-West-Wind.

the class MoreBootsClientHandler method onKeyInput.

@SubscribeEvent
public static void onKeyInput(final InputEvent.KeyInputEvent event) {
    if (Minecraft.getInstance().options.keyShift.consumeClick() && event.getAction() == GLFW.GLFW_PRESS) {
        LocalPlayer player = Minecraft.getInstance().player;
        if (player == null)
            return;
        ItemStack boots = player.getItemBySlot(EquipmentSlot.FEET);
        if (boots.getItem() instanceof BootsItem)
            ((BootsItem) boots.getItem()).onShift();
    } else if (Minecraft.getInstance().options.keyJump.consumeClick() && event.getAction() == GLFW.GLFW_PRESS) {
        LocalPlayer player = Minecraft.getInstance().player;
        if (player == null)
            return;
        ItemStack boots = player.getItemBySlot(EquipmentSlot.FEET);
        if (boots.getItem() instanceof BootsItem)
            ((BootsItem) boots.getItem()).onJump();
    } else if (KeybindInit.activate.consumeClick() && event.getAction() == GLFW.GLFW_PRESS) {
        Minecraft minecraft = Minecraft.getInstance();
        LocalPlayer player = minecraft.player;
        if (player == null)
            return;
        ItemStack boots = player.getItemBySlot(EquipmentSlot.FEET);
        if (boots.getItem() instanceof BootsItem)
            ((BootsItem) boots.getItem()).activateBoots();
    }
}
Also used : BootsItem(ml.northwestwind.moreboots.init.item.BootsItem) LocalPlayer(net.minecraft.client.player.LocalPlayer) ItemStack(net.minecraft.world.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with BootsItem

use of ml.northwestwind.moreboots.init.item.BootsItem in project MoreBoots by North-West-Wind.

the class MoreBootsClientHandler method onPlaySound.

@SubscribeEvent
public static void onPlaySound(PlaySoundEvent event) {
    LocalPlayer player = Minecraft.getInstance().player;
    if (player == null)
        return;
    ItemStack boots = player.getItemBySlot(EquipmentSlot.FEET);
    if (boots.getItem() instanceof BootsItem)
        ((BootsItem) boots.getItem()).onPlaySound(event);
}
Also used : BootsItem(ml.northwestwind.moreboots.init.item.BootsItem) LocalPlayer(net.minecraft.client.player.LocalPlayer) ItemStack(net.minecraft.world.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with BootsItem

use of ml.northwestwind.moreboots.init.item.BootsItem in project MoreBoots by North-West-Wind.

the class MoreBootsHandler method onLivingHurt.

@SubscribeEvent
public static void onLivingHurt(final LivingHurtEvent event) {
    LivingEntity entity = event.getEntityLiving();
    Entity attacker = event.getSource().getEntity();
    ItemStack boots = entity.getItemBySlot(EquipmentSlot.FEET);
    ItemStack atBoots;
    if (attacker instanceof LivingEntity && (atBoots = ((LivingEntity) attacker).getItemBySlot(EquipmentSlot.FEET)).getItem() instanceof BootsItem)
        ((BootsItem) atBoots.getItem()).onLivingAttack(event);
    else if (boots.getItem() instanceof BootsItem)
        ((BootsItem) boots.getItem()).onLivingHurt(event);
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) BootsItem(ml.northwestwind.moreboots.init.item.BootsItem) LivingEntity(net.minecraft.world.entity.LivingEntity) Entity(net.minecraft.world.entity.Entity) ItemEntity(net.minecraft.world.entity.item.ItemEntity) ItemStack(net.minecraft.world.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 4 with BootsItem

use of ml.northwestwind.moreboots.init.item.BootsItem in project MoreBoots by North-West-Wind.

the class MoreBootsHandler method onLivingEquipmentChange.

@SubscribeEvent
public static void onLivingEquipmentChange(final LivingEquipmentChangeEvent event) {
    ItemStack to = event.getTo();
    ItemStack from = event.getFrom();
    if (from.getItem().equals(ItemInit.LOKI_BOOTS) && !from.getItem().equals(to.getItem()))
        event.getEntityLiving().setInvisible(false);
    else {
        if (from.getItem() instanceof BootsItem)
            ((BootsItem) from.getItem()).onLivingEquipmentChange(event);
        if (to.getItem() instanceof BootsItem)
            ((BootsItem) to.getItem()).onLivingEquipmentChange(event);
    }
}
Also used : BootsItem(ml.northwestwind.moreboots.init.item.BootsItem) ItemStack(net.minecraft.world.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

BootsItem (ml.northwestwind.moreboots.init.item.BootsItem)4 ItemStack (net.minecraft.world.item.ItemStack)4 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)4 LocalPlayer (net.minecraft.client.player.LocalPlayer)2 Minecraft (net.minecraft.client.Minecraft)1 Entity (net.minecraft.world.entity.Entity)1 LivingEntity (net.minecraft.world.entity.LivingEntity)1 ItemEntity (net.minecraft.world.entity.item.ItemEntity)1