[TUTORIAL] How to use cauldrons in procedures (1.12 and 1.14)

Started by SomeoneElse on Fri, 10/25/2019 - 18:27

Topic category: User side tutorials

Last seen on 16:09, 23. Sep 2021
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
[TUTORIAL] How to use cauldrons in procedures (1.12 and 1.14)
Tue, 02/04/2020 - 18:26 (edited)

This tutorial will explain how to edit the water level of a cauldron, for example to clean items or to make machines that use cauldrons. It does require some custom code, but you can just copy-paste the one from this tutorial. At the end of the tutorial, you can find some template procedures which you can download.


How do cauldrons work?

Blockstates are extra info stored by some blocks, such as the block's rotation, whether it's being powered by redstone or whether it's active. Cauldrons use blockstates to store their water level: it's an integer number between 0 (empty) and 3 (full). However, MCreator doesn't have blockstate procedures (yet), so it's impossible to get the water level of a cauldron without some custom coding. Thanks to the "Custom code snippet" block, it's possible to create a procedure that interacts with the water level of cauldrons.

Procedure (1.12)

The procedure requires the X Y Z and World dependencies. Also, don't add any local variable called "waterLevel". This example procedure will be triggered only if there's water inside the cauldron. It'll do some stuff, then it'll decrease the water level of the cauldron by one.

  1. Start by adding a "if Block at X Y Z = Cauldron", like in the image. All the next blocks will go inside this if statement.
    Cauldron step 1
  2. This is where custom code comes in. Copy this piece of code:
    BlockPos pos = new BlockPos(x, y, z);
    IBlockState blockState = world.getBlockState(pos);
    int waterLevel = blockState.getValue(BlockCauldron.LEVEL);
    if (waterLevel > 0) {
    

    on "custom code snippet" blocks (found in Advanced). You should use a block for each line, to make the code more readable. What this code does is:

    • stores the X Y Z as a BlockPos variable (to make the code cleaner)

    • stores the cauldron and its blockstate as an IBlockState variable

    • stores the water level of the cauldron as an integer variable (which is why you can't use "waterLevel" as a procedure local variable)

    • checks if the water level is greater than 0 (that is, if there's water in the cauldron)

    • Step 2

  3. Now you can add your procedure blocks: apply an effect to the entity, spawn particles, remove items from your inventory etc. Do not remove the cauldron, as it'll be placed back anyway in the next step;

  4. Add more custom code snippets with these lines:

    world.setBlockState(pos, blockState.withProperty(BlockCauldron.LEVEL, waterLevel - 1));
    }

    The first line decreases the water level of the cauldron by 1, the second one closes the "if (waterLevel > 0) {" statement.
    This should be the final result:
    Step 3

  5. Save the procedure and recompile. If you did everything correctly, you shouldn't get recompilation errors

Customization

  • The cauldron isn't at x y z, but somewhere else: copy all the changes you do to the "Get block at X Y Z" block on the 1st code snippet. Example:
    Example 1In this example, the cauldron is at X, Y+1 and Z-2. All the changes I applied to the "Get block" are copied in the first custom code block.
     
  • Execute if the cauldron isn't full, and increase water level by one:
    • In the 4th code snippet, write if (waterLevel < 3) {
    • In the 5th code snippet, write waterLevel + 1 instead of waterLevel - 1
      Example 2
       
  • Execute if the cauldron is empty, and fill it completely:
    • In the 4th code snippet, write if (waterLevel == 0) {
    • In the 5th code snippet, write 3 instead of waterLevel - 1
       
  • Execute if the cauldron is full, and remove all the water:
    • In the 4th code snippet, write if (waterLevel == 3) {
    • In the 5th code snippet, write 0 instead of waterLevel - 1
       
  • Do not change the water level of the cauldron: remove the 5th code snippet. You can also replace the cauldron with another block if you wish so (for example by adding a "Place block at X Y Z" procedure)
     
  • You can change the values of the previous examples if you want to, but keep in mind that waterLevel should always be between 0 and 3. If you write something like if (waterLevel == 4) {, the procedure won't be executed

1.14

The code in Minecraft 1.14.4 is different than the one in 1.12.2. If you do the same steps as above in 1.14, you'll get recompilation errors. To make it work in 1.14, you'll need to use these code lines instead:

BlockPos pos = new BlockPos(x, y, z);
BlockState blockState = world.getBlockState(pos);
int waterLevel = blockState.get(CauldronBlock.LEVEL);
if (waterLevel > 0) {
// Your procedure blocks
world.setBlockState(pos, blockState.with(CauldronBlock.LEVEL, waterLevel - 1));
}

Template download links:

These are the procedures used in the examples (for 1.12):

  1. Decrease the water level by 1 if the cauldron isn't empty: link

  2. Increase the water level by 1 if the cauldron isn't full: link

  3. Empty the cauldron if it's full: link

  4. Fill the cauldron if it's empty: link

Edited by SomeoneElse on Tue, 02/04/2020 - 18:26
Last seen on 02:57, 31. Aug 2021
Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
WOW! I could use cauldrons…
Sat, 10/26/2019 - 06:54

WOW! I could use cauldrons for my mod bedrock alchemy now! Thank you so much

Last seen on 02:57, 31. Aug 2021
Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
@SomeoneElse, you should…
Sun, 10/27/2019 - 03:12

@SomeoneElse, you should apply as wiki contributor

Last seen on 17:49, 25. Mar 2021
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I agree with crispy chips :)
Sun, 10/27/2019 - 13:36

I agree with crispy chips :)

Last seen on 16:09, 23. Sep 2021
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Lo and behold! :P Anyway,…
Tue, 10/29/2019 - 23:14

Lo and behold! :P
Anyway, tidied up the tutorial and added some templates you can download!

Last seen on 11:25, 5. Oct 2021
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
This doesn't work for 1.14,…
Sat, 02/01/2020 - 15:05

This doesn't work for 1.14, can you help me?

Last seen on 16:09, 23. Sep 2021
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Code in 1.14 is different,…
Tue, 02/04/2020 - 18:27

Code in 1.14 is different, that's why it won't work. I added the code you need to use for 1.14; I'll add the templates later

Last seen on 14:38, 23. Oct 2021
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
What should I write if I…
Tue, 07/21/2020 - 13:54

What should I write if I want to do this with crops?

Last seen on 17:17, 23. Oct 2021
Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
It didn't work for me on 1…
Sat, 11/07/2020 - 13:44

It didn't work for me on 1.15.2, can anyone please help me?
Am trying to make an ingot that gets transformed into an unheated one when used in a cauldron. Please anyone help me.

 

Last seen on 00:20, 4. Aug 2021
Joined Jan 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thank you so much, this…
Sat, 07/24/2021 - 18:39

Thank you so much, this worked perfectly for me. 

Last seen on 01:23, 24. Oct 2021
Joined Dec 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Can anyone help me out with…
Sat, 09/18/2021 - 21:58

Can anyone help me out with this on 1.16.5?