common axe class for all rangeable axes

This commit is contained in:
Jottyfan
2026-01-02 23:41:09 +01:00
parent bccb0ef8c9
commit 1b7336e866
5 changed files with 16 additions and 59 deletions

View File

@@ -10,7 +10,10 @@ import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier; import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ToolMaterial;
import net.minecraft.world.item.Item.Properties; import net.minecraft.world.item.Item.Properties;
import net.minecraft.world.item.equipment.ArmorType; import net.minecraft.world.item.equipment.ArmorType;
@@ -52,7 +55,9 @@ public class QuicklyItems {
// TODO: rename tools to speedaxe and quickaxe instead of the powder version // TODO: rename tools to speedaxe and quickaxe instead of the powder version
public static final Item TOOL_SPEEDPOWDERAXE = registerItem("speedpowderaxe", public static final Item TOOL_SPEEDPOWDERAXE = registerItem("speedpowderaxe",
properties -> new ToolSpeedpowderAxe(properties)); properties -> new ToolRangeableAxe(
new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 800, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS), 7f,
-3.1f, properties, new HarvestRange(32, 64, 32)));
public static final Item TOOL_SPEEDPOWDERHOE = registerItem("speedpowderhoe", public static final Item TOOL_SPEEDPOWDERHOE = registerItem("speedpowderhoe",
properties -> new ToolSpeedpowderHoe(properties)); properties -> new ToolSpeedpowderHoe(properties));
public static final Item TOOL_SPEEDPOWDERPICKAXE = registerItem("speedpowderpickaxe", public static final Item TOOL_SPEEDPOWDERPICKAXE = registerItem("speedpowderpickaxe",
@@ -64,7 +69,9 @@ public class QuicklyItems {
public static final Item TOOL_SPEEDPOWDERWATERHOE = registerItem("speedpowderwaterhoe", public static final Item TOOL_SPEEDPOWDERWATERHOE = registerItem("speedpowderwaterhoe",
properties -> new ToolSpeedpowderWaterHoe(properties, QuicklyItems.TOOL_SPEEDPOWDERHOE)); properties -> new ToolSpeedpowderWaterHoe(properties, QuicklyItems.TOOL_SPEEDPOWDERHOE));
public static final Item TOOL_QUICKIEPOWDERAXE = registerItem("quickiepowderaxe", public static final Item TOOL_QUICKIEPOWDERAXE = registerItem("quickiepowderaxe",
properties -> new ToolQuickiepowderAxe(properties)); properties -> new ToolRangeableAxe(
new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 2400, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS), 7F,
-3.1F, properties, new HarvestRange(64, 128, 64)));
public static final Item TOOL_QUICKIEPOWDERHOE = registerItem("quickiepowderhoe", public static final Item TOOL_QUICKIEPOWDERHOE = registerItem("quickiepowderhoe",
properties -> new ToolQuickiepowderHoe(properties)); properties -> new ToolQuickiepowderHoe(properties));
public static final Item TOOL_QUICKIEPOWDERPICKAXE = registerItem("quickiepowderpickaxe", public static final Item TOOL_QUICKIEPOWDERPICKAXE = registerItem("quickiepowderpickaxe",

View File

@@ -1,26 +0,0 @@
package de.jottyfan.minecraft.item;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ToolMaterial;
/**
*
* @author jotty
*
*/
public class ToolQuickiepowderAxe extends ToolRangeableAxe {
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 2400, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
public ToolQuickiepowderAxe(Properties properties) {
super(MATERIAL, 7F, -3.1F, properties);
}
@Override
public HarvestRange getRange(ItemStack stack) {
// TODO: get the range from the stack
return new HarvestRange(64, 128, 64); // trees bigger than that are too heavy for one small axe...
}
}

View File

@@ -18,16 +18,18 @@ import net.minecraft.world.level.block.state.BlockState;
* @author jotty * @author jotty
* *
*/ */
public abstract class ToolRangeableAxe extends AxeItem implements ToolRangeable { public class ToolRangeableAxe extends AxeItem implements ToolRangeable {
protected ToolRangeableAxe(ToolMaterial material, float attackDamage, float attackSpeed, Properties properties) { private final HarvestRange range;
public ToolRangeableAxe(ToolMaterial material, float attackDamage, float attackSpeed, Properties properties, HarvestRange range) {
super(material, attackDamage, attackSpeed, properties); super(material, attackDamage, attackSpeed, properties);
this.range = range;
} }
@Override @Override
public HarvestRange getRange(ItemStack stack) { public HarvestRange getRange(ItemStack stack) {
// TODO: get the range from the stack return range;
return new HarvestRange(16, 32, 16);
} }
/** /**

View File

@@ -1,26 +0,0 @@
package de.jottyfan.minecraft.item;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ToolMaterial;
/**
*
* @author jotty
*
*/
public class ToolSpeedpowderAxe extends ToolRangeableAxe {
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 800, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
public ToolSpeedpowderAxe(Properties properties) {
super(MATERIAL, 7f, -3.1f, properties);
}
@Override
public HarvestRange getRange(ItemStack stack) {
// TODO: get the range from the stack
return new HarvestRange(32, 64, 32);
}
}

View File

@@ -6,7 +6,7 @@
" s " " s "
], ],
"key": { "key": {
"s": "quickky:speedingot", "s": "quickly:speedingot",
"c": [ "c": [
"minecraft:chest", "minecraft:chest",
"minecraft:barrel" "minecraft:barrel"