Jump to content

118 items in one id


Nicba1010

Recommended Posts

Hi fellow modders,

me and my friend Dautor have run into a bit of a problem today.

We are trying to register all of the 118 elements in one id. But we

have tried many solutions, and only the one where we put every

element in its own id worked. So we came here to find out if you

can help us how to solve this problem. It is not practical to have

each element in its own id because we are going to use the same

system for the chemical compounds.

This is the code we currently have

Item registering

public static Item element[] = new Element[baseVariables.elementNum];
public static void initializeItems() {
  for (int i = 0; i < BaseVariables.elementNum; i++) {
   element[i] = new Element(i);
  }
}

Item class

package core.base.item;

import java.util.List;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraftforge.oredict.OreDictionary;
import core.base.Core;
import core.base.util.BaseVariables;
import core.base.util.IDs;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class Element extends Item {

// private static String name[] = new String[baseVariables.elementNum];

private int Z;

public Element(int i) {
  super(IDs.elementID + i);
  setHasSubtypes(true);
  setMaxDamage(0);
  // for (int i = 0; i < BaseVariables.elementNum; i++) {
  Z = i;
  this.setUnlocalizedName(BaseVariables.elementSymbol[Z]);
  OreDictionary.registerOre("element" + BaseVariables.elementName[Z], this);
  LanguageRegistry.addName(this, BaseVariables.elementSymbol[Z]);
  this.setCreativeTab(Core.creativeTab);
  // }
}

public static String getName(int i) {
  return BaseVariables.elementSymbol[i];
}

@Override
public Icon getIconFromDamage(int i) {
  return this.itemIcon;
}

public String getItemNameIS(ItemStack stack) {
  return BaseVariables.elementName[stack.getItemDamage()];
}

@SideOnly(Side.CLIENT)
public void getSubBlocks(int unknown, CreativeTabs tab, List subItems) {
  for (int i = 0; i < BaseVariables.elementNum; i++) {
   subItems.add(new ItemStack(this, 1, i));
  }
}

public void registerIcons(IconRegister par1IconRegister) {
  this.itemIcon = par1IconRegister.registerIcon(BaseVariables.modId + ":"
    + BaseVariables.elementSymbol[this.getMetadata(itemID)]);
}
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
   list.add(BaseVariables.elementName[Z] + " (" + (Z+1) + ")");
  }
}

BaseVariables.java

package core.base.util;

public class BaseVariables {
public static final String modId = "DaNi";
public static final String modName = "DaNi++";
public static final String modVersion = "FR-0.0";
public static final String clientProxy = "core.base.ClientProxy";
public static final String commonProxy = "core.base.CommonProxy";
public static final int elementNum = 118;
public static String elementName[] = { "Hydrogen", "Helium", "Lithium", "Berilium", "Bohrium", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulphur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Galium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmiums", "Iridium", "Platium", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Ununtrium", "Flerovium", "Ununpentium", "Livermorium", "Ununseptium", "Ununoctium" };
public static String elementSymbol[] = { "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Ti", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Uut", "Fl", "Uup", "Lv", "Uus", "Uuo" };
}

We would really appreciate your help.

Sincerely Dautor and Nicba1010

Link to comment
Share on other sites

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

I also say yeah, use metadata. That is the most easy thing.

 

but at items it is a little bit differend as at blocks.

 

one thing i saw that you have to change (because its less work but the same result)

is the function getItemNameIs(...). I think this function is kinda useless.

Use this function show exactly that string that you type in (no Stringconverting needed)

getItemDisplayName(...). i think it is the best function you can use.

 

I hope that help

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.