diff --git a/gradle.properties b/gradle.properties index dab30e0..06dd847 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.3-pre2+build.5 loader_version=0.14.24 # Mod Properties - mod_version = 1.20.3.2 + mod_version = 1.20.3.3 maven_group = de.jottyfan.minecraft archives_base_name = quickiefabric diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java index 8491270..0320af1 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java @@ -81,6 +81,9 @@ public class EventBlockBreak { } else if (QuickieTools.QUICKIEPOWDERSHOVEL.equals(tool)) { return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player, false); + } else if (QuickieTools.QUICKIEPOWDERHOE.equals(tool)) { + return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, + player, false); } else { return 0; } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java index a43eef4..34a3714 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java @@ -110,6 +110,8 @@ public class RegistryManager { stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERAXE)); stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERPICKAXE)); stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERSHOVEL)); + stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERHOE)); + stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERWATERHOE)); stacks.add(new ItemStack(QuickieBlocks.DIRT_SALPETER)); stacks.add(new ItemStack(QuickieBlocks.ORE_NETHER_SULPHOR)); stacks.add(new ItemStack(QuickieBlocks.ORE_SALPETER)); @@ -271,6 +273,8 @@ public class RegistryManager { registerItem(QuickieTools.QUICKIEPOWDERAXE, "quickiepowderaxe"); registerItem(QuickieTools.QUICKIEPOWDERPICKAXE, "quickiepowderpickaxe"); registerItem(QuickieTools.QUICKIEPOWDERSHOVEL, "quickiepowdershovel"); + registerItem(QuickieTools.QUICKIEPOWDERHOE, "quickiepowderhoe"); + registerItem(QuickieTools.QUICKIEPOWDERWATERHOE, "quickiepowderwaterhoe"); } public static final void registerContainer() { diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/QuickieTools.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/QuickieTools.java index be940a5..c990482 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/QuickieTools.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/QuickieTools.java @@ -14,4 +14,6 @@ public class QuickieTools { public static final ToolQuickiepowderAxe QUICKIEPOWDERAXE = new ToolQuickiepowderAxe(); public static final ToolQuickiepowderPickaxe QUICKIEPOWDERPICKAXE = new ToolQuickiepowderPickaxe(); public static final ToolQuickiepowderShovel QUICKIEPOWDERSHOVEL = new ToolQuickiepowderShovel(); + public static final ToolQuickiepowderHoe QUICKIEPOWDERHOE = new ToolQuickiepowderHoe(); + public static final ToolQuickiepowderWaterHoe QUICKIEPOWDERWATERHOE = new ToolQuickiepowderWaterHoe(); } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolQuickiepowderHoe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolQuickiepowderHoe.java new file mode 100644 index 0000000..8247e6c --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolQuickiepowderHoe.java @@ -0,0 +1,18 @@ +package de.jottyfan.minecraft.quickiefabric.tools; + +import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.minecraft.item.ToolMaterials; + +/** + * + * @author jotty + * + */ +public class ToolQuickiepowderHoe extends ToolRangeableHoe { + + public static final Integer DEFAULT_PLOW_RANGE = 4; + + public ToolQuickiepowderHoe() { + super(ToolMaterials.DIAMOND, 4, 2.0f, new FabricItemSettings(), new HarvestRange(DEFAULT_PLOW_RANGE)); + } +} diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolQuickiepowderWaterHoe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolQuickiepowderWaterHoe.java new file mode 100644 index 0000000..76877bb --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolQuickiepowderWaterHoe.java @@ -0,0 +1,34 @@ +package de.jottyfan.minecraft.quickiefabric.tools; + +import net.minecraft.block.Blocks; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +/** + * + * @author jotty + * + */ +public class ToolQuickiepowderWaterHoe extends ToolQuickiepowderHoe { + @Override + public ActionResult useOnBlock(ItemUsageContext context) { + ActionResult res = super.useOnBlock(context); + if (!ActionResult.PASS.equals(res)) { + BlockPos pos = context.getBlockPos(); + World world = context.getWorld(); + world.setBlockState(pos, Blocks.WATER.getDefaultState()); + Hand hand = context.getHand(); + PlayerEntity player = context.getPlayer(); + ItemStack oldTool = player.getStackInHand(hand); + ItemStack newTool = new ItemStack(QuickieTools.QUICKIEPOWDERHOE); + newTool.setDamage(oldTool.getDamage()); + player.setStackInHand(hand, newTool); + } + return res; + } +} diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableHoe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableHoe.java new file mode 100644 index 0000000..9358326 --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableHoe.java @@ -0,0 +1,97 @@ +package de.jottyfan.minecraft.quickiefabric.tools; + +import java.util.List; + +import com.google.common.collect.Lists; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.CropBlock; +import net.minecraft.item.HoeItem; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.item.ToolMaterial; +import net.minecraft.util.ActionResult; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.World; + +/** + * + * @author jotty + * + */ +public abstract class ToolRangeableHoe extends HoeItem implements ToolRangeable { + + public HarvestRange range; + + public ToolRangeableHoe(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings, HarvestRange range) { + super(material, attackDamage, attackSpeed, settings); + this.range = range; + } + + @Override + public ActionResult useOnBlock(ItemUsageContext context) { + ActionResult res = super.useOnBlock(context); + boolean isCrop = context.getWorld().getBlockState(context.getBlockPos()).getBlock() instanceof CropBlock; + if (!ActionResult.PASS.equals(res) || isCrop) { + 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++) { + if (!isCrop) { + removePossibleGrass(context.getWorld(), new BlockPos(x, y, 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); + } else { + harvestIfPossible(context.getBlockPos().add(x, y, z), context.getWorld()); + } + } + } + } + } + return res; + } + + private void removePossibleGrass(World world, BlockPos pos) { + Block block = world.getBlockState(pos).getBlock(); + Boolean grassFound = Blocks.FERN.equals(block) || Blocks.LARGE_FERN.equals(block) + || Blocks.SHORT_GRASS.equals(block) || Blocks.TALL_GRASS.equals(block); + if (grassFound) { + world.breakBlock(pos, true); + } + } + + private void harvestIfPossible(BlockPos pos, World world) { + BlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + if (block instanceof CropBlock) { + CropBlock cBlock = (CropBlock) block; + if (cBlock.isMature(blockState)) { + Block.dropStacks(blockState, world, pos); + world.setBlockState(pos, cBlock.withAge(0)); + } + } + } + + @Override + public HarvestRange getRange(ItemStack stack) { + // TODO: get range from stack + return range; + } + + @Override + public boolean canBreakNeighbors(BlockState blockState) { + return super.isSuitableFor(blockState) || Blocks.TALL_GRASS.equals(blockState.getBlock()) + || Blocks.FERN.equals(blockState.getBlock()) || Blocks.LARGE_FERN.equals(blockState.getBlock()); + } + + @Override + public List getBlockList(Block block) { + return Lists.newArrayList(block); + } +} diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderHoe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderHoe.java index fbdf3c3..7e059ac 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderHoe.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderHoe.java @@ -1,104 +1,18 @@ package de.jottyfan.minecraft.quickiefabric.tools; -import java.util.List; - -import com.google.common.collect.Lists; - import net.fabricmc.fabric.api.item.v1.FabricItemSettings; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.CropBlock; -import net.minecraft.item.HoeItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsageContext; import net.minecraft.item.ToolMaterials; -import net.minecraft.util.ActionResult; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.World; /** * * @author jotty * */ -public class ToolSpeedpowderHoe extends HoeItem implements ToolRangeable { +public class ToolSpeedpowderHoe extends ToolRangeableHoe { - public static final Integer DEFAULT_PLOW_RANGE = 4; - public HarvestRange range; + public static final Integer DEFAULT_PLOW_RANGE = 2; public ToolSpeedpowderHoe() { - super(ToolMaterials.DIAMOND, 4, 2.0f, new FabricItemSettings()); - this.range = new HarvestRange(DEFAULT_PLOW_RANGE); + super(ToolMaterials.DIAMOND, 4, 2.0f, new FabricItemSettings(), new HarvestRange(DEFAULT_PLOW_RANGE)); } - - @Override - public ActionResult useOnBlock(ItemUsageContext context) { - ActionResult res = super.useOnBlock(context); - boolean isCrop = context.getWorld().getBlockState(context.getBlockPos()).getBlock() instanceof CropBlock; - if (!ActionResult.PASS.equals(res) || isCrop) { - 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++) { - if (!isCrop) { - 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); - } else { - harvestIfPossible(context.getBlockPos().add(x, y, z), context.getWorld()); - } - } - } - } - } - return res; - } - - private void harvestIfPossible(BlockPos pos, World world) { - BlockState blockState = world.getBlockState(pos); - Block block = blockState.getBlock(); - if (block instanceof CropBlock) { - CropBlock cBlock = (CropBlock) block; - if (cBlock.isMature(blockState)) { - Block.dropStacks(blockState, world, pos); - world.setBlockState(pos, cBlock.withAge(0)); - } - } - } - - @Override - public HarvestRange getRange(ItemStack stack) { - // TODO: get range from stack - return range; - } - - @Override - public boolean canBreakNeighbors(BlockState blockState) { - return super.isSuitableFor(blockState) - || Blocks.TALL_GRASS.equals(blockState.getBlock()) - || Blocks.FERN.equals(blockState.getBlock()) - || Blocks.LARGE_FERN.equals(blockState.getBlock()); - } - - - @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/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderWaterHoe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderWaterHoe.java index 6be654e..915d811 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderWaterHoe.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderWaterHoe.java @@ -15,15 +15,6 @@ import net.minecraft.world.World; * */ public class ToolSpeedpowderWaterHoe extends ToolSpeedpowderHoe { - - public static final Integer DEFAULT_PLOW_RANGE = 4; - public HarvestRange range; - - public ToolSpeedpowderWaterHoe() { - super(); - this.range = new HarvestRange(DEFAULT_PLOW_RANGE); - } - @Override public ActionResult useOnBlock(ItemUsageContext context) { ActionResult res = super.useOnBlock(context); diff --git a/src/main/resources/assets/quickiefabric/lang/de_de.json b/src/main/resources/assets/quickiefabric/lang/de_de.json index c30696f..68ceab1 100644 --- a/src/main/resources/assets/quickiefabric/lang/de_de.json +++ b/src/main/resources/assets/quickiefabric/lang/de_de.json @@ -10,6 +10,8 @@ "item.quickiefabric.quickiepowderaxe": "Eilpulveraxt", "item.quickiefabric.quickiepowderpickaxe": "Eilpulverspitzhacke", "item.quickiefabric.quickiepowdershovel": "Eilpulverschaufel", + "item.quickiefabric.quickiepowderhoe": "Eilpulverfeldhacke", + "item.quickiefabric.quickiepowderwaterhoe": "bewässerte Eilpulverfeldhacke", "item.quickiefabric.sulphor": "Schwefel", "item.quickiefabric.salpeter": "Salpeter", "item.quickiefabric.construction0": "leerer Bauplan", diff --git a/src/main/resources/assets/quickiefabric/lang/en_us.json b/src/main/resources/assets/quickiefabric/lang/en_us.json index 68f39f5..28be357 100644 --- a/src/main/resources/assets/quickiefabric/lang/en_us.json +++ b/src/main/resources/assets/quickiefabric/lang/en_us.json @@ -10,6 +10,8 @@ "item.quickiefabric.quickiepowderaxe": "hurrypowder axe", "item.quickiefabric.quickiepowderpickaxe": "hurrypowder pickaxe", "item.quickiefabric.quickiepowdershovel": "hurrypowder shovel", + "item.quickiefabric.quickiepowderhoe": "hurrypowder hoe", + "item.quickiefabric.quickiepowderwaterhoe": "watered hurrypowder hoe", "item.quickiefabric.sulphor": "sulfur", "item.quickiefabric.salpeter": "salpeter", "item.quickiefabric.construction0": "empty building plan", diff --git a/src/main/resources/assets/quickiefabric/models/item/quickiepowderhoe.json b/src/main/resources/assets/quickiefabric/models/item/quickiepowderhoe.json new file mode 100644 index 0000000..e24653d --- /dev/null +++ b/src/main/resources/assets/quickiefabric/models/item/quickiepowderhoe.json @@ -0,0 +1,6 @@ +{ + "parent": "item/wooden_hoe", + "textures": { + "layer0": "quickiefabric:item/quickiepowderhoe" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/quickiefabric/models/item/quickiepowderwaterhoe.json b/src/main/resources/assets/quickiefabric/models/item/quickiepowderwaterhoe.json new file mode 100644 index 0000000..6c19289 --- /dev/null +++ b/src/main/resources/assets/quickiefabric/models/item/quickiepowderwaterhoe.json @@ -0,0 +1,6 @@ +{ + "parent": "item/wooden_hoe", + "textures": { + "layer0": "quickiefabric:item/quickiepowderwaterhoe" + } +} \ No newline at end of file diff --git a/src/main/resources/data/fabric/tags/items/hoes.json b/src/main/resources/data/fabric/tags/items/hoes.json index f65f25b..4572aa7 100644 --- a/src/main/resources/data/fabric/tags/items/hoes.json +++ b/src/main/resources/data/fabric/tags/items/hoes.json @@ -2,6 +2,8 @@ "replace": false, "values": [ "quickiefabric:speedpowderhoe", - "quickiefabric:speedpowderwaterhoe" + "quickiefabric:speedpowderwaterhoe", + "quickiefabric:quickiepowderhoe", + "quickiefabric:quickiepowderwaterhoe" ] } \ No newline at end of file diff --git a/src/main/resources/data/quickiefabric/recipes/quickiepowderhoe.json b/src/main/resources/data/quickiefabric/recipes/quickiepowderhoe.json new file mode 100644 index 0000000..34a4a7d --- /dev/null +++ b/src/main/resources/data/quickiefabric/recipes/quickiepowderhoe.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "ss", + " |", + " |" + ], + "key": { + "s": { + "item": "quickiefabric:quickiepowder" + }, + "|": { + "item": "minecraft:stick" + } + }, + "result": { + "item": "quickiefabric:quickiepowderhoe", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/quickiefabric/recipes/quickiepowderwaterhoe.json b/src/main/resources/data/quickiefabric/recipes/quickiepowderwaterhoe.json new file mode 100644 index 0000000..93769ac --- /dev/null +++ b/src/main/resources/data/quickiefabric/recipes/quickiepowderwaterhoe.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "minecraft:water_bucket" + }, + { + "item": "quickiefabric:quickiepowderhoe" + } + ], + "result": { + "item": "quickiefabric:quickiepowderwaterhoe", + "count": 1 + } +} \ No newline at end of file