Пример #1
0
 /** Get the position where the dispenser at the given Coordinates should dispense to. */
 public static IPosition getDispensePosition(IBlockSource coords) {
   EnumDirection var1 = getFacing(coords.getBlockMetadata());
   double var2 = coords.getX() + 0.7D * var1.getOffsetX();
   double var4 = coords.getY() + 0.7D * var1.getOffsetY();
   double var6 = coords.getZ() + 0.7D * var1.getOffsetZ();
   return new PositionImpl(var2, var4, var6);
 }
 @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;
  }
Пример #5
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);
          }
        }