Search in sources :

Example 16 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.

the class ModularStorageTileEntity method writeBufferToNBT.

private void writeBufferToNBT(NBTTagCompound tagCompound) {
    // If sendToClient is true we have to send dummy information to the client
    // so that it can remotely open gui's.
    boolean sendToClient = isServer() && isRemote();
    NBTTagList bufferTagList = new NBTTagList();
    if (sendToClient) {
        RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
        if (storageTileEntity != null) {
            ItemStackList slots = storageTileEntity.findStacksForId(remoteId);
            for (ItemStack stack : slots) {
                NBTTagCompound nbtTagCompound = new NBTTagCompound();
                if (!stack.isEmpty()) {
                    stack.writeToNBT(nbtTagCompound);
                }
                bufferTagList.appendTag(nbtTagCompound);
            }
        }
    } else {
        for (int i = ModularStorageContainer.SLOT_STORAGE; i < inventoryHelper.getCount(); i++) {
            ItemStack stack = inventoryHelper.getStackInSlot(i);
            NBTTagCompound nbtTagCompound = new NBTTagCompound();
            if (!stack.isEmpty()) {
                stack.writeToNBT(nbtTagCompound);
            }
            bufferTagList.appendTag(nbtTagCompound);
        }
    }
    tagCompound.setTag("Items", bufferTagList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ItemStackList(mcjty.lib.varia.ItemStackList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 17 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.

the class ModularStorageTileEntity method containsItem.

private boolean containsItem(int index) {
    if (isStorageAvailableRemotely(index)) {
        index -= ModularStorageContainer.SLOT_STORAGE;
        RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
        if (storageTileEntity == null) {
            return false;
        }
        ItemStackList slots = storageTileEntity.findStacksForId(remoteId);
        if (index >= slots.size()) {
            return false;
        }
        return !slots.get(index).isEmpty();
    } else {
        return inventoryHelper.containsItem(index);
    }
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList)

Example 18 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.

the class ModularStorageTileEntity method updateStackCount.

private void updateStackCount() {
    numStacks = 0;
    if (isServer() && isRemote()) {
        RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
        if (storageTileEntity == null) {
            return;
        }
        int si = storageTileEntity.findRemoteIndex(remoteId);
        if (si == -1) {
            return;
        }
        ItemStackList stacks = storageTileEntity.getRemoteStacks(si);
        for (int i = 0; i < Math.min(maxSize, stacks.size()); i++) {
            if (!stacks.get(i).isEmpty()) {
                numStacks++;
            }
        }
        storageTileEntity.updateCount(si, numStacks);
    } else {
        for (int i = ModularStorageContainer.SLOT_STORAGE; i < ModularStorageContainer.SLOT_STORAGE + maxSize; i++) {
            if (inventoryHelper.containsItem(i)) {
                numStacks++;
            }
        }
    }
    StorageModuleItem.updateStackSize(getStackInSlot(ModularStorageContainer.SLOT_STORAGE_MODULE), numStacks);
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList)

Example 19 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.

the class ModularStorageTileEntity method getStackInSlot.

@Override
public ItemStack getStackInSlot(int index) {
    if (index >= getSizeInventory()) {
        return ItemStack.EMPTY;
    }
    if (isStorageAvailableRemotely(index)) {
        index -= ModularStorageContainer.SLOT_STORAGE;
        RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
        if (storageTileEntity == null) {
            return ItemStack.EMPTY;
        }
        ItemStackList slots = storageTileEntity.findStacksForId(remoteId);
        if (index >= slots.size()) {
            return ItemStack.EMPTY;
        }
        return slots.get(index);
    }
    return inventoryHelper.getStackInSlot(index);
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList)

Example 20 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.

the class GuiCrafter method drawGhostSlots.

private void drawGhostSlots() {
    net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.pushMatrix();
    GlStateManager.translate(guiLeft, guiTop, 0.0F);
    GlStateManager.color(1.0F, 0.0F, 0.0F, 1.0F);
    GlStateManager.enableRescaleNormal();
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (short) 240 / 1.0F, 240.0f);
    ItemStackList ghostSlots = tileEntity.getGhostSlots();
    zLevel = 100.0F;
    itemRender.zLevel = 100.0F;
    GlStateManager.enableDepth();
    GlStateManager.disableBlend();
    GlStateManager.enableLighting();
    for (int i = 0; i < ghostSlots.size(); i++) {
        ItemStack stack = ghostSlots.get(i);
        if (!stack.isEmpty()) {
            int slotIdx;
            if (i < CrafterContainer.BUFFER_SIZE) {
                slotIdx = i + CrafterContainer.SLOT_BUFFER;
            } else {
                slotIdx = i + CrafterContainer.SLOT_BUFFEROUT - CrafterContainer.BUFFER_SIZE;
            }
            Slot slot = inventorySlots.getSlot(slotIdx);
            if (!slot.getHasStack()) {
                itemRender.renderItemAndEffectIntoGUI(stack, slot.xPos, slot.yPos);
                GlStateManager.disableLighting();
                GlStateManager.enableBlend();
                GlStateManager.disableDepth();
                this.mc.getTextureManager().bindTexture(iconGuiElements);
                RenderHelper.drawTexturedModalRect(slot.xPos, slot.yPos, 14 * 16, 3 * 16, 16, 16);
                GlStateManager.enableDepth();
                GlStateManager.disableBlend();
                GlStateManager.enableLighting();
            }
        }
    }
    itemRender.zLevel = 0.0F;
    zLevel = 0.0F;
    GlStateManager.popMatrix();
    net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStackList (mcjty.lib.varia.ItemStackList)30 ItemStack (net.minecraft.item.ItemStack)21 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)9 TileEntity (net.minecraft.tileentity.TileEntity)5 BlockPos (net.minecraft.util.math.BlockPos)5 GenericTileEntity (mcjty.lib.entity.GenericTileEntity)4 ProcessorTileEntity (mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Nonnull (javax.annotation.Nonnull)1 InventoryHelper (mcjty.lib.container.InventoryHelper)1 BlockRenderEvent (mcjty.lib.gui.events.BlockRenderEvent)1 RFTools (mcjty.rftools.RFTools)1 ModularStorageTileEntity (mcjty.rftools.blocks.storage.ModularStorageTileEntity)1 GenericRFToolsItem (mcjty.rftools.items.GenericRFToolsItem)1 FILTER_SLOTS (mcjty.rftools.items.storage.StorageFilterContainer.FILTER_SLOTS)1