Search in sources :

Example 86 with TranslatableText

use of net.minecraft.text.TranslatableText in project ArmorStandEditor by Patbox.

the class EditorGuis method openGui.

public static void openGui(ServerPlayerEntity player) {
    SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_9X5, player, false) {

        @Override
        public boolean onClick(int index, ClickType type, SlotActionType action, GuiElementInterface element) {
            setIcons(player, this);
            return super.onClick(index, type, action, element);
        }
    };
    gui.setTitle(new TranslatableText("armorstandeditor.gui.editor_title"));
    setIcons(player, gui);
    gui.open();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ClickType(eu.pb4.sgui.api.ClickType) SlotActionType(net.minecraft.screen.slot.SlotActionType) GuiElementInterface(eu.pb4.sgui.api.elements.GuiElementInterface) SimpleGui(eu.pb4.sgui.api.gui.SimpleGui)

Example 87 with TranslatableText

use of net.minecraft.text.TranslatableText in project ArmorStandEditor by Patbox.

the class EditorGuis method createIcon.

private static void createIcon(ServerPlayerEntity player, SimpleGui gui, int index, Item item, String text, float power) {
    ItemStack itemStack = item.getDefaultStack();
    itemStack.setCustomName(new TranslatableText("armorstandeditor.gui.name." + text).setStyle(Style.EMPTY.withItalic(false)));
    ListTag lore = new ListTag();
    lore.add(StringTag.of(Text.Serializer.toJson(new TranslatableText("armorstandeditor.gui.blocksdeg", (Math.round(power * 100) / 100f), Math.floor(power * 3000) / 100).setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.GRAY)))));
    itemStack.getOrCreateTag().getCompound("display").put("Lore", lore);
    itemStack.addHideFlag(ItemStack.TooltipSection.ENCHANTMENTS);
    itemStack.addHideFlag(ItemStack.TooltipSection.MODIFIERS);
    if (((SPEInterface) player).getArmorStandEditorPower() == power) {
        itemStack.addEnchantment(Enchantments.POWER, 1);
    }
    gui.setSlot(index, itemStack, (index2, type, actionType) -> {
        ((SPEInterface) player).setArmorStandEditorPower(power);
    });
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) SPEInterface(eu.pb4.armorstandeditor.helpers.SPEInterface) ItemStack(net.minecraft.item.ItemStack) ListTag(net.minecraft.nbt.ListTag)

Example 88 with TranslatableText

use of net.minecraft.text.TranslatableText in project ArmorStandEditor by Patbox.

the class GeneralCommands method savePreset.

private static int savePreset(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    ServerPlayerEntity player = context.getSource().getPlayer();
    SPEInterface spei = (SPEInterface) player;
    String id = context.getArgument("id", String.class);
    String name = context.getArgument("name", String.class);
    if (ConfigManager.INVALID_CHAR.matcher(id).matches()) {
        context.getSource().sendFeedback(new TranslatableText("armorstandeditor.command.invalid-id", id).formatted(Formatting.RED), false);
        return 0;
    }
    if (spei.getArmorStandEditorData() != null) {
        ArmorStandPreset preset = new ArmorStandPreset(id, name, player.getGameProfile().getName());
        preset.fromData(spei.getArmorStandEditorData());
        ConfigManager.savePreset(preset);
        context.getSource().sendFeedback(new TranslatableText("armorstandeditor.command.save-preset.success", name, id), false);
    } else {
        context.getSource().sendFeedback(new TranslatableText("armorstandeditor.command.save-preset.fail", name, id).formatted(Formatting.RED), false);
    }
    return 0;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ArmorStandPreset(eu.pb4.armorstandeditor.config.ArmorStandPreset) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 89 with TranslatableText

use of net.minecraft.text.TranslatableText in project sodium-extra-fabric by FlashyReese.

the class SodiumExtraGameOptionPages method render.

public static OptionPage render() {
    List<OptionGroup> groups = new ArrayList<>();
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(int.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.fog")).setTooltip(new TranslatableText("sodium-extra.option.fog.tooltip")).setControl(option -> new SliderControlExtended(option, 0, 33, 1, ControlValueFormatterExtended.fogDistance(), false)).setBinding((options, value) -> options.renderSettings.fogDistance = value, options -> options.renderSettings.fogDistance).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.light_updates")).setTooltip(new TranslatableText("sodium-extra.option.light_updates.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.renderSettings.lightUpdates = value, options -> options.renderSettings.lightUpdates).build()).build());
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("entity.minecraft.item_frame")).setTooltip(new TranslatableText("sodium-extra.option.item_frames.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.renderSettings.itemFrame = value, opts -> opts.renderSettings.itemFrame).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("entity.minecraft.armor_stand")).setTooltip(new TranslatableText("sodium-extra.option.armor_stands.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.renderSettings.armorStand = value, options -> options.renderSettings.armorStand).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("entity.minecraft.painting")).setTooltip(new TranslatableText("sodium-extra.option.paintings.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.renderSettings.painting = value, options -> options.renderSettings.painting).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("block.minecraft.piston")).setTooltip(new TranslatableText("sodium-extra.option.piston.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.renderSettings.piston = value, options -> options.renderSettings.piston).build()).build());
    return new OptionPage(new TranslatableText("sodium-extra.option.render"), ImmutableList.copyOf(groups));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) SliderControlExtended(me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended) TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) MinecraftOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage) me.jellysquid.mods.sodium.client.gui.options(me.jellysquid.mods.sodium.client.gui.options) SodiumExtraOptionsStorage(me.flashyreese.mods.sodiumextra.client.gui.options.storage.SodiumExtraOptionsStorage) CyclingControl(me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl) TranslatableText(net.minecraft.text.TranslatableText) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ControlValueFormatterExtended(me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended) MinecraftClient(net.minecraft.client.MinecraftClient) ControlValueFormatter(me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl) ArrayList(java.util.ArrayList) TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) SliderControlExtended(me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended)

Example 90 with TranslatableText

use of net.minecraft.text.TranslatableText in project sodium-extra-fabric by FlashyReese.

the class SodiumExtraGameOptionPages method detail.

public static OptionPage detail() {
    List<OptionGroup> groups = new ArrayList<>();
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.sky")).setTooltip(new TranslatableText("sodium-extra.option.sky.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.detailSettings.sky = value, opts -> opts.detailSettings.sky).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.stars")).setTooltip(new TranslatableText("sodium-extra.option.stars.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.detailSettings.stars = value, opts -> opts.detailSettings.stars).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.sun_moon")).setTooltip(new TranslatableText("sodium-extra.option.sun_moon.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.detailSettings.sunMoon = value, opts -> opts.detailSettings.sunMoon).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("soundCategory.weather")).setTooltip(new TranslatableText("sodium-extra.option.rain_snow.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.detailSettings.rainSnow = value, opts -> opts.detailSettings.rainSnow).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.biome_colors")).setTooltip(new TranslatableText("sodium-extra.option.biome_colors.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.detailSettings.biomeColors = value, options -> options.detailSettings.biomeColors).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.sky_colors")).setTooltip(new TranslatableText("sodium-extra.option.sky_colors.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.detailSettings.skyColors = value, options -> options.detailSettings.skyColors).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).build());
    return new OptionPage(new TranslatableText("sodium-extra.option.details"), ImmutableList.copyOf(groups));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) SliderControlExtended(me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended) TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) MinecraftOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage) me.jellysquid.mods.sodium.client.gui.options(me.jellysquid.mods.sodium.client.gui.options) SodiumExtraOptionsStorage(me.flashyreese.mods.sodiumextra.client.gui.options.storage.SodiumExtraOptionsStorage) CyclingControl(me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl) TranslatableText(net.minecraft.text.TranslatableText) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ControlValueFormatterExtended(me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended) MinecraftClient(net.minecraft.client.MinecraftClient) ControlValueFormatter(me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl) ArrayList(java.util.ArrayList) TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl)

Aggregations

TranslatableText (net.minecraft.text.TranslatableText)161 LiteralText (net.minecraft.text.LiteralText)30 Text (net.minecraft.text.Text)19 ItemStack (net.minecraft.item.ItemStack)16 ArrayList (java.util.ArrayList)15 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)14 List (java.util.List)12 MinecraftClient (net.minecraft.client.MinecraftClient)12 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)12 SPEInterface (eu.pb4.armorstandeditor.helpers.SPEInterface)9 LivingEntity (net.minecraft.entity.LivingEntity)9 PlayerEntity (net.minecraft.entity.player.PlayerEntity)8 ListTag (net.minecraft.nbt.ListTag)8 Formatting (net.minecraft.util.Formatting)8 BlockPos (net.minecraft.util.math.BlockPos)8 Environment (net.fabricmc.api.Environment)7 AbstractButtonWidget (net.minecraft.client.gui.widget.AbstractButtonWidget)7 Entity (net.minecraft.entity.Entity)7 Collection (java.util.Collection)6 ArmorStandPreset (eu.pb4.armorstandeditor.config.ArmorStandPreset)5