Cleanup on Processor Recipes

This commit is contained in:
DarkGuardsman 2013-11-04 22:00:12 -05:00
parent e87b6418e6
commit bc7c6451cd
11 changed files with 57 additions and 43 deletions

View file

@ -0,0 +1,22 @@
package dark.api.reciepes;
import net.minecraft.item.ItemStack;
/** Simple interface that allows an item to control how its salvaged, processed, or refined by a
* processor. This is 100% optional as the processor by default can break down most items. The only
* reason to use this is for more complex prossesing or were the item was created with NBT.
*
* @author Darkgaurdsman */
public interface IProcessable
{
/** Can this item be Processed by the machine */
public boolean canProcess(ProcessorType type, ItemStack stack);
/** Gets the output array of items when this item is processed by a processor machine
*
* @param type - type of machine see ProcessorTypes enum for info
* @param stack - ItemStack of this item or block
* @return Array of all item outputed, Make sure to return less than or equal to the amount of
* items it takes to craft only one of this item */
public ItemStack[] getProcesserOutput(ProcessorType type, ItemStack stack);
}

View file

@ -1,7 +1,5 @@
package dark.api.reciepes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
@ -30,17 +28,6 @@ public class ProcessorRecipes
private static Random random = new Random();
private static boolean loadedOres = false;
public static enum ProcessorType
{
CRUSHER(),
GRINDER(),
PRESS();
public HashMap<Pair<Integer, Integer>, ProcessorRecipe> itemRecipes = new HashMap();
public HashMap<Pair<Integer, Integer>, ItemStack> altOutput = new HashMap();
public List<Pair<Integer, Integer>> canSalvage = new ArrayList();
}
static
{
createRecipe(ProcessorType.CRUSHER, Block.stone, Block.cobblestone);
@ -82,7 +69,7 @@ public class ProcessorRecipes
{
ItemStack input = convert(in);
ItemStack output = convert(out);
if (input != null && output != null && type.itemRecipes != null)
if (input != null && output != null && type.recipes != null)
{
if (min == -1)
{
@ -92,7 +79,7 @@ public class ProcessorRecipes
{
max = output.stackSize;
}
type.itemRecipes.put(new Pair<Integer, Integer>(input.itemID, input.getItemDamage()), new ProcessorRecipe(output, min, max));
type.recipes.put(new Pair<Integer, Integer>(input.itemID, input.getItemDamage()), new ProcessorRecipe(output, min, max));
}
}
}
@ -128,7 +115,7 @@ public class ProcessorRecipes
{
if (type != null && stack != null)
{
type.canSalvage.add(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage()));
type.banList.add(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage()));
}
}
@ -195,12 +182,12 @@ public class ProcessorRecipes
public static ItemStack[] getOuputNormal(ProcessorType type, ItemStack stack)
{
if (type.itemRecipes != null)
if (type.recipes != null)
{
ProcessorRecipe re = type.itemRecipes.get(new Pair<Integer, Integer>(stack.itemID, -1));
ProcessorRecipe re = type.recipes.get(new Pair<Integer, Integer>(stack.itemID, -1));
if (re == null || re.output == null)
{
re = type.itemRecipes.get(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage()));
re = type.recipes.get(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage()));
}
if (type.altOutput != null && (re == null || re.output == null))
{

View file

@ -0,0 +1,24 @@
package dark.api.reciepes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.item.ItemStack;
import com.builtbroken.common.Pair;
/** Enum of machines that support a simple A -> B processor recipe format. More complex machine will
* have there own recipe handlers
*
* @author Darkguardsman */
public enum ProcessorType
{
CRUSHER(),
GRINDER(),
METAL_PRESS(),
SHARPENING_STONE();
public HashMap<Pair<Integer, Integer>, ProcessorRecipe> recipes = new HashMap();
public HashMap<Pair<Integer, Integer>, ItemStack> altOutput = new HashMap();
public List<Pair<Integer, Integer>> banList = new ArrayList();
}

View file

@ -9,7 +9,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
import cpw.mods.fml.common.registry.GameRegistry;
import dark.api.ColorCode;
import dark.api.reciepes.ProcessorRecipes;
import dark.api.reciepes.ProcessorRecipes.ProcessorType;
import dark.api.reciepes.ProcessorType;
import dark.core.common.blocks.BlockBasalt;
import dark.core.common.blocks.BlockOre;
import dark.core.common.blocks.BlockOre.OreData;

View file

@ -5,9 +5,7 @@ import java.io.File;
import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
@ -31,11 +29,8 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import dark.api.reciepes.ProcessorRecipes;
import dark.api.reciepes.ProcessorRecipes.ProcessorType;
import dark.core.common.RecipeLoader.RecipeGrid;
import dark.core.common.blocks.BlockBasalt;
import dark.core.common.blocks.BlockColorGlass;
import dark.core.common.blocks.BlockColorGlowGlass;
@ -47,15 +42,14 @@ import dark.core.common.blocks.ItemBlockOre;
import dark.core.common.debug.BlockDebug;
import dark.core.common.items.EnumMaterial;
import dark.core.common.items.EnumOrePart;
import dark.core.common.items.EnumTool;
import dark.core.common.items.ItemBattery;
import dark.core.common.items.ItemColoredDust;
import dark.core.common.items.ItemCommonTool;
import dark.core.common.items.ItemOreDirv;
import dark.core.common.items.ItemParts;
import dark.core.common.items.ItemParts.Parts;
import dark.core.common.items.ItemReadoutTools;
import dark.core.common.items.ItemWrench;
import dark.core.common.items.ItemParts.Parts;
import dark.core.common.machines.BlockBasicMachine;
import dark.core.common.machines.BlockSolarPanel;
import dark.core.common.transmit.BlockWire;

View file

@ -29,7 +29,6 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.oredict.OreDictionary;
import universalelectricity.core.electricity.ElectricityDisplay;
import com.google.common.collect.Multimap;

View file

@ -10,7 +10,6 @@ import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.CoreRecipeLoader;
import dark.core.common.DarkMain;
import dark.core.prefab.IExtraInfo.IExtraItemInfo;
import dark.core.prefab.ModPrefab;

View file

@ -1,7 +1,5 @@
package dark.core.network;
import java.lang.reflect.Method;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;

View file

@ -9,17 +9,17 @@ import net.minecraftforge.common.MinecraftForge;
import org.modstats.Modstats;
import com.builtbroken.common.Triple;
import universalelectricity.compatibility.Compatibility;
import universalelectricity.core.UniversalElectricity;
import com.builtbroken.common.Triple;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.relauncher.Side;
import dark.api.reciepes.ProcessorRecipes;
import dark.core.common.ExternalModHandler;
import dark.core.prefab.helpers.FluidHelper;
import dark.core.registration.ModObjectRegistry;

View file

@ -13,11 +13,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidRegistry.FluidRegisterEvent;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidBlock;

View file

@ -1,13 +1,9 @@
package dark.core.prefab.helpers;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
@ -20,9 +16,6 @@ import universalelectricity.core.vector.Vector3;
import com.builtbroken.common.Pair;
import cpw.mods.fml.common.IScheduledTickHandler;
import cpw.mods.fml.common.TickType;
public class PacketDataWatcher
{
HashMap<Pair<World, Vector3>, List<Integer>> packetSizes = new HashMap<Pair<World, Vector3>, List<Integer>>();