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();
}
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);
});
}
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;
}
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));
}
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));
}
Aggregations