Fix up the dynamic trees

This commit is contained in:
grimmauld 2021-06-26 19:13:44 +02:00
parent 918c8082b1
commit 9763631984
3 changed files with 31 additions and 4 deletions

View File

@ -107,6 +107,10 @@ repositories {
maven {
url = "https://www.cursemaven.com"
}
maven {
//location of the maven for dynamic trees
url "http://harleyoconnor.com/maven"
}
}
configurations {
@ -126,7 +130,7 @@ dependencies {
runtimeOnly fg.deobf("mezz.jei:jei-1.16.4:${jei_version}")
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
implementation fg.deobf("curse.maven:dynamictrees-252818:3302576")
implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta12.1")
// i'll leave this here commented for easier testing

View File

@ -6,10 +6,12 @@ import javax.annotation.Nullable;
import com.ferreusveritas.dynamictrees.api.TreeHelper;
import com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock;
import com.ferreusveritas.dynamictrees.blocks.branches.TrunkShellBlock;
import com.ferreusveritas.dynamictrees.util.BranchDestructionData;
import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
@ -17,7 +19,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class DynamicTree extends AbstractBlockBreakQueue {
private final BlockPos startCutPos;
private BlockPos startCutPos;
public DynamicTree(BlockPos startCutPos) {
this.startCutPos = startCutPos;
@ -26,9 +28,16 @@ public class DynamicTree extends AbstractBlockBreakQueue {
@Override
public void destroyBlocks(World world, ItemStack toDamage, @Nullable PlayerEntity playerEntity, BiConsumer<BlockPos, ItemStack> drop) {
BranchBlock start = TreeHelper.getBranch(world.getBlockState(startCutPos));
if (start == null)
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.playEvent(null, 2001, startCutPos, Block.getStateId(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
@ -36,7 +45,19 @@ public class DynamicTree extends AbstractBlockBreakQueue {
start.getLogDrops(world, startCutPos, data.species, data.woodVolume).forEach(stack -> drop.accept(startCutPos, stack));
}
private BranchBlock setBranchToShellMuse(World 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;
}
public static boolean isDynamicBranch(Block block) {
return TreeHelper.isBranch(block);
return TreeHelper.isBranch(block) || block instanceof TrunkShellBlock;
}
}

View File

@ -410,6 +410,8 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
return true;
if (block instanceof ChorusPlantBlock)
return true;
if (TreeCutter.canDynamicTreeCutFrom(block))
return true;
return false;
}