Jump to content

Recommended Posts

Posted

I need to be able to have an item that cannot break any blocks - that can be achieved with events or overriding the Item class' methods. However, the server is still telling the client to render the break animation (the block's break stages), and the client is also still spawning block-break particles. Is there a way to cancel everything before the block is broken (kind of like when the block is first clicked) so that it looks seamless as though the player had not clicked at all? I know ItemSword does this, although I cannot find any place where ItemSword is referenced in the Call Hierarchy (besides where instances of it are created for registration). If someone could please elaborate on how I would get this done, I would appreciate it Thanks.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Posted

Did you look inside the vanilla ItemSword class? It has this method in it (overriding the default behavior in class Item):

 

    public float getStrVsBlock(ItemStack stack, Block block)
    {
        if (block == Blocks.web)
        {
            return 15.0F;
        }
        else
        {
            Material material = block.getMaterial();
            return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
        }
    } 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Did you look inside the vanilla ItemSword class? It has this method in it (overriding the default behavior in class Item):

 

    public float getStrVsBlock(ItemStack stack, Block block)
    {
        if (block == Blocks.web)
        {
            return 15.0F;
        }
        else
        {
            Material material = block.getMaterial();
            return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
        }
    } 

 

This works when you return 0.0F - if you are in survival. My item does not need to be able to interact with blocks (or blocks with inventory / other capabilities on left / right click). diesieben07 gave the perfect solution, MouseEvents. This stops vanilla packets from being sent and rendering / particles from being spawned on the client. Perfect solution, considering the personal MouseListener I wrote for Forge is uninterrupted by canceling vanilla Mouse actions. Thanks for the help.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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