mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
5 files changed
+301
-1
No files matched your search
@@ -7,11 +7,14 @@ import mekanism.api.util.BlockInfo;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
public class MekanismAPI
|
||||
{
|
||||
//Add a BlockInfo value here if you don't want a certain block to be picked up by cardboard boxes
|
||||
private static Set<BlockInfo> cardboardBoxIgnore = new HashSet<>();
|
||||
|
||||
private static MekanismRecipeHelper helper = null;
|
||||
|
||||
/** Mekanism debug mode */
|
||||
public static boolean debug = false;
|
||||
@@ -45,4 +48,22 @@ public class MekanismAPI
|
||||
}
|
||||
|
||||
public static class BoxBlacklistEvent extends Event {}
|
||||
|
||||
/**
|
||||
* Get the instance of the recipe helper to directly add recipes.
|
||||
*
|
||||
* Do NOT copy/repackage this method into your package, nor use the class directly as it may change.
|
||||
*
|
||||
* @return {@link MekanismRecipeHelper} The handler.
|
||||
*/
|
||||
public static MekanismRecipeHelper recipeHelper(){
|
||||
if (helper == null){
|
||||
try {
|
||||
helper = (MekanismRecipeHelper)Class.forName("mekanism.common.recipe.APIHandler").newInstance();
|
||||
} catch (ClassNotFoundException|InstantiationException|IllegalAccessException e) {
|
||||
LogManager.getLogger("MekanismAPI").error("Could not find API Handler", e);
|
||||
}
|
||||
}
|
||||
return helper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package mekanism.api;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface MekanismRecipeHelper {
|
||||
/**
|
||||
* Add an Enrichment Chamber recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output ItemStack
|
||||
*/
|
||||
void addEnrichmentChamberRecipe(ItemStack input, ItemStack output);
|
||||
|
||||
/**
|
||||
* Add an Osmium Compressor recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output ItemStack
|
||||
*/
|
||||
void addOsmiumCompressorRecipe(ItemStack input, ItemStack output);
|
||||
|
||||
/**
|
||||
* Add a Combiner recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output ItemStack
|
||||
*/
|
||||
void addCombinerRecipe(ItemStack input, ItemStack output);
|
||||
|
||||
/**
|
||||
* Add a Crusher recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output ItemStack
|
||||
*/
|
||||
void addCrusherRecipe(ItemStack input, ItemStack output);
|
||||
|
||||
/**
|
||||
* Add a Purification Chamber recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output ItemStack
|
||||
*/
|
||||
void addPurificationChamberRecipe(ItemStack input, ItemStack output);
|
||||
|
||||
/**
|
||||
* Add a Metallurgic Infuser recipe.
|
||||
* @param infuse - which Infuse to use
|
||||
* @param amount - how much of the Infuse to use
|
||||
* @param input - input ItemStack
|
||||
* @param output - output ItemStack
|
||||
*/
|
||||
void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output);
|
||||
|
||||
/**
|
||||
* Add a Chemical Infuser recipe.
|
||||
* @param leftInput - left GasStack to input
|
||||
* @param rightInput - right GasStack to input
|
||||
* @param output - output GasStack
|
||||
*/
|
||||
void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output);
|
||||
|
||||
/**
|
||||
* Add a Chemical Oxidizer recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output GasStack
|
||||
*/
|
||||
void addChemicalOxidizerRecipe(ItemStack input, GasStack output);
|
||||
|
||||
/**
|
||||
* Add a Chemical Injection Chamber recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output ItemStack
|
||||
*/
|
||||
void addChemicalInjectionChamberRecipe(ItemStack input, Gas gas, ItemStack output);
|
||||
|
||||
/**
|
||||
* Add an Electrolytic Separator recipe.
|
||||
* @param fluid - FluidStack to electrolyze
|
||||
* @param leftOutput - left gas to produce when the fluid is electrolyzed
|
||||
* @param rightOutput - right gas to produce when the fluid is electrolyzed
|
||||
*/
|
||||
void addElectrolyticSeparatorRecipe(FluidStack fluid, double energy, GasStack leftOutput, GasStack rightOutput);
|
||||
|
||||
/**
|
||||
* Add a Precision Sawmill recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param primaryOutput - guaranteed output
|
||||
* @param secondaryOutput - possible extra output
|
||||
* @param chance - probability of obtaining extra output
|
||||
*/
|
||||
void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance);
|
||||
|
||||
/**
|
||||
* Add a Precision Sawmill recipe with no chance output
|
||||
* @param input - input ItemStack
|
||||
* @param primaryOutput - guaranteed output
|
||||
*/
|
||||
void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput);
|
||||
|
||||
/**
|
||||
* Add a Chemical Dissolution Chamber recipe.
|
||||
* @param input - input ItemStack
|
||||
* @param output - output GasStack
|
||||
*/
|
||||
void addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output);
|
||||
|
||||
/**
|
||||
* Add a Chemical Washer recipe.
|
||||
* @param input - input GasStack
|
||||
* @param output - output GasStack
|
||||
*/
|
||||
void addChemicalWasherRecipe(GasStack input, GasStack output);
|
||||
|
||||
/**
|
||||
* Add a Chemical Crystallizer recipe.
|
||||
* @param input - input GasStack
|
||||
* @param output - output ItemStack
|
||||
*/
|
||||
void addChemicalCrystallizerRecipe(GasStack input, ItemStack output);
|
||||
|
||||
/**
|
||||
* Add a Pressurized Reaction Chamber recipe.
|
||||
* @param inputSolid - input ItemStack
|
||||
* @param inputFluid - input FluidStack
|
||||
* @param inputGas - input GasStack
|
||||
* @param outputSolid - output ItemStack
|
||||
* @param outputGas - output GasStack
|
||||
* @param extraEnergy - extra energy needed by the recipe
|
||||
* @param ticks - amount of ticks it takes for this recipe to complete
|
||||
*/
|
||||
void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks);
|
||||
|
||||
void addThermalEvaporationRecipe(FluidStack inputFluid, FluidStack outputFluid);
|
||||
|
||||
void addSolarNeutronRecipe(GasStack inputGas, GasStack outputGas);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package mekanism.api.gas;
|
||||
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.MekanismRenderer.FluidType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -43,6 +44,11 @@ public class Gas
|
||||
iconLocation = new ResourceLocation(icon);
|
||||
}
|
||||
|
||||
public Gas(String s, ResourceLocation icon){
|
||||
unlocalizedName = name = s;
|
||||
iconLocation = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Gas object that corresponds to the given Fluid
|
||||
*/
|
||||
@@ -139,6 +145,10 @@ public class Gas
|
||||
{
|
||||
return MekanismRenderer.getFluidTexture(fluid, FluidType.STILL);
|
||||
}
|
||||
|
||||
if (sprite == null){
|
||||
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(getIcon().toString());
|
||||
}
|
||||
|
||||
return sprite;
|
||||
}
|
||||
|
||||
@@ -3,19 +3,23 @@ package mekanism.api.gas;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
|
||||
public class GasRegistry
|
||||
{
|
||||
private static ArrayList<Gas> registeredGasses = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Register a new gas into GasRegistry.
|
||||
* Register a new gas into GasRegistry. Call this BEFORE post-init.
|
||||
* @param gas - Gas to register
|
||||
* @return the gas that has been registered, pulled right out of GasRegistry
|
||||
*/
|
||||
public static Gas register(Gas gas)
|
||||
{
|
||||
checkPhase();
|
||||
if(gas == null)
|
||||
{
|
||||
return null;
|
||||
@@ -110,4 +114,8 @@ public class GasRegistry
|
||||
|
||||
return registeredGasses.indexOf(gas);
|
||||
}
|
||||
|
||||
private static void checkPhase(){
|
||||
Preconditions.checkState(Loader.instance().getLoaderState().ordinal() > LoaderState.INITIALIZATION.ordinal(), "Gasses must be registered before postInit.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package mekanism.common.recipe;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import mekanism.api.MekanismRecipeHelper;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
|
||||
public class APIHandler implements MekanismRecipeHelper {
|
||||
private static void checkPhase(){
|
||||
Preconditions.checkState(Loader.instance().getLoaderState().ordinal() > LoaderState.INITIALIZATION.ordinal(), "Recipes should be registered during Init.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEnrichmentChamberRecipe(ItemStack input, ItemStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addEnrichmentChamberRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOsmiumCompressorRecipe(ItemStack input, ItemStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addOsmiumCompressorRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCombinerRecipe(ItemStack input, ItemStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addCombinerRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCrusherRecipe(ItemStack input, ItemStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addCrusherRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPurificationChamberRecipe(ItemStack input, ItemStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addPurificationChamberRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addMetallurgicInfuserRecipe(infuse, amount, input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addChemicalInfuserRecipe(leftInput, rightInput, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChemicalOxidizerRecipe(ItemStack input, GasStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addChemicalOxidizerRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChemicalInjectionChamberRecipe(ItemStack input, Gas gas, ItemStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addChemicalInjectionChamberRecipe(input, gas, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addElectrolyticSeparatorRecipe(FluidStack fluid, double energy, GasStack leftOutput, GasStack rightOutput) {
|
||||
checkPhase();
|
||||
RecipeHandler.addElectrolyticSeparatorRecipe(fluid, energy, leftOutput, rightOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) {
|
||||
checkPhase();
|
||||
RecipeHandler.addPrecisionSawmillRecipe(input, primaryOutput, secondaryOutput, chance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) {
|
||||
checkPhase();
|
||||
RecipeHandler.addPrecisionSawmillRecipe(input, primaryOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addChemicalDissolutionChamberRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChemicalWasherRecipe(GasStack input, GasStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addChemicalWasherRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChemicalCrystallizerRecipe(GasStack input, ItemStack output) {
|
||||
checkPhase();
|
||||
RecipeHandler.addChemicalCrystallizerRecipe(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) {
|
||||
checkPhase();
|
||||
RecipeHandler.addPRCRecipe(inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addThermalEvaporationRecipe(FluidStack inputFluid, FluidStack outputFluid) {
|
||||
checkPhase();
|
||||
RecipeHandler.addThermalEvaporationRecipe(inputFluid, outputFluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSolarNeutronRecipe(GasStack inputGas, GasStack outputGas) {
|
||||
checkPhase();
|
||||
RecipeHandler.addSolarNeutronRecipe(inputGas, outputGas);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user