diff --git a/logs/latest.log b/logs/latest.log new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderHoe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderHoe.java new file mode 100644 index 0000000..78f5407 --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderHoe.java @@ -0,0 +1,100 @@ +package de.jottyfan.minecraft.quickiefabric.tools; + +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.google.common.collect.Lists; + +import de.jottyfan.minecraft.quickiefabric.init.RegistryManager; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.item.HoeItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.item.ToolMaterials; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Identifier; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3i; +import net.minecraft.util.registry.Registry; + +/** + * + * @author jotty + * + */ +public class ToolSpeedpowderHoe extends HoeItem implements ToolRangeable { + private static final Logger LOGGER = LogManager.getLogger(ToolSpeedpowderHoe.class); + public static final Integer DEFAULT_PLOW_RANGE = 4; + public HarvestRange range; + + public ToolSpeedpowderHoe() { + super(ToolMaterials.DIAMOND, 4, 2.0f, new Item.Settings().group(RegistryManager.QUICKIEFABRIC_GROUP)); + this.range = new HarvestRange(DEFAULT_PLOW_RANGE); + } + + @Override + public ActionResult useOnBlock(ItemUsageContext context) { + ActionResult res = super.useOnBlock(context); + if (!ActionResult.PASS.equals(res)) { + for (int x = -this.range.getxRange(); x <= this.range.getxRange(); x++) { + for (int y = -this.range.getyRange(); y <= this.range.getyRange(); y++) { + for (int z = -this.range.getzRange(); z <= this.range.getzRange(); z++) { + BlockHitResult bhr = new BlockHitResult(context.getHitPos(), Direction.UP, + context.getBlockPos().add(new Vec3i(x, y, z)), isDamageable()); + ItemUsageContext ctx = new ItemUsageContext(context.getPlayer(), context.getHand(), bhr); + super.useOnBlock(ctx); + } + } + } + } + return res; + } + + @Override + public HarvestRange getRange(ItemStack stack) { + // TODO: get range from stack + return range; + } + + @Override + public boolean canBreakNeighbors(BlockState blockState) { + boolean result = HOE_EFFECTIVE_ON.contains(blockState.getBlock()) || checkExternalBlock(blockState.getBlock()); + if (!result) { + if (!blockState.isAir()) { + LOGGER.debug("cannot break block {} with that speedpowder hoe", Registry.BLOCK.getId(blockState.getBlock())); + } + } + return result; + } + + private boolean checkExternalBlock(Block block) { + boolean result = false; + for (Identifier externalID : HOE_EXTERNAL_EFFECTIVE_ON) { + Block registeredBlock = Registry.BLOCK.get(externalID); // may be null if mods are not available + result = result || (registeredBlock != null && registeredBlock.equals(block)); + } + return result; + } + + @Override + public List getBlockList(Block block) { + return Lists.newArrayList(block); + } + +// @Override +// public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { +// CommonToolCode.onItemRightClick(worldIn, playerIn, handIn); +// return super.onItemRightClick(worldIn, playerIn, handIn); +// } +// +// @Override +// public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { +// CommonToolCode.addInformation(stack, worldIn, tooltip, flagIn); +// super.addInformation(stack, worldIn, tooltip, flagIn); +// } +} diff --git a/src/main/resources/assets/quickiefabric/models/item/speedpowderhoe.json b/src/main/resources/assets/quickiefabric/models/item/speedpowderhoe.json new file mode 100644 index 0000000..aeb580d --- /dev/null +++ b/src/main/resources/assets/quickiefabric/models/item/speedpowderhoe.json @@ -0,0 +1,6 @@ +{ + "parent": "item/wooden_hoe", + "textures": { + "layer0": "quickiefabric:item/speedpowderhoe" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/quickiefabric/textures/item/speedpowderhoe.png b/src/main/resources/assets/quickiefabric/textures/item/speedpowderhoe.png new file mode 100644 index 0000000..87e0627 Binary files /dev/null and b/src/main/resources/assets/quickiefabric/textures/item/speedpowderhoe.png differ diff --git a/src/main/resources/data/quickiefabric/recipes/speedpowderhoe.json b/src/main/resources/data/quickiefabric/recipes/speedpowderhoe.json new file mode 100644 index 0000000..3591136 --- /dev/null +++ b/src/main/resources/data/quickiefabric/recipes/speedpowderhoe.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "ss", + " |", + " |" + ], + "key": { + "s": { + "item": "quickiefabric:speedpowder" + }, + "|": { + "item": "minecraft:stick" + } + }, + "result": { + "item": "quickiefabric:speedpowderhoe", + "count": 1 + } +} \ No newline at end of file