Search in sources :

Example 1 with BlockRender

use of mcjty.lib.gui.widgets.BlockRender in project RFToolsControl by McJty.

the class FluidEditor method build.

@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
    Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
    Label<?> label = new Label(mc, gui).setText("Drop bucket:");
    constantPanel.addChild(label);
    blockRender = new BlockRender(mc, gui).setDesiredWidth(18 + 100).setDesiredHeight(18).setFilledRectThickness(1).setFilledBackground(0xff555555).setShowLabel(true);
    constantPanel.addChild(blockRender);
    blockRender.addSelectionEvent(new BlockRenderEvent() {

        @Override
        public void select(Widget widget) {
            ItemStack holding = Minecraft.getMinecraft().player.inventory.getItemStack();
            if (holding.isEmpty()) {
                blockRender.setRenderItem(null);
            } else {
                blockRender.setRenderItem(stackToFluid(holding));
            }
            callback.valueChanged(readValue());
        }

        @Override
        public void doubleClick(Widget widget) {
        }
    });
    createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_FLUID);
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Label(mcjty.lib.gui.widgets.Label) Widget(mcjty.lib.gui.widgets.Widget) BlockRenderEvent(mcjty.lib.gui.events.BlockRenderEvent) ItemStack(net.minecraft.item.ItemStack) BlockRender(mcjty.lib.gui.widgets.BlockRender) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 2 with BlockRender

use of mcjty.lib.gui.widgets.BlockRender in project RFToolsControl by McJty.

the class GuiMultiTank method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(iconLocation);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    for (int i = 0; i < TANKS; i++) {
        liquids[i] = new BlockRender(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(10, 9 + i * 18, 16, 16));
        toplevel.addChild(liquids[i]);
        labels[i] = new Label(mc, this);
        labels[i].setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setVerticalAlignment(VerticalAlignment.ALIGN_CENTER).setLayoutHint(new PositionalLayout.PositionalHint(32, 9 + i * 18, WIDTH - 32 - 6, 16));
        toplevel.addChild(labels[i]);
    }
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) BlockRender(mcjty.lib.gui.widgets.BlockRender)

Example 3 with BlockRender

use of mcjty.lib.gui.widgets.BlockRender in project RFToolsControl by McJty.

the class ItemEditor method build.

@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
    Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
    Label<?> label = new Label(mc, gui).setText("Drop item:");
    constantPanel.addChild(label);
    blockRender = new BlockRender(mc, gui).setDesiredWidth(18 + 100).setDesiredHeight(18).setFilledRectThickness(1).setFilledBackground(0xff555555).setShowLabel(true);
    constantPanel.addChild(blockRender);
    blockRender.addSelectionEvent(new BlockRenderEvent() {

        @Override
        public void select(Widget widget) {
            ItemStack holding = Minecraft.getMinecraft().player.inventory.getItemStack();
            if (holding.isEmpty()) {
                blockRender.setRenderItem(null);
            } else {
                ItemStack copy = holding.copy();
                copy.setCount(1);
                blockRender.setRenderItem(copy);
            }
            callback.valueChanged(readValue());
        }

        @Override
        public void doubleClick(Widget widget) {
        }
    });
    createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_ITEM);
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Label(mcjty.lib.gui.widgets.Label) Widget(mcjty.lib.gui.widgets.Widget) BlockRenderEvent(mcjty.lib.gui.events.BlockRenderEvent) ItemStack(net.minecraft.item.ItemStack) BlockRender(mcjty.lib.gui.widgets.BlockRender) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Aggregations

BlockRender (mcjty.lib.gui.widgets.BlockRender)3 Label (mcjty.lib.gui.widgets.Label)3 Panel (mcjty.lib.gui.widgets.Panel)3 BlockRenderEvent (mcjty.lib.gui.events.BlockRenderEvent)2 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)2 Widget (mcjty.lib.gui.widgets.Widget)2 ItemStack (net.minecraft.item.ItemStack)2 Window (mcjty.lib.gui.Window)1 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)1