Jump to content

[1.7.10]Custom shovel with potion effects


Recommended Posts

First, that check for equipped is not needed, the boolean passed to the method already tells you if it is the currently equipped Item. For the animation, do you mean when the shovel is used?

And yes, of course onUpdate will be called on both sides, which is why you need to check.

Yeah the swing animation when its being used doesn't happen... and its only supposed to give you haste when its in the players hand



Link to comment
Share on other sites


First, that check for equipped is not needed, the boolean passed to the method already tells you if it is the currently equipped Item.


2. Check if


is an instance of EntityPlayer before proceeding. It may cause mods to crash if they call that method with a non-EntityPlayer as entity.


3. The surrounding {}-brackets after the super call are useless. You can remove them saw your edit after I've posted, the 2nd one is right in regards to your brackets

if(!worldObj.isRemote) {
    //my code here

instead of

    if(!worldObj.isRemote) {
        //my code here


4. Please rename your last 2 parametgers to meaningful names. par4 is


and par5 is called



Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

As SanAndreas mentioned, you MUST check if the entity is a player before proceeding:

if (entity instanceof EntityPlayer && !world.isRemote)

That won't fix your problem, but will prevent crashes later on.


What is going on in your super.onUpdate method? Because that call is pointless if it only ends up calling Item#onUpdate, which does nothing.


Finally, what exactly is the problem you are having? The potion effect is not getting applied at all, or you are not able to have the swing animation?


If you are not able to swing the shovel, can you post your entire shovel class again? It may also have something to do with applying the digSpeed potion specifically (wild guess, but worth a try) - maybe try using a different potion effect like regen that doesn't affect the shovel as its trying to dig.

Link to comment
Share on other sites

Here is the item class.



The swing isn't animating when it digs. It may be something with the potion effect. Let me try changing it and i'll update the post.


UPDATE: Sure enough changing the potion to regeneration fixes the animation.. maybe it has to do with the level of dig speed i'm using?

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.