Search in sources :

Example 76 with TranslatableText

use of net.minecraft.text.TranslatableText in project VillagerConfig by DrexHD.

the class ConfigScreen method getConfigScreen.

public static Screen getConfigScreen(Screen parentScreen) {
    ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parentScreen).setDefaultBackgroundTexture(new Identifier("minecraft:textures/block/emerald_block.png")).setTitle(new TranslatableText("config.villagerconfig.title"));
    builder.setGlobalized(true);
    builder.setGlobalizedExpanded(false);
    ConfigEntryBuilder entryBuilder = builder.entryBuilder();
    ConfigCategory features = builder.getOrCreateCategory(new TranslatableText("config.villagerconfig.category.features"));
    features.addEntry(entryBuilder.startDoubleField(new TranslatableText("config.villagerconfig.maxdiscount"), ConfigEntries.features.maxDiscount).setDefaultValue(100).setMin(0.0).setMax(100.0).setSaveConsumer(value -> ConfigEntries.features.maxDiscount = value).setTooltip(new TranslatableText("config.villagerconfig.maxdiscount.tooltip")).build());
    features.addEntry(entryBuilder.startDoubleField(new TranslatableText("config.villagerconfig.maxraise"), ConfigEntries.features.maxRaise).setDefaultValue(100).setMin(0.0).setMax(100.0).setSaveConsumer(value -> ConfigEntries.features.maxRaise = value).setTooltip(new TranslatableText("config.villagerconfig.maxraise.tooltip")).build());
    features.addEntry(entryBuilder.startDoubleField(new TranslatableText("config.villagerconfig.conversionchance"), ConfigEntries.features.conversionChance).setDefaultValue(-1).setMin(-1.0).setMax(100.0).setSaveConsumer(value -> ConfigEntries.features.conversionChance = value).setTooltip(new TranslatableText("config.villagerconfig.conversionchance.tooltip")).build());
    features.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.villagerconfig.tradecycling"), ConfigEntries.features.tradeCycling).setDefaultValue(true).setSaveConsumer(value -> ConfigEntries.features.tradeCycling = value).setTooltip(new TranslatableText("config.villagerconfig.tradecycling.tooltip")).build());
    features.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.villagerconfig.infiniteTrades"), ConfigEntries.features.infiniteTrades).setDefaultValue(false).setSaveConsumer(value -> ConfigEntries.features.infiniteTrades = value).setTooltip(new TranslatableText("config.villagerconfig.infiniteTrades.tooltip")).build());
    ConfigCategory oldTrades = builder.getOrCreateCategory(new TranslatableText("config.villagerconfig.category.old_trades")).setCategoryBackground(new Identifier("minecraft:textures/block/emerald_block.png"));
    oldTrades.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.villagerconfig.enabled"), ConfigEntries.oldTrades.enabled).setDefaultValue(false).setSaveConsumer(value -> ConfigEntries.oldTrades.enabled = value).setTooltip(new TranslatableText("config.villagerconfig.enabled.tooltip")).build());
    oldTrades.addEntry(entryBuilder.startIntField(new TranslatableText("config.villagerconfig.minuses"), ConfigEntries.oldTrades.minUses).setDefaultValue(2).setMin(0).setSaveConsumer(value -> ConfigEntries.oldTrades.minUses = value).setTooltip(new TranslatableText("config.villagerconfig.minuses.tooltip")).build());
    oldTrades.addEntry(entryBuilder.startIntField(new TranslatableText("config.villagerconfig.maxuses2"), ConfigEntries.oldTrades.maxUses).setDefaultValue(12).setMin(0).setSaveConsumer(value -> ConfigEntries.oldTrades.maxUses = value).setTooltip(new TranslatableText("config.villagerconfig.maxuses2.tooltip")).build());
    oldTrades.addEntry(entryBuilder.startDoubleField(new TranslatableText("config.villagerconfig.lockchance"), ConfigEntries.oldTrades.lockChance).setDefaultValue(20).setMin(0).setMax(100).setSaveConsumer(value -> ConfigEntries.oldTrades.lockChance = value).setTooltip(new TranslatableText("config.villagerconfig.lockchance.tooltip")).build());
    oldTrades.addEntry(entryBuilder.startDoubleField(new TranslatableText("config.villagerconfig.unlockchance"), ConfigEntries.oldTrades.unlockChance).setDefaultValue(20).setMin(0).setMax(100).setSaveConsumer(value -> ConfigEntries.oldTrades.unlockChance = value).setTooltip(new TranslatableText("config.villagerconfig.unlockchance.tooltip")).build());
    builder.setSavingRunnable(Config::saveModConfig);
    return builder.build();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Screen(net.minecraft.client.gui.screen.Screen) TranslatableText(net.minecraft.text.TranslatableText) Identifier(net.minecraft.util.Identifier) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder) Identifier(net.minecraft.util.Identifier) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder)

Example 77 with TranslatableText

use of net.minecraft.text.TranslatableText in project JexClient by DustinRepo.

the class JexTitleScreen method initWidgetsNormal.

private void initWidgetsNormal(int y) {
    JexTitleScreen titleScreen = this;
    this.addDrawableChild(new ButtonWidget(2, y, 200, 20, new TranslatableText("menu.singleplayer"), button -> {
        Wrapper.INSTANCE.getMinecraft().setScreen(new SelectWorldScreen(titleScreen));
    }));
    this.addDrawableChild(new ButtonWidget(2, y + 24, 175, 20, new TranslatableText("menu.multiplayer"), button -> {
        Wrapper.INSTANCE.getMinecraft().setScreen(new MultiplayerScreen(titleScreen));
    }));
    this.addDrawableChild(new ButtonWidget(2, y + 24 * 2, 150, 20, new TranslatableText("menu.online"), button -> {
        titleScreen.switchToRealms();
    }));
    this.addDrawableChild(new ButtonWidget(2, y + 24 * 3, 125, 20, new TranslatableText("menu.options"), button -> {
        Wrapper.INSTANCE.getMinecraft().setScreen(new OptionsScreen(titleScreen, Wrapper.INSTANCE.getOptions()));
    }));
    this.addDrawableChild(new ButtonWidget(2, y + 24 * 4, 100, 20, new TranslatableText("menu.quit"), button -> {
        Wrapper.INSTANCE.getMinecraft().scheduleStop();
    }));
    this.addDrawableChild(new ButtonWidget(2, height - 22, 100, 20, new TranslatableText("Changelog"), button -> {
        Wrapper.INSTANCE.getMinecraft().setScreen(new ChangelogScreen());
    }));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) SrcFactor(com.mojang.blaze3d.platform.GlStateManager.SrcFactor) Wrapper(me.dustin.jex.helper.misc.Wrapper) SelectWorldScreen(net.minecraft.client.gui.screen.world.SelectWorldScreen) Util(net.minecraft.util.Util) DstFactor(com.mojang.blaze3d.platform.GlStateManager.DstFactor) Feature(me.dustin.jex.feature.mod.core.Feature) StopWatch(me.dustin.jex.helper.misc.StopWatch) TranslatableText(net.minecraft.text.TranslatableText) Random(java.util.Random) FontHelper(me.dustin.jex.helper.render.font.FontHelper) Base64(org.apache.commons.codec.binary.Base64) ArrayList(java.util.ArrayList) ChangelogScreen(me.dustin.jex.gui.changelog.ChangelogScreen) ByteArrayInputStream(java.io.ByteArrayInputStream) DrawableHelper(net.minecraft.client.gui.DrawableHelper) ClientSettingsFile(me.dustin.jex.file.impl.ClientSettingsFile) SharedConstants(net.minecraft.SharedConstants) NativeImageBackedTexture(net.minecraft.client.texture.NativeImageBackedTexture) ClickableWidget(net.minecraft.client.gui.widget.ClickableWidget) MCAPIHelper(me.dustin.jex.helper.network.MCAPIHelper) CustomMainMenu(me.dustin.jex.feature.mod.impl.render.CustomMainMenu) Render2DHelper(me.dustin.jex.helper.render.Render2DHelper) Addon(me.dustin.jex.addon.Addon) GameRenderer(net.minecraft.client.render.GameRenderer) MatrixStack(net.minecraft.client.util.math.MatrixStack) IOException(java.io.IOException) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) FileUtils(org.apache.commons.io.FileUtils) File(java.io.File) Cape(me.dustin.jex.addon.cape.Cape) OptionsScreen(net.minecraft.client.gui.screen.option.OptionsScreen) UpdateManager(me.dustin.jex.helper.update.UpdateManager) Nullable(org.jetbrains.annotations.Nullable) Screen(net.minecraft.client.gui.screen.Screen) CubeMapRenderer(net.minecraft.client.gui.CubeMapRenderer) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) NativeImage(net.minecraft.client.texture.NativeImage) MathHelper(net.minecraft.util.math.MathHelper) RotatingCubeMapRenderer(net.minecraft.client.gui.RotatingCubeMapRenderer) ConfigManager(me.dustin.jex.file.core.ConfigManager) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) Identifier(net.minecraft.util.Identifier) ColorHelper(me.dustin.jex.helper.math.ColorHelper) MinecraftClient(net.minecraft.client.MinecraftClient) ModFileHelper(me.dustin.jex.helper.file.ModFileHelper) RealmsMainScreen(net.minecraft.client.realms.gui.screen.RealmsMainScreen) JexClient(me.dustin.jex.JexClient) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) OptionsScreen(net.minecraft.client.gui.screen.option.OptionsScreen) SelectWorldScreen(net.minecraft.client.gui.screen.world.SelectWorldScreen) ChangelogScreen(me.dustin.jex.gui.changelog.ChangelogScreen) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Example 78 with TranslatableText

use of net.minecraft.text.TranslatableText in project JexClient by DustinRepo.

the class BlockButton method render.

@Override
public void render(MatrixStack matrixStack) {
    if (isSelected()) {
        Render2DHelper.INSTANCE.fillAndBorder(matrixStack, this.getX(), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), ColorHelper.INSTANCE.getClientColor(), 0x25ffffff, 1);
    }
    FontHelper.INSTANCE.drawCenteredString(matrixStack, new TranslatableText(block.getTranslationKey()), this.getX() + (this.getWidth() / 2), this.getY() + (this.getHeight() / 2) - 4, isEnabled() ? 0xffaaaaaa : 0xff676767);
    Render2DHelper.INSTANCE.drawItem(new ItemStack(block.asItem()), (int) (getX() + 2), (int) (getY() + 2));
    if (isHovered() && isEnabled())
        Render2DHelper.INSTANCE.fill(matrixStack, this.getX(), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), 0x25ffffff);
    this.getChildren().forEach(button -> {
        button.render(matrixStack);
    });
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ItemStack(net.minecraft.item.ItemStack)

Example 79 with TranslatableText

use of net.minecraft.text.TranslatableText in project LevelZ by Globox1997.

the class StonecutterBlockMixin method onUseMixin.

@Inject(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;openHandledScreen(Lnet/minecraft/screen/NamedScreenHandlerFactory;)Ljava/util/OptionalInt;"), cancellable = true)
private void onUseMixin(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> info) {
    ArrayList<Object> levelList = LevelLists.stonecutterList;
    if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, true)) {
        player.sendMessage(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)), true);
        info.setReturnValue(ActionResult.FAIL);
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 80 with TranslatableText

use of net.minecraft.text.TranslatableText in project LevelZ by Globox1997.

the class SheepEntityMixin method interactMob.

@Inject(method = "interactMob", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/SheepEntity;sheared(Lnet/minecraft/sound/SoundCategory;)V"), cancellable = true)
private void interactMob(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> info) {
    ArrayList<Object> levelList = LevelLists.sheepList;
    if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, true)) {
        player.sendMessage(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)), true);
        info.setReturnValue(ActionResult.FAIL);
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

TranslatableText (net.minecraft.text.TranslatableText)336 LiteralText (net.minecraft.text.LiteralText)60 Inject (org.spongepowered.asm.mixin.injection.Inject)60 Text (net.minecraft.text.Text)52 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)46 MinecraftClient (net.minecraft.client.MinecraftClient)43 Screen (net.minecraft.client.gui.screen.Screen)42 ItemStack (net.minecraft.item.ItemStack)38 ArrayList (java.util.ArrayList)31 Environment (net.fabricmc.api.Environment)28 MatrixStack (net.minecraft.client.util.math.MatrixStack)25 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)22 List (java.util.List)20 Identifier (net.minecraft.util.Identifier)20 BlockPos (net.minecraft.util.math.BlockPos)20 EnvType (net.fabricmc.api.EnvType)19 TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)18 ConfirmScreen (net.minecraft.client.gui.screen.ConfirmScreen)16 Formatting (net.minecraft.util.Formatting)16 PlayerEntity (net.minecraft.entity.player.PlayerEntity)13