mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-09 19:44:40 +01:00
Fix up the dynamic trees
This commit is contained in:
parent
918c8082b1
commit
9763631984
3 changed files with 31 additions and 4 deletions
|
@ -107,6 +107,10 @@ repositories {
|
||||||
maven {
|
maven {
|
||||||
url = "https://www.cursemaven.com"
|
url = "https://www.cursemaven.com"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
//location of the maven for dynamic trees
|
||||||
|
url "http://harleyoconnor.com/maven"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
|
@ -126,7 +130,7 @@ dependencies {
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.16.4:${jei_version}")
|
runtimeOnly fg.deobf("mezz.jei:jei-1.16.4:${jei_version}")
|
||||||
|
|
||||||
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
|
// 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
|
// i'll leave this here commented for easier testing
|
||||||
|
|
|
@ -6,10 +6,12 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.ferreusveritas.dynamictrees.api.TreeHelper;
|
import com.ferreusveritas.dynamictrees.api.TreeHelper;
|
||||||
import com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock;
|
import com.ferreusveritas.dynamictrees.blocks.branches.BranchBlock;
|
||||||
|
import com.ferreusveritas.dynamictrees.blocks.branches.TrunkShellBlock;
|
||||||
import com.ferreusveritas.dynamictrees.util.BranchDestructionData;
|
import com.ferreusveritas.dynamictrees.util.BranchDestructionData;
|
||||||
import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue;
|
import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -17,7 +19,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class DynamicTree extends AbstractBlockBreakQueue {
|
public class DynamicTree extends AbstractBlockBreakQueue {
|
||||||
private final BlockPos startCutPos;
|
private BlockPos startCutPos;
|
||||||
|
|
||||||
public DynamicTree(BlockPos startCutPos) {
|
public DynamicTree(BlockPos startCutPos) {
|
||||||
this.startCutPos = startCutPos;
|
this.startCutPos = startCutPos;
|
||||||
|
@ -26,9 +28,16 @@ public class DynamicTree extends AbstractBlockBreakQueue {
|
||||||
@Override
|
@Override
|
||||||
public void destroyBlocks(World world, ItemStack toDamage, @Nullable PlayerEntity playerEntity, BiConsumer<BlockPos, ItemStack> drop) {
|
public void destroyBlocks(World world, ItemStack toDamage, @Nullable PlayerEntity playerEntity, BiConsumer<BlockPos, ItemStack> drop) {
|
||||||
BranchBlock start = TreeHelper.getBranch(world.getBlockState(startCutPos));
|
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;
|
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);
|
BranchDestructionData data = start.destroyBranchFromNode(world, startCutPos, Direction.DOWN, false, playerEntity);
|
||||||
|
|
||||||
// Feed all the tree drops to drop bi-consumer
|
// 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));
|
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) {
|
public static boolean isDynamicBranch(Block block) {
|
||||||
return TreeHelper.isBranch(block);
|
return TreeHelper.isBranch(block) || block instanceof TrunkShellBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,6 +410,8 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
|
||||||
return true;
|
return true;
|
||||||
if (block instanceof ChorusPlantBlock)
|
if (block instanceof ChorusPlantBlock)
|
||||||
return true;
|
return true;
|
||||||
|
if (TreeCutter.canDynamicTreeCutFrom(block))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue