Search in sources :

Example 1 with GuiTheme

use of mathax.client.gui.GuiTheme in project Client by MatHax.

the class StatsScreen method updateData.

private void updateData() {
    clear();
    GuiTheme theme = GuiThemes.get();
    Language lang = TranslationStorage.getInstance();
    add(theme.label(String.format("Type: %s", lang.get(entity.getType().getTranslationKey()))));
    add(theme.label(String.format("Age: %d", entity.age)));
    add(theme.label(String.format("UUID: %s", entity.getUuidAsString())));
    if (entity instanceof LivingEntity) {
        LivingEntity liv = (LivingEntity) entity;
        add(theme.label(String.format("Health: %.2f/%.2f", liv.getHealth(), liv.getMaxHealth())));
        add(theme.label(String.format("Armor: %d/20", liv.getArmor())));
        WSection effectList = add(theme.section("Status Effects", effectListExpanded)).expandX().widget();
        effectList.action = () -> effectListExpanded = effectList.isExpanded();
        liv.getActiveStatusEffects().forEach((effect, instance) -> {
            String status = lang.get(effect.getTranslationKey());
            if (instance.getAmplifier() != 0)
                status += (String.format(" %d (%s)", instance.getAmplifier() + 1, StatusEffectUtil.durationToString(instance, 1)));
            else
                status += (String.format(" (%s)", StatusEffectUtil.durationToString(instance, 1)));
            effectList.add(theme.label(status)).expandX();
        });
        if (liv.getActiveStatusEffects().isEmpty())
            effectList.add(theme.label("No effects")).expandX();
        WSection attribList = add(theme.section("Attributes", attribListExpanded)).expandX().widget();
        attribList.action = () -> attribListExpanded = attribList.isExpanded();
        liv.getAttributes().getTracked().forEach((attrib) -> attribList.add(theme.label(String.format("%s: %.2f", lang.get(attrib.getAttribute().getTranslationKey()), attrib.getValue()))).expandX());
    }
    WSection dimension = add(theme.section("Dimensions", dimensionExpanded)).expandX().widget();
    dimension.action = () -> dimensionExpanded = dimension.isExpanded();
    dimension.add(theme.label(String.format("Position: %.2f, %.2f, %.2f", entity.getX(), entity.getY(), entity.getZ()))).expandX();
    dimension.add(theme.label(String.format("Yaw: %.2f, Pitch: %.2f", entity.getYaw(), entity.getPitch()))).expandX();
    Box box = entity.getBoundingBox();
    dimension.add(theme.label(String.format("Bounding Box: %.2f, %.2f, %.2f", box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ))).expandX();
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) WSection(mathax.client.gui.widgets.containers.WSection) Language(net.minecraft.util.Language) GuiTheme(mathax.client.gui.GuiTheme) Box(net.minecraft.util.math.Box)

Example 2 with GuiTheme

use of mathax.client.gui.GuiTheme in project Client by MatHax.

the class WSearchBar method add.

@Override
public void add(WTable parent, MusicTab.MusicScreen screen, GuiTheme theme) {
    WTextBox box = parent.add(theme.textBox("")).expandX().widget();
    parent.add(theme.button("Search")).widget().action = () -> SearchUtils.search(box.get(), playlist -> mc.setScreen(new PlaylistViewScreen(theme, playlist, screen)));
    super.add(parent, screen, theme);
}
Also used : PlaylistViewScreen(mathax.client.gui.screens.music.PlaylistViewScreen) WTable(mathax.client.gui.widgets.containers.WTable) MusicTab(mathax.client.gui.tabs.builtin.MusicTab) WTextBox(mathax.client.gui.widgets.input.WTextBox) GuiTheme(mathax.client.gui.GuiTheme) SearchUtils(mathax.client.utils.music.SearchUtils) MatHax.mc(mathax.client.MatHax.mc) WTextBox(mathax.client.gui.widgets.input.WTextBox) PlaylistViewScreen(mathax.client.gui.screens.music.PlaylistViewScreen)

Aggregations

GuiTheme (mathax.client.gui.GuiTheme)2 MatHax.mc (mathax.client.MatHax.mc)1 PlaylistViewScreen (mathax.client.gui.screens.music.PlaylistViewScreen)1 MusicTab (mathax.client.gui.tabs.builtin.MusicTab)1 WSection (mathax.client.gui.widgets.containers.WSection)1 WTable (mathax.client.gui.widgets.containers.WTable)1 WTextBox (mathax.client.gui.widgets.input.WTextBox)1 SearchUtils (mathax.client.utils.music.SearchUtils)1 LivingEntity (net.minecraft.entity.LivingEntity)1 Language (net.minecraft.util.Language)1 Box (net.minecraft.util.math.Box)1