Posted July 6, 201510 yr Hey everyone! I have a shovel with potion effects added through the onUpdate method. It doesn't animate a swing but adds the buffs. Am I doing something wrong? Here is my item class: https://github.com/KaminoCoding/CommuMod/blob/release/V.-1.6_BugFix_%2316/src/main/java/io/cyb3rwarri0r8/commumod/items/ItemRubyShovel.java
July 6, 201510 yr My only guess would be maybe you'r adding the potion effect of client side. I could be wrong though. To confirm, log a message in onUpdate that has World.isRemote in it. Tell me what the out put is.
July 6, 201510 yr Author This is what i get back https://gist.github.com/Cyb3rWarri0r8/73789d984a4b651fc375#file-ruby-shovel-log-L253 Its weird like it mixes between it is remote and isn't... it can't seem to decide or something
July 6, 201510 yr Author 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 http://take.ms/Ub8ji
July 6, 201510 yr Author If i remove the onUpdate the shovel works like it should and has the swing animation when breaking blocks
July 6, 201510 yr Author nope.. assuming using !world.isRemote in an if statement is the right way to get it to work server side... also i'm on the latest recommended version of forge 1.7.10
July 6, 201510 yr Author Yeah i don't know whats wrong. I can do the same on a sword and it works fine
July 9, 201510 yr Author I'm wondering if its a problem with the forge code... i might look through it.. or update to the latest version of 1.7.10
July 9, 201510 yr Take your super.onUpdate call outside the world.isRemote check. That should fix it. Maker of the Craft++ mod.
July 9, 201510 yr Author like this? Tried that and it still doesn't fix it This also doesn't help. Even with the super.onUpdate above.
July 9, 201510 yr 1. 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 entity 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 super.onUpdate(...) if(!worldObj.isRemote) { //my code here } instead of super.onUpdate(...) { if(!worldObj.isRemote) { //my code here } } 4. Please rename your last 2 parametgers to meaningful names. par4 is slotId and par5 is called isEquipped 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.
July 9, 201510 yr 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. http://i.imgur.com/NdrFdld.png[/img]
July 9, 201510 yr Author Here is the item class. https://github.com/KaminoCoding/CommuMod/blob/release/V.-1.6_BugFix_%2316/src/main/java/io/cyb3rwarri0r8/commumod/items/ItemRubyShovel.java 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?
July 9, 201510 yr Don't use speeds of haste higher than about 3, it messes up the swing animation. I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.
July 10, 201510 yr Author Thank you! I was thinking that might be it but i wasn't sure.. Let me fix it
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.