theOriginalByte Posted July 6, 2015 Share Posted July 6, 2015 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 Quote Link to comment Share on other sites More sharing options...
Awesome_Spider Posted July 6, 2015 Share Posted July 6, 2015 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. Quote Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 6, 2015 Author Share Posted July 6, 2015 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 Quote Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 6, 2015 Author Share Posted July 6, 2015 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 Quote Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 6, 2015 Author Share Posted July 6, 2015 If i remove the onUpdate the shovel works like it should and has the swing animation when breaking blocks Quote Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 6, 2015 Author Share Posted July 6, 2015 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 Quote Link to comment Share on other sites More sharing options...
Awesome_Spider Posted July 6, 2015 Share Posted July 6, 2015 That is the right statement... Weird. Quote Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 6, 2015 Author Share Posted July 6, 2015 Yeah i don't know whats wrong. I can do the same on a sword and it works fine Quote Link to comment Share on other sites More sharing options...
Awesome_Spider Posted July 6, 2015 Share Posted July 6, 2015 That's really weird... I have no idea what the problem could be... Quote Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 9, 2015 Author Share Posted July 9, 2015 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 Quote Link to comment Share on other sites More sharing options...
Anon10W1z Posted July 9, 2015 Share Posted July 9, 2015 Take your super.onUpdate call outside the world.isRemote check. That should fix it. Quote Maker of the Craft++ mod. Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 9, 2015 Author Share Posted July 9, 2015 like this? Tried that and it still doesn't fix it This also doesn't help. Even with the super.onUpdate above. Quote Link to comment Share on other sites More sharing options...
SanAndreaP Posted July 9, 2015 Share Posted July 9, 2015 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 Quote 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 More sharing options...
theOriginalByte Posted July 9, 2015 Author Share Posted July 9, 2015 Tried that and it still doesn't work... Quote Link to comment Share on other sites More sharing options...
coolAlias Posted July 9, 2015 Share Posted July 9, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 9, 2015 Author Share Posted July 9, 2015 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? Quote Link to comment Share on other sites More sharing options...
HenryRichard Posted July 9, 2015 Share Posted July 9, 2015 Don't use speeds of haste higher than about 3, it messes up the swing animation. Quote 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. Link to comment Share on other sites More sharing options...
theOriginalByte Posted July 10, 2015 Author Share Posted July 10, 2015 Thank you! I was thinking that might be it but i wasn't sure.. Let me fix it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.