How do you can know "Facing" variable of a block?

Started by Maquinablablabla on

Topic category: Help with MCreator software

Joined Jan 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do you can know "Facing" variable of a block?

how to know the facing of a block in a procedure?

If, for example Im making a block placer I need to know the facing of the block for place the block in the correct side. How?

 

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
IBlockState#getValue…
Sun, 02/24/2019 - 18:25

IBlockState#getValue(IProperty) is what you are looking for. IBlockState is sometimes already sometimes provided to you by Minecraft (things like interacting with blocks), or you get it using World#getBlockState(BlockPos). As an IProperty, you parse the property that contains the EnumFacing. Unless MCreator uses a for whatever reason a custom implementation, you just need to parse BlockHorizontal.FACING. The returned value is going to be of type EnumFacing, which you can compare to any value you want and then execute the rest of the code.

The code should look basically like this:
 

EnumFacing facing = (EnumFacing)iblockstate.getValue(BlockHorizontal.FACING);
if(facing == EnumFacing.NORTH){
//do stuff....
}

 

Joined Jan 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I thank you very very muck.
Sun, 02/24/2019 - 19:07

I thank you very very muck.

Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i have a different but…
Sun, 03/17/2019 - 05:51

i have a different but related issue. 

im trying to make a bucket  like item that when you right click on a block water is spawned. but how do i figure out which side of the block is being clicked? also, how do i replace the bucket-of-water in the players main hand with a different item?

Tavonis, if you want to do…
Sun, 03/17/2019 - 11:25

Tavonis, if you want to do this with MCreator, you will have to wait a bit as we have this feature in plan but was not added yet.