Jump to content

Solved(1.7.2) How do you detect daylight(for solar generator type thing)


tompinn23

Recommended Posts

Hello I'm trying to make a solar generator but i am having trouble figuring out how to detect whether there is sunlight above the block here is what i found in the daylight detector code but really i just need it to return true or false.

public void func_149957_e(World world, int x, int y, int z)
  

{
    if (world.provider.hasNoSky) {
      return;
    }
    int i = world.getBlockMetadata(x, y, z);
    int j = world.getSavedLightValue(EnumSkyBlock.Sky, x, y, z) - world.skylightSubtracted;
    float f = world.getCelestialAngleRadians(1.0F);
    if (f < 3.141593F) {
      f += (0.0F - f) * 0.2F;
    } else {
      f += (6.283186F - f) * 0.2F;
    }
    j = Math.round(j * MathHelper.cos(f));
    if (j < 0) {
      j = 0;
    }
    if (j > 15) {
      j = 15;
    }
    if (i != j) {
      world.setBlockMetadataWithNotify(x, y, z, j, 3);
    }
  }

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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