added path creation with speed powder shovel
This commit is contained in:
parent
2dec472409
commit
eaed21a3ff
@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
loader_version=0.9.3+build.207
|
loader_version=0.9.3+build.207
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.16.3.7
|
mod_version = 1.16.3.8
|
||||||
maven_group = de.jottyfan.minecraft
|
maven_group = de.jottyfan.minecraft
|
||||||
archives_base_name = quickiefabric
|
archives_base_name = quickiefabric
|
||||||
|
|
||||||
|
@ -12,10 +12,15 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUsageContext;
|
||||||
import net.minecraft.item.ShovelItem;
|
import net.minecraft.item.ShovelItem;
|
||||||
import net.minecraft.item.ToolMaterials;
|
import net.minecraft.item.ToolMaterials;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Identifier;
|
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.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);
|
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
|
@Override
|
||||||
public HarvestRange getRange(ItemStack stack) {
|
public HarvestRange getRange(ItemStack stack) {
|
||||||
// TODO: get range from stack
|
// TODO: get range from stack
|
||||||
|
Loading…
x
Reference in New Issue
Block a user