How to know if the player right clicked the upper or lower part of the block

Started by Cdztw on

Topic category: Advanced modding

Last seen on 03:43, 26. Mar 2024
Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to know if the player right clicked the upper or lower part of the block
Mon, 11/06/2023 - 16:04 (edited)

I recently created a custom slab with rotatable textures.
I want to make the placement of this slab similar to vanilla Minecraft.
When a player is holding a slab and looks at the upper part of a block, then right-clicks, it will place the slab with the enum property "type" set to "top."
On the other hand, if the player looks at the lower part of a block and right-clicks, it will place the slab with the enum property "type" set to "bottom".
How can I implement this function?

 

*UPDATE

I tried using "Look Y position of [Event/target entity] with raytrace distance [1] fluid mode [NONE▾] block mode [OUTLINE▾] " block, but it only return integer value,
I can't get the double value to make the detection works.

Edited by Cdztw on Mon, 11/06/2023 - 16:04
Last seen on 03:43, 26. Mar 2024
Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay, I found a solution…
Tue, 11/07/2023 - 05:32

Okay, I found a solution.
Instead of making a rotatable block behaves like vanilla slabs, I modified the vanilla slabs to have facing enum property and use my custom models to acheive this goal.
Now I don't need to worry about how to solve placement problem.