use of forestry.arboriculture.tiles.TileSapling in project ForestryMC by ForestryMC.
the class TreeRoot method plantSapling.
@Override
public boolean plantSapling(World world, ITree tree, GameProfile owner, BlockPos pos) {
BlockRegistryArboriculture blocks = ModuleArboriculture.getBlocks();
IBlockState state = blocks.saplingGE.getDefaultState().withProperty(BlockSapling.TREE, tree.getGenome().getPrimary());
boolean placed = world.setBlockState(pos, state);
if (!placed) {
return false;
}
IBlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
if (blocks.saplingGE != block) {
return false;
}
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
if (sapling == null) {
world.setBlockToAir(pos);
return false;
}
sapling.setTree(tree.copy());
sapling.getOwnerHandler().setOwner(owner);
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState);
NetworkUtil.sendNetworkPacket(packet, pos, world);
return true;
}
use of forestry.arboriculture.tiles.TileSapling in project ForestryMC by ForestryMC.
the class BlockSapling method canBlockStay.
/* PLANTING */
public static boolean canBlockStay(IBlockAccess world, BlockPos pos) {
TileSapling tile = TileUtil.getTile(world, pos, TileSapling.class);
if (tile == null) {
return false;
}
ITree tree = tile.getTree();
return tree != null && tree.canStay(world, pos);
}
use of forestry.arboriculture.tiles.TileSapling in project ForestryMC by ForestryMC.
the class TreeGrowthHelper method isSapling.
private static boolean isSapling(ITreeGenome genome, World world, BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return false;
}
if (world.isAirBlock(pos)) {
return false;
}
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
if (sapling == null) {
return false;
}
ITree tree = sapling.getTree();
return tree != null && tree.getGenome().getPrimary().getUID().equals(genome.getPrimary().getUID());
}
Aggregations