Added minetweaker support for Fusion Reactor
This commit is contained in:
parent
50a45560ab
commit
8c85aeb4d3
2 changed files with 240 additions and 0 deletions
239
src/main/java/techreborn/compat/minetweaker/MTFusionReactor.java
Normal file
239
src/main/java/techreborn/compat/minetweaker/MTFusionReactor.java
Normal file
|
@ -0,0 +1,239 @@
|
|||
package techreborn.compat.minetweaker;
|
||||
|
||||
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 MTFusionReactor {
|
||||
|
||||
public static void addRecipe(IIngredient topInput, IIngredient bottomInput, IItemStack output, int startEU, int euTick, int tickTime){
|
||||
FusionReactorRecipe reactorRecipe = new FusionReactorRecipe((ItemStack) MinetweakerCompat.toObject(topInput), (ItemStack) MinetweakerCompat.toObject(bottomInput), MinetweakerCompat.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, String machineName) {
|
||||
MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output), machineName));
|
||||
}
|
||||
|
||||
private static class Remove implements IUndoableAction {
|
||||
private final ItemStack output;
|
||||
List<FusionReactorRecipe> removedRecipes = new ArrayList<FusionReactorRecipe>();
|
||||
private final String name;
|
||||
|
||||
public Remove(ItemStack output, String machineName) {
|
||||
this.output = output;
|
||||
this.name = machineName;
|
||||
}
|
||||
|
||||
@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 " + 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,6 +42,7 @@ public class MinetweakerCompat implements ICompatModule {
|
|||
MineTweakerAPI.registerClass(MTIndustrialElectrolyzer.class);
|
||||
MineTweakerAPI.registerClass(MTIndustrialSawmill.class);
|
||||
MineTweakerAPI.registerClass(MTPlateCuttingMachine.class);
|
||||
MineTweakerAPI.registerClass(MTFusionReactor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue