Java 类net.minecraft.item.ItemStack 实例源码

项目:Mods    文件:ItemStatue.java   
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = playerIn.getHeldItem(hand);
    if (!worldIn.isRemote && stack.hasTagCompound() && stack.getTagCompound().hasKey("Statue")) {
        EntityStatue statue =new EntityStatue(worldIn);
        statue.readEntityFromNBT(stack.getTagCompound().getCompoundTag("Statue"));
        BlockPos off = pos.offset(facing);
        statue.setPosition(off.getX()+0.5, off.getY(), off.getZ()+0.5);
        statue.rotationYaw = playerIn.rotationYawHead;
        statue.renderYawOffset = playerIn.rotationYawHead;

        statue.ticksLeft = -1;
        worldIn.spawnEntity(statue);
        if (!playerIn.capabilities.isCreativeMode)
            stack.shrink(1);
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.SUCCESS;
}
项目:Proyecto-DASI    文件:MinecraftTypeHelper.java   
/** Attempt to parse string as a Variation, allowing for block properties having different names to the enum values<br>
 * (eg blue_orchid vs orchidBlue etc.)
 * @param part the string (potentially in the 'wrong' format, eg 'orchidBlue')
 * @param is the ItemStack from which this string came (eg from is.getUnlocalisedName)
 * @return a Variation, if one exists, that matches the part string passed in, or one of the ItemStacks current property values.
 */
public static Variation attemptToGetAsVariant(String part, ItemStack is)
{
    if (is.getItem() instanceof ItemBlock)
    {
        // Unlocalised name doesn't always match the names we use in types.xsd
        // (which are the names displayed by Minecraft when using the F3 debug etc.)
        ItemBlock ib = (ItemBlock)(is.getItem());
        IBlockState bs = ib.block.getStateFromMeta(is.getMetadata());
        for (IProperty prop : (java.util.Set<IProperty>)bs.getProperties().keySet())
        { 
            Comparable<?> comp = bs.getValue(prop);
            Variation var = attemptToGetAsVariant(comp.toString());
            if (var != null)
                return var;
        }
        return null;
    }
    else
        return attemptToGetAsVariant(part);
}
项目:Backmemed    文件:CustomItems.java   
public static IBakedModel getCustomItemModel(ItemStack p_getCustomItemModel_0_, IBakedModel p_getCustomItemModel_1_, ResourceLocation p_getCustomItemModel_2_)
{
    if (p_getCustomItemModel_1_.isGui3d())
    {
        return p_getCustomItemModel_1_;
    }
    else if (itemProperties == null)
    {
        return p_getCustomItemModel_1_;
    }
    else
    {
        CustomItemProperties customitemproperties = getCustomItemProperties(p_getCustomItemModel_0_, 1);
        return customitemproperties == null ? p_getCustomItemModel_1_ : customitemproperties.getModel(p_getCustomItemModel_2_);
    }
}
项目:CustomWorldGen    文件:CraftingManager.java   
public ItemStack[] getRemainingItems(InventoryCrafting craftMatrix, World worldIn)
{
    for (IRecipe irecipe : this.recipes)
    {
        if (irecipe.matches(craftMatrix, worldIn))
        {
            return irecipe.getRemainingItems(craftMatrix);
        }
    }

    ItemStack[] aitemstack = new ItemStack[craftMatrix.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        aitemstack[i] = craftMatrix.getStackInSlot(i);
    }

    return aitemstack;
}
项目:Loot-Slash-Conquer    文件:ItemLEBauble.java   
@Override
public void onEquipped(ItemStack stack, EntityLivingBase entity) 
{
    if (entity.getEntityWorld().isRemote) entity.playSound(SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.1F, 1.3f);
    else
    {
        if (entity instanceof EntityPlayer)
        {
            EntityPlayer player = (EntityPlayer) entity;
            PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);

            if (info != null && info.getPlayerLevel() >= NBTHelper.loadStackNBT(stack).getInteger("Level"))
            {
                EventPlayerTick.updateStats(player, info);
            }
            else player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will not provide any bonuses."));
        }
    }
}
项目:minecraft-quiverbow    文件:Recipe_AA_Plating.java   
private ItemStack getAAFromMatrix(InventoryCrafting matrix)
{
    int counter = 0;

    while (counter < matrix.getSizeInventory())
    {
        if (matrix.getStackInSlot(counter) != null && matrix.getStackInSlot(counter).getItem() instanceof PackedUpAA)
        {
            return matrix.getStackInSlot(counter);  // Found it
        }

        counter += 1;
    }

    return null;
}
项目:minecraft-quiverbow    文件:Recipe_AA_Weapon.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting matrix)
   {
    ItemStack stack = this.result.copy();
    ItemStack previousAA = this.getAAFromMatrix(matrix);

    if (previousAA != null && previousAA.hasTagCompound())  // Copying existing properties
    {
        stack.setTagCompound((NBTTagCompound) previousAA.getTagCompound().copy());
    }
    else    // ...or just applying new ones
    {
        stack.setTagCompound(new NBTTagCompound());
    }

    // Apply the new upgrade now
    stack.getTagCompound().setBoolean("hasWeaponUpgrade", true);

    if (stack.getTagCompound().getInteger("currentHealth") == 0)    // Just making sure it's not shown with 0 health
    {
        if (stack.getTagCompound().getBoolean("hasArmorUpgrade")) { stack.getTagCompound().setInteger("currentHealth", 40); }
        else { stack.getTagCompound().setInteger("currentHealth", 20); } // Fresh turret, so setting some health
    }

       return stack;
   }
项目:minecraft-quiverbow    文件:FlintDuster.java   
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)       // Server side
{
    // Ignoring cooldown for firing purposes

    // SFX
    world.playSoundAtEntity(entity, "mob.bat.takeoff", 0.5F, 0.6F);

    // Ready
    FlintDust shot = new FlintDust(world, entity, (float) this.Speed);

    // Properties
    shot.damage = this.Dmg;
    shot.ticksInAirMax = this.MaxBlocks;

    // Go
    world.spawnEntityInWorld(shot);

    this.consumeAmmo(stack, entity, 1);
    this.setCooldown(stack, 4);
}
项目:minecraft-quiverbow    文件:RPG.java   
@Override
public void addRecipes()
{
    if (this.Enabled)
    {
        // One Firework Rocket Launcher (empty)
        GameRegistry.addRecipe(new ItemStack(this, 1 , this.getMaxDamage()), "x  ", "yx ", "zyx",
                'x', Blocks.planks,
                'y', Items.iron_ingot,
                'z', Items.flint_and_steel
                );
    }
    else if (Main.noCreative) { this.setCreativeTab(null); }    // Not enabled and not allowed to be in the creative menu

    // Fill the RPG with 1 rocket
    GameRegistry.addRecipe(new ItemStack(this), " ab", "zya", " x ",
            'x', new ItemStack(this, 1 , this.getMaxDamage()),
            'y', Blocks.tnt,
            'z', Blocks.planks,
            'a', Items.paper,
            'b', Items.string
            );
}
项目:Backmemed    文件:WorldClient.java   
public void doVoidFogParticles(int posX, int posY, int posZ)
{
    int i = 32;
    Random random = new Random();
    ItemStack itemstack = this.mc.player.getHeldItemMainhand();

    if (itemstack == null || Block.getBlockFromItem(itemstack.getItem()) != Blocks.BARRIER)
    {
        itemstack = this.mc.player.getHeldItemOffhand();
    }

    boolean flag = this.mc.playerController.getCurrentGameType() == GameType.CREATIVE && !itemstack.func_190926_b() && itemstack.getItem() == Item.getItemFromBlock(Blocks.BARRIER);
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int j = 0; j < 667; ++j)
    {
        this.showBarrierParticles(posX, posY, posZ, 16, random, flag, blockpos$mutableblockpos);
        this.showBarrierParticles(posX, posY, posZ, 32, random, flag, blockpos$mutableblockpos);
    }
}
项目:pnc-repressurized    文件:TileEntityPressureChamberInterface.java   
private void importFromChamber(TileEntityPressureChamberValve core) {
    ItemStackHandler chamberStacks = core.getStacksInChamber();
    for (ItemStack chamberStack : new ItemStackHandlerIterable(chamberStacks)) {
        ItemStack inputStack = inventory.getStackInSlot(0);
        if ((inputStack.isEmpty() || inputStack.isItemEqual(chamberStack)) && filterHandler.doesItemMatchFilter(chamberStack)) {
            int maxAllowedItems = Math.abs(core.getAirHandler(null).getAir()) / PneumaticValues.USAGE_CHAMBER_INTERFACE;
            if (maxAllowedItems > 0) {
                if (!inputStack.isEmpty()) {
                    maxAllowedItems = Math.min(maxAllowedItems, chamberStack.getMaxStackSize() - inputStack.getCount());
                }
                int transferredItems = Math.min(chamberStack.getCount(), maxAllowedItems);
                ItemStack toTransferStack = chamberStack.copy().splitStack(transferredItems);
                ItemStack excess = inventory.insertItem(0, toTransferStack, true);
                if (excess.getCount() < toTransferStack.getCount()) {
                    // we can transfer at least some of the items
                    transferredItems = toTransferStack.getCount() - excess.getCount();
                    core.addAir((core.getAirHandler(null).getAir() > 0 ? -1 : 1) * transferredItems * PneumaticValues.USAGE_CHAMBER_INTERFACE);
                    toTransferStack.setCount(transferredItems);
                    inventory.insertItem(0, toTransferStack, false);
                    chamberStack.shrink(transferredItems);
                }
            }
        }
    }
}
项目:FoodCraft-Reloaded    文件:TileEntitySmeltingDrinkMachine.java   
@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().readNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, itemStackHandler, null, tag.getTag("Items"));
    progress = tag.getInteger("progress");
    fuel = tag.getInteger("fuel");
    output = new ItemStack(tag.getCompoundTag("output"));
    fluidStack = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("fluidOutput"));
}
项目:pnc-repressurized    文件:SemiBlockLogistics.java   
@Override
public void addDrops(NonNullList<ItemStack> drops) {
    super.addDrops(drops);

    boolean shouldAddTag = false;
    for (int i = 0; i < filters.getSlots(); i++) {
        if (!filters.getStackInSlot(i).isEmpty()) { //Only set a tag when there are requests.
            shouldAddTag = true;
            break;
        }
    }

    for (FluidTank fluidFilter : fluidFilters) {
        if (fluidFilter.getFluidAmount() > 0) {
            shouldAddTag = true;
            break;
        }
    }

    if (invisible) shouldAddTag = true;

    if (shouldAddTag) {
        ItemStack drop = drops.get(0);
        NBTTagCompound tag = new NBTTagCompound();
        writeToNBT(tag);
        drop.setTagCompound(tag);
    }
}
项目:Loot-Slash-Conquer    文件:ItemGenerator.java   
/** Creates a melee weapon/armor with randomized stats. */
public static void create(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
    /*
     * Set rarity
     * Set level
     * Generate attributes based on Rarity
     *      - Common: 0-1 attributes
     *      - Uncommon: 1-2 attributes
     *      - Rare: 2-3 attributes
     *      - Legendary: 3-4 attributes
     *      - Mythic: 4-5 attributes
     * Generate base damage and base attack speed
     * Generate name based on attributes + material/type
     */

    if (Rarity.getRarity(nbt) != Rarity.DEFAULT)
    {
        IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
        IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
        int level = chunkLevel.getChunkLevel();

        //Rarity.setRarity(nbt, Rarity.getRandomRarity(nbt, ItemGeneratorHelper.rand)); // sets a random rarity
        ItemGeneratorHelper.setTypes(stack, nbt);
        nbt.setInteger("Level", level); // set level to current player level
        ItemGeneratorHelper.setRandomAttributes(stack, nbt, Rarity.getRarity(nbt));
        ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
        nbt.setInteger("HideFlags", 6); // hides Attribute Modifier and Unbreakable tags
    }
}
项目:DecompiledMinecraft    文件:InventoryMerchant.java   
/**
 * Removes a stack from the given slot and returns it.
 */
public ItemStack removeStackFromSlot(int index)
{
    if (this.theInventory[index] != null)
    {
        ItemStack itemstack = this.theInventory[index];
        this.theInventory[index] = null;
        return itemstack;
    }
    else
    {
        return null;
    }
}
项目:chesttransporter    文件:ItemChestTransporter.java   
private void damageItem(ItemStack stack, EntityPlayer player)
{
    if (!player.capabilities.isCreativeMode)
    {
        stack.damageItem(1, player);
        if (type.maxDamage == 1)
            stack.damageItem(1, player);
    }
}
项目:Backmemed    文件:Bootstrap.java   
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    Block block = Block.getBlockFromItem(stack.getItem());
    World world = source.getWorld();
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    this.field_190911_b = world.func_190527_a(block, blockpos, false, EnumFacing.DOWN, (Entity)null);

    if (this.field_190911_b)
    {
        EnumFacing enumfacing1 = world.isAirBlock(blockpos.down()) ? enumfacing : EnumFacing.UP;
        IBlockState iblockstate = block.getDefaultState().withProperty(BlockShulkerBox.field_190957_a, enumfacing1);
        world.setBlockState(blockpos, iblockstate);
        TileEntity tileentity = world.getTileEntity(blockpos);
        ItemStack itemstack = stack.splitStack(1);

        if (itemstack.hasTagCompound())
        {
            ((TileEntityShulkerBox)tileentity).func_190586_e(itemstack.getTagCompound().getCompoundTag("BlockEntityTag"));
        }

        if (itemstack.hasDisplayName())
        {
            ((TileEntityShulkerBox)tileentity).func_190575_a(itemstack.getDisplayName());
        }

        world.updateComparatorOutputLevel(blockpos, iblockstate.getBlock());
    }

    return stack;
}
项目:harshencastle    文件:HarshenRegistry.java   
@Override
public CauldronLiquid registerCauldronLiquid(ItemStack fullItem, ItemStack emptyItem, CauldronLiquid liquid, int fillBy) {
    fillBy = MathHelper.clamp(fillBy, 1, 3);
    liquid.setModID(modID);
    if(emptyItem == null || emptyItem.isEmpty())
        return registerItemLiquid(fullItem, liquid);
    INPUT_FILLBY.put(fullItem, fillBy);
    OUTPUT_FILLBY.put(emptyItem, fillBy);
    INPUT_MAP.put(fullItem, liquid);
    OUTPUT_MAP.put(liquid, emptyItem);
    return liquid;
}
项目:CustomWorldGen    文件:EntitySheep.java   
@Override
public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
{
    this.setSheared(true);
    int i = 1 + this.rand.nextInt(3);

    java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
    for (int j = 0; j < i; ++j)
        ret.add(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, this.getFleeceColor().getMetadata()));

    this.playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F);
    return ret;
}
项目:BetterBeginningsReborn    文件:KilnRecipeHandler.java   
public static void removeRecipe(RecipeElement input, ItemStack output)
{
    ItemStack result = instance().smeltingList.get(input);
    if(instance().smeltingList.containsKey(input) && ItemStack.areItemStacksEqual(result, output)) return;
    {
    instance().experienceList.remove(result);
    instance().smeltingList.remove(input);
    }
}
项目:ExPetrum    文件:ItemRock.java   
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems)
{
    if (tab != this.getCreativeTab())
    {
        return;
    }

    Stream.of(EnumRockClass.values()).forEach(c -> subItems.add(new ItemStack(this, 1, c.ordinal())));
}
项目:BaseClient    文件:EntityPlayer.java   
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
    super.writeEntityToNBT(tagCompound);
    tagCompound.setTag("Inventory", this.inventory.writeToNBT(new NBTTagList()));
    tagCompound.setInteger("SelectedItemSlot", this.inventory.currentItem);
    tagCompound.setBoolean("Sleeping", this.sleeping);
    tagCompound.setShort("SleepTimer", (short)this.sleepTimer);
    tagCompound.setFloat("XpP", this.experience);
    tagCompound.setInteger("XpLevel", this.experienceLevel);
    tagCompound.setInteger("XpTotal", this.experienceTotal);
    tagCompound.setInteger("XpSeed", this.xpSeed);
    tagCompound.setInteger("Score", this.getScore());

    if (this.spawnChunk != null)
    {
        tagCompound.setInteger("SpawnX", this.spawnChunk.getX());
        tagCompound.setInteger("SpawnY", this.spawnChunk.getY());
        tagCompound.setInteger("SpawnZ", this.spawnChunk.getZ());
        tagCompound.setBoolean("SpawnForced", this.spawnForced);
    }

    this.foodStats.writeNBT(tagCompound);
    this.capabilities.writeCapabilitiesToNBT(tagCompound);
    tagCompound.setTag("EnderItems", this.theInventoryEnderChest.saveInventoryToNBT());
    ItemStack itemstack = this.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() != null)
    {
        tagCompound.setTag("SelectedItem", itemstack.writeToNBT(new NBTTagCompound()));
    }
}
项目:SimpleTubes    文件:SimpleTubes.java   
public void displayAllRelevantItems(NonNullList<ItemStack> list) {
    //Blocks
    list.add(new ItemStack(proxy.blockTube, 1, 0));
    list.add(new ItemStack(proxy.blockDisplacer, 1, 0));

    //Items
    for (int i = 0; i < 17; i++)
        list.add(new ItemStack(proxy.itemPaintbrush, 1, i));

    list.add(new ItemStack(proxy.itemUpgrade, 1, 0));
}
项目:BaseClient    文件:InventoryPlayer.java   
public boolean canHeldItemHarvest(Block blockIn)
{
    if (blockIn.getMaterial().isToolNotRequired())
    {
        return true;
    }
    else
    {
        ItemStack itemstack = this.getStackInSlot(this.currentItem);
        return itemstack != null ? itemstack.canHarvestBlock(blockIn) : false;
    }
}
项目:CustomWorldGen    文件:EntityMinecartContainer.java   
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);
    this.minecartContainerItems = new ItemStack[this.getSizeInventory()];

    if (compound.hasKey("LootTable", 8))
    {
        this.lootTable = new ResourceLocation(compound.getString("LootTable"));
        this.lootTableSeed = compound.getLong("LootTableSeed");
    }
    else
    {
        NBTTagList nbttaglist = compound.getTagList("Items", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            int j = nbttagcompound.getByte("Slot") & 255;

            if (j >= 0 && j < this.minecartContainerItems.length)
            {
                this.minecartContainerItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
            }
        }
    }
}
项目:Thermionics    文件:ItemChunkUnloader.java   
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
    tooltip.add(I18n.translateToLocal("item.thermionics.chunkunloader.tip"));
    int loadedState = stack.getItemDamage();
    switch(loadedState) {
    default: //Default to unattuned

    case 0: tooltip.add(I18n.translateToLocalFormatted("thermionics.data.chunkunloader.unattuned")); break;
    case 1: tooltip.add(I18n.translateToLocalFormatted("thermionics.data.chunkunloader.unloaded")); break;
    case 2: tooltip.add(I18n.translateToLocalFormatted("thermionics.data.chunkunloader.loaded")); break;
    }
}
项目:connor41-etfuturum2    文件:TippedArrow.java   
public static ItemStack setEffect(ItemStack stack, Potion potion, int duration) {
    stack.setTagCompound(new NBTTagCompound());
    NBTTagCompound nbt = new NBTTagCompound();
    stack.getTagCompound().setTag("Potion", nbt);

    PotionEffect effect = new PotionEffect(potion.getId(), potion.isInstant() ? 1 : duration);
    effect.writeCustomPotionEffectToNBT(nbt);

    return stack;
}
项目:Backmemed    文件:TileEntityDispenser.java   
public boolean func_191420_l()
{
    for (ItemStack itemstack : this.stacks)
    {
        if (!itemstack.func_190926_b())
        {
            return false;
        }
    }

    return true;
}
项目:Whoosh    文件:ItemTransporter.java   
@Override
public boolean decrMode(ItemStack stack) {

    if (!stack.hasTagCompound()) {
        stack.setTagCompound(new NBTTagCompound());
    }
    int curMode = getMode(stack);
    curMode--;
    if (curMode <= 0) {
        curMode = getNumModes(stack) - 1;
    }
    stack.getTagCompound().setInteger("Mode", curMode);
    return true;
}
项目:Industrial-Foregoing    文件:EnchantmentInvokerBlock.java   
public void createRecipe() {
    RecipeUtils.addShapedRecipe(new ItemStack(this), "pbp", "dmd", "ooo",
            'p', ItemRegistry.plastic,
            'b', Items.BOOK,
            'd', "gemDiamond",
            'm', MachineCaseItem.INSTANCE,
            'o', Blocks.OBSIDIAN);
}
项目:Industrial-Foregoing    文件:PageItemList.java   
public static List<PageItemList> generatePagesFromItemStacks(List<ItemStack> stacks, String display) {
    List<PageItemList> pages = new ArrayList<>();
    while (stacks.size() > 49) {
        pages.add(new PageItemList(stacks.subList(0, 49), display));
        stacks = stacks.subList(49, stacks.size());
    }
    pages.add(new PageItemList(stacks, display));
    return pages;
}
项目:ModularMachinery    文件:ItemBlockMachineComponent.java   
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
    if(stack.isEmpty()) {
        return 0;
    }
    return Config.machineColor;
}
项目:pnc-repressurized    文件:TileEntityOmnidirectionalHopper.java   
protected boolean doImport(int maxItems) {
    boolean success = false;

    // Suck from input inventory
    IItemHandler handler = IOHelper.getInventoryForTE(IOHelper.getNeighbor(this, inputDir));
    if (handler != null) {
        for (int i = 0; i < maxItems; i++) {
            LocatedItemStack extracted = IOHelper.extractOneItem(handler, true);
            if (!extracted.stack.isEmpty()) {
                ItemStack excess = ItemHandlerHelper.insertItem(inventory, extracted.stack, false);
                if (excess.isEmpty()) {
                    handler.extractItem(extracted.slot, 1, false);
                    success = true;
                } else {
                    break;
                }
            } else {
                break;
            }
        }
    }

    // Suck in item entities
    for (EntityItem entity : getNeighborItems(this, inputDir)) {
        if (!entity.isDead) {
            ItemStack remainder = IOHelper.insert(this, entity.getItem(), null, false);
            if (remainder.isEmpty()) {
                entity.setDead();
                success = true;
            }
        }
    }

    return success;
}
项目:Firma    文件:ClayBlock2.java   
@Override
public String getSpecialName(ItemStack stack) {
    if (stack == null) {
        throw new NullPointerException();
    }
    return RockEnum2.getName(stack.getMetadata());
}
项目:harshencastle    文件:JEIRitualWrapper.java   
@SuppressWarnings("unchecked")
public JEIRitualWrapper(RitualRecipes recipe) {
    ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
    for(HarshenStack hStack : recipe.getInputs())
        builder.add(hStack.getStackList());
    input = builder.build();
    output = recipe.getOutput();
}
项目:pnc-repressurized    文件:NetworkConnectionAIHandler.java   
public NetworkConnectionAIHandler(GuiSecurityStationBase gui, TileEntitySecurityStation station, int baseX,
                                  int baseY, int nodeSpacing, int color) {
    super(gui, station, baseX, baseY, nodeSpacing, color, TileEntityConstants.NETWORK_AI_BRIDGE_SPEED);
    for (int i = 0; i < station.getPrimaryInventory().getSlots(); i++) {
        ItemStack stack = station.getPrimaryInventory().getStackInSlot(i);
        if (stack.getItemDamage() == ItemNetworkComponents.DIAGNOSTIC_SUBROUTINE) {
            slotHacked[i] = true;
        }
    }
}
项目:ThermionicsWorld    文件:ThermionicsWorld.java   
public static void addMeatCompressionRecipe(IForgeRegistry<IRecipe> registry, EnumEdibleMeat meat, boolean cooked, ItemStack ingredient) {
    ResourceLocation group = new ResourceLocation("thermionics_world", "compress.meat");
    Ingredient input = Ingredient.fromStacks(ingredient);
    ShapedRecipes recipe = 
            new ShapedRecipes(group.toString(), 3, 3,
            NonNullList.withSize(3*3, input),
            new ItemStack(TWBlocks.MEAT_EDIBLE, 1, BlockMeatEdible.getMetaFromValue(meat, cooked)) );
    recipe.setRegistryName(new ResourceLocation("thermionics_world", meat.getName()+((cooked)?".cooked":".raw")+"_CompressToBlock"));
    registry.register(recipe);
}
项目:Backmemed    文件:RecipesMapCloning.java   
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    int i = 0;
    ItemStack itemstack = ItemStack.field_190927_a;

    for (int j = 0; j < inv.getSizeInventory(); ++j)
    {
        ItemStack itemstack1 = inv.getStackInSlot(j);

        if (!itemstack1.func_190926_b())
        {
            if (itemstack1.getItem() == Items.FILLED_MAP)
            {
                if (!itemstack.func_190926_b())
                {
                    return false;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.MAP)
                {
                    return false;
                }

                ++i;
            }
        }
    }

    return !itemstack.func_190926_b() && i > 0;
}
项目:DecompiledMinecraft    文件:SlotCrafting.java   
/**
 * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
 * stack.
 */
public ItemStack decrStackSize(int amount)
{
    if (this.getHasStack())
    {
        this.amountCrafted += Math.min(amount, this.getStack().stackSize);
    }

    return super.decrStackSize(amount);
}
项目:BaseClient    文件:TileEntityHopper.java   
private boolean transferItemsOut()
{
    IInventory iinventory = this.getInventoryForHopperTransfer();

    if (iinventory == null)
    {
        return false;
    }
    else
    {
        EnumFacing enumfacing = BlockHopper.getFacing(this.getBlockMetadata()).getOpposite();

        if (this.isInventoryFull(iinventory, enumfacing))
        {
            return false;
        }
        else
        {
            for (int i = 0; i < this.getSizeInventory(); ++i)
            {
                if (this.getStackInSlot(i) != null)
                {
                    ItemStack itemstack = this.getStackInSlot(i).copy();
                    ItemStack itemstack1 = putStackInInventoryAllSlots(iinventory, this.decrStackSize(i, 1), enumfacing);

                    if (itemstack1 == null || itemstack1.stackSize == 0)
                    {
                        iinventory.markDirty();
                        return true;
                    }

                    this.setInventorySlotContents(i, itemstack);
                }
            }

            return false;
        }
    }
}