Brick Oven has NEI support.
parent
9024210961
commit
d779d72ba2
|
@ -0,0 +1,245 @@
|
|||
package net.einsteinsci.betterbeginnings.nei;
|
||||
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.FurnaceRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.GuiBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.BrickOvenRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.BrickOvenShapedRecipe;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.BrickOvenShapelessRecipe;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.IBrickOvenRecipe;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class NEIBrickOvenRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
public class BrickOvenCachedRecipe extends CachedRecipe
|
||||
{
|
||||
PositionedStack[] inputs;
|
||||
PositionedStack output;
|
||||
|
||||
public BrickOvenCachedRecipe(IBrickOvenRecipe ibr)
|
||||
{
|
||||
inputs = new PositionedStack[9];
|
||||
|
||||
if (ibr instanceof BrickOvenShapedRecipe)
|
||||
{
|
||||
BrickOvenShapedRecipe shaped = (BrickOvenShapedRecipe)ibr;
|
||||
|
||||
output = new PositionedStack(shaped.getRecipeOutput(), 119, 10);
|
||||
ItemStack[] grid = shaped.getThreeByThree();
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
int i = y * 3 + x;
|
||||
|
||||
if (grid[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
inputs[i] = new PositionedStack(grid[i], 25 + x * 18, 6 + y * 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ibr instanceof BrickOvenShapelessRecipe)
|
||||
{
|
||||
BrickOvenShapelessRecipe shapeless = (BrickOvenShapelessRecipe)ibr;
|
||||
|
||||
output = new PositionedStack(shapeless.getRecipeOutput(), 119, 10);
|
||||
ItemStack[] stacks = shapeless.getInputs();
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
int i = y * 3 + x;
|
||||
|
||||
if (stacks[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
inputs[i] = new PositionedStack(stacks[i], 25 + x * 18, 6 + y * 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
List<PositionedStack> buf = new ArrayList<>();
|
||||
for (int i = 0; i < inputs.length; i++)
|
||||
{
|
||||
if (inputs[i] != null)
|
||||
{
|
||||
buf.add(inputs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return getCycledIngredients(cycleticks / 48, buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getOtherStack() {
|
||||
return afuels.get((cycleticks / 48) % afuels.size()).stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FuelPair
|
||||
{
|
||||
public FuelPair(ItemStack ingred, int burnTime) {
|
||||
this.stack = new PositionedStack(ingred, 87, 47, false);
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
public PositionedStack stack;
|
||||
public int burnTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for (IBrickOvenRecipe ibr : BrickOvenRecipeHandler.getRecipeList())
|
||||
{
|
||||
if (ibr.getRecipeOutput().getItem() == result.getItem() &&
|
||||
(result.getItemDamage() == OreDictionary.WILDCARD_VALUE ||
|
||||
ibr.getRecipeOutput().getItemDamage() == result.getItemDamage()))
|
||||
{
|
||||
arecipes.add(new BrickOvenCachedRecipe(ibr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for (IBrickOvenRecipe ibr : BrickOvenRecipeHandler.getRecipeList())
|
||||
{
|
||||
boolean found = false;
|
||||
ItemStack[] inp = ibr.getInputs();
|
||||
for (int i = 0; i < inp.length; i++)
|
||||
{
|
||||
ItemStack is = inp[i];
|
||||
|
||||
if (is == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is.getItem() == ingredient.getItem() &&
|
||||
(is.getItemDamage() == ingredient.getItemDamage() ||
|
||||
ingredient.getItemDamage() == OreDictionary.WILDCARD_VALUE))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
arecipes.add(new BrickOvenCachedRecipe(ibr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<FuelPair> afuels;
|
||||
|
||||
@Override
|
||||
public TemplateRecipeHandler newInstance()
|
||||
{
|
||||
if (afuels == null || afuels.isEmpty())
|
||||
{
|
||||
findFuels();
|
||||
}
|
||||
|
||||
return super.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return GuiBrickOven.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return ModMain.MODID + ":textures/gui/container/brickOven.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return I18n.format("container.brickoven");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "brickoven";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe)
|
||||
{
|
||||
drawProgressBar(87, 30, 176, 0, 14, 14, 48, 7);
|
||||
drawProgressBar(84, 9, 176, 14, 24, 16, 48, 0);
|
||||
}
|
||||
|
||||
private static Set<Item> excludedFuels()
|
||||
{
|
||||
Set<Item> efuels = new HashSet<>();
|
||||
efuels.add(Item.getItemFromBlock(Blocks.brown_mushroom));
|
||||
efuels.add(Item.getItemFromBlock(Blocks.red_mushroom));
|
||||
efuels.add(Item.getItemFromBlock(Blocks.standing_sign));
|
||||
efuels.add(Item.getItemFromBlock(Blocks.wall_sign));
|
||||
efuels.add(Item.getItemFromBlock(Blocks.trapped_chest));
|
||||
efuels.add(Item.getItemFromBlock(Blocks.bedrock));
|
||||
return efuels;
|
||||
}
|
||||
|
||||
private static void findFuels()
|
||||
{
|
||||
afuels = new ArrayList<>();
|
||||
Set<Item> efuels = excludedFuels();
|
||||
|
||||
for (ItemStack item : ItemList.items)
|
||||
{
|
||||
Block block = Block.getBlockFromItem(item.getItem());
|
||||
if (block instanceof BlockDoor)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (efuels.contains(item.getItem()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int burnTime = TileEntityBrickOven.getItemBurnTime(item);
|
||||
if (burnTime > 0)
|
||||
{
|
||||
afuels.add(new FuelPair(item.copy(), burnTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,6 +22,10 @@ public class NEIConfig implements IConfigureNEI
|
|||
API.registerRecipeHandler(smelterRecipeHandler);
|
||||
API.registerUsageHandler(smelterRecipeHandler);
|
||||
|
||||
NEIBrickOvenRecipeHandler brickOvenRecipeHandler = new NEIBrickOvenRecipeHandler();
|
||||
API.registerRecipeHandler(brickOvenRecipeHandler);
|
||||
API.registerUsageHandler(brickOvenRecipeHandler);
|
||||
|
||||
API.hideItem(new ItemStack(RegisterBlocks.kilnLit));
|
||||
API.hideItem(new ItemStack(RegisterBlocks.brickOvenLit));
|
||||
API.hideItem(new ItemStack(RegisterBlocks.smelterLit));
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.einsteinsci.betterbeginnings.ModMain;
|
|||
import net.einsteinsci.betterbeginnings.gui.GuiSmelter;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.SmelterRecipe;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.SmelterRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityKiln;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntitySmelter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
|
@ -80,7 +79,6 @@ public class NEISmelterRecipeHandler extends TemplateRecipeHandler
|
|||
@Override
|
||||
public String getGuiTexture()
|
||||
{
|
||||
// vanilla
|
||||
return ModMain.MODID + ":textures/gui/container/smelter.png";
|
||||
}
|
||||
|
||||
|
|
|
@ -89,9 +89,8 @@ public class RegisterRecipes
|
|||
Blocks.pumpkin);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.fermented_spider_eye), Items.spider_eye,
|
||||
Items.sugar, Blocks.brown_mushroom);
|
||||
BrickOvenRecipeHandler
|
||||
.addShapelessRecipe(new ItemStack(Items.magma_cream), Items.slime_ball, Items.blaze_powder);
|
||||
//BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(RegisterItems.roastingStickCookedMallow), RegisterItems.roastingStickRawMallow);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.magma_cream),
|
||||
Items.slime_ball, Items.blaze_powder);
|
||||
}
|
||||
|
||||
private static void addSmelterRecipes()
|
||||
|
|
|
@ -144,18 +144,6 @@ public class BrickOvenRecipeHandler
|
|||
return recipe;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addLists(ItemStack output, Object... args)
|
||||
{
|
||||
// putLists(output, args);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void putLists(ItemStack output, Object... args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ItemStack findMatchingRecipe(TileEntityBrickOven oven)
|
||||
{
|
||||
int i = 0;
|
||||
|
@ -209,8 +197,8 @@ public class BrickOvenRecipeHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
public List getRecipeList()
|
||||
public static List<IBrickOvenRecipe> getRecipeList()
|
||||
{
|
||||
return recipes;
|
||||
return instance().recipes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
||||
{
|
||||
/**
|
||||
|
@ -202,6 +205,45 @@ public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
|||
return recipeOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputs()
|
||||
{
|
||||
List<ItemStack> buf = new ArrayList<>();
|
||||
for (ItemStack is : recipeItems)
|
||||
{
|
||||
if (is != null)
|
||||
{
|
||||
buf.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
return buf.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
public ItemStack[] getThreeByThree()
|
||||
{
|
||||
ItemStack[] res = new ItemStack[9];
|
||||
|
||||
int y = 0, x = 0;
|
||||
int v = 0, u = 0;
|
||||
for (int i = 0; i < getRecipeSize(); i++)
|
||||
{
|
||||
res[x + y * 3] = recipeItems[u + v * recipeWidth];
|
||||
|
||||
u++;
|
||||
if (u >= recipeWidth)
|
||||
{
|
||||
u = 0;
|
||||
v++;
|
||||
}
|
||||
|
||||
x = u;
|
||||
y = v;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the region of a crafting inventory is match for the recipe.
|
||||
*/
|
||||
|
|
|
@ -153,4 +153,16 @@ public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
|
|||
{
|
||||
return recipeOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputs()
|
||||
{
|
||||
ItemStack[] res = new ItemStack[9];
|
||||
for (int i = 0; i < recipeItems.size(); i++)
|
||||
{
|
||||
res[i] = recipeItems.get(i);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
|||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBrickOvenRecipe
|
||||
{
|
||||
/**
|
||||
|
@ -28,4 +30,6 @@ public interface IBrickOvenRecipe
|
|||
boolean contains(ItemStack stack);
|
||||
|
||||
ItemStack getRecipeOutput();
|
||||
|
||||
ItemStack[] getInputs();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue