diff --git a/gradle.properties b/gradle.properties index 9c3a176..3afc9a7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.21.3+build.2 loader_version=0.16.9 # Mod Properties -mod_version=1.21.3.1 +mod_version=1.21.3.2 maven_group=de.jottyfan.quickiemod archives_base_name=quickiemod diff --git a/src/main/java/de/jottyfan/quickiemod/event/EventBlockBreak.java b/src/main/java/de/jottyfan/quickiemod/event/EventBlockBreak.java index e0de73e..53ccc44 100644 --- a/src/main/java/de/jottyfan/quickiemod/event/EventBlockBreak.java +++ b/src/main/java/de/jottyfan/quickiemod/event/EventBlockBreak.java @@ -3,6 +3,7 @@ package de.jottyfan.quickiemod.event; import java.util.ArrayList; import java.util.List; +import de.jottyfan.quickiemod.Quickiemod; import de.jottyfan.quickiemod.item.HarvestRange; import de.jottyfan.quickiemod.item.ModItems; import de.jottyfan.quickiemod.item.ToolRangeable; @@ -63,32 +64,38 @@ public class EventBlockBreak { BlockPos pos, PlayerEntity player) { List validBlocks = tool.getBlockList(currentBlock); HarvestRange range = tool.getRange(itemStack); - List visitedBlocks = new ArrayList<>(); - if (tool instanceof ToolSpeedpowderAxe) { - return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS, - player, true); - } else if (ModItems.TOOL_SPEEDPOWDERPICKAXE.getName().equals(tool.getName())) { - return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, - player, false); - } else if (ModItems.TOOL_SPEEDPOWDERSHOVEL.getName().equals(tool.getName())) { - return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, - player, false); - } else if (ModItems.TOOL_SPEEDPOWDERHOE.getName().equals(tool.getName())) { - return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, - player, false); - } else if (ModItems.TOOL_QUICKIEPOWDERAXE.getName().equals(tool.getName())) { + if (tool instanceof Item) { + Item toolItem = (Item) tool; // a rangeable tool should always be an item + List visitedBlocks = new ArrayList<>(); + if (tool instanceof ToolSpeedpowderAxe) { return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS, player, true); - } else if (ModItems.TOOL_QUICKIEPOWDERPICKAXE.getName().equals(tool.getName())) { - return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, - player, false); - } else if (ModItems.TOOL_QUICKIEPOWDERSHOVEL.getName().equals(tool.getName())) { - return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, - player, false); - } else if (ModItems.TOOL_QUICKIEPOWDERHOE.getName().equals(tool.getName())) { - return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, - player, false); + } else if (ModItems.TOOL_SPEEDPOWDERPICKAXE.getName().equals(toolItem.getName())) { + return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, + player, false); + } else if (ModItems.TOOL_SPEEDPOWDERSHOVEL.getName().equals(toolItem.getName())) { + return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, + player, false); + } else if (ModItems.TOOL_SPEEDPOWDERHOE.getName().equals(toolItem.getName())) { + return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, + player, false); + } else if (ModItems.TOOL_QUICKIEPOWDERAXE.getName().equals(toolItem.getName())) { + return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS, + player, true); + } else if (ModItems.TOOL_QUICKIEPOWDERPICKAXE.getName().equals(toolItem.getName())) { + return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, + player, false); + } else if (ModItems.TOOL_QUICKIEPOWDERSHOVEL.getName().equals(toolItem.getName())) { + return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, + player, false); + } else if (ModItems.TOOL_QUICKIEPOWDERHOE.getName().equals(toolItem.getName())) { + return breakBlockRecursive(visitedBlocks, world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, + player, false); + } else { + return 0; + } } else { + Quickiemod.LOGGER.warn("using a tool that is not an item - no rangeable operations are possible."); return 0; } } diff --git a/src/main/java/de/jottyfan/quickiemod/item/ToolRangeable.java b/src/main/java/de/jottyfan/quickiemod/item/ToolRangeable.java index 48e2937..bd32cc6 100644 --- a/src/main/java/de/jottyfan/quickiemod/item/ToolRangeable.java +++ b/src/main/java/de/jottyfan/quickiemod/item/ToolRangeable.java @@ -5,7 +5,6 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; /** * @@ -14,13 +13,6 @@ import net.minecraft.text.Text; */ public interface ToolRangeable { - /** - * dummy to have a getName method that comes with the item - * - * @return the name - */ - public Text getName(); - /** * @param stack the item stack that keeps the range * @return range of blocks to be harvested