Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

Pretty much a solar pannel, I need to be able to check if its day, and if it has visibility to the sky, I looked through the block class and did not find any thing interesting.

 

Thanks,

 

-gmod622

Not new to java >> New to modding.

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]

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.

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())));
    }
    
     
  

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.