mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 04:32:23 +00:00
Merge pull request #338 from Tonius/master
Added Not Enough Items integration
This commit is contained in:
commit
1bd7c9c8b2
7 files changed
+541
-13
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package vazkii.botania.client.nei;
|
||||
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
||||
public class NEIBotaniaConfig implements IConfigureNEI {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return LibMisc.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return LibMisc.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
API.registerRecipeHandler(new RecipeHandlerPetalApothecary());
|
||||
API.registerUsageHandler(new RecipeHandlerPetalApothecary());
|
||||
|
||||
API.registerRecipeHandler(new RecipeHandlerRunicAltar());
|
||||
API.registerUsageHandler(new RecipeHandlerRunicAltar());
|
||||
|
||||
API.registerRecipeHandler(new RecipeHandlerManaPool());
|
||||
API.registerUsageHandler(new RecipeHandlerManaPool());
|
||||
|
||||
API.registerRecipeHandler(new RecipeHandlerElvenTrade());
|
||||
API.registerUsageHandler(new RecipeHandlerElvenTrade());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package vazkii.botania.client.nei;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexicon;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.common.block.BlockAlfPortal;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class RecipeHandlerElvenTrade extends TemplateRecipeHandler {
|
||||
|
||||
public class CachedElvenTradeRecipe extends CachedRecipe {
|
||||
|
||||
public List<PositionedStack> inputs = new ArrayList<PositionedStack>();
|
||||
public PositionedStack output;
|
||||
|
||||
public CachedElvenTradeRecipe(RecipeElvenTrade recipe) {
|
||||
setIngredients(recipe.getInputs());
|
||||
output = new PositionedStack(recipe.getOutput(), 107, 46);
|
||||
}
|
||||
|
||||
public void setIngredients(List<Object> inputs) {
|
||||
int i = 0;
|
||||
for (Object o : inputs) {
|
||||
if (o instanceof String) {
|
||||
this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), 60 + i * 18, 6));
|
||||
} else {
|
||||
this.inputs.add(new PositionedStack(o, 60 + 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 "Elven Trade";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "botania:textures/gui/neiBlank.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(35, 30, 48, 48), "botania.elvenTrade"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
super.drawBackground(recipe);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.7F);
|
||||
GuiDraw.changeTexture("botania:textures/gui/elvenTradeOverlay.png");
|
||||
GuiDraw.drawTexturedModalRect(30, 10, 17, 17, 100, 80);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GuiDraw.changeTexture(TextureMap.locationBlocksTexture);
|
||||
RenderItem.getInstance().renderIcon(35, 29, BlockAlfPortal.portalTex, 48, 48);
|
||||
}
|
||||
|
||||
private static boolean hasElvenKnowledge() {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null) {
|
||||
for (ItemStack stack : player.inventory.mainInventory) {
|
||||
if (stack != null && stack.getItem() instanceof ILexicon) {
|
||||
ILexicon lexicon = (ILexicon) stack.getItem();
|
||||
if (lexicon.isKnowledgeUnlocked(stack, BotaniaAPI.elvenKnowledge)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("botania.elvenTrade") && hasElvenKnowledge()) {
|
||||
if (hasElvenKnowledge()) {
|
||||
for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
|
||||
arecipes.add(new CachedElvenTradeRecipe(recipe));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
if (hasElvenKnowledge()) {
|
||||
for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result)) {
|
||||
arecipes.add(new CachedElvenTradeRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
if (hasElvenKnowledge()) {
|
||||
for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
|
||||
CachedElvenTradeRecipe crecipe = new CachedElvenTradeRecipe(recipe);
|
||||
if (crecipe.contains(crecipe.inputs, ingredient)) {
|
||||
arecipes.add(crecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package vazkii.botania.client.nei;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipeManaInfusion;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.client.render.tile.RenderTilePool;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class RecipeHandlerManaPool extends TemplateRecipeHandler {
|
||||
|
||||
public class CachedManaPoolRecipe extends CachedRecipe {
|
||||
|
||||
public List<PositionedStack> inputs = new ArrayList<PositionedStack>();
|
||||
public PositionedStack output;
|
||||
public List<PositionedStack> otherStacks = new ArrayList<PositionedStack>();
|
||||
public int mana;
|
||||
|
||||
public CachedManaPoolRecipe(RecipeManaInfusion recipe) {
|
||||
inputs.add(new PositionedStack(new ItemStack(ModBlocks.pool, 1, recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), 71, 37));
|
||||
|
||||
if (recipe.getInput() instanceof String) {
|
||||
inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 37));
|
||||
} else {
|
||||
inputs.add(new PositionedStack(recipe.getInput(), 42, 37));
|
||||
}
|
||||
if (recipe.isAlchemy()) {
|
||||
otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.alchemyCatalyst), 10, 37));
|
||||
} else if (recipe.isConjuration()) {
|
||||
otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.conjurationCatalyst), 10, 37));
|
||||
}
|
||||
|
||||
output = new PositionedStack(recipe.getOutput(), 101, 37);
|
||||
mana = recipe.getManaToConsume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 20, inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks() {
|
||||
return otherStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Collection<PositionedStack> ingredients, ItemStack ingredient) {
|
||||
if (ingredients == this.inputs) {
|
||||
boolean skippedPool = false;
|
||||
for (PositionedStack stack : ingredients) {
|
||||
if (!skippedPool) {
|
||||
skippedPool = true;
|
||||
continue;
|
||||
}
|
||||
if (stack.contains(ingredient)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.contains(ingredients, ingredient);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return "Mana Pool";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "botania:textures/gui/neiBlank.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(70, 36, 18, 18), "botania.manaPool"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
super.drawBackground(recipe);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
|
||||
GuiDraw.changeTexture("botania:textures/gui/manaInfusionOverlay.png");
|
||||
GuiDraw.drawTexturedModalRect(45, 20, 38, 35, 92, 50);
|
||||
HUDHandler.renderManaBar(32, 80, 0x0000FF, 0.75F, ((CachedManaPoolRecipe) arecipes.get(recipe)).mana, TilePool.MAX_MANA);
|
||||
RenderTilePool.forceMana = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("botania.manaPool")) {
|
||||
for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) {
|
||||
arecipes.add(new CachedManaPoolRecipe(recipe));
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result)) {
|
||||
arecipes.add(new CachedManaPoolRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) {
|
||||
CachedManaPoolRecipe crecipe = new CachedManaPoolRecipe(recipe);
|
||||
if (crecipe.contains(crecipe.getIngredients(), ingredient) || crecipe.contains(crecipe.getOtherStacks(), ingredient)) {
|
||||
arecipes.add(crecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package vazkii.botania.client.nei;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class RecipeHandlerPetalApothecary extends TemplateRecipeHandler {
|
||||
|
||||
public class CachedPetalApothecaryRecipe extends CachedRecipe {
|
||||
|
||||
public List<PositionedStack> inputs = new ArrayList<PositionedStack>();
|
||||
public PositionedStack output;
|
||||
|
||||
public CachedPetalApothecaryRecipe(RecipePetals recipe, boolean addCenterItem) {
|
||||
setIngredients(recipe.getInputs());
|
||||
output = new PositionedStack(recipe.getOutput(), 111, 21);
|
||||
if (addCenterItem) {
|
||||
inputs.add(new PositionedStack(new ItemStack(ModBlocks.altar), 73, 55));
|
||||
}
|
||||
}
|
||||
|
||||
public CachedPetalApothecaryRecipe(RecipePetals recipe) {
|
||||
this(recipe, true);
|
||||
}
|
||||
|
||||
public void setIngredients(List<Object> inputs) {
|
||||
float degreePerInput = 360F / inputs.size();
|
||||
float currentDegree = -90F;
|
||||
|
||||
for (Object o : inputs) {
|
||||
int posX = (int) Math.round(73 + Math.cos(currentDegree * Math.PI / 180D) * 32);
|
||||
int posY = (int) Math.round(55 + Math.sin(currentDegree * Math.PI / 180D) * 32);
|
||||
|
||||
if (o instanceof String) {
|
||||
this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), posX, posY));
|
||||
} else {
|
||||
this.inputs.add(new PositionedStack(o, posX, posY));
|
||||
}
|
||||
currentDegree += degreePerInput;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 20, inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return "Petal Apothecary";
|
||||
}
|
||||
|
||||
public String getRecipeID() {
|
||||
return "botania.petalApothecary";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "botania:textures/gui/neiBlank.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(72, 54, 18, 18), getRecipeID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
super.drawBackground(recipe);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
|
||||
GuiDraw.changeTexture("botania:textures/gui/petalOverlay.png");
|
||||
GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92);
|
||||
}
|
||||
|
||||
public List<? extends RecipePetals> getRecipes() {
|
||||
return BotaniaAPI.petalRecipes;
|
||||
}
|
||||
|
||||
public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) {
|
||||
return new CachedPetalApothecaryRecipe(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals(getRecipeID())) {
|
||||
for (RecipePetals recipe : getRecipes()) {
|
||||
arecipes.add(getCachedRecipe(recipe));
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (RecipePetals recipe : getRecipes()) {
|
||||
if (recipe.getOutput().stackTagCompound != null && NEIServerUtils.areStacksSameType(recipe.getOutput(), result) || recipe.getOutput().stackTagCompound == null && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result)) {
|
||||
arecipes.add(getCachedRecipe(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (RecipePetals recipe : getRecipes()) {
|
||||
CachedPetalApothecaryRecipe crecipe = getCachedRecipe(recipe);
|
||||
if (crecipe.contains(crecipe.inputs, ingredient)) {
|
||||
arecipes.add(crecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package vazkii.botania.client.nei;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import codechicken.nei.PositionedStack;
|
||||
|
||||
public class RecipeHandlerRunicAltar extends RecipeHandlerPetalApothecary {
|
||||
|
||||
public class CachedRunicAltarRecipe extends CachedPetalApothecaryRecipe {
|
||||
|
||||
public int manaUsage;
|
||||
|
||||
public CachedRunicAltarRecipe(RecipeRuneAltar recipe) {
|
||||
super(recipe, false);
|
||||
manaUsage = recipe.getManaUsage();
|
||||
inputs.add(new PositionedStack(new ItemStack(ModBlocks.runeAltar), 73, 55));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return "Runic Altar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeID() {
|
||||
return "botania.runicAltar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
super.drawBackground(recipe);
|
||||
HUDHandler.renderManaBar(32, 113, 0x0000FF, 0.75F, ((CachedRunicAltarRecipe) arecipes.get(recipe)).manaUsage, TilePool.MAX_MANA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends RecipePetals> getRecipes() {
|
||||
return BotaniaAPI.runeAltarRecipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) {
|
||||
return new CachedRunicAltarRecipe((RecipeRuneAltar) recipe);
|
||||
}
|
||||
|
||||
}
|
||||
+23
-13
@@ -15,6 +15,13 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "chickenbones"
|
||||
url = "http://chickenbones.net/maven/"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.0"
|
||||
@@ -27,9 +34,12 @@ minecraft {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile files (
|
||||
'Baubles-deobf.jar'
|
||||
)
|
||||
compile files (
|
||||
'Baubles-deobf.jar'
|
||||
)
|
||||
compile "codechicken:CodeChickenLib:1.7.10-1.1.1.95:dev"
|
||||
compile "codechicken:CodeChickenCore:1.7.10-1.0.2.9:dev"
|
||||
compile "codechicken:NotEnoughItems:1.7.10-1.0.2.15:dev"
|
||||
}
|
||||
|
||||
processResources
|
||||
@@ -46,14 +56,14 @@ processResources
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
|
||||
task deobfJar(type: Jar) {
|
||||
from(sourceSets.main.output)
|
||||
classifier = 'deobf'
|
||||
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives deobfJar
|
||||
}
|
||||
|
||||
task deobfJar(type: Jar) {
|
||||
from(sourceSets.main.output)
|
||||
classifier = 'deobf'
|
||||
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives deobfJar
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Reference in new issue
Block a user