Worked on recipes

This commit is contained in:
DarkGuardsman 2013-10-25 03:02:00 -04:00
parent d723e52bbb
commit 1d708b9a33
7 changed files with 350 additions and 15 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -3,7 +3,9 @@ package dark.core.common;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.registry.GameRegistry;
import dark.api.ColorCode;
import dark.api.ProcessorRecipes;
@ -13,9 +15,13 @@ import dark.core.common.blocks.BlockOre;
import dark.core.common.blocks.BlockOre.OreData;
import dark.core.common.items.EnumMaterial;
import dark.core.common.items.EnumOrePart;
import dark.core.common.items.EnumTool;
import dark.core.common.items.ItemOreDirv;
import dark.core.common.items.ItemParts;
import dark.core.common.items.ItemParts.Parts;
import dark.core.common.items.ItemWrench;
import dark.core.common.machines.BlockSolarPanel;
import dark.core.common.transmit.BlockWire;
public class CoreRecipeLoader extends RecipeLoader
{
@ -42,8 +48,22 @@ public class CoreRecipeLoader extends RecipeLoader
public void loadRecipes()
{
super.loadRecipes();
new RecipeGrid(new ItemStack(itemTool, 1, 0), 3, 2).setRowOne("ironTube", "valvePart", "ironTube").setRowTwo(null, "ironTube", null).RegisterRecipe();
new RecipeGrid(new ItemStack(blockSolar, 1, 0), 3, 3).setRowOne(Block.glass, Block.glass, Block.glass).setRowTwo(RecipeLoader.steel, RecipeLoader.circuit, RecipeLoader.steel).setRowThree(RecipeLoader.steel, "copperWire", RecipeLoader.steel).RegisterRecipe();
if (itemTool instanceof ItemTool)
{
new RecipeGrid(new ItemStack(itemTool, 1, 0), 3, 2).setRowOne("ironTube", "valvePart", "ironTube").setRowTwo(null, "ironTube", null).RegisterRecipe();
}
if (wrench instanceof ItemWrench)
{
new RecipeGrid(new ItemStack(wrench, 1, 0), 3, 3).setRowOne(steel, null, steel).setRowTwo(null, steel, null).setRowThree(null, steel, null).RegisterRecipe();
}
if (blockSolar instanceof BlockSolarPanel)
{
new RecipeGrid(new ItemStack(blockSolar, 1, 0), 3, 3).setRowOne(Block.glass, Block.glass, Block.glass).setRowTwo(RecipeLoader.steel, RecipeLoader.circuit, RecipeLoader.steel).setRowThree(RecipeLoader.steel, "copperWire", RecipeLoader.steel).RegisterRecipe();
}
if (blockWire instanceof BlockWire)
{
new RecipeGrid(new ItemStack(blockWire, 1, 0), 3, 1).setRowOne(Block.cloth, Block.cloth, Block.cloth).setRowTwo(copper, copper, copper).setRowThree(Block.cloth, Block.cloth, Block.cloth).RegisterRecipe();
}
this.loadParts();
}
@ -102,7 +122,23 @@ public class CoreRecipeLoader extends RecipeLoader
ItemStack rubble = EnumMaterial.getStack(mat, EnumOrePart.RUBBLE, 1);
ItemStack rod = EnumMaterial.getStack(mat, EnumOrePart.ROD, 1);
ItemStack tube = EnumMaterial.getStack(mat, EnumOrePart.TUBE, 1);
if (mat.shouldCreateItem(EnumOrePart.INGOTS))
{
OreDictionary.registerOre(mat.simpleName + "ingot", ingot);
OreDictionary.registerOre("ingot" + mat.simpleName, ingot);
}
if (mat.shouldCreateItem(EnumOrePart.RUBBLE))
{
OreDictionary.registerOre(mat.simpleName + "rubble", rubble);
OreDictionary.registerOre("rubble" + mat.simpleName, rubble);
}
if (mat.shouldCreateTool())
{
new RecipeGrid(mat.getTool(EnumTool.PICKAX)).setRowOne(ingot, ingot, ingot).setRowTwo(null, Item.stick, null).setRowThree(null, Item.stick, null).RegisterRecipe();
new RecipeGrid(mat.getTool(EnumTool.AX)).setRowOne(ingot, ingot, null).setRowTwo(ingot, Item.stick, null).setRowThree(null, Item.stick, null).RegisterRecipe();
new RecipeGrid(mat.getTool(EnumTool.HOE)).setRowOne(ingot, ingot, null).setRowTwo(null, Item.stick, null).setRowThree(null, Item.stick, null).RegisterRecipe();
new RecipeGrid(mat.getTool(EnumTool.SPADE)).setRowOne(null, ingot, null).setRowTwo(null, Item.stick, null).setRowThree(null, Item.stick, null).RegisterRecipe();
}
//Dust recipes
if (mat.shouldCreateItem(EnumOrePart.DUST))
{
@ -119,6 +155,8 @@ public class CoreRecipeLoader extends RecipeLoader
dust.stackSize = 1;
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, rod, dust);
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, tube, dust);
OreDictionary.registerOre(mat.simpleName + "dust", dust);
OreDictionary.registerOre("dust" + mat.simpleName, dust);
}
// Salvaging recipe
@ -135,6 +173,8 @@ public class CoreRecipeLoader extends RecipeLoader
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, ingot, scraps);
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, rod, scraps);
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, tube, scraps);
OreDictionary.registerOre(mat.simpleName + "scraps", scraps);
OreDictionary.registerOre("scraps" + mat.simpleName, scraps);
}
ingot.stackSize = 1;
@ -144,6 +184,8 @@ public class CoreRecipeLoader extends RecipeLoader
new RecipeGrid(tube, 3, 1).setRowOne(ingot, ingot, ingot).RegisterRecipe();
tube.stackSize = 1;
new RecipeGrid(tube, 1, 1).setRowOne(rod).RegisterRecipe();
OreDictionary.registerOre(mat.simpleName + "tube", tube);
OreDictionary.registerOre("tube" + mat.simpleName, tube);
}
if (mat.shouldCreateItem(EnumOrePart.ROD))
@ -151,14 +193,20 @@ public class CoreRecipeLoader extends RecipeLoader
rod.stackSize = 2;
new RecipeGrid(rod, 2, 1).setRowOne(ingot, ingot).RegisterRecipe();
rod.stackSize = 1;
OreDictionary.registerOre(mat.simpleName + "rod", rod);
OreDictionary.registerOre("rod" + mat.simpleName, rod);
}
if (mat.shouldCreateItem(EnumOrePart.PLATES))
{
new RecipeGrid(mat.getStack(EnumOrePart.PLATES, 1), 2, 2).setRowOne(ingot, ingot).setRowTwo(ingot, ingot).RegisterRecipe();
OreDictionary.registerOre(mat.simpleName + "plate", plates);
OreDictionary.registerOre("plate" + mat.simpleName, plates);
}
if (mat.shouldCreateItem(EnumOrePart.GEARS))
{
new RecipeGrid(mat.getStack(EnumOrePart.GEARS, 4), 3, 3).setRowOne(null, ingot, null).setRowTwo(ingot, (mat.shouldCreateItem(EnumOrePart.ROD) ? rod : Item.stick), ingot).setRowThree(null, ingot, null).RegisterRecipe();
OreDictionary.registerOre(mat.simpleName + "gear", mat.getStack(EnumOrePart.GEARS, 1));
OreDictionary.registerOre("gear" + mat.simpleName, mat.getStack(EnumOrePart.GEARS, 1));
}
}

View file

@ -12,7 +12,7 @@ import com.builtbroken.common.Triple;
import cpw.mods.fml.common.registry.GameRegistry;
/** Recipe system to make it easier to load recipes for a mod
*
*
* @author DarkGuardsman */
public abstract class RecipeLoader
{
@ -24,6 +24,8 @@ public abstract class RecipeLoader
protected static Object motor;
protected static Object bronze;
protected static Object bronzePlate;
protected static Object copper;
protected static Object copperPlate;
static boolean loaded = false;
@ -38,6 +40,8 @@ public abstract class RecipeLoader
circuit2 = Item.comparator;
steel = Item.ingotIron;
steelPlate = Item.ingotGold;
copper = Item.ingotIron;
copperPlate = Item.ingotGold;
motor = Block.pistonBase;
bronze = Item.ingotIron;
bronzePlate = Item.ingotGold;
@ -70,6 +74,14 @@ public abstract class RecipeLoader
{
bronzePlate = "plateBronze";
}
if (OreDictionary.getOres("copperBronze").size() > 0)
{
bronze = "copperBronze";
}
if (OreDictionary.getOres("copperBronze").size() > 0)
{
bronzePlate = "copperBronze";
}
}
}
@ -85,7 +97,7 @@ public abstract class RecipeLoader
}
/** An easier to read recipe system for the basic minecraft recipes
*
*
* @author DarkGaurdsman */
public static class RecipeGrid
{
@ -111,7 +123,7 @@ public abstract class RecipeLoader
/** 3x3 Crafting grid. Each Triple is a row. Input for the triples should be any of { Item,
* Block, ItemStack, String}
*
*
* @param one - top row
* @param two - middle row
* @param three - bottom row */
@ -125,7 +137,7 @@ public abstract class RecipeLoader
/** 2x2 Crafting grid. Each Pair is a row. Input for the pairs should be any of { Item,
* Block, ItemStack, String}
*
*
* @param one - top row
* @param two - middle row */
public RecipeGrid(Object stack, Pair one, Pair two)

View file

@ -13,8 +13,8 @@ import dark.core.common.CoreRecipeLoader;
import dark.core.common.DarkMain;
/** Class for storing materials, there icon names, sub items to be made from them or there sub ores
*
*
*
*
* @author DarkGuardsman */
public enum EnumMaterial
{
@ -25,13 +25,13 @@ public enum EnumMaterial
GOLD("Gold", EnumToolMaterial.GOLD, EnumOrePart.GEARS, EnumOrePart.INGOTS),
COAL("Coal", EnumToolMaterial.WOOD, EnumOrePart.GEARS, EnumOrePart.TUBE, EnumOrePart.PLATES, EnumOrePart.RUBBLE, EnumOrePart.SCRAPS),
COPPER("Copper", true, 2.5f, 79),
COPPER("Copper", true, 3.5f, 79),
TIN("Tin", true, 2.0f, 50, EnumOrePart.GEARS, EnumOrePart.TUBE),
LEAD("Lead", false, 0, 0, EnumOrePart.GEARS, EnumOrePart.TUBE),
ALUMINIUM("Aluminum", true, 4.0f, 100, EnumOrePart.GEARS, EnumOrePart.TUBE),
ALUMINIUM("Aluminum", true, 5.0f, 100, EnumOrePart.GEARS, EnumOrePart.TUBE),
SILVER("Silver", true, 11.0f, 30, EnumOrePart.GEARS),
STEEL("Steel", true, 7.0f, 2000, EnumOrePart.RUBBLE),
BRONZE("Bronze", true, 6.0f, 260, EnumOrePart.RUBBLE);
STEEL("Steel", true, 7.0f, 1000, EnumOrePart.RUBBLE),
BRONZE("Bronze", true, 6.5f, 560, EnumOrePart.RUBBLE);
/** Name of the material */
public String simpleName;
@ -74,7 +74,7 @@ public enum EnumMaterial
/** Creates a new item stack using material and part given. Uses a preset length of 50 for parts
* enum so to prevent any unwanted changes in loading of itemStacks metadata.
*
*
* @param mat - material
* @param part - part
* @return new ItemStack created from the two enums as long as everything goes right */

View file

@ -1,7 +1,10 @@
package dark.core.common.items;
import java.awt.Color;
import java.util.List;
import universalelectricity.core.electricity.ElectricityDisplay;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
@ -34,7 +37,7 @@ import dark.core.prefab.ModPrefab;
/** Flexible tool class that uses NBT to store damage and effect rather than metadata. Metadata
* instead is used to store sub items allowing several different tools to exist within the same item
*
*
* @author DarkGuardsman */
public class ItemCommonTool extends Item implements IExtraItemInfo
{
@ -51,6 +54,43 @@ public class ItemCommonTool extends Item implements IExtraItemInfo
this.setCreativeTab(CreativeTabs.tabTools);
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
if (itemStack != null)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
if (itemStack.getTagCompound().getBoolean("broken"))
{
par3List.add("Broken");
}
else
{
EnumMaterial mat = EnumMaterial.getToolMatFromMeta(itemStack.getItemDamage());
int currentDamage = itemStack.getTagCompound().getInteger("toolDamage");
par3List.add((ElectricityDisplay.roundDecimals((currentDamage / mat.maxUses)) + "%"));
}
}
}
@SideOnly(Side.CLIENT)
@Override
public int getColorFromItemStack(ItemStack itemStack, int par2)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
if (itemStack.getTagCompound().getBoolean("broken"))
{
return Color.RED.getRGB();
}
return super.getColorFromItemStack(itemStack, par2);
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{

View file

@ -0,0 +1,168 @@
package dark.core.prefab.invgui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import universalelectricity.core.vector.Vector2;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public abstract class GuiBase extends GuiScreen
{
protected Vector2 guiTopLeftCorner;
protected Vector2 guiSize = new Vector2(176, 166);
/** Adds the buttons (and other controls) to the screen in question. */
@Override
public void initGui()
{
super.initGui();
guiTopLeftCorner = new Vector2((this.width - this.guiSize.intX()) / 2, (this.height - this.guiSize.intY()) / 2);
}
/** Draws the screen and all the components in it. */
@Override
public void drawScreen(int par1, int par2, float par3)
{
this.drawDefaultBackground();
int var4 = (int) this.guiTopLeftCorner.x;
int var5 = (int) this.guiTopLeftCorner.y;
this.drawBackgroundLayer(par1, par2, par3);
GL11.glPushMatrix();
GL11.glTranslatef(var4, var5, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
short var7 = 240;
short var8 = 240;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var7 / 1.0F, var8 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawForegroundLayer(par1, par2, par3);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glPopMatrix();
super.drawScreen(par1, par2, par3);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
/** Draws the foreground layer for the GUI */
protected abstract void drawForegroundLayer(int var2, int var3, float var1);
/** Draws the background layer for the GUI */
protected abstract void drawBackgroundLayer(int var2, int var3, float var1);
/** Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). */
@Override
protected void keyTyped(char x, int y)
{
if (y == 1 || y == this.mc.gameSettings.keyBindInventory.keyCode)
{
this.mc.thePlayer.closeScreen();
}
}
/** Returns true if this GUI should pause the game when it is displayed in single-player */
@Override
public boolean doesGuiPauseGame()
{
return false;
}
/** Called from the main game loop to update the screen. */
@Override
public void updateScreen()
{
super.updateScreen();
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead)
{
this.mc.thePlayer.closeScreen();
}
}
public void drawTooltip(int x, int y, String... toolTips)
{
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
if (toolTips != null)
{
int var5 = 0;
int var6;
int var7;
for (var6 = 0; var6 < toolTips.length; ++var6)
{
var7 = this.fontRenderer.getStringWidth(toolTips[var6]);
if (var7 > var5)
{
var5 = var7;
}
}
var6 = x + 12;
var7 = y - 12;
int var9 = 8;
if (toolTips.length > 1)
{
var9 += 2 + (toolTips.length - 1) * 10;
}
if (this.guiTopLeftCorner.intY() + var7 + var9 + 6 > this.height)
{
var7 = this.height - var9 - this.guiTopLeftCorner.intY() - 6;
}
this.zLevel = 300.0F;
int var10 = -267386864;
this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10);
this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10);
this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10);
this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10);
int var11 = 1347420415;
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12);
this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11);
this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
for (int var13 = 0; var13 < toolTips.length; ++var13)
{
String var14 = toolTips[var13];
this.fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
if (var13 == 0)
{
var7 += 2;
}
var7 += 10;
}
this.zLevel = 0.0F;
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_LIGHTING);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
}
}

View file

@ -0,0 +1,67 @@
package dark.core.prefab.invgui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.DarkMain;
@SideOnly(Side.CLIENT)
public class GuiButtonImage extends GuiButton
{
public static final ResourceLocation TEXTURE = new ResourceLocation(DarkMain.getInstance().DOMAIN, DarkMain.GUI_DIRECTORY + "gui_button.png");
private int type = 0;
public GuiButtonImage(int par1, int par2, int par3, int type)
{
super(par1, par2, par3, 20, 20, "");
this.type = type;
}
/** Draws this button to the screen. */
@Override
public void drawButton(Minecraft par1Minecraft, int width, int hight)
{
if (this.drawButton)
{
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
int var5 = 106;
int var6 = 0;
if (var4)
{
var5 += this.height;
}
switch (type)
{
case 0:
var5 += 40;
break;
case 1:
var5 += 40;
var6 += 20;
break;
case 2:
var5 += 40;
var6 += 40;
break;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, var6, var5, this.width, this.height);
}
}
/** Checks to see if the x and y coords are intersecting with the button. */
public boolean isIntersect(int x, int y)
{
return x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;
}
}