當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemStackHandler.getSlots方法代碼示例

本文整理匯總了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;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:19,代碼來源:TileEntityProgrammableController.java

示例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;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:10,代碼來源:SyncedField.java

示例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));
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:8,代碼來源:SyncedField.java

示例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;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:11,代碼來源:SyncedField.java

示例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;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:9,代碼來源:SyncedField.java

示例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;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:14,代碼來源:AbstractReactorTile.java

示例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;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:10,代碼來源:WitherBuilderTile.java

示例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);
            }
        }
    }
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:11,代碼來源:BlackHoleControllerTile.java

示例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));
	}
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:29,代碼來源:BaseHarshenContainer.java

示例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;
    }

}
 
開發者ID:CreeperShift,項目名稱:WirelessCharger,代碼行數:16,代碼來源:ContainerBase.java

示例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;
}
 
開發者ID:PearXTeam,項目名稱:PurificatiMagicae,代碼行數:10,代碼來源:ContainerMagibench.java

示例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));
    }
}
 
開發者ID:PearXTeam,項目名稱:PurificatiMagicae,代碼行數:10,代碼來源:ContainerMagibench.java

示例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;
	}
}
 
開發者ID:Lemonszz,項目名稱:Anima-Mundi,代碼行數:15,代碼來源:ContainerSorter.java

示例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);
    }
}
 
開發者ID:HellFirePvP,項目名稱:ModularMachinery,代碼行數:10,代碼來源:ItemUtils.java

示例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;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:7,代碼來源:ItemStackUtils.java


注:本文中的net.minecraftforge.items.ItemStackHandler.getSlots方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。