Jump to content

Recommended Posts

Posted

I have a "generator" block that has an "active" state. I have 4 textures for the front of the block:

  • generator_front
  • generator_front_active1
  • generator_front_active2
  • generator_front_active3

When the generator is "active", I want the front of it to randomly switch between the 3 active textures (for a fire-effect). What is the best way to do this?

 

I tried adding an "active" property to the block class, and ended up with this as my .json model file:

 

{
    "variants": {
        "active=0,facing=east": { "model": “generator_front” },
        "active=0,facing=south": { "model": "generator_front", "y": 90 },
        "active=0,facing=west": { "model": "generator_front", "y": 180 },
        "active=0,facing=north": { "model": "generator_front", "y": 270 },
        "active=1,facing=east": { "model": "generator_front_active1” },
        "active=1,facing=south": { "model": "generator_front_active1”, "y": 90 },
        "active=1,facing=west": { "model": "generator_front_active1”, "y": 180 },
        "active=1,facing=north": { "model": "generator_front_active1”, "y": 270 },
        "active=2,facing=east": { "model": "generator_front_active2” },
        "active=2,facing=south": { "model": "generator_front_active2”, "y": 90 },
        "active=2,facing=west": { "model": "generator_front_active2”, "y": 180 },
        "active=2,facing=north": { "model": "generator_front_active2”, "y": 270 },
        "active=3,facing=east": { "model": "generator_front_active3” },
        "active=3,facing=south": { "model": "generator_front_active3”, "y": 90 },
        "active=3,facing=west": { "model": "generator_front_active3”, "y": 180 },
        "active=3,facing=north": { "model": "generator_front_active3”, "y": 270 }
    }
}

 

I also tried changing the "active" value in the random display tick method, but i got this weird problem where I would only see the block change textures 1 state at a time if I placed/broke a block nearby.

 

What is the right way to do this?

Posted

Are you trying to randomly select a model/texture to make each block "unique", or do you want programmatic control of the texture?

 

Minecraft's model system allows you to designate several models for 1 property definition line, and it will randomly pick a model using seeded ranomization, with the seed being fetched from the coordinates. This page has a little run-down of it.

 

 

So to sum it up, when the game looks for models, it looks for JSON objects (denoted by curly brackets), but it also looks for a JSON array (denoted by square brackets) of these JSON objects.

 

So rather than

"on=true": {"model":"mymodel"}

You can do

"on=true": [{"model":"mymodel"}, {"model":"mymodel2"}, {"model":"mymodel3"}]

Posted

Are you after an animated texture while your generator is active?

 

I have not yet made my animated textures so I can't verify if this works yet. But...

I made my animated textures and this works perfectly

 

Block and item textures support animation by placing each additional frame below the last. The animation is then controlled using using a .mcmeta file in JSON format with the same name in the same directory. For example, the .mcmeta file for stone.png would be stone.png.mcmeta.

(source: http://minecraft.gamepedia.com/Resource_pack)

 

So in your case you'd make a new texture "generator_front_active.png" that is the same width as the ones you have now but is three times as tall that contains your original three.

 

next make a text file named "generator_front_active.png.mcmeta", with the following code:

{
    "animation": {
        "frametime": 2,
        "frames": [
            0,
            1,
            2,
            1
        ]
    }
}

 

You would no longer need the multiple active states a boolean would do.

while active=false you use the static "generator_front", and when active=true you use the animated "generator_front_active"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.