Posted January 8, 201312 yr Hi, I am trying to use the onUpdate() Method in a custom Item.class to damage other items in the players inventory. Such as... public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { EntityPlayer p = ((EntityPlayer)par3Entity); if (p.isSneaking() == true && p.inventory.hasItem(mod_HarkenScythe.HSSpectralMirror.shiftedIndex)) { Damage other item via Itemstack.damageItem(damageAmount, entityplayer) } }; The last part is just Pseudo. "I have other Methods linked to it". Now this works all nice like however if the player logs out of the game or drops the item to the ground (Q key), the Item that was damage regains all of its Durability. I believe this is cause by Client and Server no syncing correctly. (Client Item is taking damage, while the server Item is not). This is very problamatic and I can't seem to find a solution for this oddity T_T. In a nut shell... I believe onUpdate() method is only called by the client and the server ignores it. Any help would be greatly appreciated! http://i715.photobucket.com/albums/ww155/JadeKnightblazer/AsgardShieldBannermain.png[/img]
January 8, 201312 yr Have you tried if(!par2World.isRemote) "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
January 8, 201312 yr Author I always wondered what isRemote() does? Please educate me http://i715.photobucket.com/albums/ww155/JadeKnightblazer/AsgardShieldBannermain.png[/img]
January 9, 201312 yr Hmm, add a Minecraft.thePlayer.addChatMessage("derp") and check if it out puts the message once or twice when you shift, if once, that means that it's only being called by client and that you should change to cast to EntitPlayerMP, otherwise try adding a tick handler in a proxy so you can check players inventory there. "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
January 9, 201312 yr Author Sadly if (!par2World.isRemote) totaly kills the Item.class onUpdate() method. Since only the client is handling it. And as for EntityPlayerMP, the cast just creates errors. Standalone. And doesn't not call any actions if, if (par3Entity instanceof EntityPlayerMP) is used. =/ Is there a way to Re-sync Items (client and server) after they take damage from client? http://i715.photobucket.com/albums/ww155/JadeKnightblazer/AsgardShieldBannermain.png[/img]
January 10, 201312 yr Author Thanks, I'll try that I wasn't aware the CommonTickHandler was able to find EntityPlayers again after the 1.3.1 update http://i715.photobucket.com/albums/ww155/JadeKnightblazer/AsgardShieldBannermain.png[/img]
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.