mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-27 23:33:08 +00:00
Cleanup CraftTweaker integration code
This commit is contained in:
1 parent
62aa90db74
commit
fb14fba251
31 files changed
+651
-1752
No files matched your search
+15
-22
@@ -7,38 +7,31 @@ import mekanism.common.Mekanism;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class CrafttweakerIntegration
|
||||
{
|
||||
public class CrafttweakerIntegration {
|
||||
public static final List<IAction> LATE_REMOVALS = new LinkedList<>();
|
||||
public static final List<IAction> LATE_ADDITIONS = new LinkedList<>();
|
||||
|
||||
/**
|
||||
* Apply after (machine)recipes have been applied, but before the FMLLoadCompleteEvent is fired.
|
||||
* Preferbly in (post)init.
|
||||
*
|
||||
* Applying to early causes remove to mallfunction as no recipes have been registered.
|
||||
* Preferably in (post)init.
|
||||
* <p>
|
||||
* Applying to early causes remove to malfunction as no recipes have been registered.
|
||||
* Applying to late causes JEI to not pickup the changes.
|
||||
*/
|
||||
public static void applyRecipeChanges()
|
||||
{
|
||||
// Remove before addition, so recipes can be overwritten
|
||||
LATE_REMOVALS.forEach(action->{
|
||||
try
|
||||
{
|
||||
public static void applyRecipeChanges() {
|
||||
//Remove before addition, so recipes can be overwritten
|
||||
applyChanges(LATE_REMOVALS);
|
||||
applyChanges(LATE_ADDITIONS);
|
||||
}
|
||||
|
||||
private static void applyChanges(List<IAction> actions) {
|
||||
actions.forEach(action -> {
|
||||
try {
|
||||
CraftTweakerAPI.apply(action);
|
||||
} catch (Exception e){
|
||||
Mekanism.logger.error("CT action failed", e);
|
||||
CraftTweakerAPI.logError("Mekanism CT action failed", e);
|
||||
}
|
||||
});
|
||||
LATE_ADDITIONS.forEach(action->{
|
||||
try
|
||||
{
|
||||
CraftTweakerAPI.apply(action);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
Mekanism.logger.error("CT action failed", e);
|
||||
CraftTweakerAPI.logError("Mekanism CT action failed", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-12
@@ -3,30 +3,25 @@ package mekanism.common.integration.crafttweaker.gas;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
|
||||
public class CraftTweakerGasDefinition implements IGasDefinition
|
||||
{
|
||||
public class CraftTweakerGasDefinition implements IGasDefinition {
|
||||
private final Gas gas;
|
||||
|
||||
public CraftTweakerGasDefinition(Gas gas)
|
||||
{
|
||||
public CraftTweakerGasDefinition(Gas gas) {
|
||||
this.gas = gas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGasStack asStack(int millibuckets)
|
||||
{
|
||||
return new CraftTweakerGasStack(new GasStack(gas, millibuckets));
|
||||
public IGasStack asStack(int mb) {
|
||||
return new CraftTweakerGasStack(new GasStack(gas, mb));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return gas.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
public String getDisplayName() {
|
||||
return gas.getLocalizedName();
|
||||
}
|
||||
}
|
||||
}
|
||||
+63
-71
@@ -1,154 +1,146 @@
|
||||
package mekanism.common.integration.crafttweaker.gas;
|
||||
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemCondition;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IItemTransformer;
|
||||
import crafttweaker.api.item.*;
|
||||
import crafttweaker.api.liquid.ILiquidStack;
|
||||
import crafttweaker.api.player.IPlayer;
|
||||
import mekanism.api.gas.GasStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CraftTweakerGasStack implements IGasStack
|
||||
{
|
||||
public class CraftTweakerGasStack implements IGasStack {
|
||||
private final GasStack stack;
|
||||
|
||||
public CraftTweakerGasStack(GasStack stack)
|
||||
{
|
||||
public CraftTweakerGasStack(GasStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IGasDefinition getDefinition()
|
||||
{
|
||||
public IGasDefinition getDefinition() {
|
||||
return new CraftTweakerGasDefinition(stack.getGas());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return stack.getGas().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
public String getDisplayName() {
|
||||
return stack.getGas().getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark()
|
||||
{
|
||||
public String getMark() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount()
|
||||
{
|
||||
public int getAmount() {
|
||||
return stack.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IItemStack> getItems()
|
||||
{
|
||||
public List<IItemStack> getItems() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack[] getItemArray()
|
||||
{
|
||||
public IItemStack[] getItemArray() {
|
||||
return new IItemStack[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids()
|
||||
{
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount)
|
||||
{
|
||||
public IIngredient amount(int amount) {
|
||||
return withAmount(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient or(IIngredient iIngredient)
|
||||
{
|
||||
public IIngredient or(IIngredient iIngredient) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient transform(IItemTransformer iItemTransformer)
|
||||
{
|
||||
public IIngredient transformNew(IItemTransformerNew transformer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient only(IItemCondition iItemCondition)
|
||||
{
|
||||
public IIngredient transform(IItemTransformer iItemTransformer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient marked(String s)
|
||||
{
|
||||
public IIngredient only(IItemCondition iItemCondition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(IItemStack iItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesExact(IItemStack iItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack iLiquidStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient iIngredient)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack applyTransform(IItemStack iItemStack, IPlayer iPlayer)
|
||||
{
|
||||
public IIngredient marked(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTransformers()
|
||||
{
|
||||
public boolean matches(IItemStack iItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGasStack withAmount(int amount)
|
||||
{
|
||||
public boolean matchesExact(IItemStack iItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack iLiquidStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient iIngredient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack applyTransform(IItemStack iItemStack, IPlayer iPlayer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack applyNewTransform(IItemStack item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNewTransformers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTransformers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGasStack withAmount(int amount) {
|
||||
return new CraftTweakerGasStack(new GasStack(stack.getGas(), amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInternal()
|
||||
{
|
||||
return null;
|
||||
public Object getInternal() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toCommandString() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("<gas:%sx%dmb>", stack.getGas().getName(), stack.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,82 +23,54 @@ import java.util.List;
|
||||
@BracketHandler(priority = 100)
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class GasBracketHandler implements IBracketHandler
|
||||
{
|
||||
public class GasBracketHandler implements IBracketHandler {
|
||||
private final IZenSymbol symbolAny;
|
||||
private final IJavaMethod method;
|
||||
|
||||
public GasBracketHandler()
|
||||
{
|
||||
public GasBracketHandler() {
|
||||
this.symbolAny = CraftTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE");
|
||||
this.method = CraftTweakerAPI.getJavaMethod(GasBracketHandler.class, "getGas", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens)
|
||||
{
|
||||
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*"))
|
||||
{
|
||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
||||
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
|
||||
return symbolAny;
|
||||
}
|
||||
|
||||
if (tokens.size() > 2)
|
||||
{
|
||||
if (tokens.get(0).getValue().equals("gas") && tokens.get(1).getValue().equals(":"))
|
||||
{
|
||||
return find(environment, tokens, 2, tokens.size());
|
||||
}
|
||||
if (tokens.size() > 2 && tokens.get(0).getValue().equals("gas") && tokens.get(1).getValue().equals(":")) {
|
||||
return find(environment, tokens, 2, tokens.size());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex)
|
||||
{
|
||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
|
||||
StringBuilder valueBuilder = new StringBuilder();
|
||||
for (int i = startIndex; i < endIndex; i++)
|
||||
{
|
||||
for (int i = startIndex; i < endIndex; i++) {
|
||||
Token token = tokens.get(i);
|
||||
valueBuilder.append(token.getValue());
|
||||
}
|
||||
|
||||
Gas gas = GasRegistry.getGas(valueBuilder.toString());
|
||||
if (gas != null)
|
||||
{
|
||||
return new GasReferenceSymbol(environment, valueBuilder.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
return gas == null ? null : new GasReferenceSymbol(environment, valueBuilder.toString());
|
||||
}
|
||||
|
||||
private class GasReferenceSymbol implements IZenSymbol
|
||||
{
|
||||
private class GasReferenceSymbol implements IZenSymbol {
|
||||
private final IEnvironmentGlobal environment;
|
||||
private final String name;
|
||||
|
||||
public GasReferenceSymbol(IEnvironmentGlobal environment, String name)
|
||||
{
|
||||
public GasReferenceSymbol(IEnvironmentGlobal environment, String name) {
|
||||
this.environment = environment;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartialExpression instance(ZenPosition zenPosition)
|
||||
{
|
||||
public IPartialExpression instance(ZenPosition zenPosition) {
|
||||
return new ExpressionCallStatic(zenPosition, environment, method, new ExpressionString(zenPosition, name));
|
||||
}
|
||||
}
|
||||
|
||||
public static IGasStack getGas(String name)
|
||||
{
|
||||
public static IGasStack getGas(String name) {
|
||||
Gas gas = GasRegistry.getGas(name);
|
||||
if (gas != null)
|
||||
{
|
||||
return new CraftTweakerGasStack(new GasStack(gas, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return gas == null ? null : new CraftTweakerGasStack(new GasStack(gas, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,11 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
||||
public interface IGasDefinition
|
||||
{
|
||||
@ZenOperator(OperatorType.MUL)
|
||||
IGasStack asStack(int millibuckets);
|
||||
IGasStack asStack(int mb);
|
||||
|
||||
@ZenGetter("NAME")
|
||||
String getName();
|
||||
|
||||
@ZenGetter("displayName")
|
||||
String getDisplayName();
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,12 @@ package mekanism.common.integration.crafttweaker.gas;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import stanhebben.zenscript.annotations.OperatorType;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import stanhebben.zenscript.annotations.ZenOperator;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
@ZenClass("mod.mekanism.gas.IGasStack")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public interface IGasStack extends IIngredient
|
||||
{
|
||||
public interface IGasStack extends IIngredient {
|
||||
@ZenGetter("definition")
|
||||
IGasDefinition getDefinition();
|
||||
|
||||
@@ -31,4 +26,4 @@ public interface IGasStack extends IIngredient
|
||||
IGasStack withAmount(int amount);
|
||||
|
||||
Object getInternal();
|
||||
}
|
||||
}
|
||||
+13
-74
@@ -1,105 +1,44 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.GasInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.CrystallizerRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.chemical.crystallizer")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class ChemicalCrystallizer
|
||||
{
|
||||
public class ChemicalCrystallizer {
|
||||
public static final String NAME = "Mekanism Chemical Crystallizer";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IGasStack gasInput, IItemStack itemOutput)
|
||||
{
|
||||
if (gasInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IGasStack gasInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, gasInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER,
|
||||
new CrystallizerRecipe(GasHelper.toGas(gasInput), InputHelper.toStack(itemOutput))));
|
||||
}
|
||||
|
||||
CrystallizerRecipe recipe = new CrystallizerRecipe(GasHelper.toGas(gasInput), InputHelper.toStack(itemOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient gasInput)
|
||||
{
|
||||
if (itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (gasInput == null)
|
||||
gasInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.get(), itemOutput, gasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient gasInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemOutput, IIngredient gasInput)
|
||||
{
|
||||
super(name, map);
|
||||
this.itemOutput = itemOutput;
|
||||
this.gasInput = gasInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<GasInput, CrystallizerRecipe> entry : ((Map<GasInput, CrystallizerRecipe>) RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.get()).entrySet())
|
||||
{
|
||||
IGasStack inputGas = new CraftTweakerGasStack(entry.getKey().ingredient);
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasInput, inputGas))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, gasInput.toString(), itemOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient gasInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<GasInput, ItemStackOutput, CrystallizerRecipe>(NAME,
|
||||
RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER, new IngredientWrapper(itemOutput), new IngredientWrapper(gasInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-75
@@ -1,106 +1,44 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.DissolutionRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.chemical.dissolution")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class ChemicalDissolution
|
||||
{
|
||||
public class ChemicalDissolution {
|
||||
public static final String NAME = "Mekanism Chemical Dissolution Chamber";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasOutput)
|
||||
{
|
||||
if (itemInput == null || gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_DISSOLUTION_CHAMBER,
|
||||
new DissolutionRecipe(InputHelper.toStack(itemInput), GasHelper.toGas(gasOutput))));
|
||||
}
|
||||
|
||||
DissolutionRecipe recipe = new DissolutionRecipe(InputHelper.toStack(itemInput), GasHelper.toGas(gasOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput)
|
||||
{
|
||||
if (gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), gasOutput, itemInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient gasOutput;
|
||||
private IIngredient itemInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient gasOutput, IIngredient itemInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.gasOutput = gasOutput;
|
||||
this.itemInput = itemInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<ItemStackInput, DissolutionRecipe> entry : ((Map<ItemStackInput, DissolutionRecipe>) RecipeHandler.Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
|
||||
IGasStack outputGas = new CraftTweakerGasStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!GasHelper.matches(gasOutput, outputGas))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, gasOutput.toString(), itemInput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<ItemStackInput, GasOutput, DissolutionRecipe>(NAME,
|
||||
RecipeHandler.Recipe.CHEMICAL_DISSOLUTION_CHAMBER, new IngredientWrapper(gasOutput), new IngredientWrapper(itemInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-81
@@ -1,110 +1,42 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ChemicalPairInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.chemical.infuser")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class ChemicalInfuser
|
||||
{
|
||||
public class ChemicalInfuser {
|
||||
public static final String NAME = "Mekanism Chemical Infuser";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IGasStack leftGasInput, IGasStack rightGasInput, IGasStack gasOutput)
|
||||
{
|
||||
if (leftGasInput == null || rightGasInput == null || gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IGasStack leftGasInput, IGasStack rightGasInput, IGasStack gasOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, leftGasInput, rightGasInput, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_INFUSER,
|
||||
new ChemicalInfuserRecipe(GasHelper.toGas(leftGasInput), GasHelper.toGas(rightGasInput), GasHelper.toGas(gasOutput))));
|
||||
}
|
||||
|
||||
ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(GasHelper.toGas(leftGasInput), GasHelper.toGas(rightGasInput), GasHelper.toGas(gasOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_INFUSER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient leftGasInput, @Optional IIngredient rightGasInput)
|
||||
{
|
||||
if (gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (leftGasInput == null)
|
||||
leftGasInput = IngredientAny.INSTANCE;
|
||||
if (rightGasInput == null)
|
||||
rightGasInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.CHEMICAL_INFUSER.get(), gasOutput, leftGasInput, rightGasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient gasOutput;
|
||||
private IIngredient leftGasInput;
|
||||
private IIngredient rightGasInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient gasOutput, IIngredient leftGasInput, IIngredient rightGasInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.gasOutput = gasOutput;
|
||||
this.leftGasInput = leftGasInput;
|
||||
this.rightGasInput = rightGasInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<ChemicalPairInput, ChemicalInfuserRecipe> entry : ((Map<ChemicalPairInput, ChemicalInfuserRecipe>) RecipeHandler.Recipe.CHEMICAL_INFUSER.get()).entrySet())
|
||||
{
|
||||
IGasStack inputGasLeft = new CraftTweakerGasStack(entry.getKey().leftGas);
|
||||
IGasStack inputGasRight = new CraftTweakerGasStack(entry.getKey().rightGas);
|
||||
IGasStack outputGas = new CraftTweakerGasStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!GasHelper.matches(gasOutput, outputGas))
|
||||
continue;
|
||||
if (!GasHelper.matches(leftGasInput, inputGasLeft))
|
||||
continue;
|
||||
if (!GasHelper.matches(rightGasInput, inputGasRight))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", NAME, gasOutput.toString(), leftGasInput.toString(), rightGasInput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient leftGasInput, @Optional IIngredient rightGasInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<ChemicalPairInput, GasOutput, ChemicalInfuserRecipe>(NAME,
|
||||
RecipeHandler.Recipe.CHEMICAL_INFUSER, new IngredientWrapper(gasOutput), new IngredientWrapper(leftGasInput, rightGasInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-86
@@ -1,118 +1,45 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.InjectionRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@ZenClass("mods.mekanism.chemical.injection")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class ChemicalInjection
|
||||
{
|
||||
public class ChemicalInjection {
|
||||
public static final String NAME = "Mekanism Chemical Injection Chamber";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || gasInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, gasInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_INJECTION_CHAMBER,
|
||||
new InjectionRecipe(new AdvancedMachineInput(InputHelper.toStack(itemInput), GasHelper.toGas(gasInput).getGas()),
|
||||
new ItemStackOutput(InputHelper.toStack(itemOutput)))));
|
||||
}
|
||||
|
||||
AdvancedMachineInput input = new AdvancedMachineInput(InputHelper.toStack(itemInput), GasHelper.toGas(gasInput).getGas());
|
||||
ItemStackOutput output = new ItemStackOutput(InputHelper.toStack(itemOutput));
|
||||
|
||||
InjectionRecipe recipe = new InjectionRecipe(input, output);
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput)
|
||||
{
|
||||
if (itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
if (gasInput == null)
|
||||
gasInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.CHEMICAL_INJECTION_CHAMBER.get(), itemOutput, itemInput, gasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient itemInput;
|
||||
private IIngredient gasInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemOutput, IIngredient itemInput, IIngredient gasInput)
|
||||
{
|
||||
super(name, map);
|
||||
this.itemOutput = itemOutput;
|
||||
this.itemInput = itemInput;
|
||||
this.gasInput = gasInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<AdvancedMachineInput, InjectionRecipe> entry : ((Map<AdvancedMachineInput, InjectionRecipe>) RecipeHandler.Recipe.CHEMICAL_INJECTION_CHAMBER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack);
|
||||
IGasStack inputGas = new CraftTweakerGasStack(new GasStack(entry.getKey().gasType, 1));
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasInput, inputGas))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", NAME, itemOutput.toString(), itemInput.toString(), gasInput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<AdvancedMachineInput, ItemStackOutput, InjectionRecipe>(NAME,
|
||||
RecipeHandler.Recipe.CHEMICAL_INJECTION_CHAMBER, new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput, gasInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-75
@@ -1,106 +1,44 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.OxidationRecipe;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.chemical.oxidizer")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class ChemicalOxidizer
|
||||
{
|
||||
public class ChemicalOxidizer {
|
||||
public static final String NAME = "Mekanism Chemical Oxidizer";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasOutput)
|
||||
{
|
||||
if (itemInput == null || gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_OXIDIZER,
|
||||
new OxidationRecipe(InputHelper.toStack(itemInput), GasHelper.toGas(gasOutput))));
|
||||
}
|
||||
|
||||
OxidationRecipe recipe = new OxidationRecipe(InputHelper.toStack(itemInput), GasHelper.toGas(gasOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_OXIDIZER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput)
|
||||
{
|
||||
if (gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.CHEMICAL_OXIDIZER.get(), gasOutput, itemInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient gasOutput;
|
||||
private IIngredient itemInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient gasOutput, IIngredient itemInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.gasOutput = gasOutput;
|
||||
this.itemInput = itemInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<ItemStackInput, OxidationRecipe> entry : ((Map<ItemStackInput, OxidationRecipe>) RecipeHandler.Recipe.CHEMICAL_OXIDIZER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
|
||||
IGasStack outputGas = new CraftTweakerGasStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasOutput, outputGas))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, gasOutput.toString(), itemInput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<ItemStackInput, GasOutput, OxidationRecipe>(NAME,
|
||||
RecipeHandler.Recipe.CHEMICAL_OXIDIZER, new IngredientWrapper(gasOutput), new IngredientWrapper(itemInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-74
@@ -1,103 +1,42 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.GasInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.WasherRecipe;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.chemical.washer")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class ChemicalWasher
|
||||
{
|
||||
public class ChemicalWasher {
|
||||
public static final String NAME = "Mekanism Chemical Washer";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IGasStack gasInput, IGasStack gasOutput)
|
||||
{
|
||||
if (gasInput == null || gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IGasStack gasInput, IGasStack gasOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, gasInput, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_WASHER,
|
||||
new WasherRecipe(GasHelper.toGas(gasInput), GasHelper.toGas(gasOutput))));
|
||||
}
|
||||
|
||||
WasherRecipe recipe = new WasherRecipe(GasHelper.toGas(gasInput), GasHelper.toGas(gasOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CHEMICAL_WASHER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient gasInput)
|
||||
{
|
||||
if (gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (gasInput == null)
|
||||
gasInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.CHEMICAL_WASHER.get(), gasOutput, gasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient gasOutput;
|
||||
private IIngredient gasInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient gasOutput, IIngredient gasInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.gasOutput = gasOutput;
|
||||
this.gasInput = gasInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<GasInput, WasherRecipe> entry : ((Map<GasInput, WasherRecipe>) RecipeHandler.Recipe.CHEMICAL_WASHER.get()).entrySet())
|
||||
{
|
||||
IGasStack inputGas = new CraftTweakerGasStack(entry.getKey().ingredient);
|
||||
IGasStack outputGas = new CraftTweakerGasStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!GasHelper.matches(gasInput, inputGas))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasOutput, outputGas))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, gasOutput.toString(), gasInput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient gasInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<GasInput, GasOutput, WasherRecipe>(NAME,
|
||||
RecipeHandler.Recipe.CHEMICAL_WASHER, new IngredientWrapper(gasOutput), new IngredientWrapper(gasInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,36 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.DoubleMachineInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.CombinerRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.combiner")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Combiner
|
||||
{
|
||||
public class Combiner {
|
||||
public static final String NAME = "Mekanism Combiner";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack extraInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || extraInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack extraInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, extraInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.COMBINER,
|
||||
new CombinerRecipe(new DoubleMachineInput(InputHelper.toStack(itemInput), InputHelper.toStack(extraInput)),
|
||||
new ItemStackOutput(InputHelper.toStack(itemOutput)))));
|
||||
}
|
||||
|
||||
DoubleMachineInput input = new DoubleMachineInput(InputHelper.toStack(itemInput), InputHelper.toStack(extraInput));
|
||||
ItemStackOutput output = new ItemStackOutput(InputHelper.toStack(itemOutput));
|
||||
CombinerRecipe recipe = new CombinerRecipe(input, output);
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.COMBINER.get(), recipe));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,80 +39,18 @@ public class Combiner
|
||||
*/
|
||||
@ZenMethod
|
||||
@Deprecated
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.COMBINER,
|
||||
new CombinerRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput))));
|
||||
}
|
||||
|
||||
CombinerRecipe recipe = new CombinerRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.COMBINER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput)
|
||||
{
|
||||
if (itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (gasInput == null)
|
||||
gasInput = IngredientAny.INSTANCE;
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.COMBINER.get(), itemOutput, itemInput, gasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient itemInput;
|
||||
private IIngredient itemExtra;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemOutput, IIngredient itemInput, IIngredient extraInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.itemOutput = itemOutput;
|
||||
this.itemInput = itemInput;
|
||||
this.itemExtra = extraInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<DoubleMachineInput, CombinerRecipe> entry : ((Map<DoubleMachineInput, CombinerRecipe>) RecipeHandler.Recipe.COMBINER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack);
|
||||
IItemStack extraItem = InputHelper.toIItemStack(entry.getKey().extraStack);
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().getOutput().output);
|
||||
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemExtra, extraItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", NAME, itemInput.toString(), itemExtra.toString(), itemOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<DoubleMachineInput, ItemStackOutput, CombinerRecipe>(NAME,
|
||||
RecipeHandler.Recipe.COMBINER, new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput, gasInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,132 +1,53 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.OsmiumCompressorRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.compressor")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Compressor
|
||||
{
|
||||
public class Compressor {
|
||||
public static final String NAME = "Mekanism Compressor";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.OSMIUM_COMPRESSOR,
|
||||
new OsmiumCompressorRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput))));
|
||||
}
|
||||
|
||||
OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.OSMIUM_COMPRESSOR.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || gasInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, gasInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.OSMIUM_COMPRESSOR,
|
||||
new OsmiumCompressorRecipe(new AdvancedMachineInput(InputHelper.toStack(itemInput), GasHelper.toGas(gasInput).getGas()),
|
||||
new ItemStackOutput(InputHelper.toStack(itemOutput)))));
|
||||
}
|
||||
|
||||
AdvancedMachineInput input = new AdvancedMachineInput(InputHelper.toStack(itemInput), GasHelper.toGas(gasInput).getGas());
|
||||
ItemStackOutput output = new ItemStackOutput(InputHelper.toStack(itemOutput));
|
||||
|
||||
OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(input, output);
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.OSMIUM_COMPRESSOR.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput)
|
||||
{
|
||||
if (itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
if (gasInput == null)
|
||||
gasInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.OSMIUM_COMPRESSOR.get(), itemOutput, itemInput, gasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient itemInput;
|
||||
private IIngredient gasInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemOutput, IIngredient itemInput, IIngredient gasInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.itemOutput = itemOutput;
|
||||
this.itemInput = itemInput;
|
||||
this.gasInput = gasInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<AdvancedMachineInput, OsmiumCompressorRecipe> entry : ((Map<AdvancedMachineInput, OsmiumCompressorRecipe>) RecipeHandler.Recipe.OSMIUM_COMPRESSOR.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack);
|
||||
IGasStack inputGas = new CraftTweakerGasStack(new GasStack(entry.getKey().gasType, 1));
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().getOutput().output);
|
||||
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasInput, inputGas))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", NAME, itemInput.toString(), gasInput.toString(), itemOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<AdvancedMachineInput, ItemStackOutput, OsmiumCompressorRecipe>(NAME,
|
||||
RecipeHandler.Recipe.OSMIUM_COMPRESSOR, new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput, gasInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +1,42 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.CrusherRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.crusher")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Crusher
|
||||
{
|
||||
public class Crusher {
|
||||
public static final String NAME = "Mekanism Crusher";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CRUSHER,
|
||||
new CrusherRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput))));
|
||||
}
|
||||
|
||||
CrusherRecipe recipe = new CrusherRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.CRUSHER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput)
|
||||
{
|
||||
if (itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.CRUSHER.get(), itemOutput, itemInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient itemInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemOutput, IIngredient itemInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.itemOutput = itemOutput;
|
||||
this.itemInput = itemInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<ItemStackInput, CrusherRecipe> entry : ((Map<ItemStackInput, CrusherRecipe>) RecipeHandler.Recipe.CRUSHER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, itemInput.toString(), itemOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<ItemStackInput, ItemStackOutput, CrusherRecipe>(NAME,
|
||||
RecipeHandler.Recipe.CRUSHER, new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-80
@@ -1,117 +1,54 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.SmeltingRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.smelter")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class EnergizedSmelter
|
||||
{
|
||||
public class EnergizedSmelter {
|
||||
public static final String NAME = "Mekanism Smelter";
|
||||
private static boolean removedRecipe = false;
|
||||
private static boolean addedRecipe = false;
|
||||
|
||||
public static boolean hasRemovedRecipe()
|
||||
{
|
||||
public static boolean hasRemovedRecipe() {
|
||||
return removedRecipe;
|
||||
}
|
||||
|
||||
public static boolean hasAddedRecipe()
|
||||
{
|
||||
public static boolean hasAddedRecipe() {
|
||||
return addedRecipe;
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.ENERGIZED_SMELTER,
|
||||
new SmeltingRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput))));
|
||||
addedRecipe = true;
|
||||
}
|
||||
|
||||
SmeltingRecipe recipe = new SmeltingRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.ENERGIZED_SMELTER.get(), recipe));
|
||||
addedRecipe = true;
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput)
|
||||
{
|
||||
if (itemInput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemOutput == null)
|
||||
itemOutput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.ENERGIZED_SMELTER.get(), itemInput, itemOutput));
|
||||
removedRecipe = true;
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemInput;
|
||||
private IIngredient itemOutput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemInput, IIngredient itemOutput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.itemInput = itemInput;
|
||||
this.itemOutput = itemOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<ItemStackInput, SmeltingRecipe> entry : ((Map<ItemStackInput, SmeltingRecipe>) RecipeHandler.Recipe.ENERGIZED_SMELTER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, itemInput.toString(), itemOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<ItemStackInput, ItemStackOutput, SmeltingRecipe>(NAME,
|
||||
RecipeHandler.Recipe.ENERGIZED_SMELTER, new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput)));
|
||||
removedRecipe = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +1,42 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.EnrichmentRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.enrichment")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Enrichment
|
||||
{
|
||||
public class Enrichment {
|
||||
public static final String NAME = "Mekanism Enrichment Chamber";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.ENRICHMENT_CHAMBER,
|
||||
new EnrichmentRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput))));
|
||||
}
|
||||
|
||||
EnrichmentRecipe recipe = new EnrichmentRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.ENRICHMENT_CHAMBER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput)
|
||||
{
|
||||
if (itemInput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemOutput == null)
|
||||
itemOutput = IngredientAny.INSTANCE;
|
||||
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.ENRICHMENT_CHAMBER.get(), itemInput, itemOutput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient itemInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemInput, IIngredient itemOutput)
|
||||
{
|
||||
super(name, map);
|
||||
this.itemOutput = itemOutput;
|
||||
this.itemInput = itemInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<ItemStackInput, EnrichmentRecipe> entry : ((Map<ItemStackInput, EnrichmentRecipe>) RecipeHandler.Recipe.ENRICHMENT_CHAMBER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, itemInput.toString(), itemOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<ItemStackInput, ItemStackOutput, EnrichmentRecipe>(NAME,
|
||||
RecipeHandler.Recipe.ENRICHMENT_CHAMBER, new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,114 +2,48 @@ package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.infuser")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Infuser
|
||||
{
|
||||
public class Infuser {
|
||||
public static final String NAME = "Mekanism Metallurgic Infuser";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(String infuseType, int infuseAmount, IItemStack itemInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || itemOutput == null || infuseType == null || infuseType.isEmpty())
|
||||
{
|
||||
public static void addRecipe(String infuseType, int infuseAmount, IItemStack itemInput, IItemStack itemOutput) {
|
||||
if (infuseType == null || infuseType.isEmpty()) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
InfusionInput input = new InfusionInput(InfuseRegistry.get(infuseType), infuseAmount, InputHelper.toStack(itemInput));
|
||||
ItemStackOutput output = new ItemStackOutput(InputHelper.toStack(itemOutput));
|
||||
|
||||
MetallurgicInfuserRecipe recipe = new MetallurgicInfuserRecipe(input, output);
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.METALLURGIC_INFUSER.get(), recipe));
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.METALLURGIC_INFUSER,
|
||||
new MetallurgicInfuserRecipe(new InfusionInput(InfuseRegistry.get(infuseType), infuseAmount, InputHelper.toStack(itemInput)),
|
||||
new ItemStackOutput(InputHelper.toStack(itemOutput)))));
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional String infuseType)
|
||||
{
|
||||
if (itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
if (infuseType == null)
|
||||
infuseType = "";
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.METALLURGIC_INFUSER.get(), itemOutput, itemInput, infuseType));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient itemInput;
|
||||
private String infuseType;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemOutput, IIngredient itemInput, String infuseType)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.itemOutput = itemOutput;
|
||||
this.itemInput = itemInput;
|
||||
this.infuseType = infuseType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<InfusionInput, MetallurgicInfuserRecipe> entry : ((Map<InfusionInput, MetallurgicInfuserRecipe>) RecipeHandler.Recipe.METALLURGIC_INFUSER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().inputStack);
|
||||
String typeInfuse = entry.getKey().infuse.type.name;
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!infuseType.isEmpty() && !infuseType.equalsIgnoreCase(typeInfuse))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, itemInput.toString(), itemOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional String infuseType) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<InfusionInput, ItemStackOutput, MetallurgicInfuserRecipe>(NAME,
|
||||
RecipeHandler.Recipe.METALLURGIC_INFUSER, new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput, infuseType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,132 +1,53 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.PurificationRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.purification")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Purification
|
||||
{
|
||||
public class Purification {
|
||||
public static final String NAME = "Mekanism Purification";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.PURIFICATION_CHAMBER,
|
||||
new PurificationRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput))));
|
||||
}
|
||||
|
||||
PurificationRecipe recipe = new PurificationRecipe(InputHelper.toStack(itemInput), InputHelper.toStack(itemOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.PURIFICATION_CHAMBER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput)
|
||||
{
|
||||
if (itemInput == null || gasInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, gasInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.PURIFICATION_CHAMBER,
|
||||
new PurificationRecipe(new AdvancedMachineInput(InputHelper.toStack(itemInput), GasHelper.toGas(gasInput).getGas()),
|
||||
new ItemStackOutput(InputHelper.toStack(itemOutput)))));
|
||||
}
|
||||
|
||||
AdvancedMachineInput input = new AdvancedMachineInput(InputHelper.toStack(itemInput), GasHelper.toGas(gasInput).getGas());
|
||||
ItemStackOutput output = new ItemStackOutput(InputHelper.toStack(itemOutput));
|
||||
|
||||
PurificationRecipe recipe = new PurificationRecipe(input, output);
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.PURIFICATION_CHAMBER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput)
|
||||
{
|
||||
if (itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
if (gasInput == null)
|
||||
gasInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.PURIFICATION_CHAMBER.get(), itemOutput, itemInput, gasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient itemInput;
|
||||
private IIngredient gasInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemOutput, IIngredient itemInput, IIngredient gasInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.itemOutput = itemOutput;
|
||||
this.itemInput = itemInput;
|
||||
this.gasInput = gasInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<AdvancedMachineInput, PurificationRecipe> entry : ((Map<AdvancedMachineInput, PurificationRecipe>) RecipeHandler.Recipe.PURIFICATION_CHAMBER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack);
|
||||
IGasStack inputGas = new CraftTweakerGasStack(new GasStack(entry.getKey().gasType, 1));
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasInput, inputGas))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", NAME, itemOutput.toString(), itemInput.toString(), gasInput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<AdvancedMachineInput, ItemStackOutput, PurificationRecipe>(NAME,
|
||||
RecipeHandler.Recipe.PURIFICATION_CHAMBER, new IngredientWrapper(itemOutput), new IngredientWrapper(itemInput, gasInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,132 +1,48 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import crafttweaker.api.liquid.ILiquidStack;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.inputs.PressurizedInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.PressurizedRecipe;
|
||||
import mekanism.common.recipe.outputs.PressurizedOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@ZenClass("mods.mekanism.reaction")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Reaction
|
||||
{
|
||||
public class Reaction {
|
||||
public static final String NAME = "Mekanism Reaction";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, ILiquidStack liquidInput, IGasStack gasInput, IItemStack itemOutput, IGasStack gasOutput, double energy, int duration)
|
||||
{
|
||||
if (itemInput == null || liquidInput == null || gasInput == null || itemOutput == null || gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, ILiquidStack liquidInput, IGasStack gasInput, IItemStack itemOutput, IGasStack gasOutput, double energy, int duration) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, liquidInput, gasInput, itemOutput, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.PRESSURIZED_REACTION_CHAMBER,
|
||||
new PressurizedRecipe(new PressurizedInput(InputHelper.toStack(itemInput), InputHelper.toFluid(liquidInput), GasHelper.toGas(gasInput)),
|
||||
new PressurizedOutput(InputHelper.toStack(itemOutput), GasHelper.toGas(gasOutput)),
|
||||
energy, duration)));
|
||||
}
|
||||
|
||||
PressurizedInput input = new PressurizedInput(InputHelper.toStack(itemInput), InputHelper.toFluid(liquidInput), GasHelper.toGas(gasInput));
|
||||
PressurizedOutput output = new PressurizedOutput(InputHelper.toStack(itemOutput), GasHelper.toGas(gasOutput));
|
||||
|
||||
PressurizedRecipe recipe = new PressurizedRecipe(input, output, energy, duration);
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.PRESSURIZED_REACTION_CHAMBER.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemOutput, IIngredient gasOutput, @Optional IIngredient itemInput, @Optional IIngredient liquidInput, @Optional IIngredient gasInput)
|
||||
{
|
||||
if (itemOutput == null || gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInput == null)
|
||||
itemInput = IngredientAny.INSTANCE;
|
||||
if (liquidInput == null)
|
||||
liquidInput = IngredientAny.INSTANCE;
|
||||
if (gasInput == null)
|
||||
gasInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.PRESSURIZED_REACTION_CHAMBER.get(), itemOutput, gasOutput, itemInput, liquidInput, gasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient gasOutput;
|
||||
private IIngredient itemInput;
|
||||
private IIngredient liquidInput;
|
||||
private IIngredient gasInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemOutput, IIngredient gasOutput, IIngredient itemInput, IIngredient liquidInput, IIngredient gasInput)
|
||||
{
|
||||
super(name, map);
|
||||
|
||||
this.itemOutput = itemOutput;
|
||||
this.gasOutput = gasOutput;
|
||||
this.itemInput = itemInput;
|
||||
this.liquidInput = liquidInput;
|
||||
this.gasInput = gasInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<PressurizedInput, PressurizedRecipe> entry : ((Map<PressurizedInput, PressurizedRecipe>) RecipeHandler.Recipe.PRESSURIZED_REACTION_CHAMBER.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().getSolid());
|
||||
ILiquidStack inputLiquid = InputHelper.toILiquidStack(entry.getKey().getFluid());
|
||||
IGasStack inputGas = new CraftTweakerGasStack(entry.getKey().getGas());
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.getItemOutput());
|
||||
IGasStack outputGas = new CraftTweakerGasStack(entry.getValue().recipeOutput.getGasOutput());
|
||||
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(liquidInput, inputLiquid))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasInput, inputGas))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasOutput, outputGas))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s, %s, %s, %s and %s. Command ignored!", NAME, itemOutput.toString(), gasOutput.toString(), itemInput.toString(), liquidInput.toString(), gasInput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemOutput, IIngredient gasOutput, @Optional IIngredient itemInput, @Optional IIngredient liquidInput, @Optional IIngredient gasInput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemOutput, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<PressurizedInput, PressurizedOutput, PressurizedRecipe>(NAME,
|
||||
RecipeHandler.Recipe.PRESSURIZED_REACTION_CHAMBER, new IngredientWrapper(itemOutput, gasOutput), new IngredientWrapper(itemInput, liquidInput, gasInput)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,115 +1,44 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.SawmillRecipe;
|
||||
import mekanism.common.recipe.outputs.ChanceOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.toStack;
|
||||
|
||||
@ZenClass("mods.mekanism.sawmill")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Sawmill
|
||||
{
|
||||
public class Sawmill {
|
||||
public static final String NAME = "Mekanism Sawmill";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput, @Optional IItemStack optionalItemOutput, @Optional double optionalChance)
|
||||
{
|
||||
if (itemInput == null || itemOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IItemStack itemInput, IItemStack itemOutput, @Optional IItemStack optionalItemOutput, @Optional double optionalChance) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput, itemOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.PRECISION_SAWMILL,
|
||||
new SawmillRecipe(new ItemStackInput(toStack(itemInput)),
|
||||
optionalItemOutput == null ? new ChanceOutput(toStack(itemOutput)) : new ChanceOutput(toStack(itemOutput), toStack(optionalItemOutput), optionalChance))));
|
||||
}
|
||||
|
||||
ItemStackInput input = new ItemStackInput(toStack(itemInput));
|
||||
ChanceOutput output = optionalItemOutput == null ? new ChanceOutput(toStack(itemOutput)) : new ChanceOutput(toStack(itemOutput), toStack(optionalItemOutput), optionalChance);
|
||||
|
||||
SawmillRecipe recipe = new SawmillRecipe(input, output);
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.PRECISION_SAWMILL.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput, @Optional IIngredient optionalItemOutput)
|
||||
{
|
||||
if (itemInput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemOutput == null)
|
||||
itemOutput = IngredientAny.INSTANCE;
|
||||
if (optionalItemOutput == null)
|
||||
optionalItemOutput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.PRECISION_SAWMILL.get(), itemInput, itemOutput, optionalItemOutput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient itemInput;
|
||||
private IIngredient itemOutput;
|
||||
private IIngredient optionalItemOutput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient itemInput, IIngredient itemOutput, IIngredient optionalItemOutput)
|
||||
{
|
||||
super(name, map);
|
||||
this.itemInput = itemInput;
|
||||
this.itemOutput = itemOutput;
|
||||
this.optionalItemOutput = optionalItemOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<ItemStackInput, SawmillRecipe> entry : ((Map<ItemStackInput, SawmillRecipe>) RecipeHandler.Recipe.PRECISION_SAWMILL.get()).entrySet())
|
||||
{
|
||||
IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient);
|
||||
IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.primaryOutput);
|
||||
IItemStack outputItemOptional = InputHelper.toIItemStack(entry.getValue().recipeOutput.secondaryOutput);
|
||||
|
||||
if (!StackHelper.matches(itemOutput, outputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(itemInput, inputItem))
|
||||
continue;
|
||||
if (!StackHelper.matches(optionalItemOutput, outputItemOptional))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, itemInput.toString(), itemOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput, @Optional IIngredient optionalItemOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, itemInput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<ItemStackInput, ChanceOutput, SawmillRecipe>(NAME,
|
||||
RecipeHandler.Recipe.PRECISION_SAWMILL, new IngredientWrapper(itemInput), new IngredientWrapper(itemOutput, optionalItemOutput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,112 +1,44 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import crafttweaker.api.liquid.ILiquidStack;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.FluidInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.SeparatorRecipe;
|
||||
import mekanism.common.recipe.outputs.ChemicalPairOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.separator")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class Separator
|
||||
{
|
||||
public class Separator {
|
||||
public static final String NAME = "Mekanism Separator";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack liquidInput, double energy, IGasStack leftGasOutput, IGasStack rightGasOutput)
|
||||
{
|
||||
if (liquidInput == null || leftGasOutput == null || rightGasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(ILiquidStack liquidInput, double energy, IGasStack leftGasOutput, IGasStack rightGasOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, liquidInput, leftGasOutput, rightGasOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR,
|
||||
new SeparatorRecipe(InputHelper.toFluid(liquidInput), energy, GasHelper.toGas(leftGasOutput), GasHelper.toGas(rightGasOutput))));
|
||||
}
|
||||
|
||||
SeparatorRecipe recipe = new SeparatorRecipe(InputHelper.toFluid(liquidInput), energy, GasHelper.toGas(leftGasOutput), GasHelper.toGas(rightGasOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient leftGasInput, @Optional IIngredient rightGasInput)
|
||||
{
|
||||
if (liquidInput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (leftGasInput == null)
|
||||
leftGasInput = IngredientAny.INSTANCE;
|
||||
if (rightGasInput == null)
|
||||
leftGasInput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.get(), liquidInput, leftGasInput, rightGasInput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient liquidInput;
|
||||
private IIngredient leftGasInput;
|
||||
private IIngredient rightGasInput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient liquidInput, IIngredient leftGasInput, IIngredient rightGasInput)
|
||||
{
|
||||
super(name, map);
|
||||
this.liquidInput = liquidInput;
|
||||
this.leftGasInput = leftGasInput;
|
||||
this.rightGasInput = rightGasInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<FluidInput, SeparatorRecipe> entry : ((Map<FluidInput, SeparatorRecipe>) RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.get()).entrySet())
|
||||
{
|
||||
ILiquidStack inputLiquid = InputHelper.toILiquidStack(entry.getKey().ingredient);
|
||||
IGasStack outputItemLeft = new CraftTweakerGasStack(entry.getValue().recipeOutput.leftGas);
|
||||
IGasStack outputItemRight = new CraftTweakerGasStack(entry.getValue().recipeOutput.rightGas);
|
||||
|
||||
if (!StackHelper.matches(liquidInput, inputLiquid))
|
||||
continue;
|
||||
if (!GasHelper.matches(leftGasInput, outputItemLeft))
|
||||
continue;
|
||||
if (!GasHelper.matches(rightGasInput, outputItemRight))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", NAME, liquidInput.toString(), leftGasInput.toString(), rightGasInput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient leftGasOutput, @Optional IIngredient rightGasOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, liquidInput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<FluidInput, ChemicalPairOutput, SeparatorRecipe>(NAME,
|
||||
RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR, new IngredientWrapper(liquidInput), new IngredientWrapper(leftGasOutput, rightGasOutput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-73
@@ -1,102 +1,42 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.helpers.GasHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.GasInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.SolarNeutronRecipe;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.solarneutronactivator")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class SolarNeutronActivator
|
||||
{
|
||||
public class SolarNeutronActivator {
|
||||
public static final String NAME = "Mekanism Solar Neutron Activator";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IGasStack gasInput, IGasStack gasOutput)
|
||||
{
|
||||
if (gasInput == null || gasOutput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
public static void addRecipe(IGasStack gasInput, IGasStack gasOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, gasInput, gasOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.SOLAR_NEUTRON_ACTIVATOR,
|
||||
new SolarNeutronRecipe(GasHelper.toGas(gasInput), GasHelper.toGas(gasOutput))));
|
||||
}
|
||||
|
||||
SolarNeutronRecipe recipe = new SolarNeutronRecipe(GasHelper.toGas(gasInput), GasHelper.toGas(gasOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.SOLAR_NEUTRON_ACTIVATOR.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient gasInput, @Optional IIngredient gasOutput)
|
||||
{
|
||||
if (gasInput == null)
|
||||
{
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if (gasOutput == null)
|
||||
gasOutput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.SOLAR_NEUTRON_ACTIVATOR.get(), gasInput, gasOutput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient gasInput;
|
||||
private IIngredient gasOutput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient gasInput, IIngredient gasOutput)
|
||||
{
|
||||
super(name, map);
|
||||
this.gasInput = gasInput;
|
||||
this.gasOutput = gasOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for (Map.Entry<GasInput, SolarNeutronRecipe> entry : ((Map<GasInput, SolarNeutronRecipe>) RecipeHandler.Recipe.SOLAR_NEUTRON_ACTIVATOR.get()).entrySet())
|
||||
{
|
||||
IGasStack inputGas = new CraftTweakerGasStack(entry.getKey().ingredient);
|
||||
IGasStack outputGas = new CraftTweakerGasStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if (!GasHelper.matches(gasInput, inputGas))
|
||||
continue;
|
||||
if (!GasHelper.matches(gasOutput, outputGas))
|
||||
continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!recipesToRemove.isEmpty())
|
||||
{
|
||||
recipes.putAll(recipesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, gasInput.toString(), gasOutput.toString()));
|
||||
}
|
||||
public static void removeRecipe(IIngredient gasInput, @Optional IIngredient gasOutput) {
|
||||
if (IngredientHelper.checkNotNull(NAME, gasInput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<GasInput, GasOutput, SolarNeutronRecipe>(NAME,
|
||||
RecipeHandler.Recipe.SOLAR_NEUTRON_ACTIVATOR, new IngredientWrapper(gasOutput), new IngredientWrapper(gasInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-60
@@ -1,91 +1,42 @@
|
||||
package mekanism.common.integration.crafttweaker.handlers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import crafttweaker.api.liquid.ILiquidStack;
|
||||
import mekanism.common.integration.crafttweaker.CrafttweakerIntegration;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.util.AddMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.RemoveMekanismRecipe;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.FluidInput;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.ThermalEvaporationRecipe;
|
||||
import mekanism.common.recipe.outputs.FluidOutput;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenClass("mods.mekanism.thermalevaporation")
|
||||
@ModOnly("mtlib")
|
||||
@ZenRegister
|
||||
public class ThermalEvaporation
|
||||
{
|
||||
public class ThermalEvaporation {
|
||||
public static final String NAME = "Mekanism Solar Evaporation";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack liquidInput, ILiquidStack liquidOutput) {
|
||||
if(liquidInput == null || liquidOutput == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
if (IngredientHelper.checkNotNull(NAME, liquidInput, liquidOutput)) {
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.THERMAL_EVAPORATION_PLANT,
|
||||
new ThermalEvaporationRecipe(InputHelper.toFluid(liquidInput), InputHelper.toFluid(liquidOutput))));
|
||||
}
|
||||
|
||||
ThermalEvaporationRecipe recipe = new ThermalEvaporationRecipe(InputHelper.toFluid(liquidInput), InputHelper.toFluid(liquidOutput));
|
||||
|
||||
CrafttweakerIntegration.LATE_ADDITIONS.add(new AddMekanismRecipe(NAME, RecipeHandler.Recipe.THERMAL_EVAPORATION_PLANT.get(), recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient liquidOutput) {
|
||||
if(liquidInput == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if(liquidOutput == null) liquidOutput = IngredientAny.INSTANCE;
|
||||
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new Remove(NAME, RecipeHandler.Recipe.THERMAL_EVAPORATION_PLANT.get(), liquidInput, liquidOutput));
|
||||
}
|
||||
|
||||
private static class Remove extends RemoveMekanismRecipe
|
||||
{
|
||||
private IIngredient liquidInput;
|
||||
private IIngredient liquidOutput;
|
||||
|
||||
public Remove(String name, Map<MachineInput, MachineRecipe> map, IIngredient liquidInput, IIngredient liquidOutput)
|
||||
{
|
||||
super(name, map);
|
||||
this.liquidInput = liquidInput;
|
||||
this.liquidOutput = liquidOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipes()
|
||||
{
|
||||
Map<MachineInput, MachineRecipe> recipesToRemove = new HashMap<>();
|
||||
|
||||
for(Map.Entry<FluidInput, ThermalEvaporationRecipe> entry : ((Map<FluidInput, ThermalEvaporationRecipe>) RecipeHandler.Recipe.THERMAL_EVAPORATION_PLANT.get()).entrySet() ) {
|
||||
ILiquidStack inputLiquid = InputHelper.toILiquidStack(entry.getKey().ingredient);
|
||||
ILiquidStack outputLiquid = InputHelper.toILiquidStack(entry.getValue().recipeOutput.output);
|
||||
|
||||
if(!StackHelper.matches(liquidInput, inputLiquid)) continue;
|
||||
if(!StackHelper.matches(liquidOutput, outputLiquid)) continue;
|
||||
|
||||
recipesToRemove.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if(!recipesToRemove.isEmpty()) {
|
||||
recipes.putAll(recipesToRemove);
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", NAME, liquidInput.toString(), liquidOutput.toString()));
|
||||
}
|
||||
if (IngredientHelper.checkNotNull(NAME, liquidInput)) {
|
||||
CrafttweakerIntegration.LATE_REMOVALS.add(new RemoveMekanismRecipe<FluidInput, FluidOutput, ThermalEvaporationRecipe>(NAME,
|
||||
RecipeHandler.Recipe.THERMAL_EVAPORATION_PLANT, new IngredientWrapper(liquidOutput), new IngredientWrapper(liquidInput)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,47 +6,31 @@ import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
|
||||
public class GasHelper
|
||||
{
|
||||
private GasHelper()
|
||||
{
|
||||
public class GasHelper {
|
||||
private GasHelper() {
|
||||
}
|
||||
|
||||
public static boolean matches(IIngredient ingredient, IGasStack gasStack)
|
||||
{
|
||||
if (ingredient == null)
|
||||
{
|
||||
public static boolean matches(IIngredient ingredient, IGasStack gasStack) {
|
||||
if (ingredient == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ingredient == IngredientAny.INSTANCE)
|
||||
{
|
||||
if (ingredient == IngredientAny.INSTANCE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ingredient instanceof IGasStack)
|
||||
{
|
||||
if (ingredient instanceof IGasStack) {
|
||||
return toGas((IGasStack) ingredient).isGasEqual(toGas(gasStack));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static GasStack toGas(IGasStack iStack)
|
||||
{
|
||||
if (iStack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
return new GasStack(GasRegistry.getGas(iStack.getName()), iStack.getAmount());
|
||||
public static GasStack toGas(IGasStack iStack) {
|
||||
return iStack == null ? null : new GasStack(GasRegistry.getGas(iStack.getName()), iStack.getAmount());
|
||||
}
|
||||
|
||||
public static GasStack[] toGases(IGasStack[] iStack)
|
||||
{
|
||||
public static GasStack[] toGases(IGasStack[] iStack) {
|
||||
GasStack[] stack = new GasStack[iStack.length];
|
||||
for (int i = 0; i < stack.length; i++)
|
||||
stack[i] = toGas(iStack[i]);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package mekanism.common.integration.crafttweaker.helpers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.helpers.StackHelper;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import crafttweaker.api.liquid.ILiquidStack;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.CraftTweakerGasStack;
|
||||
import mekanism.common.integration.crafttweaker.gas.IGasStack;
|
||||
import mekanism.common.integration.crafttweaker.util.IngredientWrapper;
|
||||
import mekanism.common.recipe.inputs.*;
|
||||
import mekanism.common.recipe.outputs.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class IngredientHelper {
|
||||
private IngredientHelper() {
|
||||
}
|
||||
|
||||
public static IIngredient optionalIngredient(IIngredient ingredient) {
|
||||
return ingredient != null ? ingredient : IngredientAny.INSTANCE;
|
||||
}
|
||||
|
||||
public static boolean checkNotNull(String name, IIngredient... ingredients) {
|
||||
for (IIngredient ingredient : ingredients) {
|
||||
if (ingredient == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static IIngredient getIngredient(Object ingredient) {
|
||||
if (ingredient instanceof ItemStack) {
|
||||
return InputHelper.toIItemStack((ItemStack) ingredient);
|
||||
} else if (ingredient instanceof GasStack) {
|
||||
return new CraftTweakerGasStack((GasStack) ingredient);
|
||||
} else if (ingredient instanceof Gas) {
|
||||
return new CraftTweakerGasStack(new GasStack((Gas) ingredient, 1));
|
||||
} else if (ingredient instanceof FluidStack) {
|
||||
return InputHelper.toILiquidStack((FluidStack) ingredient);
|
||||
} else if (ingredient instanceof Fluid) {
|
||||
return InputHelper.toILiquidStack(new FluidStack((Fluid) ingredient, 1));
|
||||
}
|
||||
//TODO: Support other types of things like ore dict
|
||||
return IngredientAny.INSTANCE;
|
||||
}
|
||||
|
||||
public static boolean matches(IIngredient input, IIngredient toMatch) {
|
||||
if (input instanceof IGasStack) {
|
||||
return GasHelper.matches(toMatch, (IGasStack) input);
|
||||
} else if (input instanceof IItemStack) {
|
||||
return StackHelper.matches(toMatch, (IItemStack) input);
|
||||
} else if (input instanceof ILiquidStack) {
|
||||
return StackHelper.matches(toMatch, (ILiquidStack) input);
|
||||
}
|
||||
//TODO: Support other types of things like ore dict
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(Object input, IIngredient toMatch) {
|
||||
return matches(getIngredient(input), toMatch);
|
||||
}
|
||||
|
||||
public static <INPUT extends MachineInput<INPUT>> boolean matches(INPUT in, IngredientWrapper toMatch) {
|
||||
if (in instanceof ItemStackInput) {
|
||||
ItemStackInput input = (ItemStackInput) in;
|
||||
return matches(input.ingredient, toMatch.getIngredient());
|
||||
} else if (in instanceof GasInput) {
|
||||
GasInput input = (GasInput) in;
|
||||
return matches(input.ingredient, toMatch.getIngredient());
|
||||
} else if (in instanceof FluidInput) {
|
||||
FluidInput input = (FluidInput) in;
|
||||
return matches(input.ingredient, toMatch.getIngredient());
|
||||
} else if (in instanceof AdvancedMachineInput) {
|
||||
AdvancedMachineInput input = (AdvancedMachineInput) in;
|
||||
return matches(input.gasType, toMatch.getLeft()) && matches(input.itemStack, toMatch.getRight());
|
||||
} else if (in instanceof ChemicalPairInput) {
|
||||
ChemicalPairInput input = (ChemicalPairInput) in;
|
||||
return matches(input.leftGas, toMatch.getLeft()) && matches(input.rightGas, toMatch.getRight());
|
||||
} else if (in instanceof DoubleMachineInput) {
|
||||
DoubleMachineInput input = (DoubleMachineInput) in;
|
||||
return matches(input.itemStack, toMatch.getLeft()) && matches(input.extraStack, toMatch.getRight());
|
||||
} else if (in instanceof PressurizedInput) {
|
||||
PressurizedInput input = (PressurizedInput) in;
|
||||
return matches(input.getSolid(), toMatch.getLeft()) && matches(input.getFluid(), toMatch.getMiddle()) && matches(input.getGas(), toMatch.getRight());
|
||||
} else if (in instanceof InfusionInput) {
|
||||
InfusionInput input = (InfusionInput) in;
|
||||
return matches(input.inputStack, toMatch.getIngredient()) && (toMatch.getInfuseType().isEmpty() || toMatch.getInfuseType().equalsIgnoreCase(input.infuse.type.name));
|
||||
} else if (in instanceof IntegerInput) {
|
||||
IntegerInput input = (IntegerInput) in;
|
||||
return input.ingredient == toMatch.getAmount();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static <OUTPUT extends MachineOutput<OUTPUT>> boolean matches(OUTPUT out, IngredientWrapper toMatch) {
|
||||
if (out instanceof ItemStackOutput) {
|
||||
ItemStackOutput output = (ItemStackOutput) out;
|
||||
return matches(output.output, toMatch.getIngredient());
|
||||
} else if (out instanceof GasOutput) {
|
||||
GasOutput output = (GasOutput) out;
|
||||
return matches(output.output, toMatch.getIngredient());
|
||||
} else if (out instanceof FluidOutput) {
|
||||
FluidOutput output = (FluidOutput) out;
|
||||
return matches(output.output, toMatch.getIngredient());
|
||||
} else if (out instanceof ChanceOutput) {
|
||||
ChanceOutput output = (ChanceOutput) out;
|
||||
return matches(output.primaryOutput, toMatch.getLeft()) && matches(output.secondaryOutput, toMatch.getRight());
|
||||
} else if (out instanceof ChemicalPairOutput) {
|
||||
ChemicalPairOutput output = (ChemicalPairOutput) out;
|
||||
return matches(output.leftGas, toMatch.getLeft()) && matches(output.rightGas, toMatch.getRight());
|
||||
} else if (out instanceof PressurizedOutput) {
|
||||
PressurizedOutput output = (PressurizedOutput) out;
|
||||
return matches(output.getItemOutput(), toMatch.getLeft()) && matches(output.getGasOutput(), toMatch.getRight());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package mekanism.common.integration.crafttweaker.helpers;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class RecipeInfoHelper {
|
||||
private RecipeInfoHelper() {
|
||||
}
|
||||
|
||||
public static String getRecipeInfo(Map.Entry<? extends MachineInput, ? extends MachineRecipe> recipe) {
|
||||
MachineOutput output = recipe.getValue().recipeOutput;
|
||||
if (output instanceof ItemStackOutput) {
|
||||
return LogHelper.getStackDescription(((ItemStackOutput) output).output);
|
||||
} else if (output instanceof GasOutput) {
|
||||
return LogHelper.getStackDescription(((GasOutput) output).output);
|
||||
} else if (output instanceof FluidOutput) {
|
||||
return LogHelper.getStackDescription(((FluidOutput) output).output);
|
||||
} else if (output instanceof ChemicalPairOutput) {
|
||||
ChemicalPairOutput out = (ChemicalPairOutput) output;
|
||||
return "[" + LogHelper.getStackDescription(out.leftGas) + ", " + LogHelper.getStackDescription(out.rightGas) + "]";
|
||||
} else if (output instanceof ChanceOutput) {
|
||||
return LogHelper.getStackDescription(((ChanceOutput) output).primaryOutput);
|
||||
} else if (output instanceof PressurizedOutput) {
|
||||
PressurizedOutput out = (PressurizedOutput) output;
|
||||
return "[" + LogHelper.getStackDescription(out.getItemOutput()) + ", " + LogHelper.getStackDescription(out.getGasOutput()) + "]";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +1,21 @@
|
||||
package mekanism.common.integration.crafttweaker.util;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
||||
import mekanism.common.integration.crafttweaker.helpers.RecipeInfoHelper;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ChanceOutput;
|
||||
import mekanism.common.recipe.outputs.ChemicalPairOutput;
|
||||
import mekanism.common.recipe.outputs.FluidOutput;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import mekanism.common.recipe.outputs.MachineOutput;
|
||||
import mekanism.common.recipe.outputs.PressurizedOutput;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AddMekanismRecipe extends BaseMapAddition<MachineInput, MachineRecipe>
|
||||
{
|
||||
private MachineRecipe recipe;
|
||||
|
||||
public AddMekanismRecipe(String name, Map<MachineInput, MachineRecipe> map, MachineRecipe recipe)
|
||||
{
|
||||
super(name, map);
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
public void addRecipes()
|
||||
{
|
||||
this.recipes.put(recipe.getInput(), recipe);
|
||||
public class AddMekanismRecipe extends BaseMapAddition<MachineInput, MachineRecipe> {
|
||||
public AddMekanismRecipe(String name, Recipe recipeType, MachineRecipe recipe) {
|
||||
super(name, recipeType.get());
|
||||
recipes.put(recipe.getInput(), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
addRecipes();
|
||||
|
||||
super.apply();
|
||||
protected String getRecipeInfo(Map.Entry<MachineInput, MachineRecipe> recipe) {
|
||||
return RecipeInfoHelper.getRecipeInfo(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<MachineInput, MachineRecipe> recipe)
|
||||
{
|
||||
MachineOutput output = recipe.getValue().recipeOutput;
|
||||
|
||||
if (output instanceof ItemStackOutput)
|
||||
{
|
||||
return LogHelper.getStackDescription(((ItemStackOutput) output).output);
|
||||
}
|
||||
else if (output instanceof GasOutput)
|
||||
{
|
||||
return LogHelper.getStackDescription(((GasOutput) output).output);
|
||||
}
|
||||
else if (output instanceof FluidOutput)
|
||||
{
|
||||
return LogHelper.getStackDescription(((FluidOutput) output).output);
|
||||
}
|
||||
else if (output instanceof ChemicalPairOutput)
|
||||
{
|
||||
return "[" + LogHelper.getStackDescription(((ChemicalPairOutput) output).leftGas) + ", " + LogHelper.getStackDescription(((ChemicalPairOutput) output).rightGas) + "]";
|
||||
}
|
||||
else if (output instanceof ChanceOutput)
|
||||
{
|
||||
return LogHelper.getStackDescription(((ChanceOutput) output).primaryOutput);
|
||||
}
|
||||
else if (output instanceof PressurizedOutput)
|
||||
{
|
||||
return "[" + LogHelper.getStackDescription(((PressurizedOutput) output).getItemOutput()) + ", " + LogHelper.getStackDescription(((PressurizedOutput) output).getGasOutput()) + "]";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package mekanism.common.integration.crafttweaker.util;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IngredientAny;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
|
||||
public class IngredientWrapper {
|
||||
private final IIngredient left;
|
||||
private final IIngredient middle;
|
||||
private final IIngredient right;
|
||||
private final String infuseType;
|
||||
|
||||
public IngredientWrapper(IIngredient ingredient) {
|
||||
this(ingredient, IngredientAny.INSTANCE);
|
||||
}
|
||||
|
||||
public IngredientWrapper(IIngredient left, IIngredient right) {
|
||||
this(left, IngredientAny.INSTANCE, right);
|
||||
}
|
||||
|
||||
public IngredientWrapper(IIngredient left, IIngredient middle, IIngredient right) {
|
||||
this.left = IngredientHelper.optionalIngredient(left);
|
||||
this.middle = IngredientHelper.optionalIngredient(middle);
|
||||
this.right = IngredientHelper.optionalIngredient(right);
|
||||
this.infuseType = "";
|
||||
}
|
||||
|
||||
public IngredientWrapper(IIngredient ingredient, String infuseType) {
|
||||
this.left = IngredientHelper.optionalIngredient(ingredient);
|
||||
this.middle = IngredientAny.INSTANCE;
|
||||
this.right = IngredientAny.INSTANCE;
|
||||
this.infuseType = infuseType == null ? "" : infuseType;
|
||||
}
|
||||
|
||||
public String getInfuseType() {
|
||||
return this.infuseType;
|
||||
}
|
||||
|
||||
public IIngredient getIngredient() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public IIngredient getLeft() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public IIngredient getMiddle() {
|
||||
return this.middle;
|
||||
}
|
||||
|
||||
public IIngredient getRight() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
//TODO: Make this method actually do something if we ever need to use IntegerInput as an input type
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String output = "";
|
||||
if (!left.equals(IngredientAny.INSTANCE)) {
|
||||
output += LogHelper.getStackDescription(left);
|
||||
}
|
||||
if (!middle.equals(IngredientAny.INSTANCE)) {
|
||||
output += ", " + LogHelper.getStackDescription(middle);
|
||||
}
|
||||
if (!right.equals(IngredientAny.INSTANCE)) {
|
||||
output += ", " + LogHelper.getStackDescription(right);
|
||||
}
|
||||
if (!infuseType.isEmpty()) {
|
||||
output += ", " + infuseType;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return left.equals(IngredientAny.INSTANCE) && middle.equals(IngredientAny.INSTANCE) && right.equals(IngredientAny.INSTANCE) && infuseType.isEmpty();
|
||||
}
|
||||
}
|
||||
+35
-52
@@ -2,65 +2,48 @@ package mekanism.common.integration.crafttweaker.util;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
||||
import mekanism.common.integration.crafttweaker.helpers.IngredientHelper;
|
||||
import mekanism.common.integration.crafttweaker.helpers.RecipeInfoHelper;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ChanceOutput;
|
||||
import mekanism.common.recipe.outputs.ChemicalPairOutput;
|
||||
import mekanism.common.recipe.outputs.FluidOutput;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import mekanism.common.recipe.outputs.MachineOutput;
|
||||
import mekanism.common.recipe.outputs.PressurizedOutput;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class RemoveMekanismRecipe extends BaseMapRemoval<MachineInput, MachineRecipe>
|
||||
{
|
||||
public RemoveMekanismRecipe(String name, Map<MachineInput, MachineRecipe> map)
|
||||
{
|
||||
super(name, map);
|
||||
}
|
||||
|
||||
public abstract void addRecipes();
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
addRecipes();
|
||||
|
||||
super.apply();
|
||||
public class RemoveMekanismRecipe<INPUT extends MachineInput<INPUT>, OUTPUT extends MachineOutput<OUTPUT>, RECIPE extends MachineRecipe<INPUT, OUTPUT, RECIPE>> extends BaseMapRemoval<INPUT, RECIPE> {
|
||||
public RemoveMekanismRecipe(String name, Recipe recipeType, IngredientWrapper output, IngredientWrapper input) {
|
||||
super(name, recipeType.get());
|
||||
map.forEach((key, value) -> {
|
||||
if (IngredientHelper.matches(key, input) && IngredientHelper.matches(value.getOutput(), output)) {
|
||||
recipes.put(key, value);
|
||||
}
|
||||
});
|
||||
if (recipes.isEmpty()) {
|
||||
String warning = "";
|
||||
if (input.isEmpty()) {
|
||||
if (!output.isEmpty()) { //It should never be the case they both are empty but just in case they are ignore it
|
||||
warning = String.format("output: '%s'", output.toString());
|
||||
}
|
||||
} else if (output.isEmpty()) {
|
||||
warning = String.format("input: '%s'", input.toString());
|
||||
} else {
|
||||
warning = String.format("input: '%s' and output: '%s'", input.toString(), output.toString());
|
||||
}
|
||||
if (!warning.isEmpty()) {
|
||||
LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", name, warning));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(Map.Entry<MachineInput, MachineRecipe> recipe)
|
||||
{
|
||||
MachineOutput output = recipe.getValue().recipeOutput;
|
||||
|
||||
if (output instanceof ItemStackOutput)
|
||||
{
|
||||
return LogHelper.getStackDescription(((ItemStackOutput) output).output);
|
||||
}
|
||||
else if (output instanceof GasOutput)
|
||||
{
|
||||
return LogHelper.getStackDescription(((GasOutput) output).output);
|
||||
}
|
||||
else if (output instanceof FluidOutput)
|
||||
{
|
||||
return LogHelper.getStackDescription(((FluidOutput) output).output);
|
||||
}
|
||||
else if (output instanceof ChemicalPairOutput)
|
||||
{
|
||||
return "[" + LogHelper.getStackDescription(((ChemicalPairOutput) output).leftGas) + ", " + LogHelper.getStackDescription(((ChemicalPairOutput) output).rightGas) + "]";
|
||||
}
|
||||
else if (output instanceof ChanceOutput)
|
||||
{
|
||||
return LogHelper.getStackDescription(((ChanceOutput) output).primaryOutput);
|
||||
}
|
||||
else if (output instanceof PressurizedOutput)
|
||||
{
|
||||
return "[" + LogHelper.getStackDescription(((PressurizedOutput) output).getItemOutput()) + ", " + LogHelper.getStackDescription(((PressurizedOutput) output).getGasOutput()) + "]";
|
||||
}
|
||||
|
||||
return null;
|
||||
protected String getRecipeInfo(Map.Entry<INPUT, RECIPE> recipe) {
|
||||
return RecipeInfoHelper.getRecipeInfo(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
//Only describe it if it didn't already throw a warning about no recipes found
|
||||
return recipes.isEmpty() ? "" : super.describe();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user