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

The following examples show how to use net.minecraft.world.World#canBlockSeeSky() . 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
Source Project: TofuCraftReload   File: BlockSaltPan.java    License: MIT License 6 votes vote down vote up
private float calcAdaptation(World world, BlockPos pos)
{
    Biome biome = world.getBiome(pos);
    boolean isUnderTheSun = world.canBlockSeeSky(pos);
    boolean isRaining = world.isRaining();
    boolean isDaytime = world.getWorldTime() % 24000 < 12000;
    float humidity = biome.getRainfall();
    float temperature = biome.getTemperature(pos);
    float rate;

    if (!isUnderTheSun || isRaining)
    {
        rate = 0.0F;
    }
    else
    {
        rate = isDaytime ? 2.0F : 1.0F;
        rate *= humidity < 0.2D ? 4.0D : humidity < 0.7D ? 2.0D : humidity < 0.9 ? 1.0D : 0.5D;
        rate *= temperature < 0.0D ? 1.0D : temperature < 0.6D ? 1.5D : temperature < 1.0D ? 2.0D : 4.0D;
    }
    return rate;
}
 
Example 2
Source Project: TFC2   File: BlockTorchTFC.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
	super.updateTick(worldIn, pos, state, rand);

	if (!worldIn.isRemote && this.isOn)
	{
		if (TFCOptions.torchBurnTime != 0 && worldIn.getTileEntity(pos) instanceof TileTorch)
		{
			TileTorch te = (TileTorch) worldIn.getTileEntity(pos);
			boolean timerExpired = Timekeeper.getInstance().getTotalHours() > te.getTimer() + TFCOptions.torchBurnTime;
			boolean isWet = worldIn.isRaining() && worldIn.canBlockSeeSky(pos);

			if (timerExpired || isWet)
			{
				int meta = this.getMetaFromState(state);
				worldIn.setBlockState(pos, TFCBlocks.TorchOff.getStateFromMeta(meta), 3);
			}
		}
	}
}
 
Example 3
Source Project: Sakura_mod   File: BlockHalfTatami.java    License: MIT License 5 votes vote down vote up
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	if(worldIn.canBlockSeeSky(pos)&&worldIn.isDaytime()){
			worldIn.setBlockState(pos, (isNS?BlockLoader.TATAMI_TAN_NS_HALF:BlockLoader.TATAMI_TAN_HALF).getDefaultState().withProperty(FACING, state.getValue(FACING)));
	}
	super.updateTick(worldIn, pos, state, rand);
}
 
Example 4
Source Project: Sakura_mod   File: BlockCarpetTatami.java    License: MIT License 5 votes vote down vote up
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	if(worldIn.canBlockSeeSky(pos)&&worldIn.isDaytime()){
			worldIn.setBlockState(pos, (isNS?BlockLoader.TATAMI_TAN_NS_CARPET:BlockLoader.TATAMI_TAN_CARPET).getDefaultState().withProperty(FACING, state.getValue(FACING)));
	}
	super.updateTick(worldIn, pos, state, rand);
}
 
Example 5
Source Project: Sakura_mod   File: BlockBambooBlock.java    License: MIT License 5 votes vote down vote up
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	if(!isSunburnt&&(worldIn.canBlockSeeSky(pos)||worldIn.getBlockState(pos.up()).getBlock() instanceof BlockBambooBlock)&&worldIn.isDaytime()){
			worldIn.setBlockState(pos, (BlockLoader.BAMBOO_BLOCK_SUNBURNT).getDefaultState().withProperty(LOG_AXIS, state.getValue(LOG_AXIS)));
	}
	super.updateTick(worldIn, pos, state, rand);
}
 
Example 6
Source Project: Sakura_mod   File: BlockTatami.java    License: MIT License 5 votes vote down vote up
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	if(worldIn.canBlockSeeSky(pos)&&worldIn.isDaytime()){
			worldIn.setBlockState(pos, (isNS?BlockLoader.TATAMI_TAN_NS:BlockLoader.TATAMI_TAN).getDefaultState().withProperty(FACING, state.getValue(FACING)));
	}
	super.updateTick(worldIn, pos, state, rand);
}