Jump to content

[SOLVED][1.10.2] Rendering Block's Animated Texture


Furgl

Recommended Posts

Hello,

 

I'm working on a mod with armor that uses the textures of certain blocks in the game. Currently I can get a block's quads, the quad's respective TextureAtlasSprite, and the sprite's icon name to get the texture location which works perfectly for most blocks. For blocks with animations (Prismarine, Magma, etc.) the only way I've managed to replicate the animation is to use reflection to access the sprite's frameCounter field and change the texture coordinates that I'm rendering the texture with to render the right texture at the right time. Unfortunately, this doesn't look to great as the textures don't change gradually as they animate.

 

Here's an example of it using the Prismarine texture (compared to actual Prismarine next to it):

 

3c2d8e858f0df5c03b25bd50982ba1ca.gif

 

 

Does anyone know of a way that I can render a block's animated texture (probably using its TextureAtlasSprite/BakedQuads)?

 

Link to comment
Share on other sites

I have a recommendation not sure if it is what you are looking for or not, but here goes. Instead of switching between textures, you could use them both, but apply the layers with transparency and have your own "counter" that determines when it changes like every time it renders decrease the transparency of the current overlay?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Instead of switching between textures, you could use them both, but apply the layers with transparency and have your own "counter" that determines when it changes like every time it renders decrease the transparency of the current overlay?

That's a really good idea, I'll try that later today.

The mod maker MCreator can make animated textures. Generate a mod with animated textures in MCreator and then look at how it is done, then replicate that in your own code.

I understand how to make animated textures with normal blocks or items, but that's not what I'm doing; I'm trying to render existing blocks' animated textures on armor.

Link to comment
Share on other sites

you can try to use some of the code from animated textures of blocks

 

Considering that's where he started....no, no he can't.

Block and item textures are animated with vanilla internals (there's no mod-based code involved) and his attempts to latch onto that system hasn't resulted in a clean result.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh. Sorry, I didn't understand what you were trying to do right away. MCreator can't do animated armor textures, but you can try to use some of the code from animated textures of blocks and items for your armor. I can't be sure tough because I have never made animated textures, even if I want to do them, but I have not been able to find a decent tutorial on doing that...

For blocks, animated textures are essentially different "frames" for the animation stacked on top of each other for the texture (see prismarine_rough.png). Blocks that have animated textures need a .mcmeta file that describes the animation: time between frames, interpolation, order of frames, etc. (see prismarine_rough.png.mcmeta). I can render the appropriate frame of the animation, but as I show in the gif in my first post, I don't know how to mimic the blending between frames that MC does for animated textures. AnimeFan8888's suggestion may work, I'll test it when I have more time later.

Link to comment
Share on other sites

Instead of switching between textures, you could use them both, but apply the layers with transparency and have your own "counter" that determines when it changes like every time it renders decrease the transparency of the current overlay?

This took a fair amount of time, but it worked! Thank you!

 

For anyone else doing something similar or wondering how I did it:

  • I got the AnimationMetadataSection from the TextureAtlasSprite via reflection
  • I calculate the current frame and amount between the current frame, and next frame to use as alpha, each tick using the AnimationMetadataSection
  • I have my model create pieces using the texture coords for the current frame and for the next frame
  • When my model renders, it renders the current frame's pieces and then renders the next frame's pieces, on top, with the alpha

  • Like 1
Link to comment
Share on other sites

I made a block with a custom block model and texture and literally copied exactly what was in prismarine_rough and the mcmeta file and the texture and got a perfect animation.

You made it for a block, which already has the standard animation with mcmeta files. He did it for armor, which doesn't have that, so he had to do it himself.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

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.