aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/plugin
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2018-12-22 13:17:31 +0800
committerUnknown <shekwancheung0528@gmail.com>2018-12-22 13:17:31 +0800
commitd1e292ca25b7987bc4ddf334205238d75f7f29b7 (patch)
tree3c2911284faccd10f97e3aa307719ec12efd4b53 /src/main/java/me/shedaniel/plugin
parent7bcd4d2e868210a842ad7e4e4fc34240de40a121 (diff)
downloadRoughlyEnoughItems-d1e292ca25b7987bc4ddf334205238d75f7f29b7.tar.gz
RoughlyEnoughItems-d1e292ca25b7987bc4ddf334205238d75f7f29b7.tar.bz2
RoughlyEnoughItems-d1e292ca25b7987bc4ddf334205238d75f7f29b7.zip
from aei but like jei now
Diffstat (limited to 'src/main/java/me/shedaniel/plugin')
-rwxr-xr-xsrc/main/java/me/shedaniel/plugin/VanillaPlugin.java43
-rwxr-xr-xsrc/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java106
-rwxr-xr-xsrc/main/java/me/shedaniel/plugin/crafting/VanillaCraftingRecipe.java16
-rwxr-xr-xsrc/main/java/me/shedaniel/plugin/crafting/VanillaShapedCraftingRecipe.java55
-rwxr-xr-xsrc/main/java/me/shedaniel/plugin/crafting/VanillaShapelessCraftingRecipe.java57
-rwxr-xr-xsrc/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceCategory.java83
-rwxr-xr-xsrc/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceRecipe.java42
7 files changed, 402 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/plugin/VanillaPlugin.java b/src/main/java/me/shedaniel/plugin/VanillaPlugin.java
new file mode 100755
index 000000000..22c87a168
--- /dev/null
+++ b/src/main/java/me/shedaniel/plugin/VanillaPlugin.java
@@ -0,0 +1,43 @@
+package me.shedaniel.plugin;
+
+import me.shedaniel.api.IAEIPlugin;
+import me.shedaniel.impl.AEIRecipeManager;
+import me.shedaniel.plugin.crafting.VanillaCraftingCategory;
+import me.shedaniel.plugin.crafting.VanillaCraftingRecipe;
+import me.shedaniel.plugin.crafting.VanillaShapedCraftingRecipe;
+import me.shedaniel.plugin.crafting.VanillaShapelessCraftingRecipe;
+import me.shedaniel.plugin.furnace.VanillaFurnaceCategory;
+import me.shedaniel.plugin.furnace.VanillaFurnaceRecipe;
+import net.minecraft.item.crafting.FurnaceRecipe;
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.item.crafting.ShapedRecipe;
+import net.minecraft.item.crafting.ShapelessRecipe;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class VanillaPlugin implements IAEIPlugin {
+ @Override
+ public void register() {
+ List<VanillaCraftingRecipe> recipes = new LinkedList<>();
+ List<VanillaFurnaceRecipe> furnaceRecipes = new LinkedList<>();
+ AEIRecipeManager.instance().addDisplayAdapter(new VanillaCraftingCategory());
+ AEIRecipeManager.instance().addDisplayAdapter(new VanillaFurnaceCategory());
+
+ for(IRecipe recipe : AEIRecipeManager.instance().recipeManager.getRecipes()) {
+ if (recipe instanceof ShapelessRecipe) {
+ recipes.add(new VanillaShapelessCraftingRecipe((ShapelessRecipe) recipe));
+ }
+ if (recipe instanceof ShapedRecipe) {
+ recipes.add(new VanillaShapedCraftingRecipe((ShapedRecipe) recipe));
+ }
+ if (recipe instanceof FurnaceRecipe) {
+ furnaceRecipes.add(new VanillaFurnaceRecipe((FurnaceRecipe) recipe));
+ }
+ }
+
+ AEIRecipeManager.instance().addRecipe("vanilla", recipes);
+ AEIRecipeManager.instance().addRecipe("furnace", furnaceRecipes);
+ }
+}
diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java
new file mode 100755
index 000000000..e064f05a4
--- /dev/null
+++ b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java
@@ -0,0 +1,106 @@
+package me.shedaniel.plugin.crafting;
+
+import me.shedaniel.api.IDisplayCategory;
+import me.shedaniel.gui.widget.AEISlot;
+import me.shedaniel.gui.widget.Control;
+import me.shedaniel.gui.widget.WidgetArrow;
+import net.minecraft.client.MainWindow;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+public class VanillaCraftingCategory implements IDisplayCategory<VanillaCraftingRecipe> {
+ MainWindow mainWindow = Minecraft.getInstance().mainWindow;
+ private List<VanillaCraftingRecipe> recipes;
+
+ @Override
+ public String getId() {
+ return "vanilla";
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Crafting";
+ }
+
+ @Override
+ public void addRecipe(VanillaCraftingRecipe recipe) {
+ if (this.recipes == null)
+ this.recipes = new ArrayList<>();
+ this.recipes.add(recipe);
+ }
+
+ @Override
+ public void resetRecipes() {
+ this.recipes = new ArrayList<>();
+ }
+
+ @Override
+ public List<AEISlot> setupDisplay(int number) {
+ List<AEISlot> slots = new LinkedList<>();
+ int count = 0;
+ List<List<ItemStack>> input = recipes.get(number).getInput();
+ for(int y = 0; y < 3; y++) {
+ for(int x = 0; x < 3; x++) {
+ AEISlot slot = new AEISlot(20 + x * 18, 75 + y * 18 + number * 75);
+ slot.setDrawBackground(true);
+ slots.add(slot);
+ count++;
+ }
+ }
+ for(int i = 0; i < input.size(); i++) {
+ if (recipes.get(number) instanceof VanillaShapedCraftingRecipe) {
+ if (!input.get(i).isEmpty())
+ slots.get(getSlotWithSize(number, i)).setStackList(input.get(i));
+ } else if (!input.get(i).isEmpty())
+ slots.get(i).setStackList(input.get(i));
+ }
+ AEISlot slot = new AEISlot(130, 75 + 18 + number * 75);
+
+ slot.setDrawBackground(true);
+ slot.setStack(recipes.get(number).getOutput().get(0).copy());
+ slots.add(slot);
+ return slots;
+ }
+
+ @Override
+ public boolean canDisplay(VanillaCraftingRecipe recipe) {
+ return false;
+ }
+
+ @Override
+ public void drawExtras() {
+
+ }
+
+ @Override
+ public void addWidget(List<Control> controls, int number) {
+ WidgetArrow wa = new WidgetArrow(90, 70 + 22 + number * 75, false);
+ controls.add(wa);
+ }
+
+ private int getSlotWithSize(int number, int num) {
+ if (recipes.get(number).getWidth() == 1) {
+ if (num == 1)
+ return 3;
+ if (num == 2)
+ return 6;
+ }
+
+ if (recipes.get(number).getWidth() == 2) {
+ if (num == 2)
+ return 3;
+ if (num == 3)
+ return 4;
+ if (num == 4)
+ return 6;
+ if (num == 5)
+ return 7;
+
+ }
+ return num;
+ }
+}
diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingRecipe.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingRecipe.java
new file mode 100755
index 000000000..f39b5d695
--- /dev/null
+++ b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingRecipe.java
@@ -0,0 +1,16 @@
+package me.shedaniel.plugin.crafting;
+
+import me.shedaniel.api.IRecipe;
+import net.minecraft.item.ItemStack;
+
+public abstract class VanillaCraftingRecipe implements IRecipe<ItemStack> {
+
+ public int getWidth() {
+ return 2;
+ }
+
+ public int getHeight() {
+ return 2;
+ }
+
+}
diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaShapedCraftingRecipe.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaShapedCraftingRecipe.java
new file mode 100755
index 000000000..1c537b2a7
--- /dev/null
+++ b/src/main/java/me/shedaniel/plugin/crafting/VanillaShapedCraftingRecipe.java
@@ -0,0 +1,55 @@
+package me.shedaniel.plugin.crafting;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.Ingredient;
+import net.minecraft.item.crafting.ShapedRecipe;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class VanillaShapedCraftingRecipe extends VanillaCraftingRecipe {
+
+ private final ShapedRecipe recipe;
+
+ public VanillaShapedCraftingRecipe(ShapedRecipe recipe) {
+
+ this.recipe = recipe;
+ }
+
+ @Override
+ public int getWidth() {
+ return recipe.getWidth();
+ }
+
+ @Override
+ public int getHeight() {
+ return recipe.getHeight();
+ }
+
+ @Override
+ public String getId() {
+ return "vanilla";
+ }
+
+ @Override
+ public List<ItemStack> getOutput() {
+ List<ItemStack> output = new LinkedList<>();
+ output.add(recipe.getRecipeOutput());
+ return output;
+ }
+
+ @Override
+ public List<List<ItemStack>> getInput() {
+ List<List<ItemStack>> input = new LinkedList<>();
+ int count = 0;
+ for(Ingredient ingredient : recipe.getIngredients()) {
+ List<ItemStack> ingList = new LinkedList<>();
+ for(ItemStack matchingStack : ingredient.getMatchingStacks()) {
+ ingList.add(matchingStack);
+ }
+ input.add(ingList);
+ count++;
+ }
+ return input;
+ }
+}
diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaShapelessCraftingRecipe.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaShapelessCraftingRecipe.java
new file mode 100755
index 000000000..034ac77b0
--- /dev/null
+++ b/src/main/java/me/shedaniel/plugin/crafting/VanillaShapelessCraftingRecipe.java
@@ -0,0 +1,57 @@
+package me.shedaniel.plugin.crafting;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.Ingredient;
+import net.minecraft.item.crafting.ShapelessRecipe;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class VanillaShapelessCraftingRecipe extends VanillaCraftingRecipe {
+
+ private final ShapelessRecipe recipe;
+
+ public VanillaShapelessCraftingRecipe(ShapelessRecipe recipe) {
+
+ this.recipe = recipe;
+ }
+
+ @Override
+ public String getId() {
+ return "vanilla";
+ }
+
+ @Override
+ public List<ItemStack> getOutput() {
+ List<ItemStack> output = new LinkedList<>();
+ output.add(recipe.getRecipeOutput());
+ return output;
+ }
+
+ @Override
+ public List<List<ItemStack>> getInput() {
+ List<List<ItemStack>> input = new LinkedList<>();
+ for(Ingredient ingredient : recipe.getIngredients()) {
+ List<ItemStack> ingList = new LinkedList<>();
+ for(ItemStack matchingStack : ingredient.getMatchingStacks()) {
+ ingList.add(matchingStack);
+ }
+ input.add(ingList);
+ }
+ return input;
+ }
+
+ @Override
+ public int getWidth() {
+ if (recipe.getIngredients().size() > 4)
+ return 3;
+ return 2;
+ }
+
+ @Override
+ public int getHeight() {
+ if (recipe.getIngredients().size() > 4)
+ return 3;
+ return 2;
+ }
+}
diff --git a/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceCategory.java b/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceCategory.java
new file mode 100755
index 000000000..e4c65cca1
--- /dev/null
+++ b/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceCategory.java
@@ -0,0 +1,83 @@
+package me.shedaniel.plugin.furnace;
+
+import me.shedaniel.api.IDisplayCategory;
+import me.shedaniel.gui.widget.AEISlot;
+import me.shedaniel.gui.widget.Control;
+import me.shedaniel.gui.widget.WidgetArrow;
+import me.shedaniel.plugin.crafting.VanillaCraftingRecipe;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntityFurnace;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class VanillaFurnaceCategory implements IDisplayCategory<VanillaFurnaceRecipe> {
+ private List<VanillaFurnaceRecipe> recipes;
+
+ @Override
+ public String getId() {
+ return "furnace";
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Smelting";
+ }
+
+ @Override
+ public void addRecipe(VanillaFurnaceRecipe recipe) {
+ if (this.recipes == null)
+ this.recipes = new ArrayList<>();
+ this.recipes.add(recipe);
+ }
+
+ @Override
+ public void resetRecipes() {
+ this.recipes = new ArrayList<>();
+ }
+
+ @Override
+ public List<AEISlot> setupDisplay(int number) {
+ List<AEISlot> slots = new LinkedList<>();
+ AEISlot inputSlot = new AEISlot(50, 70 + number * 75);
+ inputSlot.setStackList(recipes.get(number).getInput().get(0));
+ inputSlot.setDrawBackground(true);
+
+ AEISlot outputSlot = new AEISlot(110, 70 + number * 75);
+ outputSlot.setStackList(recipes.get(number).getOutput());
+ outputSlot.setDrawBackground(true);
+
+ AEISlot fuelSlot = new AEISlot(80, 100 + number * 75);
+ fuelSlot.setStackList(getFuel());
+ fuelSlot.setDrawBackground(true);
+ fuelSlot.setExtraTooltip("Fuel");
+
+ slots.add(inputSlot);
+ slots.add(outputSlot);
+ slots.add(fuelSlot);
+ return slots;
+ }
+
+ @Override
+ public boolean canDisplay(VanillaFurnaceRecipe recipe) {
+ return false;
+ }
+
+ @Override
+ public void drawExtras() {
+
+ }
+
+ @Override
+ public void addWidget(List<Control> controls, int number) {
+ WidgetArrow wa = new WidgetArrow(75, 70 + number * 75, true);
+ controls.add(wa);
+ }
+
+ private List<ItemStack> getFuel() {
+ return TileEntityFurnace.getBurnTimes().keySet().stream().map(Item::getDefaultInstance).collect(Collectors.toList());
+ }
+}
diff --git a/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceRecipe.java b/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceRecipe.java
new file mode 100755
index 000000000..a8c18d251
--- /dev/null
+++ b/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceRecipe.java
@@ -0,0 +1,42 @@
+package me.shedaniel.plugin.furnace;
+
+import me.shedaniel.api.IRecipe;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.FurnaceRecipe;
+import net.minecraft.item.crafting.Ingredient;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class VanillaFurnaceRecipe implements IRecipe<ItemStack> {
+ private final FurnaceRecipe recipe;
+
+ @Override
+ public String getId() {
+ return "furnace";
+ }
+
+ public VanillaFurnaceRecipe(FurnaceRecipe recipe) {
+ this.recipe = recipe;
+ }
+
+ @Override
+ public List<ItemStack> getOutput() {
+ List<ItemStack> output = new LinkedList<>();
+ output.add(recipe.getRecipeOutput().copy());
+ return output;
+ }
+
+ @Override
+ public List<List<ItemStack>> getInput() {
+ List<List<ItemStack>> input = new LinkedList<>();
+ for(Ingredient ingredient : recipe.getIngredients()) {
+ List<ItemStack> ingredients = new LinkedList<>();
+ for(ItemStack matchingStack : ingredient.getMatchingStacks()) {
+ ingredients.add(matchingStack);
+ }
+ input.add(ingredients);
+ }
+ return input;
+ }
+}