use of mekanism.client.gui.element.button.TranslationButton in project Mekanism by mekanism.
the class GuiPortableTeleporter method addGuiElements.
@Override
protected void addGuiElements() {
super.addGuiElements();
addButton(new GuiTeleporterStatus(this, () -> getFrequency() != null, menu::getStatus));
addButton(new GuiVerticalPowerBar(this, new IBarInfoHandler() {
@Override
public ITextComponent getTooltip() {
IEnergyContainer container = StorageUtils.getEnergyContainer(menu.getStack(), 0);
return container == null ? EnergyDisplay.ZERO.getTextComponent() : EnergyDisplay.of(container).getTextComponent();
}
@Override
public double getLevel() {
IEnergyContainer container = StorageUtils.getEnergyContainer(menu.getStack(), 0);
return container == null ? 0 : container.getEnergy().divideToLevel(container.getMaxEnergy());
}
}, 158, 26));
teleportButton = addButton(new TranslationButton(this, 42, 147, 92, 20, MekanismLang.BUTTON_TELEPORT, () -> {
TeleporterFrequency frequency = getFrequency();
if (frequency != null && menu.getStatus() == 1) {
// This should always be true if the teleport button is active, but validate it just in case
ClientTickHandler.portableTeleport(getMinecraft().player, menu.getHand(), frequency.getIdentity());
getMinecraft().player.closeContainer();
} else {
// If something did go wrong make the teleport button not able to be pressed
teleportButton.active = false;
}
}));
// Teleporter button starts as deactivated until we have a frequency get synced
teleportButton.active = false;
addButton(new GuiFrequencySelector<>(this, 14));
}
Aggregations