Jump to content

Is there still a way to check if a block has visibility to the sky[1.7.2]


gmod622

Recommended Posts

i would say take the blocks xyz pos, and see if there are any blocks on above the block on the y axis, from the blocks y pos to 256, i would also reccomend passing through glass and other transparent blocks. For example.

while(int y = yPos; y <=256; y++)
{
    if((world.getBlockatCoords(xPos,y,zPos) != null) || (world.getBlockatCoords(xPos,y,zPos) != Blocks.glass))
    {
         skyVisible = false;
    }
}

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Link to comment
Share on other sites

i would say take the blocks xyz pos, and see if there are any blocks on above the block on the y axis, from the blocks y pos to 256, i would also reccomend passing through glass and other transparent blocks. For example.

while(int y = yPos; y <=256; y++)
{
    if((world.getBlockatCoords(xPos,y,zPos) != null) || (world.getBlockatCoords(xPos,y,zPos) != Blocks.glass))
    {
         skyVisible = false;
    }
}

 

The method is getBlock(x, y, z) and the null check is useless. Blocks.air is returned in any case other than a regular block.

Link to comment
Share on other sites

I use this for my solar furnace.

 

 public static boolean sunIsVisible = false;
    
    /**
     * Checks if the specified block is able to see the sky
     */
    public void updateSunVisibility()
    {
      this.sunIsVisible = isSunVisible(this.worldObj, this.xCoord, this.yCoord + 1, this.zCoord);
    }
    
    public static boolean isSunVisible(World world, int x, int y, int z)
    {
      return (world.isDaytime()) && (!world.provider.hasNoSky) && (world.canBlockSeeTheSky(x, y, z)) && (((world.getWorldChunkManager().getBiomeGenAt(x, z) instanceof BiomeGenDesert)) || ((!world.isRaining()) && (!world.isThundering())));
    }
    
     
  

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.