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

The following are Jave code examples for showing how to use getLight() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Firma   File: TreeGeneric.java   Source Code and License Vote up 6 votes
@Override
public boolean generateTree(World worldIn, Random rand, BlockPos pos) {
	filler.leaf = leaf;
	// Check light levels
	if(worldIn.getLight(pos)<7){
		return false;
	}
	// Check height of trunk
	int h = rand.nextInt(heightVar) + height;
	for(int y = 0; y<h; y++){
		if(!checkBlockAt(worldIn,pos.add(0,h,0))){
			return false;
		}
	}
	// Place central trunk
	for(int y = 0; y<h; y++){
		fill(worldIn, pos.add(0, y, 0));
	}
	filler.fillLeaves(worldIn, pos.add(0,h-1,0), rand);
	
	return false;
}
 
Example 2
Project: Firma   File: TreeCedar.java   Source Code and License Vote up 6 votes
@Override
public boolean generateTree(World worldIn, Random rand, BlockPos pos) {
	filler.leaf = leaf;
	if(worldIn.getLight(pos)<7){
		return false;
	}
	// Check height of trunk
	int h = rand.nextInt(4) + 4;
	for(int y = 0; y<h; y++){
		if(!checkBlockAt(worldIn,pos.add(0,h,0))){
			return false;
		}
	}
	// Place central trunk
	for(int y = 0; y<h; y++){
		fill(worldIn, pos.add(0, y, 0));
		if(y>1){
			filler.fillLeaves(worldIn, pos.add(0,y,0), rand);				
		}
	}
	return true;
}
 
Example 3
Project: Thermionics   File: LayerScarf.java   Source Code and License Vote up 6 votes
private static void draw(World world, double dx, double dy, double dz, Entity entity, ScarfNode prime, ArrayList<ScarfNode> nodes) {
	TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/wool_colored_white");
	//TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
	Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	ScarfNode lastNode = prime;
	for(ScarfNode node : nodes) {
		//TODO: Swap out sprites each segment?
		
		float x1 = (float)(node.x-dx);
		float x2 = (float)(lastNode.x-dx);
		float y1 = (float)(node.y-dy);
		float y2 = (float)(lastNode.y-dy);
		float z1 = (float)(node.z-dz);
		float z2 = (float)(lastNode.z-dz);
		
		float light1 = world.getLight(new BlockPos((int)node.x, (int)node.y, (int)node.z)) / 15f;
		float light2 = world.getLight(new BlockPos((int)lastNode.x, (int)lastNode.y, (int)lastNode.z)) / 15f;
		
		ribbon(x1, y1, z1, x2, y2, z2, 0.25f, sprite, node.r, node.g, node.b, light1, light2);
		ribbon(x2, y2, z2, x1, y1, z1, 0.25f, sprite, node.r, node.g, node.b, light2, light1);
		lastNode = node;
	}
}
 
Example 4
Project: Firma   File: TreeWillow.java   Source Code and License Vote up 5 votes
@Override
public boolean generateTree(World w, Random rand, BlockPos pos) {
	filler.leaf=leaf;
	// Check light levels
	if(w.getLight(pos)<7){
		return false;
	}
	int h = 5 + rand.nextInt(height);
	// Check height of trunk
	for(int y = 0; y<h; y++){
		if(!checkBlockAt(w,pos.add(0,y,0))){
			return false;
		}
	}
	for(int y = 0; y < h; y++){
		fill(w,pos.add(0,y,0));
	}
	for(int branch = 0; branch < 5; branch++){
		float incx = rand.nextFloat()*2f-1f;
		float incz = rand.nextFloat()*2f-1f;
		float den = Math.abs(incx)+Math.abs(incz);
		incx /= den;
		incz /= den;
		float incy = rand.nextFloat()/4f;
		float x=0,y=0,z=0;
		for(int bc = 0; bc < 5; bc++){
			x+=incx; y+=incy; z+=incz;
			BlockPos p = pos.add(x, y+h, z);
			fill(w,p);
			filler.fillLeaves(w, p, rand);
		}
	}
	return true;
}
 
Example 5
Project: Firma   File: TreeFir.java   Source Code and License Vote up 5 votes
@Override
public boolean generateTree(World w, Random rand, BlockPos pos) {
	filler.leaf=leaf;
	// Check light levels
	if(w.getLight(pos)<7){
		return false;
	}
	// Check height of trunk
	int h = 3+rand.nextInt(height);
	for(int y = 0; y<h; y++){
		if(!checkBlockAt(w,pos.add(0,y,0))){
			return false;
		}
	}
	for(int y = 0; y < h; y++){
		fill(w,pos.add(0,y,0));
	}
	for(int branch = 0; branch < 5; branch++){
		float incx = rand.nextFloat()-.5f;
		float incz = rand.nextFloat()-.5f;
		float incy = rand.nextFloat()*0.5f + 0.5f;
		float x=0,y=0,z=0;
		for(int bc = 0; bc < 5; bc++){
			x+=incx; y+=incy; z+=incz;
			BlockPos p = pos.add(x, y+h, z);
			fill(w,p);
			filler.fillLeaves(w, p, rand);
		}
	}
	return true;
}
 
Example 6
Project: DecompiledMinecraft   File: BlockMushroom.java   Source Code and License Vote up 5 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (pos.getY() >= 0 && pos.getY() < 256)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.down());
        return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
    }
    else
    {
        return false;
    }
}
 
Example 7
Project: DecompiledMinecraft   File: BlockMushroom.java   Source Code and License Vote up 5 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (pos.getY() >= 0 && pos.getY() < 256)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.down());
        return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
    }
    else
    {
        return false;
    }
}
 
Example 8
Project: BaseClient   File: BlockMushroom.java   Source Code and License Vote up 5 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (pos.getY() >= 0 && pos.getY() < 256)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.down());
        return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
    }
    else
    {
        return false;
    }
}
 
Example 9
Project: BaseClient   File: BlockMushroom.java   Source Code and License Vote up 5 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (pos.getY() >= 0 && pos.getY() < 256)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.down());
        return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
    }
    else
    {
        return false;
    }
}
 
Example 10
Project: Backmemed   File: BlockMushroom.java   Source Code and License Vote up 5 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (pos.getY() >= 0 && pos.getY() < 256)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.down());
        return iblockstate.getBlock() == Blocks.MYCELIUM ? true : (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canSustainBush(iblockstate));
    }
    else
    {
        return false;
    }
}
 
Example 11
Project: CustomWorldGen   File: BlockMushroom.java   Source Code and License Vote up 5 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (pos.getY() >= 0 && pos.getY() < 256)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.down());
        return iblockstate.getBlock() == Blocks.MYCELIUM ? true : (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this));
    }
    else
    {
        return false;
    }
}
 
Example 12
Project: DecompiledMinecraft   File: BlockCrops.java   Source Code and License Vote up 4 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
}
 
Example 13
Project: DecompiledMinecraft   File: BlockCrops.java   Source Code and License Vote up 4 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
}
 
Example 14
Project: BaseClient   File: BlockCrops.java   Source Code and License Vote up 4 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
}
 
Example 15
Project: BaseClient   File: BlockCrops.java   Source Code and License Vote up 4 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
}
 
Example 16
Project: Backmemed   File: BlockCrops.java   Source Code and License Vote up 4 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canSustainBush(worldIn.getBlockState(pos.down()));
}
 
Example 17
Project: CustomWorldGen   File: BlockCrops.java   Source Code and License Vote up 4 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    IBlockState soil = worldIn.getBlockState(pos.down());
    return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this);
}
 
Example 18
Project: FoodCraft-Reloaded   File: BlockQuery.java   Source Code and License Vote up 4 votes
@Override
public boolean matches(World world, BlockPos pos) {
    return world.getLight(pos.up()) >= this.level || world.canSeeSky(pos.up());
}
 
Example 19
Project: FoodCraft-Reloaded   File: BlockQuery.java   Source Code and License Vote up 4 votes
@Override
public boolean matches(World world, BlockPos pos) {
    return world.getLight(pos.up()) <= this.level;
}
 
Example 20
Project: rtap   File: cropPeppers.java   Source Code and License Vote up 2 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) {

      IBlockState soil = worldIn.getBlockState(pos.down());
      return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this);
      
  }