Jump to content

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


Recommended Posts

Posted

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)?

 

Posted

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.

Posted

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.

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

Posted

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.

Posted

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
Posted

U really didn't have to go through any of that.

 

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.

Posted

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/

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Also check the worldsave / serverconfig folder If there is no such file, make a test without this mod  
    • Hi, I've been having trouble trying to use forge as it shows a black screen when I open the game, but I can still interact with it and hear the music.  I've done all of the step by steps and most common fixes like updating drivers, keeping up to date with Java, deleting and reinstalling minecraft, restarting my computer MANY times, even smaller things like splash.properties (I didn't have that file so I added it and set it to false thinking it would do something, definitely not) and making sure to prioritize my rtx 3070 in the settings but with no luck. Minecraft works as intended when I uninstall forge and I also don't have any mods currently, it just gives me this issue when I install forge. I also increased the ram usage, made sure my hardware isn't full or anything, and even changed the resolution in hopes it would fix things. I checked my antivirus and firewall but that isn't the issue either. Trust me, I've done everything I can think of. For some reason the black screen does flicker a little into the main menu, but obviously unplayable. I couldn't even make my way to the settings with how little it flickered. I'm not sure if it flickered randomly or if it was because I was messing around moving and clicking a bunch, I didn't really test it that much.  
    • I've had a really weird issue recently,  I wanted to add the Depper and Darker mod on my dedicated server (MC 1.21 with Fabric 0.16.9, hosted on nitroserv.com) but whenever I do add the mod the sever stops doing anything after listing the mods, and I get no crash or error or anything, just a stuck server. Here's a normal log of the server booting up: https://pastebin.com/JipFF2Eh and here's the log of the server doing the weird thing: https://pastebin.com/W4JBh3eX I just don't understand it. I've tried removing other mods (somewhat randomly) but deeper and darker still breaks my server whenever I add it. NitroServ support staff is about as confused as I am and I've had no response from the Deeper and Darker support staff... Now I know this is the Forge support not the Fabric support but I'm just trying to know if anyone has any kind of idea to fix this (aside from not using the mod obviously) Also I still have a bunch of errors and warnings whenever the server does start properly, are there any of them I should be worried about?
  • Topics

×
×
  • Create New...

Important Information

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