Search in sources :

Example 1 with Init

use of meteordevelopment.meteorclient.utils.Init in project meteor-client by MeteorDevelopment.

the class Fonts method load.

@Init(stage = InitStage.Post)
public static void load() {
    if (lastFont.equals(Config.get().font.get()))
        return;
    File file = new File(FOLDER, Config.get().font + ".ttf");
    if (!file.exists()) {
        Config.get().font.set(DEFAULT_FONT);
        file = new File(FOLDER, Config.get().font + ".ttf");
    }
    try {
        CUSTOM_FONT = new CustomTextRenderer(file);
    } catch (Exception ignored) {
        Config.get().font.set(DEFAULT_FONT);
        file = new File(FOLDER, Config.get().font + ".ttf");
        CUSTOM_FONT = new CustomTextRenderer(file);
    }
    if (mc.currentScreen instanceof WidgetScreen && Config.get().customFont.get()) {
        ((WidgetScreen) mc.currentScreen).invalidate();
    }
    lastFont = Config.get().font.get();
}
Also used : CustomTextRenderer(meteordevelopment.meteorclient.renderer.text.CustomTextRenderer) WidgetScreen(meteordevelopment.meteorclient.gui.WidgetScreen) File(java.io.File) Init(meteordevelopment.meteorclient.utils.Init)

Example 2 with Init

use of meteordevelopment.meteorclient.utils.Init in project meteor-client by MeteorDevelopment.

the class Fonts method init.

@Init(stage = InitStage.Pre)
public static void init() {
    FOLDER.mkdirs();
    // Copy built in fonts if they not exist
    for (String font : BUILTIN_FONTS) {
        File file = new File(FOLDER, font);
        if (!file.exists()) {
            StreamUtils.copy(Fonts.class.getResourceAsStream("/assets/" + MeteorClient.MOD_ID + "/fonts/" + font), file);
        }
    }
    // Load default font
    CUSTOM_FONT = new CustomTextRenderer(new File(FOLDER, DEFAULT_FONT + ".ttf"));
    lastFont = DEFAULT_FONT;
}
Also used : CustomTextRenderer(meteordevelopment.meteorclient.renderer.text.CustomTextRenderer) File(java.io.File) Init(meteordevelopment.meteorclient.utils.Init)

Example 3 with Init

use of meteordevelopment.meteorclient.utils.Init in project meteor-client by MeteorDevelopment.

the class AddonManager method init.

@Init(stage = InitStage.Pre)
public static void init() {
    // Meteor pseudo addon
    {
        METEOR = new MeteorAddon() {

            @Override
            public void onInitialize() {
            }
        };
        ModMetadata metadata = FabricLoader.getInstance().getModContainer("meteor-client").get().getMetadata();
        METEOR.name = metadata.getName();
        METEOR.authors = new String[metadata.getAuthors().size()];
        if (metadata.containsCustomValue("meteor-client:color"))
            METEOR.color.parse(metadata.getCustomValue("meteor-client:color").getAsString());
        int i = 0;
        for (Person author : metadata.getAuthors()) {
            METEOR.authors[i++] = author.getName();
        }
    }
    // Addons
    for (EntrypointContainer<MeteorAddon> entrypoint : FabricLoader.getInstance().getEntrypointContainers("meteor", MeteorAddon.class)) {
        ModMetadata metadata = entrypoint.getProvider().getMetadata();
        MeteorAddon addon = entrypoint.getEntrypoint();
        addon.name = metadata.getName();
        addon.authors = new String[metadata.getAuthors().size()];
        if (metadata.containsCustomValue("meteor-client:color"))
            addon.color.parse(metadata.getCustomValue("meteor-client:color").getAsString());
        int i = 0;
        for (Person author : metadata.getAuthors()) {
            addon.authors[i++] = author.getName();
        }
        ADDONS.add(addon);
    }
}
Also used : ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) Person(net.fabricmc.loader.api.metadata.Person) Init(meteordevelopment.meteorclient.utils.Init)

Example 4 with Init

use of meteordevelopment.meteorclient.utils.Init in project meteor-client by MeteorDevelopment.

the class MeteorClient method reflectInit.

private static void reflectInit(Method task, InitStage initStage, Set<Method> left, Map<Class<?>, List<Method>> byClass) {
    left.remove(task);
    Init init = task.getAnnotation(Init.class);
    if (!init.stage().equals(initStage))
        return;
    for (Class<?> clazz : init.dependencies()) {
        for (Method m : byClass.getOrDefault(clazz, Collections.emptyList())) {
            if (left.contains(m)) {
                reflectInit(m, initStage, left, byClass);
            }
        }
    }
    try {
        task.invoke(null);
    } catch (IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
    }
}
Also used : Init(meteordevelopment.meteorclient.utils.Init) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 5 with Init

use of meteordevelopment.meteorclient.utils.Init in project meteor-client by MeteorDevelopment.

the class EntityShaders method initOutlines.

// Outlines
@Init(stage = InitStage.Pre)
public static void initOutlines() {
    outlinesShader = new Shader("outline.vert", "outline.frag");
    outlinesFramebuffer = new SimpleFramebuffer(mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight(), false, false);
    outlinesVertexConsumerProvider = new OutlineVertexConsumerProvider(mc.getBufferBuilders().getEntityVertexConsumers());
}
Also used : OutlineVertexConsumerProvider(net.minecraft.client.render.OutlineVertexConsumerProvider) Shader(meteordevelopment.meteorclient.renderer.Shader) SimpleFramebuffer(net.minecraft.client.gl.SimpleFramebuffer) Init(meteordevelopment.meteorclient.utils.Init)

Aggregations

Init (meteordevelopment.meteorclient.utils.Init)5 File (java.io.File)2 CustomTextRenderer (meteordevelopment.meteorclient.renderer.text.CustomTextRenderer)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 WidgetScreen (meteordevelopment.meteorclient.gui.WidgetScreen)1 Shader (meteordevelopment.meteorclient.renderer.Shader)1 ModMetadata (net.fabricmc.loader.api.metadata.ModMetadata)1 Person (net.fabricmc.loader.api.metadata.Person)1 SimpleFramebuffer (net.minecraft.client.gl.SimpleFramebuffer)1 OutlineVertexConsumerProvider (net.minecraft.client.render.OutlineVertexConsumerProvider)1