jmc2obj / j-mc-2-obj

Java-based Minecraft-to-OBJ exporter.
http://www.jmc2obj.net
352 stars 59 forks source link

Assigning conditions and materials to modded blocks? #182

Closed PixusPanic closed 2 years ago

PixusPanic commented 2 years ago

Hello! This is a quick question relating to modded block configurations, and that's if it's possible to add various conditions to them (like if a block has a boolean "powered", it can change its mesh or material or so on depending on if it's true or false) and if it's possible to also add more than one material to a mesh (like if a mesh has different material attributions, such as a material named "m_1" and another named "m_2" and when m_1 is assigned to "oak_planks" and m_2 is assigned to "stone", it would give m_1 the oak_planks texture and m_2 the stone texture respectively).

For some context, I'm seeing if I can add the belts and belt related items from Create into my modded configuration and try to export them and, while I've gotten the program to read and place down a custom-made mesh of Andesite Funnels in their retracted state, it erroneously gives it the wrong texture; this is probably since I put the wrong materials down and/or it doesn't read anything beyond the first one.

For reference, here's my config file for it: https://pastebin.com/q5kLDekc

Thanks again for working on this wonderful program!

mmdanggg2 commented 2 years ago

Yes, you should be able to do this. You can have multiple objects in the obj and pick them with a # after the obj file. Might be worth having a look at how some of the models were done before I switched to using the resource pack models. Using the jmc_material attribute you can override the material on that obj object:

<block id="minecraft:potted_oak_sapling" name="Potted Oak Sapling">
  <model>Mesh</model>
  <mesh>
    <mesh>models/flowerpot.obj#base</mesh>
    <mesh jmc_material="block/oak_sapling">models/flowerpot.obj#cross</mesh>
  </mesh>
  <occlusion>none</occlusion>
</block>

And each mesh tag can be conditional with block data like with the ender eyes:

<block id="minecraft:end_portal_frame" name="End Portal Frame">
  <model>Mesh</model>
  <mesh>
    <mesh facing="north">
      <rotate const="y" value="0">
        <mesh>models/endportal_frame.obj#base</mesh>
        <mesh eye="true">models/endportal_frame.obj#eye</mesh>
      </rotate>
    </mesh>
    <mesh facing="south">
      <rotate const="y" value="180">
        <mesh>models/endportal_frame.obj#base</mesh>
        <mesh eye="true">models/endportal_frame.obj#eye</mesh>
      </rotate>
    </mesh>
    <mesh facing="west">
      <rotate const="y" value="90">
        <mesh>models/endportal_frame.obj#base</mesh>
        <mesh eye="true">models/endportal_frame.obj#eye</mesh>
      </rotate>
    </mesh>
    <mesh facing="east">
      <rotate const="y" value="-90">
        <mesh>models/endportal_frame.obj#base</mesh>
        <mesh eye="true">models/endportal_frame.obj#eye</mesh>
      </rotate>
    </mesh>      
  </mesh>
  <occlusion>none</occlusion>
</block>