本文整理汇总了Java中net.minecraftforge.items.ItemStackHandler.getSlots方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStackHandler.getSlots方法的具体用法?Java ItemStackHandler.getSlots怎么用?Java ItemStackHandler.getSlots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.items.ItemStackHandler
的用法示例。
在下文中一共展示了ItemStackHandler.getSlots方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeToNBT
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setTag("Items", inventory.serializeNBT());
NBTTagCompound tankTag = new NBTTagCompound();
tank.writeToNBT(tankTag);
tag.setTag("tank", tankTag);
ItemStackHandler handler = new ItemStackHandler(getFakePlayer().inventory.getSizeInventory());
for (int i = 0; i < handler.getSlots(); i++) {
handler.setStackInSlot(i, getFakePlayer().inventory.getStackInSlot(i));
}
tag.setTag("droneItems", handler.serializeNBT());
return tag;
}
示例2: retrieveValue
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
protected ItemStackHandler retrieveValue(Field field, Object te) throws Exception {
ItemStackHandler handler = (ItemStackHandler) field.get(te);
ItemStackHandler result = new ItemStackHandler(handler.getSlots());
for (int i = 0; i < handler.getSlots(); i++) {
result.setStackInSlot(i, handler.getStackInSlot(i));
}
return result;
}
示例3: injectValue
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
protected void injectValue(Field field, Object te, ItemStackHandler value) throws Exception {
ItemStackHandler handler = (ItemStackHandler) field.get(te);
for (int i = 0; i < value.getSlots(); i++) {
handler.setStackInSlot(i, value.getStackInSlot(i));
}
}
示例4: equals
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
protected boolean equals(ItemStackHandler oldValue, ItemStackHandler newValue) {
if (oldValue.getSlots() != newValue.getSlots()) return false;
for (int i = 0; i < oldValue.getSlots(); i++) {
if (!ItemStack.areItemsEqual(oldValue.getStackInSlot(i), newValue.getStackInSlot(i))) {
return false;
}
}
return true;
}
示例5: copyWhenNecessary
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
protected ItemStackHandler copyWhenNecessary(ItemStackHandler oldValue) {
ItemStackHandler result = new ItemStackHandler(oldValue.getSlots());
for (int i = 0; i < oldValue.getSlots(); i++) {
result.setStackInSlot(i, oldValue.getStackInSlot(i));
}
return result;
}
示例6: canInsert
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
private boolean canInsert(int slot, ItemStackHandler handler, ItemStack stack) {
if (getReactorsEntries().stream().noneMatch(entry -> entry.doesStackMatch(stack))) {
return false;
}
if (handler.getStackInSlot(slot).isItemEqual(stack)) {
return true;
}
for (int i = 0; i < handler.getSlots(); ++i) {
if (stack.isItemEqual(handler.getStackInSlot(i)))
return false;
}
return true;
}
示例7: getDefaultOrFind
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
public ItemStack getDefaultOrFind(int i, ItemStackHandler handler, ItemStack filter) {
if (handler.getStackInSlot(i).isItemEqual(filter)) return handler.getStackInSlot(i);
for (ItemStackHandler h : new ItemStackHandler[]{top, middle, bottom}) {
for (int s = 0; s < h.getSlots(); ++s) {
if (h.getStackInSlot(s).isItemEqual(filter)) return h.getStackInSlot(s);
}
}
return ItemStack.EMPTY;
}
示例8: dropItems
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
public void dropItems() {
for (ItemStackHandler items : new ItemStackHandler[]{input, storage, output}) {
for (int i = 0; i < items.getSlots(); ++i) {
ItemStack stack = items.getStackInSlot(i);
if (!stack.isEmpty()) {
InventoryHelper.spawnItemStack(this.getWorld(), pos.getX(), pos.getY(), pos.getZ(), stack);
}
}
}
}
示例9: BaseHarshenContainer
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
public BaseHarshenContainer(ItemStackHandler handler, EntityPlayer player)
{
this.handler = handler;
this.playerInventory = player != null;
totalSize = handler.getSlots() + (playerInventory ? 36 : 0);
for(int i = 0; i < handler.getSlots(); i++)
try
{
getPoint(i);
}
catch (IndexOutOfBoundsException e)
{
throw new IllegalArgumentException("There arnt enough registered points to quantify all the slots");
}
for(int i = 0; i < handler.getSlots(); i++)
this.addSlotToContainer(getSlot(handler, i, getPoint(i).x, getPoint(i).y));
if(playerInventory)
{
Point p = getInventoryStart();
for(int y = 0; y < 3; ++y)
for(int x = 0; x < 9; ++x)
this.addSlotToContainer(new Slot(player.inventory, x + y * 9 + 9, p.x + x * 18, p.y + y * 18));
for(int x = 0; x < 9; ++x)
this.addSlotToContainer(new Slot(player.inventory, x, p.x + x * 18, p.y + 58));
}
}
示例10: addUpgradeSlots
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
public void addUpgradeSlots(ItemStackHandler inventory) {
int x = 152;
int y = 8;
// Add our own slots
int slotIndex = 0;
for (int i = 0; i < inventory.getSlots(); i++) {
addSlotToContainer(new SlotItemHandler(inventory, slotIndex, x, y));
slotIndex++;
y += 18;
}
}
示例11: isEmpty
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
public boolean isEmpty()
{
ItemStackHandler hand = ContainerMagibench.this.tile.handler;
for(int i = 0; i < hand.getSlots(); i++)
if(!hand.getStackInSlot(i).isEmpty())
return false;
return true;
}
示例12: fillStackedContents
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
public void fillStackedContents(RecipeItemHelper helper)
{
ItemStackHandler handler = ContainerMagibench.this.tile.handler;
for (int i = 0; i < handler.getSlots(); i++)
{
helper.accountStack(handler.getStackInSlot(i));
}
}
示例13: addSortSlots
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
private void addSortSlots()
{
int y = 6;
int x = 8;
for(ItemStackHandler handler : te.getSortStacks())
{
for(int i = 0; i < handler.getSlots(); i++)
{
this.addSlotToContainer(new SlotSorter(handler, i, x + (i * 18), y));
}
y += 18;
}
}
示例14: decrStackInInventory
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
public static void decrStackInInventory(ItemStackHandler handler, int slot) {
if (slot < 0 || slot >= handler.getSlots()) return;
ItemStack st = handler.getStackInSlot(slot);
if (st.isEmpty()) return;
st.setCount(st.getCount() - 1);
if (st.getCount() <= 0) {
handler.setStackInSlot(slot, ItemStack.EMPTY);
}
}
示例15: isInventoryFull
import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
public static boolean isInventoryFull(ItemStackHandler handler) {
for (int i = 0; i < handler.getSlots(); ++i) {
if (handler.getStackInSlot(i).isEmpty()) return false;
}
return true;
}