KubeJS GT Dynamic Render

Quick rating

KubeJS GT Dynamic Render

No reviews yet

Addon for adding GregTech CEu Modern renderers with KubeJS

Industrial
No Genre
GregTech
Mod Addon
Mod Loaders
Forge
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

About

Project Details

Type
Mod
Latest Version
kubejs_gtrender-0.2.2.jar
Authors

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID

Resources

External Links

Source Issues Wiki Discord

About

Description

Wouldn't you like to add cool rendering to GregTech CEu Modern? But that requires Java? Don't worry! This mod solves that.
 
We only support 1.20.1 Forge because that's where GTCEu is.
 
Example: 
in startup_scripts: 
GTRenderJSEvents.registerModelsForRender(event => {
    event.register("kubejs:obj/space");
    event.register("kubejs:obj/star");
    event.register("kubejs:obj/foo");
    event.register("kubejs:obj/bar");
    event.register("kubejs:obj/baz");
});
These obj files should be placed in /assets/kubejs/models.
 

in startup_scripts (gregtech multiblockmachine registry)

// before
.workableCasingModel(
            "gtceu:block/casings/solid/machine_casing_stable_titanium",
            "gtceu:block/multiblock/implosion_compressor"
        );
// You will use this instead of that.
// after
.model(
            GTMachineModels.createWorkableCasingMachineModel(
                "gtceu:block/casings/solid/machine_casing_stable_titanium",
                 "gtceu:block/multiblock/implosion_compressor"
            )["andThen(java.util.function.Consumer)"](b =>
                b.addDynamicRenderer(() => KubeJSDynamicRender.of("kubejs:example"))
            )
        );

in client_scripts

const OverlayTexture = Java.loadClass("net.minecraft.client.renderer.texture.OverlayTexture");
const RenderType = Java.loadClass("net.minecraft.client.renderer.RenderType");
const LightTexture = Java.loadClass("net.minecraft.client.renderer.LightTexture");

GTRenderJSEvents.registerDynamicRender(event => {
    event.create(
        "kubejs:example",
        /**
         *@param {Internal.RenderBuilder<Internal.WorkableElectricMultiblockMachine,{ someValue:string }>} builder
         */
        builder => {
            // default: raw => raw
            // By using this API, you can utilize arguments with type safety and default values.
            // The result of this function is cached.
            builder.prepareBindings(raw => {
                return {
                    someValue: raw.someValue || "default value",
                };
            });

            builder.render(ctx => {
                // you can use bindings here
                console.log(ctx.binding.someValue);
                // const light = ctx.packedLight;
                // const overlay = ctx.packedOverlay;
                const machine = ctx.machine;
                const poseStack = ctx.poseStack;
                const buffer = ctx.buffer;
                var tick = machine.getOffsetTimer() + ctx.partialTick;
                // offsets
                var x = 0.5,
                    y = 0.5,
                    z = 0.5;
                switch (machine.getFrontFacing()) {
                    case Direction.NORTH:
                        z = 16.5;
                        break;
                    case Direction.SOUTH:
                        z = -15.5;
                        break;
                    case Direction.WEST:
                        x = 16.5;
                        break;
                    case Direction.EAST:
                        x = -15.5;
                        break;
                }
                poseStack.pushPose();
                poseStack.translate(x, y, z);
                renderOuterSpaceShell(poseStack, buffer.getBuffer(RenderType.solid()));
                poseStack.popPose();
            });
            const shouldRender = machine => machine.isFormed();

            builder
                .viewDistance(256)
                .shouldRender(shouldRender)
                .shouldRenderOffScreen(shouldRender)
                .renderBoundingBox(() => {
                    // todo ちゃんとやる
                    const rad = 32;
                    return AABB.of(-rad, -rad, -rad, rad, rad, rad);
                });
        }
    );
});
/**
 * @param {Internal.PoseStack} poseStack
 * @param {Internal.MultiBufferSource} buffer
 * @param {number} scale
 */
function renderOuterSpaceShell(poseStack, buffer) {
    const scale = 0.01 * 17.5;
    poseStack.pushPose();
    poseStack.scale(scale, scale, scale);
    const rt = RenderType.solid();
    BakedModelRenderer.renderModel(poseStack.last(), buffer.getBuffer(rt), getBakedModel("kubejs:obj/space"), rt);
    poseStack.popPose();
}

/**
 * @param {ResourceLocation_} id
 */
function getBakedModel(id) {
    // In the context of KubeJS, Client = Minecraft.getInstance()
    return Client.getModelManager().getModel(id);
}

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

~7,000
Downloads
Last Updated
Created
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works