diff --git a/src/main/java/com/sosnitzka/taiga/book/ContentOres.java b/src/main/java/com/sosnitzka/taiga/book/ContentOres.java new file mode 100644 index 0000000..a8375d9 --- /dev/null +++ b/src/main/java/com/sosnitzka/taiga/book/ContentOres.java @@ -0,0 +1,206 @@ +package com.sosnitzka.taiga.book; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.gson.annotations.SerializedName; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.oredict.OreDictionary; +import slimeknights.mantle.client.book.data.BookData; +import slimeknights.mantle.client.book.data.element.ImageData; +import slimeknights.mantle.client.book.data.element.TextData; +import slimeknights.mantle.client.gui.book.GuiBook; +import slimeknights.mantle.client.gui.book.element.BookElement; +import slimeknights.mantle.client.gui.book.element.ElementImage; +import slimeknights.mantle.client.gui.book.element.ElementText; +import slimeknights.tconstruct.common.ClientProxy; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.Util; +import slimeknights.tconstruct.library.book.TinkerPage; +import slimeknights.tconstruct.library.book.elements.ElementTinkerItem; +import slimeknights.tconstruct.library.client.CustomFontColor; +import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.modifiers.IModifier; +import slimeknights.tconstruct.library.modifiers.IModifierDisplay; +import slimeknights.tconstruct.library.tools.ToolCore; +import slimeknights.tconstruct.tools.TinkerMaterials; + +import java.util.ArrayList; +import java.util.List; + +@SideOnly(Side.CLIENT) +public class ContentOres extends TinkerPage { + + public static final transient String ID = "modifier"; + + public static final transient int TEX_SIZE = 256; + //public static final transient ImageData IMG_MODIFY = new ImageData(ClientProxy.BOOK_MODIFY), 0, 0, 122, 70, TEX_SIZE, TEX_SIZE); + public static final transient ImageData IMG_SLOT_1 = new ImageData(ClientProxy.BOOK_MODIFY, 0, 75, 22, 22, TEX_SIZE, TEX_SIZE); + public static final transient ImageData IMG_SLOT_2 = new ImageData(ClientProxy.BOOK_MODIFY, 0, 97, 40, 22, TEX_SIZE, TEX_SIZE); + public static final transient ImageData IMG_SLOT_3 = new ImageData(ClientProxy.BOOK_MODIFY, 0, 119, 58, 22, TEX_SIZE, TEX_SIZE); + public static final transient ImageData IMG_SLOT_5 = new ImageData(ClientProxy.BOOK_MODIFY, 0, 141, 58, 41, TEX_SIZE, TEX_SIZE); + public static final transient ImageData IMG_TABLE = new ImageData(ClientProxy.BOOK_MODIFY, 214, 0, 42, 46, TEX_SIZE, TEX_SIZE); + + private transient IModifier modifier; + private transient List tool; + + public TextData[] text; + public String[] effects; + + @SerializedName("modifier") + public String modifierName; + public String[] demoTool = new String[]{Util.getResource("pickaxe").toString()}; + + public ContentOres() { + } + + public ContentOres(IModifier modifier) { + this.modifier = modifier; + this.modifierName = modifier.getIdentifier(); + } + + @Override + public void load() { + if (modifierName == null) { + modifierName = parent.name; + } + if (modifier == null) { + modifier = TinkerRegistry.getModifier(modifierName); + } + if (tool == null) { + tool = Lists.newArrayList(); + for (String entry : demoTool) { + Item item = Item.REGISTRY.getObject(new ResourceLocation(entry)); + if (item != null) { + tool.add(item); + } + } + } + } + + @Override + public void build(BookData book, ArrayList list, boolean rightSide) { + int color = 0xdddddd; + int inCount = 1; + ItemStack[][] inputItems = null; + if (modifier instanceof IModifierDisplay) { + IModifierDisplay modifierDisplay = (IModifierDisplay) modifier; + color = modifierDisplay.getColor(); + + // determine how many slots we need to display + List> inputList = modifierDisplay.getItems(); // cache it, can be expensive + inputItems = new ItemStack[5][]; // max size so we don't have to iterate twice + + for (int i = 0; i < 5; i++) { + inputItems[i] = new ItemStack[inputList.size()]; + } + + for (int i = 0; i < inputList.size(); i++) { + List inputs = new ArrayList<>(inputList.get(i)); + if (inputs.size() > inCount) { + inCount = inputs.size(); + } + + for (int j = 0; j < inputs.size() && j < 5; j++) { + ItemStack stack = inputs.get(j); + if (stack != null && stack.getMetadata() == OreDictionary.WILDCARD_VALUE) { + stack = stack.copy(); + stack.setItemDamage(0); + } + inputItems[j][i] = stack; + } + } + } + + addTitle(list, CustomFontColor.encodeColor(color) + modifier.getLocalizedName(), true); + + // description + int h = GuiBook.PAGE_WIDTH / 3 - 10; + list.add(new ElementText(10, 20, GuiBook.PAGE_WIDTH - 20, h, text)); + + if (effects.length > 0) { + TextData head = new TextData(parent.translate("modifier.effect")); + head.underlined = true; + list.add(new ElementText(10, 20 + h, GuiBook.PAGE_WIDTH / 2 - 5, GuiBook.PAGE_HEIGHT - h - 20, head)); + + List effectData = Lists.newArrayList(); + for (String e : effects) { + effectData.add(new TextData("\u25CF ")); + effectData.add(new TextData(e)); + effectData.add(new TextData("\n")); + } + + list.add(new ElementText(10, 30 + h, GuiBook.PAGE_WIDTH / 2 + 5, GuiBook.PAGE_HEIGHT - h - 20, effectData)); + } + + ImageData img; + switch (inCount) { + case 1: + img = IMG_SLOT_1; + break; + case 2: + img = IMG_SLOT_2; + break; + case 3: + img = IMG_SLOT_3; + break; + default: + img = IMG_SLOT_5; + } + + int imgX = GuiBook.PAGE_WIDTH / 2 + 20; + int imgY = GuiBook.PAGE_HEIGHT / 2 + 30; + + // move ot towards the center wher ewe want it, since image sice can differ + imgX = imgX + 29 - img.width / 2; + imgY = imgY + 20 - img.height / 2; + + //int[] slotX = new int[] { 7, 3, 28, 53, 49}; + //int[] slotY = new int[] {50, 24, 3, 24, 50}; + int[] slotX = new int[]{3, 21, 39, 12, 30}; + int[] slotY = new int[]{3, 3, 3, 22, 22}; + + //list.add(new ElementItemCustom(imgX + IMG_MODIFY.width/2 - 24, imgY - 25, 3f, new ItemStack(TinkerTools.toolTables, 1, BlockToolTable.TableTypes.ToolStation.meta), new ItemStack(TinkerTools.toolForge))); + + list.add(new ElementImage(imgX + (img.width - IMG_TABLE.width) / 2, imgY - 24, -1, -1, IMG_TABLE)); + list.add(new ElementImage(imgX, imgY, -1, -1, img, book.appearance.slotColor)); + + ItemStack[] demo = getDemoTools(inputItems); + + ElementTinkerItem toolItem = new ElementTinkerItem(imgX + (img.width - 16) / 2, imgY - 24, 1f, demo); + toolItem.noTooltip = true; + + list.add(toolItem); + list.add(new ElementImage(imgX + (img.width - 22) / 2, imgY - 27, -1, -1, IMG_SLOT_1, 0xffffff)); + + if (inputItems != null) { + for (int i = 0; i < inCount; i++) { + list.add(new ElementTinkerItem(imgX + slotX[i], imgY + slotY[i], 1f, inputItems[i])); + } + } + } + + protected ItemStack[] getDemoTools(ItemStack[][] inputItems) { + ItemStack[] demo = new ItemStack[tool.size()]; + + for (int i = 0; i < tool.size(); i++) { + if (tool.get(i) instanceof ToolCore) { + ToolCore core = (ToolCore) tool.get(i); + List mats = ImmutableList.of(TinkerMaterials.wood, TinkerMaterials.cobalt, TinkerMaterials.ardite, TinkerMaterials.manyullyn); + mats = mats.subList(0, core.getRequiredComponents().size()); + demo[i] = ((ToolCore) tool.get(i)).buildItemForRendering(mats); + } else if (tool != null) { + demo[i] = new ItemStack(tool.get(i)); + } + + if (demo[i] != null) { + modifier.apply(demo[i]); + } + } + + return demo; + } +} \ No newline at end of file diff --git a/src/main/java/com/sosnitzka/taiga/book/ContentSmelting.java b/src/main/java/com/sosnitzka/taiga/book/ContentSmelting.java new file mode 100644 index 0000000..835483e --- /dev/null +++ b/src/main/java/com/sosnitzka/taiga/book/ContentSmelting.java @@ -0,0 +1,85 @@ +package com.sosnitzka.taiga.book; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import slimeknights.mantle.client.book.data.BookData; +import slimeknights.mantle.client.book.data.content.PageContent; +import slimeknights.mantle.client.book.data.element.ImageData; +import slimeknights.mantle.client.book.data.element.ItemStackData; +import slimeknights.mantle.client.book.data.element.TextData; +import slimeknights.mantle.client.gui.book.GuiBook; +import slimeknights.mantle.client.gui.book.element.BookElement; +import slimeknights.mantle.client.gui.book.element.ElementImage; +import slimeknights.mantle.client.gui.book.element.ElementItem; +import slimeknights.mantle.client.gui.book.element.ElementText; + +import java.util.ArrayList; + +import static slimeknights.mantle.client.gui.book.Textures.TEX_SMELTING; + +public class ContentSmelting extends PageContent { + + public static final transient int TEX_SIZE = 128; + public static final transient ImageData IMG_SMELTING = new ImageData(TEX_SMELTING, 0, 0, 110, 114, TEX_SIZE, TEX_SIZE); + + public static final transient int INPUT_X = 5; + public static final transient int INPUT_Y = 5; + public static final transient int RESULT_X = 74; + public static final transient int RESULT_Y = 41; + public static final transient int FUEL_X = 5; + public static final transient int FUEL_Y = 77; + + public static final transient float ITEM_SCALE = 2.0F; + + public String title = "Smelting"; + public ItemStackData input; + public ItemStackData result; + public TextData[] description; + + @Override + public void build(BookData book, ArrayList list, boolean rightSide) { + int x = GuiBook.PAGE_WIDTH / 2 - IMG_SMELTING.width / 2; + int y = TITLE_HEIGHT; + + TextData tdTitle = new TextData(title); + tdTitle.underlined = true; + list.add(new ElementText(0, 0, GuiBook.PAGE_WIDTH, 9, new TextData[]{tdTitle})); + list.add(new ElementImage(x, y, IMG_SMELTING.width, IMG_SMELTING.height, IMG_SMELTING, book.appearance.slotColor)); + + if (input != null && !input.id.equals("")) { + list.add(new ElementItem(x + INPUT_X, y + INPUT_Y, ITEM_SCALE, input.getItems(), input.action)); + } + + if (result != null && !result.id.equals("")) { + list.add(new ElementItem(x + RESULT_X, y + RESULT_Y, ITEM_SCALE, result.getItems(), result.action)); + } + + list.add(new ElementItem(x + FUEL_X, y + FUEL_Y, ITEM_SCALE, getFuelsList())); + + if (description != null && description.length > 0) { + list.add(new ElementText(0, IMG_SMELTING.height + y + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - y - 5, description)); + } + } + + public ItemStack[] getFuelsList() { + //TODO ask JEI for fuel list if it is present + + ItemStack[] fuels = new ItemStack[13]; + fuels[0] = new ItemStack(Blocks.WOODEN_SLAB); + fuels[1] = new ItemStack(Blocks.PLANKS); + fuels[2] = new ItemStack(Blocks.COAL_BLOCK); + fuels[3] = new ItemStack(Items.WOODEN_PICKAXE); + fuels[4] = new ItemStack(Items.WOODEN_SWORD); + fuels[5] = new ItemStack(Items.WOODEN_HOE); + fuels[6] = new ItemStack(Items.STICK); + fuels[7] = new ItemStack(Items.COAL); + fuels[8] = new ItemStack(Items.LAVA_BUCKET); + fuels[9] = new ItemStack(Blocks.SAPLING); + fuels[10] = new ItemStack(Items.BLAZE_ROD); + fuels[11] = new ItemStack(Items.WOODEN_SHOVEL); + fuels[12] = new ItemStack(Items.WOODEN_AXE); + + return fuels; + } +} \ No newline at end of file diff --git a/src/main/java/com/sosnitzka/taiga/book/ContentTextRightImage.java b/src/main/java/com/sosnitzka/taiga/book/ContentTextRightImage.java new file mode 100644 index 0000000..aedb58b --- /dev/null +++ b/src/main/java/com/sosnitzka/taiga/book/ContentTextRightImage.java @@ -0,0 +1,48 @@ +package com.sosnitzka.taiga.book; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.mantle.client.book.data.BookData; +import slimeknights.mantle.client.book.data.content.PageContent; +import slimeknights.mantle.client.book.data.element.ImageData; +import slimeknights.mantle.client.book.data.element.TextData; +import slimeknights.mantle.client.gui.book.GuiBook; +import slimeknights.mantle.client.gui.book.element.BookElement; +import slimeknights.mantle.client.gui.book.element.ElementImage; +import slimeknights.mantle.client.gui.book.element.ElementText; + +import java.util.ArrayList; + +@SideOnly(Side.CLIENT) +public class ContentTextRightImage extends PageContent { + + public String title; + public TextData[] text1; + public TextData[] text2; + public ImageData image; + + @Override + public void build(BookData book, ArrayList list, boolean rightSide) { + int y = TITLE_HEIGHT; + + if (title == null || title.isEmpty()) { + y = 0; + } else { + addTitle(list, title); + } + + if (text1 != null && text1.length > 0) { + list.add(new ElementText(0, y, GuiBook.PAGE_WIDTH - 55, 50, text1)); + } + + if (image != null && image.location != null) { + list.add(new ElementImage(GuiBook.PAGE_WIDTH - 50, y, 50, 50, image)); + } else { + list.add(new ElementImage(GuiBook.PAGE_WIDTH - 50, y, 50, 50, ImageData.MISSING)); + } + + if (text2 != null && text2.length > 0) { + list.add(new ElementText(0, y + 55, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 55 - y, text2)); + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/bsp/pageblkinteraction.json b/src/main/resources/assets/taiga/book/en_US/bsp/pageblkinteraction.json new file mode 100644 index 0000000..c4ff182 --- /dev/null +++ b/src/main/resources/assets/taiga/book/en_US/bsp/pageblkinteraction.json @@ -0,0 +1,14 @@ +{ + "title": "Interacting with Blocks", + "input": { + "itemList": "items/records.json" + }, + "block": { + "id": "minecraft:jukebox" + }, + "description": [ + { + "text": "That's my jam!" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/bsp/pagecrafting.json b/src/main/resources/assets/taiga/book/en_US/bsp/pagecrafting.json new file mode 100644 index 0000000..e3fc391 --- /dev/null +++ b/src/main/resources/assets/taiga/book/en_US/bsp/pagecrafting.json @@ -0,0 +1,46 @@ +{ + "title": "Crafting a Thing", + "grid_size": "large", + "grid": [ + [ + {}, + { + "id": "minecraft:redstone_torch" + } + ], + [ + { + "id": "minecraft:redstone_torch" + }, + { + "id": "minecraft:quartz" + }, + { + "id": "minecraft:redstone_torch" + } + ], + [ + { + "id": "minecraft:stone" + }, + { + "id": "minecraft:stone" + }, + { + "id": "minecraft:stone" + } + ] + ], + "result": { + "id": "minecraft:comparator" + }, + "description": [ + { + "text": "This item does stuff and, of course, " + }, + { + "text": "things.", + "underlined": true + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/bsp/pagecraftingsmall.json b/src/main/resources/assets/taiga/book/en_US/bsp/pagecraftingsmall.json new file mode 100644 index 0000000..648a90c --- /dev/null +++ b/src/main/resources/assets/taiga/book/en_US/bsp/pagecraftingsmall.json @@ -0,0 +1,34 @@ +{ + "title": "Crafting a Thing", + "grid_size": "small", + "grid": [ + [ + { + "id": "minecraft:stick" + }, + { + "id": "minecraft:planks" + } + ], + [ + { + "id": "minecraft:planks" + }, + { + "id": "minecraft:stick" + } + ] + ], + "result": { + "id": "tconstruct:stencil" + }, + "description": [ + { + "text": "This item does stuff and, of course, " + }, + { + "text": "things.", + "underlined": true + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/bsp/pagesmelting.json b/src/main/resources/assets/taiga/book/en_US/bsp/pagesmelting.json new file mode 100644 index 0000000..c8b7d86 --- /dev/null +++ b/src/main/resources/assets/taiga/book/en_US/bsp/pagesmelting.json @@ -0,0 +1,14 @@ +{ + "title": "Smelting a Thing", + "input": { + "id": "minecraft:iron_ore" + }, + "result": { + "id": "minecraft:iron_ingot" + }, + "description": [ + { + "text": "Very delicious iron." + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/bsp/pagesmithing.json b/src/main/resources/assets/taiga/book/en_US/bsp/pagesmithing.json new file mode 100644 index 0000000..a6795a0 --- /dev/null +++ b/src/main/resources/assets/taiga/book/en_US/bsp/pagesmithing.json @@ -0,0 +1,33 @@ +{ + "title": "Smithing a Thing", + "input": { + "id": "minecraft:diamond_sword" + }, + "modifier": { + "id": "minecraft:enchanted_book", + "nbt": { + "ench": [ + { + "id": 16, + "lvl": 5 + } + ] + } + }, + "result": { + "id": "minecraft:diamond_sword", + "nbt": { + "ench": [ + { + "id": 16, + "lvl": 5 + } + ] + } + }, + "description": [ + { + "text": "Ow, that's sharp." + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/ores/basalt.json b/src/main/resources/assets/taiga/book/en_US/ores/basalt.json new file mode 100644 index 0000000..a03c632 --- /dev/null +++ b/src/main/resources/assets/taiga/book/en_US/ores/basalt.json @@ -0,0 +1,16 @@ +{ + "title": "Basalt", + "text1": [ + { + "text": "TAIGA adds various new blocks and ores. To get higher tiers, stats and traits you need to alloy them." + } + ], + "text2": [ + { + "text": "On the next Pages you will learn where to get these new materials and what you need to know else." + } + ], + "image": { + "file": "taiga:textures/book/ores.png" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/ores/firstwords.json b/src/main/resources/assets/taiga/book/en_US/ores/firstwords.json index cfac3fe..9e8bd4d 100644 --- a/src/main/resources/assets/taiga/book/en_US/ores/firstwords.json +++ b/src/main/resources/assets/taiga/book/en_US/ores/firstwords.json @@ -1,20 +1,11 @@ { "title": "New ores", "image": { - "file": "taiga:textures/logo_s.png" + "file": "taiga:textures/book/ores.png" }, "text": [ { - "text": "TAIGA adds various new blocks and ores. You need to combine them in different alloys to get higher tiers,1 some better stats and special traits." - }, - { - "text": "\n" - }, - { - "text": "\n" - }, - { - "text": "The ores have to be found at special places. On the next pages, you will be teached where to find the ores and how they have to be handeled." + "text": "TAIGA adds various new blocks and ores. To get higher tiers, stats and traits you need to alloy them wisely. On the next Pages you will learn where to get these new materials and what else you need to know." } ] } \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/ores/multiblock.json b/src/main/resources/assets/taiga/book/en_US/ores/multiblock.json deleted file mode 100644 index 53a0cf4..0000000 --- a/src/main/resources/assets/taiga/book/en_US/ores/multiblock.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": "structure/tank.json" -} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/en_US/ores/structure.json b/src/main/resources/assets/taiga/book/en_US/ores/structure.json deleted file mode 100644 index 1999813..0000000 --- a/src/main/resources/assets/taiga/book/en_US/ores/structure.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "title": "", - "text": [ - { - "text": "The Tinker Tank can be any size from 3x3 to 11x11, and with any height from a minimum of 3. Larger structues increase the size of the tank. In order to be a valid structure, it requires a floor and ceiling, along with a frame around the whole structure" - }, - { - "text": "The Tinker Tank can be built using any combination of seared blocks, glass, and drains. The floor and ceiling frame must be either seared blocks or drains. A single Tinker Tank controller is required. It can be placed on any layer except the ceiling, and must not be placed on the outside edges of the frame. The ceiling additionally supports slabs and stairs, even in the frame, provided they are downwards facing.", - "paragraph": true - } - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/taiga/book/sections/intro.json b/src/main/resources/assets/taiga/book/sections/intro.json index 5d3586e..f65f254 100644 --- a/src/main/resources/assets/taiga/book/sections/intro.json +++ b/src/main/resources/assets/taiga/book/sections/intro.json @@ -6,10 +6,40 @@ }, { "name": "firstwords", - "type": "text with right image etch", + "type": "image with text below", "data": "ores/firstwords.json" }, + { + "name": "basalt", + "type": "text with right image etch", + "data": "ores/basalt.json" + }, { "type": "blank" + }, + { + "name": "PageCrafter", + "type": "crafting", + "data": "bsp/pagecrafting.json" + }, + { + "name": "PageSmallCrafter", + "type": "crafting", + "data": "bsp/pagecraftingsmall.json" + }, + { + "name": "PageSmelting", + "type": "smelting", + "data": "bsp/pagesmelting.json" + }, + { + "name": "PageSmithing", + "type": "smithing", + "data": "bsp/pagesmithing.json" + }, + { + "name": "PageBlockInteraction", + "type": "block interaction", + "data": "bsp/pageblkinteraction.json" } ] \ No newline at end of file