Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

Just a guess here:

 

Try using

getActualState(IBlockState, IBlockAccess, BlockPos){}

 

And then using a value in the tile entity to cycle.

I think its my java of the variables.

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"}]

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.