mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
depth hoe effect
This commit is contained in:
parent
f565a02561
commit
80f313137f
1 changed files with 12 additions and 5 deletions
|
@ -17,7 +17,10 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.BushBlock;
|
import net.minecraft.world.level.block.BushBlock;
|
||||||
|
import net.minecraft.world.level.block.LeavesBlock;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
|
|
||||||
|
@ -78,8 +81,9 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, Player player) {
|
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, Player player) {
|
||||||
if (stack.getItem() == ModItems.SKY_HOE) {
|
if (!player.isShiftKeyDown() && (stack.getItem() == ModItems.SKY_HOE || stack.getItem() == ModItems.DEPTH_HOE)) {
|
||||||
if (!(player.level.getBlockState(pos).getBlock() instanceof BushBlock))
|
var block = player.level.getBlockState(pos).getBlock();
|
||||||
|
if (!(block instanceof BushBlock) && (stack.getItem() != ModItems.DEPTH_HOE || !(block instanceof LeavesBlock)))
|
||||||
return false;
|
return false;
|
||||||
if (!player.level.isClientSide) {
|
if (!player.level.isClientSide) {
|
||||||
var range = 3;
|
var range = 3;
|
||||||
|
@ -89,9 +93,12 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
||||||
if (x == 0 && y == 0 && z == 0)
|
if (x == 0 && y == 0 && z == 0)
|
||||||
continue;
|
continue;
|
||||||
var offset = pos.offset(x, y, z);
|
var offset = pos.offset(x, y, z);
|
||||||
var otherState = player.level.getBlockState(offset);
|
var offState = player.level.getBlockState(offset);
|
||||||
if (otherState.getBlock() instanceof BushBlock)
|
if (offState.getBlock() instanceof BushBlock || stack.getItem() == ModItems.DEPTH_HOE && offState.getBlock() instanceof LeavesBlock) {
|
||||||
player.level.destroyBlock(offset, true);
|
var entity = offState.hasBlockEntity() ? player.level.getBlockEntity(offset) : null;
|
||||||
|
Block.dropResources(offState, player.level, offset, entity, null, ItemStack.EMPTY);
|
||||||
|
player.level.setBlock(offset, Blocks.AIR.defaultBlockState(), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue