From d10c57046695397b2960d4c8cad333aa7108a226 Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Fri, 25 Jul 2014 08:40:47 +0200 Subject: [PATCH] start work on science book --- .../assets/buildcraft/lang/en_US.lang | 1 + .../textures/gui/science_focus_gui.png | Bin 0 -> 1482 bytes .../buildcraft/textures/gui/science_gui.png | Bin 0 -> 1570 bytes .../buildcraft/textures/gui/science_icons.png | Bin 0 -> 1443 bytes .../textures/items/science_book.png | Bin 0 -> 643 bytes common/buildcraft/BuildCraftCore.java | 40 ++- common/buildcraft/BuildCraftEnergy.java | 25 +- common/buildcraft/BuildCraftFactory.java | 15 +- common/buildcraft/BuildCraftTransport.java | 9 + common/buildcraft/core/GuiHandler.java | 38 +++ common/buildcraft/core/GuiIds.java | 2 + common/buildcraft/core/ItemScienceBook.java | 43 ++++ common/buildcraft/core/gui/AdvancedSlot.java | 13 +- .../core/gui/ContainerScienceBook.java | 39 +++ .../core/gui/GuiAdvancedInterface.java | 51 +++- common/buildcraft/core/gui/GuiBuildCraft.java | 2 +- .../buildcraft/core/gui/GuiScienceBook.java | 239 ++++++++++++++++++ common/buildcraft/core/gui/ItemSlot.java | 6 + common/buildcraft/core/proxy/CoreProxy.java | 13 + .../core/recipes/BuildCraftRecipe.java | 64 +++++ .../core/science/TechnoSimpleItem.java | 67 +++++ .../buildcraft/core/science/TechnoTier.java | 57 +++++ .../buildcraft/core/science/Technology.java | 99 ++++++++ common/buildcraft/core/science/Tier.java | 58 +++++ 24 files changed, 857 insertions(+), 24 deletions(-) create mode 100755 buildcraft_resources/assets/buildcraft/textures/gui/science_focus_gui.png create mode 100755 buildcraft_resources/assets/buildcraft/textures/gui/science_gui.png create mode 100755 buildcraft_resources/assets/buildcraft/textures/gui/science_icons.png create mode 100755 buildcraft_resources/assets/buildcraft/textures/items/science_book.png create mode 100755 common/buildcraft/core/GuiHandler.java create mode 100755 common/buildcraft/core/ItemScienceBook.java create mode 100755 common/buildcraft/core/gui/ContainerScienceBook.java create mode 100755 common/buildcraft/core/gui/GuiScienceBook.java create mode 100755 common/buildcraft/core/recipes/BuildCraftRecipe.java create mode 100755 common/buildcraft/core/science/TechnoSimpleItem.java create mode 100755 common/buildcraft/core/science/TechnoTier.java create mode 100755 common/buildcraft/core/science/Technology.java create mode 100755 common/buildcraft/core/science/Tier.java diff --git a/buildcraft_resources/assets/buildcraft/lang/en_US.lang b/buildcraft_resources/assets/buildcraft/lang/en_US.lang index 7747e5df..c722df4b 100755 --- a/buildcraft_resources/assets/buildcraft/lang/en_US.lang +++ b/buildcraft_resources/assets/buildcraft/lang/en_US.lang @@ -140,6 +140,7 @@ gui.pipes.emzuli.title=Extraction Presets gui.pipes.emzuli.paint=Paint Items %s gui.pipes.emzuli.nopaint=Don't Paint Items +item.scienceBook.name=Engineering Science Book item.bucketFuel.name=Fuel Bucket item.bucketOil.name=Oil Bucket item.woodenGearItem.name=Wood Gear diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/science_focus_gui.png b/buildcraft_resources/assets/buildcraft/textures/gui/science_focus_gui.png new file mode 100755 index 0000000000000000000000000000000000000000..2d935ed33a3146409bc5f566963982225a768bac GIT binary patch literal 1482 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&6|H(?D8gCb z5n0T@z;_UY8Fx&~ehU<2FY)wsWxvNR!KWa#P_)IDfq^yL)5S5Q;?~={xp|AjL>e9z zE3enO#}?P2x{1sElT(89!638J-^=G&y;~wHSo5Id^(|iJPl`Fu;jarkHt)G^{I5v9;q=p_eub%@f6537#$J!* z?=w05yXd#R%%2ITyF(e67&sUd7#bLeWZ0ZMr`1p?(|`Qp<&0Ts-+u39I3Q)}Yy9ee z{_V1B?@M>EFnkAv4hw?-g98R5LACBr?g7(1MkoK=UjM%Ox8pH}81p+4#rxp`*BB0j z9lo(`ErWyG@4s~)(^c}AoRXN3-Ig=;Im3fN++0`Ys0d(+7;1}B8Jfo*)S>*28(*(x)1_?vSwZ6yUy*dj+;1IJ^=1N(K} zK3rxg53~Rn6wmLV2L&koOlT5pO#4@yTYE%CnQ3iwXGc_aZ->DQCe69$pLcY;*rnH& z=&^N=9^(NN({Uyfc;FCbupH1rH|EBK&p+o>RhA0|dTEwQw3TQxZ(@I_sPuIyCG%Tm)i{vZt?qg zEx!96xILTiS$duKy!dVT%)2-_IysS(_y*DawIUKf-ZLMSWY{2iy?xCb#shPG-XFDK zZdk&;pTVIBCAXoJ4f{X8`M&Dx`9ITa_AmW8F`wD4xNiC7%*&_K>w4^%S8P4^PwL6r z?I-5h?!Wx<%axz5EkD=R)UCV{RbN||skdD|uIAXE2KzlMJO0it;+sEz{{4CL&RgzZ z_xfLk-1h&rOLnv1$SMiBX8%hcY~OAkEjfpg!Jq#?c|H>p_f8g#rAJT62tgywWQ5=(3L=Mtd;rx=%f0eO<(_b0e-8bxRZ5sd44YCn7x%G}@jdN0Yq-^1!_fr?(2)O73Fu=}- z`hn!oM7kdrO*Hc1z`LRcgm`n7ys^>kb$yqm8XFf9#Nv%&Pv!0iBg1FQl6dw-zeAv% zu>^Fp>h2FSQ{uh@X*5=Qa=J0-)loJ87J#A`DJ4z*ACbRvDi1?ZV zu#=4w5+Lr9@|Nm{FH}ti^FOfwp%51E`SwK*0*S>O7w04~(Rtu?Bu=bYeM=zFq4~2f zWtH>!krtbyzfP7FXpv{jWP)%ON)9(KTc5=uI!b?340>0t9pq6SwLBoh%?5y}D^*>T zT2;kfx&bW(Z*=ND4)&UbFI>GOChZvhNrrw^S4heJUQlHyUYp<$>1YKeREN(FY_|?z zz+B>2{4Id;Btu;-VOJB;j7>Yh)J@@x=m>Ibsp<@C%#IBAxq(5?JtkzunRQtU6^6l! zaZ5nwCl-YRr6i`lNk+e|M@46=&tB@fx{6N(mi1fLc$ygpKo*eH)9&uJa4FVci+0x$%DBdutIBrP6RjnsV+aS$yE`s+ulGlG0 z1%4#C{0o%2tNN{aA}y7|s;KBlRGVx&z&1QO-L!isXFYc9RI7CTVFrFc1~_V*I*Vydnr~u%L&L{ zu=iqbE#Qz;C(e#ZQd3h4?klZ8+Ix_%4W{h*wj78~$&)vPM98L0l+T{tyUAR-j$^1? dZOBBa&jEkG7cPv`s~Z410%;-C%bWHb{13GeNdEu; literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/science_icons.png b/buildcraft_resources/assets/buildcraft/textures/gui/science_icons.png new file mode 100755 index 0000000000000000000000000000000000000000..6a994b427894a97060cad4c2a107e5ff7e52f0ac GIT binary patch literal 1443 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&6|H(?D8gCb z5n0T@z;_UY8Fx&~ehU<2FY)wsWxvNR!NVgr=j{I}3=FIWo-U3d6}R5r_03ZXmuS2A zK3j3q#5D(*t7T1n)*rHc>$pr|BRhZM6jufz>n#5~{vU$dI%8G#U2lCQb8>Ru)bP-b z z&->nUxM^Wlo4fsX-2Lsh-}>dh*>~UGQakT#xT(I#y?J}%s@v^XYzxGZpM9J8kG+5HCA?2R`6>O_4UY74|OZs zefK5XeEGM}KJT=xj^Fn@9G|ywgh-wx!}0&etF?g{cWA} zoNafdqZy1oe_2!(8=m{($Bm`as$;J&eZBkb>*%BQfl5a8e^%@hPo1@x+rj0?&+e$~ z6|Z+)KD#yj{j9wmH{27puG$u^R8;c*-{JKP6K78Refs>YskSnTv){_rW$oN2y>DN~ z%Wm_P&cC0ZdfY6&+429m`QP)-$F09{L_YA-&Wp1XrBv&B--kC`*U#hr_Qr4l!-0bS zmBHos@-W_jBXpU0nX?$)E& zpNM{28vFcL-k)Emg6HhZdN;SsOY&-XTty(GJQEYi$pvTHqMk{R1l+)|gB7P`B&Kn= fIV9<;X}xc_xMBBu<9J_SamwK7>gTe~DWM4fbC(AX-H8B0)iK2ye7F?YXJaK z(?>8psc>I`^cfcu5ycGj;8}fu+{gK(7s*M5rR@`T01z`Vg~$Cigaa;fs81$=rG=m= z5)H|y)>?>$WE87S6iSAWBmm=M&HwZL__ib8353gkcc@cIqU+Lmp8E2Y!5_U zS_q>5s`t0+f1N7^iWLK^xlNp%&p`VAlZZ^laP7tu>^0k_lQl_U)`PW92k&(QSFhj3 zYHky{uJm?~*xINyy3p$_F|>)ZQwqaJ6|6sciF`f}0C=2RLE+t306^@R z1G^tu;=ijrpB$yc5p=q}{%);>kDq>lq&V oilBiomeIDs = new HashSet(); @@ -341,6 +347,7 @@ public class BuildCraftEnergy extends BuildCraftMod { if (BuildCraftCore.loadDefaultRecipes) { loadRecipes(); } + EnergyProxy.proxy.registerBlockRenderers(); EnergyProxy.proxy.registerTileEntities(); } @@ -364,12 +371,24 @@ public class BuildCraftEnergy extends BuildCraftMod { } public static void loadRecipes() { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 0), + technoRedstoneEngine = new TechnoSimpleItem(Tier.WoodenGear, new ItemStack(engineBlock, 1, 0), + new ItemStack(BuildCraftCore.woodenGearItem, 5)); + + technoStoneEngine = new TechnoSimpleItem(Tier.StoneGear, new ItemStack(engineBlock, 1, 1), + new ItemStack(BuildCraftCore.stoneGearItem, 10), technoRedstoneEngine); + + technoIronEngine = new TechnoSimpleItem(Tier.IronGear, new ItemStack(engineBlock, 1, 2), + new ItemStack(BuildCraftCore.ironGearItem, 20), technoStoneEngine); + + CoreProxy.proxy.addCraftingRecipe(technoRedstoneEngine, + new ItemStack(engineBlock, 1, 0), "www", " g ", "GpG", 'w', "plankWood", 'g', Blocks.glass, 'G', BuildCraftCore.woodenGearItem, 'p', Blocks.piston); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), "www", " g ", "GpG", 'w', "cobblestone", + CoreProxy.proxy.addCraftingRecipe(technoStoneEngine, + new ItemStack(engineBlock, 1, 1), "www", " g ", "GpG", 'w', "cobblestone", 'g', Blocks.glass, 'G', BuildCraftCore.stoneGearItem, 'p', Blocks.piston); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), "www", " g ", "GpG", 'w', Items.iron_ingot, + CoreProxy.proxy.addCraftingRecipe(technoIronEngine, + new ItemStack(engineBlock, 1, 2), "www", " g ", "GpG", 'w', Items.iron_ingot, 'g', Blocks.glass, 'G', BuildCraftCore.ironGearItem, 'p', Blocks.piston); if (blockEnergyConverter != null) { diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index cdddae55..5f9d4103 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -43,6 +43,9 @@ import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.science.TechnoSimpleItem; +import buildcraft.core.science.Technology; +import buildcraft.core.science.Tier; import buildcraft.core.utils.ConfigUtils; import buildcraft.factory.BlockAutoWorkbench; import buildcraft.factory.BlockFloodGate; @@ -85,6 +88,9 @@ public class BuildCraftFactory extends BuildCraftMod { public static BlockTank tankBlock; public static BlockRefinery refineryBlock; public static BlockHopper hopperBlock; + + public static Technology technoAutoWorkbench; + public static boolean allowMining = true; public static boolean quarryOneTimeUse = false; public static float miningMultiplier = 1; @@ -223,6 +229,13 @@ public class BuildCraftFactory extends BuildCraftMod { } public static void loadRecipes() { + technoAutoWorkbench = new TechnoSimpleItem + (Tier.WoodenGear, + autoWorkbenchBlock, + new ItemStack(BuildCraftCore.woodenGearItem, 10), + BuildCraftEnergy.technoRedstoneEngine, + BuildCraftTransport.technoWoodenPipe); + if (allowMining) { if (miningWellBlock != null) { @@ -273,7 +286,7 @@ public class BuildCraftFactory extends BuildCraftMod { } if (autoWorkbenchBlock != null) { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(autoWorkbenchBlock), + CoreProxy.proxy.addCraftingRecipe(technoAutoWorkbench, new ItemStack(autoWorkbenchBlock), " g ", "gwg", " g ", diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 05fbdf78..240fc29f 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -51,6 +51,9 @@ import buildcraft.core.ItemBuildCraft; import buildcraft.core.Version; import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.science.TechnoSimpleItem; +import buildcraft.core.science.Technology; +import buildcraft.core.science.Tier; import buildcraft.core.triggers.ActionPipeClose; import buildcraft.transport.BlockFilteredBuffer; import buildcraft.transport.BlockGenericPipe; @@ -188,6 +191,8 @@ public class BuildCraftTransport extends BuildCraftMod { public static IAction actionExtractionPresetGreen = new ActionExtractionPreset(EnumColor.GREEN); public static IAction actionExtractionPresetYellow = new ActionExtractionPreset(EnumColor.YELLOW); + public static Technology technoWoodenPipe; + @Mod.Instance("BuildCraft|Transport") public static BuildCraftTransport instance; @@ -461,6 +466,10 @@ public class BuildCraftTransport extends BuildCraftMod { } public void loadRecipes() { + technoWoodenPipe = new TechnoSimpleItem + (Tier.WoodenGear, + pipeItemsWood, + new ItemStack(BuildCraftCore.woodenGearItem, 5)); // Add base recipe for pipe waterproof. GameRegistry.addShapelessRecipe(new ItemStack(pipeWaterproof, 1), new ItemStack(Items.dye, 1, 2)); diff --git a/common/buildcraft/core/GuiHandler.java b/common/buildcraft/core/GuiHandler.java new file mode 100755 index 00000000..ec823d6d --- /dev/null +++ b/common/buildcraft/core/GuiHandler.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +import cpw.mods.fml.common.network.IGuiHandler; + +import buildcraft.core.gui.ContainerScienceBook; +import buildcraft.core.gui.GuiScienceBook; + +public class GuiHandler implements IGuiHandler { + + @Override + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { + if (id == GuiIds.SCIENCE_BOOK) { + return new GuiScienceBook(player); + } + + return null; + } + + @Override + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { + if (id == GuiIds.SCIENCE_BOOK) { + return new ContainerScienceBook(player); + } + + return null; + } +} diff --git a/common/buildcraft/core/GuiIds.java b/common/buildcraft/core/GuiIds.java index 8e5d40c6..f8ec7a1a 100644 --- a/common/buildcraft/core/GuiIds.java +++ b/common/buildcraft/core/GuiIds.java @@ -35,6 +35,8 @@ public final class GuiIds { public static final int REDSTONE_BOARD = 70; + public static final int SCIENCE_BOOK = 70; + /** * Deactivate constructor */ diff --git a/common/buildcraft/core/ItemScienceBook.java b/common/buildcraft/core/ItemScienceBook.java new file mode 100755 index 00000000..9ac2a408 --- /dev/null +++ b/common/buildcraft/core/ItemScienceBook.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import buildcraft.BuildCraftCore; + +public class ItemScienceBook extends ItemBuildCraft { + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + itemIcon = par1IconRegister.registerIcon("buildcraft:science_book"); + } + + @Override + public int getItemStackLimit(ItemStack stack) { + return 1; + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World world, EntityPlayer entityPlayer) { + if (!world.isRemote) { + entityPlayer.openGui(BuildCraftCore.instance, GuiIds.SCIENCE_BOOK, world, 0, 0, 0); + } + + return par1ItemStack; + } + +} diff --git a/common/buildcraft/core/gui/AdvancedSlot.java b/common/buildcraft/core/gui/AdvancedSlot.java index 577c8b77..68f3386c 100755 --- a/common/buildcraft/core/gui/AdvancedSlot.java +++ b/common/buildcraft/core/gui/AdvancedSlot.java @@ -94,17 +94,10 @@ public abstract class AdvancedSlot { } public void drawStack(ItemStack item) { - Minecraft mc = Minecraft.getMinecraft(); + int cornerX = (gui.width - gui.getXSize()) / 2; + int cornerY = (gui.height - gui.getYSize()) / 2; - if (item != null) { - int cornerX = (gui.width - gui.getXSize()) / 2; - int cornerY = (gui.height - gui.getYSize()) / 2; - - GuiAdvancedInterface.getItemRenderer().zLevel = 200F; - GuiAdvancedInterface.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer (), mc.renderEngine, item, cornerX + x, cornerY + y); - GuiAdvancedInterface.getItemRenderer().renderItemOverlayIntoGUI(gui.getFontRenderer (), mc.renderEngine, item, cornerX + x, cornerY + y); - GuiAdvancedInterface.getItemRenderer().zLevel = 0.0F; - } + gui.drawStack(item, cornerX + x, cornerY + y); } public void selected () { diff --git a/common/buildcraft/core/gui/ContainerScienceBook.java b/common/buildcraft/core/gui/ContainerScienceBook.java new file mode 100755 index 00000000..2c8bbb98 --- /dev/null +++ b/common/buildcraft/core/gui/ContainerScienceBook.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.gui; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; + +public class ContainerScienceBook extends BuildCraftContainer { + + private EntityPlayer player; + + public ContainerScienceBook(EntityPlayer iPlayer) { + super(iPlayer.inventory.getSizeInventory()); + + player = iPlayer; + + for (int sy = 0; sy < 3; sy++) { + for (int sx = 0; sx < 9; sx++) { + addSlotToContainer(new Slot(player.inventory, sx + sy * 9 + 9, 19 + sx * 18, 101 + sy * 18)); + } + } + + for (int sx = 0; sx < 9; sx++) { + addSlotToContainer(new Slot(player.inventory, sx, 19 + sx * 18, 159)); + } + + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } +} diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java index d5aa387b..3226870c 100644 --- a/common/buildcraft/core/gui/GuiAdvancedInterface.java +++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java @@ -10,6 +10,7 @@ package buildcraft.core.gui; import org.lwjgl.opengl.GL11; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; @@ -28,7 +29,8 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { public int getSlotAtLocation(int i, int j) { for (int position = 0; position < slots.length; ++position) { AdvancedSlot s = slots[position]; - if (i >= s.x && i <= s.x + 16 && j >= s.y && j <= s.y + 16) { + + if (s != null && i >= s.x && i <= s.x + 16 && j >= s.y && j <= s.y + 16) { return position; } } @@ -48,9 +50,11 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, i1 / 1.0F, k1 / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - for (AdvancedSlot slot : slots) { - if (slot != null) { - slot.drawSprite(cornerX, cornerY); + if (slots != null) { + for (AdvancedSlot slot : slots) { + if (slot != null) { + slot.drawSprite(cornerX, cornerY); + } } } @@ -100,4 +104,43 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { public void renderToolTip(ItemStack stack, int x, int y) { super.renderToolTip(stack, x, y); } + + public void drawStack(ItemStack item, int x, int y) { + Minecraft mc = Minecraft.getMinecraft(); + + if (item != null) { + GL11.glEnable(GL11.GL_LIGHTING); + float prevZ = GuiAdvancedInterface.getItemRenderer().zLevel; + GuiAdvancedInterface.getItemRenderer().zLevel = 200F; + GuiAdvancedInterface.getItemRenderer().renderItemAndEffectIntoGUI(getFontRenderer(), mc.renderEngine, item, x, y); + GuiAdvancedInterface.getItemRenderer().renderItemOverlayIntoGUI(getFontRenderer(), mc.renderEngine, item, x, y); + GuiAdvancedInterface.getItemRenderer().zLevel = prevZ; + GL11.glDisable(GL11.GL_LIGHTING); + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + super.mouseClicked(mouseX, mouseY, mouseButton); + + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + + int position = getSlotAtLocation(mouseX - cornerX, mouseY - cornerY); + + AdvancedSlot slot = null; + + if (position < 0) { + return; + } + + if (slots[position].isDefined()) { + slotClicked(slots[position]); + } + } + + // TODO: Use this for all children of this class + protected void slotClicked(AdvancedSlot slot) { + + } } diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java index 776fafe7..875e4a27 100644 --- a/common/buildcraft/core/gui/GuiBuildCraft.java +++ b/common/buildcraft/core/gui/GuiBuildCraft.java @@ -42,8 +42,8 @@ public abstract class GuiBuildCraft extends GuiContainer { public static final ResourceLocation LEDGER_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/ledger.png"); public final LedgerManager ledgerManager = new LedgerManager(this); public final TileEntity tile; - public final ResourceLocation texture; public final BuildCraftContainer container; + public ResourceLocation texture; public GuiBuildCraft(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) { super(container); diff --git a/common/buildcraft/core/gui/GuiScienceBook.java b/common/buildcraft/core/gui/GuiScienceBook.java new file mode 100755 index 00000000..80358249 --- /dev/null +++ b/common/buildcraft/core/gui/GuiScienceBook.java @@ -0,0 +1,239 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.gui; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import buildcraft.core.DefaultProps; +import buildcraft.core.science.Technology; +import buildcraft.core.science.Tier; + +public class GuiScienceBook extends GuiAdvancedInterface { + + private static final ResourceLocation TEXTURE_BASE = new ResourceLocation( + "buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/science_gui.png"); + private static final ResourceLocation TEXTURE_FOCUS = new ResourceLocation( + "buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/science_focus_gui.png"); + private static final ResourceLocation TEXTURE_ICONS = new ResourceLocation( + "buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/science_icons.png"); + + private Tier currentTier = null; + + private Technology inFocus = null; + + private List baseInventorySlots; + + static class EmptySlot extends AdvancedSlot { + public EmptySlot(GuiAdvancedInterface gui, int x, int y) { + super(gui, x, y); + } + } + + static class TechnologySlot extends AdvancedSlot { + private Technology techno; + + public TechnologySlot(GuiAdvancedInterface gui, int x, int y, Technology iTechno) { + super(gui, x, y); + + techno = iTechno; + } + + @Override + public IIcon getIcon() { + return techno.getIcon(); + } + + @Override + public ItemStack getItemStack() { + return techno.getStackToDisplay(); + } + } + + public GuiScienceBook(EntityPlayer player) { + super(new ContainerScienceBook(player), player.inventory, TEXTURE_BASE); + + xSize = 256; + ySize = 181; + + slots = new AdvancedSlot[50]; + + baseInventorySlots = container.inventorySlots; + + setTier(Tier.WoodenGear); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + + bindTexture(TEXTURE_ICONS); + + for (int i = 0; i < 7; ++i) { + if (inFocus != null || currentTier.ordinal() != i) { + drawTexturedModalRect(cornerX + 28 * i, cornerY - 28, 28 * i, 1, 29, 32); + } + + if (inFocus != null || currentTier.ordinal() != i + 7) { + drawTexturedModalRect(cornerX + 28 * i, cornerY + ySize - 4, 28 * i, 62, 29, 32); + } + } + + if (inFocus == null) { + texture = TEXTURE_BASE; + } else { + texture = TEXTURE_FOCUS; + } + + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + + bindTexture(TEXTURE_ICONS); + + for (int i = 0; i < 7; ++i) { + if (inFocus == null && currentTier.ordinal() == i) { + drawTexturedModalRect(cornerX + 28 * i, cornerY - 28, 28 * i, 32, 29, 32); + } + + if (inFocus == null && currentTier.ordinal() == i + 7) { + drawTexturedModalRect(cornerX + 28 * i, cornerY + ySize - 4, 28 * i, 96, 29, 32); + } + } + + for (int i = 0; i < 7; ++i) { + drawStack(Tier.values()[i].getStackToDisplay(), cornerX + 28 * i + 6, cornerY - 28 + 9); + + drawStack(Tier.values()[i + 7].getStackToDisplay(), cornerX + 28 * i + 6, cornerY + ySize - 4 + 7); + } + + drawBackgroundSlots(); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + super.drawGuiContainerForegroundLayer(par1, par2); + + drawTooltipForSlotAt(par1, par2); + } + + + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + super.mouseClicked(mouseX, mouseY, mouseButton); + + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + + for (int i = 0; i < 7; ++i) { + int x1 = cornerX + 28 * i; + int x2 = x1 + 29; + int y1 = cornerY - 30; + int y2 = y1 + 32; + + if (mouseX >= x1 && mouseX <= x2 && mouseY >= y1 && mouseY <= y2) { + setTier(Tier.values()[i]); + return; + } + + y1 = cornerY + ySize - 2; + y2 = y1 + 32; + + if (mouseX >= x1 && mouseX <= x2 && mouseY >= y1 && mouseY <= y2) { + setTier(Tier.values()[i + 7]); + return; + } + } + } + + @Override + protected void slotClicked(AdvancedSlot slot) { + super.slotClicked(slot); + + if (slot instanceof TechnologySlot) { + setFocus(((TechnologySlot) slot).techno); + } + } + + private void setTier(Tier newTier) { + if (inFocus != null || newTier != currentTier) { + slots = new AdvancedSlot[50]; + currentTier = newTier; + + int id = 0; + + Collection technos = Technology.getTechnologies(currentTier); + + for (Technology t : technos) { + int j = id / 10; + int i = id - j * 10; + + slots[id] = new TechnologySlot(this, 9 + i * 18, 7 + j * 18, t); + id++; + } + + while (id < 50) { + int j = id / 10; + int i = id - j * 10; + + slots[id] = new EmptySlot(this, 9 + i * 18, 7 + j * 18); + id++; + } + } + + inFocus = null; + container.inventorySlots = baseInventorySlots; + } + + private void setFocus(Technology techno) { + inFocus = techno; + container.inventorySlots = new ArrayList(); + slots = new AdvancedSlot[5 + 3 + 1 + 10]; + + int id = 0; + + for (int i = 0; i < 5; ++i) { + if (techno.getPrerequisites().size() > i + && techno.getPrerequisites().get(i) != null) { + slots[id++] = new TechnologySlot(this, 33, 43 + 18 * i, techno.getPrerequisites().get(i)); + } else { + id++; + } + } + + for (int i = 0; i < 3; ++i) { + if (techno.getRequirements() != null) { + slots[id++] = new ItemSlot(this, 71, 115 + 18 * i, techno.getRequirements()[i]); + } else { + id++; + } + } + + slots[id++] = new TechnologySlot(this, 89, 79, techno); + + for (int i = 0; i < 5; ++i) { + for (int j = 0; j < 2; ++j) { + int followupId = i * 2 + j; + if (techno.getFollowups().size() > followupId + && techno.getFollowups().get(followupId) != null) { + slots[id++] = new TechnologySlot(this, 145 + 18 * j, 43 + 18 * i, techno.getFollowups().get( + followupId)); + } else { + id++; + } + } + } + } +} diff --git a/common/buildcraft/core/gui/ItemSlot.java b/common/buildcraft/core/gui/ItemSlot.java index c71d18d1..e9c5ea2a 100755 --- a/common/buildcraft/core/gui/ItemSlot.java +++ b/common/buildcraft/core/gui/ItemSlot.java @@ -18,6 +18,12 @@ public class ItemSlot extends AdvancedSlot { super(gui, x, y); } + public ItemSlot(GuiAdvancedInterface gui, int x, int y, ItemStack iStack) { + super(gui, x, y); + + stack = iStack; + } + @Override public ItemStack getItemStack() { return stack; diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index e17fd73e..29251975 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -40,6 +40,8 @@ import buildcraft.api.core.ICoreProxy; import buildcraft.core.EntityBlock; import buildcraft.core.ItemBlockBuildCraft; import buildcraft.core.LaserKind; +import buildcraft.core.recipes.BuildCraftRecipe; +import buildcraft.core.science.Technology; public class CoreProxy implements ICoreProxy { @@ -108,6 +110,17 @@ public class CoreProxy implements ICoreProxy { stack.onCrafting(world, player, stack.stackSize); } + @SuppressWarnings("unchecked") + public void addCraftingRecipe(Technology techno, ItemStack result, Object... recipe) { + String name = Item.itemRegistry.getNameForObject(result.getItem()); + + if (BuildCraftCore.recipesBlacklist.contains(name)) { + return; + } + + CraftingManager.getInstance().getRecipeList().add(new BuildCraftRecipe(techno, result, recipe)); + } + @SuppressWarnings("unchecked") public void addCraftingRecipe(ItemStack result, Object... recipe) { String name = Item.itemRegistry.getNameForObject(result.getItem()); diff --git a/common/buildcraft/core/recipes/BuildCraftRecipe.java b/common/buildcraft/core/recipes/BuildCraftRecipe.java new file mode 100755 index 00000000..a10f9e06 --- /dev/null +++ b/common/buildcraft/core/recipes/BuildCraftRecipe.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.recipes; + +import java.lang.reflect.Field; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import net.minecraftforge.oredict.ShapedOreRecipe; + +import buildcraft.core.science.Technology; + +public class BuildCraftRecipe extends ShapedOreRecipe { + + Technology techno; + + public BuildCraftRecipe(Technology iTechno, ItemStack result, Object[] recipe) { + super(result, recipe); + + iTechno = techno; + } + + @Override + public boolean matches(InventoryCrafting inv, World world) { + try { + Field f = InventoryCrafting.class.getDeclaredField("eventHandler"); + + if (!f.isAccessible()) { + f.setAccessible(true); + } + + Container container = (Container) f.get(inv); + + f = Container.class.getDeclaredField("crafters"); + + if (!f.isAccessible()) { + f.setAccessible(true); + } + + List crafters = (List) f.get(container); + + for (Object p : crafters) { + EntityPlayer player = (EntityPlayer) p; + + System.out.println(player.getEntityId()); + } + } catch (Throwable e) { + e.printStackTrace(); + } + + return super.matches(inv, world); + } +} diff --git a/common/buildcraft/core/science/TechnoSimpleItem.java b/common/buildcraft/core/science/TechnoSimpleItem.java new file mode 100755 index 00000000..88043e92 --- /dev/null +++ b/common/buildcraft/core/science/TechnoSimpleItem.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.science; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class TechnoSimpleItem extends Technology { + + private ItemStack itemToDisplay; + + public TechnoSimpleItem(Tier iTier, + Object iItemToDisplay, + ItemStack requirement, + Technology... iPrerequisites) { + this(iTier, iItemToDisplay, requirement, null, null, iPrerequisites); + } + + public TechnoSimpleItem(Tier iTier, + Object iItemToDisplay, + ItemStack requirement1, + ItemStack requirement2, + Technology... iPrerequisites) { + this(iTier, iItemToDisplay, requirement1, requirement2, null, iPrerequisites); + } + + public TechnoSimpleItem(Tier iTier, + Object iItemToDisplay, + ItemStack requirement1, + ItemStack requirement2, + ItemStack requirement3, + Technology... iPrerequisites) { + + super(iTier, requirement1, requirement2, requirement3, iPrerequisites); + + itemToDisplay = toStack(iItemToDisplay); + } + + @Override + public ItemStack getStackToDisplay() { + return itemToDisplay; + } + + @Override + public String getLocalizedName() { + return ""; + } + + public static ItemStack toStack(Object obj) { + if (obj instanceof ItemStack) { + return (ItemStack) obj; + } else if (obj instanceof Item) { + return new ItemStack((Item) obj); + } else if (obj instanceof Block) { + return new ItemStack((Block) obj); + } else { + return null; + } + } +} diff --git a/common/buildcraft/core/science/TechnoTier.java b/common/buildcraft/core/science/TechnoTier.java new file mode 100755 index 00000000..01838afd --- /dev/null +++ b/common/buildcraft/core/science/TechnoTier.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.science; + +import net.minecraft.item.ItemStack; + +public class TechnoTier extends Technology { + + private ItemStack itemToDisplay; + private Technology[] prerequisites; + private ItemStack[] requirements; + + public TechnoTier(Tier iTier, + Object requirement, + Technology... iPrerequisites) { + this(iTier, requirement, null, null, iPrerequisites); + } + + public TechnoTier(Tier iTier, + Object requirement1, + Object requirement2, + Technology... iPrerequisites) { + this(iTier, requirement1, requirement2, null, iPrerequisites); + } + + public TechnoTier(Tier iTier, + Object requirement1, + Object requirement2, + Object requirement3, + Technology... iPrerequisites) { + + super(Tier.values()[(iTier.ordinal() > 0 ? iTier.ordinal() - 1 : 0)], + requirement1, + requirement2, + requirement3); + + itemToDisplay = toStack(iTier.getStackToDisplay()); + + prerequisites = iPrerequisites; + } + + @Override + public ItemStack getStackToDisplay() { + return itemToDisplay; + } + + @Override + public String getLocalizedName() { + return ""; + } +} diff --git a/common/buildcraft/core/science/Technology.java b/common/buildcraft/core/science/Technology.java new file mode 100755 index 00000000..74070e67 --- /dev/null +++ b/common/buildcraft/core/science/Technology.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.science; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class Technology { + + private static final LinkedList[] registry = new LinkedList[Tier.values().length]; + + private Tier tier; + private ItemStack[] requirements; + private ArrayList prerequisites = new ArrayList(); + protected ArrayList followups = new ArrayList();; + + public Technology(Tier iTier, + Object requirement1, + Object requirement2, + Object requirement3, + Technology... iPrerequisites) { + getTechnologies(iTier).add(this); + + tier = iTier; + + requirements = new ItemStack[] + {toStack(requirement1), + toStack(requirement2), + toStack(requirement3)}; + + for (Technology t : iPrerequisites) { + prerequisites.add(t); + t.followups.add(this); + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon() { + return null; + } + + public ItemStack getStackToDisplay() { + return null; + } + + public abstract String getLocalizedName(); + + public final ArrayList getPrerequisites() { + return prerequisites; + } + + public final ArrayList getFollowups() { + return followups; + } + + public final ItemStack[] getRequirements() { + return requirements; + } + + public final Tier getTier() { + return tier; + } + + public static Collection getTechnologies(Tier tier) { + if (registry[tier.ordinal()] == null) { + registry[tier.ordinal()] = new LinkedList(); + } + + return registry[tier.ordinal()]; + } + + public static ItemStack toStack(Object obj) { + if (obj instanceof ItemStack) { + return (ItemStack) obj; + } else if (obj instanceof Item) { + return new ItemStack((Item) obj); + } else if (obj instanceof Block) { + return new ItemStack((Block) obj); + } else { + return null; + } + } + +} diff --git a/common/buildcraft/core/science/Tier.java b/common/buildcraft/core/science/Tier.java new file mode 100755 index 00000000..ee2e4f2a --- /dev/null +++ b/common/buildcraft/core/science/Tier.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.science; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import buildcraft.BuildCraftCore; +import buildcraft.silicon.ItemRedstoneChipset; + +public enum Tier { + WoodenGear, + StoneGear, + IronGear, + GoldenGear, + DiamondGear, + EmeraldGear, + RedstoneCrystalGear, + + Chipset, + IronChipset, + GoldenChipset, + DiamondChipset, + EmeraldChipset, + RedstoneCrystalChipset, + Unrevealed; + + private static ItemStack[] stacksToDisplay; + + public ItemStack getStackToDisplay () { + if (stacksToDisplay == null) { + stacksToDisplay = new ItemStack[Tier.values().length]; + + stacksToDisplay [WoodenGear.ordinal()] = new ItemStack (BuildCraftCore.woodenGearItem); + stacksToDisplay [StoneGear.ordinal()] = new ItemStack (BuildCraftCore.stoneGearItem); + stacksToDisplay [IronGear.ordinal()] = new ItemStack (BuildCraftCore.ironGearItem); + stacksToDisplay [GoldenGear.ordinal()] = new ItemStack (BuildCraftCore.goldGearItem); + stacksToDisplay[DiamondGear.ordinal()] = new ItemStack(BuildCraftCore.diamondGearItem); + stacksToDisplay [EmeraldGear.ordinal()] = new ItemStack (Blocks.bedrock); + stacksToDisplay [RedstoneCrystalGear.ordinal()] = new ItemStack (Blocks.bedrock); + stacksToDisplay[Chipset.ordinal()] = ItemRedstoneChipset.Chipset.RED.getStack(); + stacksToDisplay[IronChipset.ordinal()] = ItemRedstoneChipset.Chipset.IRON.getStack(); + stacksToDisplay[GoldenChipset.ordinal()] = ItemRedstoneChipset.Chipset.GOLD.getStack(); + stacksToDisplay[DiamondChipset.ordinal()] = ItemRedstoneChipset.Chipset.DIAMOND.getStack(); + stacksToDisplay[EmeraldChipset.ordinal()] = ItemRedstoneChipset.Chipset.EMERALD.getStack(); + stacksToDisplay[RedstoneCrystalChipset.ordinal()] = new ItemStack(Blocks.bedrock); + stacksToDisplay[Unrevealed.ordinal()] = new ItemStack(Blocks.bedrock); + } + + return stacksToDisplay[ordinal()]; + } +}