public void addEntry(String text, PageData link) { TextData data = new TextData(text); if(link != null) { data.action = ProtocolGoToPage.GO_TO_RTN + ":" + link.parent.name + "." + link.name; } entries.add(data); }
public static ItemStackData getItemStackData(ItemStack stack) { return getItemStackData(stack, false); }
@Override public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { float r = ((colorMultiplier >> 16) & 0xff) / 255.F; float g = ((colorMultiplier >> 8) & 0xff) / 255.F; float b = (colorMultiplier & 0xff) / 255.F; GlStateManager.color(r, g, b); if(image.item == null) { renderEngine.bindTexture(image.location); drawScaledCustomSizeModalRect(x, y, image.u, image.v, image.uw, image.vh, width, height, image.texWidth, image.texHeight); } else { GlStateManager.pushMatrix(); GlStateManager.scale(width, height, 1F); RenderHelper.enableGUIStandardItemLighting(); mc.getRenderItem().renderItemAndEffectIntoGUI(image.item.getItems().get(0), x, y); RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix(); } } }
@Override public void build(BookData book, ArrayList<BookElement> 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 static ItemStackData getItemStackData(ItemStack stack, boolean ignoreNbt) { ItemStackData data = new ItemStackData(); data.id = Item.REGISTRY.getNameForObject(stack.getItem()).toString(); data.amount = (byte) stack.getCount(); data.damage = (short) stack.getItemDamage(); if(!ignoreNbt && stack.getTagCompound() != null) { data.nbt = BookLoader.GSON.toJsonTree(stack.getTagCompound(), NBTTagCompound.class).getAsJsonObject(); } return data; }
public NonNullList<ItemStack> getItems() { if(itemListLocation != null && source.resourceExists(itemListLocation)) { try { ItemsList itemsList = BookLoader.GSON .fromJson(source.resourceToString(source.getResource(itemListLocation)), ItemsList.class); NonNullList<ItemStack> items = NonNullList.<ItemStack> withSize(itemsList.items.length, ItemStack.EMPTY); for(int i = 0; i < itemsList.items.length; i++) { items.set(i, itemsList.items[i].getItem()); } this.action = itemsList.action; return items; } catch(Exception ignored) { } } return NonNullList.<ItemStack> withSize(1, getItem()); }
private ItemStack getItem() { Item item; boolean isMissingItem = false; try { item = CommandGive.getItemByText(null, id); } catch(NumberInvalidException e) { item = Item.getItemFromBlock(Blocks.BARRIER); isMissingItem = true; } if(item == Items.AIR) { item = Item.getItemFromBlock(Blocks.BARRIER); isMissingItem = true; } ItemStack itemStack = new ItemStack(item, amount, damage); if(nbt != null) { try { itemStack.setTagCompound(JsonToNBT.getTagFromJson(filterJsonQuotes(nbt.toString()))); } catch(NBTException ignored) { } } if(isMissingItem) { NBTTagCompound display = itemStack.getOrCreateSubCompound("display"); display.setString("Name", "\u00A7rUnknown Item"); NBTTagList lore = new NBTTagList(); lore.appendTag(new NBTTagString("\u00A7r\u00A7eItem Name:")); lore.appendTag(new NBTTagString("\u00A7r\u00A7e" + id)); display.setTag("Lore", lore); } return itemStack; }
public void addEntry(String text, PageData link) { TextData data = new TextData(text); if(link != null) { data.action = ProtocolGoToPage.GO_TO_RTN + ":" + link.parent.name + "." + link.name; } entries.add(data); }
int resultY = 50; TextData tdTitle = new TextData(title); tdTitle.underlined = true; list.add(new ElementText(0, 0, GuiBook.PAGE_WIDTH, 9, new TextData[]{tdTitle})); .round(ElementItem.ITEM_SIZE_HARDCODED * ITEM_SCALE)) * j, y + SLOT_MARGIN + (SLOT_PADDING + Math .round(ElementItem.ITEM_SIZE_HARDCODED * ITEM_SCALE)) * i, ITEM_SCALE, grid[i][j] .getItems(), grid[i][j].action)); list.add(new ElementItem(resultX, resultY, ITEM_SCALE, result.getItems(), result.action));
public void itemClicked(ItemStack item) { StringActionProcessor.process(book.getItemAction(ItemStackData.getItemStackData(item, true)), this); }
public ElementListingCentered(int x, int y, int width, int height, TextData... text) { super(x, y, width, height, text); this.originalX = this.x; this.text = Lists.asList(new TextData(), this.text).toArray(new TextData[this.text.length + 2]); this.text[this.text.length - 1] = new TextData(); this.text[0].color = "dark red"; this.text[this.text.length - 1].color = "dark red"; }
public ElementListingLeft(int x, int y, int width, int height, TextData... text) { super(x, y, width, height, text); this.text = Lists.asList(new TextData(), this.text).toArray(new TextData[this.text.length + 1]); this.text[0].color = "dark red"; }
public void addTitle(ArrayList<BookElement> list, String titleText, boolean dropShadow, int y) { TextData title = new TextData(titleText); title.scale = 1.2f; title.underlined = true; title.dropshadow = dropShadow; int w = (int) Math.ceil(parent.parent.parent.fontRenderer.getStringWidth(titleText) * title.scale); int x = (GuiBook.PAGE_WIDTH - w) / 2; list.add(new ElementText(x, y, w, 24, title)); } }
public static List<TextData> getStatLines(IMaterialStats stats) { List<TextData> lineData = new ArrayList<>(); for(int i = 0; i < stats.getLocalizedInfo().size(); i++) { TextData text = new TextData(stats.getLocalizedInfo().get(i)); text.tooltip = LocUtils.convertNewlines(stats.getLocalizedDesc().get(i)).split("\n"); lineData.add(text); lineData.add(new TextData("\n")); } return lineData; }
public static List<TextData> getTraitLines(List<ITrait> traits, Material material) { List<TextData> lineData = new ArrayList<>(); for(ITrait trait : traits) { TextData text = new TextData(trait.getLocalizedName()); text.tooltip = LocUtils.convertNewlines(material.getTextColor() + trait.getLocalizedDesc()).split("\n"); text.color = TextFormatting.DARK_GRAY.getFriendlyName(); text.underlined = true; lineData.add(text); lineData.add(new TextData("\n")); } return lineData; }
public ElementText(int x, int y, int width, int height, String text) { this(x, y, width, height, new TextData(text)); }
@Override public void build(BookData book, ArrayList<BookElement> list, boolean rightSide) { addTitle(list, material.getLocalizedNameColored(), true); // the cool tools to the left/right addDisplayItems(list, rightSide ? GuiBook.PAGE_WIDTH - 18 : 0); int col_margin = 22; int top = 15; int left = rightSide ? 0 : col_margin; int y = top + 10; int x = left + 10; int w = GuiBook.PAGE_WIDTH / 2 - 10; LinkedHashSet<ITrait> allTraits = new LinkedHashSet<>(); // head stats addStatsDisplay(x, y, w, list, allTraits, MaterialTypes.HEAD); // handle addStatsDisplay(x + w, y, w - 10, list, allTraits, MaterialTypes.HANDLE); // extra y += 65 + 10 * material.getAllTraitsForStats(MaterialTypes.HEAD).size(); addStatsDisplay(x, y, w, list, allTraits, MaterialTypes.EXTRA); // inspirational quote String flavour = parent.parent.parent.strings.get(String.format("%s.flavour", material.getIdentifier())); //flavour = "How much wood could a woodchuck chuck if a woodchuck could chuck wood?"; if(flavour != null) { TextData flavourData = new TextData("\"" + flavour + "\""); flavourData.italic = true; list.add(new ElementText(x + w, y, w - 16, 60, flavourData)); } }
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)); effectData.add(new TextData("\u25CF ")); effectData.add(new TextData(e)); effectData.add(new TextData("\n"));
public void addTitle(ArrayList<BookElement> list, String title) { TextData tdTitle = new TextData(title); tdTitle.underlined = true; addTitle(list, new TextData[]{tdTitle}); }