mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-26 23:13:09 +00:00
Work on the Petal Apothecary, it actually does something now :D
This commit is contained in:
1 parent
87ffdc1984
commit
e41e49a3f3
5 files changed
+133
-6
No files matched your search
@@ -14,15 +14,18 @@ package vazkii.botania.api;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import vazkii.botania.api.internal.DummyMethodHandler;
|
||||
import vazkii.botania.api.internal.IInternalMethodHandler;
|
||||
import vazkii.botania.api.internal.RecipePetals;
|
||||
|
||||
public final class BotaniaAPI {
|
||||
|
||||
private static List<LexiconCategory> categories = new ArrayList<LexiconCategory>();
|
||||
private static List<LexiconEntry> allEntries = new ArrayList<LexiconEntry>();
|
||||
public static List<RecipePetals> petalRecipes = new ArrayList<RecipePetals>();
|
||||
|
||||
/**
|
||||
* The internal method handler in use. Do not overwrite.
|
||||
@@ -30,6 +33,19 @@ public final class BotaniaAPI {
|
||||
*/
|
||||
public static IInternalMethodHandler internalHandler = new DummyMethodHandler();
|
||||
|
||||
/**
|
||||
* Registers a Petal Recipe.
|
||||
* @param output The ItemStack to craft.
|
||||
* @param colors The required metadata petals for this recipe to be accept.
|
||||
* Eg: 0, 0, 1 is White, White, Orange
|
||||
* @return The recipe created.
|
||||
*/
|
||||
public static RecipePetals registerPetalRecipe(ItemStack output, int... colors) {
|
||||
RecipePetals recipe = new RecipePetals(output, colors);
|
||||
petalRecipes.add(recipe);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a category to the list of registered categories to appear in the Lexicon.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jan 22, 2014, 2:02:44 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RecipePetals {
|
||||
|
||||
ItemStack output;
|
||||
List<Integer> colors = new ArrayList();
|
||||
|
||||
public RecipePetals(ItemStack output, int... colors) {
|
||||
this.output = output;
|
||||
for(int c : colors)
|
||||
this.colors.add(c);
|
||||
}
|
||||
|
||||
public boolean matches(IInventory inv) {
|
||||
List<Integer> colorsMissing = new ArrayList(colors);
|
||||
|
||||
for(int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if(stack == null)
|
||||
break;
|
||||
|
||||
int color = stack.getItemDamage();
|
||||
|
||||
if(!colorsMissing.contains(color))
|
||||
return false;
|
||||
colorsMissing.remove((Integer) color);
|
||||
}
|
||||
|
||||
return colorsMissing.isEmpty();
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,9 +16,13 @@ import java.util.List;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.RecipePetals;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
@@ -35,13 +39,18 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory {
|
||||
boolean didChange = false;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack == null)
|
||||
return false;
|
||||
|
||||
if(stack.itemID == ModItems.petal.itemID) {
|
||||
if(getStackInSlot(getSizeInventory() - 1) != null)
|
||||
return false;
|
||||
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
item.setDead();
|
||||
if(!worldObj.isRemote) {
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
item.setDead();
|
||||
}
|
||||
|
||||
for(int i = 0; i < getSizeInventory(); i++)
|
||||
if(getStackInSlot(i) == null) {
|
||||
@@ -49,6 +58,25 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory {
|
||||
didChange = true;
|
||||
break;
|
||||
}
|
||||
} else if(stack.itemID == Item.seeds.itemID) {
|
||||
for(RecipePetals recipe : BotaniaAPI.petalRecipes) {
|
||||
if(recipe.matches(this)) {
|
||||
ItemStack output = recipe.getOutput().copy();
|
||||
EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output);
|
||||
worldObj.spawnEntityInWorld(outputItem);
|
||||
for(int i = 0; i < getSizeInventory(); i++)
|
||||
setInventorySlotContents(i, null);
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
item.setDead();
|
||||
}
|
||||
|
||||
didChange = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return didChange;
|
||||
|
||||
@@ -17,10 +17,11 @@ import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.LexiconEntry;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.BiomeDecorationHandler;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.handler.InternalMethodHandler;
|
||||
import vazkii.botania.common.core.handler.BiomeDecorationHandler;
|
||||
import vazkii.botania.common.crafting.ModCrafingRecipes;
|
||||
import vazkii.botania.common.crafting.ModPetalRecipes;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.network.GuiHandler;
|
||||
@@ -28,7 +29,6 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class CommonProxy {
|
||||
|
||||
@@ -41,7 +41,8 @@ public class CommonProxy {
|
||||
ModItems.init();
|
||||
|
||||
ModCrafingRecipes.init();
|
||||
|
||||
ModPetalRecipes.init();
|
||||
|
||||
LexiconData.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jan 22, 2014, 2:22:21 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.RecipePetals;
|
||||
|
||||
public final class ModPetalRecipes {
|
||||
|
||||
public static final int white = 0, orange = 1, magenta = 2, lightBlue = 3, yellow = 4, lime = 5, pink = 6, gray = 7, lightGray = 8, cyan = 9, purple = 10, blue = 11, brown = 12, green = 13, red = 14, black = 15;
|
||||
|
||||
public static RecipePetals testRecipe;
|
||||
|
||||
public static void init() {
|
||||
testRecipe = BotaniaAPI.registerPetalRecipe(new ItemStack(Item.diamond), orange, orange, white);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user