use of mcjty.lib.gui.events.BlockRenderEvent in project RFTools by McJty.
the class GuiStorageScanner method addItemToList.
private Pair<Panel, Integer> addItemToList(ItemStack item, WidgetList itemList, Pair<Panel, Integer> currentPos, int numcolumns, int spacing) {
Panel panel = currentPos.getKey();
if (panel == null || currentPos.getValue() >= numcolumns) {
panel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(spacing).setHorizontalMargin(1)).setDesiredHeight(12).setUserObject(new Integer(-1)).setDesiredHeight(16);
currentPos = MutablePair.of(panel, 0);
itemList.addChild(panel);
}
BlockRender blockRender = new BlockRender(mc, this).setRenderItem(item).setUserObject(// Mark as a special stack in the renderer (for tooltip)
1).setOffsetX(-1).setOffsetY(-1).setHilightOnHover(true);
blockRender.addSelectionEvent(new BlockRenderEvent() {
@Override
public void select(Widget widget) {
BlockRender br = (BlockRender) widget;
Object item = br.getRenderItem();
if (item != null) {
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
requestItem((ItemStack) item, shift ? 1 : -1);
}
}
@Override
public void doubleClick(Widget widget) {
}
});
panel.addChild(blockRender);
currentPos.setValue(currentPos.getValue() + 1);
return currentPos;
}
use of mcjty.lib.gui.events.BlockRenderEvent in project RFToolsControl by McJty.
the class GuiCraftingStation method updateRecipeList.
private void updateRecipeList() {
String filterText = searchField.getText().toLowerCase().trim();
fromServer_craftables.sort((r1, r2) -> {
return r1.getDisplayName().compareTo(r2.getDisplayName());
});
recipeList.removeChildren();
Panel panel = null;
int index = 0;
for (ItemStack stack : fromServer_craftables) {
String displayName = stack.getDisplayName();
if ((!filterText.isEmpty()) && !displayName.toLowerCase().contains(filterText)) {
continue;
}
if (panel == null || panel.getChildCount() >= 6) {
panel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(3).setHorizontalMargin(1)).setDesiredHeight(16);
recipeList.addChild(panel);
}
BlockRender blockRender = new BlockRender(mc, this) {
@Override
public List<String> getTooltips() {
ITooltipFlag flag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
List<String> list = stack.getTooltip(this.mc.player, flag);
for (int i = 0; i < list.size(); ++i) {
if (i == 0) {
list.set(i, stack.getRarity().rarityColor + list.get(i));
} else {
list.set(i, TextFormatting.GRAY + list.get(i));
}
}
List<String> newlist = new ArrayList<>();
newlist.add(TextFormatting.GREEN + "Click: " + TextFormatting.WHITE + "craft single");
newlist.add(TextFormatting.GREEN + "Shift + click: " + TextFormatting.WHITE + "craft amount");
newlist.add("");
newlist.addAll(list);
return newlist;
}
}.setRenderItem(stack).setHilightOnHover(true).setOffsetX(-1).setOffsetY(-1).setUserObject(index);
index++;
blockRender.addSelectionEvent(new BlockRenderEvent() {
@Override
public void select(Widget widget) {
BlockRender br = (BlockRender) widget;
Object item = br.getRenderItem();
if (item != null) {
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
Object index = br.getUserObject();
if (shift) {
askAmountToCraft(stack);
} else {
requestItem(stack, 1);
}
}
}
@Override
public void doubleClick(Widget widget) {
}
});
panel.addChild(blockRender);
}
}
use of mcjty.lib.gui.events.BlockRenderEvent 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);
}
use of mcjty.lib.gui.events.BlockRenderEvent in project RFTools by McJty.
the class ScreenModuleGuiBuilder method ghostStack.
@Override
public IModuleGuiBuilder ghostStack(String tagname) {
ItemStack stack = ItemStack.EMPTY;
if (currentData.hasKey(tagname)) {
stack = new ItemStack(currentData.getCompoundTag(tagname));
}
BlockRender blockRender = new BlockRender(mc, gui).setRenderItem(stack).setDesiredWidth(18).setDesiredHeight(18).setFilledRectThickness(1).setFilledBackground(0xff555555);
row.add(blockRender);
blockRender.addSelectionEvent(new BlockRenderEvent() {
@Override
public void select(Widget widget) {
ItemStack holding = Minecraft.getMinecraft().player.inventory.getItemStack();
if (holding.isEmpty()) {
currentData.removeTag(tagname);
blockRender.setRenderItem(null);
} else {
ItemStack copy = holding.copy();
copy.setCount(1);
blockRender.setRenderItem(copy);
NBTTagCompound tc = new NBTTagCompound();
copy.writeToNBT(tc);
currentData.setTag(tagname, tc);
}
moduleGuiChanged.updateData();
}
@Override
public void doubleClick(Widget widget) {
}
});
return this;
}
use of mcjty.lib.gui.events.BlockRenderEvent in project RFToolsControl by McJty.
the class GuiCraftingCard method createSelectionEvent.
private BlockRenderEvent createSelectionEvent(final int idx) {
return new BlockRenderEvent() {
@Override
public void select(Widget parent) {
ItemStack itemstack = mc.player.inventory.getItemStack();
slots[idx].setRenderItem(itemstack);
ItemStackList stacks = getStacks();
if (!stacks.isEmpty()) {
stacks.set(idx, itemstack);
ItemStack cardItem = mc.player.getHeldItem(EnumHand.MAIN_HAND);
CraftingCardItem.putStacksInItem(cardItem, stacks);
RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketItemNBTToServer(cardItem.getTagCompound()));
}
}
@Override
public void doubleClick(Widget parent) {
}
};
}
Aggregations