use of baubles.api.IBauble in project Witchworks by Um-Mitternacht.
the class ItemBauble method onItemRightClick.
@SuppressWarnings("deprecation")
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack toEquip = player.getHeldItem(hand).copy();
toEquip.setCount(1);
if (canEquip(toEquip, player)) {
IInventory baubles = BaublesApi.getBaubles(player);
for (int i = 0; i < baubles.getSizeInventory(); i++) {
if (baubles.isItemValidForSlot(i, toEquip)) {
ItemStack stackInSlot = baubles.getStackInSlot(i);
if (stackInSlot.isEmpty() || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, player)) {
if (!world.isRemote) {
baubles.setInventorySlotContents(i, toEquip);
stackInSlot.shrink(1);
}
if (!stackInSlot.isEmpty()) {
((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, player);
return ActionResult.newResult(EnumActionResult.SUCCESS, stackInSlot.copy());
}
break;
}
}
}
}
return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
}
Aggregations