public ItemStack dispenseStack(IBlockSource blockSource, ItemStack itemstack) {
    EnumFacing facing = EnumFacing.func_82600_a(blockSource.func_82620_h());
    World world = blockSource.getWorld();
    int targetX = blockSource.getXInt() + facing.func_82601_c();
    int targetY = blockSource.getYInt();
    int targetZ = blockSource.getZInt() + facing.func_82599_e();

    TileEntity te = world.getBlockTileEntity(targetX, targetY, targetZ);
    if (te != null && te instanceof ITankContainer) {
      return fillOrEmptyContainer((ITankContainer) te, itemstack, facing);
    }
    if (world.isAirBlock(targetX, targetY, targetZ)) {
      TileEntity tileabove = world.getBlockTileEntity(targetX, targetY + 1, targetZ);
      TileEntity tilebelow = world.getBlockTileEntity(targetX, targetY - 1, targetZ);
      if (tileabove != null && LiquidContainerRegistry.isEmptyContainer(itemstack)) {
        return fillContainer((ITankContainer) tileabove, itemstack, EnumFacing.UP);
      }
      if (tilebelow != null && LiquidContainerRegistry.isFilledContainer(itemstack)) {
        return emptyContainer((ITankContainer) tilebelow, itemstack, EnumFacing.DOWN);
      }
    }
    System.out.println("Not matched");

    return null;
  }
 protected void spawnDispenseParticles(IBlockSource blockSource) {
   EnumFacing facing = EnumFacing.func_82600_a(blockSource.func_82620_h());
   blockSource
       .getWorld()
       .playAuxSFX(
           2000,
           blockSource.getXInt(),
           blockSource.getYInt(),
           blockSource.getZInt(),
           facing.func_82601_c() + 1 + (facing.func_82599_e() + 1) * 3);
 }
 @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;
  }
示例#6
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);
          }
        }
 protected void playDispenseSound(IBlockSource blockSource) {
   blockSource
       .getWorld()
       .playAuxSFX(1000, blockSource.getXInt(), blockSource.getYInt(), blockSource.getZInt(), 0);
 }