Added pure daisy NEI handler and some small tweaks to its recipe API.

This commit is contained in:
Lizbeth Rika committed 2015-04-17 18:01:16 +01:00
1 parent 00cebd4d2f
commit 8cf7d29dad
7 files changed
+147 -3

No files matched your search

@@ -240,6 +240,13 @@ public final class BotaniaAPI {
return recipe;
}
/**
* Registers a Pure Daisy Recipe.
* @param input The block that works as an input for the recipe. Can be a Block or an oredict String.
* @param output The block to be placed upon recipe completion.
* @param outputMeta The metadata to be placed upon recipe completion.
* @return The recipe created.
*/
public static RecipePureDaisy registerPureDaisyRecipe(Object input, Block output, int outputMeta) {
RecipePureDaisy recipe = new RecipePureDaisy(input, output, outputMeta);
pureDaisyRecipes.add(recipe);
@@ -247,7 +254,7 @@ public final class BotaniaAPI {
}
/**
* Registers a Rune Altar
* Registers a Rune Altar Recipe.
* @param output The ItemStack to craft.
* @param mana The amount of mana required. Don't go over 100000!
* @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper
@@ -31,6 +31,9 @@ public class RecipePureDaisy {
throw new IllegalArgumentException("input must be an oredict String or a Block.");
}
/**
* This gets called every tick, please be careful with your checks.
*/
public boolean matches(World world, int x, int y, int z, SubTileEntity pureDaisy) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
@@ -42,7 +45,7 @@ public class RecipePureDaisy {
return isOreDict(stack, oredict);
}
private boolean isOreDict(ItemStack stack, String entry) {
public boolean isOreDict(ItemStack stack, String entry) {
for(ItemStack ostack : OreDictionary.getOres(entry)) {
ItemStack cstack = ostack.copy();
if(cstack.getItemDamage() == Short.MAX_VALUE)
@@ -35,6 +35,9 @@ public class NEIBotaniaConfig implements IConfigureNEI {
API.registerRecipeHandler(new RecipeHandlerBrewery());
API.registerUsageHandler(new RecipeHandlerBrewery());
API.registerRecipeHandler(new RecipeHandlerPureDaisy());
API.registerUsageHandler(new RecipeHandlerPureDaisy());
}
}
@@ -0,0 +1,129 @@
package vazkii.botania.client.integration.nei;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipePureDaisy;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.client.integration.nei.RecipeHandlerManaPool.CachedManaPoolRecipe;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.render.tile.RenderTilePool;
import vazkii.botania.common.block.tile.mana.TilePool;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
import vazkii.botania.common.lib.LibBlockNames;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
public class RecipeHandlerPureDaisy extends TemplateRecipeHandler {
public class CachedPureDaisyRecipe extends CachedRecipe {
public List<PositionedStack> inputs = new ArrayList<PositionedStack>();
public PositionedStack output;
public List<PositionedStack> otherStacks = new ArrayList<PositionedStack>();
public CachedPureDaisyRecipe(RecipePureDaisy recipe) {
inputs.add(new PositionedStack(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY), 71, 23));
if(recipe.getInput() instanceof String)
inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 23));
else inputs.add(new PositionedStack(recipe.getInput(), 42, 23));
output = new PositionedStack(new ItemStack(recipe.getOutput()), 101, 23);
}
@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 == inputs) {
boolean skippedPool = false;
for(PositionedStack stack : ingredients)
if(stack.contains(ingredient))
return true;
}
return super.contains(ingredients, ingredient);
}
}
@Override
public String getRecipeName() {
return StatCollector.translateToLocal("botania.nei.pureDaisy");
}
@Override
public String getGuiTexture() {
return LibResources.GUI_NEI_BLANK;
}
@Override
public int recipiesPerPage() {
return 2;
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(70, 22, 18, 18), "botania.pureDaisy"));
}
@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(LibResources.GUI_PURE_DAISY_OVERLAY);
GuiDraw.drawTexturedModalRect(45, 10, 0, 0, 65, 44);
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if(outputId.equals("botania.pureDaisy")) {
for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes)
arecipes.add(new CachedPureDaisyRecipe(recipe));
} else super.loadCraftingRecipes(outputId, results);
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes)
if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(recipe.getOutput()), result))
arecipes.add(new CachedPureDaisyRecipe(recipe));
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) {
CachedPureDaisyRecipe crecipe = new CachedPureDaisyRecipe(recipe);
if(crecipe.contains(crecipe.getIngredients(), ingredient) || crecipe.contains(crecipe.getOtherStacks(), ingredient))
arecipes.add(crecipe);
}
}
}
@@ -31,6 +31,7 @@ public final class LibResources {
public static final String GUI_PAPER = PREFIX_GUI + "paper.png";
public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png";
public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png";
public static final String GUI_PURE_DAISY_OVERLAY = PREFIX_GUI + "pureDaisyOverlay.png";
public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png";
public static final String GUI_TERRASTEEL_OVERLAY = PREFIX_GUI + "terrasteelOverlay.png";
public static final String GUI_ELVEN_TRADE_OVERLAY = PREFIX_GUI + "elvenTradeOverlay.png";
@@ -114,10 +114,11 @@ botaniamisc.achievements=Botania Achievements
# NEI INTEGRATION
botania.nei.brewery=Botanical Brewery
botania.nei.elvenTrade=Elven Trade
botania.nei.floatingFlowers=Floating Flower Crafting
botania.nei.floatingFlowers=Floating Flowers
botania.nei.manaPool=Mana Infusion
botania.nei.petalApothecary=Petal Apothecary
botania.nei.runicAltar=Runic Altar
botania.nei.pureDaisy=Pure Daisy
# BUILDCRAFT INTEGRATION
botania.triggers.manaDetector=Mana Burst
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB