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);
}
}
}
}
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();
}
}
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;
}
}
}
}
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;
}
Aggregations