Enum Property Check

Started by S33R_OF_PYR3 on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 02:02, 13. May 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Enum Property Check

I have a procedure that runs when the player right clicks a block, and I want the code to run only when the block is on the floor (as opposed to the ceiling or wall). I have this if statement encapsulating the code at the start, but something seems to be wrong with it as the code won't run even if the block is on the floor.

if (((world.getBlockState(new BlockPos(x, y, z))).getBlock().getStateDefinition().getProperty("face") instanceof EnumProperty _getep1

            ? (world.getBlockState(new BlockPos(x, y, z))).getValue(_getep1).toString()

            : "").equals("floor")) {

I'm using the visual editor to write the procedures so I'm not sure if the raw code is correct. According to the visual editor, the if statement reads:

if ([get enum property "face" of {block x y z}] = "floor")

 

I've checked and assigned integer blockstates successfully but haven't messed with enum properties much, so I'm in the dark here. Would appreciate the help~

Last seen on 05:10, 3. Dec 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I haven't touched enum much…
Sat, 09/23/2023 - 17:38

I haven't touched enum much either. Just to confirm, you have defined the enum property in the opening line, correct?

 

Also, to do what you are looking to do isn't too complex. With MCreator procedures you would be able to set up 2 ways. The first being and "if (get block x, y-1, z) = ! Air ) do {whatever you need}". Second way would be using the directional procedures to test on the "down" face of the block.