mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-26 15:03:03 +00:00
Added support for OreDict recipes. Also added the Pestle and Mortar item.
This commit is contained in:
1 parent
3cba219f5f
commit
ac10ed02d7
13 files changed
+102
-11
No files matched your search
@@ -30,8 +30,8 @@ public final class RenderHelper {
|
||||
}
|
||||
|
||||
public static void renderTooltipGreen(int x, int y, List<String> tooltipData) {
|
||||
int color = 0x00a000ff;
|
||||
int color2 = 0x001e0010;
|
||||
int color = 0x5000a000;
|
||||
int color2 = 0xf0001e00;
|
||||
|
||||
renderTooltip(x, y, tooltipData, color, color2);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
|
||||
addBlock(ModBlocks.flower);
|
||||
addItem(ModItems.petal);
|
||||
addItem(ModItems.pestleAndMortar);
|
||||
addItem(ModItems.dye);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public final class ConfigHandler {
|
||||
LibItemIDs.idLexicon = loadItem(LibItemNames.LEXICON, LibItemIDs.idLexicon);
|
||||
LibItemIDs.idPetal = loadItem(LibItemNames.PETAL, LibItemIDs.idPetal);
|
||||
LibItemIDs.idDye = loadItem(LibItemNames.DYE, LibItemIDs.idDye);
|
||||
LibItemIDs.idPestleAndMortar = loadItem(LibItemNames.PESTLE_AND_MORTAR, LibItemIDs.idPestleAndMortar);
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
@@ -13,8 +13,12 @@ package vazkii.botania.common.crafting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
@@ -24,16 +28,32 @@ public final class ModCrafingRecipes {
|
||||
|
||||
public static List<IRecipe> recipesPetals;
|
||||
public static List<IRecipe> recipesDyes;
|
||||
public static IRecipe recipePestleAndMortar;
|
||||
|
||||
public static final void init() {
|
||||
public static void init() {
|
||||
// Petal/Dye Recipes
|
||||
for(int i = 0; i < 16; i++)
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.petal, 2, i), new ItemStack(ModBlocks.flower, 1, i));
|
||||
recipesPetals = BotaniaAPI.getLatestAddedRecipes(16);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.dye, 1, i), new ItemStack(ModItems.petal, 1, i));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.dye, 1, i), new ItemStack(ModItems.petal, 1, i), new ItemStack(ModItems.pestleAndMortar));
|
||||
recipesDyes = BotaniaAPI.getLatestAddedRecipes(16);
|
||||
|
||||
addOreDictRecipe(new ItemStack(ModItems.pestleAndMortar),
|
||||
" S", "W ", "B ",
|
||||
'S', "stickWood",
|
||||
'W', "plankWood",
|
||||
'B', Item.bowlEmpty);
|
||||
recipePestleAndMortar = BotaniaAPI.getLatestAddedRecipe();
|
||||
|
||||
}
|
||||
|
||||
private static void addOreDictRecipe(ItemStack output, Object... recipe) {
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, recipe));
|
||||
}
|
||||
|
||||
private static void addShapelessOreDictRecipe(ItemStack output, Object... recipe) {
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, recipe));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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 19, 2014, 7:00:34 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item;
|
||||
|
||||
import vazkii.botania.common.lib.LibItemIDs;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemPestleAndMortar extends ItemMod {
|
||||
|
||||
public ItemPestleAndMortar() {
|
||||
super(LibItemIDs.idPestleAndMortar);
|
||||
setMaxStackSize(1);
|
||||
setContainerItem(this);
|
||||
setUnlocalizedName(LibItemNames.PESTLE_AND_MORTAR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,17 +21,21 @@ public final class ModItems {
|
||||
public static Item lexicon;
|
||||
public static Item petal;
|
||||
public static Item dye;
|
||||
public static Item pestleAndMortar;
|
||||
|
||||
public static void init() {
|
||||
lexicon = new ItemLexicon();
|
||||
petal = new ItemPetal();
|
||||
dye = new ItemDye();
|
||||
|
||||
pestleAndMortar = new ItemPestleAndMortar();
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
|
||||
for(int i = 0; i < 16; i++) {
|
||||
OreDictionary.registerOre(LibOreDict.PETAL[i], new ItemStack(petal.itemID, 1, i));
|
||||
OreDictionary.registerOre(LibOreDict.DYE[i], new ItemStack(dye.itemID, 1, i));
|
||||
}
|
||||
OreDictionary.registerOre(LibOreDict.PESTLE_AND_MORTAR, pestleAndMortar);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public final class LexiconData {
|
||||
|
||||
// BASICS ENTRIES
|
||||
entry = new BLexiconEntry("world", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"), new PageImage("2", LibResources.ENTRY_FLOWERS), new PageCraftingRecipes("3", ModCrafingRecipes.recipesPetals), new PageCraftingRecipes("4", ModCrafingRecipes.recipesDyes));
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"), new PageImage("2", LibResources.ENTRY_FLOWERS), new PageCraftingRecipes("3", ModCrafingRecipes.recipesPetals), new PageCraftingRecipes("4", ModCrafingRecipes.recipePestleAndMortar), new PageCraftingRecipes("5", ModCrafingRecipes.recipesDyes));
|
||||
|
||||
entry = new BLexiconEntry("basicConcepts", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"));
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
*/
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -29,6 +29,8 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -36,6 +38,7 @@ import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.api.page.LexiconPage;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class PageCraftingRecipes extends LexiconPage {
|
||||
|
||||
@@ -110,6 +113,17 @@ public class PageCraftingRecipes extends LexiconPage {
|
||||
for(int x = 0; x < shaped.recipeWidth; x++)
|
||||
renderItemAtGridPos(gui, 1 + x, 1 + y, shaped.recipeItems[y * shaped.recipeWidth + x], true);
|
||||
|
||||
} else if(recipe instanceof ShapedOreRecipe) {
|
||||
ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
|
||||
int width = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4);
|
||||
int height = (Integer) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5);
|
||||
|
||||
for(int y = 0; y < height; y++)
|
||||
for(int x = 0; x < width; x++) {
|
||||
Object input = shaped.getInput()[y * width + x];
|
||||
if(input != null)
|
||||
renderItemAtGridPos(gui, 1 + x, 1 + y, input instanceof ItemStack ? (ItemStack) input : ((ArrayList<ItemStack>) input).get(0), true);
|
||||
}
|
||||
} else if(recipe instanceof ShapelessRecipes) {
|
||||
ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
|
||||
|
||||
@@ -124,6 +138,22 @@ public class PageCraftingRecipes extends LexiconPage {
|
||||
renderItemAtGridPos(gui, 1 + x, 1 + y, (ItemStack) shapeless.recipeItems.get(index), true);
|
||||
}
|
||||
}
|
||||
} else if(recipe instanceof ShapelessOreRecipe) {
|
||||
ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
|
||||
|
||||
drawGrid : {
|
||||
for(int y = 0; y < 3; y++)
|
||||
for(int x = 0; x < 3; x++) {
|
||||
int index = y * 3 + x;
|
||||
|
||||
if(index >= shapeless.getRecipeSize())
|
||||
break drawGrid;
|
||||
|
||||
Object input = shapeless.getInput().get(index);
|
||||
if(input != null)
|
||||
renderItemAtGridPos(gui, 1 + x, 1 + y, input instanceof ItemStack ? (ItemStack) input : ((ArrayList<ItemStack>) input).get(0), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderItemAtGridPos(gui, 2, 0, recipe.getRecipeOutput(), false);
|
||||
@@ -153,9 +183,11 @@ public class PageCraftingRecipes extends LexiconPage {
|
||||
|
||||
if(relativeMouseX >= xPos && relativeMouseY >= yPos && relativeMouseX <= xPos + 16 && relativeMouseY <= yPos + 16) {
|
||||
tooltipStack = stack;
|
||||
ItemStack containerStack = stack.getItem().getContainerItemStack(stack);
|
||||
if(containerStack != null && containerStack.getItem() != null)
|
||||
tooltipContainerStack = containerStack;
|
||||
if(accountForContainer) {
|
||||
ItemStack containerStack = stack.getItem().getContainerItemStack(stack);
|
||||
if(containerStack != null && containerStack.getItem() != null)
|
||||
tooltipContainerStack = containerStack;
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
@@ -16,5 +16,6 @@ public final class LibItemIDs {
|
||||
public static int idLexicon = 19555;
|
||||
public static int idPetal = 19556;
|
||||
public static int idDye = 19557;
|
||||
public static int idPestleAndMortar = 19558;
|
||||
|
||||
}
|
||||
@@ -18,5 +18,6 @@ public final class LibItemNames {
|
||||
public static final String LEXICON = LibResources.PREFIX_MOD + "lexicon";
|
||||
public static final String PETAL = LibResources.PREFIX_MOD + "petal";
|
||||
public static final String DYE = LibResources.PREFIX_MOD + "dye";
|
||||
public static final String PESTLE_AND_MORTAR = LibResources.PREFIX_MOD + "pestleAndMortar";
|
||||
|
||||
}
|
||||
@@ -26,4 +26,6 @@ public final class LibOreDict {
|
||||
public static final String[] DYE = new String[] {
|
||||
"dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", "dyeYellow", "dyeLime", "dyePink", "dyeGray", "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack",
|
||||
};
|
||||
|
||||
public static final String PESTLE_AND_MORTAR = "pestleAndMortar";
|
||||
}
|
||||
@@ -57,6 +57,8 @@ item.botania:dye12.name=Floral Brown Dye
|
||||
item.botania:dye13.name=Floral Green Dye
|
||||
item.botania:dye14.name=Floral Red Dye
|
||||
item.botania:dye15.name=Floral Black Dye
|
||||
item.botania:pestleAndMortar.name=Pestle and Mortar
|
||||
|
||||
# GUI TEXT
|
||||
botania.gui.lexicon.header=Lexica Botania Index - Pick which category you would like to study:
|
||||
|
||||
@@ -77,7 +79,8 @@ botania.page.world0=The world is fun.<br>This line of text is very long so I can
|
||||
botania.page.world1=This is a second page. There will be something here. Eventually.
|
||||
botania.page.world2=Flowers in the wild
|
||||
botania.page.world3=Plucking petals off flowers
|
||||
botania.page.world4=Grinding petals into dye
|
||||
botania.page.world4=Pestle and Mortar
|
||||
botania.page.world5=Grinding petals into dye
|
||||
|
||||
# -- BASIC CONCEPTS
|
||||
botania.entry.basicConcepts=Basic Concepts
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Reference in new issue
Block a user