Package appeng.core.sync.packets

Examples of appeng.core.sync.packets.PacketMEInventoryUpdate


        else
          simulation = true;

        try
        {
          PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
          PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
          PacketMEInventoryUpdate c = result.isSimulation() ? new PacketMEInventoryUpdate( (byte) 2 ) : null;

          IItemList<IAEItemStack> plan = AEApi.instance().storage().createItemList();
          result.populatePlan( plan );

          bytesUsed = result.getByteTotal();

          for (IAEItemStack out : plan)
          {
            IAEItemStack m = null;

            IAEItemStack o = out.copy();
            o.reset();
            o.setStackSize( out.getStackSize() );

            IAEItemStack p = out.copy();
            p.reset();
            p.setStackSize( out.getCountRequestable() );

            IStorageGrid sg = getGrid().getCache( IStorageGrid.class );
            IMEInventory<IAEItemStack> items = sg.getItemInventory();

            if ( c != null && result.isSimulation() )
            {
              m = o.copy();
              o = items.extractItems( o, Actionable.SIMULATE, mySrc );

              if ( o == null )
              {
                o = m.copy();
                o.setStackSize( 0 );
              }

              m.setStackSize( m.getStackSize() - o.getStackSize() );
            }

            if ( o.getStackSize() > 0 )
              a.appendItem( o );

            if ( p.getStackSize() > 0 )
              b.appendItem( p );

            if ( c != null && m != null && m.getStackSize() > 0 )
              c.appendItem( m );
          }

          for (Object g : this.crafters)
          {
            if ( g instanceof EntityPlayer )
View Full Code Here


        powerUsage = (long) (100.0 * eg.getAvgPowerUsage());
        currentPower = (long) (100.0 * eg.getStoredPower());
        maxPower = (long) (100.0 * eg.getMaxStoredPower());
      }

      PacketMEInventoryUpdate piu;
      try
      {
        piu = new PacketMEInventoryUpdate();

        for (Class<? extends IGridHost> machineClass : network.getMachinesClasses())
        {
          IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
          for (IGridNode machine : network.getMachines( machineClass ))
          {
            IGridBlock blk = machine.getGridBlock();
            ItemStack is = blk.getMachineRepresentation();
            if ( is != null && is.getItem() != null )
            {
              IAEItemStack ais = AEItemStack.create( is );
              ais.setStackSize( 1 );
              ais.setCountRequestable( (long) (blk.getIdlePowerUsage() * 100.0) );
              list.add( ais );
            }
          }

          for (IAEItemStack ais : list)
            piu.appendItem( ais );
        }

        for (Object c : this.crafters)
        {
          if ( c instanceof EntityPlayer )
View Full Code Here

  {
    if ( Platform.isServer() && monitor != null && !list.isEmpty() )
    {
      try
      {
        PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
        PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
        PacketMEInventoryUpdate c = new PacketMEInventoryUpdate( (byte) 2 );

        for (IAEItemStack out : list)
        {
          a.appendItem( monitor.getItemStack( out, CraftingItemList.STORAGE ) );
          b.appendItem( monitor.getItemStack( out, CraftingItemList.ACTIVE ) );
          c.appendItem( monitor.getItemStack( out, CraftingItemList.PENDING ) );
        }

        list.resetStatus();

        for (Object g : this.crafters)
        {
          if ( g instanceof EntityPlayer )
          {
            if ( !a.isEmpty() )
              NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );

            if ( !b.isEmpty() )
              NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );

            if ( !c.isEmpty() )
              NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
          }
        }
      }
      catch (IOException e)
View Full Code Here

      {
        try
        {
          IItemList<IAEItemStack> monitorCache = monitor.getStorageList();

          PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();

          for (IAEItemStack is : items)
          {
            IAEItemStack send = monitorCache.findPrecise( is );
            if ( send == null )
            {
              is.setStackSize( 0 );
              piu.appendItem( is );
            }
            else
              piu.appendItem( send );
          }

          if ( !piu.isEmpty() )
          {
            items.resetStatus();

            for (Object c : this.crafters)
            {
View Full Code Here

  {
    if ( Platform.isServer() && c instanceof EntityPlayer && monitor != null )
    {
      try
      {
        PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
        IItemList<IAEItemStack> monitorCache = monitor.getStorageList();

        for (IAEItemStack send : monitorCache)
        {
          try
          {
            piu.appendItem( send );
          }
          catch (BufferOverflowException boe)
          {
            NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );

            piu = new PacketMEInventoryUpdate();
            piu.appendItem( send );
          }
        }

        NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
      }
View Full Code Here

TOP

Related Classes of appeng.core.sync.packets.PacketMEInventoryUpdate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.