Reformatted tinker page for type ore to get coloured titles, and reduced the size of the icon.

This commit is contained in:
Robert Sosnitzka
2017-01-09 23:33:48 +01:00
parent 39976d1319
commit bb7a50bebb
9 changed files with 51 additions and 270 deletions

View File

@@ -24,7 +24,7 @@ public class Blocks {
// blocks and ores spawned via worldgen
public static Block basaltBlock = new BasicBlock("basalt_block", Material.ROCK, 20.0f, 35.0f, DIAMOND, PREFIX_BLOCK);
public static Block basaltBlock = new BasicBlock("basalt_block", Material.ROCK, 20.0f, 35.0f, IRON, PREFIX_BLOCK);
public static Block tiberiumOre = new BlockTiberium();
public static Block auroriumOre = new BasicBlock("aurorium_ore", Material.ROCK, 15.0f, 12f, COBALT, 0.2f, PREFIX_ORE);
public static Block prometheumOre = new BasicBlock("prometheum_ore", Material.ROCK, 20.0f, 12f, DURANITE, 0.4f, PREFIX_ORE);

View File

@@ -17,12 +17,14 @@ import java.util.List;
public class ContentOre extends TinkerPage {
public static final transient int INPUT_X = 100;
public static final transient int INPUT_X = 110;
public static final transient int INPUT_Y = 80;
public static final transient float ITEM_SCALE = 1.75F;
public static final transient float ITEM_SCALE = 1.5F;
public String title = "Ore";
public int r, g, b;
public ItemStackData input;
public TextData[] description;
public String[] informations;
@@ -33,9 +35,9 @@ public class ContentOre extends TinkerPage {
TextData tdTitle = new TextData(title);
tdTitle.underlined = true;
//list.add(new ElementText(GuiBook.PAGE_WIDTH/2, 0, GuiBook.PAGE_WIDTH, 9, new TextData[]{tdTitle}));
addTitle(list, CustomFontColor.encodeColor(0xcccccc) + title, true);
addTitle(list, CustomFontColor.encodeColor(r, g, b) + title, true);
if (input != null && !input.id.equals("")) {
list.add(new ElementItem(INPUT_X, INPUT_Y, ITEM_SCALE * 2.5f, input.getItems(), input.action));

View File

@@ -1,203 +0,0 @@
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);
public TextData[] text;
public String[] effects;
@SerializedName("modifier")
public String modifierName;
public String[] demoTool = new String[]{Util.getResource("pickaxe").toString()};
private transient IModifier modifier;
private transient List<Item> tool;
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<BookElement> 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<List<ItemStack>> 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<ItemStack> 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<TextData> 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<Material> mats = ImmutableList.<Material>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;
}
}

View File

@@ -1,48 +0,0 @@
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<BookElement> 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));
}
}
}

View File

@@ -1,5 +1,8 @@
{
"title": "Basalt",
"r": 220,
"g": 220,
"b": 220,
"input": {
"id": "taiga:basalt_block"
},
@@ -7,5 +10,10 @@
{
"text": "This is basalt. Basalt is a block, which can be found in the overworld at the top of lava lakes. If you don't want to fall into the lava you have to mine it carefully. Try to build some blocks underneath to be on the safe side."
}
],
"informations": [
"Level: Iron",
"Swims on lava",
"Used for some alloys"
]
}

View File

@@ -1,15 +1,18 @@
{
"title": "Meteorite",
"r": 35,
"g": 35,
"b": 35,
"input": {
"id": "taiga:meteorite_block"
},
"description": [
{
"text": "You have to be patient, to find meteorite in your surroundings. Many hundrets of thounsands years ago they fell from the sky. Most of them are buried under dirt and grass and you have to dig a lot."
"text": "You have to be patient, to find meteorite in your surroundings. Many thounsands years ago they fell from the sky. Most of them are buried under dirt and grass and you have to dig a lot."
}
],
"informations": [
"Deals massive damage to spiders and silverfish",
"Multiple levels"
"Level: Cobalt",
"Will be cracked sometimes"
]
}

View File

@@ -0,0 +1,20 @@
{
"title": "Obsidiorite",
"r": 34,
"g": 72,
"b": 83,
"input": {
"id": "taiga:obsidiorite_block"
},
"description": [
{
"text": "Obsidiorite is a very common block in the end. It seems that it came from the void and cooled down in cube shapes floating in the ender sky. You need to build stairs to reach that cubes."
}
],
"informations": [
"Level: Duranite",
"Will be cracked sometimes",
"Hard to break",
"Floating in the sky"
]
}

View File

@@ -1,11 +0,0 @@
{
"title": "Obsidiorite",
"input": {
"id": "taiga:obsidiorite_block"
},
"description": [
{
"text": "They are flying in the end!"
}
]
}

View File

@@ -13,5 +13,15 @@
"name": "meteorite",
"type": "taigaore",
"data": "ore/meteorite.json"
},
{
"name": "obsidiorite",
"type": "taigaore",
"data": "ore/obsidiorite.json"
},
{
"name": "basalt",
"type": "taigaore",
"data": "ore/basalt.json"
}
]