private void drawTally(int j, int k) { ItemHashMap<Integer> map = array.tally(); int i = 0; int n = 8; for (ItemStack is : map.keySet()) { int dx = j + 10 + (i / n) * 50; int dy = k + 30 + (i % n) * 22; ItemStack is2 = is.copy(); if (ChromaBlocks.CHROMA.match(is)) { is2 = ChromaItems.BUCKET.getStackOfMetadata(0); } else if (ChromaBlocks.RUNE.match(is)) { is2 = ChromaBlocks.RUNE.getStackOfMetadata(getElementByTick()); } else if (page == ChromaResearch.PORTALSTRUCT && Block.getBlockFromItem(is.getItem()) == Blocks.bedrock) { is2 = ChromaItems.ENDERCRYSTAL.getStackOfMetadata(1); } else if (page == ChromaResearch.TREE && Block.getBlockFromItem(is.getItem()) == ChromaBlocks.PYLON.getBlockInstance()) { is2 = ChromaTiles.POWERTREE.getCraftedProduct(); } else if (page == ChromaResearch.CLOAKTOWER && Block.getBlockFromItem(is.getItem()) == ChromaBlocks.TILEMODELLED2.getBlockInstance()) { is2 = ChromaTiles.CLOAKING.getCraftedProduct(); } api.drawItemStackWithTooltip(itemRender, fontRendererObj, is2, dx, dy); fontRendererObj.drawString(String.valueOf(map.get(is)), dx + 20, dy + 5, 0xffffff); i++; } }
protected void drawAuxGraphics(int posX, int posY) { ItemHashMap<Integer> items = this.getItemCounts(); ArrayList<ItemStack> li = new ArrayList(items.keySet()); Collections.sort(li, new AlphabeticItemComparator()); for (int i = recipeTextOffset; i < li.size(); i++) { ItemStack is = li.get(i); int num = items.get(is); String s0 = is.getDisplayName(); String s = String.format(": x%d", num); FontRenderer fr = s0.contains(FontType.OBFUSCATED.id) ? FontType.OBFUSCATED.renderer : fontRendererObj; s0 = DelegateFontRenderer.stripFlags(s0); fr.drawString( s0, posX + descX + 3, posY + descY + (fr.FONT_HEIGHT + 2) * (i - recipeTextOffset), 0xffffff); fontRendererObj.drawString( s, posX + descX + 3 + fr.getStringWidth(s0), posY + descY + (fr.FONT_HEIGHT + 2) * (i - recipeTextOffset), 0xffffff); if (i - recipeTextOffset > 9) break; } }
private void removeFound(World world, int x, int y, int z, Block b, int meta) { if (Item.getItemFromBlock(b) == null) return; ItemStack is = new ItemStack(b, 1, meta); if (b instanceof SpecialOreBlock) { is = ((SpecialOreBlock) b).getDisplayItem(world, x, y, z); } else if (ReikaBlockHelper.isOre(b, meta)) { ReikaOreHelper ore = ReikaOreHelper.getEntryByOreDict(is); ModOreList mod = ModOreList.getModOreFromOre(is); if (ore != null) { is = ore.getOreBlock(); } else if (mod != null && mod != ModOreList.CERTUSQUARTZ) { is = mod.getFirstOreBlock(); } } Integer i = found.get(is); if (i == null) i = 0; if (i > 1) found.put(is, i - 1); else found.remove(is); // ReikaJavaLibrary.pConsole("Removed "+b+":"+meta+" from cache, now have "+found.get(is)); }
private void finishDigging() { digging = false; digReady = false; coords.clear(); found.clear(); finishedDigging = true; // ReikaJavaLibrary.pConsole(found); this.syncAllData(true); this.scheduleBlockUpdate(5); // ChunkManager.instance.unloadChunks(this); }
@Override protected void writeSyncTag(NBTTagCompound NBT) { super.writeSyncTag(NBT); NBT.setBoolean("dig", digging); NBT.setBoolean("dig2", digReady); NBT.setInteger("index", index); NBT.setBoolean("finish", finishedDigging); NBTTagList li = new NBTTagList(); for (ItemStack is : found.keySet()) { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("id", Item.getIdFromItem(is.getItem())); tag.setInteger("meta", is.getItemDamage()); tag.setInteger("count", found.get(is)); li.appendTag(tag); } NBT.setTag("count", li); NBT.setBoolean("dropped", dropFlag); }
@Override protected void readSyncTag(NBTTagCompound NBT) { super.readSyncTag(NBT); digging = NBT.getBoolean("dig"); digReady = NBT.getBoolean("dig2"); finishedDigging = NBT.getBoolean("finish"); index = NBT.getInteger("index"); dropFlag = NBT.getBoolean("dropped"); found.clear(); NBTTagList li = NBT.getTagList("count", NBTTypes.COMPOUND.ID); for (Object o : li.tagList) { NBTTagCompound tag = (NBTTagCompound) o; int id = tag.getInteger("id"); int meta = tag.getInteger("meta"); int count = tag.getInteger("count"); ItemStack is = new ItemStack(Item.getItemById(id), 1, meta); found.put(is, count); } }
private void addFound(World world, int x, int y, int z, Block b, int meta) { if (b != null && Item.getItemFromBlock(b) == null) { ChromatiCraft.logger.logError("Block " + b + " has no item to drop when mined???"); return; } ItemStack is = new ItemStack(b, 1, meta); if (b instanceof SpecialOreBlock) { is = ((SpecialOreBlock) b).getDisplayItem(world, x, y, z); } else if (ReikaBlockHelper.isOre(b, meta)) { ReikaOreHelper ore = ReikaOreHelper.getEntryByOreDict(is); ModOreList mod = ModOreList.getModOreFromOre(is); if (ore != null) { is = ore.getOreBlock(); } else if (mod != null && mod != ModOreList.CERTUSQUARTZ) { is = mod.getFirstOreBlock(); } } Integer i = found.get(is); if (i == null) i = 0; found.put(is, i + 1); // ReikaJavaLibrary.pConsole("Found "+b+":"+meta+" @ "+x+","+y+","+z+"; have "+(i+1)); }
public static void loadPostCache() { for (int i = 0; i < researchList.length; i++) { ChromaResearch r = researchList[i]; if (!r.isDummiedOut()) { Collection<ItemStack> c = r.getItemStacks(); if (c != null) { for (ItemStack is : c) { if (is != null && is.getItem() != null) itemMap.put(is, r); } } Collection<CastingRecipe> crc = r.getCraftingRecipes(); for (CastingRecipe cr : crc) { cr.setFragment(r); } } } }
private PneumaticPlantHandler() { if (this.hasMod()) { try { Class ic = this.getMod().getItemClass(); Field seedf = ic.getDeclaredField("plasticPlant"); Item seed = (Item) seedf.get(null); Class bc = this.getMod().getBlockClass(); for (int i = 0; i < Plants.plantList.length; i++) { Plants p = Plants.plantList[i]; Field f = bc.getDeclaredField(p.blockField); p.block = (Block) f.get(null); p.seed = new ItemStack(seed, 1, p.seedMeta); blockMap.put(p.block, p); itemMap.put(p.seed, p); } } catch (Exception e) { e.printStackTrace(); this.logFailure(e); } } else { this.noMod(); } }
public int getNumberFound(ItemStack is) { Integer i = found.get(is); return i != null ? i.intValue() : 0; }
public List<ItemStack> getFound() { return Collections.unmodifiableList(found.sortedKeyset()); }
public static ChromaResearch getPageFor(ItemStack is) { return itemMap.get(is); }
@Override public boolean initializedProperly() { return !blockMap.isEmpty() && !itemMap.isEmpty(); }
@Override public boolean isSeedItem(ItemStack is) { return itemMap.containsKey(is); }