added tools

This commit is contained in:
Jottyfan
2024-11-23 19:31:37 +01:00
parent 7993693d9c
commit 6d2c1967fa
54 changed files with 1482 additions and 43 deletions

View File

@ -0,0 +1,63 @@
package de.jottyfan.quickiemod.item;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
import net.minecraft.item.AxeItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterial;
import net.minecraft.registry.tag.BlockTags;
/**
*
* @author jotty
*
*/
public abstract class ToolRangeableAxe extends AxeItem implements ToolRangeable {
protected ToolRangeableAxe(ToolMaterial material, float attackDamage, float attackSpeed, Item.Settings settings) {
super(material, attackDamage, attackSpeed, settings);
}
@Override
public HarvestRange getRange(ItemStack stack) {
// TODO: get the range from the stack
return new HarvestRange(16, 32, 16);
}
/**
* check if the block is a leaves block
*
* @param blockIn the block
* @return true or false
*/
private boolean isLeavesBlock(BlockState blockIn) {
boolean vanillaLeaves = blockIn.getBlock() instanceof LeavesBlock;
boolean terrestriaLeaves = false;
try {
Class<?> extendedLeavesBlock = Class.forName("com.terraformersmc.terraform.leaves.block.ExtendedLeavesBlock");
terrestriaLeaves = extendedLeavesBlock.isInstance(blockIn.getBlock());
} catch (ClassNotFoundException e) {
// no terrestria mod available, so ignore this
// using this approach instead of the instanceof functionality, we don't need to refer to terrestria
// and omit a crash on installations that do not have or want terrestria available
}
boolean blockTagLeaves = blockIn.isIn(BlockTags.LEAVES);
return vanillaLeaves || terrestriaLeaves || blockTagLeaves;
}
@Override
public boolean canBreakNeighbors(BlockState blockIn) {
return new ItemStack(this).isSuitableFor(blockIn) || isLeavesBlock(blockIn) || blockIn.isIn(BlockTags.LOGS);
}
@Override
public List<Block> getBlockList(Block block) {
return Lists.newArrayList(block);
}
}