Can block see the sky not working.

Started by Help_Me_Please on

Topic category: Help with MCreator software

Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can block see the sky not working.

I have really simple block code:

If the block can see the sky then strike lightning on it.  Without the if statement it works fine lightning strikes but it goes through blocks, I don't want that.  With the if statement the lightning never strikes.  How exactly does the block in world data: can block see the sky x y z, work?.

Joined Dec 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry if this is late, which…
Tue, 12/18/2018 - 06:49

Sorry if this is late, which it is. But I think I figured out a code that works

1st, make sure this is in the code, imported:

import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;

And no I don't know if you need both, I'm not good at coding.

2nd, use this code for blockpos:

		if (!(entity.world.canSeeSky(new BlockPos((int) entity.posX, (int) 
        entity.getEntityBoundingBox().minY, (int) entity.posZ)))) {
             do something here
             }