use of com.lowdragmc.multiblocked.api.capability.IO in project Multiblocked by Low-Drag-MC.
the class ContentWidget method openConfigurator.
/**
* Configurator.
*/
public void openConfigurator(WidgetGroup dialog) {
dialog.addWidget(new LabelWidget(5, 8, "multiblocked.gui.label.chance"));
dialog.addWidget(new TextFieldWidget(125 - 60, 5, 30, 15, null, number -> setContent(io, content, Float.parseFloat(number), perTick)).setNumbersOnly(0f, 1f).setCurrentString(chance + ""));
dialog.addWidget(new SwitchWidget(125 - 25, 5, 15, 15, (cd, r) -> setContent(io, content, chance, r)).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/boolean.png").getSubTexture(0, 0, 1, 0.5)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/boolean.png").getSubTexture(0, 0.5, 1, 0.5)).setHoverBorderTexture(1, -1).setPressed(perTick).setHoverTooltips("multiblocked.gui.content.per_tick"));
}
use of com.lowdragmc.multiblocked.api.capability.IO in project Multiblocked by Low-Drag-MC.
the class PredicateAnyCapability method checkCapability.
private static boolean checkCapability(IO io, MultiblockCapability<?> capability, MultiblockState state) {
if (io != null) {
TileEntity tileEntity = state.getTileEntity();
if (tileEntity != null && capability.isBlockHasCapability(io, tileEntity)) {
Map<Long, EnumMap<IO, Set<MultiblockCapability<?>>>> capabilities = state.getMatchContext().getOrCreate("capabilities", Long2ObjectOpenHashMap::new);
capabilities.computeIfAbsent(state.getPos().asLong(), l -> new EnumMap<>(IO.class)).computeIfAbsent(io, x -> new HashSet<>()).add(capability);
return true;
}
}
state.setError(new PatternStringError(LocalizationUtils.format("multiblocked.pattern.error.capability", LocalizationUtils.format(capability.getUnlocalizedName()), io == null ? "NULL" : io.name())));
return false;
}
use of com.lowdragmc.multiblocked.api.capability.IO in project Multiblocked by Low-Drag-MC.
the class SimplePredicate method getConfigWidget.
public List<WidgetGroup> getConfigWidget(List<WidgetGroup> groups) {
WidgetGroup group = new WidgetGroup(0, 0, 300, 90);
groups.add(group);
group.setClientSideWidget();
group.addWidget(new LabelWidget(0, 0, () -> LocalizationUtils.format("multiblocked.gui.label.type") + " " + type).setTextColor(-1).setDrop(true));
TextFieldWidget min, max, preview, nbt, tooltips;
group.addWidget(min = new TextFieldWidget(55, 15, 30, 15, () -> minCount + "", s -> {
minCount = Integer.parseInt(s);
if (minCount > maxCount) {
maxCount = minCount;
}
}).setNumbersOnly(0, Integer.MAX_VALUE));
min.setHoverTooltips("multiblocked.gui.tips.min").setVisible(minCount != -1);
group.addWidget(new SwitchWidget(0, 15, 50, 15, (cd, r) -> {
min.setVisible(r);
minCount = r ? 0 : -1;
}).setPressed(minCount != -1).setHoverBorderTexture(1, -1).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("min (N)", -1).setDropShadow(true)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("min (Y)", -1).setDropShadow(true)).setHoverTooltips("multiblocked.gui.predicate.min"));
group.addWidget(max = new TextFieldWidget(55, 33, 30, 15, () -> maxCount + "", s -> {
maxCount = Integer.parseInt(s);
if (minCount > maxCount) {
minCount = maxCount;
}
}).setNumbersOnly(0, Integer.MAX_VALUE));
max.setHoverTooltips("multiblocked.gui.tips.max").setVisible(maxCount != -1);
group.addWidget(new SwitchWidget(0, 33, 50, 15, (cd, r) -> {
max.setVisible(r);
maxCount = r ? 0 : -1;
}).setPressed(maxCount != -1).setHoverBorderTexture(1, -1).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("max (N)", -1).setDropShadow(true)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("max (Y)", -1).setDropShadow(true)).setHoverTooltips("multiblocked.gui.predicate.max"));
group.addWidget(preview = (TextFieldWidget) new TextFieldWidget(55, 51, 30, 15, () -> previewCount + "", s -> previewCount = Integer.parseInt(s)).setNumbersOnly(0, Integer.MAX_VALUE).setHoverTooltips("multiblocked.gui.predicate.preview"));
preview.setHoverTooltips("multiblocked.gui.predicate.jei").setVisible(previewCount != -1);
group.addWidget(new SwitchWidget(0, 51, 50, 15, (cd, r) -> {
preview.setVisible(r);
previewCount = r ? 0 : -1;
}).setPressed(previewCount != -1).setHoverBorderTexture(1, -1).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("jei (N)", -1).setDropShadow(true)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("jei (Y)", -1).setDropShadow(true)).setHoverTooltips("multiblocked.gui.predicate.preview.1"));
WidgetGroup widgetGroup = new WidgetGroup(0, 70, 100, 15).addWidget(new SwitchWidget(0, 0, 15, 15, (cd, r) -> disableRenderFormed = r).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/boolean.png").getSubTexture(0, 0, 1, 0.5)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/boolean.png").getSubTexture(0, 0.5, 1, 0.5)).setHoverTexture(new ColorBorderTexture(1, -1)).setPressed(disableRenderFormed).setHoverTooltips("multiblocked.gui.predicate.disabled")).addWidget(new ImageWidget(2, 2, 11, 11, new ColorBorderTexture(1, -1))).addWidget(new LabelWidget(20, 3, "disableRenderFormed").setTextColor(-1).setDrop(true));
group.addWidget(widgetGroup);
group.addWidget(nbt = new TextFieldWidget(155, 15, 100, 15, null, s -> nbtParser = s));
nbt.setCurrentString(nbtParser == null ? "" : nbtParser).setHoverTooltips("nbt parser").setVisible(nbtParser != null);
group.addWidget(new SwitchWidget(100, 15, 50, 15, (cd, r) -> {
nbt.setVisible(r);
nbtParser = r ? "" : null;
}).setPressed(nbtParser != null).setHoverBorderTexture(1, -1).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("nbt (N)", -1).setDropShadow(true)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("nbt (Y)", -1).setDropShadow(true)).setHoverTooltips("multiblocked.gui.predicate.nbt"));
group.addWidget(tooltips = new TextFieldWidget(155, 33, 100, 15, null, s -> customTips = s));
tooltips.setCurrentString(customTips != null ? customTips : "").setHoverTooltips("multiblocked.gui.predicate.tips").setVisible(customTips != null);
group.addWidget(new SwitchWidget(100, 33, 50, 15, (cd, r) -> {
tooltips.setVisible(r);
customTips = r ? "" : null;
}).setPressed(customTips != null).setHoverBorderTexture(1, -1).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("tips (N)", -1).setDropShadow(true)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/button_common.png"), new TextTexture("tips (Y)", -1).setDropShadow(true)).setHoverTooltips("multiblocked.gui.predicate.add_tips"));
group.addWidget(new SelectorWidget(130, 70, 40, 15, Arrays.asList("IN", "OUT", "BOTH", "NULL"), -1).setValue(io == null ? "NULL" : io.name()).setIsUp(true).setOnChanged(io -> this.io = io.equals("NULL") ? null : IO.valueOf(io)).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xff333333)).setHoverTooltips("multiblocked.gui.tips.io"));
return groups;
}
use of com.lowdragmc.multiblocked.api.capability.IO in project Multiblocked by Low-Drag-MC.
the class ProgressCapabilityTrait method initSettingDialog.
@Override
protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot) {
ImageWidget imageWidget = (ImageWidget) slot.widgets.get(0);
ButtonWidget setting = (ButtonWidget) slot.widgets.get(1);
ButtonWidget imageSelector = (ButtonWidget) new ButtonWidget(5, 65, width, height, new GuiTextureGroup(new ColorBorderTexture(1, -1), new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5)), null).setHoverTooltips("multiblocked.gui.tips.select_image");
dialog.addWidget(new TextFieldWidget(5, 25, 50, 15, null, s -> {
width = Integer.parseInt(s);
Size size = new Size(width, height);
slot.setSize(size);
imageWidget.setSize(size);
imageSelector.setSize(size);
setting.setSelfPosition(new Position(width - 8, 0));
}).setCurrentString(width + "").setNumbersOnly(1, 180).setHoverTooltips("multiblocked.gui.trait.set_width"));
dialog.addWidget(new TextFieldWidget(5, 45, 50, 15, null, s -> {
height = Integer.parseInt(s);
Size size = new Size(width, height);
slot.setSize(size);
imageWidget.setSize(size);
imageSelector.setSize(size);
setting.setSelfPosition(new Position(width - 8, 0));
}).setCurrentString(height + "").setNumbersOnly(1, 180).setHoverTooltips("multiblocked.gui.trait.set_height"));
dialog.addWidget(new SelectorWidget(5, 5, 50, 15, Arrays.stream(IO.VALUES).map(Enum::name).collect(Collectors.toList()), -1).setValue(capabilityIO.name()).setOnChanged(io -> {
capabilityIO = IO.valueOf(io);
imageWidget.setImage(new GuiTextureGroup(new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
}).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.capability_io"));
dialog.addWidget(imageSelector);
imageSelector.setOnPressCallback(cd -> new ResourceTextureWidget(dialog.getParent().getGui().mainGroup, texture1 -> {
if (texture1 != null) {
texture = texture1.imageLocation.toString();
ResourceTexture resourceTexture = new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5);
imageSelector.setButtonTexture(new GuiTextureGroup(new ColorBorderTexture(1, -1), resourceTexture));
imageWidget.setImage(new GuiTextureGroup(resourceTexture, new ColorBorderTexture(1, getColorByIO(capabilityIO))));
}
}));
}
Aggregations