Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ dependencies {
//runtimeOnly("cc.tweaked:cc-tweaked-${cc_tweaked_minecraft_version}-forge:${cc_tweaked_version}")
}

if (dynamic_trees_enable.toBoolean()) {
compileOnly("com.dtteam.dynamictrees:dynamictrees-neoforge-${dynamic_trees_minecraft_version}:${dynamic_trees_version}")
}

runtimeOnly("dev.architectury:architectury-neoforge:13.0.8")
implementation("dev.ftb.mods:ftb-chunks-neoforge:2101.1.1")
implementation("dev.ftb.mods:ftb-teams-neoforge:2101.1.0")
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ cc_tweaked_enable = true
cc_tweaked_minecraft_version = 1.21.1
cc_tweaked_version = 1.114.2

dynamic_trees_enable = true
dynamic_trees_minecraft_version = 1.21.1
dynamic_trees_version = 1.5.0-BETA07

# mod options
mod_id = create
mod_name = Create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

import javax.annotation.Nullable;

import com.dtteam.dynamictrees.tree.TreeHelper;
import com.dtteam.dynamictrees.block.branch.BranchBlock;
import com.dtteam.dynamictrees.block.branch.TrunkShellBlock;
import com.dtteam.dynamictrees.api.network.BranchDestructionData;
import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;

public class DynamicTree extends AbstractBlockBreakQueue {

Expand All @@ -21,47 +27,46 @@ public DynamicTree(BlockPos startCutPos) {
}

public static boolean isDynamicBranch(Block block) {
//return TreeHelper.isBranch(block) || block instanceof TrunkShellBlock;
return false;
return TreeHelper.isBranch(block) || block instanceof TrunkShellBlock;
}


@Override
public void destroyBlocks(Level world, ItemStack toDamage, @Nullable Player playerEntity, BiConsumer<BlockPos, ItemStack> drop) {

// BranchBlock start = TreeHelper.getBranch(world.getBlockState(startCutPos));
// if (start == null) //if start is null, it was not a branch
// start = setBranchToShellMuse(world, world.getBlockState(startCutPos)); //we check for a trunk shell instead
//
// if (start == null) //if it is null again, it was neither a branch nor a trunk shell and thus we return
// return;
//
// // Play and render block break sound and particles
// world.levelEvent(null, 2001, startCutPos, Block.getId(world.getBlockState(startCutPos)));
//
// // Actually breaks the tree
// BranchDestructionData data = start.destroyBranchFromNode(world, startCutPos, Direction.DOWN, false, playerEntity);
//
// // Feed all the tree drops to drop bi-consumer
// data.leavesDrops.forEach(stackPos -> drop.accept(stackPos.pos.offset(startCutPos), stackPos.stack));
// start.getFamily().getCommonSpecies().getBranchesDrops(world, data.woodVolume).forEach(stack -> drop.accept(startCutPos, stack));
BranchBlock start = TreeHelper.getBranch(world.getBlockState(startCutPos));
if (start == null) //if start is null, it was not a branch
start = setBranchToShellMuse(world, world.getBlockState(startCutPos)); //we check for a trunk shell instead

if (start == null) //if it is null again, it was neither a branch nor a trunk shell and thus we return
return;

// Play and render block break sound and particles
world.levelEvent(null, 2001, startCutPos, Block.getId(world.getBlockState(startCutPos)));

// Actually breaks the tree
BranchDestructionData data = start.destroyBranchFromNode(world, startCutPos, Direction.DOWN, false, playerEntity);

// Feed all the tree drops to drop bi-consumer
data.leavesDrops.forEach(stackPos -> drop.accept(stackPos.pos.offset(startCutPos), stackPos.stack));
start.getFamily().getCommonSpecies().getBranchesDrops(world, data.woodVolume).forEach(stack -> drop.accept(startCutPos, stack));

}


// private BranchBlock setBranchToShellMuse(Level world, BlockState state) {
//
// Block block = state.getBlock();
// if (block instanceof TrunkShellBlock){
// TrunkShellBlock.ShellMuse muse = ((TrunkShellBlock)block).getMuse(world, startCutPos);
// if (muse != null){
// startCutPos = muse.pos; //the cut pos is moved to the center of the trunk
// return TreeHelper.getBranch(muse.state);
// }
// }
//
// return null;
// }
private BranchBlock setBranchToShellMuse(Level world, BlockState state) {

Block block = state.getBlock();
if (block instanceof TrunkShellBlock){
TrunkShellBlock.ShellMuse muse = ((TrunkShellBlock)block).getMuse(world, state, startCutPos);
if (muse != null){
startCutPos = muse.pos(); //the cut pos is moved to the center of the trunk
return TreeHelper.getBranch(muse.state());
}
}

return null;
}


}