Topic category: Bugs and solutions
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.
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.
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!