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 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(); } } }
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; }
@Override public void build(BookData book, ArrayList<BookElement> list, boolean rightSide) { int x = GuiBook.PAGE_WIDTH / 2 - IMG_SMITHING.width / 2; int y = TITLE_HEIGHT; if(title == null || title.isEmpty()) { y = 0; } else { addTitle(list, title); } list.add(new ElementImage(x, y, IMG_SMITHING.width, IMG_SMITHING.height, IMG_SMITHING, 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(modifier != null && !modifier.id.equals("")) { list.add(new ElementItem(x + MODIFIER_X, y + MODIFIER_Y, ITEM_SCALE, modifier.getItems(), modifier.action)); } if(result != null && !result.id.equals("")) { list.add(new ElementItem(x + RESULT_X, y + RESULT_Y, ITEM_SCALE, result.getItems(), result.action)); } if(description != null && description.length > 0) { list.add(new ElementText(0, IMG_SMITHING.height + y + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - IMG_SMITHING.height - y - 5, description)); } } }
public void itemClicked(ItemStack item) { StringActionProcessor.process(book.getItemAction(ItemStackData.getItemStackData(item, true)), this); }
@Override public void build(BookData book, ArrayList<BookElement> list, boolean rightSide) { int x = GuiBook.PAGE_WIDTH / 2 - IMG_SMITHING.width / 2 - 10; int y = TITLE_HEIGHT; if(title == null || title.isEmpty()) { y = 0; } else { addTitle(list, title); } list.add(new ElementImage(x, y, IMG_SMITHING.width, IMG_SMITHING.height, IMG_SMITHING, 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(block != null && !block.id.equals("")) { list.add(new ElementItem(x + BLOCK_X, y + BLOCK_Y, BLOCK_SCALE, block.getItems(), block.action)); } if(description != null && description.length > 0) { list.add(new ElementText(0, IMG_SMITHING.height + y + 50, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - IMG_SMITHING.height - y - 50, description)); } } }
@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)); } }
.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));
GlStateManager.scale(2F, 2F, 1F); RenderHelper.enableGUIStandardItemLighting(); mc.getRenderItem().renderItemAndEffectIntoGUI(section.icon.item.getItems().get(0), 0, 0); RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix();