Search in sources :

Example 1 with BlockSurfaceRoot

use of com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot in project DynamicTrees by DynamicTreesTeam.

the class ChunkTreeHelper method cleanupBlock.

/**
 * Cleanup blocks that are attached(or setting on) various parts of the tree
 *
 * @param world
 * @param pos
 */
public static void cleanupBlock(World world, BlockPos pos) {
    IBlockState blockstate = world.getBlockState(pos);
    if (blockstate == ModBlocks.blockStates.air) {
        // This is the most likely case so bail early
        return;
    }
    Block block = blockstate.getBlock();
    // Cleanup snow layers, hanging fruit(apples), trunk fruit(cocoa), and surface roots.
    if (block instanceof BlockSnow || block instanceof BlockFruit || block instanceof BlockFruitCocoa || block instanceof BlockSurfaceRoot) {
        world.setBlockState(pos, ModBlocks.blockStates.air, 2);
    } else // Cleanup vines
    if (block instanceof BlockVine) {
        cleanupVines(world, pos);
    }
}
Also used : BlockSnow(net.minecraft.block.BlockSnow) IBlockState(net.minecraft.block.state.IBlockState) BlockVine(net.minecraft.block.BlockVine) BlockFruit(com.ferreusveritas.dynamictrees.blocks.BlockFruit) Block(net.minecraft.block.Block) BlockFruitCocoa(com.ferreusveritas.dynamictrees.blocks.BlockFruitCocoa) BlockSurfaceRoot(com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot)

Example 2 with BlockSurfaceRoot

use of com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot in project DynamicTrees by DynamicTreesTeam.

the class FeatureGenRoots method postGrow.

@Override
public boolean postGrow(World world, BlockPos rootPos, BlockPos treePos, Species species, int soilLife, boolean natural) {
    int trunkRadius = TreeHelper.getRadius(world, treePos);
    if (soilLife > 0 && trunkRadius >= minTrunkRadius) {
        Surround surr = Surround.values()[world.rand.nextInt(8)];
        BlockPos dPos = treePos.add(surr.getOffset());
        if (world.getBlockState(dPos).getBlock() instanceof BlockSurfaceRoot) {
            world.setBlockState(dPos, ModBlocks.blockTrunkShell.getDefaultState().withProperty(BlockTrunkShell.COREDIR, surr.getOpposite()));
        }
        startRoots(world, treePos, species, trunkRadius);
    }
    return true;
}
Also used : Surround(com.ferreusveritas.dynamictrees.util.CoordUtils.Surround) BlockPos(net.minecraft.util.math.BlockPos) BlockSurfaceRoot(com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot)

Example 3 with BlockSurfaceRoot

use of com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot in project DynamicTrees by DynamicTreesTeam.

the class ModelHelper method regModel.

/**
 * Registers models associated with the tree. At the moment this only deals with {@link BlockBranch} blocks
 *
 * @param tree
 */
public static void regModel(TreeFamily tree) {
    BlockBranch blockBranch = tree.getDynamicBranch();
    ModelResourceLocation modelLocation = getBranchModelResourceLocation(blockBranch);
    setGenericStateMapper(blockBranch, modelLocation);
    if (blockBranch instanceof BlockBranchThick) {
        setGenericStateMapper(((BlockBranchThick) blockBranch).otherBlock, modelLocation);
    }
    BlockSurfaceRoot surfaceRoot = tree.getSurfaceRoots();
    if (surfaceRoot != null) {
        ModelLoader.setCustomStateMapper(surfaceRoot, new StateMap.Builder().ignore(surfaceRoot.getIgnorableProperties()).build());
    }
}
Also used : BlockBranchThick(com.ferreusveritas.dynamictrees.blocks.BlockBranchThick) StateMap(net.minecraft.client.renderer.block.statemap.StateMap) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) BlockBranch(com.ferreusveritas.dynamictrees.blocks.BlockBranch) BlockSurfaceRoot(com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot)

Aggregations

BlockSurfaceRoot (com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot)3 BlockBranch (com.ferreusveritas.dynamictrees.blocks.BlockBranch)1 BlockBranchThick (com.ferreusveritas.dynamictrees.blocks.BlockBranchThick)1 BlockFruit (com.ferreusveritas.dynamictrees.blocks.BlockFruit)1 BlockFruitCocoa (com.ferreusveritas.dynamictrees.blocks.BlockFruitCocoa)1 Surround (com.ferreusveritas.dynamictrees.util.CoordUtils.Surround)1 Block (net.minecraft.block.Block)1 BlockSnow (net.minecraft.block.BlockSnow)1 BlockVine (net.minecraft.block.BlockVine)1 IBlockState (net.minecraft.block.state.IBlockState)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 StateMap (net.minecraft.client.renderer.block.statemap.StateMap)1 BlockPos (net.minecraft.util.math.BlockPos)1