Jump to content

[Solved] Different variable values for each player


Niedzwiedz

Recommended Posts

I know it's rather simple, but I can't figure it out by myself.

I have item which players are supposed to right click and when that happens it sets the variable to for example x coordinate, and then on left click it shows that value, but if another player perform right click action that variable is set to his x coordinate, but I want that every player have their separate value.

Link to comment
Share on other sites

I know it's rather simple, but I can't figure it out by myself.

I have item which players are supposed to right click and when that happens it sets the variable to for example x coordinate, and then on left click it shows that value, but if another player perform right click action that variable is set to his x coordinate, but I want that every player have their separate value.

 

You have to store the information in the ItemStack's nbt tag, because the Item class is a singleton.  Every field is effectively static.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Item (as class) has only one instance (or rather that many as you register into Game). The Item is a definition of what you are holding, the ItemStack is the thing that actually holds data. You cannot assign ANY data to Item that you don't want to be global. To save data per-item you need to use ItemStack's NBT.

 

You can do that straight from yourItem class. No point in explaining further.

 

www.minecraftforge.net/wiki/Creating_NBT_for_items

 

Post code if you can't figure out why it doesn't work. (note: NBT is null on default).

 

EDIT

Why am I not getting notifications that someone wrote before me? :C

1.7.10 is no longer supported by forge, you are on your own.

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.