Here are the examples of the java api class net.minecraft.item.ItemStack taken from open source projects.
1. Press#register()
View license@Override public void register() throws RegistrationError, MissingIngredientError { if (this.getImprintable() == null) { return; } if (this.getOutput() == null) { return; } final ItemStack[] realInput = this.getImprintable().getItemStackSet(); final List<ItemStack> inputs = new ArrayList<ItemStack>(realInput.length); Collections.addAll(inputs, realInput); final ItemStack top = (this.getTopOptional() == null) ? null : this.getTopOptional().getItemStack(); final ItemStack bot = (this.getBotOptional() == null) ? null : this.getBotOptional().getItemStack(); final ItemStack output = this.getOutput().getItemStack(); final InscriberProcessType type = InscriberProcessType.Press; final IInscriberRecipe recipe = new InscriberRecipe(inputs, output, top, bot, type); AEApi.instance().registries().inscriber().addRecipe(recipe); }
2. ItemConduit#getDrops()
View license@Override public List<ItemStack> getDrops() { List<ItemStack> res = new ArrayList<ItemStack>(); res.add(createItem()); for (ItemStack stack : speedUpgrades.values()) { res.add(stack); } for (ItemStack stack : functionUpgrades.values()) { res.add(stack); } for (ItemStack stack : inputFilterUpgrades.values()) { res.add(stack); } for (ItemStack stack : outputFilterUpgrades.values()) { res.add(stack); } return res; }
3. DarkSteelRecipeManager#handleRepair()
View licenseprivate void handleRepair(AnvilUpdateEvent evt) { ItemStack targetStack = evt.left; ItemStack ingots = evt.right; //repair event IDarkSteelItem targetItem = (IDarkSteelItem) targetStack.getItem(); int maxIngots = targetItem.getIngotsRequiredForFullRepair(); double damPerc = (double) targetStack.getItemDamage() / targetStack.getMaxDamage(); int requiredIngots = (int) Math.ceil(damPerc * maxIngots); if (ingots.stackSize > requiredIngots) { return; } int damageAddedPerIngot = (int) Math.ceil((double) targetStack.getMaxDamage() / maxIngots); int totalDamageRemoved = damageAddedPerIngot * ingots.stackSize; ItemStack resultStack = targetStack.copy(); resultStack.setItemDamage(Math.max(0, resultStack.getItemDamage() - totalDamageRemoved)); evt.output = resultStack; evt.cost = ingots.stackSize + (int) Math.ceil(getEnchantmentRepairCost(resultStack) / 2); }
4. Inscribe#register()
View license@Override public void register() throws RegistrationError, MissingIngredientError { if (this.getImprintable() == null) { return; } if (this.getOutput() == null) { return; } final ItemStack[] realInput = this.getImprintable().getItemStackSet(); final List<ItemStack> inputs = new ArrayList<ItemStack>(realInput.length); Collections.addAll(inputs, realInput); final ItemStack top = (this.getTopOptional() == null) ? null : this.getTopOptional().getItemStack(); final ItemStack bot = (this.getBotOptional() == null) ? null : this.getBotOptional().getItemStack(); final ItemStack output = this.getOutput().getItemStack(); final InscriberProcessType type = InscriberProcessType.Inscribe; final IInscriberRecipe recipe = new InscriberRecipe(inputs, output, top, bot, type); AEApi.instance().registries().inscriber().addRecipe(recipe); }
5. ConduitRecipes#addAeRecipes()
View license@Method(modid = "appliedenergistics2") private static void addAeRecipes() { String fluix = "crystalFluix"; String pureFluix = "crystalPureFluix"; ItemStack quartzFiber = AEApi.instance().parts().partQuartzFiber.stack(1).copy(); ItemStack conduitBinder = new ItemStack(EnderIO.itemMaterial, 1, Material.CONDUIT_BINDER.ordinal()); ItemStack res = new ItemStack(EnderIO.itemMEConduit, Config.numConduitsPerRecipe / 2); addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', fluix, 'q', quartzFiber); addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', pureFluix, 'q', quartzFiber); res.stackSize = 1; addShaped(new ItemStack(EnderIO.itemMEConduit, 1, 1), "bCb", "CbC", "bCb", 'b', conduitBinder, 'C', res); }
6. InventoryUpgrades#decrStackSize()
View license@Override public ItemStack decrStackSize(int slot, int num) { ItemStack current = getStackInSlot(slot); if (current == null) { return current; } ItemStack result; ItemStack remaining; if (num >= current.stackSize) { result = current.copy(); remaining = null; } else { result = current.copy(); result.stackSize = num; remaining = current.copy(); remaining.stackSize -= num; } setInventorySlotContents(slot, remaining); return result; }
7. SlotItemHandler#getItemStackLimit()
View license@Override public int getItemStackLimit(ItemStack stack) { ItemStack maxAdd = stack.copy(); maxAdd.stackSize = maxAdd.getMaxStackSize(); ItemStack currentStack = this.getItemHandler().getStackInSlot(index); ItemStack remainder = this.getItemHandler().insertItem(index, maxAdd, true); int current = currentStack == null ? 0 : currentStack.stackSize; int added = maxAdd.stackSize - (remainder != null ? remainder.stackSize : 0); return current + added; }
8. SlotItemHandler#getItemStackLimit()
View license@Override public int getItemStackLimit(ItemStack stack) { ItemStack maxAdd = stack.copy(); maxAdd.stackSize = maxAdd.getMaxStackSize(); ItemStack currentStack = this.getItemHandler().getStackInSlot(index); ItemStack remainder = this.getItemHandler().insertItem(index, maxAdd, true); int current = currentStack == null ? 0 : currentStack.stackSize; int added = maxAdd.stackSize - (remainder != null ? remainder.stackSize : 0); return current + added; }
9. BrewingRecipeRegistryTest#init()
View license@EventHandler public void init(FMLInitializationEvent event) { if (!ENABLE) return; // The following adds a recipe that brews a piece of rotten flesh "into" a diamond sword resulting in a diamond hoe BrewingRecipeRegistry.addRecipe(new ItemStack(Items.DIAMOND_SWORD), new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.DIAMOND_HOE)); ItemStack output0 = BrewingRecipeRegistry.getOutput(new ItemStack(Items.DIAMOND_SWORD), new ItemStack(Items.ROTTEN_FLESH)); if (output0.getItem() == Items.DIAMOND_HOE) System.out.println("Recipe succefully registered and working. Diamond Hoe obtained."); // Testing if OreDictionary support is working. Register a recipe that brews a gemDiamond into a gold sword resulting in a diamond sword BrewingRecipeRegistry.addRecipe(new ItemStack(Items.GOLDEN_SWORD), "gemDiamond", new ItemStack(Items.DIAMOND_SWORD)); ItemStack output1 = BrewingRecipeRegistry.getOutput(new ItemStack(Items.GOLDEN_SWORD), new ItemStack(Items.DIAMOND)); if (output1.getItem() == Items.DIAMOND_SWORD) System.out.println("Recipe succefully registered and working. Diamond Sword obtained."); // In vanilla, brewing netherwart into a water bottle results in an awkward potion (with metadata 16). The following tests if that still happens ItemStack output2 = BrewingRecipeRegistry.getOutput(new ItemStack(Items.POTIONITEM, 1, 0), new ItemStack(Items.NETHER_WART)); if (output2 != null && output2.getItem() == Items.POTIONITEM && output2.getItemDamage() == 16) System.out.println("Vanilla behaviour still in place. Brewed Water Bottle with Nether Wart and got Awkward Potion"); }
10. GoldenEyeRechargeRecipe#getCraftingResult()
View license@Override public ItemStack getCraftingResult(InventoryCrafting inventory) { ItemStack golden = null; int enderCount = 0; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); if (stack == null) continue; Item item = stack.getItem(); if (item instanceof ItemGoldenEye) golden = stack; else if (item instanceof ItemEnderPearl) enderCount++; } if (golden == null) return null; ItemStack result = golden.copy(); result.setItemDamage(golden.getItemDamage() - enderCount * PEARL_RECHARGE); return result; }
11. ExplosiveEnchantmentsHandler#useItems()
View licenseprivate static void useItems(EntityPlayer player, int gunpowderSlot, int armorSlot, int gunpowderAmout) { if (player.capabilities.isCreativeMode) return; final InventoryPlayer inventory = player.inventory; ItemStack armor = inventory.armorItemInSlot(armorSlot); armor.damageItem(1, player); if (armor.stackSize <= 0) inventory.armorInventory[armorSlot] = null; ItemStack resource = inventory.mainInventory[gunpowderSlot]; resource.stackSize -= gunpowderAmout; if (resource.stackSize <= 0) inventory.mainInventory[gunpowderSlot] = null; }
12. UselessToolFlimFlam#execute()
View license@Override public boolean execute(EntityPlayerMP target) { Item tool = selectTool(); ItemStack dropped = new ItemStack(tool); @SuppressWarnings("unchecked") Map<Integer, EnchantmentData> enchantments = EnchantmentHelper.mapEnchantmentData(30, dropped); EnchantmentData data = CollectionUtils.getRandom(enchantments.values()); if (data == null) return false; dropped.addEnchantment(data.enchantmentobj, random.nextInt(data.enchantmentLevel) + 1); dropped.setItemDamage(dropped.getMaxDamage()); BlockUtils.dropItemStackInWorld(target.worldObj, target.posX, target.posY, target.posZ, dropped); return true; }
13. TileWorktable#onCraftingStart()
View license@Override public boolean onCraftingStart(EntityPlayer player) { if (currentRecipe == null) { return false; } ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix()); ItemStack[] inventory = InventoryUtil.getStacks(this); InventoryCraftingForestry crafting = RecipeUtil.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput()); if (crafting == null) { return false; } recipeItems = InventoryUtil.getStacks(crafting); // craft recipe should exactly match ingredients here, so no oreDict or tool matching ItemStack[] removed = InventoryUtil.removeSets(this, 1, recipeItems, player, false, false, false); if (removed == null) { return false; } // update crafting display to match the ingredients that were actually used setCraftingDisplay(crafting); return true; }
14. ItemHohlraum#getSubItems()
View license@Override public void getSubItems(Item item, CreativeTabs tabs, List list) { ItemStack empty = new ItemStack(this); setGas(empty, null); empty.setItemDamage(100); list.add(empty); ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(GasRegistry.getGas("fusionFuelDT"), ((IGasItem) filled.getItem()).getMaxGas(filled))); list.add(filled); }
15. ItemFlamethrower#getSubItems()
View license@Override public void getSubItems(Item item, CreativeTabs tabs, List list) { ItemStack empty = new ItemStack(this); setGas(empty, null); empty.setItemDamage(100); list.add(empty); ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(GasRegistry.getGas("hydrogen"), ((IGasItem) filled.getItem()).getMaxGas(filled))); list.add(filled); }
16. ItemJetpack#getSubItems()
View license@Override public void getSubItems(Item item, CreativeTabs tabs, List list) { ItemStack empty = new ItemStack(this); setGas(empty, null); empty.setItemDamage(100); list.add(empty); ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(GasRegistry.getGas("hydrogen"), ((IGasItem) filled.getItem()).getMaxGas(filled))); list.add(filled); }
17. ItemScubaTank#getSubItems()
View license@Override public void getSubItems(Item item, CreativeTabs tabs, List list) { ItemStack empty = new ItemStack(this); setGas(empty, null); empty.setItemDamage(100); list.add(empty); ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(GasRegistry.getGas("oxygen"), ((IGasItem) filled.getItem()).getMaxGas(filled))); list.add(filled); }
18. ItemQuiver#getQuiverJavelinTypes()
View license@SuppressWarnings("rawtypes") public // Storing both Strings and Integers in the same ArrayList List[] getQuiverJavelinTypes(ItemStack item) { ArrayList[] pair = new ArrayList[2]; ArrayList<String> list = new ArrayList<String>(); ArrayList<Integer> listNum = new ArrayList<Integer>(); ItemStack[] inventory = loadInventory(item); for (ItemStack i : inventory) { if (i != null && i.getItem() instanceof ItemJavelin) { String s = i.getItem().getItemStackDisplayName(i); if (!list.contains(s)) list.add(s); int n = list.indexOf(s); if (listNum.size() == n) listNum.add(0); listNum.set(n, listNum.get(n) + 1); } } pair[0] = list; pair[1] = listNum; return pair; }
19. WAILAData#anvilBody()
View license// Bodies public List<String> anvilBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { NBTTagCompound tag = accessor.getNBTData(); int tier = tag.getInteger("Tier"); currenttip.add(TFC_Core.translate("gui.tier") + " : " + tier); ItemStack storage[] = getStorage(tag, accessor.getTileEntity()); ItemStack flux = storage[TEAnvil.FLUX_SLOT]; if (flux != null && flux.getItem() == TFCItems.powder && flux.getItemDamage() == 0 && flux.stackSize > 0) currenttip.add(TFC_Core.translate("item.Powder.Flux.name") + " : " + flux.stackSize); return currenttip; }
20. WAILAData#nestBoxBody()
View licensepublic List<String> nestBoxBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { NBTTagCompound tag = accessor.getNBTData(); ItemStack storage[] = getStorage(tag, accessor.getTileEntity()); int eggCount = 0, fertEggCount = 0; for (ItemStack is : storage) { if (is != null && is.getItem() == TFCItems.egg) { if (is.hasTagCompound() && is.getTagCompound().hasKey("Fertilized")) fertEggCount++; else eggCount++; } } if (eggCount > 0) currenttip.add(TFC_Core.translate("gui.eggs") + " : " + eggCount); if (fertEggCount > 0) currenttip.add(TFC_Core.translate("gui.fertEggs") + " : " + fertEggCount); return currenttip; }
21. RecipeInputOreDict#getInputs()
View license@Override public List<ItemStack> getInputs() { List<ItemStack> ores = getOres(); // check if we have to filter the list first boolean hasInvalidEntries = false; for (ItemStack stack : ores) { if (stack.getItem() == null) { hasInvalidEntries = true; break; } } if (!hasInvalidEntries) return ores; List<ItemStack> ret = new ArrayList<ItemStack>(ores.size()); for (ItemStack stack : ores) { // ignore invalid if (stack.getItem() != null) ret.add(stack); } return Collections.unmodifiableList(ret); }
22. CommonPlayerTickHandler#isGasMaskOn()
View licensepublic static boolean isGasMaskOn(EntityPlayer player) { ItemStack tank = player.inventory.armorInventory[2]; ItemStack mask = player.inventory.armorInventory[3]; if (tank != null && mask != null) { if (tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) { ItemScubaTank scubaTank = (ItemScubaTank) tank.getItem(); if (scubaTank.getGas(tank) != null) { if (scubaTank.getFlowing(tank)) { return true; } } } } return false; }
23. InventoryBin#removeStack()
View licensepublic ItemStack removeStack() { ItemStack stack = getStack(); if (stack == null) { return null; } setItemCount(getItemCount() - stack.stackSize); return stack.copy(); }
24. ItemBlockGasTank#getSubItems()
View license@Override public void getSubItems(Item item, CreativeTabs tabs, List list) { ItemStack empty = new ItemStack(this); setGas(empty, null); empty.setItemDamage(100); list.add(empty); for (Gas type : GasRegistry.getRegisteredGasses()) { if (type.isVisible()) { ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(type, ((IGasItem) filled.getItem()).getMaxGas(filled))); list.add(filled); } } }
25. GuiIOPort#drawBG()
View license@Override public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { super.drawBG(offsetX, offsetY, mouseX, mouseY); final IDefinitions definitions = AEApi.instance().definitions(); for (final ItemStack cell1kStack : definitions.items().cell1k().maybeStack(1).asSet()) { this.drawItem(offsetX + 66 - 8, offsetY + 17, cell1kStack); } for (final ItemStack driveStack : definitions.blocks().drive().maybeStack(1).asSet()) { this.drawItem(offsetX + 94 + 8, offsetY + 17, driveStack); } }
26. P2PTunnelRegistry#getModItem()
View license@Nullable private ItemStack getModItem(final String modID, final String name, final int meta) { final ItemStack myItemStack = GameRegistry.findItemStack(modID, name, 1); if (myItemStack == null) { return null; } myItemStack.setItemDamage(meta); return myItemStack; }
27. InWorldToolOperationResult#getBlockOperationResult()
View licensepublic static InWorldToolOperationResult getBlockOperationResult(final ItemStack[] items) { final List<ItemStack> temp = new ArrayList<ItemStack>(); ItemStack b = null; for (final ItemStack l : items) { if (b == null) { final Block bl = Block.getBlockFromItem(l.getItem()); if (bl != null && !(bl instanceof BlockAir)) { b = l; continue; } } temp.add(l); } return new InWorldToolOperationResult(b, temp); }
28. AESharedNBT#createFromCompound()
View licenseprivate static AESharedNBT createFromCompound(final Item itemID, final int damageValue, final NBTTagCompound c) { final AESharedNBT x = new AESharedNBT(itemID, damageValue); // c.getTags() for (final Object o : c.func_150296_c()) { final String name = (String) o; x.setTag(name, c.getTag(name).copy()); } x.hash = Platform.NBTOrderlessHash(c); final ItemStack isc = new ItemStack(itemID, 1, damageValue); isc.setTagCompound(c); x.comp = AEApi.instance().registries().specialComparison().getSpecialComparison(isc); return x; }
29. ItemDarkSteelArmor#getSubItems()
View license@SuppressWarnings({ "unchecked", "rawtypes" }) @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { ItemStack is = new ItemStack(this); par3List.add(is); is = new ItemStack(this); EnergyUpgrade.EMPOWERED_FOUR.writeToItem(is); EnergyUpgrade.setPowerFull(is); Iterator<IDarkSteelUpgrade> iter = DarkSteelRecipeManager.instance.recipeIterator(); while (iter.hasNext()) { IDarkSteelUpgrade upgrade = iter.next(); if (!(upgrade instanceof EnergyUpgrade) && upgrade.canAddToItem(is)) { upgrade.writeToItem(is); } } par3List.add(is); }
30. ItemDarkSteelPickaxe#getSubItems()
View license@Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { ItemStack is = new ItemStack(this); par3List.add(is); is = new ItemStack(this); EnergyUpgrade.EMPOWERED_FOUR.writeToItem(is); EnergyUpgrade.setPowerFull(is); TravelUpgrade.INSTANCE.writeToItem(is); SpoonUpgrade.INSTANCE.writeToItem(is); par3List.add(is); }
31. ItemDarkSteelSword#getSubItems()
View license@Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { ItemStack is = new ItemStack(this); par3List.add(is); is = new ItemStack(this); EnergyUpgrade.EMPOWERED_FOUR.writeToItem(is); EnergyUpgrade.setPowerFull(is); TravelUpgrade.INSTANCE.writeToItem(is); par3List.add(is); }
32. AbstractMachineEntity#decrStackSize()
View license@Override public ItemStack decrStackSize(int fromSlot, int amount) { ItemStack fromStack = inventory[fromSlot]; if (fromStack == null) { return null; } if (fromStack.stackSize <= amount) { inventory[fromSlot] = null; return fromStack; } ItemStack result = new ItemStack(fromStack.getItem(), amount, fromStack.getItemDamage()); if (fromStack.stackTagCompound != null) { result.stackTagCompound = (NBTTagCompound) fromStack.stackTagCompound.copy(); } fromStack.stackSize -= amount; return result; }
33. VanillaSmeltingRecipe#getCompletedResult()
View license@Override public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) { ItemStack output = null; int inputCount = 0; for (MachineRecipeInput ri : inputs) { if (ri != null && ri.item != null && output == null) { output = FurnaceRecipes.smelting().getSmeltingResult(ri.item); } } if (output == null) { return new ResultStack[0]; } int stackSize = output.stackSize; output = OreDictionaryPreferences.instance.getPreferred(output); ItemStack result = output.copy(); result.stackSize = stackSize; result.stackSize = result.stackSize * getNumInputs(inputs); return new ResultStack[] { new ResultStack(result) }; }
34. OptionUtilities#drawIcons()
View license@Override public void drawIcons() { int x = buttonX(); LayoutManager.drawIcon(x + 4, 4, new Image(120, 24, 12, 12)); x += 24; LayoutManager.drawIcon(x + 4, 4, new Image(120, 12, 12, 12)); x += 24; LayoutManager.drawIcon(x + 4, 4, new Image(168, 24, 12, 12)); x += 24; LayoutManager.drawIcon(x + 4, 4, new Image(144, 12, 12, 12)); x += 24; LayoutManager.drawIcon(x + 4, 4, new Image(180, 24, 12, 12)); x += 24; LayoutManager.drawIcon(x + 4, 4, new Image(132, 12, 12, 12)); x += 24; RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableRescaleNormal(); ItemStack sword = new ItemStack(Items.diamond_sword); sword.addEnchantment(Enchantment.sharpness, 1); GuiContainerManager.drawItem(x + 2, 2, sword); x += 24; GuiContainerManager.drawItem(x + 2, 2, new ItemStack(Items.potionitem)); x += 24; GuiContainerManager.drawItem(x + 2, 2, new ItemStack(Blocks.stone)); x += 24; }
35. BlockOre2#onBlockExploded()
View license/*public boolean removeBlockByPlayer(World world, EntityPlayer player, int i, int j, int k) { if(player != null) { player.addStat(StatList.mineBlockStatArray[blockID], 1); player.addExhaustion(0.075F); } MovingObjectPosition objectMouseOver = Helper.getMouseOverObject(player, world); if(objectMouseOver == null) { return false; } int side = objectMouseOver.sideHit; int sub = objectMouseOver.subHit; if(true) { ItemChisel.CreateSlab(world, i, j, k, this.blockID, (byte) world.getBlockMetadata(i, j, k), side, mod_TFC_Core.stoneMinedSlabs.blockID); TileEntityPartial te = (TileEntityPartial) world.getTileEntity(i,j,k); int id = te.TypeID; int meta = te.MetaID; ItemChisel.CreateSlab(world, i, j, k, te.TypeID, te.MetaID, side, mod_TFC_Core.stoneMinedSlabs.blockID); te = (TileEntityPartial) world.getTileEntity(i, j, k); Block.blocksList[id].harvestBlock(world, player, i, j, k, meta); if(te != null) { long extraX = (te.extraData) & 0xf; long extraY = (te.extraData >> 4) & 0xf; long extraZ = (te.extraData >> 8) & 0xf; long extraX2 = (te.extraData >> 12) & 0xf; long extraY2 = (te.extraData >> 16) & 0xf; long extraZ2 = (te.extraData >> 20) & 0xf; if(extraX+extraY+extraZ+extraX2+extraY2+extraZ2 > 8) return world.setBlock(i, j, k, 0); } else return world.setBlock(i, j, k, 0); } return false; }*/ @Override public void onBlockExploded(World world, int x, int y, int z, Explosion exp) { Random random = new Random(); ItemStack itemstack; int meta = world.getBlockMetadata(x, y, z); itemstack = new ItemStack(TFCItems.oreChunk, 1, meta + 16); if (meta == 5) itemstack = kimberliteGemSpawn(); else if (meta == 13) itemstack = new ItemStack(TFCItems.powder, 1 + random.nextInt(3), 4); if (itemstack != null) dropBlockAsItem(world, x, y, z, itemstack); onBlockDestroyedByExplosion(world, x, y, z, exp); }
36. ContainerTFC#areCompoundsEqual()
View licensepublic static boolean areCompoundsEqual(ItemStack is1, ItemStack is2) { ItemStack is3 = is1.copy(); ItemStack is4 = is2.copy(); NBTTagCompound is3Tags = is3.getTagCompound(); NBTTagCompound is4Tags = is4.getTagCompound(); if (is3Tags == null) return is4Tags == null || is4Tags.hasNoTags(); if (is4Tags == null) return is3Tags.hasNoTags(); float temp3 = TFC_ItemHeat.getTemp(is1); float temp4 = TFC_ItemHeat.getTemp(is2); is3Tags.removeTag("temp"); is4Tags.removeTag("temp"); return is3Tags.equals(is4Tags) && Math.abs(temp3 - temp4) < 5; }
37. TileEntityOsmiumCompressor#getItemGas()
View license@Override public GasStack getItemGas(ItemStack itemstack) { int amount = 0; for (ItemStack ore : OreDictionary.getOres("ingotOsmium")) { if (ore.isItemEqual(itemstack)) { return new GasStack(GasRegistry.getGas("liquidOsmium"), 200); } } for (ItemStack ore : OreDictionary.getOres("blockOsmium")) { if (ore.isItemEqual(itemstack)) { return new GasStack(GasRegistry.getGas("liquidOsmium"), 1800); } } return null; }
38. AuthorCmd#execute()
View license@Override public void execute(String[] args) throws Cmd.Error { if (args.length == 0) syntaxError(); if (!mc.thePlayer.capabilities.isCreativeMode) error("Creative mode only."); ItemStack item = mc.thePlayer.inventory.getCurrentItem(); if (item == null || Item.getIdFromItem(item.getItem()) != 387) error("You are not holding a written book in your hand."); String author = args[0]; for (int i = 1; i < args.length; i++) author += " " + args[i]; item.setTagInfo("author", new NBTTagString(author)); }
39. RenameCmd#execute()
View license@Override public void execute(String[] args) throws Error { if (!mc.thePlayer.capabilities.isCreativeMode) error("Creative mode only."); if (args.length == 0) syntaxError(); String message = args[0]; for (int i = 1; i < args.length; i++) message += " " + args[i]; message = message.replace("$", "").replace("", "$"); ItemStack item = mc.thePlayer.inventory.getCurrentItem(); if (item == null) error("There is no item in your hand."); item.setStackDisplayName(message); wurst.chat.message("Renamed item to \"" + message + "r\"."); }
40. RepairCmd#execute()
View license@Override public void execute(String[] args) throws Error { if (args.length > 0) syntaxError(); // check for creative mode EntityPlayerSP player = mc.thePlayer; if (!player.capabilities.isCreativeMode) error("Creative mode only."); // validate item ItemStack item = player.inventory.getCurrentItem(); if (item == null) error("You need an item in your hand."); if (!item.isItemStackDamageable()) error("This item can't take damage."); if (!item.isItemDamaged()) error("This item is not damaged."); // repair item item.setItemDamage(0); player.sendQueue.addToSendQueue(new C10PacketCreativeInventoryAction(36 + player.inventory.currentItem, item)); }
41. InventoryImpl#decrStackSize()
View license@Override public ItemStack decrStackSize(int fromSlot, int amount) { if (inventory == null) { return null; } if (fromSlot < 0 || fromSlot >= inventory.length) { return null; } ItemStack item = inventory[fromSlot]; if (item == null) { return null; } if (item.stackSize <= amount) { ItemStack result = item.copy(); inventory[fromSlot] = null; return result; } item.stackSize -= amount; return item.copy(); }
42. TileEnchanter#decrStackSize()
View license@Override public ItemStack decrStackSize(int slot, int amount) { if (amount <= 0 || slot < 0 || slot >= inv.length || inv[slot] == null) { return null; } ItemStack fromStack = inv[slot]; if (fromStack == null) { return null; } if (fromStack.stackSize <= amount) { inv[slot] = null; return fromStack; } ItemStack result = new ItemStack(fromStack.getItem(), amount, fromStack.getItemDamage()); if (fromStack.stackTagCompound != null) { result.stackTagCompound = (NBTTagCompound) fromStack.stackTagCompound.copy(); } fromStack.stackSize -= amount; return result; }
43. TileCapacitorBank#doDecrStackSize()
View licensepublic ItemStack doDecrStackSize(int fromSlot, int amount) { if (fromSlot < 0 || fromSlot >= inventory.length) { return null; } ItemStack item = inventory[fromSlot]; if (item == null) { return null; } if (item.stackSize <= amount) { ItemStack result = item.copy(); inventory[fromSlot] = null; return result; } item.stackSize -= amount; return item.copy(); }
44. AbstractSoulBinderRecipe#getCompletedResult()
View license@Override public ResultStack[] getCompletedResult(float randomChance, MachineRecipeInput... inputs) { String mobType = null; for (MachineRecipeInput input : inputs) { if (input != null && EnderIO.itemSoulVessel.containsSoul(input.item)) { mobType = EnderIO.itemSoulVessel.getMobTypeFromStack(input.item); } } if (!getSupportedSouls().contains(mobType)) { return new ResultStack[0]; } ItemStack resultStack = getOutputStack(mobType); ItemStack soulVessel = new ItemStack(EnderIO.itemSoulVessel); return new ResultStack[] { new ResultStack(soulVessel), new ResultStack(resultStack) }; }
45. SoulBinderSpawnerRecipe#getCompletedResult()
View license@Override public ResultStack[] getCompletedResult(float randomChance, MachineRecipeInput... inputs) { String mobType = null; for (MachineRecipeInput input : inputs) { if (input != null && EnderIO.itemSoulVessel.containsSoul(input.item)) { mobType = EnderIO.itemSoulVessel.getMobTypeFromStack(input.item); } } if (mobType == null) { return new ResultStack[0]; } ItemStack spawner = EnderIO.itemBrokenSpawner.createStackForMobType(mobType); if (spawner == null) { return new ResultStack[0]; } ItemStack soulVessel = new ItemStack(EnderIO.itemSoulVessel); return new ResultStack[] { new ResultStack(soulVessel), new ResultStack(spawner) }; }
46. TileVacuumChest#decrStackSize()
View license@Override public ItemStack decrStackSize(int fromSlot, int amount) { ItemStack fromStack = inv[fromSlot]; if (fromStack == null) { return null; } if (fromStack.stackSize <= amount) { inv[fromSlot] = null; return fromStack; } ItemStack result = new ItemStack(fromStack.getItem(), amount, fromStack.getItemDamage()); if (fromStack.stackTagCompound != null) { result.stackTagCompound = (NBTTagCompound) fromStack.stackTagCompound.copy(); } fromStack.stackSize -= amount; return result; }
47. BeekeepingLogic#doProduction()
View licenseprivate static void doProduction(IBee queen, IBeeHousing beeHousing, IBeeListener beeListener) { // Produce and add stacks ItemStack[] products = queen.produceStacks(beeHousing); if (products == null) { return; } beeListener.wearOutEquipment(1); IBeeHousingInventory beeInventory = beeHousing.getBeeInventory(); for (ItemStack stack : products) { beeInventory.addProduct(stack, false); } }
48. AlleleBeeSpecies#getResearchSuitability()
View license/* RESEARCH */ @Override public float getResearchSuitability(ItemStack itemstack) { if (itemstack == null) { return 0f; } for (ItemStack stack : productChances.keySet()) { if (stack.isItemEqual(itemstack)) { return 1.0f; } } for (ItemStack stack : specialtyChances.keySet()) { if (stack.isItemEqual(itemstack)) { return 1.0f; } } return super.getResearchSuitability(itemstack); }
49. WoodAccess#getStack()
View license@Override public ItemStack getStack(IWoodType woodType, WoodBlockKind woodBlockKind, boolean fireproof) { if (woodBlockKind == WoodBlockKind.DOOR) { fireproof = true; } WoodMap woodMap = woodMaps.get(woodBlockKind); ItemStack itemStack = woodMap.getItem(fireproof).get(woodType); if (itemStack == null) { Log.error("No stack found for {} {} {}", woodType, woodMap.getName(), fireproof ? "fireproof" : ""); return null; } return itemStack.copy(); }
50. FluidHelper#drainContainers()
View licensepublic static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot) { ItemStack input = inv.getStackInSlot(inputSlot); if (input == null) { return false; } ItemStack drainedItemSimulated = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, false); if (drainedItemSimulated == null) { return false; } if (input.stackSize == 1 || drainedItemSimulated.stackSize == 0) { ItemStack drainedItem = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, true); if (drainedItem != null) { if (drainedItem.stackSize > 0) { inv.setInventorySlotContents(inputSlot, drainedItem); } else { inv.decrStackSize(inputSlot, 1); } return true; } } return false; }
51. GuiAlyzer#drawMutationInfo()
View licensepublic void drawMutationInfo(IMutation combination, IAllele species, int x, IBreedingTracker breedingTracker) { Map<String, ItemStack> iconStacks = combination.getRoot().getAlyzerPlugin().getIconStacks(); ItemStack partnerBee = iconStacks.get(combination.getPartner(species).getUID()); widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), partnerBee)); drawProbabilityArrow(combination, guiLeft + x + 18, guiTop + textLayout.getLineY() + 4, breedingTracker); IAllele result = combination.getTemplate()[EnumBeeChromosome.SPECIES.ordinal()]; ItemStack resultBee = iconStacks.get(result.getUID()); widgetManager.add(new ItemStackWidget(widgetManager, x + 33, textLayout.getLineY(), resultBee)); }
52. ContainerWorktable#onCraftMatrixChanged()
View license// Fired when SlotCraftMatrix detects a change. // Direct changes to the underlying inventory are not detected, only slot changes. @Override public void onCraftMatrixChanged(IInventory iinventory, int slot) { if (slot >= craftMatrix.getSizeInventory()) { return; } ItemStack stack = iinventory.getStackInSlot(slot); ItemStack currentStack = craftMatrix.getStackInSlot(slot); if (!ItemStackUtil.isIdenticalItem(stack, currentStack)) { craftMatrix.setInventorySlotContents(slot, stack); } }
53. InfuserMixtureManager#getSeasoned()
View license@Override public ItemStack getSeasoned(ItemStack base, ItemStack[] ingredients) { InfuserMixture[] mixtures = getMatchingMixtures(ingredients); List<IBeverageEffect> effects = BeverageEffect.loadEffects(base); int weight = 0; int meta = 0; for (InfuserMixture mixture : mixtures) { effects.add(mixture.getEffect()); if (mixture.getWeight() > weight) { weight = mixture.getWeight(); meta = mixture.getMeta(); } } ItemStack seasoned = base.copy(); seasoned.setItemDamage(meta); BeverageEffect.saveEffects(seasoned, effects); return seasoned; }
54. AlleleButterflySpecies#getResearchSuitability()
View license@Override public float getResearchSuitability(ItemStack itemstack) { if (itemstack == null) { return 0f; } if (itemstack.getItem() == Items.GLASS_BOTTLE) { return 0.9f; } for (ItemStack stack : butterflyLoot.keySet()) { if (stack.isItemEqual(itemstack)) { return 1.0f; } } for (ItemStack stack : caterpillarLoot.keySet()) { if (stack.isItemEqual(itemstack)) { return 1.0f; } } return super.getResearchSuitability(itemstack); }
55. CommandDuplicate#processCommandPlayer()
View license@Override public void processCommandPlayer(EntityPlayerMP player, String[] args) { ItemStack stack = player.getCurrentEquippedItem(); if (stack == null) throw new TranslatedCommandException("No item equipped"); int stackSize = 0; if (args.length > 0) stackSize = parseInt(player, args[0]); ItemStack newStack = stack.copy(); if (stackSize > 0) newStack.stackSize = stackSize; PlayerUtil.give(player, newStack); }
56. CommandRename#processCommandPlayer()
View license@Override public void processCommandPlayer(EntityPlayerMP sender, String[] args) { if (args.length == 0) throw new TranslatedCommandException(getCommandUsage(sender)); ItemStack is = sender.inventory.getCurrentItem(); if (is == null) throw new TranslatedCommandException("You are not holding a valid item."); StringBuilder sb = new StringBuilder(); for (String arg : args) { sb.append(arg + " "); } is.setStackDisplayName(sb.toString().trim()); }
57. LayerHeldItem#doRenderLayer()
View licensepublic void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { boolean flag = entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT; ItemStack itemstack = flag ? entitylivingbaseIn.getHeldItemOffhand() : entitylivingbaseIn.getHeldItemMainhand(); ItemStack itemstack1 = flag ? entitylivingbaseIn.getHeldItemMainhand() : entitylivingbaseIn.getHeldItemOffhand(); if (itemstack != null || itemstack1 != null) { GlStateManager.pushMatrix(); if (this.livingEntityRenderer.getMainModel().isChild) { float f = 0.5F; GlStateManager.translate(0.0F, 0.625F, 0.0F); GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 0.0F); GlStateManager.scale(0.5F, 0.5F, 0.5F); } this.renderHeldItem(entitylivingbaseIn, itemstack1, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT); this.renderHeldItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT); GlStateManager.popMatrix(); } }
58. InventoryPlayer#decrStackSize()
View license/** * Removes up to a specified number of items from an inventory slot and returns them in a new stack. */ @Nullable public ItemStack decrStackSize(int index, int count) { ItemStack[] aitemstack = null; for (ItemStack[] aitemstack1 : this.allInventories) { if (index < aitemstack1.length) { aitemstack = aitemstack1; break; } index -= aitemstack1.length; } return aitemstack != null && aitemstack[index] != null ? ItemStackHelper.getAndSplit(aitemstack, index, count) : null; }
59. InventoryPlayer#setInventorySlotContents()
View license/** * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). */ public void setInventorySlotContents(int index, @Nullable ItemStack stack) { ItemStack[] aitemstack = null; for (ItemStack[] aitemstack1 : this.allInventories) { if (index < aitemstack1.length) { aitemstack = aitemstack1; break; } index -= aitemstack1.length; } if (aitemstack != null) { aitemstack[index] = stack; } }
60. InventoryPlayer#getStackInSlot()
View license/** * Returns the stack in the given slot. */ @Nullable public ItemStack getStackInSlot(int index) { ItemStack[] aitemstack = null; for (ItemStack[] aitemstack1 : this.allInventories) { if (index < aitemstack1.length) { aitemstack = aitemstack1; break; } index -= aitemstack1.length; } return aitemstack == null ? null : aitemstack[index]; }
61. SlotMerchantResult#doTrade()
View licenseprivate boolean doTrade(MerchantRecipe trade, ItemStack firstItem, ItemStack secondItem) { ItemStack itemstack = trade.getItemToBuy(); ItemStack itemstack1 = trade.getSecondItemToBuy(); if (firstItem != null && firstItem.getItem() == itemstack.getItem() && firstItem.stackSize >= itemstack.stackSize) { if (itemstack1 != null && secondItem != null && itemstack1.getItem() == secondItem.getItem() && secondItem.stackSize >= itemstack1.stackSize) { firstItem.stackSize -= itemstack.stackSize; secondItem.stackSize -= itemstack1.stackSize; return true; } if (itemstack1 == null && secondItem == null) { firstItem.stackSize -= itemstack.stackSize; return true; } } return false; }
62. UpgradeCapBankRecipe#getCraftingResult()
View license@Override public ItemStack getCraftingResult(InventoryCrafting var1) { long energy = 0; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { ItemStack st = var1.getStackInRowAndColumn(x, y); if (st != null) { energy += PowerHandlerUtil.getStoredEnergyForItem(st); } } } ItemStack res = super.getCraftingResult(var1); PowerHandlerUtil.setStoredEnergyForItem(res, (int) Math.min(Integer.MAX_VALUE, energy)); return res; }
63. ItemPotterySmallVessel#loadBagInventory()
View license@Override public ItemStack[] loadBagInventory(ItemStack is) { ItemStack[] bag = new ItemStack[4]; if (is != null && is.hasTagCompound() && is.getTagCompound().hasKey("Items")) { NBTTagList nbttaglist = is.getTagCompound().getTagList("Items", 10); for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < 4) bag[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } else return null; return bag; }
64. SoulBinderSpawnerRecipe#isValidInput()
View license@Override public boolean isValidInput(MachineRecipeInput input) { if (input == null || input.item == null) { return false; } int slot = input.slotNumber; ItemStack item = input.item; if (slot == 0) { String mobType = EnderIO.itemSoulVessel.getMobTypeFromStack(item); return mobType != null && !EnderIO.blockPoweredSpawner.isBlackListed(mobType); } if (slot == 1) { return item.getItem() == EnderIO.itemBrokenSpawner; } return false; }
65. AbstractSoulBinderRecipe#isValidInput()
View license@Override public boolean isValidInput(MachineRecipeInput input) { if (input == null || input.item == null) { return false; } int slot = input.slotNumber; ItemStack item = input.item; if (slot == 0) { String type = EnderIO.itemSoulVessel.getMobTypeFromStack(item); return getSupportedSouls().contains(type); } if (slot == 1) { return item.isItemEqual(getInputStack()); } return false; }
66. TileSliceAndSplice#isValidInputForAlloyRecipe()
View licenseprivate boolean isValidInputForAlloyRecipe(int slot, ItemStack itemstack, int numSlotsFilled, List<IMachineRecipe> recipes) { ItemStack[] resultInv = new ItemStack[slotDefinition.getNumInputSlots()]; for (int i = slotDefinition.getMinInputSlot(); i <= slotDefinition.getMaxInputSlot(); i++) { if (i >= 0 && i < inventory.length && i != axeIndex && i != shearsIndex) { if (i == slot) { resultInv[i] = itemstack; } else { resultInv[i] = inventory[i]; } } } for (IMachineRecipe recipe : recipes) { if (recipe instanceof ManyToOneMachineRecipe) { if (((ManyToOneMachineRecipe) recipe).isValidRecipeComponents(resultInv)) { return true; } } } return false; }
67. OreDictionaryRecipeInput#getEquivelentInputs()
View license@Override public ItemStack[] getEquivelentInputs() { ArrayList<ItemStack> res = OreDictionary.getOres(oreId); if (res == null || res.isEmpty()) { return null; } ItemStack[] res2 = res.toArray(new ItemStack[res.size()]); for (int i = 0; i < res.size(); ++i) { res2[i] = res2[i].copy(); res2[i].stackSize = getInput().stackSize; } return res2; }
68. BasicManyToOneRecipe#isValidRecipeComponents()
View license@Override public boolean isValidRecipeComponents(ItemStack... items) { List<RecipeInput> inputs = new ArrayList<RecipeInput>(Arrays.asList(recipe.getInputs())); for (ItemStack is : items) { if (is != null) { RecipeInput remove = null; for (RecipeInput ri : inputs) { if (ri.isInput(is)) { remove = ri; break; } } if (remove != null) { inputs.remove(remove); } else { return false; } } } return true; }
69. ContainerCapacitorBank#mergeItemStackIntoArmor()
View licenseprivate boolean mergeItemStackIntoArmor(EntityPlayer entityPlayer, ItemStack origStack, int slotIndex) { if (origStack == null || !(origStack.getItem() instanceof ItemArmor)) { return false; } ItemArmor armor = (ItemArmor) origStack.getItem(); int index = 3 - armor.armorType; ItemStack[] ai = entityPlayer.inventory.armorInventory; if (ai[index] == null) { ai[index] = origStack.copy(); origStack.stackSize = 0; return true; } return false; }
70. PaintSourceValidator#removeFromList()
View licenseprotected void removeFromList(RecipeInput input, List<RecipeInput> list) { ItemStack inStack = input.getInput(); if (inStack == null) { return; } RecipeInput toRemove = null; for (RecipeInput in : list) { if (ItemUtil.areStacksEqual(inStack, in.getInput())) { toRemove = in; break; } } if (toRemove != null) { list.remove(toRemove); } }
71. MachineRecipeInput#readFromNBT()
View licensepublic static MachineRecipeInput readFromNBT(NBTTagCompound root) { int slotNum = root.getInteger("slotNum"); ItemStack item = null; FluidStack fluid = null; if (root.hasKey("itemStack")) { NBTTagCompound stackRoot = root.getCompoundTag("itemStack"); item = ItemStack.loadItemStackFromNBT(stackRoot); } else if (root.hasKey("fluidStack")) { NBTTagCompound stackRoot = root.getCompoundTag("fluidStack"); fluid = FluidStack.loadFluidStackFromNBT(stackRoot); } return new MachineRecipeInput(slotNum, item, fluid); }
72. NormalInventory#extractItem()
View license@Override public int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int count) { ISidedInventory inv = ni.getInventoryRecheck(); int side = ni.getInventorySide(); int[] slotIndices = inv.getAccessibleSlotsFromSide(side); if (slotIndices == null || slot >= slotIndices.length) { return 0; } int invSlot = slotIndices[slot]; ItemStack stack = inv.getStackInSlot(invSlot); if (stack == null || !inv.canExtractItem(invSlot, stack, side)) { return 0; } if (db.lookupItem(stack, entry, false) != entry) { return 0; } int remaining = stack.stackSize; if (count > remaining) { count = remaining; } ni.itemExtracted(invSlot, count); remaining -= count; updateCount(db, slot, entry, remaining); return count; }
73. DSUInventory#extractItem()
View license@Override public int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int count) { ItemStack stack = dsu.getStoredItemType(); if (db.lookupItem(stack, entry, false) != entry) { return 0; } int remaining = stack.stackSize; if (count > remaining) { count = remaining; } remaining -= count; dsu.setStoredItemCount(remaining); updateCount(db, 0, entry, remaining); return count; }
74. DrawerGroupInventory#extractItem()
View license@Override int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int count) { if (slot >= dg.getDrawerCount()) { return 0; } IDrawer drawer = dg.getDrawer(slot); if (drawer == null) { return 0; } int remaining = drawer.getStoredItemCount(); if (remaining <= 0) { return 0; } ItemStack stack = drawer.getStoredItemPrototype(); if (db.lookupItem(stack, entry, false) != entry) { return 0; } if (count > remaining) { count = remaining; } remaining -= count; drawer.setStoredItemCount(remaining); updateCount(db, slot, entry, remaining); return count; }
75. InventoryPanelContainer#executeMoveItems()
View licensepublic boolean executeMoveItems(int fromSlot, int toSlotStart, int toSlotEnd, int amount) { if ((fromSlot >= toSlotStart && fromSlot < toSlotEnd) || toSlotEnd <= toSlotStart || amount <= 0) { return false; } Slot srcSlot = getSlot(fromSlot); ItemStack src = srcSlot.getStack(); if (src != null) { ItemStack toMove = src.copy(); toMove.stackSize = Math.min(src.stackSize, amount); int remaining = src.stackSize - toMove.stackSize; if (mergeItemStack(toMove, toSlotStart, toSlotEnd, false)) { remaining += toMove.stackSize; if (remaining == 0) { srcSlot.putStack(null); } else { src.stackSize = remaining; srcSlot.onSlotChanged(); } return true; } } return false; }
76. GuiInventoryPanel#drawGhostSlotTooltip()
View license@Override protected void drawGhostSlotTooltip(GhostSlot slot, int mouseX, int mouseY) { ItemStack stack = slot.getStack(); if (stack != null) { ghostSlotTooltipStacksize = stack.stackSize; try { renderToolTip(stack, mouseX, mouseY); } finally { ghostSlotTooltipStacksize = 0; } } }
77. ItemEntry#findUnlocName()
View licenseprivate void findUnlocName() { ItemStack stack = makeItemStack(); try { name = stack.getDisplayName(); if (name == null || name.isEmpty()) { name = stack.getItem().getUnlocalizedName(); if (name == null || name.isEmpty()) { name = stack.getItem().getClass().getName(); } } } catch (Throwable ex) { name = "Exception: " + ex.getMessage(); } }
78. InventoryPanelNEIOverlayHandler#mapSlots()
View licenseprivate ItemStack[][] mapSlots(List<PositionedStack> ingredients, InventoryPanelContainer c) { ItemStack[][] slots = new ItemStack[9][]; List<Slot> craftingGrid = c.getCraftingGridSlots(); int found = 0; for (PositionedStack pstack : ingredients) { for (int idx = 0; idx < 9; idx++) { Slot slot = craftingGrid.get(idx); if (slot.xDisplayPosition == pstack.relx + CRAFTING_GRID_OFFSET_X && slot.yDisplayPosition == pstack.rely + CRAFTING_GRID_OFFSET_Y) { slots[idx] = pstack.items; found++; break; } } } if (found != ingredients.size()) { return null; } return slots; }
79. InventoryPanelNEIOverlayHandler#overlayRecipe()
View license@Override public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift) { GuiInventoryPanel guiInvPanel = (GuiInventoryPanel) gui; List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex); if (shift) { shift = guiInvPanel.getContainer().clearCraftingGrid(); } ItemStack[][] slots = mapSlots(ingredients, guiInvPanel.getContainer()); if (slots != null) { CraftingHelperNEI helper = new CraftingHelperNEI(slots); helper.overlayRenderer = new DefaultOverlayRenderer(ingredients, positioner); guiInvPanel.setCraftingHelper(helper); if (shift) { helper.refill(guiInvPanel, 64); } } else { guiInvPanel.setCraftingHelper(null); } }
80. CraftingHelper#findAllCandidates()
View licenseprivate Candidate findAllCandidates(ItemStack[] pstack, GuiInventoryPanel gui, InventoryDatabaseClient db, Candidate[] candidates) { Candidate bestInventory = null; Candidate bestNetwork = null; for (ItemStack istack : pstack) { Candidate candidate = findCandidates(istack, gui, db, candidates); if (candidate.available > 0) { if (bestInventory == null || bestInventory.available < candidate.available) { bestInventory = candidate; } } if (candidate.entry != null) { if (bestNetwork == null || bestNetwork.entry.getCount() < candidate.entry.getCount()) { bestNetwork = candidate; } } } if (bestInventory != null) { return bestInventory; } else { return bestNetwork; } }
81. CraftingHelper#createFromSlots()
View licensepublic static CraftingHelper createFromSlots(List<Slot> slots) { if (slots.size() != 9) { return null; } ItemStack[][] ingredients = new ItemStack[9][]; int count = 0; for (int idx = 0; idx < 9; idx++) { Slot slot = slots.get(idx); ItemStack stack = slot.getStack(); if (stack != null) { stack = stack.copy(); stack.stackSize = 1; ingredients[idx] = new ItemStack[] { stack }; count++; } } if (count > 0) { return new CraftingHelperNEI(ingredients); } return null; }
82. TileHyperCube#recieveItems()
View licenseprivate ItemStack recieveItems(ItemStack toPush) { if (toPush == null) { return null; } ItemStack result = toPush.copy(); //TODO: need to cache this BlockCoord myLoc = new BlockCoord(this); for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { BlockCoord checkLoc = myLoc.getLocation(dir); TileEntity te = worldObj.getTileEntity(checkLoc.x, checkLoc.y, checkLoc.z); result.stackSize -= ItemUtil.doInsertItem(te, result, dir.getOpposite()); if (result.stackSize <= 0) { return null; } } return result; }
83. TileEnchanter#getEnchantmentCost()
View licenseprivate int getEnchantmentCost(EnchanterRecipe currentEnchantment) { ItemStack item = inv[1]; if (item == null) { return 0; } if (currentEnchantment == null) { return 0; } Enchantment enchantment = currentEnchantment.getEnchantment(); int level = currentEnchantment.getLevelForStackSize(item.stackSize); return getEnchantmentCost(currentEnchantment, level); }
84. TileCrafter#updateCraftingOutput()
View licensepublic void updateCraftingOutput() { InventoryCrafting inv = new InventoryCrafting(new Container() { @Override public boolean canInteractWith(EntityPlayer var1) { return false; } }, 3, 3); for (int i = 0; i < 9; i++) { inv.setInventorySlotContents(i, craftingGrid.getStackInSlot(i)); } ItemStack matches = CraftingManager.getInstance().findMatchingRecipe(inv, worldObj); craftingGrid.setInventorySlotContents(9, matches); markDirty(); }
85. ClearConfigRecipe#matches()
View license@Override public boolean matches(InventoryCrafting inv, World world) { int count = 0; ItemStack input = null; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack checkStack = inv.getStackInSlot(i); if (checkStack != null && Block.getBlockFromItem(checkStack.getItem()) instanceof AbstractMachineBlock) { count++; } input = count == 1 && checkStack != null ? checkStack : input; } if (count == 1 && input.stackTagCompound != null && input.stackTagCompound.getBoolean("eio.abstractMachine")) { ItemStack out = input.copy(); out.stackTagCompound = new NBTTagCompound(); out.stackTagCompound.setBoolean("clearedConfig", true); out.stackSize = 1; output = out; } else { output = null; } return count == 1 && output != null; }
86. CapBankNetwork#chargeItems()
View licensepublic boolean chargeItems(ItemStack[] items) { if (items == null) { return false; } boolean chargedItem = false; int available = getEnergyAvailableForTick(getMaxIO()); for (ItemStack item : items) { if (item != null && available > 0 && item.stackSize == 1 && item.getItem() instanceof IEnergyContainerItem) { IEnergyContainerItem chargable = (IEnergyContainerItem) item.getItem(); int max = chargable.getMaxEnergyStored(item); int cur = chargable.getEnergyStored(item); if (cur < max) { int canUse = Math.min(available, max - cur); int used = chargable.receiveEnergy(item, canUse, false); if (used > 0) { addEnergy(-used); chargedItem = true; available -= used; } } } } return chargedItem; }
87. ContainerCapBank#mergeItemStackIntoArmor()
View licenseprivate boolean mergeItemStackIntoArmor(EntityPlayer entityPlayer, ItemStack origStack, int slotIndex) { if (origStack == null || !(origStack.getItem() instanceof ItemArmor)) { return false; } ItemArmor armor = (ItemArmor) origStack.getItem(); int index = 3 - armor.armorType; ItemStack[] ai = entityPlayer.inventory.armorInventory; if (ai[index] == null) { ai[index] = origStack.copy(); origStack.stackSize = 0; return true; } return false; }
88. FacadePart#isTransparent()
View license@Override public boolean isTransparent() { if (AEApi.instance().partHelper().getCableRenderMode().transparentFacades) { return true; } final ItemStack is = this.getTexture(); final Block blk = Block.getBlockFromItem(is.getItem()); return !blk.isOpaqueCube(); }
89. AchievementPickupHandler#onItemPickUp()
View license@SubscribeEvent public void onItemPickUp(final PlayerEvent.ItemPickupEvent event) { if (this.differentiator.isNoPlayer(event.player) || event.pickedUp == null || event.pickedUp.getEntityItem() == null) { return; } final ItemStack is = event.pickedUp.getEntityItem(); for (final Achievements achievement : Achievements.values()) { if (achievement.getType() == AchievementType.Pickup && Platform.isSameItemPrecise(achievement.getStack(), is)) { achievement.addToPlayer(event.player); return; } } }
90. MatterCannonAmmoRegistry#getPenetration()
View license@Override public float getPenetration(final ItemStack is) { for (final ItemStack o : this.DamageModifiers.keySet()) { if (Platform.isSameItem(o, is)) { return this.DamageModifiers.get(o).floatValue(); } } return 0; }
91. IMCMatterCannon#process()
View license@Override public void process(final IMCMessage m) { final NBTTagCompound msg = m.getNBTValue(); final NBTTagCompound item = (NBTTagCompound) msg.getTag("item"); final ItemStack ammo = ItemStack.loadItemStackFromNBT(item); final double weight = msg.getDouble("weight"); if (ammo == null) { throw new IllegalStateException("invalid item in message " + m); } AEApi.instance().registries().matterCannon().registerAmmo(ammo, weight); }
92. IMCBlackListSpatial#process()
View license@Override public void process(final IMCMessage m) { final ItemStack is = m.getItemStackValue(); if (is != null) { final Block blk = Block.getBlockFromItem(is.getItem()); if (blk != null) { AEApi.instance().registries().movable().blacklistBlock(blk); return; } } AELog.info("Bad Block blacklisted by " + m.getSender()); }
93. ContainerSecurity#detectAndSendChanges()
View license@Override public void detectAndSendChanges() { this.verifyPermissions(SecurityPermissions.SECURITY, false); this.setPermissionMode(0); final ItemStack a = this.configSlot.getStack(); if (a != null && a.getItem() instanceof IBiometricCard) { final IBiometricCard bc = (IBiometricCard) a.getItem(); for (final SecurityPermissions sp : bc.getPermissions(a)) { this.setPermissionMode(this.getPermissionMode() | (1 << sp.ordinal())); } } this.updatePowerStatus(); super.detectAndSendChanges(); }
94. ContainerQuartzKnife#decrStackSize()
View license@Override public ItemStack decrStackSize(final int var1, final int var2) { final ItemStack is = this.getStackInSlot(0); if (is != null) { if (this.makePlate()) { return is; } } return null; }
95. ContainerQuartzKnife#getStackInSlot()
View license@Override public ItemStack getStackInSlot(final int var1) { final ItemStack input = this.inSlot.getStackInSlot(0); if (input == null) { return null; } if (SlotRestrictedInput.isMetalIngot(input)) { if (this.myName.length() > 0) { for (final ItemStack namePressStack : AEApi.instance().definitions().materials().namePress().maybeStack(1).asSet()) { final NBTTagCompound compound = Platform.openNbtData(namePressStack); compound.setString("InscribeName", this.myName); return namePressStack; } } } return null; }
96. ContainerPatternTerm#getInputs()
View licenseprivate ItemStack[] getInputs() { final ItemStack[] input = new ItemStack[9]; boolean hasValue = false; for (int x = 0; x < this.craftingSlots.length; x++) { input[x] = this.craftingSlots[x].getStack(); if (input[x] != null) { hasValue = true; } } if (hasValue) { return input; } return null; }
97. WAILAData#cropStack()
View licensepublic ItemStack cropStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { NBTTagCompound tag = accessor.getNBTData(); int cropId = tag.getInteger("cropId"); CropIndex crop = CropManager.getInstance().getCropFromId(cropId); ItemStack itemstack; if (crop.output2 != null) itemstack = new ItemStack(crop.output2); else itemstack = new ItemStack(crop.output1); ItemFoodTFC.createTag(itemstack); return itemstack; }
98. WAILAData#firepitBody()
View licensepublic List<String> firepitBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { NBTTagCompound tag = accessor.getNBTData(); ItemStack storage[] = getStorage(tag, accessor.getTileEntity()); if (storage != null) { int fuelCount = 0; for (ItemStack is : storage) { if (is != null && is.getItem() != null && (is.getItem() == TFCItems.logs || is.getItem() == Item.getItemFromBlock(TFCBlocks.peat))) fuelCount++; } if (fuelCount > 0) currenttip.add(TFC_Core.translate("gui.fuel") + " : " + fuelCount + "/4"); } return currenttip; }
99. WAILAData#loomStack()
View licensepublic ItemStack loomStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { NBTTagCompound tag = accessor.getNBTData(); boolean finished = tag.getBoolean("finished"); ItemStack storage[] = getStorage(tag, accessor.getTileEntity()); if (finished && storage[1] != null) { return storage[1]; } return null; }
100. TileEntityOven#decrStackSize()
View license@Override public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); if (itemStack != null) { if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); } else { itemStack = itemStack.splitStack(decrementAmount); if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } } return itemStack; }