Posted August 16, 201411 yr 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(); } }
August 16, 201411 yr 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
August 17, 201411 yr 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. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
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.