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;
}
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);
}
}
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;
}
Aggregations