net.minecraft.item.ItemStack

Here are the examples of the java api class net.minecraft.item.ItemStack taken from open source projects.

1. Inscribe#register()

Project: Applied-Energistics-2
Source File: Inscribe.java
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);
}

2. Press#register()

Project: Applied-Energistics-2
Source File: Press.java
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);
}

3. ItemConduit#getDrops()

Project: EnderIO
Source File: ItemConduit.java
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;
}

4. DarkSteelRecipeManager#handleRepair()

Project: EnderIO
Source File: DarkSteelRecipeManager.java
View license
private 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);
}

5. ConduitRecipes#addAeRecipes()

Project: EnderIO
Source File: ConduitRecipes.java
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()

Project: EnderIO
Source File: InventoryUpgrades.java
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. TileWorktable#onCraftingStart()

Project: ForestryMC
Source File: TileWorktable.java
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;
}

8. SlotItemHandler#getItemStackLimit()

Project: Kingdoms
Source File: SlotItemHandler.java
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. SlotItemHandler#getItemStackLimit()

Project: MinecraftForge
Source File: SlotItemHandler.java
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;
}

10. 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");
}

11. 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;
}

12. ExplosiveEnchantmentsHandler#useItems()

View license
private 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;
}

13. UselessToolFlimFlam#execute()

Project: OpenBlocks
Source File: UselessToolFlimFlam.java
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;
}

14. ItemFlamethrower#getSubItems()

Project: vsminecraft
Source File: ItemFlamethrower.java
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);
}

15. ItemJetpack#getSubItems()

Project: vsminecraft
Source File: ItemJetpack.java
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. ItemScubaTank#getSubItems()

Project: vsminecraft
Source File: ItemScubaTank.java
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);
}

17. ItemHohlraum#getSubItems()

Project: vsminecraft
Source File: ItemHohlraum.java
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);
}

18. 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);
    }
}

19. 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;
}

20. InWorldToolOperationResult#getBlockOperationResult()

View license
public 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);
}

21. AESharedNBT#createFromCompound()

View license
private 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;
}

22. ItemDarkSteelArmor#getSubItems()

Project: EnderIO
Source File: ItemDarkSteelArmor.java
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);
}

23. ItemDarkSteelPickaxe#getSubItems()

Project: EnderIO
Source File: ItemDarkSteelPickaxe.java
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);
}

24. ItemDarkSteelSword#getSubItems()

Project: EnderIO
Source File: ItemDarkSteelSword.java
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);
}

25. AbstractMachineEntity#decrStackSize()

Project: EnderIO
Source File: AbstractMachineEntity.java
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;
}

26. VanillaSmeltingRecipe#getCompletedResult()

Project: EnderIO
Source File: VanillaSmeltingRecipe.java
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) };
}

27. InventoryImpl#decrStackSize()

Project: EnderIO
Source File: InventoryImpl.java
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();
}

28. TileEnchanter#decrStackSize()

Project: EnderIO
Source File: TileEnchanter.java
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;
}

29. TileCapacitorBank#doDecrStackSize()

Project: EnderIO
Source File: TileCapacitorBank.java
View license
public 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();
}

30. 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) };
}

31. 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) };
}

32. TileVacuumChest#decrStackSize()

Project: EnderIO
Source File: TileVacuumChest.java
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;
}

33. BeekeepingLogic#doProduction()

Project: ForestryMC
Source File: BeekeepingLogic.java
View license
private 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);
    }
}

34. AlleleBeeSpecies#getResearchSuitability()

Project: ForestryMC
Source File: AlleleBeeSpecies.java
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);
}

35. WoodAccess#getStack()

Project: ForestryMC
Source File: WoodAccess.java
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();
}

36. FluidHelper#drainContainers()

Project: ForestryMC
Source File: FluidHelper.java
View license
public 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;
}

37. GuiAlyzer#drawMutationInfo()

Project: ForestryMC
Source File: GuiAlyzer.java
View license
public 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));
}

38. ContainerWorktable#onCraftMatrixChanged()

Project: ForestryMC
Source File: ContainerWorktable.java
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);
    }
}

39. 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;
}

40. 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);
}

41. 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);
}

42. CommandRename#processCommandPlayer()

Project: ForgeEssentials
Source File: CommandRename.java
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());
}

43. LayerHeldItem#doRenderLayer()

Project: Kingdoms
Source File: LayerHeldItem.java
View license
public 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();
    }
}

44. InventoryPlayer#decrStackSize()

Project: Kingdoms
Source File: InventoryPlayer.java
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;
}

45. InventoryPlayer#setInventorySlotContents()

Project: Kingdoms
Source File: InventoryPlayer.java
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;
    }
}

46. InventoryPlayer#getStackInSlot()

Project: Kingdoms
Source File: InventoryPlayer.java
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];
}

47. SlotMerchantResult#doTrade()

Project: Kingdoms
Source File: SlotMerchantResult.java
View license
private 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;
}

48. OptionUtilities#drawIcons()

Project: NotEnoughItems
Source File: OptionUtilities.java
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;
}

49. BlockOre2#onBlockExploded()

Project: TFCraft
Source File: BlockOre2.java
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);
}

50. ContainerTFC#areCompoundsEqual()

Project: TFCraft
Source File: ContainerTFC.java
View license
public 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;
}

51. ItemQuiver#getQuiverJavelinTypes()

Project: TFCraft
Source File: ItemQuiver.java
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;
}

52. WAILAData#anvilBody()

Project: TFCraft
Source File: WAILAData.java
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;
}

53. WAILAData#nestBoxBody()

Project: TFCraft
Source File: WAILAData.java
View license
public 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;
}

54. RecipeInputOreDict#getInputs()

Project: vsminecraft
Source File: RecipeInputOreDict.java
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);
}

55. CommonPlayerTickHandler#isGasMaskOn()

View license
public 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;
}

56. InventoryBin#removeStack()

Project: vsminecraft
Source File: InventoryBin.java
View license
public ItemStack removeStack() {
    ItemStack stack = getStack();
    if (stack == null) {
        return null;
    }
    setItemCount(getItemCount() - stack.stackSize);
    return stack.copy();
}

57. ItemBlockGasTank#getSubItems()

Project: vsminecraft
Source File: ItemBlockGasTank.java
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);
        }
    }
}

58. 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;
}

59. AuthorCmd#execute()

Project: Wurst-Client
Source File: AuthorCmd.java
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));
}

60. RenameCmd#execute()

Project: Wurst-Client
Source File: RenameCmd.java
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\".");
}

61. RepairCmd#execute()

Project: Wurst-Client
Source File: RepairCmd.java
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));
}

62. BlockEnergyCell#getCheckedSubBlocks()

View license
@Override
@SideOnly(Side.CLIENT)
public void getCheckedSubBlocks(final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks) {
    super.getCheckedSubBlocks(item, tabs, itemStacks);
    final ItemStack charged = new ItemStack(this, 1);
    final NBTTagCompound tag = Platform.openNbtData(charged);
    tag.setDouble("internalCurrentPower", this.getMaxPower());
    tag.setDouble("internalMaxPower", this.getMaxPower());
    itemStacks.add(charged);
}

63. ClientHelper#wheelEvent()

View license
@SubscribeEvent
public void wheelEvent(final MouseEvent me) {
    if (me.isCanceled() || me.dwheel == 0) {
        return;
    }
    final Minecraft mc = Minecraft.getMinecraft();
    final EntityPlayer player = mc.thePlayer;
    final ItemStack is = player.getHeldItem();
    if (is != null && is.getItem() instanceof IMouseWheelItem && player.isSneaking()) {
        try {
            NetworkHandler.instance.sendToServer(new PacketValueConfig("Item", me.dwheel > 0 ? "WheelUp" : "WheelDown"));
            me.setCanceled(true);
        } catch (final IOException e) {
            AELog.debug(e);
        }
    }
}

64. AEBaseGui#mouseClickMove()

View license
@Override
protected void mouseClickMove(final int x, final int y, final int c, final long d) {
    final Slot slot = this.getSlot(x, y);
    final ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
    if (slot instanceof SlotFake && itemstack != null) {
        this.drag_click.add(slot);
        if (this.drag_click.size() > 1) {
            for (final Slot dr : this.drag_click) {
                final PacketInventoryAction p = new PacketInventoryAction(c == 0 ? InventoryAction.PICKUP_OR_SET_DOWN : InventoryAction.PLACE_SINGLE, dr.slotNumber, 0);
                NetworkHandler.instance.sendToServer(p);
            }
        }
    } else {
        super.mouseClickMove(x, y, c, d);
    }
}

65. ItemEncodedPatternRenderer#renderItem()

View license
@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    this.recursive = true;
    final ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem();
    final ItemStack is = iep.getOutput(item);
    final Minecraft mc = Minecraft.getMinecraft();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT);
    RenderHelper.enableGUIStandardItemLighting();
    this.ri.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), is, 0, 0);
    RenderHelper.disableStandardItemLighting();
    GL11.glPopAttrib();
    this.recursive = false;
}

66. ContainerMAC#isValidItemForSlot()

View license
public boolean isValidItemForSlot(final int slotIndex, final ItemStack i) {
    final IInventory mac = this.getUpgradeable().getInventoryByName("mac");
    final ItemStack is = mac.getStackInSlot(10);
    if (is == null) {
        return false;
    }
    if (is.getItem() instanceof ItemEncodedPattern) {
        final World w = this.getTileEntity().getWorldObj();
        final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
        final ICraftingPatternDetails ph = iep.getPatternForItem(is, w);
        if (ph.isCraftable()) {
            return ph.isValidItemForSlot(slotIndex, i, w);
        }
    }
    return false;
}

67. ContainerPatternTerm#getAndUpdateOutput()

View license
private ItemStack getAndUpdateOutput() {
    final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
    for (int x = 0; x < ic.getSizeInventory(); x++) {
        ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
    }
    final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
    this.cOut.setInventorySlotContents(0, is);
    return is;
}

68. ContainerPatternTerm#getInputs()

View license
private 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;
}

69. 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;
}

70. 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;
}

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

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

73. 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);
}

74. 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;
}

75. 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;
        }
    }
}

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

77. CraftGuide#addGrinderRecipes()

View license
private void addGrinderRecipes(final IAppEngApi api, final ItemStack grindstone, final RecipeGenerator generator) {
    final ItemStack handle = api.definitions().blocks().crankHandle().maybeStack(1).orNull();
    final RecipeTemplate grinderTemplate = generator.createRecipeTemplate(GRINDER_SLOTS, grindstone);
    for (final IGrinderEntry recipe : api.registries().grinder().getRecipes()) {
        generator.addRecipe(grinderTemplate, new Object[] { recipe.getInput(), recipe.getOutput(), new Object[] { recipe.getOptionalOutput(), (int) (recipe.getOptionalChance() * GRINDER_RATIO) }, new Object[] { recipe.getSecondOptionalOutput(), (int) (recipe.getOptionalChance() * GRINDER_RATIO) }, handle, grindstone });
    }
}

78. BSCrate#injectItems()

Project: Applied-Energistics-2
Source File: BSCrate.java
View license
@Override
public IAEItemStack injectItems(final IAEItemStack input, final Actionable mode, final BaseActionSource src) {
    if (mode == Actionable.SIMULATE) {
        return null;
    }
    final ItemStack failed = this.crateStorage.insertItems(input.getItemStack());
    if (failed == null) {
        return null;
    }
    input.setStackSize(failed.stackSize);
    return input;
}

79. BSCrate#extractItems()

Project: Applied-Energistics-2
Source File: BSCrate.java
View license
@Override
public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final BaseActionSource src) {
    if (mode == Actionable.SIMULATE) {
        final int howMany = this.crateStorage.getItemCount(request.getItemStack());
        return howMany > request.getStackSize() ? request : request.copy().setStackSize(howMany);
    }
    final ItemStack obtained = this.crateStorage.extractItems(request.getItemStack(), (int) request.getStackSize());
    return AEItemStack.create(obtained);
}

80. BSCrateStorageAdaptor#simulateAdd()

View license
@Override
public ItemStack simulateAdd(final ItemStack toBeSimulated) {
    final int items = this.cs.getSpaceForItem(toBeSimulated);
    final ItemStack cloned = Platform.cloneItemStack(toBeSimulated);
    if (toBeSimulated.stackSize <= items) {
        return null;
    }
    cloned.stackSize -= items;
    return cloned;
}

81. FactorizationBarrel#containsItemType()

View license
private boolean containsItemType(final IAEItemStack i, final boolean acceptEmpty) {
    final ItemStack currentItem = this.fProxy.barrelGetItem(this.te);
    // empty barrels want your love too!
    if (acceptEmpty && currentItem == null) {
        return true;
    }
    return i.equals(currentItem);
}

82. FactorizationBarrel#getAvailableItems()

View license
@Override
public IItemList<IAEItemStack> getAvailableItems(final IItemList out) {
    final ItemStack i = this.fProxy.barrelGetItem(this.te);
    if (i != null) {
        i.stackSize = this.fProxy.barrelGetItemCount(this.te);
        out.addStorage(AEItemStack.create(i));
    }
    return out;
}

83. NEI#drawSlot()

Project: Applied-Energistics-2
Source File: NEI.java
View license
@Override
public void drawSlot(final Slot s) {
    if (s == null) {
        return;
    }
    final ItemStack stack = s.getStack();
    if (stack == null) {
        return;
    }
    final Minecraft mc = Minecraft.getMinecraft();
    final FontRenderer fontRenderer = mc.fontRenderer;
    final int x = s.xDisplayPosition;
    final int y = s.yDisplayPosition;
    GuiContainerManager.drawItems.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), stack, x, y);
    GuiContainerManager.drawItems.renderItemOverlayIntoGUI(fontRenderer, mc.getTextureManager(), stack, x, y, String.valueOf(stack.stackSize));
}

84. NEIFacadeRecipeHandler#loadUsageRecipes()

View license
@Override
public void loadUsageRecipes(final ItemStack ingredient) {
    final List<ItemStack> facades = this.facade.getFacades();
    for (final ItemStack anchorStack : this.anchorDefinition.maybeStack(1).asSet()) {
        for (final ItemStack is : facades) {
            final CachedShapedRecipe recipe = new CachedShapedRecipe(this.facade, anchorStack, is);
            if (recipe.contains(recipe.ingredients, ingredient.getItem())) {
                recipe.computeVisuals();
                if (recipe.contains(recipe.ingredients, ingredient)) {
                    recipe.setIngredientPermutation(recipe.ingredients, ingredient);
                    this.arecipes.add(recipe);
                }
            }
        }
    }
}

85. NEIWorldCraftingHandler#addRecipe()

View license
private void addRecipe(final IItemDefinition def, final String msg) {
    for (final ItemStack definitionStack : def.maybeStack(1).asSet()) {
        if (NEIServerUtils.areStacksSameTypeCrafting(definitionStack, this.target)) {
            this.offsets.add(def);
            this.outputs.add(new PositionedStack(definitionStack, 75, 4));
            this.details.put(def, msg);
        }
    }
}

86. RF#registerRFAttunement()

Project: Applied-Energistics-2
Source File: RF.java
View license
private void registerRFAttunement(final String mod, final String name, final int dmg) {
    assert mod != null;
    assert !mod.isEmpty();
    assert name != null;
    assert !name.isEmpty();
    assert dmg >= 0;
    final ItemStack modItem = GameRegistry.findItemStack(mod, name, 1);
    if (modItem != null) {
        modItem.setItemDamage(dmg);
        AEApi.instance().registries().p2pTunnel().addNewAttunement(modItem, TunnelType.RF_POWER);
    }
}

87. ItemCrystalSeed#getResolver()

View license
@Nullable
public static ResolverResult getResolver(final int certus2) {
    ResolverResult resolver = null;
    for (ItemStack crystalSeedStack : AEApi.instance().definitions().items().crystalSeed().maybeStack(1).asSet()) {
        crystalSeedStack.setItemDamage(certus2);
        crystalSeedStack = newStyle(crystalSeedStack);
        resolver = new ResolverResult("ItemCrystalSeed", crystalSeedStack.getItemDamage(), crystalSeedStack.getTagCompound());
    }
    return resolver;
}

88. ItemEncodedPattern#getOutput()

View license
public ItemStack getOutput(final ItemStack item) {
    ItemStack out = SIMPLE_CACHE.get(item);
    if (out != null) {
        return out;
    }
    final World w = CommonHelper.proxy.getWorld();
    if (w == null) {
        return null;
    }
    final ICraftingPatternDetails details = this.getPatternForItem(item, w);
    if (details == null) {
        return null;
    }
    SIMPLE_CACHE.put(item, out = details.getCondensedOutputs()[0].getItemStack());
    return out;
}

89. ItemFacade#createFromIDs()

View license
public ItemStack createFromIDs(final int[] ids) {
    for (final ItemStack facadeStack : AEApi.instance().definitions().items().facade().maybeStack(1).asSet()) {
        final NBTTagCompound facadeTag = new NBTTagCompound();
        facadeTag.setIntArray("x", ids.clone());
        facadeStack.setTagCompound(facadeTag);
        return facadeStack;
    }
    throw new MissingDefinition("Tried to create a facade, while facades are being deactivated.");
}

90. ItemFacade#useAlphaPass()

View license
@Override
public boolean useAlphaPass(final ItemStack is) {
    final ItemStack out = this.getTextureItem(is);
    if (out == null || out.getItem() == null) {
        return false;
    }
    final Block blk = Block.getBlockFromItem(out.getItem());
    if (blk != null && blk.canRenderInPass(1)) {
        return true;
    }
    return false;
}

91. AERootPoweredItem#getCheckedSubItems()

View license
@Override
protected void getCheckedSubItems(final Item sameItem, final CreativeTabs creativeTab, final List<ItemStack> itemStacks) {
    super.getCheckedSubItems(sameItem, creativeTab, itemStacks);
    final ItemStack charged = new ItemStack(this, 1);
    final NBTTagCompound tag = Platform.openNbtData(charged);
    tag.setDouble("internalCurrentPower", this.getAEMaxPower(charged));
    tag.setDouble("internalMaxPower", this.getAEMaxPower(charged));
    itemStacks.add(charged);
}

92. BlockUpgradeInventory#getMaxInstalled()

View license
@Override
public int getMaxInstalled(final Upgrades upgrades) {
    int max = 0;
    for (final ItemStack is : upgrades.getSupported().keySet()) {
        final Item encodedItem = is.getItem();
        if (encodedItem instanceof ItemBlock && Block.getBlockFromItem(encodedItem) == this.block) {
            max = upgrades.getSupported().get(is);
            break;
        }
    }
    return max;
}

93. DefinitionUpgradeInventory#getMaxInstalled()

View license
@Override
public int getMaxInstalled(final Upgrades upgrades) {
    int max = 0;
    for (final ItemStack stack : upgrades.getSupported().keySet()) {
        if (this.definition.isSameAs(stack)) {
            max = upgrades.getSupported().get(stack);
            break;
        }
    }
    return max;
}

94. PartAnnihilationPlane#calculateEnergyUsage()

View license
/**
	 * Checks if this plane can handle the block at the specific coordinates.
	 */
protected float calculateEnergyUsage(final WorldServer w, final int x, final int y, final int z, final List<ItemStack> items) {
    final Block block = w.getBlock(x, y, z);
    final float hardness = block.getBlockHardness(w, x, y, z);
    float requiredEnergy = 1 + hardness;
    for (final ItemStack is : items) {
        requiredEnergy += is.stackSize;
    }
    return requiredEnergy;
}

95. PartAnnihilationPlane#breakBlockAndStoreItems()

View license
private void breakBlockAndStoreItems(final WorldServer w, final int x, final int y, final int z, final List<ItemStack> items) {
    w.setBlock(x, y, z, Platform.AIR_BLOCK, 0, 3);
    final AxisAlignedBB box = AxisAlignedBB.getBoundingBox(x - 0.2, y - 0.2, z - 0.2, x + 1.2, y + 1.2, z + 1.2);
    for (final Object ei : w.getEntitiesWithinAABB(EntityItem.class, box)) {
        if (ei instanceof EntityItem) {
            final EntityItem entityItem = (EntityItem) ei;
            this.storeEntityItem(entityItem);
        }
    }
    for (final ItemStack snaggedItem : items) {
        final IAEItemStack overflow = this.storeItemStack(snaggedItem);
        this.spawnOverflow(overflow);
    }
}

96. StackUpgradeInventory#getMaxInstalled()

View license
@Override
public int getMaxInstalled(final Upgrades upgrades) {
    int max = 0;
    for (final ItemStack is : upgrades.getSupported().keySet()) {
        if (Platform.isSameItem(this.stack, is)) {
            max = upgrades.getSupported().get(is);
            break;
        }
    }
    return max;
}

97. AbstractPartTerminal#getDrops()

View license
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
    super.getDrops(drops, wrenched);
    for (final ItemStack is : this.viewCell) {
        if (is != null) {
            drops.add(is);
        }
    }
}

98. PartCraftingTerminal#getDrops()

View license
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
    super.getDrops(drops, wrenched);
    for (final ItemStack is : this.craftingGrid) {
        if (is != null) {
            drops.add(is);
        }
    }
}

99. AEItemResolver#paintBall()

View license
private Object paintBall(final AEColoredItemDefinition partType, final String substring, final boolean lumen) {
    AEColor col;
    try {
        col = AEColor.valueOf(substring);
    } catch (final Throwable t) {
        col = AEColor.Transparent;
    }
    if (col == AEColor.Transparent) {
        return null;
    }
    final ItemStack is = partType.stack(col, 1);
    return new ResolverResult("ItemPaintBall", (lumen ? 20 : 0) + is.getItemDamage());
}

100. AEItemResolver#cableItem()

View license
private Object cableItem(final AEColoredItemDefinition partType, final String substring) {
    AEColor col;
    try {
        col = AEColor.valueOf(substring);
    } catch (final Throwable t) {
        col = AEColor.Transparent;
    }
    final ItemStack is = partType.stack(col, 1);
    return new ResolverResult("ItemMultiPart", is.getItemDamage());
}