package darkknight.jewelrycraft.affixes; import java.util.*; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import darkknight.jewelrycraft.api.ModifierEffect; import darkknight.jewelrycraft.random.WeightedRandomAffix; import net.minecraft.util.WeightedRandom; public class AffixMods { private static Map prefixes; private static Map suffixes; private static List prefixGen; private static List suffixGen; public static void initializeAffixes(FMLPreInitializationEvent fpie) { prefixes = new HashMap(); suffixes = new HashMap(); prefixGen = new LinkedList(); suffixGen = new LinkedList(); ModifierEffect health1 = new HealthAffix(1); ModifierEffect health2 = new HealthAffix(2); ModifierEffect health3 = new HealthAffix(3); prefixes.put("health1", health1); prefixes.put("health2", health2); prefixes.put("health3", health3); prefixGen.add(new WeightedRandomAffix("health1", 10)); prefixGen.add(new WeightedRandomAffix("health2", 7)); prefixGen.add(new WeightedRandomAffix("health3", 5)); suffixes.put("health1", health1); suffixes.put("health2", health2); suffixes.put("health3", health3); suffixGen.add(new WeightedRandomAffix("health1", 10)); suffixGen.add(new WeightedRandomAffix("health2", 7)); suffixGen.add(new WeightedRandomAffix("health3", 5)); } public static ModifierEffect getPrefix(String prefix) { return prefixes.get(prefix); } public static ModifierEffect getSuffix(String suffix) { return suffixes.get(suffix); } public static String pickPrefix(Random random) { WeightedRandomAffix wra = ((WeightedRandomAffix) WeightedRandom.getRandomItem(random, prefixGen)); return wra.getAffix(random); } public static String pickSuffix(Random random) { WeightedRandomAffix wra = ((WeightedRandomAffix) WeightedRandom.getRandomItem(random, suffixGen)); return wra.getAffix(random); } }