Java 类net.minecraft.inventory.InventoryBasic 实例源码

项目:VillagerInventory    文件:VillagerInventoryMod.java   
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event)
{
    // if villager death drops are enabled, if the newly dead entity is a villager, and that villager was killed by a player...
    if ((ModConfiguration.enableDeathDrops) && (event.getEntityLiving() instanceof EntityVillager) && (event.getSource().getTrueSource() instanceof EntityPlayerMP))
    {
        // iterate through the itemstacks in the villager's inventory
        InventoryBasic inventory = ((EntityVillager)event.getEntityLiving()).getVillagerInventory();
        for (int i = 0; i < inventory.getSizeInventory(); i++)
        {
            // remove the stack from the inventory and spawn it in the world
            ItemStack stack = inventory.getStackInSlot(i);
            if (stack != ItemStack.EMPTY)
            {
                event.getEntityLiving().entityDropItem(stack, 0.0F);
            }
        }
    }
}
项目:DecompiledMinecraft    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic p_76316_1_)
{
    int i = this.getHorseArmorIndexSynced();
    boolean flag = this.isHorseSaddled();
    this.updateHorseSlots();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:DecompiledMinecraft    文件:EntityVillager.java   
public EntityVillager(World worldIn, int professionId)
{
    super(worldIn);
    this.villagerInventory = new InventoryBasic("Items", false, 8);
    this.setProfession(professionId);
    this.setSize(0.6F, 1.8F);
    ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
    this.tasks.addTask(1, new EntityAITradePlayer(this));
    this.tasks.addTask(1, new EntityAILookAtTradePlayer(this));
    this.tasks.addTask(2, new EntityAIMoveIndoors(this));
    this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
    this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
    this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
    this.tasks.addTask(6, new EntityAIVillagerMate(this));
    this.tasks.addTask(7, new EntityAIFollowGolem(this));
    this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
    this.tasks.addTask(9, new EntityAIVillagerInteract(this));
    this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    this.setCanPickUpLoot(true);
}
项目:DecompiledMinecraft    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic p_76316_1_)
{
    int i = this.getHorseArmorIndexSynced();
    boolean flag = this.isHorseSaddled();
    this.updateHorseSlots();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:DecompiledMinecraft    文件:EntityVillager.java   
public EntityVillager(World worldIn, int professionId)
{
    super(worldIn);
    this.villagerInventory = new InventoryBasic("Items", false, 8);
    this.setProfession(professionId);
    this.setSize(0.6F, 1.8F);
    ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
    this.tasks.addTask(1, new EntityAITradePlayer(this));
    this.tasks.addTask(1, new EntityAILookAtTradePlayer(this));
    this.tasks.addTask(2, new EntityAIMoveIndoors(this));
    this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
    this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
    this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
    this.tasks.addTask(6, new EntityAIVillagerMate(this));
    this.tasks.addTask(7, new EntityAIFollowGolem(this));
    this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
    this.tasks.addTask(9, new EntityAIVillagerInteract(this));
    this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    this.setCanPickUpLoot(true);
}
项目:BaseClient    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic p_76316_1_)
{
    int i = this.getHorseArmorIndexSynced();
    boolean flag = this.isHorseSaddled();
    this.updateHorseSlots();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:BaseClient    文件:EntityVillager.java   
public EntityVillager(World worldIn, int professionId)
{
    super(worldIn);
    this.villagerInventory = new InventoryBasic("Items", false, 8);
    this.setProfession(professionId);
    this.setSize(0.6F, 1.8F);
    ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
    this.tasks.addTask(1, new EntityAITradePlayer(this));
    this.tasks.addTask(1, new EntityAILookAtTradePlayer(this));
    this.tasks.addTask(2, new EntityAIMoveIndoors(this));
    this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
    this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
    this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
    this.tasks.addTask(6, new EntityAIVillagerMate(this));
    this.tasks.addTask(7, new EntityAIFollowGolem(this));
    this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
    this.tasks.addTask(9, new EntityAIVillagerInteract(this));
    this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    this.setCanPickUpLoot(true);
}
项目:BaseClient    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic p_76316_1_)
{
    int i = this.getHorseArmorIndexSynced();
    boolean flag = this.isHorseSaddled();
    this.updateHorseSlots();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:BaseClient    文件:EntityVillager.java   
public EntityVillager(World worldIn, int professionId)
{
    super(worldIn);
    this.villagerInventory = new InventoryBasic("Items", false, 8);
    this.setProfession(professionId);
    this.setSize(0.6F, 1.8F);
    ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
    this.tasks.addTask(1, new EntityAITradePlayer(this));
    this.tasks.addTask(1, new EntityAILookAtTradePlayer(this));
    this.tasks.addTask(2, new EntityAIMoveIndoors(this));
    this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
    this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
    this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
    this.tasks.addTask(6, new EntityAIVillagerMate(this));
    this.tasks.addTask(7, new EntityAIFollowGolem(this));
    this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
    this.tasks.addTask(9, new EntityAIVillagerInteract(this));
    this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    this.setCanPickUpLoot(true);
}
项目:CustomWorldGen    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic invBasic)
{
    HorseArmorType horsearmortype = this.getHorseArmorType();
    boolean flag = this.isHorseSaddled();
    this.updateHorseSlots();

    if (this.ticksExisted > 20)
    {
        if (horsearmortype == HorseArmorType.NONE && horsearmortype != this.getHorseArmorType())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
        }
        else if (horsearmortype != this.getHorseArmorType())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_SADDLE, 0.5F, 1.0F);
        }
    }
}
项目:ExtraUtilities    文件:XUHelper.java   
public static NBTTagCompound writeInventoryBasicToNBT(final NBTTagCompound tag, final InventoryBasic inventoryBasic) {
    if (inventoryBasic.hasCustomInventoryName()) {
        tag.setString("CustomName", inventoryBasic.getInventoryName());
    }
    final NBTTagList nbttaglist = new NBTTagList();
    for (int i = 0; i < inventoryBasic.getSizeInventory(); ++i) {
        final ItemStack stackInSlot = inventoryBasic.getStackInSlot(i);
        if (stackInSlot != null) {
            final NBTTagCompound itemTag = new NBTTagCompound();
            itemTag.setByte("Slot", (byte)i);
            stackInSlot.writeToNBT(itemTag);
            nbttaglist.appendTag((NBTBase)itemTag);
        }
    }
    tag.setTag("Items", (NBTBase)nbttaglist);
    return tag;
}
项目:ExtraUtilities    文件:RegisterPipeParts.java   
public TMultiPart convert(final World world, final BlockCoord pos) {
    final Block id = world.getBlock(pos.x, pos.y, pos.z);
    int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
    if (id != ExtraUtils.transferPipe && id != ExtraUtils.transferPipe2) {
        return null;
    }
    if (id == ExtraUtils.transferPipe2) {
        meta += 16;
    }
    if (meta != 9) {
        return (TMultiPart)new PipePart(meta);
    }
    if (world.getTileEntity(pos.x, pos.y, pos.z) instanceof TileEntityFilterPipe) {
        final InventoryBasic t = ((TileEntityFilterPipe)world.getTileEntity(pos.x, pos.y, pos.z)).items;
        return (TMultiPart)new FilterPipePart(t);
    }
    return (TMultiPart)new FilterPipePart();
}
项目:TombManyGraves    文件:GuiDeathItems.java   
private void createListOfItemsInExpandableBackpack()
{
    if (!TombManyGraves.isExpandableBackpacksInstalled)
    {
        expandableBackpackItems = new ArrayList<>();
        return;
    }
    NBTTagCompound tag = deathList.getTagCompound().getCompoundTag("ExpandableBackpack");
    ItemStack stack = ItemStack.loadItemStackFromNBT(tag);
    if (stack == null || stack.stackSize == 0)
    {
        expandableBackpackItems = new ArrayList<>();
        return;
    }

    IInventory inventory = new InventoryBasic("temp",false,1);
    inventory.setInventorySlotContents(0,stack);
    expandableBackpackItems = createListFromInventory(inventory, EXPANDABLE);
}
项目:TombManyGraves    文件:GuiDeathItems.java   
private void createListOfItemsInEydamosBackpack()
    {
        if (!TombManyGraves.isEydamosBackpacksInstalled)
        {
            eydamosBackpackItems = new ArrayList<>();
            return;
        }
        NBTTagCompound tag = deathList.getTagCompound().getCompoundTag("EydamosBackpack");
        ItemStack stack = ItemStack.loadItemStackFromNBT(tag);
        if (stack == null || stack.stackSize == 0)
        {
            eydamosBackpackItems = new ArrayList<>();
            return;
        }

//        BackpackSave instance = BackpackSave.loadBackpack(player.worldObj, stack, player, false);
//
//        eydamosBackpackItems = createListFromInventory(instance, EYDAMOS);
//        return;
        IInventory inventory = new InventoryBasic("temp",false,1);
        inventory.setInventorySlotContents(0, stack);

        eydamosBackpackItems = createListFromInventory(inventory, EYDAMOS);

    }
项目:MMDLib-old    文件:NBTUtils.java   
/**
 * Writes an inventory to an NBTTagCompound. Can be used to save an inventory in a
 * TileEntity, or perhaps an ItemStack.
 *
 * @param tag: The NBTTagCompound to write the inventory to.
 * @param inventory: The inventory to write to the NBTTagCompound.
 * @return NBTTagCompound: The same NBTTagCompound that was passed to this method.
 */
public static NBTTagCompound writeInventoryToNBT (NBTTagCompound tag, InventoryBasic inventory) {
    if (inventory.hasCustomName())
        tag.setString("CustomName", inventory.getName());
    final NBTTagList nbttaglist = new NBTTagList();
    for (int slotCount = 0; slotCount < inventory.getSizeInventory(); slotCount++) {
        final ItemStack stackInSlot = inventory.getStackInSlot(slotCount);
        if (stackInSlot != null) {
            final NBTTagCompound itemTag = new NBTTagCompound();
            itemTag.setByte("Slot", (byte) slotCount);
            stackInSlot.writeToNBT(itemTag);
            nbttaglist.appendTag(itemTag);
        }
    }
    tag.setTag("Items", nbttaglist);
    return tag;
}
项目:EZStorage2    文件:ContainerStorageCore.java   
public ContainerStorageCore(EntityPlayer player, World world, int x, int y, int z) {
    this.tileEntity = ((TileEntityStorageCore) world.getTileEntity(new BlockPos(x, y, z)));
    int startingY = 18;
    int startingX = 8;

    // the EZStorage slots
    IInventory inventory = new InventoryBasic("title", false, this.rowCount() * 9);
    for (int i = 0; i < this.rowCount(); i++) {
        for (int j = 0; j < 9; j++) {
            addSlotToContainer(new Slot(inventory, j + i * 9, startingX + j * 18, startingY + i * 18));
        }
    }

    // the player inventory
    bindPlayerInventory(player.inventory);
}
项目:KalStuff    文件:ContainerTrashCan.java   
public void addPlayerSlots(InventoryPlayer player) {
    for (int i = 0; i < 3; ++i) {
           for (int j = 0; j < 9; ++j) {
               this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 51 + i * 18));
           }
       }

       for (int i = 0; i < 9; ++i)
           this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 109));

       IInventory tableInventory = new InventoryBasic("Trash", false, 1) {
        public void setInventorySlotContents(int index, ItemStack stack) {

           }
       };
       this.addSlotToContainer(new Slot(tableInventory, 0, 80, 20));
}
项目:Bookshelf    文件:NBTUtils.java   
/**
 * Writes an inventory to an NBTTagCompound. Can be used to save an inventory in a
 * TileEntity, or perhaps an ItemStack.
 *
 * @param tag: The NBTTagCompound to write the inventory to.
 * @param inventory: The inventory to write to the NBTTagCompound.
 * @return NBTTagCompound: The same NBTTagCompound that was passed to this method.
 */
public static NBTTagCompound writeInventoryToNBT (NBTTagCompound tag, InventoryBasic inventory) {

    if (inventory.hasCustomName()) {
        tag.setString("CustomName", inventory.getName());
    }

    final NBTTagList nbttaglist = new NBTTagList();

    for (int slotCount = 0; slotCount < inventory.getSizeInventory(); slotCount++) {

        final ItemStack stackInSlot = inventory.getStackInSlot(slotCount);

        if (!stackInSlot.isEmpty()) {

            final NBTTagCompound itemTag = new NBTTagCompound();
            itemTag.setByte("Slot", (byte) slotCount);
            stackInSlot.writeToNBT(itemTag);
            nbttaglist.appendTag(itemTag);
        }
    }

    tag.setTag("Items", nbttaglist);

    return tag;
}
项目:Bookshelf    文件:NBTUtils.java   
/**
 * Reads an inventory from an NBTTagCompound. Can be used to load an Inventory from a
 * TileEntity or perhaps an ItemStak.
 *
 * @param tag: The NBTTagCompound to read the inventory data from.
 * @param inventory: The inventory to set all of the inventory data to.
 * @return InventoryBasic: The same instance of InventoryBasic that was passed to this
 *         method.
 */
public static InventoryBasic readInventoryFromNBT (NBTTagCompound tag, InventoryBasic inventory) {

    if (tag.hasKey("CustomName", 8)) {
        inventory.setCustomName(tag.getString("CustomName"));
    }

    final NBTTagList items = tag.getTagList("Items", 10);

    for (int storedCount = 0; storedCount < items.tagCount(); storedCount++) {

        final NBTTagCompound itemTag = items.getCompoundTagAt(storedCount);
        final int slotCount = itemTag.getByte("Slot") & 0xFF;

        if (slotCount >= 0 && slotCount < inventory.getSizeInventory()) {
            inventory.setInventorySlotContents(slotCount, new ItemStack(itemTag));
        }
    }

    return inventory;
}
项目:Resilience-Client-Source    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic par1InventoryBasic)
{
    int var2 = this.func_110241_cb();
    boolean var3 = this.isHorseSaddled();
    this.func_110232_cE();

    if (this.ticksExisted > 20)
    {
        if (var2 == 0 && var2 != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (var2 != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!var3 && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:Rediscovered-Mod-1.8.8    文件:EntityGreenVillager.java   
public EntityGreenVillager(World worldIn, int professionId)
{
    super(worldIn);
    this.villagerInventory = new InventoryBasic("Items", false, 8);
    this.setProfession(professionId);
    this.setSize(0.6F, 1.8F);
    ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
    this.tasks.addTask(1, new EntityAITradeGreen(this));
    this.tasks.addTask(1, new EntityAILookAtTradeGreen(this));
    this.tasks.addTask(2, new EntityAIMoveIndoors(this));
    this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
    this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
    this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
    this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
    this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    this.setCanPickUpLoot(true);
}
项目:Rediscovered-Mod-1.8.8    文件:EntityPigman.java   
public EntityPigman(World worldIn, int professionId)
   {
       super(worldIn);
       this.villagerInventory = new InventoryBasic("Items", false, 8);
       this.setProfession(professionId);
       this.setSize(0.6F, 1.8F);
       ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
       ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
       this.tasks.addTask(0, new EntityAISwimming(this));
       this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
       this.tasks.addTask(1, new EntityAITradePigman(this));
       this.tasks.addTask(1, new EntityAILookAtTradePigman(this));
       this.tasks.addTask(2, new EntityAIMoveIndoors(this));
       this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
       this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
       this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
this.tasks.addTask(6, new EntityAIPigmanMate(this));
       this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
       this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
       this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
       this.setCanPickUpLoot(true);
   }
项目:HandCraft    文件:HandRecipe.java   
public int countPossibleRecipes(IInventory inventory)
{
    InventoryBasic basic = new InventoryBasic("basic", false, inventory.getSizeInventory());
    for (int i = 0; i < basic.getSizeInventory(); i++) 
        if(inventory.getStackInSlot(i) != null)
            basic.setInventorySlotContents(i, inventory.getStackInSlot(i).copy());

    searched.clear();

    ArrayList<RecipeOverflow> overflow = new ArrayList<RecipeOverflow>();
    int ammount = 0;
    ConsumeResult result = consumeRecipe(basic, input, overflow, new SearchLimiter());
    while(result != null)
    {
        overflow.addAll(result.overflow);
        ammount++;
        result = consumeRecipe(basic, input, overflow, new SearchLimiter());
        searched.clear();
    }

    searched.clear();

    return ammount;
}
项目:PeripheralsPlusPlus    文件:ContainerCrafter.java   
public ContainerCrafter(EntityPlayer player, TileCrafter inventory) {
    super(player, inventory, 140);
    this.crafter = inventory;

    for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
            addSlotToContainer(new SlotRO(inventory.craftingInv, x + y * 3, 30 + x * 18, 17 + y * 18));
        }
    }

    addSlotToContainer(craftResult = new SlotRO(new InventoryBasic("", false, 1), 0, 124, 35));

    for (int x = 0; x < 9; x++) {
        for (int y = 0; y < 2; y++) {
            addSlotToContainer(new Slot(crafter, x + y * 9, 8 + x * 18, 90 + y * 18));              
        }
    }
}
项目:ExpandedRailsMod    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic invBasic)
{
    HorseArmorType horsearmortype = this.getHorseArmorType();
    boolean flag = this.isHorseSaddled();
    this.updateHorseSlots();

    if (this.ticksExisted > 20)
    {
        if (horsearmortype == HorseArmorType.NONE && horsearmortype != this.getHorseArmorType())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
        }
        else if (horsearmortype != this.getHorseArmorType())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_SADDLE, 0.5F, 1.0F);
        }
    }
}
项目:NausicaaMod    文件:EntityHorseclaw.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
@Override
public void onInventoryChanged(InventoryBasic par1InventoryBasic) {
    int i = this.func_110241_cb();
    boolean flag = this.isHorseSaddled();
    this.func_110232_cE();

    if (this.ticksExisted > 20) {
        if (i == 0 && i != this.func_110241_cb()) {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        } else if (i != this.func_110241_cb()) {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled()) {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:MoarPeripherals    文件:ContainerCrafter.java   
public ContainerCrafter(EntityPlayer player, TileComputerCrafter inventory) {
    super(inventory);
    crafter = inventory;

    // the crafting grid
    for (int row = 0; row < 3; ++row) {
        for (int col = 0; col < 3; ++col) {
            addSlotToContainer(new SlotReadOnly(inventory.craftingInv, col + row * 3, 30 + col * 18, 17 + row * 18));
        }
    }

    // the TE inventory
    for (int row = 0; row < 2; ++row) {
        for (int col = 0; col < 9; ++col) {
            addSlotToContainer(new Slot(crafter, col + row * 9, 8 + col * 18, 90 + row * 18));
        }
    }

    // the fake output slot is so fake that it's not even stored in the TE
    addSlotToContainer(craftResult = new SlotReadOnly(new InventoryBasic("", false, 1), 0, 124, 35));

    bindPlayerInventory(player.inventory, 140);
}
项目:Cauldron    文件:EntityHorse.java   
public void onInventoryChanged(InventoryBasic p_76316_1_)
{
    int i = this.func_110241_cb();
    boolean flag = this.isHorseSaddled();
    this.func_110232_cE();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (i != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:Cauldron    文件:EntityHorse.java   
public void onInventoryChanged(InventoryBasic p_76316_1_)
{
    int i = this.func_110241_cb();
    boolean flag = this.isHorseSaddled();
    this.func_110232_cE();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (i != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:TameHumans    文件:EntityAIMineOre.java   
private boolean shouldMineBlock(Block block, int x, int y, int z) {
    if (block instanceof BlockOre || block instanceof BlockRedstoneOre) {
        InventoryBasic minerInventory = this.miner.inventory;
        if (InventoryUtils.hasRoomInInventory(minerInventory)) {
            return true;
        }
        else {
            World world = this.miner.worldObj;
            ArrayList<ItemStack> items = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
            for (ItemStack item : items) {
                if (InventoryUtils.canFitItem(item, minerInventory)) {
                    return true;
                }
            }
        }
    }
    return false;
}
项目:TameHumans    文件:InventoryUtils.java   
public static void addToInventory(ItemStack itemStack, InventoryBasic inventory) {
    if (itemStack != null && itemStack.stackSize != 0 && itemStack.getItem() != null) {
        int emptySlot = getFirstEmptyStack(inventory);

        if (itemStack.isItemDamaged()) {
            if (emptySlot > -1) {
                inventory.setInventorySlotContents(emptySlot, itemStack);
            }
        }
        else {
            int compatibleSlot = getExistingCompatibleStack(itemStack, inventory);
            if (compatibleSlot > -1) {
                ItemStack existingStack = inventory.getStackInSlot(compatibleSlot);
                existingStack.stackSize += itemStack.stackSize;
            }
            else if (emptySlot > -1) {
                inventory.setInventorySlotContents(emptySlot, itemStack);
            }
        }
    }
}
项目:RuneCraftery    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic par1InventoryBasic)
{
    int i = this.func_110241_cb();
    boolean flag = this.isHorseSaddled();
    this.func_110232_cE();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:Dota2Items    文件:ContainerShopSell.java   
public ContainerShopSell(InventoryPlayer inventoryPlayer) {
    this.invPlayer = inventoryPlayer;
    // Assign trade slots:
    invSelling = new InventoryBasic("Selling", false, 1);
    addSlotToContainer(new Slot(invSelling, 0, 20, 45));
    // Assign player's inventory:
    int i;
    for (i = 0; i < 3; ++i) {
        for (int j = 0; j < 9; ++j) {
            addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, PLAYER_INV_X + j * 18, PLAYER_INV_Y + i * 18));
        }
    }
    for (i = 0; i < 9; ++i) {
        addSlotToContainer(new Slot(inventoryPlayer, i, PLAYER_INV_X + i * 18, 58 + PLAYER_INV_Y));
    }
}
项目:BetterNutritionMod    文件:EntityHorse.java   
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic par1InventoryBasic)
{
    int i = this.func_110241_cb();
    boolean flag = this.isHorseSaddled();
    this.func_110232_cE();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
项目:McMod-CubicVillager    文件:VillagerEvent.java   
private static void dropInventory(List<EntityItem> drops, EntityVillager villager)
{
    // 村人自身のインベントリの内容をドロップ
    // InventoryBasicもIterableにしてくれ~
    InventoryBasic inv = villager.getVillagerInventory();
    final int invElements = inv.getSizeInventory();
    for(int i = 0; i < invElements; i++)
    {
        // スロットごとにItemStackがないか確認
        ItemStack stack = inv.getStackInSlot(i);
        if(stack == null)
        {
            continue;
        }
        // ItemStackがあればそれをドロップアイテムとして登録
        EntityItem entityDropItem = new EntityItem(villager.world, villager.posX, villager.posY + 1, villager.posZ, stack);
        drops.add(entityDropItem);
    }
}
项目:VillagerInventory    文件:ContainerVillagerInventory.java   
public ContainerVillagerInventory(IInventory playerInventory, final InventoryBasic villagerInventoryIn, final EntityVillager villager, EntityPlayer player)
{
    this.villagerInventory = villagerInventoryIn;
    this.villager = villager;

    this.villagerInventory.setCustomName(this.villager.getDisplayName().getUnformattedText());


    villagerInventoryIn.openInventory(player);

    // villager inventory slots
    int offsetX = 17;
    int offsetY = 20;
    for (int col = 0; col < 8; col++)
    {
        this.addSlotToContainer(new Slot(villagerInventoryIn, col, offsetX + col * 18, offsetY));
    }

    // player inventory
    offsetX = 8;
    offsetY = 51;
    for (int row = 0; row < 3; row++)
    {
        for (int col = 0; col < 9; col++)
        {
            this.addSlotToContainer(new Slot(playerInventory, col + row * 9 + 9, offsetX + col * 18, offsetY + row * 18));
        }
    }

    // player hotbar inventory
    offsetY = 109;
    for (int col = 0; col < 9; col++)
    {
        this.addSlotToContainer(new Slot(playerInventory, col, offsetX + col * 18, offsetY));
    }

}
项目:VillagerInventory    文件:GuiVillagerInventory.java   
public GuiVillagerInventory(InventoryPlayer playerInv, InventoryBasic villagerInv, EntityVillager villager)
{
    super(new ContainerVillagerInventory(playerInv, villagerInv, villager, playerInv.player));
    this.playerInventory = playerInv;
    this.villagerInventory = villagerInv;
    this.villagerEntity = villager;
    this.allowUserInput = false;
    this.ySize = 133;
}
项目:DecompiledMinecraft    文件:NetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
 * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
 */
public void handleOpenWindow(S2DPacketOpenWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayerSP entityplayersp = this.gameController.thePlayer;

    if ("minecraft:container".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("minecraft:villager".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("EntityHorse".equals(packetIn.getGuiId()))
    {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

        if (entity instanceof EntityHorse)
        {
            entityplayersp.displayGUIHorse((EntityHorse)entity, new AnimalChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
        }
    }
    else if (!packetIn.hasSlots())
    {
        entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else
    {
        ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(containerlocalmenu);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目:BaseClient    文件:NetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
 * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
 */
public void handleOpenWindow(S2DPacketOpenWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayerSP entityplayersp = this.gameController.thePlayer;

    if ("minecraft:container".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("minecraft:villager".equals(packetIn.getGuiId()))
    {
        entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else if ("EntityHorse".equals(packetIn.getGuiId()))
    {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

        if (entity instanceof EntityHorse)
        {
            entityplayersp.displayGUIHorse((EntityHorse)entity, new AnimalChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
        }
    }
    else if (!packetIn.hasSlots())
    {
        entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
    else
    {
        ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(containerlocalmenu);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}
项目:BaseClient    文件:NetHandlerPlayClient.java   
/**
 * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace,
 * Dispenser, Enchanting table, Brewing stand, Villager merchant, Beacon, Anvil,
 * Hopper, Dropper, Horse
 */
public void handleOpenWindow(S2DPacketOpenWindow packetIn) {
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayerSP entityplayersp = this.gameController.thePlayer;

    if ("minecraft:container".equals(packetIn.getGuiId())) {
        entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    } else if ("minecraft:villager".equals(packetIn.getGuiId())) {
        entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    } else if ("EntityHorse".equals(packetIn.getGuiId())) {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

        if (entity instanceof EntityHorse) {
            entityplayersp.displayGUIHorse((EntityHorse) entity,
                    new AnimalChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
        }
    } else if (!packetIn.hasSlots()) {
        entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    } else {
        ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(),
                packetIn.getWindowTitle(), packetIn.getSlotCount());
        entityplayersp.displayGUIChest(containerlocalmenu);
        entityplayersp.openContainer.windowId = packetIn.getWindowId();
    }
}