本文整理汇总了Java中baubles.api.cap.IBaublesItemHandler.isItemValidForSlot方法的典型用法代码示例。如果您正苦于以下问题:Java IBaublesItemHandler.isItemValidForSlot方法的具体用法?Java IBaublesItemHandler.isItemValidForSlot怎么用?Java IBaublesItemHandler.isItemValidForSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类baubles.api.cap.IBaublesItemHandler
的用法示例。
在下文中一共展示了IBaublesItemHandler.isItemValidForSlot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemRightClick
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (!world.isRemote) {
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
for (int i = 0; i < baubles.getSlots(); i++)
if (baubles.getStackInSlot(i).isEmpty() && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) {
baubles.setStackInSlot(i, player.getHeldItem(hand).copy());
if (!player.capabilities.isCreativeMode) {
player.setHeldItem(hand, ItemStack.EMPTY);
}
onEquipped(player.getHeldItem(hand), player);
break;
}
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
示例2: onItemRightClick
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if(player.isSneaking()){
//no special case if sneaking
return super.onItemRightClick(world, player, hand);
}
ItemStack stack = player.getHeldItem(hand);
ItemStack toEquip = stack.copy();
toEquip.setCount(1);
if(canEquip(toEquip, player) && Loader.isModLoaded("baubles")) {
//InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
for(int i = 0; i < baubles.getSlots(); i++) {
if(baubles.isItemValidForSlot(i, toEquip,player)) {
ItemStack stackInSlot = baubles.getStackInSlot(i);
if(stackInSlot.isEmpty()) {
if(!world.isRemote) {
baubles.insertItem(i, toEquip,false);
stack.setCount(stack.getCount()-1);
}
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
}
}
}
return super.onItemRightClick(world, player, hand);
}