Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FuelMixerIRecipes
- {
- // Make a singleton instance of the object
- private static final FuelMixerIRecipes INSTANCE = new FuelMixerIRecipes();
- // HashMap<output, Triple<input, input, input>>
- private final HashMap<ItemStack, ImmutableTriple<ItemStack, ItemStack>>
- alloyList = Maps.<ItemStack, ImmutableTriple<ItemStack, ItemStack,>>newHashMap();
- private final Map<ItemStack, Float>
- experienceList = Maps.<ItemStack, Float>newHashMap();
- public static FuelMixerIRecipes getInstance() {
- return INSTANCE;
- }
- private FuelMixerIRecipes() {
- addFuelMixerIRecipe(new ItemStack(Items.COAL), new ItemStack(ModItems.BURNT_COAL),
- new ItemStack(Items.COAL), new ItemStack(ModItems.BURNT_COAL), 2.0f);
- }
- public void addBloomeryRecipe(ItemStack input1, ItemStack input2, ItemStack input3, ItemStack result, float experience) {
- if (getAlloyingResult(input1, input2, input3) != ItemStack.EMPTY) return;
- alloyList.put(result, new ImmutableTriple<ItemStack, ItemStack, ItemStack>(input1, input2, input3));
- experienceList.put(result, Float.valueOf(experience));
- }
- public ItemStack getAlloyingResult(ItemStack input1, ItemStack input2, ItemStack input3) {
- // HashMap<output, Triple<input, input, input>>
- for (Entry<ItemStack, ImmutableTriple<ItemStack, ItemStack, ItemStack>> entry : alloyList.entrySet()) {
- if (compareItemStacks(input1, entry.getValue().getLeft()) && compareItemStacks(input2, entry.getValue().getMiddle())
- && compareItemStacks(input3, entry.getValue().getRight())) {
- return entry.getKey();
- }
- }
- return ItemStack.EMPTY;
- }
- private boolean compareItemStacks(ItemStack stack1, ItemStack stack2) {
- return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata());
- }
- public HashMap<ItemStack, ImmutableTriple<ItemStack, ItemStack, ItemStack>> getAlloyingList() {
- return alloyList;
- }
- public float getAlloyingExperience(ItemStack stack) {
- for (Entry<ItemStack, Float> entry : experienceList.entrySet()) {
- if (this.compareItemStacks(stack, entry.getKey())) {
- return entry.getValue();
- }
- }
- return 0.0f;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement