Jump to content

(Minecraft 1.15.2 Forge) Grass not updating


Recommended Posts

    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?image.png.60a764334259facca3cbdb2041d5b2fc.png

Edited by NindyBun
Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.