Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/vazkii/botania/client/integration/nei/IMCForNEI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package vazkii.botania.client.integration.nei;

import cpw.mods.fml.common.event.FMLInterModComms;
import net.minecraft.nbt.NBTTagCompound;

public class IMCForNEI {
public static void IMCSender() {
sendCatalyst("botania.brewery", "Botania:vial", -1);
sendCatalyst("botania.brewery", "Botania:vial:1", -1);
sendCatalyst("botania.brewery", "Botania:incenseStick", -1);
}

private static void sendCatalyst(String handlerName, String stack, int priority) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("handlerID", handlerName);
nbt.setString("itemName", stack);
nbt.setInteger("priority", priority);
FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", nbt);
}
}
18 changes: 18 additions & 0 deletions src/main/java/vazkii/botania/client/integration/nei/NEIHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package vazkii.botania.client.integration.nei;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;

public class NEIHelper {
public static final RenderItem renderItem = new RenderItem();
public static final Minecraft mc = Minecraft.getMinecraft();
public static final TextureManager textureManager = mc.getTextureManager();
public static final FontRenderer font = mc.fontRenderer;

public static void renderItemIntoGUI(ItemStack flowerStack, int x, int y) {
renderItem.renderItemIntoGUI(font, textureManager, flowerStack, x, y);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,118 +23,127 @@

public class RecipeHandlerBrewery extends TemplateRecipeHandler {

public class CachedBreweryRecipe extends CachedRecipe {

public List<PositionedStack> inputs = new ArrayList<>();
public PositionedStack output;
public int mana;

public CachedBreweryRecipe(RecipeBrew recipe, ItemStack vial) {
if(recipe == null)
return;

setIngredients(recipe.getInputs());
ItemStack toVial;
if (vial == null)
toVial = new ItemStack(ModItems.vial);
else
toVial = vial.copy();
toVial.stackSize = 1;
inputs.add(new PositionedStack(toVial, 39, 42));

output = new PositionedStack(recipe.getOutput(toVial), 87, 42);
}

public CachedBreweryRecipe(RecipeBrew recipe) {
this(recipe, null);
}

public void setIngredients(List<Object> inputs) {
int left = 96 - inputs.size() * 18 / 2;

int i = 0;
for (Object o : inputs) {
if (o instanceof String)
this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), left + i * 18, 6));
else
this.inputs.add(new PositionedStack(o, left + i * 18, 6));

i++;
}
}

@Override
public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 20, inputs);
}

@Override
public PositionedStack getResult() {
return output;
}

}

@Override
public String getRecipeName() {
return StatCollector.translateToLocal("botania.nei.brewery");
}

@Override
public String getGuiTexture() {
return LibResources.GUI_NEI_BREWERY;
}

@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(87, 25, 15, 14), "botania.brewery"));
}

@Override
public void drawBackground(int recipe) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65);
}

@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if(outputId.equals("botania.brewery"))
for(RecipeBrew recipe : BotaniaAPI.brewRecipes)
arecipes.add(new CachedBreweryRecipe(recipe));
else super.loadCraftingRecipes(outputId, results);
}

@Override
public void loadCraftingRecipes(ItemStack result) {
if(result.getItem() instanceof IBrewItem)
for(RecipeBrew recipe : BotaniaAPI.brewRecipes) {
if(recipe == null)
continue;

if(((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew())
arecipes.add(new CachedBreweryRecipe(recipe));
}
}

@Override
public void loadUsageRecipes(ItemStack ingredient) {
if(ingredient.getItem() instanceof IBrewContainer) {
for(RecipeBrew recipe : BotaniaAPI.brewRecipes) {
if(recipe == null)
continue;

if(recipe.getOutput(ingredient) != null)
arecipes.add(new CachedBreweryRecipe(recipe, ingredient));
}
} else for(RecipeBrew recipe : BotaniaAPI.brewRecipes) {
if(recipe == null)
continue;

CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe);
if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient))
arecipes.add(crecipe);
}
}
public class CachedBreweryRecipe extends CachedRecipe {

public List<PositionedStack> inputs = new ArrayList<>();
public PositionedStack output;
public int mana;

public CachedBreweryRecipe(RecipeBrew recipe, ItemStack vial) {
if (recipe == null) return;

setIngredients(recipe.getInputs());
ItemStack toVial;
if (vial == null) {
toVial = new ItemStack(ModItems.vial);
} else {
toVial = vial.copy();
}
toVial.stackSize = 1;
inputs.add(new PositionedStack(toVial, 39, 42));

output = new PositionedStack(recipe.getOutput(toVial), 87, 42);
}

public CachedBreweryRecipe(RecipeBrew recipe) {
this(recipe, null);
}

public void setIngredients(List<Object> inputs) {
int left = 96 - inputs.size() * 18 / 2;

int i = 0;
for (Object o : inputs) {
if (o instanceof String) {
this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), left + i * 18, 6));
} else {
this.inputs.add(new PositionedStack(o, left + i * 18, 6));
}
i++;
}
}

@Override
public List<PositionedStack> getIngredients() {
return inputs;
}

@Override
public PositionedStack getResult() {
return output;
}

}

@Override
public String getRecipeName() {
return StatCollector.translateToLocal("botania.nei.brewery");
}

@Override
public String getOverlayIdentifier() {
return "botania.brewery";
}

@Override
public String getGuiTexture() {
return LibResources.GUI_NEI_BREWERY;
}

@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(87, 25, 15, 14), getOverlayIdentifier()));
}

@Override
public void drawBackground(int recipe) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65);
}

@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(getOverlayIdentifier())) {
for (RecipeBrew recipe : BotaniaAPI.brewRecipes) {
arecipes.add(new CachedBreweryRecipe(recipe));
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}

@Override
public void loadCraftingRecipes(ItemStack result) {
if (!(result.getItem() instanceof IBrewItem)) {
return;
}
for (RecipeBrew recipe : BotaniaAPI.brewRecipes) {
if (recipe != null && ((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew()) {
arecipes.add(new CachedBreweryRecipe(recipe));
}
}
}

@Override
public void loadUsageRecipes(ItemStack ingredient) {
if (ingredient.getItem() instanceof IBrewContainer) {
for (RecipeBrew recipe : BotaniaAPI.brewRecipes) {
if (recipe != null && recipe.getOutput(ingredient) != null) {
arecipes.add(new CachedBreweryRecipe(recipe, ingredient));
}
}
} else {
for (RecipeBrew recipe : BotaniaAPI.brewRecipes) {
if (recipe == null)
continue;

CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe);
if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) {
arecipes.add(crecipe);
}
}
}
}

}
Loading
Loading