Search in sources :

Example 71 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project FZMM-Mod by Zailer43.

the class GradientLogic method getGradient.

public static MutableText getGradient(String message, Color4f initialColor4f, Color4f finalColor4f, boolean obfuscated, boolean bold, boolean strikethrough, boolean underline, boolean italic) {
    MinecraftClient mc = MinecraftClient.getInstance();
    assert mc.player != null;
    Color initialColor = new Color(initialColor4f.intValue);
    Color finalColor = new Color(finalColor4f.intValue);
    byte red = (byte) (initialColor.getRed() + Byte.MIN_VALUE);
    byte green = (byte) (initialColor.getGreen() + Byte.MIN_VALUE);
    byte blue = (byte) (initialColor.getBlue() + Byte.MIN_VALUE);
    byte red2 = (byte) (finalColor.getRed() + Byte.MIN_VALUE);
    byte green2 = (byte) (finalColor.getGreen() + Byte.MIN_VALUE);
    byte blue2 = (byte) (finalColor.getBlue() + Byte.MIN_VALUE);
    Style style = Style.EMPTY;
    if (obfuscated)
        style = style.withObfuscated(true);
    if (bold)
        style = style.withBold(true);
    if (strikethrough)
        style = style.withStrikethrough(true);
    if (underline)
        style = style.withUnderline(true);
    if (italic)
        style = style.withItalic(true);
    else
        style = style.withItalic(false);
    return getGradient(message, red, green, blue, red2, green2, blue2, style);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) TextColor(net.minecraft.text.TextColor) Style(net.minecraft.text.Style)

Example 72 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project FZMM-Mod by Zailer43.

the class GenericCallback method changeGuiScale.

private boolean changeGuiScale(boolean increment) {
    MinecraftClient mc = MinecraftClient.getInstance();
    int guiScale = mc.options.guiScale;
    if (increment)
        guiScale++;
    else
        guiScale--;
    guiScale = MathHelper.clamp(guiScale, 1, 4);
    mc.options.guiScale = guiScale;
    mc.onResolutionChanged();
    return true;
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient)

Example 73 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project BlockMeter by ModProg.

the class BlockMeterClient method renderOverlay.

public void renderOverlay(float partialTicks, MatrixStack stack) {
    final MinecraftClient client = MinecraftClient.getInstance();
    final Camera camera = client.gameRenderer.getCamera();
    final Identifier currentDimension = client.player.world.getRegistryKey().getValue();
    final ModConfig cfg = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
    // MEH! but this seems to be needed to get the first background
    // rectangle
    client.textRenderer.draw(stack, "XXX", -100, -100, 0);
    if (this.active || cfg.showBoxesWhenDisabled)
        if (cfg.showOtherUsersBoxes) {
            if (otherUsersBoxes != null && otherUsersBoxes.size() > 0) {
                this.otherUsersBoxes.forEach((playerText, boxList) -> {
                    boxList.forEach(box -> box.render(camera, stack, currentDimension, playerText));
                });
                this.boxes.forEach(box -> {
                    if (!box.isFinished())
                        box.render(camera, stack, currentDimension);
                });
            }
            if (!cfg.sendBoxes)
                this.boxes.forEach(box -> {
                    if (box.isFinished())
                        box.render(camera, stack, currentDimension, client.player.getDisplayName());
                    else
                        box.render(camera, stack, currentDimension);
                });
        } else
            this.boxes.forEach(box -> box.render(camera, stack, currentDimension));
}
Also used : PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) Item(net.minecraft.item.Item) OptionsGui(win.baruna.blockmeter.gui.OptionsGui) ConfigManager(me.shedaniel.autoconfig.ConfigManager) TranslatableText(net.minecraft.text.TranslatableText) PacketByteBuf(net.minecraft.network.PacketByteBuf) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Unpooled(io.netty.buffer.Unpooled) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) UseBlockCallback(net.fabricmc.fabric.api.event.player.UseBlockCallback) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) ClientModInitializer(net.fabricmc.api.ClientModInitializer) ClientPlayNetworking(net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking) PlayerEntity(net.minecraft.entity.player.PlayerEntity) KeyBindingHelper(net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper) InputUtil(net.minecraft.client.util.InputUtil) MatrixStack(net.minecraft.client.util.math.MatrixStack) BlockHitResult(net.minecraft.util.hit.BlockHitResult) BlockPos(net.minecraft.util.math.BlockPos) KeyBinding(net.minecraft.client.option.KeyBinding) GLFW(org.lwjgl.glfw.GLFW) Toml4jConfigSerializer(me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer) ActionResult(net.minecraft.util.ActionResult) HitResult(net.minecraft.util.hit.HitResult) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) DyeColor(net.minecraft.util.DyeColor) SelectBoxGui(win.baruna.blockmeter.gui.SelectBoxGui) AutoConfig(me.shedaniel.autoconfig.AutoConfig) Identifier(net.minecraft.util.Identifier) ClientTickEvents(net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents) MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) Camera(net.minecraft.client.render.Camera) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) Camera(net.minecraft.client.render.Camera)

Example 74 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project bewitchment by MoriyaShiine.

the class SyncContractsPacket method handle.

public static void handle(MinecraftClient client, ClientPlayNetworkHandler network, PacketByteBuf buf, PacketSender sender) {
    NbtCompound contractsCompound = buf.readNbt();
    client.execute(new Runnable() {

        @Override
        public void run() {
            if (client.player != null) {
                BWComponents.CONTRACTS_COMPONENT.maybeGet(client.player).ifPresent(contractsComponent -> {
                    contractsComponent.getContracts().clear();
                    NbtList contractsList = contractsCompound.getList("Contracts", NbtType.COMPOUND);
                    for (int i = 0; i < contractsList.size(); i++) {
                        NbtCompound contractCompound = contractsList.getCompound(i);
                        contractsComponent.addContract(new Contract.Instance(BWRegistries.CONTRACTS.get(new Identifier(contractCompound.getString("Contract"))), contractCompound.getInt("Duration"), contractCompound.getInt("Cost")));
                    }
                });
            }
        }
    });
}
Also used : PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Contract(moriyashiine.bewitchment.api.registry.Contract) NbtList(net.minecraft.nbt.NbtList) PacketByteBuf(net.minecraft.network.PacketByteBuf) Unpooled(io.netty.buffer.Unpooled) BWRegistries(moriyashiine.bewitchment.common.registry.BWRegistries) NbtCompound(net.minecraft.nbt.NbtCompound) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) NbtType(net.fabricmc.fabric.api.util.NbtType) ServerPlayNetworking(net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking) BWComponents(moriyashiine.bewitchment.common.registry.BWComponents) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) Bewitchment(moriyashiine.bewitchment.common.Bewitchment) Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList)

Example 75 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project reeses-sodium-options by FlashyReese.

the class SodiumVideoOptionsScreen method applyChanges.

private void applyChanges() {
    final HashSet<OptionStorage<?>> dirtyStorages = new HashSet<>();
    final EnumSet<OptionFlag> flags = EnumSet.noneOf(OptionFlag.class);
    this.getAllOptions().forEach((option -> {
        if (!option.hasChanged()) {
            return;
        }
        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.setMipmapLevels(client.options.mipmapLevels);
        client.reloadResourcesConcurrently();
    }
    for (OptionStorage<?> storage : dirtyStorages) {
        storage.save();
    }
}
Also used : FabricLoader(net.fabricmc.loader.api.FabricLoader) LiteralText(net.minecraft.text.LiteralText) Util(net.minecraft.util.Util) TranslatableText(net.minecraft.text.TranslatableText) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) OptionFlag(me.jellysquid.mods.sodium.client.gui.options.OptionFlag) TabFrame(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.tab.TabFrame) EnumSet(java.util.EnumSet) FlatButtonWidget(me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget) SodiumGameOptions(me.jellysquid.mods.sodium.client.gui.SodiumGameOptions) Dim2i(me.jellysquid.mods.sodium.client.util.Dim2i) SodiumClientMod(me.jellysquid.mods.sodium.client.SodiumClientMod) VideoOptionsScreen(net.minecraft.client.gui.screen.option.VideoOptionsScreen) MatrixStack(net.minecraft.client.util.math.MatrixStack) IOException(java.io.IOException) OptionStorage(me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage) GLFW(org.lwjgl.glfw.GLFW) Tab(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.tab.Tab) Option(me.jellysquid.mods.sodium.client.gui.options.Option) OptionPage(me.jellysquid.mods.sodium.client.gui.options.OptionPage) AbstractFrame(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.AbstractFrame) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) Stream(java.util.stream.Stream) MinecraftClient(net.minecraft.client.MinecraftClient) BasicFrame(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.BasicFrame) IrisApi(net.irisshaders.iris.api.v0.IrisApi) MinecraftClient(net.minecraft.client.MinecraftClient) OptionStorage(me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage) OptionFlag(me.jellysquid.mods.sodium.client.gui.options.OptionFlag) HashSet(java.util.HashSet)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)107 Text (net.minecraft.text.Text)15 ItemStack (net.minecraft.item.ItemStack)14 PlayerEntity (net.minecraft.entity.player.PlayerEntity)11 TranslatableText (net.minecraft.text.TranslatableText)10 Inject (org.spongepowered.asm.mixin.injection.Inject)10 Identifier (net.minecraft.util.Identifier)8 TextRenderer (net.minecraft.client.font.TextRenderer)7 Screen (net.minecraft.client.gui.screen.Screen)7 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)7 BlockHitResult (net.minecraft.util.hit.BlockHitResult)7 GameRenderer (net.minecraft.client.render.GameRenderer)6 MatrixStack (net.minecraft.client.util.math.MatrixStack)6 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 PlayerInventory (net.minecraft.entity.player.PlayerInventory)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 Entity (net.minecraft.entity.Entity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4