Exemplo n.º 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);
 }
Exemplo n.º 2
0
 public static IPosition func_82525_a(IBlockSource p_82525_0_) {
   EnumFacing var1 = func_100009_j_(p_82525_0_.func_82620_h());
   double var2 = p_82525_0_.func_82615_a() + 0.7D * (double) var1.func_82601_c();
   double var4 = p_82525_0_.func_82617_b() + 0.7D * (double) var1.func_96559_d();
   double var6 = p_82525_0_.func_82616_c() + 0.7D * (double) var1.func_82599_e();
   return new PositionImpl(var2, var4, var6);
 }
  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;
  }
Exemplo n.º 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_);
   }
 }
 @Override
 public ItemStack dispense(IBlockSource blockSource, ItemStack itemstack) {
   ItemStack result = dispenseStack(blockSource, itemstack);
   if (result == null) {
     System.out.println("Not processed. Chain to Vanilla.");
     return chain.dispense(blockSource, itemstack);
   }
   if (result.stackSize <= 0) {
     // The result was empty.
   } else if (addResultToInventory((TileEntityDispenser) blockSource.func_82619_j(), result)) {
     // The result was placed in inventory.
   } else if (itemstack.stackSize <= 0) {
     itemstack.itemID = result.itemID;
     itemstack.setItemDamage(result.getItemDamage());
     itemstack.stackSize = result.stackSize;
   } else {
     defaultDispenseBehavior.dispense(blockSource, result);
   }
   playDispenseSound(blockSource);
   spawnDispenseParticles(blockSource);
   return itemstack;
 }
 protected void playDispenseSound(IBlockSource blockSource) {
   blockSource
       .getWorld()
       .playAuxSFX(1000, blockSource.getXInt(), blockSource.getYInt(), blockSource.getZInt(), 0);
 }