Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.