Update IC2 API
This commit is contained in:
parent
a73bf9e9d4
commit
92bee121b2
10 changed files with 152 additions and 26 deletions
|
@ -22,6 +22,9 @@ public interface IEnergySink extends IEnergyAcceptor {
|
||||||
/**
|
/**
|
||||||
* Transfer energy to the sink.
|
* Transfer energy to the sink.
|
||||||
*
|
*
|
||||||
|
* It's highly recommended to accept all energy by letting the internal buffer overflow to
|
||||||
|
* increase the performance and accuracy of the distribution simulation.
|
||||||
|
*
|
||||||
* @param directionFrom direction from which the energy comes from
|
* @param directionFrom direction from which the energy comes from
|
||||||
* @param amount energy to be transferred
|
* @param amount energy to be transferred
|
||||||
* @return Energy not consumed (leftover)
|
* @return Energy not consumed (leftover)
|
||||||
|
|
|
@ -19,7 +19,7 @@ public interface IEnergySource extends IEnergyEmitter {
|
||||||
*
|
*
|
||||||
* If the source doesn't have a buffer, this is a no-op.
|
* If the source doesn't have a buffer, this is a no-op.
|
||||||
*
|
*
|
||||||
* @param amount amount of EU to draw
|
* @param amount amount of EU to draw, may be negative
|
||||||
*/
|
*/
|
||||||
void drawEnergy(double amount);
|
void drawEnergy(double amount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ public interface IMachineRecipeManager {
|
||||||
* @param metadata meta data for additional recipe properties, may be null
|
* @param metadata meta data for additional recipe properties, may be null
|
||||||
* @param outputs Recipe outputs, zero or more depending on the machine
|
* @param outputs Recipe outputs, zero or more depending on the machine
|
||||||
*/
|
*/
|
||||||
public void addRecipe(ItemStack input, NBTTagCompound metadata, ItemStack... outputs);
|
public void addRecipe(IRecipeInput input, NBTTagCompound metadata, ItemStack... outputs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the recipe output for the given input.
|
* Gets the recipe output for the given input.
|
||||||
|
@ -35,5 +35,5 @@ public interface IMachineRecipeManager {
|
||||||
*
|
*
|
||||||
* @return List of recipes
|
* @return List of recipes
|
||||||
*/
|
*/
|
||||||
public Map<ItemStack, RecipeOutput> getRecipes();
|
public Map<IRecipeInput, RecipeOutput> getRecipes();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,12 @@ import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public interface IPatternStorage {
|
public interface IPatternStorage {
|
||||||
|
|
||||||
boolean transferPattern(ItemStack itemstack, short amountUU , int amountEU);
|
boolean transferPattern(ItemStack itemstack, int amountUU , int amountEU);
|
||||||
|
|
||||||
|
int[] getPatternvalus(ItemStack itemstack);
|
||||||
|
|
||||||
|
short getPatternCount();
|
||||||
|
|
||||||
|
ItemStack getPatternItemstack(int index);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
31
common/ic2/api/recipe/IRecipeInput.java
Normal file
31
common/ic2/api/recipe/IRecipeInput.java
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package ic2.api.recipe;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public interface IRecipeInput {
|
||||||
|
/**
|
||||||
|
* Check if subject matches this recipe input, ignoring the amount.
|
||||||
|
*
|
||||||
|
* @param subject ItemStack to check
|
||||||
|
* @return true if it matches the requirement
|
||||||
|
*/
|
||||||
|
boolean matches(ItemStack subject);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the minimum input stack size.
|
||||||
|
*
|
||||||
|
* @return input amount required
|
||||||
|
*/
|
||||||
|
int getAmount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all possible inputs (best effort).
|
||||||
|
*
|
||||||
|
* The stack size is undefined, use getAmount to get the correct one.
|
||||||
|
*
|
||||||
|
* @return list of inputs, may be incomplete
|
||||||
|
*/
|
||||||
|
List<ItemStack> getInputs();
|
||||||
|
}
|
38
common/ic2/api/recipe/RecipeInputItemStack.java
Normal file
38
common/ic2/api/recipe/RecipeInputItemStack.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package ic2.api.recipe;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
public class RecipeInputItemStack implements IRecipeInput {
|
||||||
|
public RecipeInputItemStack(ItemStack input) {
|
||||||
|
this(input, input.stackSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeInputItemStack(ItemStack input, int amount) {
|
||||||
|
this.input = input;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(ItemStack subject) {
|
||||||
|
return subject.itemID == input.itemID &&
|
||||||
|
(subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getInputs() {
|
||||||
|
return Arrays.asList(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final ItemStack input;
|
||||||
|
public final int amount;
|
||||||
|
}
|
45
common/ic2/api/recipe/RecipeInputOreDict.java
Normal file
45
common/ic2/api/recipe/RecipeInputOreDict.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package ic2.api.recipe;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
public class RecipeInputOreDict implements IRecipeInput {
|
||||||
|
public RecipeInputOreDict(String input) {
|
||||||
|
this(input, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipeInputOreDict(String input, int amount) {
|
||||||
|
this.input = input;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(ItemStack subject) {
|
||||||
|
List<ItemStack> inputs = OreDictionary.getOres(input);
|
||||||
|
|
||||||
|
for (ItemStack input : inputs) {
|
||||||
|
if (subject.itemID == input.itemID &&
|
||||||
|
(subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getInputs() {
|
||||||
|
return OreDictionary.getOres(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String input;
|
||||||
|
public final int amount;
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ public class Recipes {
|
||||||
public static IMachineRecipeManager metalformerExtruding;
|
public static IMachineRecipeManager metalformerExtruding;
|
||||||
public static IMachineRecipeManager metalformerCutting;
|
public static IMachineRecipeManager metalformerCutting;
|
||||||
public static IMachineRecipeManager metalformerRolling;
|
public static IMachineRecipeManager metalformerRolling;
|
||||||
public static IMachineRecipeManager orewasching;
|
public static IMachineRecipeManager oreWashing;
|
||||||
public static IMachineRecipeManager Scanner;
|
public static IMachineRecipeManager Scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package mekanism.common;
|
package mekanism.common;
|
||||||
|
|
||||||
|
import ic2.api.recipe.RecipeInputItemStack;
|
||||||
import ic2.api.recipe.Recipes;
|
import ic2.api.recipe.Recipes;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -9,13 +10,13 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import mekanism.api.Object3D;
|
||||||
import mekanism.api.gas.GasNetwork.GasTransferEvent;
|
import mekanism.api.gas.GasNetwork.GasTransferEvent;
|
||||||
import mekanism.api.infuse.InfuseObject;
|
import mekanism.api.infuse.InfuseObject;
|
||||||
import mekanism.api.infuse.InfuseRegistry;
|
import mekanism.api.infuse.InfuseRegistry;
|
||||||
import mekanism.api.infuse.InfuseType;
|
import mekanism.api.infuse.InfuseType;
|
||||||
import mekanism.api.infuse.InfusionInput;
|
import mekanism.api.infuse.InfusionInput;
|
||||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||||
import mekanism.api.Object3D;
|
|
||||||
import mekanism.client.sound.SoundHandler;
|
import mekanism.client.sound.SoundHandler;
|
||||||
import mekanism.common.EnergyNetwork.EnergyTransferEvent;
|
import mekanism.common.EnergyNetwork.EnergyTransferEvent;
|
||||||
import mekanism.common.FluidNetwork.FluidTransferEvent;
|
import mekanism.common.FluidNetwork.FluidTransferEvent;
|
||||||
|
@ -944,7 +945,7 @@ public class Mekanism
|
||||||
|
|
||||||
if(hooks.IC2Loaded)
|
if(hooks.IC2Loaded)
|
||||||
{
|
{
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Ingot, 1, 2), null, MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Ingot, 1, 2), 1), null, MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1));
|
||||||
}
|
}
|
||||||
if(hooks.TELoaded)
|
if(hooks.TELoaded)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package mekanism.common;
|
package mekanism.common;
|
||||||
|
|
||||||
|
import ic2.api.recipe.IRecipeInput;
|
||||||
|
import ic2.api.recipe.RecipeInputItemStack;
|
||||||
import ic2.api.recipe.RecipeOutput;
|
import ic2.api.recipe.RecipeOutput;
|
||||||
import ic2.api.recipe.Recipes;
|
import ic2.api.recipe.Recipes;
|
||||||
|
|
||||||
|
@ -52,34 +54,34 @@ public final class MekanismHooks
|
||||||
|
|
||||||
if(IC2Loaded)
|
if(IC2Loaded)
|
||||||
{
|
{
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.OreBlock, 1, 0), null, new ItemStack(Mekanism.Dust, 2, 2));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.OreBlock, 1, 0), 1), null, new ItemStack(Mekanism.Dust, 2, 2));
|
||||||
|
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Ingot, 1, 1), null, new ItemStack(Mekanism.Dust, 1, 2));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Ingot, 1, 1), 1), null, new ItemStack(Mekanism.Dust, 1, 2));
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Ingot, 1, 0), null, new ItemStack(Mekanism.Dust, 1, 3));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Ingot, 1, 0), 1), null, new ItemStack(Mekanism.Dust, 1, 3));
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Ingot, 1, 3), null, new ItemStack(Item.glowstone));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Ingot, 1, 3), 1), null, new ItemStack(Item.glowstone));
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Ingot, 1, 4), null, new ItemStack(Mekanism.Dust, 1, 5));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Ingot, 1, 4), 1), null, new ItemStack(Mekanism.Dust, 1, 5));
|
||||||
|
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Clump, 1, 0), null, new ItemStack(Mekanism.DirtyDust, 1, 0));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Clump, 1, 0), 1), null, new ItemStack(Mekanism.DirtyDust, 1, 0));
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Clump, 1, 1), null, new ItemStack(Mekanism.DirtyDust, 1, 1));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Clump, 1, 1), 1), null, new ItemStack(Mekanism.DirtyDust, 1, 1));
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Clump, 1, 2), null, new ItemStack(Mekanism.DirtyDust, 1, 2));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Clump, 1, 2), 1), null, new ItemStack(Mekanism.DirtyDust, 1, 2));
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Clump, 1, 3), null, new ItemStack(Mekanism.DirtyDust, 1, 3));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Clump, 1, 3), 1), null, new ItemStack(Mekanism.DirtyDust, 1, 3));
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Clump, 1, 4), null, new ItemStack(Mekanism.DirtyDust, 1, 4));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Clump, 1, 4), 1), null, new ItemStack(Mekanism.DirtyDust, 1, 4));
|
||||||
Recipes.macerator.addRecipe(new ItemStack(Mekanism.Clump, 1, 5), null, new ItemStack(Mekanism.DirtyDust, 1, 5));
|
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.Clump, 1, 5), 1), null, new ItemStack(Mekanism.DirtyDust, 1, 5));
|
||||||
|
|
||||||
for(Map.Entry<ItemStack, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet())
|
for(Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet())
|
||||||
{
|
{
|
||||||
if(MekanismUtils.getName(entry.getKey()).startsWith("ore"))
|
if(MekanismUtils.getName(entry.getKey().getInputs().get(0)).startsWith("ore"))
|
||||||
{
|
{
|
||||||
if(!Recipe.ENRICHMENT_CHAMBER.containsRecipe(entry.getKey()))
|
if(!Recipe.ENRICHMENT_CHAMBER.containsRecipe(entry.getKey().getInputs().get(0)))
|
||||||
{
|
{
|
||||||
RecipeHandler.addEnrichmentChamberRecipe(entry.getKey(), entry.getValue().items.get(0));
|
RecipeHandler.addEnrichmentChamberRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(MekanismUtils.getName(entry.getKey()).startsWith("ingot"))
|
else if(MekanismUtils.getName(entry.getKey().getInputs().get(0)).startsWith("ingot"))
|
||||||
{
|
{
|
||||||
if(!Recipe.CRUSHER.containsRecipe(entry.getKey()))
|
if(!Recipe.CRUSHER.containsRecipe(entry.getKey().getInputs().get(0)))
|
||||||
{
|
{
|
||||||
RecipeHandler.addCrusherRecipe(entry.getKey(), entry.getValue().items.get(0));
|
RecipeHandler.addCrusherRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +89,7 @@ public final class MekanismHooks
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
tag.setInteger("amplification", 50000);
|
tag.setInteger("amplification", 50000);
|
||||||
|
|
||||||
Recipes.matterAmplifier.addRecipe(new ItemStack(Mekanism.EnrichedAlloy), tag);
|
Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.EnrichedAlloy), 1), tag);
|
||||||
|
|
||||||
System.out.println("[Mekanism] Hooked into IC2 successfully.");
|
System.out.println("[Mekanism] Hooked into IC2 successfully.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue