Started by
S33R_OF_PYR3
on
Topic category: Troubleshooting, bugs, and solutions
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~
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.