Java Code Examples for net.minecraft.init.Items#GOLDEN_APPLE

The following examples show how to use net.minecraft.init.Items#GOLDEN_APPLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegenModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();

        final ItemStack stack = mc.player.inventory.getCurrentItem();

        switch (this.mode.getValue()) {
            case POTION:
                break;
            case GAPPLE:
                if (mc.player.getHealth() <= this.health.getValue() && mc.player.getAbsorptionAmount() <= 0) {
                    gappleSlot = getItemHotbar(Items.GOLDEN_APPLE);
                }

                if (gappleSlot != -1) {
                    mc.player.inventory.currentItem = gappleSlot;
                    mc.playerController.updateController();

                    if (stack.getItem() != Items.AIR && stack.getItem() == Items.GOLDEN_APPLE) {
                        if (mc.currentScreen == null) {
                            mc.gameSettings.keyBindUseItem.pressed = true;
                        } else {
                            mc.playerController.processRightClick(mc.player, mc.world, EnumHand.MAIN_HAND);
                        }

                        if (mc.player.getAbsorptionAmount() > 0) {
                            mc.gameSettings.keyBindUseItem.pressed = false;
                            gappleSlot = -1;
                            if(this.once.getValue()) this.toggle();
                        }
                    }
                } else {
                    if (mc.player.getHealth() <= this.health.getValue() && mc.player.getAbsorptionAmount() <= 0) {
                        if (this.refill.getValue()) {
                            final int invSlot = findStackInventory(Items.GOLDEN_APPLE);
                            if (invSlot != -1) {
                                final int empty = findEmptyHotbar();
                                mc.playerController.windowClick(mc.player.inventoryContainer.windowId, invSlot, empty == -1 ? mc.player.inventory.currentItem : empty, ClickType.SWAP, mc.player);
                                mc.playerController.updateController();
                            }
                        }
                    }
                }
                break;
        }
    }
}