Search in sources :

Example 1 with TubeStack

use of com.bluepowermod.container.stack.TubeStack in project BluePower by Qmunity.

the class WidgetTabItemLister method render.

@Override
public void render(MatrixStack matrixStack, FontRenderer fontRenderer, float zLevel, float partialTicks) {
    this.setText(showingItems.size() == 0 ? "gui.bluepower:tab.stuffed.noItems" : "");
    super.render(matrixStack, fontRenderer, zLevel, partialTicks);
    if (isDoneExpanding()) {
        if (showingItems.size() > 0) {
            AbstractGui.fill(matrixStack, getBaseX() + 7, getAffectedY() + 16, getBaseX() + Math.min(MAX_ITEMS_X, showingItems.size()) * 18 + 9, getAffectedY() + 36 + (showingItems.size() - 1) / MAX_ITEMS_X * 18, 0xFFAAAAAA);
        }
        for (int i = 0; i < MAX_ITEMS_X; i++) {
            for (int j = 0; i + j * MAX_ITEMS_X < showingItems.size(); j++) {
                TubeStack stack = showingItems.get(i + j * MAX_ITEMS_X);
                int x = getBaseX() + i * 18 + 9;
                int y = getAffectedY() + j * 18 + 18;
                if (stack.color != TubeColor.NONE) {
                    AbstractGui.fill(matrixStack, x, y, x + 16, y + 16, 0xFF000000 + MinecraftColor.values()[stack.color.ordinal()].getHex());
                }
                renderItem(fontRenderer, x, y, stack.stack);
            }
        }
    }
}
Also used : TubeStack(com.bluepowermod.container.stack.TubeStack)

Example 2 with TubeStack

use of com.bluepowermod.container.stack.TubeStack in project BluePower by Qmunity.

the class TileMachineBase method addItemToOutputBuffer.

protected void addItemToOutputBuffer(ItemStack stack, TubeColor color) {
    if (!level.isClientSide) {
        internalItemStackBuffer.add(new TubeStack(stack, getOutputDirection().getOpposite(), color));
        if (internalItemStackBuffer.size() == 1)
            ejectionScheduled = true;
        animationTicker = 0;
        sendUpdatePacket();
        setChanged();
    }
}
Also used : TubeStack(com.bluepowermod.container.stack.TubeStack)

Example 3 with TubeStack

use of com.bluepowermod.container.stack.TubeStack in project BluePower by Qmunity.

the class TileMachineBase method ejectItems.

private void ejectItems() {
    for (Iterator<TubeStack> iterator = internalItemStackBuffer.iterator(); iterator.hasNext(); ) {
        TubeStack tubeStack = iterator.next();
        if (IOHelper.canInterfaceWith(getTileCache(getOutputDirection()), getFacingDirection())) {
            ItemStack returnedStack = IOHelper.insert(getTileCache(getOutputDirection()), tubeStack.stack, getFacingDirection(), tubeStack.color, false);
            if (returnedStack.isEmpty()) {
                iterator.remove();
                setChanged();
                if (!ejectionScheduled)
                    break;
            } else if (returnedStack.getCount() != tubeStack.stack.getCount()) {
                setChanged();
                if (!ejectionScheduled)
                    break;
            } else {
                break;
            }
        } else if (spawnItemsInWorld) {
            Direction direction = getFacingDirection().getOpposite();
            Block block = level.getBlockState(worldPosition.relative(direction)).getBlock();
            if (!level.getBlockState(worldPosition.relative(direction)).canOcclude() || block instanceof IFluidBlock) {
                ejectItemInWorld(tubeStack.stack, direction);
                iterator.remove();
                setChanged();
            } else {
                break;
            }
        }
    }
}
Also used : TubeStack(com.bluepowermod.container.stack.TubeStack) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) Direction(net.minecraft.util.Direction)

Example 4 with TubeStack

use of com.bluepowermod.container.stack.TubeStack in project BluePower by Qmunity.

the class TileMachineBase method save.

@Override
public CompoundNBT save(CompoundNBT compound) {
    super.save(compound);
    ListNBT nbttaglist = new ListNBT();
    for (TubeStack tubeStack : internalItemStackBuffer) {
        if (tubeStack != null) {
            CompoundNBT nbttagcompound1 = new CompoundNBT();
            tubeStack.writeToNBT(nbttagcompound1);
            nbttaglist.add(nbttagcompound1);
        }
    }
    compound.put("ItemBuffer", nbttaglist);
    return compound;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) TubeStack(com.bluepowermod.container.stack.TubeStack)

Aggregations

TubeStack (com.bluepowermod.container.stack.TubeStack)4 Block (net.minecraft.block.Block)1 ItemStack (net.minecraft.item.ItemStack)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 ListNBT (net.minecraft.nbt.ListNBT)1 Direction (net.minecraft.util.Direction)1 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)1