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

Sorry if the title is a little confusing, I wasn't quite sure how to word it :P

 

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?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

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;
}

  • 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?

width=463 height=200

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.

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.