Skip to content
TheChatArchiveThe Chat Archive
Metallama-4-maverick-03-26-experimental· MetaHugging Face LMArena Human Preference 140K

In GregTech Modern with kubejs, how can I create a multiblock that renders a obj file…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-opus-4-20250514’s answer.
  1. User

    In GregTech Modern with kubejs, how can I create a multiblock that renders a obj file once active, and where do I place the obj file and it's correlated coloration file? Would you like to see my code for the multiblock?

  2. Meta Assistant

    A GregTech Modern question with KubeJS! Sounds like a challenge!

    Yes, I'd love to help you with that. Rendering a custom OBJ model for a multiblock in GregTech Modern with KubeJS is totally doable. I'll guide you through the steps.

    Prerequisites:

    1. You have GregTech Modern installed with KubeJS ( obviously )
    2. You're familiar with KubeJS scripting (JavaScript)
    3. You have an OBJ file (and its associated MTL file for coloration/textures) ready

    Step 1: Prepare your OBJ and MTL files

    Place your OBJ file (your_model.obj) and its associated MTL file (your_model.mtl) in the following directory:

    assets/your_mod_id/models/multiblock/your_model.obj assets/your_mod_id/models/multiblock/your_model.mtl

    Replace your_mod_id with the actual ID of your mod (e.g., kubejs, gregtech, or a custom mod ID you've created). If the multiblock folder doesn't exist, create it.

    Important: Make sure your OBJ file uses the MTL file for material definitions (coloration, textures). In your OBJ file, there should be a line like: mtllib your_model.mtl

    Step 2: Register the model in KubeJS

    Create a new KubeJS script (e.g., multiblock_models.js) in your kubejs/assets/kubejs/models directory (create the folders if they don't exist).

    In this script, add the following code:

    // multiblock_models.js
    StartupEvents.registry('block', event => {
      event.registerModel('your_model', 'your_mod_id:multiblock/your_model.obj')
    })
    

    Here:

    • your_model is the registry name for your model (choose a unique name).
    • your_mod_id:multiblock/your_model.obj is the resource location pointing to your OBJ file.

    Step 3: Create the Multiblock in KubeJS

    Now, let's create the multiblock. Please YES, share your current multiblock code, and I'll help you modify it to render the OBJ model when active. If you don't have any code yet, here's a minimal example to get started:

    // your_multiblock.js
    GTCEuStartupEvents.registry('gtceu:machine', event => {
      event.create('your_multiblock', 'multiblock')
        .rotationState(RotationState.NON_Y_AXIS)
        .shape([
          // Define your multiblock shape here (e.g., 3x3x3 cube)
          [0, 0, 0, 0, 0, 0],
          [0, 1, 1, 1, 1, 0],
          [0, 1, 1, 1, 1, 0],
          [0, 1, 1, 1, 1, 0],
          [0, 0, 0, 0, 0, 0]
        ])
        .controller()
        .patternDefinition((controller, tile) => {
          // Define your pattern logic here (e.g., casing, glass, coils, etc.)
          // For now, just return true to make the multiblock form
          return true
        })
        .additionalDisplay((controller, components) => {
          // **We'll add the OBJ rendering here later**
        })
        .build();
    })
    

    Step 4: Render the OBJ model when active

    Modify the additionalDisplay method in your multiblock code (from Step 3) to render the OBJ model:

    .additionalDisplay((controller, components) => {
      if (controller.isFormed()) { // Only render when the multiblock is active/formed
        components.addRenderLayer((matrix, buffer) -> {
          // Render our custom OBJ model
          matrix.pushPose();
          matrix.translate(0.5, 0, 0.5); // Center the model (adjust as needed)
          matrix.scale(1, 1, 1); // Scale (if needed)
          // Use our registered model from Step 2
          event.renderModel('your_model', matrix, buffer);
          matrix.popPose();
        });
      }
    })
    

    Here:

    • We check if the multiblock is formed (isFormed()).
    • We add a custom render layer using addRenderLayer.
    • Inside the render layer, we:
      1. Push the matrix pose (save the current transformation).
      2. Translate (move) the model to the desired position (centered in this example).
      3. Scale the model (if needed).
      4. Render the model using event.renderModel, passing the registry name (your_model) from Step 2.
      5. Pop the matrix pose (restore the previous transformation).

    That's it! With these steps:

    1. Your OBJ and MTL files are in the correct directory.
    2. You've registered the model in KubeJS (multiblock_models.js).
    3. You've created/modified your multiblock code to render the OBJ model when active.

    Reload your game (or use /reload command) and form your multiblock. The OBJ model should now render when the multiblock is active!

    Please share your multiblock code, and I'll help with any adjustments or issues you might encounter.

    Happy GregTech-ing!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.