Search in sources :

Example 1 with EnumSkyBlock

use of net.minecraft.world.EnumSkyBlock in project Galacticraft by micdoodle8.

the class TileEntityArclamp method getRawLight.

/**
 * From vanilla.  This is buggy, gets confused if two low opacity blocks adjacent (e.g. redstone wire, stairs)
 * if those blocks are receiving similar light levels from another source
 */
private int getRawLight(BlockPos pos, EnumSkyBlock lightType) {
    Block block = this.worldObj.getBlockState(pos).getBlock();
    int blockLight = block.getLightValue(this.worldObj, pos);
    int light = lightType == EnumSkyBlock.SKY ? 0 : blockLight;
    if (light < 14) {
        int opacity = block.getLightOpacity(this.worldObj, pos);
        if (opacity < 1) {
            opacity = 1;
        } else if (opacity >= 15) {
            if (blockLight > 0) {
                opacity = 1;
            } else {
                return 0;
            }
        }
        for (BlockPos blockpos : GCCoreUtil.getPositionsAdjoining(pos)) {
            // Easily picks up neighbour lighting if opacity is low...
            int neighbourLight = this.worldObj.getLightFor(lightType, blockpos) - opacity;
            if (neighbourLight > light) {
                if (neighbourLight >= 14) {
                    return neighbourLight;
                }
                light = neighbourLight;
            }
        }
    }
    return light;
}
Also used : Block(net.minecraft.block.Block) EnumSkyBlock(net.minecraft.world.EnumSkyBlock) BlockPos(net.minecraft.util.BlockPos)

Aggregations

Block (net.minecraft.block.Block)1 BlockPos (net.minecraft.util.BlockPos)1 EnumSkyBlock (net.minecraft.world.EnumSkyBlock)1