use of buildcraft.core.blueprints.RequirementItemStack in project BuildCraft by BuildCraft.
the class GuiBuilder method drawGuiContainerBackgroundLayer.
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
// We cannot do super here due to some crazy shenanigans with a dynamically
// resized GUI.
GlStateManager.color(1f, 1f, 1f, 1f);
boolean isBlueprint = builder.getStackInSlot(0) != null;
mc.renderEngine.bindTexture(REGULAR_TEXTURE);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 176, ySize);
mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
if (isBlueprint) {
drawTexturedModalRect(guiLeft + 169, guiTop, 169, 0, 256 - 169, ySize);
}
List<RequirementItemStack> needs = builder.getNeededItems();
if (needs != null) {
if (needs.size() > slots.size()) {
getContainerBuilder().scrollbarWidget.hidden = false;
getContainerBuilder().scrollbarWidget.setLength((needs.size() - slots.size() + 3) / 4);
} else {
getContainerBuilder().scrollbarWidget.hidden = true;
}
int offset = getContainerBuilder().scrollbarWidget.getPosition() * 4;
for (int s = 0; s < slots.size(); s++) {
int ts = offset + s;
if (ts >= needs.size()) {
((SlotBuilderRequirement) slots.get(s)).stack = null;
} else {
((SlotBuilderRequirement) slots.get(s)).stack = needs.get(ts);
}
}
for (GuiButton b : (List<GuiButton>) buttonList) {
b.visible = true;
}
} else {
getContainerBuilder().scrollbarWidget.hidden = true;
for (AdvancedSlot slot : slots) {
((SlotBuilderRequirement) slot).stack = null;
}
for (GuiButton b : (List<GuiButton>) buttonList) {
b.visible = false;
}
}
if (builder.getControlMode() == Mode.Off) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
int extraX = guiLeft + OPTION_EXTRA_X_POS.getAsInt();
int extraY = guiTop + OPTION_EXTRA_Y_POS.getAsInt();
drawTexturedModalRect(extraX, extraY, CoreIconProvider.TURNED_OFF.getSprite(), 16, 16);
}
drawWidgets(x, y);
if (isBlueprint) {
drawBackgroundSlots(x, y);
for (int i = 0; i < builder.fluidTanks.length; i++) {
Tank tank = builder.fluidTanks[i];
if (tank.getFluid() != null && tank.getFluid().amount > 0) {
drawFluid(tank.getFluid(), guiLeft + 179 + 18 * i, guiTop + 145, 16, 47, tank.getCapacity());
}
}
mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
for (int i = 0; i < builder.fluidTanks.length; i++) {
Tank tank = builder.fluidTanks[i];
if (tank.getFluid() != null && tank.getFluid().amount > 0) {
drawTexturedModalRect(guiLeft + 179 + 18 * i, guiTop + 145, 0, 54, 16, 47);
}
}
}
GlStateManager.color(1f, 1f, 1f, 1f);
}
use of buildcraft.core.blueprints.RequirementItemStack in project BuildCraft by BuildCraft.
the class TileBuilder method updateRequirements.
private void updateRequirements() {
List<RequirementItemStack> reqCopy = null;
if (currentBuilder instanceof BptBuilderBlueprint) {
currentBuilder.initialize();
reqCopy = ((BptBuilderBlueprint) currentBuilder).getNeededItems();
}
for (EntityPlayer p : guiWatchers) {
BuildCraftCore.instance.sendToPlayer(p, getItemRequirementsPacket(reqCopy));
}
}
use of buildcraft.core.blueprints.RequirementItemStack in project BuildCraft by BuildCraft.
the class BuilderTooltipHandler method itemTooltipEvent.
@SubscribeEvent
public void itemTooltipEvent(ItemTooltipEvent event) {
EntityPlayer player = event.getEntityPlayer();
if (event.getItemStack() != null && player != null && player.openContainer != null && player.openContainer instanceof ContainerBuilder) {
ContainerBuilder containerBuilder = (ContainerBuilder) player.openContainer;
TileBuilder builder = containerBuilder.getBuilder();
if (builder != null) {
List<RequirementItemStack> needs = builder.getNeededItems();
if (needs != null) {
for (RequirementItemStack ris : needs) {
if (ris.stack == event.getItemStack()) {
event.getToolTip().add(TextFormatting.GRAY + "" + TextFormatting.ITALIC + "Needed: " + ris.size);
}
}
}
}
}
}
use of buildcraft.core.blueprints.RequirementItemStack in project BuildCraft by BuildCraft.
the class TileBuilder method getItemRequirementsPacket.
private Packet getItemRequirementsPacket(List<RequirementItemStack> itemsIn) {
if (itemsIn != null) {
final List<RequirementItemStack> items = new ArrayList<>();
items.addAll(itemsIn);
return new PacketCommand(this, "setItemRequirements", new CommandWriter() {
@Override
public void write(ByteBuf data) {
data.writeMedium(items.size());
for (RequirementItemStack rb : items) {
data.writeShort(Item.getIdFromItem(rb.stack.getItem()));
data.writeShort(rb.stack.getItemDamage());
data.writeMedium((rb.stack.hasTagCompound() ? 0x800000 : 0x000000) | Math.min(0x7FFFFF, rb.size));
if (rb.stack.hasTagCompound()) {
NetworkUtils.writeNBT(data, rb.stack.getTagCompound());
}
}
}
});
} else {
return new PacketCommand(this, "clearItemRequirements", null);
}
}
Aggregations