How do I make a cauldron change state when an item is used on it?

Started by BouncingPiplup on

Topic category: Help with modding (Java Edition)

Last seen on 03:51, 5. Sep 2024
Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make a cauldron change state when an item is used on it?
Wed, 09/04/2024 - 02:23 (edited)

I'm making a chemistry-based mod, and I'm trying to make it so that, when used on a non-empty water cauldron, a (stackable) empty beaker item is replaced with a (stackable) water beaker and deplete the cauldron's water level by one (basically identically to how vanilla water bottles work, except that since the water beaker item is also stackable, the result would need to go into the first non-full stack). I can't find any tutorials that are seemingly up to date, and I haven't been able to figure it out on my own.

Basically, I want it to function as follows:

  1. Player clicks on non-empty Water Cauldron with Empty Beaker
  2. One Empty Beaker from the player's main hand gets replaced with a Beaker of Water, which goes into the first unfilled stack (or into the main hand if it's the last empty beaker in the stack and there is no unfilled stack available)
  3. The Water Cauldron's water level is depleted by 1

How would I make a RightClickedOnBlock procedure to make this function? Any help would be appreciated.

Edited by BouncingPiplup on Wed, 09/04/2024 - 02:23
Last seen on 03:51, 5. Sep 2024
Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Upon further testing, I…
Sun, 09/01/2024 - 17:00

Upon further testing, I somehow got it to partially work without realizing it. The beaker gets converted correctly, but the cauldron still doesn't get depleted.

Last seen on 03:51, 5. Sep 2024
Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've also noticed that if…
Sun, 09/01/2024 - 18:13

I've also noticed that if there is no stack available yet, and the empty beaker isn't in the first available slot of the hotbar, the resulting water beaker won't be in the main hand like intended.

My current code looks like this