Jump to content

Having problems with Custom Item.class onUpdate(), Client/Server syncing


Jade_Knightblazer

Recommended Posts

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!

 

Link to comment
Share on other sites

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

 

ლ(́◉◞౪◟◉‵ლ

Link to comment
Share on other sites

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?

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.

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.



×
×
  • Create New...

Important Information

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