diff --git a/gradle.properties b/gradle.properties index 3667ae5..d6db115 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.9.3+build.207 # Mod Properties - mod_version = 1.16.3.7 + mod_version = 1.16.3.8 maven_group = de.jottyfan.minecraft archives_base_name = quickiefabric diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java index e69628b..494357d 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java @@ -12,10 +12,15 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsageContext; import net.minecraft.item.ShovelItem; import net.minecraft.item.ToolMaterials; +import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.util.registry.Registry; +import net.minecraft.world.World; /** * @@ -32,6 +37,41 @@ public class ToolSpeedpowderShovel extends ShovelItem implements ToolRangeable { this.range = new HarvestRange(DEFAULT_HARVEST_RANGE); } + private void createPathOnGrass(World world, BlockPos pos, Direction side) { + BlockState blockState = world.getBlockState(pos); + if (blockState.isAir()) { + // try to find one underneath + pos = pos.down(); + blockState = world.getBlockState(pos); + } else if (!world.getBlockState(pos.up()).isAir()) { + pos = pos.up(); + blockState = world.getBlockState(pos); + } + if (side != Direction.DOWN) { + BlockState blockState2 = (BlockState) PATH_STATES.get(blockState.getBlock()); + if (blockState2 != null && world.getBlockState(pos.up()).isAir()) { + if (!world.isClient) { + world.setBlockState(pos, blockState2, 11); + } + } + } + } + + @Override + public ActionResult useOnBlock(ItemUsageContext context) { + World world = context.getWorld(); + BlockPos pos = context.getBlockPos(); + createPathOnGrass(world, pos.north(), context.getSide()); + createPathOnGrass(world, pos.north().east(), context.getSide()); + createPathOnGrass(world, pos.north().west(), context.getSide()); + createPathOnGrass(world, pos.east(), context.getSide()); + createPathOnGrass(world, pos.west(), context.getSide()); + createPathOnGrass(world, pos.south(), context.getSide()); + createPathOnGrass(world, pos.south().east(), context.getSide()); + createPathOnGrass(world, pos.south().west(), context.getSide()); + return super.useOnBlock(context); + } + @Override public HarvestRange getRange(ItemStack stack) { // TODO: get range from stack