Jump to content

[1.7.10]How to make custom machine with custom recipes have 2 outputs


slugslug

Recommended Posts

I have this custom recipe handler for my custom machine and i cant figure out how to convert it to have two outputs.

 

Here is the file:

 

 

package com.professorvennie.api.recipes;

import net.minecraft.item.ItemStack;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;

/**
* Created by ProfessorVennie on 8/16/2014 at 2:55 PM.
*/
public class ExtractorRecipes {

    private static final ExtractorRecipes SMELTING_BASE = new ExtractorRecipes();
    private Map extractorList = new HashMap();
    private Map expList = new HashMap();
    private Random random = new Random();

    public static ExtractorRecipes extractoring(){
        return SMELTING_BASE;
    }

    public ExtractorRecipes(){

    }

    public void addRecipe(ItemStack itemStack1, ItemStack itemstack2 , float exp){
        this.addLists(itemStack1, itemstack2, exp);
    }

    public void addLists(ItemStack itemStack1, ItemStack itemstack2, float exp){
        this.putLists(itemStack1, itemstack2, exp);
    }

    public void putLists(ItemStack itemstack, ItemStack itemstack2, float exp){
        this.extractorList.put(itemstack, itemstack2);
        this.expList.put(itemstack2, Float.valueOf(exp));
    }

    public ItemStack getExtractoringResult(ItemStack itemstack){
        Iterator iterator = this.extractorList.entrySet().iterator();

        Map.Entry entry;

        do{
            if(!iterator.hasNext()){;
                return null;
            }
            entry = (Map.Entry) iterator.next();
        }
        while(!canBeExtracted(itemstack, (ItemStack)entry.getKey()));
        return (ItemStack) entry.getValue();
    }

    private boolean canBeExtracted(ItemStack itemstack, ItemStack itemstack2) {
        return itemstack2.getItem() == itemstack.getItem() && (itemstack2.getItemDamage() == 32767 ||itemstack2.getItemDamage() == itemstack.getItemDamage());
    }

    public float giveExp(ItemStack itemstack){
        Iterator iterator = this.expList.entrySet().iterator();
        Map.Entry entry;

        do{
            if(!iterator.hasNext()){
                return 0;
            }
            entry = (Map.Entry) iterator.next();
        }
        while(!canBeExtracted(itemstack, (ItemStack)entry.getKey()));

        if(itemstack.getItem().getSmeltingExperience(itemstack) != -1){
            return itemstack.getItem().getSmeltingExperience(itemstack);
        }

        return ((Float) entry.getValue()).floatValue();
    }
}

 

 

Link to comment
Share on other sites

ok firstly, when you define hashmaps, put you classes in don't leave them a s just Map or HashMap (you will only see Map in decompiled code) this prevent adding incorrect stuff to it by accident

 

For what you are doing would probably be better off not to use hashmaps and simply add the recipes to a list

then search the list for a match and you can then get the 2 output from the recipe

 

Link to comment
Share on other sites

Two output?

Of What, with what and what else?

Always two output or is one output possible, too?

What is the input?

Does it work like two furnaces or one furnace with a random second output?

 

All of these choices drive how to program both your recipes and your logic.

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.