public static void add(World world, Coord pos, int slot, ItemStack item) {

    TileEntity te = WorldGenPrimitive.getTileEntity(world, pos);
    if (te == null) return;
    if (!(te instanceof TileEntityDispenser)) return;
    TileEntityDispenser dispenser = (TileEntityDispenser) te;
    dispenser.setInventorySlotContents(slot, item);
  }
  public void func_71852_a(
      World p_71852_1_,
      int p_71852_2_,
      int p_71852_3_,
      int p_71852_4_,
      int p_71852_5_,
      int p_71852_6_) {
    TileEntityDispenser var7 =
        (TileEntityDispenser) p_71852_1_.func_72796_p(p_71852_2_, p_71852_3_, p_71852_4_);
    if (var7 != null) {
      for (int var8 = 0; var8 < var7.func_70302_i_(); ++var8) {
        ItemStack var9 = var7.func_70301_a(var8);
        if (var9 != null) {
          float var10 = this.field_72284_a.nextFloat() * 0.8F + 0.1F;
          float var11 = this.field_72284_a.nextFloat() * 0.8F + 0.1F;
          float var12 = this.field_72284_a.nextFloat() * 0.8F + 0.1F;

          while (var9.field_77994_a > 0) {
            int var13 = this.field_72284_a.nextInt(21) + 10;
            if (var13 > var9.field_77994_a) {
              var13 = var9.field_77994_a;
            }

            var9.field_77994_a -= var13;
            EntityItem var14 =
                new EntityItem(
                    p_71852_1_,
                    (double) ((float) p_71852_2_ + var10),
                    (double) ((float) p_71852_3_ + var11),
                    (double) ((float) p_71852_4_ + var12),
                    new ItemStack(var9.field_77993_c, var13, var9.func_77960_j()));
            if (var9.func_77942_o()) {
              var14
                  .func_92059_d()
                  .func_77982_d((NBTTagCompound) var9.func_77978_p().func_74737_b());
            }

            float var15 = 0.05F;
            var14.field_70159_w = (double) ((float) this.field_72284_a.nextGaussian() * var15);
            var14.field_70181_x =
                (double) ((float) this.field_72284_a.nextGaussian() * var15 + 0.2F);
            var14.field_70179_y = (double) ((float) this.field_72284_a.nextGaussian() * var15);
            p_71852_1_.func_72838_d(var14);
          }
        }
      }

      p_71852_1_.func_96440_m(p_71852_2_, p_71852_3_, p_71852_4_, p_71852_5_);
    }

    super.func_71852_a(p_71852_1_, p_71852_2_, p_71852_3_, p_71852_4_, p_71852_5_, p_71852_6_);
  }
 public void func_146102_a(TileEntityDispenser p_146102_1_) {
   this.getNextWindowId();
   this.playerNetServerHandler.sendPacket(
       new S2DPacketOpenWindow(
           this.currentWindowId,
           p_146102_1_ instanceof TileEntityDropper ? 10 : 3,
           p_146102_1_.getInventoryName(),
           p_146102_1_.getSizeInventory(),
           p_146102_1_.isCustomInventoryName()));
   this.openContainer = new ContainerDispenser(this.inventory, p_146102_1_);
   this.openContainer.windowId = this.currentWindowId;
   this.openContainer.onCraftGuiOpened(this);
 }
 protected void func_82526_n(World p_82526_1_, int p_82526_2_, int p_82526_3_, int p_82526_4_) {
   BlockSourceImpl var5 = new BlockSourceImpl(p_82526_1_, p_82526_2_, p_82526_3_, p_82526_4_);
   TileEntityDispenser var6 = (TileEntityDispenser) var5.func_82619_j();
   if (var6 != null) {
     int var7 = var6.func_70361_i();
     if (var7 < 0) {
       p_82526_1_.func_72926_e(1001, p_82526_2_, p_82526_3_, p_82526_4_, 0);
     } else {
       ItemStack var8 = var6.func_70301_a(var7);
       IBehaviorDispenseItem var9 = this.func_96472_a(var8);
       if (var9 != IBehaviorDispenseItem.field_82483_a) {
         ItemStack var10 = var9.func_82482_a(var5, var8);
         var6.func_70299_a(var7, var10.field_77994_a == 0 ? null : var10);
       }
     }
   }
 }
  /** Generates the Dispenser contents. */
  public static void generateDispenserContents(
      Random par0Random,
      WeightedRandomChestContent[] par1ArrayOfWeightedRandomChestContent,
      TileEntityDispenser par2TileEntityDispenser,
      int par3) {
    for (int j = 0; j < par3; ++j) {
      WeightedRandomChestContent weightedrandomchestcontent =
          (WeightedRandomChestContent)
              WeightedRandom.getRandomItem(par0Random, par1ArrayOfWeightedRandomChestContent);
      ItemStack[] stacks =
          weightedrandomchestcontent.generateChestContent(par0Random, par2TileEntityDispenser);

      for (ItemStack item : stacks) {
        par2TileEntityDispenser.setInventorySlotContents(
            par0Random.nextInt(par2TileEntityDispenser.getSizeInventory()), item);
      }
    }
  }
 private boolean addResultToInventory(TileEntityDispenser te, ItemStack result) {
   int size = te.getSizeInventory();
   int i;
   ItemStack itemstack;
   for (i = 0; i < size; ++i) {
     itemstack = te.getStackInSlot(i);
     if (itemstack != null
         && itemstack.isItemEqual(result)
         && itemstack.stackSize + result.stackSize <= itemstack.getMaxStackSize()) {
       itemstack.stackSize += result.stackSize;
       return true;
     }
   }
   for (i = 0; i < size; ++i) {
     itemstack = te.getStackInSlot(i);
     if (itemstack == null || itemstack.itemID == 0) {
       te.setInventorySlotContents(i, result);
       return true;
     }
   }
   return false;
 }