Search in sources :

Example 1 with IItemUseManager

use of gregtech.api.items.metaitem.stats.IItemUseManager in project GregTech by GregTechCE.

the class MetaItem method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    for (IItemBehaviour behaviour : getBehaviours(itemStack)) {
        ActionResult<ItemStack> behaviourResult = behaviour.onItemRightClick(world, player, hand);
        itemStack = behaviourResult.getResult();
        if (behaviourResult.getType() != EnumActionResult.PASS) {
            return ActionResult.newResult(behaviourResult.getType(), itemStack);
        } else if (itemStack.isEmpty()) {
            return ActionResult.newResult(EnumActionResult.PASS, ItemStack.EMPTY);
        }
    }
    IItemUseManager useManager = getUseManager(itemStack);
    if (useManager != null && useManager.canStartUsing(itemStack, player)) {
        useManager.onItemUseStart(itemStack, player);
        player.setActiveHand(hand);
        return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
    }
    return ActionResult.newResult(EnumActionResult.PASS, itemStack);
}
Also used : IItemBehaviour(gregtech.api.items.metaitem.stats.IItemBehaviour) ThermalFluidHandlerItemStack(gregtech.api.capability.impl.ThermalFluidHandlerItemStack) ItemStack(net.minecraft.item.ItemStack) IItemUseManager(gregtech.api.items.metaitem.stats.IItemUseManager)

Aggregations

ThermalFluidHandlerItemStack (gregtech.api.capability.impl.ThermalFluidHandlerItemStack)1 IItemBehaviour (gregtech.api.items.metaitem.stats.IItemBehaviour)1 IItemUseManager (gregtech.api.items.metaitem.stats.IItemUseManager)1 ItemStack (net.minecraft.item.ItemStack)1