diff --git a/resources/assets/mantle/manuals/test.xml b/resources/assets/mantle/manuals/test.xml new file mode 100644 index 0000000..639fadb --- /dev/null +++ b/resources/assets/mantle/manuals/test.xml @@ -0,0 +1,165 @@ + + + + +Tinker's Log #1: + +Today is a new day. I finally left home and decided to wander around in the wilderness until I find a good place to call my home. + +Tinker's Log #2: + +I've decided to keep a log of my creations and machinations, as well as some insights into what I'm doing. I haven't actually built anything yet. There is a small cave I can board up for the night. I created a stone pickaxe affectionately called "Betsy". + + + +Tinker's Log #3: + +The night is scary. Creepers are everywhere, the zombies are banging on my door, bats block out the sky... it is not fun being alone out here. I want to hide in the corner and cry until they leave. This log doesn't help take my mind off of anything. + +Tinker's Log #4: + +Betsy didn't last long. She just crumpled into dust suddenly and the handle shattered. My parents told me this would happen and this was normal, but it still seems so wrong. If I could make the pickaxe a little better perhaps, maybe I could repair it. + + + +Tinker's Log #5: + +I've spent the past three days looking for paper and ink. Squids were easy enough to find, but the sugar cane was buried deep in a ravine next to a creeper nest. Eventually I dropped rocks on the creepers and watched them explode out of surprise. My eyebrow will grow back in time. + +Tinker's Log #6: + +Waiting on sugar cane to grow. Not much else today. + + + +Tinker's Log #7: + +I've sketched out plans for a new workbench. It's a little strange. The center of the workbench is missing, but sturdy, and there are grooves in the top for supplies. I think I will call it a "table". + +Tinker's Log #8: + +I made a few more tables with different patterns in them. They look useful for different things, so I put different materials and tools by each one. Perhaps I will come up with a use for them in time. + + + +Tinker's Log #9: + +To make tools, you need to know what you're making. The pickaxe and shovel are easy enough to make with practice, the best crafters in my village told me, but I can't seem to make any good ones. Out of frustration I punched a hole in a wooden board. And another. And a few more. By the end I had something that resembled an axe, and that gave me a few ideas... + + + +Tinker's Log #10: + +I punched holes in a few boards carefully in different shapes. I spent a lot of time making them, so they look really good. They all resemble the parts of tools that I can remember: heads, handles, bindings, pieces, and some others. They look really useful, so I placed them by a table for later. + + + +Tinker's Log #11: + +I grabbed a few of the boards and started to make tool parts using them as an outline. The parts themselves feel sturdy, and when I put them together the end result felt a lot better than Betsy did. They're made completely out of stone, something even the finest crafters could never manage. This feels like a great accomplishment. + +Tinker's Log #12: + +Perhaps making a tool completely out of stone wasn't the best idea. It didn't last very long. On the upside, instead of shattering into dust only the tip scratched off. I glued a new tip on the head and it seemed good as new. + + + +Tinker's Log #13: + +I wanted to make a few more tools, but the boards with tool shapes in them went everywhere! I ended up breaking a few out of frustration. They don't fit very well in my chest either. I took a few of them, added a few slots to the bottom of the chest, placed it by my table and called it good. + +I also named them "Patterns", the chest a "Pattern Chest". I'm still angry at them, and it took so long to make new ones... + + + +Tinker's Log #14 + +Today I learned just how hard it was to shape iron. First you have to dig it out of the earth. A wooden pickaxe will shatter the ore; this I found out the hard way. Once you do get that ore there isn't much to do with it besides throw it in the furnace. Melting the iron and the stone seems inefficient, but I do need the metal more than I care about the waste. + +I shaped a few of the bars into tools, and they felt strong. Much stronger, in fact, than the ones back at the village. I've named the pickaxe "Krug" after some of the stories Nana used to tell me at night. How I miss her... + + + +Tinker's Log #15: + +This place holds little for me now. I've packed up my things, grabbed what resources I can carry, and set off. The tables and patterns will have to stay behind. I can't possibly carry them with all the food I have. + +Tinker's Log #16: + +A week later and I've finally found some others to visit. Some of them seem nice, most don't look like me. A few of them have things I never could have dreamed of. They've pointed me at a patch of land that was quiet and secluded. There I should be able to work, for I have ideas from the journey. + + + +Tinker's Log #17: + +After three days and nights of fending off zombies, I've finally created a house. It has a few rooms, a basement, but most importantly a workshop. All of the tables and patterns I had before are here, as well as a few others I wanted to try out from the trip. + +There's a round one I can cook food with and one that's just as good as any hoe, but can chop trees or actually dig the ground up. The villagers tell me these are named "Frying Pan" and "Mattock". The Frying Pan seems heavy enough to smack creepers with. I have a sword named "Shimmer" that I want to alter somehow. + + + +Tinker's Log #18: + +One of the villagers was kind enough to give me some random things. Each one looks useful in their own right. I was lucky enough to find a few diamonds earlier, and I have a few more tools in storage. This should be fun. + + + +Tinker's Log #19: + +After some heavy experimentation, I've ended up with some things that look amazing and others that look less useful than they actually are. A diamond tip on a pickaxe makes for a wondefully hard mining tool, and an emerald on a sword hilt somehow makes it stay together longer, but some things don't do anything. + +Adding flowers to a tool does nothing; they don't even stay on the thing. Mushrooms have a similar effect, and adding more material to a tool just makes it heavier. You wouldn't think redstone would do anything. I've coated a shovel so much that it looks deep red. However, it slides through dirt as if the dirt wasn't there. + + + +Moss is also a strange one. Somehow it seems to be healing the tool, even to the point where it looks like new. + +Tinker's Log #20: + +I tried to make some tools out of gold, like the crafters in my village used to, but instead it broke the table. Some of the villages laughed at me for such an idea... if only they knew. + + + +Tinker's Log #21: + +Some of these tools are more useful than I thought. Adding blaze powder to a weapon seems to give it some kind of burning effect. Lapis has this strange quality of being able to find more materials in the same area, even if I know exactly what I'm looking at. + +Tinker's Log #22: + +I have some ideas for creating tools, but for that I need a large place to create them. The furnace is inadequate, and I need a lot of stone. Combining lava with coal and netherrack seems to instantly cook stone as I mine it, up to the point where I can bypass the furnace entirely. + + + +Tinker's Log #23: + +Today I made something strange. It's round, wooden, and doesn't look like anything I've ever seen. Someone came by and said it was a "wheel" and that they were great fun to roll around. I wonder what else it could be used for? + +Tinker's Log #24: + +I made a few more of the wheels to get some practice in. I had some fun rolling them around, rolling them in pairs, and then one ended up beside my boat. It just looked so natural I had to start putting them together. + + + +Tinker's Log #25: + +I think I'm on to something here. Combining the boat with the wheel made it work something like a minecart, only I can pull it around places. It feels a little small though. + +Tinker's Log #26: + +I have all these tools laying around with little notes on what each one does. Instead of leaving them scattered about, I think I will create one place to store them. + + +Tinker's Log #27: + +I went exploring and found some new ores today. They're colors I've never seen before, and they don't shatter on impact like iron does. I wonder what I can do with these? + +Tinker's Log #28: + +The normal furnace is nice for keeping warm, but it leaves something to be desired for processing metal. I've dug a pit and lined it with some clay, gathered lava nearby, and put ore in the center in an attempt to improve on the design. The results were quite interesting. + + +The more lava I fed into the pit the hotter the material became. Eventually the whole thing liquified. I broke open the side of the pit with a cauldron in an attempt to catch the material, but it went everywhere. There were some remnants left in the pit as well. + +Raw ore still has parts of stone in it. There must be a way to remove the excess. + + \ No newline at end of file diff --git a/resources/assets/mantle/textures/gui/book.png b/resources/assets/mantle/textures/gui/book.png new file mode 100644 index 0000000..c9007bd Binary files /dev/null and b/resources/assets/mantle/textures/gui/book.png differ diff --git a/resources/assets/mantle/textures/gui/bookcrafting.png b/resources/assets/mantle/textures/gui/bookcrafting.png new file mode 100644 index 0000000..e9ee759 Binary files /dev/null and b/resources/assets/mantle/textures/gui/bookcrafting.png differ diff --git a/resources/assets/mantle/textures/gui/bookfurnace.png b/resources/assets/mantle/textures/gui/bookfurnace.png new file mode 100644 index 0000000..cda94fb Binary files /dev/null and b/resources/assets/mantle/textures/gui/bookfurnace.png differ diff --git a/resources/assets/mantle/textures/gui/bookleft.png b/resources/assets/mantle/textures/gui/bookleft.png new file mode 100644 index 0000000..08b462d Binary files /dev/null and b/resources/assets/mantle/textures/gui/bookleft.png differ diff --git a/resources/assets/mantle/textures/gui/bookright.png b/resources/assets/mantle/textures/gui/bookright.png new file mode 100644 index 0000000..8c255a7 Binary files /dev/null and b/resources/assets/mantle/textures/gui/bookright.png differ diff --git a/resources/assets/mantle/textures/gui/tinkerbook_blue.png b/resources/assets/mantle/textures/gui/tinkerbook_blue.png new file mode 100644 index 0000000..8a1fe83 Binary files /dev/null and b/resources/assets/mantle/textures/gui/tinkerbook_blue.png differ diff --git a/resources/assets/mantle/textures/gui/tinkerbook_green.png b/resources/assets/mantle/textures/gui/tinkerbook_green.png new file mode 100644 index 0000000..e73dd2b Binary files /dev/null and b/resources/assets/mantle/textures/gui/tinkerbook_green.png differ diff --git a/resources/assets/mantle/textures/items/mantlebook_blue.png b/resources/assets/mantle/textures/items/mantlebook_blue.png new file mode 100644 index 0000000..8a1fe83 Binary files /dev/null and b/resources/assets/mantle/textures/items/mantlebook_blue.png differ diff --git a/src/mantle/books/BookData.java b/src/mantle/books/BookData.java index 10c2d18..723c341 100644 --- a/src/mantle/books/BookData.java +++ b/src/mantle/books/BookData.java @@ -1,17 +1,24 @@ package mantle.books; -import java.util.HashMap; +import org.w3c.dom.Document; public class BookData { - public final String unlocalizedName = new String(); - public final String toolTip = new String(); - public final String modID = new String(); - public String getFullUnlocalizedName(){ - return this.modID + ":" + this.unlocalizedName; - } + public final String unlocalizedName = new String(); + public final String toolTip = new String(); + public final String modID = new String(); + public final String LeftImageLocation = new String(); + public final String rightImageLocation = new String(); + public final Document doc = ManualReader.readManual("/assets/mantle/manuals/test.xml"); - - + public Document getDoc () + { + return this.doc; + } + + public String getFullUnlocalizedName () + { + return this.modID + ":" + this.unlocalizedName; + } } diff --git a/src/mantle/books/BookDataStore.java b/src/mantle/books/BookDataStore.java index 8dfc25a..301b5cb 100644 --- a/src/mantle/books/BookDataStore.java +++ b/src/mantle/books/BookDataStore.java @@ -9,17 +9,17 @@ public class BookDataStore public void addBook (BookData bd) { - int pos = data.size(); + int insertOrder = data.size(); data.put(bd.getFullUnlocalizedName(), bd); - intMap.put(pos, bd.getFullUnlocalizedName()); + intMap.put(insertOrder, bd.getFullUnlocalizedName()); } - public BookData getBookfromName (String ModID, String unlocalizedName) + public static BookData getBookfromName (String ModID, String unlocalizedName) { return getBookFromName(ModID + ":" + unlocalizedName); } - public BookData getBookFromName (String fullBookName) + public static BookData getBookFromName (String fullBookName) { return data.get(fullBookName); } @@ -29,12 +29,12 @@ public class BookDataStore return data.get(intMap.get(bookIDNum)); } - public int getIDFromName (String FullUnlocalizedName) + public static int getIDFromName (String FullUnlocalizedName) { return intMap.inverse().get(FullUnlocalizedName); } - public int getIDFromBook (BookData b) + public static int getIDFromBook (BookData b) { return getIDFromName(data.inverse().get(b)); } diff --git a/src/mantle/books/ManualReader.java b/src/mantle/books/ManualReader.java new file mode 100644 index 0000000..dbdd530 --- /dev/null +++ b/src/mantle/books/ManualReader.java @@ -0,0 +1,33 @@ +package mantle.books; + +import java.io.InputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import mantle.Mantle; + +import org.w3c.dom.Document; + +public class ManualReader +{ + static Document readManual (String location) + { + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + + try + { + InputStream stream = Mantle.class.getResourceAsStream(location); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(stream); + doc.getDocumentElement().normalize(); + return doc; + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/mantle/client/MProxyClient.java b/src/mantle/client/MProxyClient.java index 4b57745..d2af94f 100644 --- a/src/mantle/client/MProxyClient.java +++ b/src/mantle/client/MProxyClient.java @@ -1,5 +1,6 @@ package mantle.client; +import mantle.books.BookDataStore; import mantle.common.MProxyCommon; import java.util.HashMap; @@ -66,6 +67,6 @@ public class MProxyClient extends MProxyCommon private static Document getManualFromStack (ItemStack stack) { - return null; + return BookDataStore.getBookFromName(stack.getItem().getUnlocalizedName()).getDoc(); } } diff --git a/src/mantle/client/gui/GuiManual.java b/src/mantle/client/gui/GuiManual.java index 07b9ee1..e46e0df 100644 --- a/src/mantle/client/gui/GuiManual.java +++ b/src/mantle/client/gui/GuiManual.java @@ -155,8 +155,8 @@ public class GuiManual extends GuiScreen } } - private static final ResourceLocation bookRight = new ResourceLocation("tinker", "textures/gui/bookright.png"); - private static final ResourceLocation bookLeft = new ResourceLocation("tinker", "textures/gui/bookleft.png"); + private static final ResourceLocation bookRight = new ResourceLocation("mantle", "textures/gui/bookright.png"); + private static final ResourceLocation bookLeft = new ResourceLocation("mantle", "textures/gui/bookleft.png"); public void drawScreen (int par1, int par2, float par3) { diff --git a/src/mantle/debug/DebugHelper.java b/src/mantle/debug/DebugHelper.java index 0b612ac..b0003ac 100644 --- a/src/mantle/debug/DebugHelper.java +++ b/src/mantle/debug/DebugHelper.java @@ -1,5 +1,7 @@ package mantle.debug; +import org.apache.commons.lang3.StringUtils; + import mantle.player.PlayerUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; diff --git a/src/mantle/lib/client/MantleClientRegistry.java b/src/mantle/lib/client/MantleClientRegistry.java index 3dd6629..173e248 100644 --- a/src/mantle/lib/client/MantleClientRegistry.java +++ b/src/mantle/lib/client/MantleClientRegistry.java @@ -3,6 +3,7 @@ package mantle.lib.client; import java.util.HashMap; import java.util.Map; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -10,7 +11,7 @@ public class MantleClientRegistry { public static Map manualIcons = new HashMap(); public static Map recipeIcons = new HashMap(); - public static ItemStack defaultStack = new ItemStack(Item.func_150899_d(265)); + public static ItemStack defaultStack = new ItemStack(Items.iron_ingot); public static void registerManualIcon (String name, ItemStack stack) {