fixed bug on path creation
This commit is contained in:
@@ -12,7 +12,7 @@ loader_version=0.18.4
|
|||||||
loom_version=1.15-SNAPSHOT
|
loom_version=1.15-SNAPSHOT
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=26.1.4
|
mod_version=26.1.4.1
|
||||||
maven_group=de.jottyfan.minecraft
|
maven_group=de.jottyfan.minecraft
|
||||||
archives_base_name=quickly
|
archives_base_name=quickly
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.jottyfan.minecraft.item;
|
package de.jottyfan.minecraft.item;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ public class QShovel extends ShovelItem implements ToolRangeable {
|
|||||||
this.range = properties.getHarvestRange();
|
this.range = properties.getHarvestRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPathOnGrass(Level level, BlockPos pos, Direction side) {
|
private void createPath(Level level, BlockPos pos, Direction side, Set<Block> validBlocks) {
|
||||||
BlockState blockState = level.getBlockState(pos);
|
BlockState blockState = level.getBlockState(pos);
|
||||||
if (blockState.isAir()) {
|
if (blockState.isAir()) {
|
||||||
// try to find one underneath
|
// try to find one underneath
|
||||||
@@ -39,7 +40,9 @@ public class QShovel extends ShovelItem implements ToolRangeable {
|
|||||||
if (side != Direction.DOWN) {
|
if (side != Direction.DOWN) {
|
||||||
if (blockState != null && level.getBlockState(pos.above()).isAir()) {
|
if (blockState != null && level.getBlockState(pos.above()).isAir()) {
|
||||||
if (!level.isClientSide()) {
|
if (!level.isClientSide()) {
|
||||||
level.setBlockAndUpdate(pos, Blocks.DIRT_PATH.defaultBlockState());
|
if (validBlocks.contains(blockState.getBlock())) {
|
||||||
|
level.setBlockAndUpdate(pos, Blocks.DIRT_PATH.defaultBlockState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,10 +50,13 @@ public class QShovel extends ShovelItem implements ToolRangeable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult useOn(UseOnContext context) {
|
public InteractionResult useOn(UseOnContext context) {
|
||||||
for (BlockPos pos : range.getRangeAsBlockPosArray(context.getClickedPos(), true, new BlockPos(1, 1, 1))) {
|
InteractionResult result = super.useOn(context);
|
||||||
createPathOnGrass(context.getLevel(), pos, context.getClickedFace());
|
if (InteractionResult.SUCCESS.equals(result)) {
|
||||||
|
for (BlockPos pos : range.getRangeAsBlockPosArray(context.getClickedPos(), true, new BlockPos(1, 1, 1))) {
|
||||||
|
createPath(context.getLevel(), pos, context.getClickedFace(), FLATTENABLES.keySet());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.useOn(context);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user