Search in sources :

Example 1 with HaloInfusionItem

use of com.teamwizardry.wizardry.api.item.halo.HaloInfusionItem in project Wizardry by TeamWizardry.

the class EntityHaloInfusionItem method processInitialInteract.

@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
    TileEntity tile = world.getTileEntity(infuserPos);
    if (tile == null || !(tile instanceof TileHaloInfuser)) {
        world.removeEntity(this);
        return false;
    }
    ItemStack heldItem = player.getHeldItem(hand);
    if (heldItem.isEmpty()) {
        ItemStack slotted = getHaloInfusionItem().getStack();
        if (!slotted.isEmpty()) {
            player.setHeldItem(hand, slotted);
            setHaloInfusionItem(HaloInfusionItemRegistry.EMPTY, false);
            return true;
        } else
            return true;
    }
    for (HaloInfusionItem haloInfusionItem : HaloInfusionItemRegistry.getItems()) {
        if (haloInfusionItem.getStack().isItemEqual(heldItem)) {
            setHaloInfusionItem(haloInfusionItem, false);
            // todo: remove from hand
            return true;
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileHaloInfuser(com.teamwizardry.wizardry.common.tile.TileHaloInfuser) HaloInfusionItem(com.teamwizardry.wizardry.api.item.halo.HaloInfusionItem) ItemStack(net.minecraft.item.ItemStack)

Aggregations

HaloInfusionItem (com.teamwizardry.wizardry.api.item.halo.HaloInfusionItem)1 TileHaloInfuser (com.teamwizardry.wizardry.common.tile.TileHaloInfuser)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1