Search in sources :

Example 6 with TranslatableComponent

use of net.minecraft.network.chat.TranslatableComponent in project MinecraftForge by MinecraftForge.

the class ModListScreen method render.

@Override
public void render(PoseStack mStack, int mouseX, int mouseY, float partialTicks) {
    this.modList.render(mStack, mouseX, mouseY, partialTicks);
    if (this.modInfo != null)
        this.modInfo.render(mStack, mouseX, mouseY, partialTicks);
    Component text = new TranslatableComponent("fml.menu.mods.search");
    int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().width(text) / 2);
    this.search.render(mStack, mouseX, mouseY, partialTicks);
    super.render(mStack, mouseX, mouseY, partialTicks);
    getFontRenderer().draw(mStack, text.getVisualOrderText(), x, search.y - getFontRenderer().lineHeight, 0xFFFFFF);
}
Also used : TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Component(net.minecraft.network.chat.Component)

Example 7 with TranslatableComponent

use of net.minecraft.network.chat.TranslatableComponent in project MinecraftForge by MinecraftForge.

the class ClientModLoader method clientPackFinder.

private static void clientPackFinder(Map<IModFile, ? extends PathResourcePack> modResourcePacks, Consumer<Pack> consumer, Pack.PackConstructor factory) {
    List<PathResourcePack> hiddenPacks = new ArrayList<>();
    for (Entry<IModFile, ? extends PathResourcePack> e : modResourcePacks.entrySet()) {
        IModInfo mod = e.getKey().getModInfos().get(0);
        final String name = "mod:" + mod.getModId();
        final Pack packInfo = Pack.create(name, false, e::getValue, factory, Pack.Position.BOTTOM, PackSource.DEFAULT);
        if (packInfo == null) {
            // Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
            ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
            continue;
        }
        LOGGER.debug(CORE, "Generating PackInfo named {} for mod file {}", name, e.getKey().getFilePath());
        if (mod.getOwningFile().showAsResourcePack()) {
            consumer.accept(packInfo);
        } else {
            hiddenPacks.add(e.getValue());
        }
    }
    final Pack packInfo = Pack.create("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources", new PackMetadataSection(new TranslatableComponent("fml.resources.modresources", hiddenPacks.size()), PackType.CLIENT_RESOURCES.getVersion(SharedConstants.getCurrentVersion())), hiddenPacks), factory, Pack.Position.BOTTOM, PackSource.DEFAULT);
    consumer.accept(packInfo);
}
Also used : DelegatingResourcePack(net.minecraftforge.resource.DelegatingResourcePack) IModInfo(net.minecraftforge.forgespi.language.IModInfo) ClientPackSource(net.minecraft.client.resources.ClientPackSource) RepositorySource(net.minecraft.server.packs.repository.RepositorySource) PackType(net.minecraft.server.packs.PackType) File(java.io.File) MinecraftForge(net.minecraftforge.common.MinecraftForge) PackSource(net.minecraft.server.packs.repository.PackSource) IModFile(net.minecraftforge.forgespi.locating.IModFile) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) IModFile(net.minecraftforge.forgespi.locating.IModFile) Pack(net.minecraft.server.packs.repository.Pack) PathResourcePack(net.minecraftforge.resource.PathResourcePack) DelegatingResourcePack(net.minecraftforge.resource.DelegatingResourcePack) PathResourcePack(net.minecraftforge.resource.PathResourcePack) PackMetadataSection(net.minecraft.server.packs.metadata.pack.PackMetadataSection)

Example 8 with TranslatableComponent

use of net.minecraft.network.chat.TranslatableComponent in project MinecraftForge by MinecraftForge.

the class ModListScreen method init.

@Override
public void init() {
    for (IModInfo mod : mods) {
        listWidth = Math.max(listWidth, getFontRenderer().width(mod.getDisplayName()) + 10);
        listWidth = Math.max(listWidth, getFontRenderer().width(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5);
    }
    listWidth = Math.max(Math.min(listWidth, width / 3), 100);
    listWidth += listWidth % numButtons != 0 ? (numButtons - listWidth % numButtons) : 0;
    int modInfoWidth = this.width - this.listWidth - (PADDING * 3);
    int doneButtonWidth = Math.min(modInfoWidth, 200);
    int y = this.height - 20 - PADDING;
    int fullButtonHeight = PADDING + 20 + PADDING;
    doneButton = new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, new TranslatableComponent("gui.done"), b -> ModListScreen.this.onClose());
    openModsFolderButton = new Button(6, y, this.listWidth, 20, new TranslatableComponent("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile()));
    y -= 20 + PADDING;
    configButton = new Button(6, y, this.listWidth, 20, new TranslatableComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig());
    y -= 14 + PADDING;
    search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslatableComponent("fml.menu.mods.search"));
    this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.y - getFontRenderer().lineHeight - PADDING);
    this.modList.setLeftPos(6);
    this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING);
    this.addRenderableWidget(modList);
    this.addRenderableWidget(modInfo);
    this.addRenderableWidget(search);
    this.addRenderableWidget(doneButton);
    this.addRenderableWidget(configButton);
    this.addRenderableWidget(openModsFolderButton);
    search.setFocus(false);
    search.setCanLoseFocus(true);
    configButton.active = false;
    final int width = listWidth / numButtons;
    int x = PADDING;
    addRenderableWidget(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL)));
    x += width + buttonMargin;
    addRenderableWidget(SortType.A_TO_Z.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z)));
    x += width + buttonMargin;
    addRenderableWidget(SortType.Z_TO_A.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A)));
    resortMods(SortType.NORMAL);
    updateCache();
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) Font(net.minecraft.client.gui.Font) ObjectSelectionList(net.minecraft.client.gui.components.ObjectSelectionList) Pair(org.apache.commons.lang3.tuple.Pair) ComparableVersion(org.apache.maven.artifact.versioning.ComparableVersion) PathResourcePack(net.minecraftforge.resource.PathResourcePack) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) FMLPaths(net.minecraftforge.fml.loading.FMLPaths) Screen(net.minecraft.client.gui.screens.Screen) ModList(net.minecraftforge.fml.ModList) IModInfo(net.minecraftforge.forgespi.language.IModInfo) Collectors(java.util.stream.Collectors) Language(net.minecraft.locale.Language) Style(net.minecraft.network.chat.Style) List(java.util.List) Util(net.minecraft.Util) Logger(org.apache.logging.log4j.Logger) EditBox(net.minecraft.client.gui.components.EditBox) Entry(java.util.Map.Entry) FormattedCharSequence(net.minecraft.util.FormattedCharSequence) ForgeI18n(net.minecraftforge.common.ForgeI18n) Size2i(net.minecraftforge.common.util.Size2i) DynamicTexture(net.minecraft.client.renderer.texture.DynamicTexture) ForgeHooks(net.minecraftforge.common.ForgeHooks) ModContainer(net.minecraftforge.fml.ModContainer) Function(java.util.function.Function) ArrayList(java.util.ArrayList) PoseStack(com.mojang.blaze3d.vertex.PoseStack) Minecraft(net.minecraft.client.Minecraft) MavenVersionStringHelper(net.minecraftforge.common.util.MavenVersionStringHelper) NativeImage(com.mojang.blaze3d.platform.NativeImage) Button(net.minecraft.client.gui.components.Button) StringUtils(net.minecraftforge.fml.loading.StringUtils) GameRenderer(net.minecraft.client.renderer.GameRenderer) ResourcePackLoader(net.minecraftforge.resource.ResourcePackLoader) Component(net.minecraft.network.chat.Component) NarrationElementOutput(net.minecraft.client.gui.narration.NarrationElementOutput) IOException(java.io.IOException) TextureManager(net.minecraft.client.renderer.texture.TextureManager) Consumer(java.util.function.Consumer) Tesselator(com.mojang.blaze3d.vertex.Tesselator) VersionChecker(net.minecraftforge.fml.VersionChecker) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) ModListWidget(net.minecraftforge.client.gui.widget.ModListWidget) Comparator(java.util.Comparator) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) ConfigGuiHandler(net.minecraftforge.client.ConfigGuiHandler) InputStream(java.io.InputStream) IModInfo(net.minecraftforge.forgespi.language.IModInfo) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Button(net.minecraft.client.gui.components.Button) EditBox(net.minecraft.client.gui.components.EditBox) ModListWidget(net.minecraftforge.client.gui.widget.ModListWidget)

Example 9 with TranslatableComponent

use of net.minecraft.network.chat.TranslatableComponent in project MinecraftForge by MinecraftForge.

the class ChunkGenWorker method doWork.

@Override
public boolean doWork() {
    /* TODO: Check how many things are pending save, and slow down world gen if to many
        AnvilChunkLoader loader = dim.getChunkProvider().chunkLoader instanceof AnvilChunkLoader ? (AnvilChunkLoader)world.getChunkProvider().chunkLoader : null;
        if (loader != null && loader.getPendingSaveCount() > 100)
        {

            if (lastNotifcationTime < System.currentTimeMillis() - 10*1000)
            {
                listener.sendFeedback(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true);
                lastNotifcationTime = System.currentTimeMillis();
            }
            return false;
        }
        */
    BlockPos next = queue.poll();
    if (next != null) {
        if (++lastNotification >= notificationFrequency || lastNotifcationTime < System.currentTimeMillis() - 60 * 1000) {
            listener.sendSuccess(new TranslatableComponent("commands.forge.gen.progress", total - queue.size(), total), true);
            lastNotification = 0;
            lastNotifcationTime = System.currentTimeMillis();
        }
        int x = next.getX();
        int z = next.getZ();
        if (!dim.hasChunk(x, z)) {
            // Chunk is unloaded
            ChunkAccess chunk = dim.getChunk(x, z, ChunkStatus.EMPTY, true);
            if (!chunk.getStatus().isOrAfter(ChunkStatus.FULL)) {
                chunk = dim.getChunk(x, z, ChunkStatus.FULL);
                // There isn't a way to check if the chunk is actually created just if it was loaded
                genned++;
            }
        }
    }
    if (queue.size() == 0) {
        listener.sendSuccess(new TranslatableComponent("commands.forge.gen.complete", genned, total, dim.dimension().location()), true);
        /* TODO: Readd if/when we introduce world unloading, or get Mojang to do it.
            if (keepingLoaded != null && !keepingLoaded)
                DimensionManager.keepLoaded(dim, false);
            */
        return false;
    }
    return true;
}
Also used : ChunkAccess(net.minecraft.world.level.chunk.ChunkAccess) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) BlockPos(net.minecraft.core.BlockPos)

Aggregations

TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)9 Component (net.minecraft.network.chat.Component)3 TextComponent (net.minecraft.network.chat.TextComponent)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 Collectors (java.util.stream.Collectors)2 ResourceLocation (net.minecraft.resources.ResourceLocation)2 ServerLevel (net.minecraft.server.level.ServerLevel)2 DimensionType (net.minecraft.world.level.dimension.DimensionType)2 IModInfo (net.minecraftforge.forgespi.language.IModInfo)2 PathResourcePack (net.minecraftforge.resource.PathResourcePack)2 NativeImage (com.mojang.blaze3d.platform.NativeImage)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 PoseStack (com.mojang.blaze3d.vertex.PoseStack)1 Tesselator (com.mojang.blaze3d.vertex.Tesselator)1 ArgumentBuilder (com.mojang.brigadier.builder.ArgumentBuilder)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1