-
Notifications
You must be signed in to change notification settings - Fork 100
Feature/minetweaker #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Baughn
wants to merge
3
commits into
develop
Choose a base branch
from
feature/minetweaker
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/minetweaker #478
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/mods/eln/integration/minetweaker/MinetweakerIntegration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package mods.eln.integration.minetweaker; | ||
|
|
||
| import minetweaker.MineTweakerAPI; | ||
| import mods.eln.integration.minetweaker.machines.Compressor; | ||
| import mods.eln.integration.minetweaker.machines.Macerator; | ||
| import mods.eln.integration.minetweaker.machines.Magnetizer; | ||
| import mods.eln.integration.minetweaker.machines.PlateMachine; | ||
|
|
||
| public class MinetweakerIntegration { | ||
| public static MinetweakerIntegration instance = new MinetweakerIntegration(); | ||
|
|
||
|
|
||
| public void initialize(){ | ||
| MineTweakerAPI.registerClass(Macerator.class); | ||
| MineTweakerAPI.registerClass(Compressor.class); | ||
| MineTweakerAPI.registerClass(Magnetizer.class); | ||
| MineTweakerAPI.registerClass(PlateMachine.class); | ||
| } | ||
|
|
||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/mods/eln/integration/minetweaker/machines/Compressor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package mods.eln.integration.minetweaker.machines; | ||
|
|
||
| import stanhebben.zenscript.annotations.ZenClass; | ||
| import stanhebben.zenscript.annotations.ZenMethod; | ||
| import minetweaker.api.item.IIngredient; | ||
| import minetweaker.api.item.IItemStack; | ||
| import mods.eln.integration.minetweaker.utils.MinetweakerMachine; | ||
|
|
||
| @ZenClass("mods.electricalage.Compressor") | ||
| public class Compressor { | ||
|
|
||
| @ZenMethod | ||
| public static void addRecipe(IIngredient input, double energy, IItemStack[] output) | ||
| { | ||
| MinetweakerMachine.COMPRESSOR.addRecipe(input, energy, output); | ||
| } | ||
|
|
||
| @ZenMethod | ||
| public static void removeRecipe(IIngredient input) | ||
| { | ||
| MinetweakerMachine.COMPRESSOR.removeRecipe(input); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/mods/eln/integration/minetweaker/machines/Macerator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package mods.eln.integration.minetweaker.machines; | ||
|
|
||
| import stanhebben.zenscript.annotations.ZenClass; | ||
| import stanhebben.zenscript.annotations.ZenMethod; | ||
| import minetweaker.api.item.IIngredient; | ||
| import minetweaker.api.item.IItemStack; | ||
| import mods.eln.integration.minetweaker.utils.MinetweakerMachine; | ||
|
|
||
| @ZenClass("mods.electricalage.Macerator") | ||
| public class Macerator { | ||
|
|
||
| @ZenMethod | ||
| public static void addRecipe(IIngredient input, double energy, IItemStack[] output) | ||
| { | ||
| MinetweakerMachine.MACERATOR.addRecipe(input, energy, output); | ||
| } | ||
|
|
||
| @ZenMethod | ||
| public static void removeRecipe(IIngredient input) | ||
| { | ||
| MinetweakerMachine.MACERATOR.removeRecipe(input); | ||
| } | ||
|
|
||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/mods/eln/integration/minetweaker/machines/Magnetizer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package mods.eln.integration.minetweaker.machines; | ||
|
|
||
| import stanhebben.zenscript.annotations.ZenClass; | ||
| import stanhebben.zenscript.annotations.ZenMethod; | ||
| import minetweaker.api.item.IIngredient; | ||
| import minetweaker.api.item.IItemStack; | ||
| import mods.eln.integration.minetweaker.utils.MinetweakerMachine; | ||
|
|
||
| @ZenClass("mods.electricalage.Magnetizer") | ||
| public class Magnetizer { | ||
|
|
||
| @ZenMethod | ||
| public static void addRecipe(IIngredient input, double energy, IItemStack[] output) | ||
| { | ||
| MinetweakerMachine.MAGNETIZER.addRecipe(input, energy, output); | ||
| } | ||
|
|
||
| @ZenMethod | ||
| public static void removeRecipe(IIngredient input) | ||
| { | ||
| MinetweakerMachine.MAGNETIZER.removeRecipe(input); | ||
| } | ||
|
|
||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/mods/eln/integration/minetweaker/machines/PlateMachine.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package mods.eln.integration.minetweaker.machines; | ||
|
|
||
| import stanhebben.zenscript.annotations.ZenClass; | ||
| import stanhebben.zenscript.annotations.ZenMethod; | ||
| import minetweaker.api.item.IIngredient; | ||
| import minetweaker.api.item.IItemStack; | ||
| import mods.eln.integration.minetweaker.utils.MinetweakerMachine; | ||
|
|
||
| @ZenClass("mods.electricalage.PlateMachine") | ||
| public class PlateMachine { | ||
|
|
||
| @ZenMethod | ||
| public static void addRecipe(IIngredient input, double energy, IItemStack[] output) | ||
| { | ||
| MinetweakerMachine.PLATEMACHINE.addRecipe(input, energy, output); | ||
| } | ||
|
|
||
| @ZenMethod | ||
| public static void removeRecipe(IIngredient input) | ||
| { | ||
| MinetweakerMachine.PLATEMACHINE.removeRecipe(input); | ||
| } | ||
|
|
||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/mods/eln/integration/minetweaker/utils/AddRecipe.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package mods.eln.integration.minetweaker.utils; | ||
|
|
||
| import mods.eln.misc.Recipe; | ||
|
|
||
| public class AddRecipe extends BasicUndoableAction { | ||
| Recipe recipe; | ||
|
|
||
| public AddRecipe(MinetweakerMachine machine, Recipe recipe) { | ||
| super(machine); | ||
| this.recipe = recipe; | ||
| } | ||
|
|
||
| @Override | ||
| public void apply() { | ||
| machine.recipes.addRecipe(recipe); | ||
| } | ||
|
|
||
| @Override | ||
| public void undo() { | ||
| machine.recipes.getRecipes().remove(recipe); | ||
| } | ||
|
|
||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/mods/eln/integration/minetweaker/utils/BasicUndoableAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package mods.eln.integration.minetweaker.utils; | ||
|
|
||
| import minetweaker.IUndoableAction; | ||
|
|
||
| public abstract class BasicUndoableAction implements IUndoableAction { | ||
| MinetweakerMachine machine; | ||
|
|
||
| public BasicUndoableAction(MinetweakerMachine machine) { | ||
| this.machine = machine; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean canUndo() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public String describe() { | ||
| return machine.addDesc; | ||
| } | ||
|
|
||
| @Override | ||
| public String describeUndo() { | ||
| return "Undo" + machine.removeDesc; | ||
| } | ||
|
|
||
| @Override | ||
| public Object getOverrideKey() { | ||
| return null; | ||
| } | ||
|
|
||
| } |
58 changes: 58 additions & 0 deletions
58
src/main/java/mods/eln/integration/minetweaker/utils/MinetweakerMachine.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package mods.eln.integration.minetweaker.utils; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| import minetweaker.MineTweakerAPI; | ||
| import minetweaker.api.item.IIngredient; | ||
| import minetweaker.api.item.IItemStack; | ||
| import minetweaker.api.minecraft.MineTweakerMC; | ||
| import mods.eln.Eln; | ||
| import mods.eln.misc.Recipe; | ||
| import mods.eln.misc.RecipesList; | ||
|
|
||
| import net.minecraft.item.ItemStack; | ||
|
|
||
| public class MinetweakerMachine { | ||
|
|
||
| public static MinetweakerMachine MACERATOR = new MinetweakerMachine(Eln.instance.maceratorRecipes, "Adding Macerator Recipe", "Removing Macerator Recipe"); | ||
| public static MinetweakerMachine COMPRESSOR = new MinetweakerMachine(Eln.instance.compressorRecipes, "Adding Compressor Recipe", "Removing Compressor Recipe"); | ||
| public static MinetweakerMachine MAGNETIZER = new MinetweakerMachine(Eln.instance.magnetiserRecipes, "Adding Magnetizer Recipe", "Removing Magnetizer Recipe"); | ||
| public static MinetweakerMachine PLATEMACHINE = new MinetweakerMachine(Eln.instance.plateMachineRecipes, "Adding Plate Machine Recipe", "Removing Plate Machine Recipe"); | ||
|
|
||
| public RecipesList recipes; | ||
| public String removeDesc; | ||
| public String addDesc; | ||
|
|
||
| public MinetweakerMachine(RecipesList recipes, String addDesc, String removeDesc) { | ||
| this.recipes = recipes; | ||
| this.addDesc = addDesc; | ||
| this.removeDesc = removeDesc; | ||
| } | ||
|
|
||
| public void addRecipe(IIngredient input, double energy, IItemStack[] output) | ||
| { | ||
| if (input == null || output == null || energy < 0) | ||
| return; | ||
| if (output.length > 4) { | ||
| throw new IllegalArgumentException("Too much outputs"); | ||
| } | ||
|
|
||
| ArrayList<ItemStack> outs = new ArrayList<ItemStack>(); | ||
| for (IIngredient i : output) { | ||
| ItemStack stack = MineTweakerMC.getItemStack(i); | ||
| if (stack != null) { | ||
| outs.add(stack); | ||
| } | ||
| } | ||
|
|
||
| Recipe recipe = new Recipe(MineTweakerMC.getItemStack(input), outs.toArray(new ItemStack[] {}), energy); | ||
|
|
||
| MineTweakerAPI.apply(new AddRecipe(this, recipe)); | ||
| } | ||
|
|
||
| public void removeRecipe(IIngredient input) | ||
| { | ||
| MineTweakerAPI.apply(new RemoveRecipe(this, input)); | ||
| } | ||
|
|
||
| } |
36 changes: 36 additions & 0 deletions
36
src/main/java/mods/eln/integration/minetweaker/utils/RemoveRecipe.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package mods.eln.integration.minetweaker.utils; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| import minetweaker.api.item.IIngredient; | ||
| import minetweaker.api.minecraft.MineTweakerMC; | ||
| import mods.eln.Eln; | ||
| import mods.eln.misc.Recipe; | ||
|
|
||
|
|
||
| public class RemoveRecipe extends BasicUndoableAction{ | ||
| IIngredient input; | ||
| ArrayList<Recipe> toRemove; | ||
|
|
||
| public RemoveRecipe(MinetweakerMachine machine, IIngredient input) { | ||
| super(machine); | ||
| this.input = input; | ||
| } | ||
|
|
||
| @Override | ||
| public void apply() { | ||
| toRemove = new ArrayList<Recipe>(); | ||
| for (Recipe r : Eln.instance.maceratorRecipes.getRecipes()){ | ||
| if(input.matches(MineTweakerMC.getIItemStack(r.input))){ | ||
| toRemove.add(r); | ||
| } | ||
| } | ||
| machine.recipes.getRecipes().removeAll(toRemove); | ||
| } | ||
|
|
||
| @Override | ||
| public void undo() { | ||
| machine.recipes.getRecipes().addAll(toRemove); | ||
| } | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a bug