Minecraft – How to add animation to textures

minecraft-java-edition

Recently, I saw the best map ever, and it had a menu identical to the main minecraft menu, and I'm trying to replicate it. I believe I have found a way, but it requires more knowledge than the internet is willing to offer. I need the 'pumpkinblur' texture to:
1. Have multiple possible textures, and
2. Change between these textures based on where I am looking (similar to the rx, rxm, ry, and rym arguments)
also, why is there no minecraft-resourcepacks/ minecraft-textures tag?

Best Answer

I need the 'pumpkinblur' texture to: 1. Have multiple possible texture

There is no way, in vanilla Minecraft, to have the pumpkinblur texture have multiple frames. You can animate the texture of blocks and items, but not the more irregular textures like paintings, GUI elements, etc..


How to add animation to textures

The basis of animating a block/item is that each frame should be below the previous one vertically. The width of the image is taken as the height of each frame (16px here):

enter image description here

Then, a file with the same name as the texture you're animating (including the .png), but with .mcmeta on the end, must exist in the same directory as this texture.

To have the animation play (at 20FPS) all that you'll need to do is open up the .mcmeta file with a text editor, and add the following:

{ "animation": { } }

There's a fair bit that you can do with animated textures, such as interpolation ("fading") and changing frame order, so you may want to look at the wiki page on it or a tutorial.



Change between these textures based on where I am looking (similar to the rx, rxm, ry, and rym arguments)

You cannot change between frames of the same texture based on rotation, but you could change an item's data value or switch to a different item (this doesn't work with pumpkinblur) that has a different texture. For example, replacing the player's first hotbar slot with a hoe with a certain damage value if they look upwards:

/replaceitem entity @a[rxm=-90] slot.hotbar.0 diamond_hoe 1 25

This is likely how the menu you saw worked, giving different items or data values different menu textures, changing the item's model rotation so that they face the player when held, and then changing what item the player is holding based off of their rotation.

Could also be teleporting a mob with the item on its head to where the player is facing, or just constantly teleporting a player so that they look at a textured changing block, I can't really tell without knowing what the map is.