protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
   EnumFacing var3 = BlockDispenser.getFacing(source.getBlockMetadata());
   IPosition var4 = BlockDispenser.getDispensePosition(source);
   ItemStack var5 = stack.splitStack(1);
   doDispense(source.getWorld(), var5, 6, var3, var4);
   return stack;
 }
  /** Dispense the specified stack, play the dispense sound and spawn particles. */
  public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
    EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
    World world = par1IBlockSource.getWorld();
    double d0 = par1IBlockSource.getX() + (double) ((float) enumfacing.getFrontOffsetX() * 1.125F);
    double d1 = par1IBlockSource.getY() + (double) ((float) enumfacing.getFrontOffsetY() * 1.125F);
    double d2 = par1IBlockSource.getZ() + (double) ((float) enumfacing.getFrontOffsetZ() * 1.125F);
    int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
    int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
    int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
    Material material = world.getBlockMaterial(i, j, k);
    double d3;

    if (Material.water.equals(material)) {
      d3 = 1.0D;
    } else {
      if (!Material.air.equals(material)
          || !Material.water.equals(world.getBlockMaterial(i, j - 1, k))) {
        return this.defaultDispenserItemBehavior.dispense(par1IBlockSource, par2ItemStack);
      }

      d3 = 0.0D;
    }

    EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
    world.spawnEntityInWorld(entityboat);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
  }
Пример #3
0
 public ItemStack dispenseItem(ItemStack it, boolean sim) {
   ForgeDirection side = getSideFacing();
   TileEntity te =
       worldObj.getTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ);
   if (te != null && te instanceof IInventory) {
     ItemStack rem = ItemUtil.addItemToNearbyInventories(this, it, false, sim, side);
     return rem;
   } else {
     if (!sim) {
       BlockSourceImpl impl = new BlockSourceImpl(worldObj, xCoord, yCoord, zCoord);
       BehaviorDefaultDispenseItem.doDispense(
           worldObj,
           it,
           6,
           BlockDispenser.func_149937_b(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)),
           BlockDispenser.func_149939_a(impl));
     }
     return null;
   }
 }
 @Override
 protected ItemStack dispenseStack(IBlockSource dispenser, ItemStack dispensedItem) {
   EnumFacing enumfacing = BlockDispenser.func_149937_b(dispenser.getBlockMetadata());
   World world = dispenser.getWorld();
   int i = dispenser.getXInt() + enumfacing.getFrontOffsetX();
   int j = dispenser.getYInt() + enumfacing.getFrontOffsetY();
   int k = dispenser.getZInt() + enumfacing.getFrontOffsetZ();
   EntityTinyTNTPrimed primedTinyTNTEntity =
       new EntityTinyTNTPrimed(world, i + 0.5F, j + 0.5F, k + 0.5F, null);
   world.spawnEntityInWorld(primedTinyTNTEntity);
   --dispensedItem.stackSize;
   return dispensedItem;
 }
  @Override
  public ItemStack dispenseStack(IBlockSource block, ItemStack stack) {
    EnumFacing enumfacing = BlockDispenser.func_149937_b(block.getBlockMetadata());
    double d0 = block.getX() + enumfacing.getFrontOffsetX();
    double d1 = block.getYInt() + 0.2F;
    double d2 = block.getZ() + enumfacing.getFrontOffsetZ();
    Entity entity = ItemEntityEgg.spawnEntity(block.getWorld(), stack.getItemDamage(), d0, d1, d2);

    if (entity instanceof EntityLivingBase && stack.hasDisplayName())
      ((EntityLiving) entity).setCustomNameTag(stack.getDisplayName());

    stack.splitStack(1);
    return stack;
  }
  public ItemStack dispenseStack(IBlockSource BlockSource, ItemStack stack) {
    EnumFacing enumfacing = BlockDispenser.getFacing(BlockSource.getBlockMetadata());
    double d0 = BlockSource.getX() + (double) enumfacing.getFrontOffsetX();
    double d1 = BlockSource.getY() + (double) enumfacing.getFrontOffsetY();
    double d2 = BlockSource.getZ() + (double) enumfacing.getFrontOffsetZ();
    Entity entity =
        ItemGaiaSpawnEgg.spawnCreature(BlockSource.getWorld(), stack.getItemDamage(), d0, d1, d2);

    if (entity instanceof EntityLivingBase && stack.hasDisplayName()) {
      ((EntityLiving) entity).setCustomNameTag(stack.getDisplayName());
    }

    stack.splitStack(1);
    return stack;
  }
 /** Dispense the specified stack, play the dispense sound and spawn particles. */
 protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
   EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
   World world = par1IBlockSource.getWorld();
   int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
   int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
   int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
   EntityTNTPrimed entitytntprimed =
       new EntityTNTPrimed(
           world,
           (double) ((float) i + 0.5F),
           (double) ((float) j + 0.5F),
           (double) ((float) k + 0.5F),
           (EntityLivingBase) null);
   world.spawnEntityInWorld(entitytntprimed);
   --par2ItemStack.stackSize;
   return par2ItemStack;
 }
Пример #8
0
        protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
          BlockPos blockpos =
              source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
          int i = blockpos.getX();
          int j = blockpos.getY();
          int k = blockpos.getZ();
          AxisAlignedBB axisalignedbb =
              new AxisAlignedBB(
                  (double) i,
                  (double) j,
                  (double) k,
                  (double) (i + 1),
                  (double) (j + 1),
                  (double) (k + 1));
          List<EntityLivingBase> list =
              source
                  .getWorld()
                  .<EntityLivingBase>getEntitiesWithinAABB(
                      EntityLivingBase.class,
                      axisalignedbb,
                      Predicates.<EntityLivingBase>and(
                          EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));

          if (list.size() > 0) {
            EntityLivingBase entitylivingbase = (EntityLivingBase) list.get(0);
            int l = entitylivingbase instanceof EntityPlayer ? 1 : 0;
            int i1 = EntityLiving.getArmorPosition(stack);
            ItemStack itemstack = stack.copy();
            itemstack.stackSize = 1;
            entitylivingbase.setCurrentItemOrArmor(i1 - l, itemstack);

            if (entitylivingbase instanceof EntityLiving) {
              ((EntityLiving) entitylivingbase).setEquipmentDropChance(i1, 2.0F);
            }

            --stack.stackSize;
            return stack;
          } else {
            return super.dispenseStack(source, stack);
          }
        }
 public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) {
   ItemBucket var3 = (ItemBucket) p_82487_2_.func_77973_b();
   int var4 = p_82487_1_.func_82623_d();
   int var5 = p_82487_1_.func_82622_e();
   int var6 = p_82487_1_.func_82621_f();
   EnumFacing var7 = BlockDispenser.func_100009_j_(p_82487_1_.func_82620_h());
   if (var3.func_77875_a(
       p_82487_1_.func_82618_k(),
       (double) var4,
       (double) var5,
       (double) var6,
       var4 + var7.func_82601_c(),
       var5 + var7.func_96559_d(),
       var6 + var7.func_82599_e())) {
     p_82487_2_.field_77993_c = Item.field_77788_aw.field_77779_bT;
     p_82487_2_.field_77994_a = 1;
     return p_82487_2_;
   } else {
     return this.field_96459_b.func_82482_a(p_82487_1_, p_82487_2_);
   }
 }
 public final ItemStack dispense(IBlockSource source, ItemStack stack) {
   ItemStack var3 = this.dispenseStack(source, stack);
   this.playDispenseSound(source);
   this.spawnDispenseParticles(source, BlockDispenser.getFacing(source.getBlockMetadata()));
   return var3;
 }