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

The following examples show how to use net.minecraft.world.World#getLight() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@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 Project: AgriCraft   File: LightHelper.java    License: 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
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 Project: TFC2   File: BlockCrop.java    License: 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);
}