Java Code Examples for net.minecraft.world.World#getLight()

The following examples show how to use net.minecraft.world.World#getLight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockFoam.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random) {
    int lightLevel = (worldIn.canSeeSky(pos) && worldIn.isDaytime()) ? 16 : worldIn.getLight(pos);
    if (random.nextInt(20 - lightLevel) == 0) {
        worldIn.setBlockState(pos, getPetrifiedBlock(state));
    }
}
 
Example 2
Source File: LightHelper.java    From AgriCraft with MIT License 5 votes vote down vote up
@Nonnull
public static byte[] getLightData(@Nonnull World world, @Nonnull BlockPos pos) {
    // Validate
    Preconditions.checkNotNull(world);
    Preconditions.checkNotNull(pos);

    // Create the array.
    final byte lightData[] = new byte[LIGHT_METHOD_COUNT];

    // Fill the array.
    lightData[0] = (byte) world.getLight(pos);
    lightData[1] = (byte) world.getLight(pos, false);
    lightData[2] = (byte) world.getLight(pos, true);
    lightData[3] = (byte) world.getLightFor(EnumSkyBlock.SKY, pos);
    lightData[4] = (byte) world.getLightFor(EnumSkyBlock.BLOCK, pos);
    lightData[5] = (byte) world.getLightFromNeighbors(pos);
    if (world.isRemote) {
        lightData[6] = (byte) world.getLightFromNeighborsFor(EnumSkyBlock.SKY, pos);
        lightData[7] = (byte) world.getLightFromNeighborsFor(EnumSkyBlock.BLOCK, pos);
    } else {
        lightData[6] = (byte) 0;
        lightData[7] = (byte) 0;
    }
    lightData[8] = (byte) world.getLightBrightness(pos);

    // Return the array.
    return lightData;
}
 
Example 3
Source File: Area.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void loadShipIntoStorage(World world, BaseVehicleEntity entity) {
	for (BlockPos bp : scanArea(world)) {
		BlockStorage bs = new BlockStorage(world.getBlockState(bp), world.getTileEntity(bp), world.getLight(bp));
		entity.getStorage().blockMap.put(bp, bs);
	}
}
 
Example 4
Source File: BlockCrop.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
	IBlockState soil = worldIn.getBlockState(pos.down());
	return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && (Core.isSoil(soil) || soil.getBlock() == TFCBlocks.Farmland);
}