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);
}
Aggregations