Update CraftTweaker support

This commit is contained in:
modmuss50 2017-03-14 12:59:17 +00:00
parent 3e6fc499df
commit da6925195b
No known key found for this signature in database
GPG key ID: 203A5ED4D3E48BEA
19 changed files with 98 additions and 98 deletions

View file

@ -0,0 +1,66 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.AlloySmelterRecipe;
/**
* mods.techreborn.alloySmelter.addRecipe(<minecraft:gold_ingot>, <minecraft:iron_ingot>, <minecraft:diamond>, 20, 100);
*/
@ZenClass("mods.techreborn.alloySmelter")
public class CTAlloySmelter extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
AlloySmelterRecipe r = new AlloySmelterRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.alloySmelteRecipe;
}
}

View file

@ -0,0 +1,63 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
@ZenClass("mods.techreborn.assemblingMachine")
public class CTAssemblingMachine extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
AssemblingMachineRecipe r = new AssemblingMachineRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.assemblingMachineRecipe;
}
}

View file

@ -0,0 +1,62 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.BlastFurnaceRecipe;
@ZenClass("mods.techreborn.blastFurnace")
public class CTBlastFurnace extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IIngredient input1, IIngredient input2, int ticktime, int euTick, int neededHeat) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
BlastFurnaceRecipe r = new BlastFurnaceRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), ticktime, euTick, neededHeat);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.blastFurnaceRecipe;
}
}

View file

@ -0,0 +1,62 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.CentrifugeRecipe;
@ZenClass("mods.techreborn.centrifuge")
public class CTCentrifuge extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
CentrifugeRecipe r = new CentrifugeRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), CraftTweakerCompat.toStack(output3), CraftTweakerCompat.toStack(output4), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.centrifugeRecipe;
}
}

View file

@ -0,0 +1,62 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.ChemicalReactorRecipe;
@ZenClass("mods.techreborn.chemicalReactorRecipe")
public class CTChemicalReactor extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output1, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
ChemicalReactorRecipe r = new ChemicalReactorRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output1), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.chemicalReactorRecipe;
}
}

View file

@ -0,0 +1,66 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.CompressorRecipe;
/*
* mods.techreborn.compressor.addRecipe(<minecraft:clay>,<minecraft:clay_ball>, 40,100);
*/
@ZenClass("mods.techreborn.compressor")
public class CTCompressor extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output1, IIngredient input1, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
//public CompressorRecipe(ItemStack input1, ItemStack output1, int tickTime, int euPerTick) {
CompressorRecipe r = new CompressorRecipe(oInput1, CraftTweakerCompat.toStack(output1), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.compressorRecipe;
}
}

View file

@ -0,0 +1,260 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.item.ItemStack;
import reborncore.common.util.ItemUtils;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.reactor.FusionReactorRecipe;
import techreborn.api.reactor.FusionReactorRecipeHelper;
import java.util.ArrayList;
import java.util.List;
@ZenClass("mods.techreborn.fusionReactor")
public class CTFusionReactor {
@ZenMethod
public static void addRecipe(IIngredient topInput, IIngredient bottomInput, IItemStack output, int startEU, int euTick, int tickTime) {
FusionReactorRecipe reactorRecipe = new FusionReactorRecipe((ItemStack) CraftTweakerCompat.toObject(topInput), (ItemStack) CraftTweakerCompat.toObject(bottomInput), CraftTweakerCompat.toStack(output), startEU, euTick, tickTime);
MineTweakerAPI.apply(new Add(reactorRecipe));
}
@ZenMethod
public static void removeTopInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveTopInput(iIngredient));
}
@ZenMethod
public static void removeBottomInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveTopInput(iIngredient));
}
private static class Add implements IUndoableAction {
private final FusionReactorRecipe recipe;
public Add(FusionReactorRecipe recipe) {
this.recipe = recipe;
}
@Override
public void apply() {
FusionReactorRecipeHelper.registerRecipe(recipe);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
FusionReactorRecipeHelper.reactorRecipes.remove(recipe);
}
@Override
public String describe() {
return "Adding Fusion Reactor recipe for " + recipe.getOutput().getDisplayName();
}
@Override
public String describeUndo() {
return "Removing Fusion Reactor recipe for " + recipe.getOutput().getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output)));
}
private static class Remove implements IUndoableAction {
private final ItemStack output;
List<FusionReactorRecipe> removedRecipes = new ArrayList<FusionReactorRecipe>();
public Remove(ItemStack output) {
this.output = output;
}
@Override
public void apply() {
for (FusionReactorRecipe recipeType : FusionReactorRecipeHelper.reactorRecipes) {
if (ItemUtils.isItemEqual(recipeType.getOutput(), output, true, false)) {
removedRecipes.add(recipeType);
FusionReactorRecipeHelper.reactorRecipes.remove(recipeType);
break;
}
}
}
@Override
public void undo() {
if (removedRecipes != null) {
for (FusionReactorRecipe recipe : removedRecipes) {
if (recipe != null) {
FusionReactorRecipeHelper.registerRecipe(recipe);
}
}
}
}
@Override
public String describe() {
return "Removing Fusion Reactor recipe for " + output.getDisplayName();
}
@Override
public String describeUndo() {
return "Re-Adding Fusion Reactor recipe for " + output.getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public boolean canUndo() {
return true;
}
}
private static class RemoveTopInput implements IUndoableAction {
private final IIngredient output;
List<FusionReactorRecipe> removedRecipes = new ArrayList<FusionReactorRecipe>();
public RemoveTopInput(IIngredient output) {
this.output = output;
}
@Override
public void apply() {
for (FusionReactorRecipe recipeType : FusionReactorRecipeHelper.reactorRecipes) {
if (output.matches(MineTweakerMC.getIItemStack(recipeType.getTopInput()))) {
removedRecipes.add(recipeType);
FusionReactorRecipeHelper.reactorRecipes.remove(recipeType);
break;
}
}
}
@Override
public void undo() {
if (removedRecipes != null) {
for (FusionReactorRecipe recipe : removedRecipes) {
if (recipe != null) {
FusionReactorRecipeHelper.registerRecipe(recipe);
}
}
}
}
@Override
public String describe() {
return "Removing Fusion Reactor recipe";
}
@Override
public String describeUndo() {
return "Re-Adding Fusion Reactor recipe";
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public boolean canUndo() {
return true;
}
}
private static class RemoveBottomInput implements IUndoableAction {
private final IIngredient output;
List<FusionReactorRecipe> removedRecipes = new ArrayList<FusionReactorRecipe>();
public RemoveBottomInput(IIngredient output) {
this.output = output;
}
@Override
public void apply() {
for (FusionReactorRecipe recipeType : FusionReactorRecipeHelper.reactorRecipes) {
if (output.matches(MineTweakerMC.getIItemStack(recipeType.getBottomInput()))) {
removedRecipes.add(recipeType);
FusionReactorRecipeHelper.reactorRecipes.remove(recipeType);
break;
}
}
}
@Override
public void undo() {
if (removedRecipes != null) {
for (FusionReactorRecipe recipe : removedRecipes) {
if (recipe != null) {
FusionReactorRecipeHelper.registerRecipe(recipe);
}
}
}
}
@Override
public String describe() {
return "Removing Fusion Reactor recipe";
}
@Override
public String describeUndo() {
return "Re-Adding Fusion Reactor recipe";
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public boolean canUndo() {
return true;
}
}
}

View file

@ -0,0 +1,37 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.api.liquid.ILiquidStack;
import reborncore.api.fuel.FluidPowerManager;
import stanhebben.zenscript.annotations.ZenClass;
@ZenClass("mods.techreborn.generator")
public class CTGenerator {
public static void addFluidPower(ILiquidStack fluid, double value) {
FluidPowerManager.fluidPowerValues.put(CraftTweakerCompat.toFluidStack(fluid).getFluid(), value);
}
}

View file

@ -0,0 +1,200 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.minecraft.MineTweakerMC;
import net.minecraft.item.ItemStack;
import reborncore.api.recipe.IBaseRecipeType;
import reborncore.api.recipe.RecipeHandler;
import reborncore.common.util.ItemUtils;
import techreborn.api.recipe.BaseRecipe;
import java.util.ArrayList;
import java.util.List;
public class CTGeneric {
public static String getMachineName() {
return null;
}
public static void addRecipe(BaseRecipe recipe) {
MineTweakerAPI.apply(new Add(recipe));
}
private static class Add implements IUndoableAction {
private final BaseRecipe recipe;
public Add(BaseRecipe recipe) {
this.recipe = recipe;
}
@Override
public void apply() {
RecipeHandler.addRecipe(recipe);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo() {
RecipeHandler.recipeList.remove(recipe);
}
@Override
public String describe() {
return "Adding " + recipe.getRecipeName() + " recipe for " + recipe.getOutput(0).getDisplayName();
}
@Override
public String describeUndo() {
return "Removing " + recipe.getRecipeName() + " recipe for " + recipe.getOutput(0).getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
}
public static class Remove implements IUndoableAction {
private final ItemStack output;
List<BaseRecipe> removedRecipes = new ArrayList<BaseRecipe>();
private final String name;
public Remove(ItemStack output, String machineName) {
this.output = output;
this.name = machineName;
}
@Override
public void apply() {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(name)) {
for (ItemStack stack : recipeType.getOutputs()) {
if (ItemUtils.isItemEqual(stack, output, true, false)) {
removedRecipes.add((BaseRecipe) recipeType);
RecipeHandler.recipeList.remove(recipeType);
break;
}
}
}
}
@Override
public void undo() {
if (removedRecipes != null) {
for (BaseRecipe recipe : removedRecipes) {
if (recipe != null) {
RecipeHandler.addRecipe(recipe);
}
}
}
}
@Override
public String describe() {
return "Removing " + name + " recipe for " + output.getDisplayName();
}
@Override
public String describeUndo() {
return "Re-Adding " + name + " recipe for " + output.getDisplayName();
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public boolean canUndo() {
return true;
}
}
public static class RemoveInput implements IUndoableAction {
private final IIngredient output;
List<BaseRecipe> removedRecipes = new ArrayList<BaseRecipe>();
private final String name;
public RemoveInput(IIngredient output, String machineName) {
this.output = output;
this.name = machineName;
}
@Override
public void apply() {
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(name)) {
for (Object stack : recipeType.getInputs()) {
if(stack instanceof ItemStack){
if (output.matches(MineTweakerMC.getIItemStack((ItemStack) stack))) {
removedRecipes.add((BaseRecipe) recipeType);
RecipeHandler.recipeList.remove(recipeType);
break;
}
}
}
}
}
@Override
public void undo() {
if (removedRecipes != null) {
for (BaseRecipe recipe : removedRecipes) {
if (recipe != null) {
RecipeHandler.addRecipe(recipe);
}
}
}
}
@Override
public String describe() {
return "Removing " + name + " recipe";
}
@Override
public String describeUndo() {
return "Re-Adding " + name + " recipe";
}
@Override
public Object getOverrideKey() {
return null;
}
@Override
public boolean canUndo() {
return true;
}
}
}

View file

@ -0,0 +1,62 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
@ZenClass("mods.techreborn.implosionCompressor")
public class CTImplosionCompressor extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
ImplosionCompressorRecipe r = new ImplosionCompressorRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.implosionCompressorRecipe;
}
}

View file

@ -0,0 +1,62 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.IndustrialElectrolyzerRecipe;
@ZenClass("mods.techreborn.industrialElectrolyzer")
public class CTIndustrialElectrolyzer extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient cells, IIngredient input2, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(cells);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
IndustrialElectrolyzerRecipe r = new IndustrialElectrolyzerRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), CraftTweakerCompat.toStack(output3), CraftTweakerCompat.toStack(output4), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.industrialElectrolyzerRecipe;
}
}

View file

@ -0,0 +1,74 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.IndustrialGrinderRecipe;
@ZenClass("mods.techreborn.grinder")
public class CTIndustrialGrinder extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
addRecipe(output1, output2, output3, output4, input1, input2, null, ticktime, euTick);
}
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient input1, IIngredient input2, ILiquidStack fluid, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
FluidStack fluidStack = null;
if (fluid != null) {
fluidStack = CraftTweakerCompat.toFluidStack(fluid);
}
IndustrialGrinderRecipe r = new IndustrialGrinderRecipe(oInput1, fluidStack, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), CraftTweakerCompat.toStack(output3), CraftTweakerCompat.toStack(output4), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.industrialGrinderRecipe;
}
}

View file

@ -0,0 +1,85 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.IndustrialSawmillRecipe;
@ZenClass("mods.techreborn.industrialSawmill")
public class CTIndustrialSawmill extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IIngredient input1, IIngredient input2, ILiquidStack fluid, int ticktime, int euTick) {
addRecipe(output1, output2, output3, input1, input2, fluid, ticktime, euTick, true);
}
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
addRecipe(output1, output2, output3, input1, input2, null, ticktime, euTick, true);
}
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IIngredient input1, IIngredient input2, int ticktime, int euTick, boolean useOreDic) {
addRecipe(output1, output2, output3, input1, input2, null, ticktime, euTick, useOreDic);
}
@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IIngredient input1, IIngredient input2, ILiquidStack fluid, int ticktime, int euTick, boolean useOreDic) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input1);
ItemStack oInput2 = (ItemStack) CraftTweakerCompat.toObject(input2);
FluidStack fluidStack = null;
if (fluid != null) {
fluidStack = CraftTweakerCompat.toFluidStack(fluid);
}
IndustrialSawmillRecipe r = new IndustrialSawmillRecipe(oInput1, oInput2, fluidStack, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), CraftTweakerCompat.toStack(output3), ticktime, euTick, useOreDic);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.industrialSawmillRecipe;
}
}

View file

@ -0,0 +1,147 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.oredict.IOreDictEntry;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import reborncore.common.util.ItemUtils;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.RollingMachineRecipe;
import techreborn.api.TechRebornAPI;
import java.util.ArrayList;
import java.util.List;
@ZenClass("mods.techreborn.rollingMachine")
public class CTRollingMachine {
@ZenMethod
public static void addShaped(IItemStack output, IIngredient[][] ingredients) {
TechRebornAPI.addRollingOreMachinceRecipe(toStack(output), toShapedObjects(ingredients));
}
@ZenMethod
public static void addShapeless(IItemStack output, IIngredient[] ingredients) {
TechRebornAPI.addShapelessOreRollingMachinceRecipe(toStack(output), toObjects(ingredients));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
List<IRecipe> toRemove = new ArrayList<>();
for (IRecipe recipe : RollingMachineRecipe.instance.getRecipeList()) {
if (ItemUtils.isItemEqual(recipe.getRecipeOutput(), CraftTweakerCompat.toStack(output), true, false)) {
toRemove.add(recipe);
}
}
RollingMachineRecipe.instance.getRecipeList().removeAll(toRemove);
}
public static ItemStack toStack(IItemStack iStack) {
if (iStack == null)
return null;
else {
Object internal = iStack.getInternal();
if (internal == null || !(internal instanceof ItemStack)) {
MineTweakerAPI.getLogger().logError("Not a valid item stack: " + iStack);
}
return (ItemStack) internal;
}
}
public static ItemStack[] toStacks(IItemStack[] iStack) {
if (iStack == null)
return null;
else {
ItemStack[] output = new ItemStack[iStack.length];
for (int i = 0; i < iStack.length; i++) {
output[i] = toStack(iStack[i]);
}
return output;
}
}
public static Object toObject(IIngredient iStack) {
if (iStack == null)
return null;
else {
if (iStack instanceof IOreDictEntry) {
return toString((IOreDictEntry) iStack);
} else if (iStack instanceof IItemStack) {
return toStack((IItemStack) iStack);
} else
return null;
}
}
public static Object[] toObjects(IIngredient[] ingredient) {
if (ingredient == null)
return null;
else {
Object[] output = new Object[ingredient.length];
for (int i = 0; i < ingredient.length; i++) {
if (ingredient[i] != null) {
output[i] = toObject(ingredient[i]);
} else
output[i] = "";
}
return output;
}
}
public static Object[] toShapedObjects(IIngredient[][] ingredients) {
if (ingredients == null)
return null;
else {
ArrayList prep = new ArrayList();
prep.add("abc");
prep.add("def");
prep.add("ghi");
char[][] map = new char[][] { { 'a', 'b', 'c' }, { 'd', 'e', 'f' }, { 'g', 'h', 'i' } };
for (int x = 0; x < ingredients.length; x++) {
if (ingredients[x] != null) {
for (int y = 0; y < ingredients[x].length; y++) {
if (ingredients[x][y] != null && x < map.length && y < map[x].length) {
prep.add(map[x][y]);
prep.add(toObject(ingredients[x][y]));
}
}
}
}
return prep.toArray();
}
}
public static String toString(IOreDictEntry entry) {
return ((IOreDictEntry) entry).getName();
}
}

View file

@ -0,0 +1,60 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import techreborn.api.Reference;
import techreborn.api.recipe.machines.VacuumFreezerRecipe;
@ZenClass("mods.techreborn.vacuumFreezer")
public class CTVacuumFreezer extends CTGeneric {
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input, int ticktime, int euTick) {
ItemStack oInput1 = (ItemStack) CraftTweakerCompat.toObject(input);
VacuumFreezerRecipe r = new VacuumFreezerRecipe(oInput1, CraftTweakerCompat.toStack(output), ticktime, euTick);
addRecipe(r);
}
@ZenMethod
public static void removeInputRecipe(IIngredient iIngredient) {
MineTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
public static void removeRecipe(IItemStack output) {
MineTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}
public static String getMachineName() {
return Reference.vacuumFreezerRecipe;
}
}

View file

@ -0,0 +1,103 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2017 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.crafttweaker;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import minetweaker.api.item.IngredientStack;
import minetweaker.api.liquid.ILiquidStack;
import minetweaker.api.oredict.IOreDictEntry;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import techreborn.compat.ICompatModule;
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
import static minetweaker.api.minecraft.MineTweakerMC.getLiquidStack;
public class CraftTweakerCompat implements ICompatModule {
public static ItemStack toStack(IItemStack iStack) {
return getItemStack(iStack);
}
public static Object toObject(IIngredient iStack) {
if (iStack == null)
return null;
else {
if (iStack instanceof IOreDictEntry)
return ((IOreDictEntry) iStack).getName();
else if (iStack instanceof IItemStack)
return getItemStack((IItemStack) iStack);
else if (iStack instanceof IngredientStack) {
IIngredient ingr = ReflectionHelper.getPrivateValue(IngredientStack.class, (IngredientStack) iStack, "ingredient");
return toObject(ingr);
} else
return null;
}
}
public static FluidStack toFluidStack(ILiquidStack iStack) {
return getLiquidStack(iStack);
}
@Override
public void preInit(FMLPreInitializationEvent event) {
}
@Override
public void init(FMLInitializationEvent event) {
}
@Override
public void postInit(FMLPostInitializationEvent event) {
MineTweakerAPI.registerClass(CTAlloySmelter.class);
MineTweakerAPI.registerClass(CTAssemblingMachine.class);
MineTweakerAPI.registerClass(CTBlastFurnace.class);
MineTweakerAPI.registerClass(CTCentrifuge.class);
MineTweakerAPI.registerClass(CTChemicalReactor.class);
MineTweakerAPI.registerClass(CTCompressor.class);
MineTweakerAPI.registerClass(CTIndustrialGrinder.class);
MineTweakerAPI.registerClass(CTImplosionCompressor.class);
MineTweakerAPI.registerClass(CTIndustrialElectrolyzer.class);
MineTweakerAPI.registerClass(CTIndustrialSawmill.class);
MineTweakerAPI.registerClass(CTFusionReactor.class);
MineTweakerAPI.registerClass(CTVacuumFreezer.class);
MineTweakerAPI.registerClass(CTGenerator.class);
MineTweakerAPI.registerClass(CTRollingMachine.class);
}
@Override
public void serverStarting(FMLServerStartingEvent event) {
}
}