[Solved] "When right clicked on block" Trigger won't work on water blocks

Started by Kierra Mac on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 05:33, 23. Apr 2020
Joined Dec 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Solved] "When right clicked on block" Trigger won't work on water blocks
Tue, 01/01/2019 - 21:34 (edited)

In the mod I'm creating, I wanted to be able to click a block with a custom item and have it call a specific procedure if the block is water. However, Minecraft doesn't consider water blocks when getting "Looking at" coordinates. Here's what I mean.

Coordinates when looking at grass block

Coordinates when looking at water block

The coordinates are the same, even though I'm looking at the water block in the second image. So, the statement "If block at x,y,z is water" will never return true in this case. I did figure out a work around, though. It doesn't function exactly the same as I originally wanted, but it works well enough for my purpose. It checks around the provided x,y,z coordinates to see if any are water blocks. I plan on improving this later, but you can download my original code here. It will be collapsed when you import it, but you can expand all of it to edit some variables, as I've described below. Here is the expanded code.

Image of the whole procedure

The numbers I've circled in red represent how many blocks away you want to check for water. If you want to change how many blocks away the procedure checks, you have to change all of the numbers that are circled. The call procedure outlined in the red rectangle should be changed to the procedure you want to call if water is found.

The "Import procedure" button can be found near the top right of the Mcreator window when you open a procedure. After it's imported, just connect the new blocks to the "Event trigger" block. To trigger the procedure, I created a new item and set its "When right clicked on block (hand loc.)" option to this procedure.

If you have any suggestions or improvement, please let me know!

Edited by Kierra Mac on Tue, 01/01/2019 - 21:34
Last seen on 17:18, 11. Feb 2020
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How you make the Water Bars?…
Thu, 01/03/2019 - 20:26

How you make the Water Bars? I will make mana Bars from terraria but i dont know how.

Last seen on 21:42, 17. Aug 2019
Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RockstarBonnet You just need…
Sat, 01/19/2019 - 17:26

RockstarBonnet You just need to make an overlay and import the picture of bar you want, please don't ask me about procedures because I am not and well aware in the fact I am not an expert in that

Last seen on 17:18, 11. Feb 2020
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
thanks
Sat, 01/19/2019 - 17:41

thanks

Last seen on 08:33, 9. Apr 2020
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Not sure if this solution…
Mon, 03/16/2020 - 20:32

Not sure if this solution was covered in this thread (I might have missed it).  I, too, noticed how MCreator looks right through a water block at the block behind it.  So, what about telling it to check the block above the one looked at to see if it is a water block?  It doesn't necessarily need to check every block around the one being looked at, but just 2 of them... x, y-1, z (in case the crosshairs are sitting on the block directly under the water block), and also x-1,y,z (in case the crosshairs are sitting on the block further away from the player than the water block but on the same "y" as the player).

Last seen on 08:33, 9. Apr 2020
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Actually, one of those…
Mon, 03/16/2020 - 20:34

Actually, one of those coordinates should be x,y+1,z instead of x,y-1,z.

Last seen on 08:33, 9. Apr 2020
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, but wait a minute... I…
Mon, 03/16/2020 - 20:38

Oh, but wait a minute... I guess it does need to check more than just 2 blocks, because of the angle the player might be looking along.

Last seen on 08:33, 9. Apr 2020
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I found something that works…
Mon, 03/16/2020 - 21:13

I found something that works.  But it reads only the block directly above the one being looked at, not any other blocks all around.  So the player needs to keep moving the crosshairs around a little.  But it works, anyway.

https://ibb.co/vPnnVL2

 

Last seen on 22:41, 29. Dec 2021
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how do i get the "local:…
Wed, 04/08/2020 - 21:29

how do i get the "local: loopNumber" and "local: Water nearby"?

Last seen on 22:41, 29. Dec 2021
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Do you have a download for…
Wed, 04/08/2020 - 21:30

Do you have a download for that?

 

Last seen on 22:41, 29. Dec 2021
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nevermind
Wed, 04/08/2020 - 21:42

Nevermind

Last seen on 08:33, 9. Apr 2020
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have a better one here:…
Thu, 04/09/2020 - 08:33

I have a better one here: https://ibb.co/w04CnBs.&nbsp

In this one shown here, it checks to see if the block directly above the block you click on has empty air.  If it does have empty air AND you're holding a bucket with water, it will put a water block there, remove the water bucket from inventory, and add an empty bucket to your inventory.  So you need to create two items: a bucket of water and an empty bucket.

This snippet of commands also checks if the block directly above the block you click on already has water.  So in this case, you'd be clicking on a block underwater.  If it does have water above it already AND you're holding an empty bucket, it will remove the water block, remove the empty bucket from your inventory, and add a bucket of water to your inventory.

The only problem with this that I haven't been able to fix is that it will take water from both still water and flowing water, whereas the vanilla iron bucket will take water from only still water and not from flowing water.  I haven't been able to figure out how distinguish between still water and flowing water.  Even though MCreator has two separate water items, one that says "standing water" and the other that says "flowing water", when I use either one in this code, it will treat them both the same.

I hope this helps.  Have a good one.

Last seen on 22:41, 29. Dec 2021
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you vision quester for…
Wed, 04/22/2020 - 21:38

Thank you vision quester for the procedures! i have credited you in the credits of my mod.

Last seen on 05:33, 23. Apr 2020
Joined Dec 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Interesting! I wasn't…
Thu, 04/23/2020 - 02:29

Interesting! I wasn't expecting a bucket feature in this mod, but that's a good approach to the issue. That could definitely trim down the amount of code used.