94 lines
2.5 KiB
Java
Executable file
94 lines
2.5 KiB
Java
Executable file
package common.block.foliage;
|
|
|
|
import common.block.Block;
|
|
import common.block.Material;
|
|
import common.init.Blocks;
|
|
import common.item.CheatTab;
|
|
import common.model.BlockLayer;
|
|
import common.rng.Random;
|
|
import common.util.BlockPos;
|
|
import common.util.BoundingBox;
|
|
import common.world.State;
|
|
import common.world.World;
|
|
import common.world.AWorldServer;
|
|
|
|
public class BlockBush extends Block
|
|
{
|
|
public BlockBush()
|
|
{
|
|
this(Material.PLANT);
|
|
}
|
|
|
|
public BlockBush(Material p_i46452_1_)
|
|
{
|
|
super(p_i46452_1_);
|
|
this.setTickRandomly();
|
|
float f = 0.2F;
|
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);
|
|
this.setTab(CheatTab.PLANTS);
|
|
}
|
|
|
|
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
|
{
|
|
return super.canPlaceBlockAt(worldIn, pos) && this.canPlaceBlockOn(worldIn.getState(pos.down()).getBlock());
|
|
}
|
|
|
|
/**
|
|
* is the block grass, dirt or farmland
|
|
*/
|
|
protected boolean canPlaceBlockOn(Block ground)
|
|
{
|
|
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland || ground == Blocks.tian_soil;
|
|
}
|
|
|
|
/**
|
|
* Called when a neighboring block changes.
|
|
*/
|
|
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
|
|
{
|
|
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
|
|
this.checkAndDropBlock(worldIn, pos, state);
|
|
}
|
|
|
|
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
|
{
|
|
this.checkAndDropBlock(worldIn, pos, state);
|
|
}
|
|
|
|
protected void checkAndDropBlock(World worldIn, BlockPos pos, State state)
|
|
{
|
|
if (!this.canBlockStay(worldIn, pos, state))
|
|
{
|
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
|
worldIn.setState(pos, Blocks.air.getState(), 3);
|
|
}
|
|
}
|
|
|
|
public boolean canBlockStay(World worldIn, BlockPos pos, State state)
|
|
{
|
|
return this.canPlaceBlockOn(worldIn.getState(pos.down()).getBlock());
|
|
}
|
|
|
|
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
|
*/
|
|
public boolean isOpaqueCube()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public boolean isFullCube()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public BlockLayer getBlockLayer()
|
|
{
|
|
return BlockLayer.CUTOUT;
|
|
}
|
|
}
|