Search in sources :

Example 6 with Surround

use of com.ferreusveritas.dynamictrees.util.CoordUtils.Surround 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 7 with Surround

use of com.ferreusveritas.dynamictrees.util.CoordUtils.Surround in project DynamicTrees by DynamicTreesTeam.

the class BlockBranchThick method setRadius.

@Override
public int setRadius(World world, BlockPos pos, int radius, EnumFacing originDir, int flags) {
    // If the radius is <= 8 then we can just set the block as normal and move on
    if (radius <= RADMAX_NORMAL) {
        return super.setRadius(world, pos, radius, originDir, flags);
    }
    ReplaceableState[] repStates = new ReplaceableState[8];
    boolean setable = true;
    for (Surround dir : Surround.values()) {
        BlockPos dPos = pos.add(dir.getOffset());
        ReplaceableState rep = getReplaceability(world, dPos, pos);
        repStates[dir.ordinal()] = rep;
        if (rep == ReplaceableState.BLOCKING) {
            setable = false;
            break;
        }
    }
    if (setable) {
        int setRadius = super.setRadius(world, pos, radius, originDir, flags);
        for (Surround dir : Surround.values()) {
            BlockPos dPos = pos.add(dir.getOffset());
            ReplaceableState rep = repStates[dir.ordinal()];
            if (rep == ReplaceableState.REPLACEABLE) {
                world.setBlockState(dPos, ModBlocks.blockTrunkShell.getDefaultState().withProperty(BlockTrunkShell.COREDIR, dir.getOpposite()), flags);
            }
        }
        return setRadius;
    } else {
        return super.setRadius(world, pos, RADMAX_NORMAL, originDir, flags);
    }
}
Also used : Surround(com.ferreusveritas.dynamictrees.util.CoordUtils.Surround) BlockPos(net.minecraft.util.math.BlockPos)

Example 8 with Surround

use of com.ferreusveritas.dynamictrees.util.CoordUtils.Surround in project DynamicTrees by DynamicTreesTeam.

the class BlockBranchThick method getReplaceability.

public ReplaceableState getReplaceability(World world, BlockPos pos, BlockPos corePos) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    if (block == ModBlocks.blockTrunkShell) {
        // Determine if this shell belongs to the trunk.  Block otherwise.
        Surround surr = state.getValue(BlockTrunkShell.COREDIR);
        return pos.add(surr.getOffset()).equals(corePos) ? ReplaceableState.SHELL : ReplaceableState.BLOCKING;
    }
    if (block.isReplaceable(world, pos) || block instanceof BlockBush) {
        return ReplaceableState.REPLACEABLE;
    }
    if (TreeHelper.isTreePart(block)) {
        return ReplaceableState.TREEPART;
    }
    if (block instanceof BlockSurfaceRoot) {
        return ReplaceableState.TREEPART;
    }
    if (getFamily().getCommonSpecies().isAcceptableSoil(world, pos, state)) {
        return ReplaceableState.REPLACEABLE;
    }
    return ReplaceableState.BLOCKING;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Surround(com.ferreusveritas.dynamictrees.util.CoordUtils.Surround) Block(net.minecraft.block.Block) BlockBush(net.minecraft.block.BlockBush)

Aggregations

Surround (com.ferreusveritas.dynamictrees.util.CoordUtils.Surround)8 BlockPos (net.minecraft.util.math.BlockPos)5 IBlockState (net.minecraft.block.state.IBlockState)4 EnumFacing (net.minecraft.util.EnumFacing)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 ArrayList (java.util.ArrayList)2 Block (net.minecraft.block.Block)2 Vec3d (net.minecraft.util.math.Vec3d)2 Vec3i (net.minecraft.util.math.Vec3i)2 Vector3f (org.lwjgl.util.vector.Vector3f)2 BlockSurfaceRoot (com.ferreusveritas.dynamictrees.blocks.BlockSurfaceRoot)1 Nullable (javax.annotation.Nullable)1 BlockBush (net.minecraft.block.BlockBush)1