Texture of block changes when it has items in it

Started by DerpBurger123 on

Topic category: Help with modding (Java Edition)

Last seen on 22:01, 18. Apr 2023
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Texture of block changes when it has items in it

I am making a block that works similarly to a brewing stand. I want to have the texture/model of the block change when there are items in it (similar to how the brewing stand changes texture when there are bottles/potions in it). How would I go about doing this?

Last seen on 05:56, 4. May 2024
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think the only good way to…
Wed, 04/05/2023 - 16:07

I think the only good way to do this right now is to duplicate the block and name it "(your_thing)_filled" or something like that. 
Then make a procedure for your block on the 'on block update' trigger, and check if any slots don't contain air. And if one does contain air, replace the block with your _filled block and keep state and NBT. then duplicate your other block's procedure so when the block updates it checks if all of the slots contain air, and if they do. replace the block with the original.
It's kind of hard to follow and a bit tedious to set up but it should work.

Last seen on 05:56, 4. May 2024
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I meant 'if one does not…
Wed, 04/05/2023 - 16:09

I meant 'if one does not contain air' on the 4th line

Last seen on 22:01, 18. Apr 2023
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks, this worked! For…
Sun, 04/09/2023 - 22:22

Thanks, this worked!

For anyone else who might be having trouble doing it, set the tick rate of the block to 1. Duplicate and make the filled block with all the same properties, EXCEPT change the drop and creative pick item to the regular (not filled) block and remove it from the creative tab.

Then make a procedure that checks if 1. the block is the empty one and 2. the number of items in any slot is not 0, in which case it replaces with the filled block with keep state and NBT. Make a separate check (in the same procedure) that checks if 1. the block is the filled one and 2.all the slots have 0 items, in which case replace the block with the empty one. Then make a new procedure whose only purpose is to call the previously mentioned procedure, and set this call procedure to both blocks' update tick (for some reason it is necessary to have a second procedure the calls the first one, you can't just set on update tick to the first procedure).