Search in sources :

Example 1 with BlockFruitPod

use of forestry.arboriculture.blocks.BlockFruitPod 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 BlockFruitPod

use of forestry.arboriculture.blocks.BlockFruitPod in project ForestryMC by ForestryMC.

the class FruitPodStateMapper method putStateModelLocations.

@Override
public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block block) {
    if (block instanceof BlockFruitPod) {
        BlockFruitPod blockFruitPod = (BlockFruitPod) block;
        IAlleleFruit fruit = blockFruitPod.getFruit();
        String modID = fruit.getModID();
        if (modID == null) {
            modID = Constants.MOD_ID;
        }
        String modelName = fruit.getModelName();
        String resourcePath = modID + ":pods/" + modelName;
        for (IBlockState state : block.getBlockState().getValidStates()) {
            String propertyString = getPropertyString(state.getProperties());
            mapStateModelLocations.put(state, new ModelResourceLocation(resourcePath, propertyString));
        }
    }
    return mapStateModelLocations;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) BlockFruitPod(forestry.arboriculture.blocks.BlockFruitPod)

Aggregations

BlockFruitPod (forestry.arboriculture.blocks.BlockFruitPod)2 IBlockState (net.minecraft.block.state.IBlockState)2 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)1 BlockRegistryArboriculture (forestry.arboriculture.blocks.BlockRegistryArboriculture)1 TileFruitPod (forestry.arboriculture.tiles.TileFruitPod)1 Block (net.minecraft.block.Block)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 EnumFacing (net.minecraft.util.EnumFacing)1