Posted March 11, 20214 yr @Override public ActionResultType onItemUse(ItemUseContext context) { refuel(context.getItem(), context.getPlayer()); int fuelValue = 0; if (context.getItem().hasTag() && context.getItem().getTag().contains("FuelValue")) { fuelValue = context.getItem().getTag().getInt("FuelValue"); } World world = context.getWorld(); ItemStack stack = context.getItem(); BlockPos pos = context.getPos(); BlockState state = context.getWorld().getBlockState(pos); PlayerEntity player = context.getPlayer(); Block block = world.getBlockState(pos).getBlock(); if (fuelValue >= use){ //context.getWorld().destroyBlock(context.getPos(), false); if (block.removedByPlayer(state, world, pos, player, true, state.getFluidState())){ BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player); block.dropXpOnBlockBreak(world, pos, event.getExpToDrop()); block.harvestBlock(world, player, pos, state, world.getTileEntity(pos), stack); event.getWorld().destroyBlock(pos, false); //event.getWorld().playSound(context.getPlayer(), event.getPos(), event.getState().getSoundType().getBreakSound(), SoundCategory.BLOCKS, event.getState().getSoundType().getVolume(), event.getState().getSoundType().getPitch()); //context.getWorld().setBlockState(context.getPos(), Blocks.AIR.getDefaultState()); } fuelValue -= use; context.getItem().getTag().putInt("FuelValue", context.getItem().getTag().getInt("FuelValue")-use); } return super.onItemUse(context); } So i made an item that harvests a block on right click, but when I do it under a piece of grass, the grass doesn't break. How do I fix this issue? Edited March 11, 20214 yr by NindyBun
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.