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 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)); }
@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)); }
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(); } }