Search in sources :

Example 16 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project frame-fabric by moddingplayground.

the class TabWidget method renderButtonStack.

public void renderButtonStack(GUIIcon<?> icon, boolean hovered, boolean selected, int x, int y) {
    GUIIcon.optional(icon, hovered, selected, ItemStack.class).ifPresent(stack -> {
        MinecraftClient client = MinecraftClient.getInstance();
        ItemRenderer itemRenderer = client.getItemRenderer();
        itemRenderer.renderInGui(stack, x, y);
    });
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ItemRenderer(net.minecraft.client.render.item.ItemRenderer) ItemStack(net.minecraft.item.ItemStack)

Example 17 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project frame-fabric by moddingplayground.

the class TabWidget method renderTooltip.

@Override
public void renderTooltip(MatrixStack matrices, int mouseX, int mouseY) {
    MinecraftClient client = MinecraftClient.getInstance();
    if (client.currentScreen != null && !this.isSelected()) {
        Text message = this.getMessage();
        TooltipComponent tooltip = TooltipComponent.of(message.asOrderedText());
        int width = tooltip.getWidth(client.textRenderer);
        int height = tooltip.getHeight();
        int ox = this.isRightColumn() ? -this.width + 62 : -(width + this.width) + 20;
        int oz = -(height + this.height) + 16;
        client.currentScreen.renderTooltip(matrices, message, x + ox, y - oz);
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text) TooltipComponent(net.minecraft.client.gui.tooltip.TooltipComponent)

Example 18 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project frame-fabric by moddingplayground.

the class TabWidget method renderButton.

@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) {
    MinecraftClient client = MinecraftClient.getInstance();
    Tab tab = this.getTab();
    GUIIcon<?> icon = tab.getIcon();
    boolean hovered = this.isHovered();
    boolean selected = this.isSelected();
    int xo = hovered || selected ? (this.isRightColumn() ? 2 : -2) : 0;
    int x = this.x + 11 + xo;
    int y = this.y + 4;
    // render background
    this.renderBackground(matrices, client, mouseX, mouseY);
    // render icon
    GUIIcon.optional(icon, hovered, selected, Identifier.class).ifPresentOrElse(texture -> this.renderButtonTexture(texture, matrices, x, y), () -> this.renderButtonStack(icon, hovered, selected, x, y));
    // render tooltip
    if (hovered)
        this.renderTooltip(matrices, mouseX, mouseY);
}
Also used : Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient)

Example 19 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project sodium-fabric by CaffeineMC.

the class SodiumGameOptionPages method general.

public static OptionPage general() {
    List<OptionGroup> groups = new ArrayList<>();
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(int.class, vanillaOpts).setName("View Distance").setTooltip("The view distance controls how far away terrain will be rendered. Lower distances mean that less terrain will be " + "rendered, improving frame rates.").setControl(option -> new SliderControl(option, 2, 32, 1, ControlValueFormatter.quanity("Chunks"))).setBinding((options, value) -> options.viewDistance = value, options -> options.viewDistance).setImpact(OptionImpact.HIGH).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).add(OptionImpl.createBuilder(boolean.class, vanillaOpts).setName("V-Sync").setTooltip("If enabled, the game's frame rate will be synchronized to the monitor's refresh rate, making for a generally smoother experience " + "at the expense of overall input latency. This setting might reduce performance if your system is too slow.").setControl(TickBoxControl::new).setBinding(new VanillaBooleanOptionBinding(net.minecraft.client.options.Option.VSYNC)).setImpact(OptionImpact.VARIES).build()).add(OptionImpl.createBuilder(int.class, vanillaOpts).setName("FPS Limit").setTooltip("Limits the maximum number of frames per second. In effect, this will throttle the game and can be useful when you want to conserve " + "battery life or multi-task between other applications.").setControl(option -> new SliderControl(option, 5, 300, 5, ControlValueFormatter.quanity("FPS"))).setBinding((opts, value) -> {
        opts.maxFps = value;
        MinecraftClient.getInstance().getWindow().setFramerateLimit(value);
    }, opts -> opts.maxFps).build()).add(OptionImpl.createBuilder(boolean.class, vanillaOpts).setName("Fullscreen").setTooltip("If enabled, the game will display in full-screen.").setControl(TickBoxControl::new).setBinding((opts, value) -> {
        opts.fullscreen = value;
        MinecraftClient client = MinecraftClient.getInstance();
        Window window = client.getWindow();
        if (window != null && window.isFullscreen() != opts.fullscreen) {
            window.toggleFullscreen();
            // The client might not be able to enter full-screen mode
            opts.fullscreen = window.isFullscreen();
        }
    }, (opts) -> opts.fullscreen).build()).build());
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(int.class, vanillaOpts).setName("Brightness").setTooltip("Controls the brightness (gamma) of the game.").setControl(opt -> new SliderControl(opt, 0, 100, 1, ControlValueFormatter.percentage())).setBinding((opts, value) -> opts.gamma = value * 0.01D, (opts) -> (int) (opts.gamma / 0.01D)).build()).add(OptionImpl.createBuilder(boolean.class, sodiumOpts).setName("Clouds").setTooltip("Controls whether or not clouds will be visible.").setControl(TickBoxControl::new).setBinding((opts, value) -> opts.quality.enableClouds = value, (opts) -> opts.quality.enableClouds).setImpact(OptionImpact.LOW).build()).add(OptionImpl.createBuilder(ParticlesOption.class, vanillaOpts).setName("Particles").setTooltip("Controls the maximum number of particles which can be present on screen at any one time.").setControl(opt -> new CyclingControl<>(opt, ParticlesOption.values(), new String[] { "All", "Decreased", "Minimal" })).setBinding((opts, value) -> opts.particles = value, (opts) -> opts.particles).setImpact(OptionImpact.MEDIUM).build()).build());
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(boolean.class, vanillaOpts).setName("View Bobbing").setTooltip("If enabled, the player's view will sway and bob when moving around. Players who suffer from motion sickness can benefit from disabling this.").setControl(TickBoxControl::new).setBinding(new VanillaBooleanOptionBinding(net.minecraft.client.options.Option.VIEW_BOBBING)).build()).add(OptionImpl.createBuilder(AttackIndicator.class, vanillaOpts).setName("Attack Indicator").setTooltip("Controls where the Attack Indicator is displayed on screen.").setControl(opts -> new CyclingControl<>(opts, AttackIndicator.values(), new String[] { "Off", "Crosshair", "Hotbar" })).setBinding((opts, value) -> opts.attackIndicator = value, (opts) -> opts.attackIndicator).build()).build());
    return new OptionPage("General", ImmutableList.copyOf(groups));
}
Also used : TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) VanillaBooleanOptionBinding(me.jellysquid.mods.sodium.client.gui.options.binding.compat.VanillaBooleanOptionBinding) MinecraftOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage) me.jellysquid.mods.sodium.client.gui.options(me.jellysquid.mods.sodium.client.gui.options) CyclingControl(me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl) ParticlesOption(net.minecraft.client.options.ParticlesOption) GlVertexArray(me.jellysquid.mods.sodium.client.render.gl.GlVertexArray) ArrayList(java.util.ArrayList) SodiumOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage) Window(net.minecraft.client.util.Window) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) MinecraftClient(net.minecraft.client.MinecraftClient) ControlValueFormatter(me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter) AttackIndicator(net.minecraft.client.options.AttackIndicator) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl) Window(net.minecraft.client.util.Window) CyclingControl(me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl) VanillaBooleanOptionBinding(me.jellysquid.mods.sodium.client.gui.options.binding.compat.VanillaBooleanOptionBinding) ArrayList(java.util.ArrayList) TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) MinecraftClient(net.minecraft.client.MinecraftClient) ParticlesOption(net.minecraft.client.options.ParticlesOption) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl)

Example 20 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project sodium-fabric by CaffeineMC.

the class SodiumOptionsGUI method applyChanges.

private void applyChanges() {
    final HashSet<OptionStorage<?>> dirtyStorages = new HashSet<>();
    final EnumSet<OptionFlag> flags = EnumSet.noneOf(OptionFlag.class);
    for (Option<?> option : this.currentPage.getOptions()) {
        if (!option.hasChanged()) {
            continue;
        }
        option.applyChanges();
        flags.addAll(option.getFlags());
        dirtyStorages.add(option.getStorage());
    }
    MinecraftClient client = MinecraftClient.getInstance();
    if (flags.contains(OptionFlag.REQUIRES_RENDERER_RELOAD)) {
        client.worldRenderer.reload();
    }
    if (flags.contains(OptionFlag.REQUIRES_ASSET_RELOAD)) {
        client.resetMipmapLevels(client.options.mipmapLevels);
        client.reloadResourcesConcurrently();
    }
    for (OptionStorage<?> storage : dirtyStorages) {
        storage.save();
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) OptionStorage(me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage) HashSet(java.util.HashSet)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)84 ItemStack (net.minecraft.item.ItemStack)12 Text (net.minecraft.text.Text)7 Identifier (net.minecraft.util.Identifier)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 TextRenderer (net.minecraft.client.font.TextRenderer)5 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)5 BlockHitResult (net.minecraft.util.hit.BlockHitResult)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Entity (net.minecraft.entity.Entity)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)3 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)3 GameRenderer (net.minecraft.client.render.GameRenderer)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3