From 9d0d74a3ba0aeca9f1130d1228fa4b9ef08d19d6 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Sun, 30 Mar 2014 22:59:36 +0300 Subject: Added a gui! Yaaay! --- .../darkknight/jewelrycraft/JewelrycraftMod.java | 2 + .../darkknight/jewelrycraft/block/BlockShadow.java | 2 +- .../darkknight/jewelrycraft/client/GuiGuide.java | 215 +++++++++++++++ .../jewelrycraft/config/ConfigHandler.java | 2 + .../jewelrycraft/container/ContainerGuide.java | 18 ++ .../jewelrycraft/container/GuiHandler.java | 38 ++- .../jewelrycraft/container/GuiRectangle.java | 66 +++++ .../darkknight/jewelrycraft/container/GuiTab.java | 37 +++ .../jewelrycraft/container/GuiTabBlocks.java | 294 +++++++++++++++++++++ .../jewelrycraft/container/GuiTabItems.java | 227 ++++++++++++++++ .../container/GuiTabJewelsAndModifiers.java | 85 ++++++ .../jewelrycraft/container/GuiTabNecklaces.java | 36 +++ .../jewelrycraft/container/GuiTabRings.java | 67 +++++ common/darkknight/jewelrycraft/container/Page.java | 158 +++++++++++ .../jewelrycraft/events/EntityEventHandler.java | 48 ++++ common/darkknight/jewelrycraft/item/ItemGuide.java | 28 ++ common/darkknight/jewelrycraft/item/ItemList.java | 3 + common/darkknight/jewelrycraft/item/ItemRing.java | 7 +- .../darkknight/jewelrycraft/util/BlockUtils.java | 121 +++++++++ .../jewelrycraft/util/JewelrycraftUtil.java | 2 +- .../darkknight/jewelrycraft/util/PlayerUtils.java | 57 ++++ resources/assets/jewelrycraft/Changelog.txt | 1 + resources/assets/jewelrycraft/lang/en_US.lang | 2 + .../assets/jewelrycraft/textures/gui/guidePage.png | Bin 0 -> 18212 bytes .../jewelrycraft/textures/gui/guidePage1.png | Bin 0 -> 30103 bytes .../jewelrycraft/textures/gui/guidePageFlip.png | Bin 0 -> 18340 bytes .../jewelrycraft/textures/gui/guidePageFlip1.png | Bin 0 -> 30159 bytes .../assets/jewelrycraft/textures/items/guide.png | Bin 0 -> 350 bytes 28 files changed, 1508 insertions(+), 8 deletions(-) create mode 100644 common/darkknight/jewelrycraft/client/GuiGuide.java create mode 100644 common/darkknight/jewelrycraft/container/ContainerGuide.java create mode 100644 common/darkknight/jewelrycraft/container/GuiRectangle.java create mode 100644 common/darkknight/jewelrycraft/container/GuiTab.java create mode 100644 common/darkknight/jewelrycraft/container/GuiTabBlocks.java create mode 100644 common/darkknight/jewelrycraft/container/GuiTabItems.java create mode 100644 common/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java create mode 100644 common/darkknight/jewelrycraft/container/GuiTabNecklaces.java create mode 100644 common/darkknight/jewelrycraft/container/GuiTabRings.java create mode 100644 common/darkknight/jewelrycraft/container/Page.java create mode 100644 common/darkknight/jewelrycraft/events/EntityEventHandler.java create mode 100644 common/darkknight/jewelrycraft/item/ItemGuide.java create mode 100644 common/darkknight/jewelrycraft/util/BlockUtils.java create mode 100644 common/darkknight/jewelrycraft/util/PlayerUtils.java create mode 100644 resources/assets/jewelrycraft/textures/gui/guidePage.png create mode 100644 resources/assets/jewelrycraft/textures/gui/guidePage1.png create mode 100644 resources/assets/jewelrycraft/textures/gui/guidePageFlip.png create mode 100644 resources/assets/jewelrycraft/textures/gui/guidePageFlip1.png create mode 100644 resources/assets/jewelrycraft/textures/items/guide.png diff --git a/common/darkknight/jewelrycraft/JewelrycraftMod.java b/common/darkknight/jewelrycraft/JewelrycraftMod.java index 47ac735..0b794d7 100644 --- a/common/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/common/darkknight/jewelrycraft/JewelrycraftMod.java @@ -37,6 +37,7 @@ import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.client.JewelryCraftClient; import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.container.GuiHandler; +import darkknight.jewelrycraft.events.EntityEventHandler; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.lib.Reference; import darkknight.jewelrycraft.recipes.CraftingRecipes; @@ -98,6 +99,7 @@ public class JewelrycraftMod implements IConnectionHandler { logger.severe("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.6.4"); } + MinecraftForge.EVENT_BUS.register(new EntityEventHandler()); proxy.registerRenderers(); } diff --git a/common/darkknight/jewelrycraft/block/BlockShadow.java b/common/darkknight/jewelrycraft/block/BlockShadow.java index dc058f1..1e58d54 100644 --- a/common/darkknight/jewelrycraft/block/BlockShadow.java +++ b/common/darkknight/jewelrycraft/block/BlockShadow.java @@ -80,7 +80,7 @@ public class BlockShadow extends BlockContainer public boolean shouldSideBeRendered(IBlockAccess iBlockAccess, int par2, int par3, int par4, int par5) { - return iBlockAccess.isAirBlock(par2, par3, par4)?true:false; + return iBlockAccess.isAirBlock(par2, par3, par4)?true:iBlockAccess.isBlockNormalCube(par2, par3, par4)?false:(iBlockAccess.getBlockId(par2, par3, par4) == BlockList.shadowBlock.blockID)?false:true; } public boolean hasComparatorInputOverride() diff --git a/common/darkknight/jewelrycraft/client/GuiGuide.java b/common/darkknight/jewelrycraft/client/GuiGuide.java new file mode 100644 index 0000000..48fc762 --- /dev/null +++ b/common/darkknight/jewelrycraft/client/GuiGuide.java @@ -0,0 +1,215 @@ +package darkknight.jewelrycraft.client; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.container.GuiRectangle; +import darkknight.jewelrycraft.container.GuiTab; +import darkknight.jewelrycraft.container.GuiTabBlocks; +import darkknight.jewelrycraft.container.GuiTabItems; +import darkknight.jewelrycraft.container.GuiTabJewelsAndModifiers; +import darkknight.jewelrycraft.container.GuiTabNecklaces; +import darkknight.jewelrycraft.container.GuiTabRings; + +public class GuiGuide extends GuiContainer +{ + public int page, rot, del; + public boolean prevHover, nextHover; + World world; + private final GuiTab[] tabs; + private GuiTab activeTab; + + public GuiGuide(Container container, World world) + { + super(container); + page = 1; + rot = 0; + del = 0; + this.world = world; + + tabs = new GuiTab[] { + new GuiTabBlocks(0), + new GuiTabItems(1), + new GuiTabJewelsAndModifiers(2), + new GuiTabRings(3), + new GuiTabNecklaces(4) + }; + + activeTab = tabs[0]; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) + { + nextHover = false; + prevHover = false; + if(del == 0) rot++; + del++; + if(del >= 2) del = 0; + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePage.png")); + drawTexturedModalRect(guiLeft + 147/2 + 20, guiTop - 10, 0, 0, 145, 180); + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip.png")); + drawTexturedModalRect(guiLeft - 147/2 + 21, guiTop - 10, 0, 0, 145, 180); + + for (GuiRectangle tab : tabs) { + int srcX = 24; + int sizeX = 19; + + if (tab == activeTab) { + srcX += 38; + sizeX +=3; + }else if(tab.inRect(this, i, j)) { + srcX += 19; + } + + tab.draw(this, srcX, 180, sizeX, 18); + } + + if(i >= guiLeft + 195 + 20 && i <= guiLeft + 195 + 20 + 11 && j >= guiTop + 127 + 20 && j <= guiTop + 127 + 20 + 14) + { + drawTexturedModalRect(guiLeft + 195 + 20, guiTop + 127 + 20, 0, 180, 11, 14); + nextHover = true; + } + + if(i >= guiLeft + 20 - 61 && i <= guiLeft - 61 + 20 + 11 && j >= guiTop + 127 + 20 && j <= guiTop + 127 + 20 + 14) + { + drawTexturedModalRect(guiLeft - 61 + 20, guiTop + 127 + 20, 11, 180, 11, 14); + prevHover = true; + } + + activeTab.drawBackground(this, i, j, page); + activeTab.drawBackground(this, i, j, page + 1); + + ArrayList text = new ArrayList(); + text.add(Integer.toString(page)); + this.drawHoveringText(text, guiLeft - 10 + 20 - text.get(0).length(), guiTop + 150 + 20, fontRenderer); + text.remove(Integer.toString(page)); + text.add(Integer.toString(page + 1)); + this.drawHoveringText(text, guiLeft - 10 + 20 + 147 - text.get(0).length(), guiTop + 150 + 20, fontRenderer); + + for(int tab = 0; tab < tabs.length; tab++) + renderItem(tabs[tab].getIcon(), guiLeft - 52, guiTop + 26 + tab*19, activeTab.getIcon()); + + } + + protected void drawGuiContainerForegroundLayer(int x, int y) + { + activeTab.drawForeground(this, x, y, page); + activeTab.drawForeground(this, x, y, page + 1); + + for (GuiTab tab : tabs) { + tab.drawString(this, x, y, tab.getName()); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) + { + if(nextHover && page+2 <= activeTab.getMaxPages()) page+=2; + else if (prevHover && page > 1) page-=2; + + activeTab.mouseClick(this, x, y, button); + + for (GuiTab tab : tabs) { + if (activeTab != tab) { + if (tab.inRect(this, x, y)) { + activeTab = tab; + page = 1; + break; + } + } + } + } + + public void renderItem(ItemStack item, float x, float y, ItemStack activeIcon) + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, item); + entityitem.hoverStart = 0.0F; + if(item.isItemEqual(new ItemStack(BlockList.jewelAltar))) + { + y-=4; + } + GL11.glTranslatef(x, y, 100); + + float scale = 30F; + GL11.glScalef(-scale, scale, scale); + + if(activeIcon != null && item.isItemEqual(activeIcon)) GL11.glRotatef(rot, 0, 1, 0); + if(item.isItemEqual(new ItemStack(BlockList.jewelAltar))) + { + GL11.glRotatef(160.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + + } + + public void renderItem(ItemStack item, float x, float y, float scale) + { + GL11.glPushMatrix(); + EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, item); + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(x, y, 100); + GL11.glScalef(-scale, scale, scale); + GL11.glRotatef(160.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glPopMatrix(); + } + + public int getLeft() + { + return guiLeft; + } + + public int getTop() + { + return guiTop; + } + + public FontRenderer getFont() + { + return fontRenderer; + } + + @SuppressWarnings("rawtypes") + public void drawHoverString(List lst, int x, int y) + { + drawHoveringText(lst, x, y, fontRenderer); + } +} \ No newline at end of file diff --git a/common/darkknight/jewelrycraft/config/ConfigHandler.java b/common/darkknight/jewelrycraft/config/ConfigHandler.java index ca045ba..80309af 100644 --- a/common/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/common/darkknight/jewelrycraft/config/ConfigHandler.java @@ -13,6 +13,7 @@ public class ConfigHandler public static int idClayMolds = 17497; public static int idCrystal = 17498; public static int idNecklace = 17499; + public static int idGuide = 17500; public static int idShadowOre = 1750; public static int idSmelter = 1751; @@ -44,6 +45,7 @@ public class ConfigHandler idRing = config.getItem("Ring", idRing).getInt(); idNecklace = config.getItem("Necklace", idNecklace).getInt(); idCrystal = config.getItem("Crystal", idCrystal).getInt(); + idGuide = config.getItem("Guide", idGuide).getInt(); idShadowOre = config.getBlock("Shadow Ore", idShadowOre).getInt(); idShadowBlock = config.getBlock("Shadow Block", idShadowBlock).getInt(); diff --git a/common/darkknight/jewelrycraft/container/ContainerGuide.java b/common/darkknight/jewelrycraft/container/ContainerGuide.java new file mode 100644 index 0000000..ef05cc4 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/ContainerGuide.java @@ -0,0 +1,18 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; + +/** + * User: joel / Date: 16.12.13 / Time: 22:36 + */ +public class ContainerGuide extends Container { + + public ContainerGuide() { + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } +} \ No newline at end of file diff --git a/common/darkknight/jewelrycraft/container/GuiHandler.java b/common/darkknight/jewelrycraft/container/GuiHandler.java index a0afc3f..6e1a78a 100644 --- a/common/darkknight/jewelrycraft/container/GuiHandler.java +++ b/common/darkknight/jewelrycraft/container/GuiHandler.java @@ -6,25 +6,57 @@ import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.client.GuiGuide; import darkknight.jewelrycraft.client.GuiRingChest; public class GuiHandler implements IGuiHandler { + public static enum GuiId { + ringChest, + guide; + + public static final GuiId[] VALUES = GuiId.values(); + } + public GuiHandler() { NetworkRegistry.instance().registerGuiHandler(JewelrycraftMod.instance, this); } - + @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - return new ContainerRingChest(player.inventory, (TileEntityChest) world.getBlockTileEntity(x, y, z)); + final GuiId guiId = getGuiId(ID); + if (guiId == null) return null; + switch(guiId) + { + case ringChest: return new ContainerRingChest(player.inventory, (TileEntityChest) world.getBlockTileEntity(x, y, z)); + case guide: return new ContainerGuide(); + default: return null; + } } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - return new GuiRingChest((ContainerRingChest) getServerGuiElement(ID, player, world, x, y, z)); + final GuiId guiId = getGuiId(ID); + if (guiId == null) return null; + switch(guiId) + { + case ringChest: return new GuiRingChest((ContainerRingChest) getServerGuiElement(ID, player, world, x, y, z)); + case guide: return new GuiGuide((ContainerGuide) getServerGuiElement(ID, player, world, x, y, z), world); + default: return null; + } } + private static GuiId getGuiId(int id) { + try + { + return GuiId.VALUES[id]; + } + catch (ArrayIndexOutOfBoundsException e) + { + return null; + } + } } diff --git a/common/darkknight/jewelrycraft/container/GuiRectangle.java b/common/darkknight/jewelrycraft/container/GuiRectangle.java new file mode 100644 index 0000000..76dee04 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/GuiRectangle.java @@ -0,0 +1,66 @@ +package darkknight.jewelrycraft.container; + +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import darkknight.jewelrycraft.client.GuiGuide; + +public class GuiRectangle +{ + + private int x; + private int y; + private int w; + private int h; + + public GuiRectangle(int x, int y, int w, int h) + { + this.x = x; + this.y = y; + this.w = w; + this.h = h; + } + + public boolean inRect(GuiGuide gui, int mouseX, int mouseY) + { + mouseX -= gui.getLeft(); + mouseY -= gui.getTop(); + + return x <= mouseX && mouseX <= x + w && y <= mouseY && mouseY <= y + h; + } + + public void setX(int x) + { + this.x = x; + } + + public void setY(int y) + { + this.y = y; + } + + + public void draw(GuiGuide gui, int srcX, int srcY) + { + gui.drawTexturedModalRect(gui.getLeft() + x, gui.getTop() + y, srcX, srcY, w, h); + } + + + public void draw(GuiGuide gui, int srcX, int srcY, int width, int height) + { + gui.drawTexturedModalRect(gui.getLeft() + x, gui.getTop() + y, srcX, srcY, width, height); + } + + public void drawString(GuiGuide gui, int mouseX, int mouseY, String str) + { + if (inRect(gui, mouseX, mouseY)) { + gui.drawHoverString(Arrays.asList(str.split("\n")), mouseX - gui.getLeft(), mouseY - gui.getTop()); + } + } + + public ItemStack getIcon() + { + return null; + } +} diff --git a/common/darkknight/jewelrycraft/container/GuiTab.java b/common/darkknight/jewelrycraft/container/GuiTab.java new file mode 100644 index 0000000..c092ba6 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/GuiTab.java @@ -0,0 +1,37 @@ +package darkknight.jewelrycraft.container; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.client.GuiGuide; + +@SideOnly(Side.CLIENT) +public abstract class GuiTab extends GuiRectangle +{ + int values, del; + private String name; + + public GuiTab(String name, int id) + { + super(-62, 10 + 19*id, 19, 18); + this.name = name; + values = 0; + del = 0; + } + + public String getName() + { + return name; + } + + public abstract void drawBackground(GuiGuide gui, int x, int y, int page); + public abstract void drawForeground(GuiGuide gui, int x, int y, int page); + public void mouseClick(GuiGuide gui, int x, int y, int button) {} + public void mouseMoveClick(GuiGuide gui, int x, int y, int button, long timeSinceClicked) {} + public void mouseReleased(GuiGuide gui, int x, int y, int button) {} + + public int getMaxPages() + { + return 1; + } + +} diff --git a/common/darkknight/jewelrycraft/container/GuiTabBlocks.java b/common/darkknight/jewelrycraft/container/GuiTabBlocks.java new file mode 100644 index 0000000..614b6d4 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/GuiTabBlocks.java @@ -0,0 +1,294 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; + +public class GuiTabBlocks extends GuiTab +{ + + public GuiTabBlocks(int id) + { + super("Blocks", id); + } + + public ItemStack getIcon() + { + return new ItemStack(BlockList.jewelAltar); + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + ArrayList text = new ArrayList(); + ArrayList items = new ArrayList(); + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + text.add(" This ore is extremely"); + text.add("rare and can be found"); + text.add("only between Y level 5"); + text.add("and 8. It can only be"); + text.add("mined using a diamond"); + text.add("pickaxe."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), new ItemStack(BlockList.shadowOre), text, 90f); + break; + case 2: + text.add(" The Shadow Block is"); + text.add("crafted using 9 shadow"); + text.add("ingots. It has been"); + text.add("discovered that it"); + text.add("poseses abnormal"); + text.add("properties in the"); + text.add("shadow. The darker it"); + items.add(new ItemStack(BlockList.shadowBlock)); + for(int i = 1; i <= 9; i++) items.add(new ItemStack(ItemList.shadowIngot)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 3: + text.add("is, the more"); + text.add("transparent it will be,"); + text.add("until it becomes"); + text.add("walkable through. If a"); + text.add("comparator is attached"); + text.add("to it, the output"); + text.add("strength will be equal"); + text.add("to the value of"); + text.add("darkness it is in."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 4: + text.add(" The smelter is one of"); + text.add("the first blocks needed"); + text.add("to get started with"); + text.add("Jewelrycraft. Requiring"); + text.add("just some cobble and"); + text.add("a couple buckets, it's"); + text.add("the most important"); + items.add(new ItemStack(BlockList.smelter)); + items.add(new ItemStack(Block.cobblestone)); + items.add(new ItemStack(Item.bucketEmpty)); + items.add(new ItemStack(Block.cobblestone)); + items.add(new ItemStack(Block.cobblestone)); + items.add(null); + items.add(new ItemStack(Block.cobblestone)); + items.add(new ItemStack(Block.cobblestone)); + items.add(new ItemStack(Item.bucketLava)); + items.add(new ItemStack(Block.cobblestone)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 5: + text.add("block as it can melt"); + text.add("ingots which can be"); + text.add("made into pieces of"); + text.add("jewellery, like rings"); + text.add("or necklaces. To use"); + text.add("the block all you need"); + text.add("to do is right click"); + text.add("on it with any ingot."); + text.add("If left clicked while"); + text.add("smelting, a message"); + text.add("will appear saying the"); + text.add("percentage it is done."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 6: + text.add("If left clicked when"); + text.add("it's done smelting,"); + text.add("a message will be"); + text.add("displayed, mentioning"); + text.add("the contents of the"); + text.add("block."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 7: + text.add(" The molder is a key"); + text.add("piece in creating"); + text.add("jewellery. You need"); + text.add("to pour the molten"); + text.add("metal out of the"); + text.add("smelter somewhere."); + text.add("That somewhere is the"); + + items.add(new ItemStack(BlockList.molder)); + items.add(new ItemStack(Block.cobblestone)); + items.add(null); + items.add(new ItemStack(Block.cobblestone)); + for(int i = 1; i <= 3; i++) items.add(new ItemStack(Block.cobblestone)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 8: + text.add("molder. But before"); + text.add("pouring the molten"); + text.add("metal in it, you must"); + text.add("first add a mold."); + text.add("You can do that by"); + text.add("simply right clicking"); + text.add("the block with the"); + text.add("mold of your choice."); + text.add("If you want to get the"); + text.add("mold out, simply crouch"); + text.add("and right click it with"); + text.add("an empty hand."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 9: + text.add(" Once you have a mold"); + text.add("inside, left click on"); + text.add("the smelter and wait"); + text.add("for the metal to cool"); + text.add("down. When it's done,"); + text.add("left click on the"); + text.add("molder to get the"); + text.add("jewellery. §4Be aware"); + text.add("§4that this block must be"); + text.add("§4placed directly in front"); + text.add("§4of the smelter,"); + text.add("§4otherwise it won't work!"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 10: + text.add(" Your jewellery on"); + text.add("their own don't do"); + text.add("much. They need to be"); + text.add("modified a bit and the"); + text.add("only way to do that is"); + text.add("by using this block."); + text.add("Simply right click the"); + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values >= 4) values = 0; + items.add(new ItemStack(BlockList.jewelCraftingTable)); + for(int i = 1; i <= 3; i++)items.add(new ItemStack(Block.planks, 1, values)); + items.add(new ItemStack(Block.cobblestone)); + items.add(null); + items.add(new ItemStack(Block.cobblestone)); + items.add(new ItemStack(Block.cobblestone)); + items.add(null); + items.add(new ItemStack(Block.cobblestone)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 11: + text.add("block while holding the"); + text.add("jewellery to place it in."); + text.add("After that just add in"); + text.add("a jewel or a modifier,"); + text.add("or even both, to the"); + text.add("block. To do that simply"); + text.add("right click with them on"); + text.add("the block. Once it's"); + text.add("done modifying, left"); + text.add("click on it to retrieve"); + text.add("the modified item. If"); + text.add("you wish to know how"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 12: + text.add("much is left before the"); + text.add("transformation is done,"); + text.add("simply left click on the"); + text.add("table in the process."); + text.add(" A list with all the"); + text.add("possible modifiers is"); + text.add("located in a separate"); + text.add("tab."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 13: + text.add(" This block can store"); + text.add("any jewellery in it"); + text.add("and activate their"); + text.add("effects as it were a"); + text.add("player. However, it"); + text.add("does not work with"); + text.add("everything. You can"); + items.add(new ItemStack(BlockList.jewelAltar)); + items.add(new ItemStack(Block.whiteStone)); + items.add(new ItemStack(Block.cloth, 1, 5)); + items.add(new ItemStack(Block.whiteStone)); + items.add(new ItemStack(Block.netherBrick)); + items.add(new ItemStack(Block.cloth, 1, 5)); + items.add(new ItemStack(Block.netherBrick)); + items.add(new ItemStack(Block.netherBrick)); + items.add(new ItemStack(Block.netherBrick)); + items.add(new ItemStack(Block.netherBrick)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 14: + text.add("find out which jewellery"); + text.add("works by looking in"); + text.add("their apropriate tab."); + text.add(" Each item will have a"); + text.add("note where it is"); + text.add("mentioned their effect"); + text.add("when placed in this"); + text.add("block."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 15: + text.add(" The Storage"); + text.add("Displayer, as the"); + text.add("name suggests, can"); + text.add("store a large amount"); + text.add("of a single item/block"); + text.add("placed in it. This will"); + text.add("display all possible"); + items.add(new ItemStack(BlockList.displayer)); + items.add(null); + items.add(new ItemStack(Item.ingotIron)); + items.add(null); + items.add(new ItemStack(Item.ingotIron)); + items.add(new ItemStack(Item.ingotIron)); + items.add(new ItemStack(Item.ingotIron)); + items.add(new ItemStack(Block.blockEmerald)); + items.add(new ItemStack(Block.blockEmerald)); + items.add(new ItemStack(Block.blockEmerald)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 16: + text.add("infromation about the"); + text.add("object in it, such as"); + text.add("the name, durability,"); + text.add("enchantments and many"); + text.add("more. Below the name"); + text.add("is shown the amount"); + text.add("stored. To store"); + text.add("something in it simply"); + text.add("right click with that"); + text.add("object on it and the"); + text.add("whole amount of items"); + text.add("or blocks will be"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 17: + text.add("immediately stored"); + text.add("inside. To retrieve"); + text.add("a single item just"); + text.add("left click the block."); + text.add("If you wish to get"); + text.add("a whole stack, just"); + text.add("crouch and left click."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + default:; + } + } + + public int getMaxPages() + { + return 17; + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/common/darkknight/jewelrycraft/container/GuiTabItems.java b/common/darkknight/jewelrycraft/container/GuiTabItems.java new file mode 100644 index 0000000..78ab2dc --- /dev/null +++ b/common/darkknight/jewelrycraft/container/GuiTabItems.java @@ -0,0 +1,227 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; + +public class GuiTabItems extends GuiTab +{ + + public GuiTabItems(int id) + { + super("Items", id); + } + + public ItemStack getIcon() + { + return new ItemStack(ItemList.thiefGloves); + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + ArrayList text = new ArrayList(); + ArrayList items = new ArrayList(); + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + text.add(" Shadow ingots are"); + text.add("obtained by smelting"); + text.add("shadow ore. They are"); + text.add("used in a few recipes"); + text.add("and an important key"); + text.add("for making some"); + text.add("jewellery work."); + items.add(new ItemStack(BlockList.shadowOre)); + items.add(new ItemStack(ItemList.shadowIngot)); + Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); + break; + case 2: + text.add(" These gloves allow"); + text.add("you to steal the trades"); + text.add("the pesky Testificates"); + text.add("have to offer."); + text.add(" To use these simply"); + text.add("open their gui at least"); + text.add("once, then crouch and"); + items.add(new ItemStack(ItemList.thiefGloves)); + items.add(new ItemStack(ItemList.shadowIngot)); + items.add(null); + items.add(new ItemStack(ItemList.shadowIngot)); + items.add(new ItemStack(Block.cloth, 1, 15)); + items.add(new ItemStack(ItemList.shadowIngot)); + items.add(new ItemStack(Block.cloth, 1, 15)); + items.add(new ItemStack(Block.cloth, 1, 15)); + items.add(new ItemStack(ItemList.shadowIngot)); + items.add(new ItemStack(Block.cloth, 1, 15)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 3: + text.add("right click on the them"); + text.add("to steal the trades."); + text.add("A villager has 7 of the"); + text.add("same trade item. So, for"); + text.add("example, if he wants 2"); + text.add("emeralds in exchange"); + text.add("for 4 diamonds, you will"); + text.add("get 28 diamonds from"); + text.add("him, because 7*4=28."); + text.add("However, if you have"); + text.add("traded with him before,"); + text.add("then he will have that"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 4: + text.add("many times less of the"); + text.add("item. This has a maximum"); + text.add("of 10 uses before it"); + text.add("breaks."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 5: + text.add(" In order to get the"); + text.add("ingot back from the"); + text.add("smelter you need a"); + text.add("mold for it. However,"); + text.add("this mold can't be used."); + text.add("It is too soft. It needs"); + text.add("to be hardened in"); + text.add("order for it to be used."); + items.add(new ItemStack(ItemList.clayMolds, 1, 0)); + items.add(new ItemStack(Item.clay)); + items.add(new ItemStack(Item.clay)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), true, text, items, x, y); + break; + case 6: + text.add(" By smelting the clay"); + text.add("mold you get a harder"); + text.add("version which can be"); + text.add("used to create ingots."); + text.add("Simply right click with"); + text.add("this on a molder to"); + text.add("attach it and you're"); + text.add("ready to go."); + items.add(new ItemStack(ItemList.clayMolds, 1, 0)); + items.add(new ItemStack(ItemList.molds, 1, 0)); + Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); + break; + case 7: + text.add(" In order to create a"); + text.add("ring you need a mold"); + text.add("for it. However, this"); + text.add("one can't be used. It is"); + text.add("too soft. It needs to be"); + text.add("hardened in order for"); + text.add("it to be used."); + items.add(new ItemStack(ItemList.clayMolds, 1, 1)); + items.add(null); + items.add(new ItemStack(Item.clay)); + items.add(null); + items.add(new ItemStack(Item.clay)); + items.add(null); + items.add(new ItemStack(Item.clay)); + items.add(null); + items.add(new ItemStack(Item.clay)); + items.add(null); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 8: + text.add(" By smelting the clay"); + text.add("mold you get a harder"); + text.add("version which can be"); + text.add("used to create rings."); + text.add("Simply right click with"); + text.add("this on a molder to"); + text.add("attach it and you're"); + text.add("ready to go."); + items.add(new ItemStack(ItemList.clayMolds, 1, 1)); + items.add(new ItemStack(ItemList.molds, 1, 1)); + Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); + break; + case 9: + text.add(" In order to create a"); + text.add("necklace you need a"); + text.add("mold for it. However,"); + text.add("this one can't be used."); + text.add("It is too soft. It needs"); + text.add("to be hardened in"); + text.add("order for it to be used."); + items.add(new ItemStack(ItemList.clayMolds, 1, 2)); + items.add(new ItemStack(Item.clay)); + items.add(null); + items.add(new ItemStack(Item.clay)); + items.add(new ItemStack(Item.clay)); + items.add(null); + items.add(new ItemStack(Item.clay)); + items.add(null); + items.add(new ItemStack(Item.clay)); + items.add(null); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 10: + text.add(" By smelting the clay"); + text.add("mold you get a harder"); + text.add("version which can be"); + text.add("used to create"); + text.add("necklaces. Simply right"); + text.add("click with this on a"); + text.add("molder to attach it and"); + text.add("you're ready to go."); + items.add(new ItemStack(ItemList.clayMolds, 1, 2)); + items.add(new ItemStack(ItemList.molds, 1, 2)); + Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); + break; + case 11: + text.add(" Crystals don't do"); + text.add("much. They can be dyed"); + text.add("in any color and used"); + text.add("as jewels to create a"); + text.add("nice jewellery."); + items.add(new ItemStack(ItemList.crystal, 1, 15)); + items.add(null); + items.add(new ItemStack(Block.glass)); + items.add(null); + items.add(new ItemStack(Block.glass)); + items.add(null); + items.add(new ItemStack(Block.glass)); + items.add(null); + items.add(new ItemStack(Block.glass)); + items.add(null); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 12: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values >= 15) values = 0; + items.add(new ItemStack(ItemList.crystal, 1, values)); + items.add(new ItemStack(Item.dyePowder, 1, values)); + items.add(new ItemStack(ItemList.crystal, 1, 15)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), true, text, items, x, y); + items.removeAll(items); + items.add(new ItemStack(ItemList.crystal, 1, 15)); + items.add(new ItemStack(Item.dyePowder, 1, 15)); + items.add(new ItemStack(ItemList.crystal, 1, values)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop() + 60, true, text, items, x, y); + break; + default:; + } + } + + public int getMaxPages() + { + return 11; + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/common/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java b/common/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java new file mode 100644 index 0000000..e755b14 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java @@ -0,0 +1,85 @@ +package darkknight.jewelrycraft.container; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class GuiTabJewelsAndModifiers extends GuiTab +{ + public GuiTabJewelsAndModifiers(int id) + { + super("Jewels and modifiers", id); + } + + public ItemStack getIcon() + { + return new ItemStack(Item.emerald); + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + gui.getFont().drawString("§1§n" + "Jewels", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++){ + gui.renderItem(JewelrycraftUtil.jewel.get(i), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.jewel.get(i).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + } + break; + case 2: + gui.getFont().drawString("§1§n" + "Jewels", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++){ + gui.renderItem(JewelrycraftUtil.jewel.get(i+9), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.jewel.get(i+9).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + } + break; + case 3: + gui.getFont().drawString("§1§n" + "Jewels", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++) + if(i+18 < JewelrycraftUtil.jewel.size()){ + gui.renderItem(JewelrycraftUtil.jewel.get(i+18), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.jewel.get(i+18).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + GL11.glDisable(GL11.GL_LIGHTING); + } + break; + case 4: + gui.getFont().drawString("§1§n" + "Modifiers", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++){ + if(i < JewelrycraftUtil.modifiers.size()) + { + gui.renderItem(JewelrycraftUtil.modifiers.get(i), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.modifiers.get(i).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + } + } + break; + case 5: + gui.getFont().drawString("§1§n" + "Modifiers", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++){ + if(i+9 < JewelrycraftUtil.modifiers.size()){ + gui.renderItem(JewelrycraftUtil.modifiers.get(i + 9), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.modifiers.get(i + 9).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + GL11.glDisable(GL11.GL_LIGHTING); + } + } + break; + default:; + } + } + + public int getMaxPages() + { + return 5; + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/common/darkknight/jewelrycraft/container/GuiTabNecklaces.java b/common/darkknight/jewelrycraft/container/GuiTabNecklaces.java new file mode 100644 index 0000000..c42ea92 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/GuiTabNecklaces.java @@ -0,0 +1,36 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class GuiTabNecklaces extends GuiTab +{ + public GuiTabNecklaces(int id) + { + super("Necklaces", id); + } + + public ItemStack getIcon() + { + ItemStack it = new ItemStack(ItemList.necklace); + JewelryNBT.addMetal(it, new ItemStack(Item.ingotIron)); + JewelryNBT.addJewel(it, new ItemStack(Block.blockRedstone)); + return it; + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + gui.getFont().drawString(this.getName(), gui.getLeft() + 4, gui.getTop() + 5, 3432135); + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/common/darkknight/jewelrycraft/container/GuiTabRings.java b/common/darkknight/jewelrycraft/container/GuiTabRings.java new file mode 100644 index 0000000..1982fee --- /dev/null +++ b/common/darkknight/jewelrycraft/container/GuiTabRings.java @@ -0,0 +1,67 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class GuiTabRings extends GuiTab +{ + + public GuiTabRings(int id) + { + super("Rings", id); + } + + public ItemStack getIcon() + { + ItemStack it = new ItemStack(ItemList.ring); + JewelryNBT.addMetal(it, new ItemStack(Item.ingotGold)); + JewelryNBT.addJewel(it, new ItemStack(Item.enderPearl)); + return it; + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + ArrayList text = new ArrayList(); + ItemStack item = new ItemStack(ItemList.ring); + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Item.enderPearl)); + + text.add("§2Jewel: §0Ender Pearl"); + text.add("§2Modifier: §0None"); + text.add("§2Ingot: §0Any"); + text.add(" This ring allows you"); + text.add("to teleport in any"); + text.add("location from the same"); + text.add("dimension. Simply right"); + text.add("click once in a location"); + text.add("to se the position. Then"); + text.add("right click any time you"); + text.add("want to teleport there."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10); + break; + default:; + } + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/common/darkknight/jewelrycraft/container/Page.java b/common/darkknight/jewelrycraft/container/Page.java new file mode 100644 index 0000000..f3b9622 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/Page.java @@ -0,0 +1,158 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import darkknight.jewelrycraft.client.GuiGuide; + +public class Page +{ + public static void addCraftingRecipeTextPage(GuiGuide gui, int x, int y, boolean isSmall, ArrayList text, ArrayList items, int mouseX, int mouseY) + { + y+=5; + gui.getFont().drawString("§1§n" + items.get(0).getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items.get(0).getDisplayName())/2) - 10, y - 2, 0); + GL11.glColor4f(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip1.png")); + ArrayList name = new ArrayList(); + if(isSmall){ + gui.drawTexturedModalRect(x, y + 10, 145, 54, 111, 46); + gui.renderItem(items.get(0), x + 89, y + 22 + 10, 30f); +// gui.drawRect(x, y + 10, x + 111, y + 46, 325325); + if(items.size() > 1 && items.get(1) != null){ + gui.renderItem(items.get(1), x + 8, y + 16 + 10, 30f); + if(x - gui.getLeft() >= x + 8) gui.drawHoverString(text, x, y); + name.add(items.get(1).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x - 8, y + 10); + name.removeAll(name); + } + if(items.size() > 2 && items.get(2) != null){ + gui.renderItem(items.get(2), x + 30, y + 16 + 10, 30f); + name.add(items.get(2).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x + 15, y + 10); + name.removeAll(name); + } + if(items.size() > 3 && items.get(3) != null){ + gui.renderItem(items.get(3), x + 8, y + 40 + 10, 30f); + name.add(items.get(3).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 36 && mouseY <= y + 36 + 16) gui.drawHoverString(name, x - 8, y + 35); + name.removeAll(name); + } + if(items.size() > 4 && items.get(4) != null){ + gui.renderItem(items.get(4), x + 30, y + 40 + 10, 30f); + name.add(items.get(4).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 36 && mouseY <= y + 36 + 16) gui.drawHoverString(name, x + 15, y + 35); + name.removeAll(name); + } + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 55 + i*12, 0); + } + else{ + gui.drawTexturedModalRect(x, y + 10, 145, 0, 111, 54); + gui.renderItem(items.get(0), x + 91, y + 28 + 10, 30f); + if(items.size() > 1 && items.get(1) != null){ + gui.renderItem(items.get(1), x + 8, y + 20, 30f); + name.add(items.get(1).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x + 8, y + 10); + name.removeAll(name); + } + if(items.size() > 2 && items.get(2) != null){ + gui.renderItem(items.get(2), x + 28, y + 20, 30f); + name.add(items.get(2).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x + 28, y + 10); + name.removeAll(name); + } + if(items.size() > 3 && items.get(3) != null){ + gui.renderItem(items.get(3), x + 45, y + 20, 30f); + name.add(items.get(3).getDisplayName()); + if(mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x + 45, y + 10); + name.removeAll(name); + } + if(items.size() > 4 && items.get(4) != null){ + gui.renderItem(items.get(4), x + 8, y + 37, 30f); + name.add(items.get(4).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 27 && mouseY <= y + 27 + 16) gui.drawHoverString(name, x + 8, y + 27); + name.removeAll(name); + } + if(items.size() > 5 && items.get(5) != null){ + gui.renderItem(items.get(5), x + 28, y + 37, 30f); + name.add(items.get(5).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 27 && mouseY <= y + 27 + 16) gui.drawHoverString(name, x + 28, y + 27); + name.removeAll(name); + } + if(items.size() > 6 && items.get(6) != null){ + gui.renderItem(items.get(6), x + 45, y + 37, 30f); + name.add(items.get(6).getDisplayName()); + if(mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 27 && mouseY <= y + 27 + 16) gui.drawHoverString(name, x + 45, y + 27); + name.removeAll(name); + } + if(items.size() > 7 && items.get(7) != null){ + gui.renderItem(items.get(7), x + 8, y + 57, 30f); + name.add(items.get(7).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 8, y + 47); + name.removeAll(name); + } + if(items.size() > 8 && items.get(8) != null){ + gui.renderItem(items.get(8), x + 28, y + 57, 30f); + name.add(items.get(8).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 28, y + 47); + name.removeAll(name); + } + if(items.size() > 9 && items.get(9) != null){ + gui.renderItem(items.get(9), x + 45, y + 57, 30f); + name.add(items.get(9).getDisplayName()); + if(mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 45, y + 47); + name.removeAll(name); + } + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 62 + i*12, 0); + GL11.glColor4f(1, 1, 1, 1); + } + } + + public static void addSmeltingRecipeTextPage(GuiGuide gui, int x, int y, ArrayList text, ArrayList items, int mouseX, int mouseY) + { + ArrayList name = new ArrayList(); + gui.getFont().drawString("§1§n" + items.get(1).getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items.get(0).getDisplayName())/2), y + 2, 0); + GL11.glColor4f(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip1" + + ".png")); + gui.drawTexturedModalRect(x, y + 10, 145, 100, 111, 46); + + gui.renderItem(items.get(0), x + 13, y + 20 + 10, 50f); + name.add(items.get(0).getDisplayName()); + if(mouseX >= x && mouseX <= x + 20 && mouseY >= y + 20 && mouseY <= y + 20 + 16) gui.drawHoverString(name, x, y + 20); + name.removeAll(name); + + gui.renderItem(items.get(1), x + 77, y + 28 + 10, 50f); + + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 60 + i*12, 0); + GL11.glColor4f(1, 1, 1, 1); + } + + public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, ArrayList text, float size) + { + y+=5; + gui.getFont().drawString("§1§n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName())/2) - 10, y + 2, 0); + GL11.glColor4f(1, 1, 1, 1); + gui.renderItem(item, x + 13, y + 18, size); + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 30 + i*12, 0); + } + + public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, ArrayList text, float size, int txtX, int txtY) + { + y+=5; + gui.getFont().drawString("§1§n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName())/2) - 10, y + 2, 0); + GL11.glColor4f(1, 1, 1, 1); + gui.renderItem(item, x + 13, y + 18, size); + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x + txtX, y + 30 + txtY + i*12, 0); + } + + public static void addTextPage(GuiGuide gui, int x, int y, ArrayList text) + { + y-=25; + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 30 + i*12, 0); + GL11.glColor4f(1, 1, 1, 1); + } +} diff --git a/common/darkknight/jewelrycraft/events/EntityEventHandler.java b/common/darkknight/jewelrycraft/events/EntityEventHandler.java new file mode 100644 index 0000000..a3af5f9 --- /dev/null +++ b/common/darkknight/jewelrycraft/events/EntityEventHandler.java @@ -0,0 +1,48 @@ +package darkknight.jewelrycraft.events; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.BlockUtils; +import darkknight.jewelrycraft.util.PlayerUtils; + +/** + * Code taken from OpenBlocks + */ +public class EntityEventHandler +{ + + public static final String OPENBLOCKS_PERSIST_TAG = "Jewelrycraft"; + public static final String GIVEN_GUIDE_TAG = "givenGuive"; + + @ForgeSubscribe + public void onEntityJoinWorld(EntityJoinWorldEvent event) + { + + final Entity entity = event.entity; + /** + * If the player hasn't been given a manual, we'll give him one! (or + * throw it on the floor..) + */ + if (!event.world.isRemote && entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer)entity; + NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + + boolean shouldGiveManual = ItemList.guide != null && !persistTag.getBoolean(GIVEN_GUIDE_TAG); + if (shouldGiveManual) + { + ItemStack manual = new ItemStack(ItemList.guide); + if (!player.inventory.addItemStackToInventory(manual)) + { + BlockUtils.dropItemStackInWorld(player.worldObj, player.posX, player.posY, player.posZ, manual); + } + persistTag.setBoolean(GIVEN_GUIDE_TAG, true); + } + } + } +} \ No newline at end of file diff --git a/common/darkknight/jewelrycraft/item/ItemGuide.java b/common/darkknight/jewelrycraft/item/ItemGuide.java new file mode 100644 index 0000000..7decf67 --- /dev/null +++ b/common/darkknight/jewelrycraft/item/ItemGuide.java @@ -0,0 +1,28 @@ +package darkknight.jewelrycraft.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.container.GuiHandler; + +public class ItemGuide extends Item +{ + + public ItemGuide(int id) + { + super(id); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (world.isRemote) + { + player.openGui(JewelrycraftMod.instance, GuiHandler.GuiId.guide.ordinal(), player.worldObj, 0, 0, 0); + } + + return stack; + } +} \ No newline at end of file diff --git a/common/darkknight/jewelrycraft/item/ItemList.java b/common/darkknight/jewelrycraft/item/ItemList.java index c45909b..8178763 100644 --- a/common/darkknight/jewelrycraft/item/ItemList.java +++ b/common/darkknight/jewelrycraft/item/ItemList.java @@ -15,6 +15,7 @@ public class ItemList public static Item crystal; public static ItemRing ring; public static ItemNecklace necklace; + public static Item guide; private static boolean isInitialized = false; @@ -29,6 +30,7 @@ public class ItemList ring = (ItemRing) new ItemRing(ConfigHandler.idRing - 256).setUnlocalizedName("Jewelrycraft.ring").setTextureName("jewelrycraft:ring"); crystal = new ItemCrystal(ConfigHandler.idCrystal - 256).setUnlocalizedName("Jewelrycraft.crystal").setTextureName("jewelrycraft:crystal").setCreativeTab(JewelrycraftMod.jewelrycraft); necklace = (ItemNecklace) new ItemNecklace(ConfigHandler.idNecklace - 256).setUnlocalizedName("Jewelrycraft.necklace").setTextureName("jewelrycraft:necklace"); + guide = new ItemGuide(ConfigHandler.idGuide - 256).setUnlocalizedName("Jewelrycraft.guide").setTextureName("jewelrycraft:guide").setCreativeTab(JewelrycraftMod.jewelrycraft); GameRegistry.registerItem(thiefGloves, "thiefGloves"); GameRegistry.registerItem(shadowIngot, "shadowIngot"); @@ -37,6 +39,7 @@ public class ItemList GameRegistry.registerItem(ring, "ring"); GameRegistry.registerItem(necklace, "necklace"); GameRegistry.registerItem(crystal, "crystal"); + GameRegistry.registerItem(guide, "guide"); isInitialized = true; } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index 368cde3..900039b 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -14,6 +14,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.container.GuiHandler; import darkknight.jewelrycraft.util.JewelryNBT; import net.minecraft.block.Block; @@ -103,7 +104,7 @@ public class ItemRing extends Item red = (icon.getRGB(x, y) >> 16) & 0xFF; green = (icon.getRGB(x, y) >> 8) & 0xFF; blue = icon.getRGB(x, y) & 0xFF; - if((red <= 80 && green <=80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)) + if((red <= 80 && green <= 80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)) { if(x=icon.getTileWidth()-1 && y> 16) & 0xFF; green = (icon.getRGB(x, y) >> 8) & 0xFF; blue = icon.getRGB(x, y) & 0xFF; - if((red <= 80 && green <=80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)) + if((red <= 95 && green <= 95 && blue <= 95) || (red >= 180 && green >= 180 && blue >= 180)) { if(x=icon.getTileWidth()-1 && y 45.5F) { + return ForgeDirection.DOWN; + } else if (entity.rotationPitch < -45.5F) { return ForgeDirection.UP; } + return get2dOrientation(entity); + } + + public static EntityItem dropItemStackInWorld(World worldObj, double x, double y, double z, ItemStack stack) { + float f = 0.7F; + float d0 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F; + float d1 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F; + float d2 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F; + EntityItem entityitem = new EntityItem(worldObj, x + d0, y + d1, z + d2, stack); + entityitem.delayBeforeCanPickup = 10; + if (stack.hasTagCompound()) { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); + } + worldObj.spawnEntityInWorld(entityitem); + return entityitem; + } + + public static EntityItem ejectItemInDirection(World world, double x, double y, double z, ForgeDirection direction, ItemStack stack) { + EntityItem item = BlockUtils.dropItemStackInWorld(world, x, y, z, stack); + item.motionX = direction.offsetX / 5F; + item.motionY = direction.offsetY / 5F; + item.motionZ = direction.offsetZ / 5F; + return item; + } + + public static void dropInventory(IInventory inventory, World world, double x, double y, double z) { + if (inventory == null) { return; } + for (int i = 0; i < inventory.getSizeInventory(); ++i) { + ItemStack itemStack = inventory.getStackInSlot(i); + if (itemStack != null) { + dropItemStackInWorld(world, x, y, z, itemStack); + } + } + } + + public static void dropInventory(IInventory inventory, World world, int x, int y, int z) { + dropInventory(inventory, world, x + 0.5, y + 0.5, z + 0.5); + } + + public static TileEntity getTileInDirection(TileEntity tile, ForgeDirection direction) { + int targetX = tile.xCoord + direction.offsetX; + int targetY = tile.yCoord + direction.offsetY; + int targetZ = tile.zCoord + direction.offsetZ; + return tile.worldObj.getBlockTileEntity(targetX, targetY, targetZ); + } + + public static int getFirstNonAirBlockFromTop(World world, int x, int z) { + int y; + for (y = world.getActualHeight(); world.isAirBlock(x, y - 1, z) && y > 0; y--) {} + return y; + } + + public static boolean isBlockHit(MovingObjectPosition mop, TileEntity tile) { + if (tile == null) return false; + return isBlockHit(mop, tile.xCoord, tile.yCoord, tile.zCoord); + } + + public static boolean isBlockHit(MovingObjectPosition mop, int x, int y, int z) { + if (mop == null) return false; + return mop.blockX == x && mop.blockY == y && mop.blockZ == z; + } + +} \ No newline at end of file diff --git a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java index 4fabc21..d738b36 100644 --- a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java +++ b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -40,7 +40,7 @@ public class JewelrycraftUtil modifiers.add(new ItemStack(Item.potion, 1, 8270)); //Jewels - for(int i=0; i <= 16; i++) + for(int i=0; i < 16; i++) jewel.add(new ItemStack(ItemList.crystal, 1, i)); jewel.add(new ItemStack(Block.blockRedstone)); jewel.add(new ItemStack(Block.blockLapis)); diff --git a/common/darkknight/jewelrycraft/util/PlayerUtils.java b/common/darkknight/jewelrycraft/util/PlayerUtils.java new file mode 100644 index 0000000..65b8a17 --- /dev/null +++ b/common/darkknight/jewelrycraft/util/PlayerUtils.java @@ -0,0 +1,57 @@ +package darkknight.jewelrycraft.util; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.integrated.IntegratedServer; +import cpw.mods.fml.common.FMLCommonHandler; + +/** + * Code taken from OpenBlocks + */ +public class PlayerUtils +{ + public static boolean isPlayerOp(String username) + { + username = username.toLowerCase(); + + MinecraftServer server = FMLCommonHandler.instance().getSidedDelegate().getServer(); + + // SP and LAN + if (server.isSinglePlayer()) { + if (server instanceof IntegratedServer) return server.getServerOwner().equals(username); + return server.getConfigurationManager().getOps().contains(username); + } + + // SMP + return server.getConfigurationManager().getOps().contains(username); + } + + public static NBTTagCompound getModPlayerPersistTag(EntityPlayer player, String modName) + { + + NBTTagCompound tag = player.getEntityData(); + + NBTTagCompound persistTag = null; + if (tag.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + { + persistTag = tag.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + } else + { + persistTag = new NBTTagCompound(); + tag.setCompoundTag(EntityPlayer.PERSISTED_NBT_TAG, persistTag); + } + + NBTTagCompound modTag = null; + if (persistTag.hasKey(modName)) + { + modTag = persistTag.getCompoundTag(modName); + } else + { + modTag = new NBTTagCompound(); + persistTag.setCompoundTag(modName, modTag); + } + + return modTag; + } +} \ No newline at end of file diff --git a/resources/assets/jewelrycraft/Changelog.txt b/resources/assets/jewelrycraft/Changelog.txt index 3035388..b1af1e8 100644 --- a/resources/assets/jewelrycraft/Changelog.txt +++ b/resources/assets/jewelrycraft/Changelog.txt @@ -13,6 +13,7 @@ - Balanced Villager trades - Fixed Displayer text rendering in front of everything - Added the Jewel Altar +- Added a guide TODO - Make it so you can smelt ores in the smelter diff --git a/resources/assets/jewelrycraft/lang/en_US.lang b/resources/assets/jewelrycraft/lang/en_US.lang index 41bffe7..528ba74 100644 --- a/resources/assets/jewelrycraft/lang/en_US.lang +++ b/resources/assets/jewelrycraft/lang/en_US.lang @@ -9,6 +9,7 @@ item.Jewelrycraft.mold.clayNecklace.name=Clay Necklace Mold item.Jewelrycraft.ring.name=Ring item.Jewelrycraft.necklace.name=Necklace item.Jewelrycraft.crystal.name=Crystal +item.Jewelrycraft.guide.name=Jewelrycraft Guide tile.Jewelrycraft.oreShadow.name=Shadow Ore tile.Jewelrycraft.blockShadow.name=Shadow Block tile.Jewelrycraft.glow.name=Glow @@ -19,6 +20,7 @@ tile.Jewelrycraft.jewelCraftingTable.name=Jeweler's Crafting Table tile.Jewelrycraft.altar.name=Jewel Altar itemGroup.JewelryCraft=Jewelrycraft itemGroup.Rings=Jewelrycraft Rings +itemGroup.Necklaces=Jewelrycraft Necklaces chatmessage.Jewelrycraft.molder.addedmold=Added %s to molder. chatmessage.Jewelrycraft.molder.metaliscooling=Molten metal is cooling... chatmessage.Jewelrycraft.molder.moldisempty=Mold is currently empty. diff --git a/resources/assets/jewelrycraft/textures/gui/guidePage.png b/resources/assets/jewelrycraft/textures/gui/guidePage.png new file mode 100644 index 0000000..c855048 Binary files /dev/null and b/resources/assets/jewelrycraft/textures/gui/guidePage.png differ diff --git a/resources/assets/jewelrycraft/textures/gui/guidePage1.png b/resources/assets/jewelrycraft/textures/gui/guidePage1.png new file mode 100644 index 0000000..9ffdf08 Binary files /dev/null and b/resources/assets/jewelrycraft/textures/gui/guidePage1.png differ diff --git a/resources/assets/jewelrycraft/textures/gui/guidePageFlip.png b/resources/assets/jewelrycraft/textures/gui/guidePageFlip.png new file mode 100644 index 0000000..418c472 Binary files /dev/null and b/resources/assets/jewelrycraft/textures/gui/guidePageFlip.png differ diff --git a/resources/assets/jewelrycraft/textures/gui/guidePageFlip1.png b/resources/assets/jewelrycraft/textures/gui/guidePageFlip1.png new file mode 100644 index 0000000..9a0ef55 Binary files /dev/null and b/resources/assets/jewelrycraft/textures/gui/guidePageFlip1.png differ diff --git a/resources/assets/jewelrycraft/textures/items/guide.png b/resources/assets/jewelrycraft/textures/items/guide.png new file mode 100644 index 0000000..39c7f2c Binary files /dev/null and b/resources/assets/jewelrycraft/textures/items/guide.png differ -- cgit v1.2.3