use of com.ferreusveritas.dynamictrees.util.BranchDestructionData in project DynamicTrees by DynamicTreesTeam.
the class BlockRooty method destroyTree.
public void destroyTree(World world, BlockPos rootPos) {
Optional<BlockBranch> branch = TreeHelper.getBranchOpt(world.getBlockState(rootPos.up()));
if (branch.isPresent()) {
BranchDestructionData destroyData = branch.get().destroyBranchFromNode(world, rootPos.up(), EnumFacing.DOWN, true);
EntityFallingTree.dropTree(world, destroyData, new ArrayList<ItemStack>(0), DestroyType.ROOT);
}
}
use of com.ferreusveritas.dynamictrees.util.BranchDestructionData in project DynamicTrees by DynamicTreesTeam.
the class EntityFallingTree method setupFromNBT.
public void setupFromNBT(NBTTagCompound tag) {
destroyData = new BranchDestructionData(tag);
if (destroyData.getNumBranches() == 0) {
setDead();
}
destroyType = DestroyType.values()[tag.getInteger("destroytype")];
geomCenter = new Vec3d(tag.getDouble("geomx"), tag.getDouble("geomy"), tag.getDouble("geomz"));
massCenter = new Vec3d(tag.getDouble("massx"), tag.getDouble("massy"), tag.getDouble("massz"));
this.setEntityBoundingBox(this.buildAABBFromDestroyData(destroyData).offset(posX, posY, posZ));
this.renderBB = renderNormAABB.offset(posX, posY, posZ);
onFire = tag.getBoolean("onfire");
}
use of com.ferreusveritas.dynamictrees.util.BranchDestructionData in project DynamicTrees by DynamicTreesTeam.
the class BlockBranch method sloppyBreak.
protected void sloppyBreak(World world, BlockPos cutPos, DestroyType destroyType) {
// Do the actual destruction
BranchDestructionData destroyData = destroyBranchFromNode(world, cutPos, EnumFacing.DOWN, false);
// Sloppy breaks return no goodies.
List<ItemStack> woodDropList = Collections.EMPTY_LIST;
destroyData.leavesDrops.clear();
// This will drop the EntityFallingTree into the world
EntityFallingTree.dropTree(world, destroyData, woodDropList, destroyType);
}
use of com.ferreusveritas.dynamictrees.util.BranchDestructionData in project DynamicTrees by DynamicTreesTeam.
the class ModelEntityFallingTree method generateTreeQuads.
public List<TreeQuadData> generateTreeQuads(EntityFallingTree entity, World world) {
final BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
final BranchDestructionData destructionData = entity.getDestroyData();
final Species species = destructionData.species;
final BlockPos cutPos = destructionData.cutPos;
final EnumFacing cutDir = destructionData.cutDir;
final ArrayList<TreeQuadData> treeQuads = new ArrayList<>();
if (destructionData.getNumBranches() <= 0) {
return treeQuads;
}
// Draw the ring texture cap on the cut block
IExtendedBlockState exState = destructionData.getBranchBlockState(0);
if (exState == null) {
return treeQuads;
}
for (EnumFacing face : EnumFacing.VALUES) {
exState = exState.withProperty(BlockBranch.CONNECTIONS[face.getIndex()], face == cutDir.getOpposite() ? 8 : 0);
}
int radius = ((BlockBranch) exState.getBlock()).getRadius(exState);
float offset = (8 - Math.min(radius, BlockBranch.RADMAX_NORMAL)) / 16f;
// Since we source the blockState from the destruction data it will always be the same
IBakedModel branchModel = dispatcher.getModelForState(exState.getClean());
treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(branchModel, exState, new Vec3d(BlockPos.ORIGIN.offset(cutDir)).scale(offset), new EnumFacing[] { cutDir }), 0xFFFFFFFF, exState.getClean()));
// Draw the rest of the tree/branch
for (int index = 0; index < destructionData.getNumBranches(); index++) {
Block previousBranch = exState.getBlock();
exState = destructionData.getBranchBlockState(index);
if (// Update the branch model only if the block is different
!previousBranch.equals(exState.getBlock())) {
branchModel = dispatcher.getModelForState(exState.getClean());
}
BlockPos relPos = destructionData.getBranchRelPos(index);
treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(branchModel, exState, new Vec3d(relPos)), 0xFFFFFFFF, exState.getClean()));
}
// Draw the leaves
HashMap<BlockPos, IBlockState> leavesClusters = species.getFamily().getFellingLeavesClusters(destructionData);
if (leavesClusters != null) {
for (Entry<BlockPos, IBlockState> leafLoc : leavesClusters.entrySet()) {
IBlockState leafState = leafLoc.getValue();
if (leafState instanceof IExtendedBlockState) {
leafState = ((IExtendedBlockState) leafState).getClean();
}
treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(dispatcher.getModelForState(leafState), leafLoc.getValue(), new Vec3d(leafLoc.getKey())), species.getLeavesProperties().foliageColorMultiplier(leafState, world, cutPos), leafState));
}
} else {
for (int index = 0; index < destructionData.getNumLeaves(); index++) {
BlockPos relPos = destructionData.getLeavesRelPos(index);
IBlockState state = destructionData.getLeavesBlockState(index);
IBakedModel leavesModel = dispatcher.getModelForState(state);
treeQuads.addAll(toTreeQuadData(QuadManipulator.getQuads(leavesModel, state, new Vec3d(relPos)), destructionData.getLeavesProperties(index).foliageColorMultiplier(state, world, cutPos.add(relPos)), state));
}
}
return treeQuads;
}
use of com.ferreusveritas.dynamictrees.util.BranchDestructionData in project DynamicTrees by DynamicTreesTeam.
the class ModelEntityFallingTree method getBrightness.
public static int getBrightness(EntityFallingTree entity) {
BranchDestructionData destructionData = entity.getDestroyData();
World world = entity.getEntityWorld();
return world.getBlockState(destructionData.cutPos).getPackedLightmapCoords(world, destructionData.cutPos);
}
Aggregations