Jump to content

[1.8] Notify other Players when I stop using an Item


Bedrock_Miner

Recommended Posts

Heyho Guys!

 

I created a Bow Item, which works great generally, except one single problem:

I used the NBTTag to store the current pulling state of the bow for the renderer. Everytime the method onUsingTick is called, the value is updated. When the method onPlayerStoppedUsing is called, an arrow is summoned and the nbt data gets resetted.

 

The problem is: When I watch another player pulling the bow and releasing it, I see him pulling the bow as normal. But when he releases it, the texture is not switched back. I figured out that onPlayerStoppedUsing is only called on the Server and on the Client who caused it.

Now, I need to know how to notify the other players that the NBT data needs to be resetted.

 

I already tried several things to solve this:

The methods here were called on the server side to synchronize the Item but it didn't work.

if (stack.hasTagCompound())
    stack.getTagCompound().removeTag("$BOWSTATE$");

if (!world.isRemote)
    ((EntityPlayerMP)player).updateHeldItem();

// ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new C09PacketHeldItemChange(player.inventory.currentItem));
// ((EntityPlayerMP) player).markPlayerActive();

 

Actually, the other players do not see the default bow texture unless I unequip and re-equip my bow.

 

Any ideas how to fix this?

Link to comment
Share on other sites

Well, I got it to work right now myself, but your post lead me in the right direction: It's updated when the value has changed and not if it is changed and then changed back immediately. During the pullback time of the bow I can only change the value on client side, because the pull time would restart otherwise. Thats why nothing changed for the server, only for the clients. I now added a change when the player starts pulling on server and client and now it works.

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.

Announcements



×
×
  • Create New...

Important Information

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