Posted July 7, 201312 yr Sorry if the title is a little confusing, I wasn't quite sure how to word it ย Basically, what I need to do is assign a static int. Nothing fancy, just a basic number to each of a set of items.. so for example item A is 100, item B is 200 etc. ย Then, I need to be able to read what these ints are when they're placed into a container, and change the players NBT to add all of those together to a tag. I need to be able to take the values from both item A and item B, and add them together, so effectively adding 300 to the NBT in my example. ย Can anyone point me in the right direction? http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
July 7, 201312 yr You could store all the values in a map, public static Map<Item, Integer> itemValue = new HashMap<Item, Integer>(); ย add item/value pair itemValue.put(theItem, thevalue); ย get value of an item if (itemValue.containsKey(theItem)) { ย ย value = itemValue.get(theItem); } ย That would also allow you to use item your mod doesn't add. ย ย ย If it's only for your own items, you could add it directly to your items class and read from it later. ย public class ItemValued extends Item { ย ย public static itemValue = 200; ...... ย Retrieved later if (item instanceof ItemValued) { ย ย value = ((ItemValued)item).itemValue; }
July 7, 201312 yr Author If it's only for your own items, you could add it directly to your items class and read from it later. ย public class ItemValued extends Item { ย ย public static itemValue = 200; ...... ย Retrieved later if (item instanceof ItemValued) { ย ย value = ((ItemValued)item).itemValue; } ย That's all I need, thanks The mod is pretty static. Not something people will have any reason to want to add to later really ย EDIT: I'm assuming "public static itemValue = 200;" is supposed to be "public static int itemValue = 200;" by the way? http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
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.