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.