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

I was wondering if it was possible to get a projectile to read NBT data from the player's currently equipped item, preferably when it is spawned.

I have had a look at a few vanilla projectiles but I couldn't see anything helpful (though it is late and I may have missed something in my fatigue), EntityPotion has a method for writing/reading entity NBT data though I am not sure how to use it to my advantage, and Google didn't turn up anything either.

Which player? Do you have an EntityPlayer available in your projectile, e.g. the thrower / shooter? If so, you can use player.getHeldItem() to get the currently held ItemStack, if any, and do whatever you want with it, e.g. stack.getTagCompound() to get the NBTTagCompound, if any.

  • Author

Getting the thrower's held item and reading the NBT from there was what I thought I should do, but I was unsure where to put the code.

If I put it in onImpact it would create a slight bug, and I couldn't see an 'onSpawn' type event for EntityThrowable.

I have the code for handling the NBT and what to do for the result, just wondering where the most efficient place for it would be.

Would I perhaps need to get the item to write to the entityNBT in the method that spawns the entity?

  • Author

To be fair, diesieben07, I am new to Minecraft modding and I still have things to learn - I am doing my best to get by, by looking for answers in vanilla code, but obviously I don't know the best methods, or even all of them.

That's why I was asking for the best way t do what I wanted to do. I am by no means an idiot just because I am uninformed, so I won't take your reaction personally. But thanks for the pointer in the right direction.

  • Author

I'm looking at potions, at the moment, to see how thrown potions know what effects to do. I think I get the idea. Thanks. :)

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.