Search in sources :

Example 1 with TileFruitPod

use of forestry.arboriculture.tiles.TileFruitPod in project ForestryMC by ForestryMC.

the class TreeRoot method setFruitBlock.

@Override
public boolean setFruitBlock(World world, ITreeGenome genome, IAlleleFruit allele, float sappiness, BlockPos pos) {
    BlockRegistryArboriculture blocks = ModuleArboriculture.getBlocks();
    EnumFacing facing = BlockUtil.getValidPodFacing(world, pos);
    if (facing != null) {
        BlockFruitPod fruitPod = blocks.getFruitPod(allele);
        if (fruitPod != null) {
            IBlockState state = fruitPod.getDefaultState().withProperty(BlockHorizontal.FACING, facing);
            boolean placed = world.setBlockState(pos, state);
            if (placed) {
                Block block = world.getBlockState(pos).getBlock();
                if (fruitPod == block) {
                    TileFruitPod pod = TileUtil.getTile(world, pos, TileFruitPod.class);
                    if (pod != null) {
                        pod.setProperties(genome, allele, sappiness);
                        world.markBlockRangeForRenderUpdate(pos, pos);
                        return true;
                    } else {
                        world.setBlockToAir(pos);
                        return false;
                    }
                }
            }
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) BlockRegistryArboriculture(forestry.arboriculture.blocks.BlockRegistryArboriculture) Block(net.minecraft.block.Block) BlockFruitPod(forestry.arboriculture.blocks.BlockFruitPod) TileFruitPod(forestry.arboriculture.tiles.TileFruitPod)

Example 2 with TileFruitPod

use of forestry.arboriculture.tiles.TileFruitPod in project ForestryMC by ForestryMC.

the class BlockFruitPod method updateTick.

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
    if (!canBlockStay(world, pos, state)) {
        dropBlockAsItem(world, pos, state, 0);
        world.setBlockToAir(pos);
        return;
    }
    TileFruitPod tile = TileUtil.getTile(world, pos, TileFruitPod.class);
    if (tile == null) {
        return;
    }
    tile.onBlockTick(world, pos, state, rand);
}
Also used : TileFruitPod(forestry.arboriculture.tiles.TileFruitPod)

Aggregations

TileFruitPod (forestry.arboriculture.tiles.TileFruitPod)2 BlockFruitPod (forestry.arboriculture.blocks.BlockFruitPod)1 BlockRegistryArboriculture (forestry.arboriculture.blocks.BlockRegistryArboriculture)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EnumFacing (net.minecraft.util.EnumFacing)1