use of mekanism.common.network.to_server.PacketGuiInteract in project Mekanism by mekanism.
the class GuiQIOFilterHandler method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiQIOFrequencyTab(this, tile));
addButton(new GuiInnerScreen(this, 9, 16, imageWidth - 18, 12, () -> {
List<ITextComponent> list = new ArrayList<>();
QIOFrequency freq = tile.getQIOFrequency();
if (freq == null) {
list.add(MekanismLang.NO_FREQUENCY.translate());
} else {
list.add(MekanismLang.FREQUENCY.translate(freq.getKey()));
}
return list;
}).tooltip(() -> {
List<ITextComponent> list = new ArrayList<>();
QIOFrequency freq = tile.getQIOFrequency();
if (freq != null) {
list.add(MekanismLang.QIO_ITEMS_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(freq.getTotalItemCount()), TextUtils.format(freq.getTotalItemCountCapacity())));
list.add(MekanismLang.QIO_TYPES_DETAIL.translateColored(EnumColor.GRAY, EnumColor.INDIGO, TextUtils.format(freq.getTotalItemTypes(true)), TextUtils.format(freq.getTotalItemTypeCapacity())));
}
return list;
}));
// Filter holder
addButton(new GuiElementHolder(this, 9, 30, 144, 68));
// new filter button border
addButton(new GuiElementHolder(this, 9, 98, 144, 22));
addButton(new TranslationButton(this, 10, 99, 142, 20, MekanismLang.BUTTON_NEW_FILTER, () -> addWindow(new GuiQIOFilerSelect(this, tile))));
scrollBar = addButton(new GuiScrollBar(this, 153, 30, 90, () -> tile.getFilters().size(), () -> FILTER_COUNT));
// Add each of the buttons and then just change visibility state to match filter info
for (int i = 0; i < FILTER_COUNT; i++) {
addButton(new MovableFilterButton(this, 10, 31 + i * 22, 142, 22, i, scrollBar::getCurrentSelection, tile::getFilters, index -> {
if (index > 0) {
Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.MOVE_FILTER_UP, tile, index));
}
}, index -> {
if (index < tile.getFilters().size() - 1) {
Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.MOVE_FILTER_DOWN, tile, index));
}
}, this::onClick, filter -> {
List<ItemStack> list = new ArrayList<>();
if (filter != null) {
if (filter instanceof IItemStackFilter) {
list.add(((IItemStackFilter<?>) filter).getItemStack());
} else if (filter instanceof ITagFilter) {
String name = ((ITagFilter<?>) filter).getTagName();
if (name != null && !name.isEmpty()) {
list.addAll(TagCache.getItemTagStacks(((ITagFilter<?>) filter).getTagName()));
}
} else if (filter instanceof IModIDFilter) {
list.addAll(TagCache.getModIDStacks(((IModIDFilter<?>) filter).getModID(), false));
}
}
return list;
}));
}
}
use of mekanism.common.network.to_server.PacketGuiInteract in project Mekanism by mekanism.
the class GuiQIOImporter method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiScreenSwitch(this, 9, 122, imageWidth - 18, MekanismLang.QIO_IMPORT_WITHOUT_FILTER.translate(), tile::getImportWithoutFilter, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.QIO_TOGGLE_IMPORT_WITHOUT_FILTER, tile))));
}
use of mekanism.common.network.to_server.PacketGuiInteract in project Mekanism by mekanism.
the class GuiRotaryCondensentrator method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiDownArrow(this, 159, 44));
addButton(new GuiHorizontalPowerBar(this, tile.getEnergyContainer(), 115, 75));
addButton(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getEnergyUsed));
addButton(new GuiFluidGauge(() -> tile.fluidTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 133, 13));
addButton(new GuiGasGauge(() -> tile.gasTank, () -> tile.getGasTanks(null), GaugeType.STANDARD, this, 25, 13));
addButton(new GuiProgress(new IBooleanProgressInfoHandler() {
@Override
public boolean fillProgressBar() {
return tile.getActive();
}
@Override
public boolean isActive() {
return !tile.mode;
}
}, ProgressType.LARGE_RIGHT, this, 64, 39).jeiCategories(condensentrating));
addButton(new GuiProgress(new IBooleanProgressInfoHandler() {
@Override
public boolean fillProgressBar() {
return tile.getActive();
}
@Override
public boolean isActive() {
return tile.mode;
}
}, ProgressType.LARGE_LEFT, this, 64, 39).jeiCategories(decondensentrating));
addButton(new ToggleButton(this, 4, 4, () -> tile.mode, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.NEXT_MODE, tile)), getOnHover(MekanismLang.CONDENSENTRATOR_TOGGLE)));
}
use of mekanism.common.network.to_server.PacketGuiInteract in project Mekanism by mekanism.
the class GuiLogisticalSorter method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiSlot(SlotType.NORMAL, this, 12, 136).setRenderAboveSlots());
addButton(new TranslationButton(this, 56, 136, 96, 20, MekanismLang.BUTTON_NEW_FILTER, () -> addWindow(new GuiSorterFilerSelect(this, tile))));
addButton(new MekanismImageButton(this, 12, 58, 14, getButtonLocation("single"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.SINGLE_ITEM_BUTTON, tile)), getOnHover(MekanismLang.SORTER_SINGLE_ITEM_DESCRIPTION)));
addButton(new MekanismImageButton(this, 12, 84, 14, getButtonLocation("round_robin"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.ROUND_ROBIN_BUTTON, tile)), getOnHover(MekanismLang.SORTER_ROUND_ROBIN_DESCRIPTION)));
addButton(new MekanismImageButton(this, 12, 110, 14, getButtonLocation("auto_eject"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.AUTO_EJECT_BUTTON, tile)), getOnHover(MekanismLang.SORTER_AUTO_EJECT_DESCRIPTION)));
addButton(new ColorButton(this, 13, 137, 16, 16, () -> tile.color, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.CHANGE_COLOR, tile, hasShiftDown() ? -1 : TransporterUtils.getColorIndex(TransporterUtils.increment(tile.color)))), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.CHANGE_COLOR, tile, TransporterUtils.getColorIndex(TransporterUtils.decrement(tile.color))))));
}
use of mekanism.common.network.to_server.PacketGuiInteract in project Mekanism by mekanism.
the class GuiFilterHolder method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiInnerScreen(this, 9, 17, 46, 140));
// Filter holder
addButton(new GuiElementHolder(this, 55, 17, 98, 118));
// new filter button border
addButton(new GuiElementHolder(this, 55, 135, 98, 22));
scrollBar = addButton(new GuiScrollBar(this, 153, 17, 140, () -> getFilters().size(), () -> FILTER_COUNT));
// Add each of the buttons and then just change visibility state to match filter info
for (int i = 0; i < FILTER_COUNT; i++) {
addFilterButton(new MovableFilterButton(this, 56, 18 + i * 29, i, scrollBar::getCurrentSelection, this::getFilters, index -> {
if (index > 0) {
Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.MOVE_FILTER_UP, tile, index));
}
}, index -> {
if (index < getFilters().size() - 1) {
Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.MOVE_FILTER_DOWN, tile, index));
}
}, this::onClick, filter -> {
List<ItemStack> list = new ArrayList<>();
if (filter != null) {
if (filter instanceof IItemStackFilter) {
list.add(((IItemStackFilter<?>) filter).getItemStack());
} else if (filter instanceof ITagFilter) {
list.addAll(getTagStacks(((ITagFilter<?>) filter).getTagName()));
} else if (filter instanceof IMaterialFilter) {
list.addAll(TagCache.getMaterialStacks(((IMaterialFilter<?>) filter).getMaterialItem()));
} else if (filter instanceof IModIDFilter) {
list.addAll(TagCache.getModIDStacks(((IModIDFilter<?>) filter).getModID(), false));
}
}
return list;
}));
}
}
Aggregations