Search in sources :

Example 6 with BlockRenderEvent

use of mcjty.lib.gui.events.BlockRenderEvent 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)

Example 7 with BlockRenderEvent

use of mcjty.lib.gui.events.BlockRenderEvent in project XNet by McJty.

the class AbstractEditorPanel method ghostSlot.

@Override
public IEditorGui ghostSlot(String tag, ItemStack stack) {
    int w = 16;
    fitWidth(w);
    BlockRender blockRender = new BlockRender(mc, gui).setRenderItem(stack).setDesiredWidth(18).setDesiredHeight(18).setFilledRectThickness(-1).setFilledBackground(0xff888888);
    blockRender.addSelectionEvent(new BlockRenderEvent() {

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

        @Override
        public void doubleClick(Widget widget) {
        }
    });
    blockRender.setLayoutHint(new PositionalLayout.PositionalHint(x, y - 1, 17, 17));
    data.put(tag, stack);
    panel.addChild(blockRender);
    components.put(tag, blockRender);
    x += w;
    return this;
}
Also used : PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) BlockRenderEvent(mcjty.lib.gui.events.BlockRenderEvent) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BlockRenderEvent (mcjty.lib.gui.events.BlockRenderEvent)7 ItemStack (net.minecraft.item.ItemStack)7 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)4 Panel (mcjty.lib.gui.widgets.Panel)4 BlockRender (mcjty.lib.gui.widgets.BlockRender)2 Label (mcjty.lib.gui.widgets.Label)2 Widget (mcjty.lib.gui.widgets.Widget)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)1 ItemStackList (mcjty.lib.varia.ItemStackList)1 PacketItemNBTToServer (mcjty.rftoolscontrol.network.PacketItemNBTToServer)1 ITooltipFlag (net.minecraft.client.util.ITooltipFlag)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1