use of com.ferreusveritas.dynamictrees.trees.TreeFamily in project DynamicTrees by DynamicTreesTeam.
the class BlockBranchBasic method getHydrationCell.
// /////////////////////////////////////////
// GROWTH
// /////////////////////////////////////////
@Override
public ICell getHydrationCell(IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing dir, ILeavesProperties leavesProperties) {
TreeFamily thisTree = getFamily();
if (leavesProperties.getTree() == thisTree) {
// The requesting leaves must match the tree for hydration to occur
int radiusAndMeta = thisTree.getRadiusForCellKit(world, pos, state, dir, this);
int radius = CellMetadata.getRadius(radiusAndMeta);
int metadata = CellMetadata.getMeta(radiusAndMeta);
return leavesProperties.getCellKit().getCellForBranch(radius, metadata);
} else {
return CellNull.NULLCELL;
}
}
use of com.ferreusveritas.dynamictrees.trees.TreeFamily in project DynamicTrees by DynamicTreesTeam.
the class ClientProxy method registerModels.
@Override
public void registerModels() {
// Resolve all leaves properties so the LeavesStateMapper can function properly
LeavesPropertiesJson.resolveAll();
// BLOCKS
ModelLoader.setCustomStateMapper(ModBlocks.blockRootyDirt, new StateMap.Builder().ignore(BlockRooty.LIFE).build());
ModelLoader.setCustomStateMapper(ModBlocks.blockRootyDirtSpecies, new StateMap.Builder().ignore(BlockRooty.LIFE).build());
ModelLoader.setCustomStateMapper(ModBlocks.blockRootySand, new StateMap.Builder().ignore(BlockRooty.LIFE).build());
// Register Potion Mesher
for (DendroPotion.DendroPotionType type : DendroPotion.DendroPotionType.values()) {
ModelHelper.regModel(ModItems.dendroPotion, type.getIndex());
}
// Register DirtBucket Mesher
ModelHelper.regModel(ModItems.dirtBucket);
// Register Woodland Staff Mesher
ModelHelper.regModel(ModItems.treeStaff);
// Register Meshers for Branches and Seeds
for (TreeFamily tree : ModTrees.baseFamilies) {
// Register Branch itemBlock
ModelHelper.regModel(tree.getDynamicBranch());
// Register Seed Item Models
ModelHelper.regModel(tree.getCommonSpecies().getSeed());
// Register custom state mapper for branch
ModelHelper.regModel(tree);
}
// Sapling
ModelHelper.setGenericStateMapper(ModBlocks.blockDynamicSapling, new ModelResourceLocation(new ResourceLocation(ModConstants.MODID, "sapling"), ""));
// Setup the state mapper for the trunk shell
ModelLoader.setCustomStateMapper(ModBlocks.blockTrunkShell, new StateMap.Builder().ignore(BlockTrunkShell.COREDIR).build());
// Register models for cactus
ModelLoader.setCustomStateMapper(ModTrees.dynamicCactus.getDynamicBranch(), new StateMap.Builder().ignore(BlockBranchCactus.TRUNK, BlockBranchCactus.ORIGIN).build());
ModelHelper.regModel(ModTrees.dynamicCactus.getDynamicBranch());
ModelHelper.regModel(ModTrees.dynamicCactus.getCommonSpecies().getSeed());
// Special seed for apple
ModelHelper.regModel(Species.REGISTRY.getValue(new ResourceLocation(ModConstants.MODID, "apple")).getSeed());
// Set state mappers for all blocks created with the LeavesPaging object
LeavesPaging.setStateMappers();
// Register the file loader for Branch models
ModelLoaderRegistry.registerLoader(new ModelLoaderBlockBranchBasic());
ModelLoaderRegistry.registerLoader(new ModelLoaderBlockBranchCactus());
ModelLoaderRegistry.registerLoader(new ModelLoaderBlockBranchThick());
ModelLoaderRegistry.registerLoader(new ModelLoaderBlockSurfaceRoot());
ModelLoaderRegistry.registerLoader(new ModelLoaderSapling());
}
use of com.ferreusveritas.dynamictrees.trees.TreeFamily in project DynamicTrees by DynamicTreesTeam.
the class JoCode method cleanupFrankentree.
/**
* Attempt to clean up fused trees that have multiple root blocks by simply destroying them both messily
*/
protected void cleanupFrankentree(World world, BlockPos treePos, IBlockState treeState, List<BlockPos> endPoints, SafeChunkBounds safeBounds) {
Set<BlockPos> blocksToDestroy = new HashSet<>();
BlockBranch branch = TreeHelper.getBranch(treeState);
MapSignal signal = new MapSignal(new NodeCollector(blocksToDestroy));
signal.destroyLoopedNodes = false;
signal.trackVisited = true;
branch.analyse(treeState, world, treePos, null, signal);
BlockBranch.destroyMode = EnumDestroyMode.IGNORE;
for (BlockPos pos : blocksToDestroy) {
if (safeBounds.inBounds(pos, false)) {
IBlockState branchState = world.getBlockState(pos);
Optional<BlockBranch> branchBlock = TreeHelper.getBranchOpt(branchState);
if (branchBlock.isPresent()) {
int radius = branchBlock.get().getRadius(branchState);
TreeFamily family = branchBlock.get().getFamily();
Species species = family.getCommonSpecies();
if (family.getPrimaryThickness() == radius) {
ILeavesProperties leavesProperties = species.getLeavesProperties();
if (leavesProperties != LeavesProperties.NULLPROPERTIES) {
SimpleVoxmap leafCluster = leavesProperties.getCellKit().getLeafCluster();
if (leafCluster != LeafClusters.NULLMAP) {
for (Cell cell : leafCluster.getAllNonZeroCells()) {
BlockPos delPos = pos.add(cell.getPos());
if (safeBounds.inBounds(delPos, false)) {
IBlockState leavesState = world.getBlockState(delPos);
if (TreeHelper.isLeaves(leavesState)) {
BlockDynamicLeaves leavesBlock = (BlockDynamicLeaves) leavesState.getBlock();
if (leavesProperties.getTree() == leavesBlock.getProperties(leavesState).getTree()) {
world.setBlockState(delPos, ModBlocks.blockStates.air, 2);
}
}
}
}
}
}
}
world.setBlockState(pos, ModBlocks.blockStates.air, 2);
}
}
}
BlockBranch.destroyMode = EnumDestroyMode.HARVEST;
// Now wreck out all surrounding leaves. Let them grow back naturally.
/*if(!endPoints.isEmpty()) {
BlockBounds bounds = new BlockBounds(endPoints);
bounds.expand(3);
for(BlockPos pos : bounds.iterate()) {
if(safeBounds.inBounds(pos, false)) {
if(TreeHelper.isLeaves(world.getBlockState(pos))) {
world.setBlockState(pos, ModBlocks.blockStates.air, 2);
}
}
}
}*/
}
use of com.ferreusveritas.dynamictrees.trees.TreeFamily in project DynamicTrees by DynamicTreesTeam.
the class ClientProxy method discoverWoodColors.
private void discoverWoodColors() {
Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter = location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
for (TreeFamily family : Species.REGISTRY.getValuesCollection().stream().map(s -> s.getFamily()).distinct().collect(Collectors.toList())) {
// For roots
family.woodColor = 0xFFF1AE;
if (family != TreeFamily.NULLFAMILY) {
IBlockState state = family.getPrimitiveLog();
if (state.getBlock() != Blocks.AIR) {
IModel model = QuadManipulator.getModelForState(state);
ResourceLocation resloc = QuadManipulator.getModelTexture(model, bakedTextureGetter, state, EnumFacing.UP);
if (resloc != null) {
PixelBuffer pixbuf = new PixelBuffer(bakedTextureGetter.apply(resloc));
int u = pixbuf.w / 16;
PixelBuffer center = new PixelBuffer(u * 8, u * 8);
pixbuf.blit(center, u * -8, u * -8);
family.woodColor = center.averageColor();
}
}
}
}
}
use of com.ferreusveritas.dynamictrees.trees.TreeFamily in project DynamicTrees by DynamicTreesTeam.
the class FeatureGenFlareBottom method flareBottom.
/**
* Put a cute little flare on the bottom of the dark oaks
*
* @param world The world
* @param rootPos The position of the rooty dirt block of the tree
* @return The radius of the bottom trunk section after operation
*/
public void flareBottom(World world, BlockPos rootPos, Species species) {
TreeFamily family = species.getFamily();
// Put a cute little flare on the bottom of the dark oaks
int radius3 = TreeHelper.getRadius(world, rootPos.up(3));
if (radius3 > 6) {
family.getDynamicBranch().setRadius(world, rootPos.up(2), radius3 + 1, EnumFacing.UP);
family.getDynamicBranch().setRadius(world, rootPos.up(1), radius3 + 2, EnumFacing.UP);
}
}
Aggregations