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

Started by SomeoneElse on

Topic category: User side tutorials

Active 9 months ago
Joined Nov 2017
Points:
897

User statistics:

  • Modifications: 1
  • Forum topics: 15
  • Wiki pages: 2
  • MCreator plugins: 0
  • Comments: 158
[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
Active 10 months ago
Joined Jun 2019
Points:
2601

User statistics:

  • Modifications: 4
  • Forum topics: 48
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3319
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

Active 10 months ago
Joined Jun 2019
Points:
2601

User statistics:

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

@SomeoneElse, you should apply as wiki contributor

Active 4 years ago
Joined Jun 2016
Points:
3649

User statistics:

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

I agree with crispy chips :)

Active 9 months ago
Joined Nov 2017
Points:
897

User statistics:

  • Modifications: 1
  • Forum topics: 15
  • Wiki pages: 2
  • MCreator plugins: 0
  • Comments: 158
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!

Active 3 years ago
Joined Apr 2016
Points:
828

User statistics:

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

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

Active 9 months ago
Joined Nov 2017
Points:
897

User statistics:

  • Modifications: 1
  • Forum topics: 15
  • Wiki pages: 2
  • MCreator plugins: 0
  • Comments: 158
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

Active 3 years ago
Joined Jun 2020
Points:
649

User statistics:

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

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

Active 11 months ago
Joined Nov 2020
Points:
642

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 10
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.

 

Active 4 years ago
Joined Jan 2018
Points:
697

User statistics:

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

Thank you so much, this worked perfectly for me. 

Active 1 day ago
Joined Dec 2018
Points:
1329

User statistics:

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

Can anyone help me out with this on 1.16.5?

Active 2 days ago
Joined Sep 2020
Points:
739

User statistics:

  • Modifications: 1
  • Forum topics: 15
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 83
How to do it on 1.16.5?
Mon, 05/16/2022 - 22:58

How to do it on 1.16.5?