本文整理汇总了Java中openperipheral.api.helpers.Index.checkElementIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Index.checkElementIndex方法的具体用法?Java Index.checkElementIndex怎么用?Java Index.checkElementIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openperipheral.api.helpers.Index
的用法示例。
在下文中一共展示了Index.checkElementIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pullNotebookPage
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.BOOLEAN, description = "Pull an item from the target inventory into any slot in the current one. Returns true if item was consumed")
public boolean pullNotebookPage(TileEntity desk,
@Arg(name = "deskSlot") Index deskSlot,
@Arg(name = "direction", description = "The direction of the other inventory)") ForgeDirection direction,
@Arg(name = "fromSlot", description = "The slot in the other inventory that you're pulling from") Index fromSlot) {
IInventory inv = getTargetTile(desk, direction);
fromSlot.checkElementIndex("input slot", inv.getSizeInventory());
ItemStack stack = inv.getStackInSlot(fromSlot.value);
Preconditions.checkNotNull(stack, "Other inventory empty");
final NotebookWrapper wrapper = createInventoryWrapper(desk, deskSlot);
ItemStack added = wrapper.addPage(stack);
inv.setInventorySlotContents(fromSlot.value, added);
inv.markDirty();
return added == null;
}
示例2: swapStacks
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@Asynchronous(false)
@ScriptCallable(description = "Swap two slots in the inventory")
public void swapStacks(IInventory target,
@Arg(name = "from", description = "The first slot") Index fromSlot,
@Arg(name = "to", description = "The other slot") Index intoSlot,
@Optionals @Arg(name = "fromDirection") ForgeDirection fromDirection,
@Arg(name = "fromDirection") ForgeDirection toDirection) {
IInventory inventory = InventoryUtils.getInventory(target);
Preconditions.checkNotNull(inventory, "Invalid target!");
final int size = inventory.getSizeInventory();
fromSlot.checkElementIndex("first slot id", size);
intoSlot.checkElementIndex("second slot id", size);
if (inventory instanceof ISidedInventory) {
InventoryUtils.swapStacks((ISidedInventory)inventory,
fromSlot.value, Objects.firstNonNull(fromDirection, ForgeDirection.UNKNOWN),
intoSlot.value, Objects.firstNonNull(toDirection, ForgeDirection.UNKNOWN));
} else InventoryUtils.swapStacks(inventory, fromSlot.value, intoSlot.value);
inventory.markDirty();
}
示例3: getStackInSlot
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.OBJECT, description = "Get details of an item in a particular slot")
public Object getStackInSlot(IInventory target,
@Arg(name = "slotNumber", description = "Slot number") Index slot,
@Optionals @Arg(name = "proxy", description = "If true, method will return proxy instead of computing whole table") Boolean proxy) {
IInventory inventory = InventoryUtils.getInventory(target);
slot.checkElementIndex("slot id", inventory.getSizeInventory());
ItemStack stack = inventory.getStackInSlot(slot.value);
return proxy == Boolean.TRUE? OpcAccess.itemStackMetaBuilder.createProxy(stack) : stack;
}
示例4: destroyStack
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@Asynchronous(false)
@ScriptCallable(description = "Destroy a stack")
public void destroyStack(IInventory target,
@Arg(name = "slotNumber", description = "The slot number") Index slot) {
IInventory inventory = InventoryUtils.getInventory(target);
slot.checkElementIndex("slot id", inventory.getSizeInventory());
inventory.setInventorySlotContents(slot.value, null);
inventory.markDirty();
}
示例5: setLine
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@ScriptCallable(description = "Sets the text on the sign")
public void setLine(TileEntitySign sign,
@Arg(name = "line", description = "The line number to set the text on the sign") Index line,
@Arg(name = "text", description = "The text to display on the sign") String text) {
line.checkElementIndex("line", sign.signText.length);
setLine(sign, line.value, text);
updateSign(sign);
}
示例6: getLine
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@Asynchronous
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Gets the text from the supplied line of the sign")
public String getLine(TileEntitySign sign,
@Arg(name = "line", description = "The line number to get from the sign") Index line) {
line.checkElementIndex("line", sign.signText.length);
return sign.signText[line.value];
}
示例7: getSlotOneBased
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@Asynchronous
@ScriptCallable(description = "Get the item currently being displayed in a specific slot", returnTypes = ReturnType.TABLE, name = "getSlot")
public ItemStack getSlotOneBased(@Arg(name = "slot", description = "The slot you want to get details about") Index slot) {
slot.checkElementIndex("slot id", 10);
return slots[slot.value].get();
}
示例8: setSlot
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@ScriptCallable(description = "Set the item being displayed on a specific slot")
public void setSlot(
@Arg(name = "slot", description = "The slot you want to modify") Index slot,
@Optionals @Arg(name = "item", description = "The item you want to display. nil to set empty") ItemStack stack) {
slot.checkElementIndex("slot id", 10);
if (stack != null) stack.stackSize = 1;
this.slots[slot.value].set(stack);
sync();
}
示例9: getPageFromSlot
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.TABLE)
public ItemStack getPageFromSlot(@Arg(name = "slot") Index slot) {
List<ItemStack> pages = getPages();
slot.checkElementIndex("slot", pages.size());
return pages.get(slot.value);
}
示例10: checkSlotId
import openperipheral.api.helpers.Index; //导入方法依赖的package包/类
private static void checkSlotId(IInventory inventory, Index slot, String name) {
Preconditions.checkNotNull(inventory, "Invalid inventory");
if (slot.value != ANY_SLOT) slot.checkElementIndex(name + " slot id", inventory.getSizeInventory());
}