diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-08-24 08:16:37 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-08-24 08:16:37 -0400 |
| commit | 70c1354a4a96698758a88c032866288f79de6f5a (patch) | |
| tree | eca51294e84b90a4cb3230bc2c7900469e784184 /src/main/java/jp/plusplus/fbs/nei | |
Diffstat (limited to 'src/main/java/jp/plusplus/fbs/nei')
17 files changed, 895 insertions, 0 deletions
diff --git a/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler$CachedAppraisalRecipe.class b/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler$CachedAppraisalRecipe.class Binary files differnew file mode 100644 index 0000000..b2cefcc --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler$CachedAppraisalRecipe.class diff --git a/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler.class b/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler.class Binary files differnew file mode 100644 index 0000000..2becbb6 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler.class diff --git a/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler.java b/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler.java new file mode 100644 index 0000000..a6130c1 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/AppraisalHandler.java @@ -0,0 +1,105 @@ +package jp.plusplus.fbs.nei;
+
+import codechicken.lib.gui.GuiDraw;
+import codechicken.nei.NEIClientUtils;
+import codechicken.nei.PositionedStack;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.alchemy.AlchemyRegistry;
+import jp.plusplus.fbs.gui.GuiExtractingFurnace;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.item.ItemStack;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * Created by pluslus_F on 2015/06/24.
+ */
+public class AppraisalHandler extends TemplateRecipeHandler {
+ @Override
+ public void loadTransferRects() {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(68, 35, 22, 15), "fbs.appraisal", new Object[0]));
+ }
+
+ @Override
+ public String getOverlayIdentifier() {
+ return "fbs.appraisal";
+ }
+
+ @Override
+ public void drawBackground(int recipe) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.changeTexture(this.getGuiTexture());
+ GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 139-5, 65);
+ }
+ @Override
+ public void drawExtras(int recipe) {
+ }
+
+ @Override
+ public void loadCraftingRecipes(String outputId, Object... results) {
+ if(outputId.equals("fbs.appraisal") && this.getClass() == AppraisalHandler.class) {
+ for(AlchemyRegistry.ItemPair ip : AlchemyRegistry.GetAlllAppraisal()) {
+ arecipes.add(new CachedAppraisalRecipe(ip.getItem1(), ip.getItem2()));
+ }
+ } else {
+ super.loadCraftingRecipes(outputId, results);
+ }
+
+ }
+
+ @Override
+ public void loadCraftingRecipes(ItemStack result) {
+ //登録済みアイテムから探す
+ for(AlchemyRegistry.ItemPair ip : AlchemyRegistry.GetAlllAppraisal()){
+ if(ip.getItem2().isItemEqual(result)){
+ arecipes.add(new CachedAppraisalRecipe(ip.getItem1(), result));
+ }
+ }
+ }
+
+ @Override
+ public void loadUsageRecipes(ItemStack ingredient) {
+ //登録済みアイテムから探す
+ for(AlchemyRegistry.ItemPair ip : AlchemyRegistry.GetAlllAppraisal()){
+ if(ip.getItem1().isItemEqual(ingredient)){
+ arecipes.add(new CachedAppraisalRecipe(ingredient, ip.getItem2()));
+ }
+ }
+ }
+
+ @Override
+ public String getGuiTexture() {
+ return FBS.MODID+":textures/gui/appraisal.png";
+ }
+
+ @Override
+ public String getRecipeName() {
+ return NEIClientUtils.translate("recipe.fbs.appraisal", new Object[0]);
+ }
+
+ public class CachedAppraisalRecipe extends CachedRecipe {
+ public ArrayList<PositionedStack> ingredients=new ArrayList<PositionedStack>();
+ public PositionedStack result;
+
+ public CachedAppraisalRecipe(ItemStack in, ItemStack out){
+ ingredients.add(new PositionedStack(in, 56-5, 35-11));
+ result=new PositionedStack(out, 115-5,35-11);
+ }
+
+ @Override
+ public java.util.List<PositionedStack> getIngredients() {
+ return getCycledIngredients(AppraisalHandler.this.cycleticks / 20, ingredients);
+ }
+
+ @Override
+ public PositionedStack getResult() {
+ return result;
+ }
+
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler$CachedExtractingRecipe.class b/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler$CachedExtractingRecipe.class Binary files differnew file mode 100644 index 0000000..ced8b98 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler$CachedExtractingRecipe.class diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler.class b/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler.class Binary files differnew file mode 100644 index 0000000..c55b8ae --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler.class diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler.java b/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler.java new file mode 100644 index 0000000..52ee5d0 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSExtractingHandler.java @@ -0,0 +1,190 @@ +package jp.plusplus.fbs.nei;
+
+import codechicken.core.ReflectionManager;
+import codechicken.lib.gui.GuiDraw;
+import codechicken.nei.NEIClientConfig;
+import codechicken.nei.NEIClientUtils;
+import codechicken.nei.NEIServerUtils;
+import codechicken.nei.PositionedStack;
+import codechicken.nei.api.DefaultOverlayRenderer;
+import codechicken.nei.api.IOverlayHandler;
+import codechicken.nei.api.IRecipeOverlayRenderer;
+import codechicken.nei.api.IStackPositioner;
+import codechicken.nei.recipe.RecipeInfo;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.gui.GuiExtractingFurnace;
+import jp.plusplus.fbs.gui.GuiWorkbench;
+import jp.plusplus.fbs.item.ItemCore;
+import jp.plusplus.fbs.tileentity.TileEntityExtractingFurnace;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.item.crafting.ShapedRecipes;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * Created by pluslus_F on 2015/06/24.
+ */
+public class FBSExtractingHandler extends TemplateRecipeHandler {
+ protected LinkedList<Registry.ItemManaContainer> items=new LinkedList<Registry.ItemManaContainer>();
+
+ @Override
+ public void loadTransferRects() {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(68, 35, 22, 15), "fbs.extracting", new Object[0]));
+ }
+
+ @Override
+ public String getOverlayIdentifier() {
+ return "fbs.extracting";
+ }
+
+ @Override
+ public Class<? extends GuiContainer> getGuiClass() {
+ return GuiExtractingFurnace.class;
+ }
+
+ @Override
+ public void drawBackground(int recipe) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.changeTexture(this.getGuiTexture());
+ GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 132-5, 65);
+ }
+ @Override
+ public void drawExtras(int recipe) {
+ int a=items.get(recipe).amount;
+ String str="";
+ if(a!=-1) str=""+a+" mb";
+ else str="??? mb";
+ GuiDraw.fontRenderer.drawString(str, 79 - (GuiDraw.fontRenderer.getStringWidth(str)) / 2 - 5, 51 - 11, 0x404040);
+
+ //流体の描画
+ int scale = 52 * a / TileEntityExtractingFurnace.TANK_CAPACITY;
+ if(scale<=0) scale=1;
+
+ int x=98-5, y=69-11-scale, w=34, h=scale;
+ IIcon icon=BlockCore.mana.getIcon();
+
+ GL11.glPushMatrix();
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glColor4f(2.0F, 2.0F, 2.0F, 0.75F);
+
+ GuiDraw.changeTexture(TextureMap.locationBlocksTexture);
+
+ int sx, sy;
+ for (sy = 0; h - sy * 16 > 16; sy++) {
+ for (sx = 0; w - sx * 16 > 16; sx++) {
+ GuiDraw.gui.drawTexturedModelRectFromIcon(x + sx * 16, y + sy * 16, icon, 16, 16);
+ }
+ GuiDraw.gui.drawTexturedModelRectFromIcon(x + sx * 16, y + sy * 16, icon, w - sx * 16, 16);
+ }
+ for (sx = 0; w - sx * 16 > 16; sx++) {
+ GuiDraw.gui.drawTexturedModelRectFromIcon(x + sx * 16, y + sy * 16, icon, 16, h - sy * 16);
+ }
+ GuiDraw.gui.drawTexturedModelRectFromIcon(x + sx * 16, y + sy * 16, icon, w - sx * 16, h - sy * 16);
+
+ GL11.glDisable(GL12.GL_RESCALE_NORMAL);
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopMatrix();
+
+ GuiDraw.changeTexture(this.getGuiTexture());
+ }
+
+ @Override
+ public void loadCraftingRecipes(String outputId, Object... results) {
+ if(outputId.equals("fbs.extracting") && this.getClass() == FBSExtractingHandler.class) {
+ Registry.ItemManaContainer rp;
+ Iterator i$ = Registry.GetManaContainers().iterator();
+
+ //書物
+ rp=new Registry.ItemManaContainer(new ItemStack(ItemCore.bookOld), -1);
+ arecipes.add(new FBSExtractingHandler.CachedExtractingRecipe(rp));
+ items.add(rp);
+ rp=new Registry.ItemManaContainer(new ItemStack(ItemCore.bookSorcery), -1);
+ arecipes.add(new FBSExtractingHandler.CachedExtractingRecipe(rp));
+ items.add(rp);
+
+ //登録済みアイテム
+ while(i$.hasNext()) {
+ rp=(Registry.ItemManaContainer)i$.next();
+ arecipes.add(new FBSExtractingHandler.CachedExtractingRecipe(rp));
+ items.add(rp);
+ }
+ } else {
+ super.loadCraftingRecipes(outputId, results);
+ }
+
+ }
+
+ @Override
+ public void loadCraftingRecipes(ItemStack result) {}
+
+ @Override
+ public void loadUsageRecipes(ItemStack ingredient) {
+ if(ingredient.getItem()==ItemCore.bookOld){
+ items.add(new Registry.ItemManaContainer(ingredient.copy(), -1));
+ return;
+ }
+ if(ingredient.getItem()==ItemCore.bookSorcery){
+ items.add(new Registry.ItemManaContainer(ingredient.copy(), -1));
+ return;
+ }
+
+ //登録済みアイテムから探す
+ Iterator i$ = Registry.GetManaContainers().iterator();
+ while(i$.hasNext()) {
+ Registry.ItemManaContainer rp=(Registry.ItemManaContainer)i$.next();
+ if(rp.item.isItemEqual(ingredient)) {
+ this.arecipes.add(new FBSExtractingHandler.CachedExtractingRecipe(rp));
+ items.add(rp);
+ }
+ }
+ }
+
+ @Override
+ public String getGuiTexture() {
+ return FBS.MODID+":textures/gui/extractingFurnace.png";
+ }
+
+ @Override
+ public String getRecipeName() {
+ return NEIClientUtils.translate("recipe.fbs.extracting", new Object[0]);
+ }
+
+ public class CachedExtractingRecipe extends CachedRecipe {
+ public ArrayList<PositionedStack> ingredients=new ArrayList<PositionedStack>();
+ public PositionedStack result;
+ public PositionedStack input;
+ public int amount;
+
+ public CachedExtractingRecipe(Registry.ItemManaContainer im){
+ ingredients.add(new PositionedStack(im.item, 44-5, 35-11));
+ amount=im.amount;
+ }
+
+ @Override
+ public java.util.List<PositionedStack> getIngredients() {
+ return getCycledIngredients(FBSExtractingHandler.this.cycleticks / 20, ingredients);
+ }
+
+ @Override
+ public PositionedStack getResult() {
+ return null;
+ }
+
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler$CachedShapedRecipe.class b/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler$CachedShapedRecipe.class Binary files differnew file mode 100644 index 0000000..779256a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler$CachedShapedRecipe.class diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler.class b/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler.class Binary files differnew file mode 100644 index 0000000..cc4cb04 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler.class diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler.java b/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler.java new file mode 100644 index 0000000..69c9f97 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSShapedRecipeHandler.java @@ -0,0 +1,241 @@ +package jp.plusplus.fbs.nei;
+
+import codechicken.core.ReflectionManager;
+import codechicken.lib.gui.GuiDraw;
+import codechicken.nei.NEIClientConfig;
+import codechicken.nei.NEIClientUtils;
+import codechicken.nei.NEIServerUtils;
+import codechicken.nei.PositionedStack;
+import codechicken.nei.api.DefaultOverlayRenderer;
+import codechicken.nei.api.IOverlayHandler;
+import codechicken.nei.api.IRecipeOverlayRenderer;
+import codechicken.nei.api.IStackPositioner;
+import codechicken.nei.recipe.RecipeInfo;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.gui.GuiWorkbench;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.gui.inventory.GuiCrafting;
+import net.minecraft.inventory.*;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.CraftingManager;
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.item.crafting.ShapedRecipes;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+
+import java.awt.*;
+import java.awt.List;
+import java.util.*;
+
+/**
+ * Createdby pluslus_Fon 2015/06/15.
+ */
+public class FBSShapedRecipeHandler extends TemplateRecipeHandler {
+ protected LinkedList<Integer> manas=new LinkedList<Integer>();
+
+ public void loadTransferRects() {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(90, 35, 22, 15), "fbs.crafting", new Object[0]));
+ }
+
+ public Class<? extends GuiContainer> getGuiClass() {
+ return GuiWorkbench.class;
+ }
+
+ public String getRecipeName() {
+ return NEIClientUtils.translate("recipe.fbs.shaped", new Object[0]);
+ }
+
+ public void drawExtras(int recipe) {
+ String str=""+manas.get(recipe)+"mb";
+ GuiDraw.fontRenderer.drawString(str, (196-GuiDraw.fontRenderer.getStringWidth(str))/2, 45, 0x404040);
+ }
+
+ public void loadCraftingRecipes(String outputId, Object... results) {
+ if(outputId.equals("fbs.crafting") && this.getClass() == FBSShapedRecipeHandler.class) {
+ Iterator i$ = Registry.getCraftingRecipes().iterator();
+
+ while(i$.hasNext()) {
+ Registry.RecipePair rp=((Registry.RecipePair)i$.next());
+ IRecipe irecipe = rp.recipe;
+ FBSShapedRecipeHandler.CachedShapedRecipe recipe = null;
+ if(irecipe instanceof ShapedRecipes) {
+ recipe = new FBSShapedRecipeHandler.CachedShapedRecipe((ShapedRecipes)irecipe);
+ } else if(irecipe instanceof ShapedOreRecipe) {
+ recipe = this.forgeShapedRecipe((ShapedOreRecipe)irecipe);
+ }
+
+ if(recipe != null) {
+ recipe.computeVisuals();
+ this.arecipes.add(recipe);
+ manas.add(rp.mana);
+ }
+ }
+ } else {
+ super.loadCraftingRecipes(outputId, results);
+ }
+
+ }
+
+ public void loadCraftingRecipes(ItemStack result) {
+ Iterator i$ = Registry.getCraftingRecipes().iterator();
+
+ while(i$.hasNext()) {
+ Registry.RecipePair rp=((Registry.RecipePair)i$.next());
+ IRecipe irecipe = rp.recipe;
+ if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
+ FBSShapedRecipeHandler.CachedShapedRecipe recipe = null;
+ if(irecipe instanceof ShapedRecipes) {
+ recipe = new FBSShapedRecipeHandler.CachedShapedRecipe((ShapedRecipes)irecipe);
+ } else if(irecipe instanceof ShapedOreRecipe) {
+ recipe = this.forgeShapedRecipe((ShapedOreRecipe)irecipe);
+ }
+
+ if(recipe != null) {
+ recipe.computeVisuals();
+ this.arecipes.add(recipe);
+ manas.add(rp.mana);
+ }
+ }
+ }
+
+ }
+
+ public void loadUsageRecipes(ItemStack ingredient) {
+ Iterator i$ = Registry.getCraftingRecipes().iterator();
+
+ while(i$.hasNext()) {
+ Registry.RecipePair rp=((Registry.RecipePair)i$.next());
+ IRecipe irecipe = rp.recipe;
+ FBSShapedRecipeHandler.CachedShapedRecipe recipe = null;
+ if(irecipe instanceof ShapedRecipes) {
+ recipe = new FBSShapedRecipeHandler.CachedShapedRecipe((ShapedRecipes)irecipe);
+ } else if(irecipe instanceof ShapedOreRecipe) {
+ recipe = this.forgeShapedRecipe((ShapedOreRecipe)irecipe);
+ }
+
+ if(recipe != null && recipe.contains(recipe.ingredients, ingredient.getItem())) {
+ recipe.computeVisuals();
+ if(recipe.contains(recipe.ingredients, ingredient)) {
+ recipe.setIngredientPermutation(recipe.ingredients, ingredient);
+ this.arecipes.add(recipe);
+ manas.add(rp.mana);
+ }
+ }
+ }
+
+ }
+
+ public FBSShapedRecipeHandler.CachedShapedRecipe forgeShapedRecipe(ShapedOreRecipe recipe) {
+ int width;
+ int height;
+ try {
+ width = ((Integer) ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 4)).intValue();
+ height = ((Integer)ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 5)).intValue();
+ } catch (Exception var9) {
+ NEIClientConfig.logger.error("Error loading recipe", var9);
+ return null;
+ }
+
+ Object[] items = recipe.getInput();
+ Object[] arr$ = items;
+ int len$ = items.length;
+
+ for(int i$ = 0; i$ < len$; ++i$) {
+ Object item = arr$[i$];
+ if(item instanceof java.util.List && ((java.util.List)item).isEmpty()) {
+ return null;
+ }
+ }
+
+ return new FBSShapedRecipeHandler.CachedShapedRecipe(width, height, items, recipe.getRecipeOutput());
+ }
+
+ public String getGuiTexture() {
+ return "textures/gui/container/crafting_table.png";
+ }
+
+ public String getOverlayIdentifier() {
+ return "fbs.crafting.shaped";
+ }
+
+ public boolean hasOverlay(GuiContainer gui, net.minecraft.inventory.Container container, int recipe) {
+ return super.hasOverlay(gui, container, recipe) || this.isRecipe2x2(recipe) && RecipeInfo.hasDefaultOverlay(gui, "crafting2x2");
+ }
+
+ public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe) {
+ IRecipeOverlayRenderer renderer = super.getOverlayRenderer(gui, recipe);
+ if(renderer != null) {
+ return renderer;
+ } else {
+ IStackPositioner positioner = RecipeInfo.getStackPositioner(gui, "crafting2x2");
+ return positioner == null?null:new DefaultOverlayRenderer(this.getIngredientStacks(recipe), positioner);
+ }
+ }
+
+ public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe) {
+ IOverlayHandler handler = super.getOverlayHandler(gui, recipe);
+ return handler != null?handler:RecipeInfo.getOverlayHandler(gui, "crafting2x2");
+ }
+
+ public boolean isRecipe2x2(int recipe) {
+ Iterator i$ = this.getIngredientStacks(recipe).iterator();
+
+ PositionedStack stack;
+ do {
+ if(!i$.hasNext()) {
+ return true;
+ }
+
+ stack = (PositionedStack)i$.next();
+ } while(stack.relx <= 43 && stack.rely <= 24);
+
+ return false;
+ }
+
+ public class CachedShapedRecipe extends CachedRecipe {
+ public ArrayList<PositionedStack> ingredients;
+ public PositionedStack result;
+
+ public CachedShapedRecipe(int width, int height, Object[] items, ItemStack out) {
+ //super(FBSShapedRecipeHandler.this);
+ this.result = new PositionedStack(out, 119, 24);
+ this.ingredients = new ArrayList();
+ this.setIngredients(width, height, items);
+ }
+
+ public CachedShapedRecipe(ShapedRecipes recipe) {
+ this(recipe.recipeWidth, recipe.recipeHeight, recipe.recipeItems, recipe.getRecipeOutput());
+ }
+
+ public void setIngredients(int width, int height, Object[] items) {
+ for(int x = 0; x < width; ++x) {
+ for(int y = 0; y < height; ++y) {
+ if(items[y * width + x] != null) {
+ PositionedStack stack = new PositionedStack(items[y * width + x], 25 + x * 18, 6 + y * 18, false);
+ stack.setMaxSize(1);
+ this.ingredients.add(stack);
+ }
+ }
+ }
+
+ }
+
+ public java.util.List<PositionedStack> getIngredients() {
+ return this.getCycledIngredients(FBSShapedRecipeHandler.this.cycleticks / 20, this.ingredients);
+ }
+
+ public PositionedStack getResult() {
+ return this.result;
+ }
+
+ public void computeVisuals() {
+ Iterator i$ = this.ingredients.iterator();
+
+ while(i$.hasNext()) {
+ PositionedStack p = (PositionedStack)i$.next();
+ p.generatePermutations();
+ }
+
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler$CachedShapelessRecipe.class b/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler$CachedShapelessRecipe.class Binary files differnew file mode 100644 index 0000000..7fab582 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler$CachedShapelessRecipe.class diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler.class b/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler.class Binary files differnew file mode 100644 index 0000000..1c939d6 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler.class diff --git a/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler.java b/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler.java new file mode 100644 index 0000000..950c1fb --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/FBSShapelessRecipeHandler.java @@ -0,0 +1,173 @@ +package jp.plusplus.fbs.nei;
+
+import codechicken.nei.NEIClientUtils;
+import codechicken.nei.NEIServerUtils;
+import codechicken.nei.PositionedStack;
+import codechicken.nei.recipe.ShapedRecipeHandler;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.Registry;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.CraftingManager;
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.item.crafting.ShapelessRecipes;
+import net.minecraftforge.oredict.ShapelessOreRecipe;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Createdby pluslus_Fon 2015/06/15.
+ */
+public class FBSShapelessRecipeHandler extends FBSShapedRecipeHandler {
+ public int[][] stackorder = new int[][]{{0, 0}, {1, 0}, {0, 1}, {1, 1}, {0, 2}, {1, 2}, {2, 0}, {2, 1}, {2, 2}};
+
+ public FBSShapelessRecipeHandler() {
+ }
+
+ public String getRecipeName() {
+ return NEIClientUtils.translate("recipe.fbs.shapeless", new Object[0]);
+ }
+
+ public void loadCraftingRecipes(String outputId, Object... results) {
+ if(outputId.equals("fbs.crafting") && this.getClass() == FBSShapelessRecipeHandler.class) {
+ Iterator i$ = Registry.getCraftingRecipes().iterator();
+
+ while(i$.hasNext()) {
+ Registry.RecipePair rp=((Registry.RecipePair)i$.next());
+ IRecipe irecipe = rp.recipe;
+ FBSShapelessRecipeHandler.CachedShapelessRecipe recipe = null;
+ if(irecipe instanceof ShapelessRecipes) {
+ recipe = this.shapelessRecipe((ShapelessRecipes)irecipe);
+ } else if(irecipe instanceof ShapelessOreRecipe) {
+ recipe = this.forgeShapelessRecipe((ShapelessOreRecipe)irecipe);
+ }
+
+ if(recipe != null) {
+ this.arecipes.add(recipe);
+ manas.add(rp.mana);
+ }
+ }
+ } else {
+ super.loadCraftingRecipes(outputId, results);
+ }
+
+ }
+
+ public void loadCraftingRecipes(ItemStack result) {
+ Iterator i$ = Registry.getCraftingRecipes().iterator();
+
+ while(i$.hasNext()) {
+ Registry.RecipePair rp=((Registry.RecipePair)i$.next());
+ IRecipe irecipe = rp.recipe;
+ if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
+ FBSShapelessRecipeHandler.CachedShapelessRecipe recipe = null;
+ if(irecipe instanceof ShapelessRecipes) {
+ recipe = this.shapelessRecipe((ShapelessRecipes)irecipe);
+ } else if(irecipe instanceof ShapelessOreRecipe) {
+ recipe = this.forgeShapelessRecipe((ShapelessOreRecipe)irecipe);
+ }
+
+ if(recipe != null) {
+ this.arecipes.add(recipe);
+ manas.add(rp.mana);
+ }
+ }
+ }
+
+ }
+
+ public void loadUsageRecipes(ItemStack ingredient) {
+ Iterator i$ = Registry.getCraftingRecipes().iterator();
+
+ while(i$.hasNext()) {
+ Registry.RecipePair rp=((Registry.RecipePair)i$.next());
+ IRecipe irecipe = rp.recipe;
+ FBSShapelessRecipeHandler.CachedShapelessRecipe recipe = null;
+ if(irecipe instanceof ShapelessRecipes) {
+ recipe = this.shapelessRecipe((ShapelessRecipes)irecipe);
+ } else if(irecipe instanceof ShapelessOreRecipe) {
+ recipe = this.forgeShapelessRecipe((ShapelessOreRecipe)irecipe);
+ }
+
+ if(recipe != null && recipe.contains(recipe.ingredients, ingredient)) {
+ recipe.setIngredientPermutation(recipe.ingredients, ingredient);
+ this.arecipes.add(recipe);
+ manas.add(rp.mana);
+ }
+ }
+
+ }
+
+ private FBSShapelessRecipeHandler.CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) {
+ return recipe.recipeItems == null?null:new FBSShapelessRecipeHandler.CachedShapelessRecipe(recipe.recipeItems, recipe.getRecipeOutput());
+ }
+
+ public FBSShapelessRecipeHandler.CachedShapelessRecipe forgeShapelessRecipe(ShapelessOreRecipe recipe) {
+ ArrayList items = recipe.getInput();
+ Iterator i$ = items.iterator();
+
+ Object item;
+ do {
+ if(!i$.hasNext()) {
+ return new FBSShapelessRecipeHandler.CachedShapelessRecipe(items, recipe.getRecipeOutput());
+ }
+
+ item = i$.next();
+ } while(!(item instanceof List) || !((List)item).isEmpty());
+
+ return null;
+ }
+
+ public boolean isRecipe2x2(int recipe) {
+ return this.getIngredientStacks(recipe).size() <= 4;
+ }
+
+ public class CachedShapelessRecipe extends CachedRecipe {
+ public ArrayList<PositionedStack> ingredients;
+ public PositionedStack result;
+
+ public CachedShapelessRecipe() {
+ //super(FBSShapelessRecipeHandler.this);
+ this.ingredients = new ArrayList();
+ }
+
+ public CachedShapelessRecipe(ItemStack output) {
+ this();
+ this.setResult(output);
+ }
+
+ public CachedShapelessRecipe(Object[] input, ItemStack output) {
+ this((List) Arrays.asList(input), output);
+ }
+
+ public CachedShapelessRecipe(List input, ItemStack output) {
+ this(output);
+ this.setIngredients(input);
+ }
+
+ public void setIngredients(List<?> items) {
+ this.ingredients.clear();
+
+ for(int ingred = 0; ingred < items.size(); ++ingred) {
+ PositionedStack stack = new PositionedStack(items.get(ingred), 25 + FBSShapelessRecipeHandler.this.stackorder[ingred][0] * 18, 6 + FBSShapelessRecipeHandler.this.stackorder[ingred][1] * 18);
+ stack.setMaxSize(1);
+ this.ingredients.add(stack);
+ }
+
+ }
+
+ public void setResult(ItemStack output) {
+ this.result = new PositionedStack(output, 119, 24);
+ }
+
+ public List<PositionedStack> getIngredients() {
+ return this.getCycledIngredients(FBSShapelessRecipeHandler.this.cycleticks / 20, this.ingredients);
+ }
+
+ public PositionedStack getResult() {
+ return this.result;
+ }
+ }
+}
\ No newline at end of file diff --git a/src/main/java/jp/plusplus/fbs/nei/NEILoader.class b/src/main/java/jp/plusplus/fbs/nei/NEILoader.class Binary files differnew file mode 100644 index 0000000..65b4150 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/NEILoader.class diff --git a/src/main/java/jp/plusplus/fbs/nei/NEILoader.java b/src/main/java/jp/plusplus/fbs/nei/NEILoader.java new file mode 100644 index 0000000..735f10d --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/NEILoader.java @@ -0,0 +1,43 @@ +package jp.plusplus.fbs.nei;
+
+import codechicken.nei.api.API;
+import jp.plusplus.fbs.gui.GuiExtractingFurnace;
+import jp.plusplus.fbs.pottery.GuiPottersWheel;
+import jp.plusplus.fbs.gui.GuiWorkbench;
+
+/**
+ * Created by plusplus_F on 2015/06/15.
+ */
+public class NEILoader {
+ public static FBSShapedRecipeHandler shapedRecipe;
+ public static FBSShapelessRecipeHandler shapelessRecipe;
+ public static FBSExtractingHandler extractingRecipe;
+ public static PotteryCraftHandler pch;
+ public static AppraisalHandler ah;
+
+ public static void LoadNEI(){
+ shapedRecipe=new FBSShapedRecipeHandler();
+ API.registerRecipeHandler(shapedRecipe);
+ API.registerUsageHandler(shapedRecipe);
+ API.registerGuiOverlay(GuiWorkbench.class, shapedRecipe.getOverlayIdentifier(), 0, 0);
+
+ shapelessRecipe=new FBSShapelessRecipeHandler();
+ API.registerRecipeHandler(shapelessRecipe);
+ API.registerUsageHandler(shapelessRecipe);
+ API.registerGuiOverlay(GuiWorkbench.class, shapelessRecipe.getOverlayIdentifier(), 0, 0);
+
+ extractingRecipe=new FBSExtractingHandler();
+ API.registerRecipeHandler(extractingRecipe);
+ API.registerUsageHandler(extractingRecipe);
+ API.registerGuiOverlay(GuiExtractingFurnace.class, extractingRecipe.getOverlayIdentifier(), 0, 0);
+
+ pch=new PotteryCraftHandler();
+ API.registerRecipeHandler(pch);
+ API.registerUsageHandler(pch);
+ API.registerGuiOverlay(GuiPottersWheel.class, pch.getOverlayIdentifier(), 0, 0);
+
+ ah=new AppraisalHandler();
+ API.registerRecipeHandler(ah);
+ API.registerUsageHandler(ah);
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler$CachedPottery.class b/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler$CachedPottery.class Binary files differnew file mode 100644 index 0000000..4662900 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler$CachedPottery.class diff --git a/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler.class b/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler.class Binary files differnew file mode 100644 index 0000000..9d6ab32 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler.class diff --git a/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler.java b/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler.java new file mode 100644 index 0000000..3c94acc --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/nei/PotteryCraftHandler.java @@ -0,0 +1,143 @@ +package jp.plusplus.fbs.nei;
+
+import codechicken.lib.gui.GuiDraw;
+import codechicken.nei.NEIClientUtils;
+import codechicken.nei.PositionedStack;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.pottery.GuiPottersWheel;
+import jp.plusplus.fbs.item.ItemCore;
+import jp.plusplus.fbs.pottery.PotteryRegistry;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * Created by pluslus_F on 2015/06/24.
+ */
+public class PotteryCraftHandler extends TemplateRecipeHandler {
+
+ @Override
+ public int recipiesPerPage(){
+ return 1;
+ }
+
+ @Override
+ public void loadTransferRects() {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(106, 53, 22, 15), "fbs.pottery", new Object[0]));
+ }
+
+ @Override
+ public String getOverlayIdentifier() {
+ return "fbs.pottery";
+ }
+
+ @Override
+ public Class<? extends GuiContainer> getGuiClass() {
+ return GuiPottersWheel.class;
+ }
+
+ @Override
+ public void drawBackground(int recipe) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.changeTexture(this.getGuiTexture());
+ GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 162-5, 102);
+ }
+ @Override
+ public void drawExtras(int recipe) {}
+
+ @Override
+ public void loadCraftingRecipes(String outputId, Object... results) {
+ if(outputId.equals("fbs.pottery") && this.getClass() == PotteryCraftHandler.class) {
+ Iterator i$ = PotteryRegistry.GetPotteryCrafting().iterator();
+
+ while(i$.hasNext()) {
+ PotteryRegistry.PotteryPair r=(PotteryRegistry.PotteryPair)i$.next();
+ arecipes.add(new CachedPottery(r));
+ }
+ } else {
+ super.loadCraftingRecipes(outputId, results);
+ }
+ }
+
+ @Override
+ public void loadCraftingRecipes(ItemStack result) {
+ Iterator i$ = PotteryRegistry.GetPotteryCrafting().iterator();
+
+ while(i$.hasNext()) {
+ PotteryRegistry.PotteryPair rp=(PotteryRegistry.PotteryPair)i$.next();
+ if(rp.product.isItemEqual(result)) arecipes.add(new CachedPottery(rp));
+ }
+ }
+
+ @Override
+ public void loadUsageRecipes(ItemStack ingredient) {
+ Iterator i$ = PotteryRegistry.GetPotteryCrafting().iterator();
+
+ while(i$.hasNext()) {
+ PotteryRegistry.PotteryPair rp=(PotteryRegistry.PotteryPair)i$.next();
+
+ boolean flag=false;
+ for(int i=0;i<rp.materials.length;i++){
+ ItemStack item=null;
+ if(rp.materials[i]=='c') flag=ingredient.getItem()==ItemCore.clayWet;
+ else if(rp.materials[i]=='g') flag=ingredient.getItem()==ItemCore.clayGlow;
+ else if(rp.materials[i]=='f'){
+ Item it=ingredient.getItem();
+ flag=(it==Item.getItemFromBlock(Blocks.red_flower) || it==Item.getItemFromBlock(Blocks.yellow_flower));
+ }
+ else if(rp.materials[i]=='s') flag=ingredient.getItem()==Items.stick;
+ else if(rp.materials[i]=='b') flag=ingredient.getItem()==Item.getItemFromBlock(Blocks.iron_bars);
+
+ }
+ if(flag) arecipes.add(new CachedPottery(rp));
+ }
+ }
+
+ @Override
+ public String getGuiTexture() {
+ return FBS.MODID+":textures/gui/pottersWheel.png";
+ }
+
+ @Override
+ public String getRecipeName() {
+ return NEIClientUtils.translate("recipe.fbs.pottery", new Object[0]);
+ }
+
+ public class CachedPottery extends CachedRecipe {
+ public ArrayList<PositionedStack> ingredients=new ArrayList<PositionedStack>();
+ public PositionedStack result;
+ public CachedPottery(PotteryRegistry.PotteryPair rp){
+ for(int i=0;i<rp.materials.length;i++){
+ ItemStack item=null;
+ if(rp.materials[i]=='c') item=new ItemStack(ItemCore.clayWet);
+ else if(rp.materials[i]=='g') item=new ItemStack(ItemCore.clayGlow);
+ else if(rp.materials[i]=='f') item=new ItemStack(Blocks.red_flower);
+ else if(rp.materials[i]=='s') item=new ItemStack(Items.stick);
+ else if(rp.materials[i]=='b') item=new ItemStack(Blocks.iron_bars);
+
+ if(item!=null) ingredients.add(new PositionedStack(item, 8-5+18*(i%5), 17-11+18*(i/5)));
+ }
+ result=new PositionedStack(rp.product, 140-5, 54-11);
+ }
+
+ @Override
+ public java.util.List<PositionedStack> getIngredients() {
+ return getCycledIngredients(PotteryCraftHandler.this.cycleticks / 20, ingredients);
+ }
+
+ @Override
+ public PositionedStack getResult() {
+ return result;
+ }
+
+ }
+}
|
