Package appeng.api.parts

Examples of appeng.api.parts.IPart


        IPartItem bi = (IPartItem) is.getItem();

        is = is.copy();
        is.stackSize = 1;

        IPart bp = bi.createPartFromItemStack( is );
        if ( bp instanceof IPartCable )
        {
          boolean canPlace = true;
          for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
            if ( getPart( d ) != null && !getPart( d ).canBePlacedOn( ((IPartCable) bp).supportsBuses() ) )
              canPlace = false;

          if ( !canPlace )
            return null;

          if ( getPart( ForgeDirection.UNKNOWN ) != null )
            return null;

          setCenter( (IPartCable) bp );
          bp.setPartHostInfo( ForgeDirection.UNKNOWN, this, tcb.getTile() );

          if ( player != null )
            bp.onPlacement( player, is, side );

          if ( inWorld )
            bp.addToWorld();

          IGridNode cn = getCenter().getGridNode();
          if ( cn != null )
          {
            for (ForgeDirection ins : ForgeDirection.VALID_DIRECTIONS)
            {
              IPart sbp = getPart( ins );
              if ( sbp != null )
              {
                IGridNode sn = sbp.getGridNode();
                if ( sn != null )
                {
                  try
                  {
                    new GridConnection( cn, sn, ForgeDirection.UNKNOWN );
                  }
                  catch (FailedConnection e)
                  {
                    // ekk!

                    bp.removeFromWorld();
                    setCenter( null );
                    return null;
                  }
                }
              }
            }
          }

          updateConnections();
          markForUpdate();
          markForSave();
          partChanged();
          return ForgeDirection.UNKNOWN;
        }
        else if ( bp != null && !(bp instanceof IPartCable) && side != ForgeDirection.UNKNOWN )
        {
          IPart cable = getPart( ForgeDirection.UNKNOWN );
          if ( cable != null && !bp.canBePlacedOn( ((IPartCable) cable).supportsBuses() ) )
            return null;

          setSide( side, bp );
          bp.setPartHostInfo( side, this, this.getTile() );
View Full Code Here


    // start with the center, then install the side parts into the grid.
    for (int x = 6; x >= 0; x--)
    {
      ForgeDirection s = ForgeDirection.getOrientation( x );
      IPart part = getPart( s );

      if ( part != null )
      {
        part.setPartHostInfo( s, this, te );
        part.addToWorld();

        if ( s != ForgeDirection.UNKNOWN )
        {
          IGridNode sn = part.getGridNode();
          if ( sn != null )
          {
            // this is a really stupid if statement, why was this
            // here?
            // if ( !sn.getConnections().iterator().hasNext() )

            IPart center = getPart( ForgeDirection.UNKNOWN );
            if ( center != null )
            {
              IGridNode cn = center.getGridNode();
              if ( cn != null )
              {
                try
                {
                  AEApi.instance().createGridConnection( cn, sn );
View Full Code Here

    inWorld = false;

    for (ForgeDirection s : ForgeDirection.values())
    {
      IPart part = getPart( s );
      if ( part != null )
        part.removeFromWorld();
    }

    partChanged();
  }
View Full Code Here

  @Override
  public boolean canConnectRedstone(EnumSet<ForgeDirection> enumSet)
  {
    for (ForgeDirection dir : enumSet)
    {
      IPart part = getPart( dir );
      if ( part != null && part.canConnectRedstone() )
        return true;
    }
    return false;
  }
View Full Code Here

      if ( newType != null )
      {
        if ( newType.getItem() instanceof IPartItem )
        {
          IPart testPart = ((IPartItem) newType.getItem()).createPartFromItemStack( newType );
          if ( testPart instanceof PartP2PTunnel )
          {
            getHost().removePart( side, true );
            ForgeDirection dir = getHost().addPart( newType, side, player );
            IPart newBus = getHost().getPart( dir );

            if ( newBus instanceof PartP2PTunnel )
            {
              PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
              newTunnel.output = true;

              try
              {
                P2PCache p2p = newTunnel.proxy.getP2P();
                p2p.updateFreq( newTunnel, freq );
              }
              catch (GridAccessException e)
              {
                // :P
              }

              newTunnel.onTunnelNetworkChange();
            }

            mc.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
            return true;
          }
        }
      }
      mc.notifyUser( player, MemoryCardMessages.INVALID_MACHINE );
    }
    else if ( tt != null ) // attunement
    {
      ItemStack newType = null;

      switch (tt)
      {
      case LIGHT:
        newType = AEApi.instance().parts().partP2PTunnelLight.stack( 1 );
        break;

      case RF_POWER:
        newType = AEApi.instance().parts().partP2PTunnelRF.stack( 1 );
        break;

      case BC_POWER:
        newType = AEApi.instance().parts().partP2PTunnelMJ.stack( 1 );
        break;

      case FLUID:
        newType = AEApi.instance().parts().partP2PTunnelLiquids.stack( 1 );
        break;

      case IC2_POWER:
        newType = AEApi.instance().parts().partP2PTunnelEU.stack( 1 );
        break;

      case ITEM:
        newType = AEApi.instance().parts().partP2PTunnelItems.stack( 1 );
        break;

      case ME:
        newType = AEApi.instance().parts().partP2PTunnelME.stack( 1 );
        break;

      case REDSTONE:
        newType = AEApi.instance().parts().partP2PTunnelRedstone.stack( 1 );
        break;

      default:
        break;

      }

      if ( newType != null && !Platform.isSameItem( newType, this.is ) )
      {
        boolean oldOutput = output;
        long myFreq = freq;

        getHost().removePart( side, false );
        ForgeDirection dir = getHost().addPart( newType, side, player );
        IPart newBus = getHost().getPart( dir );

        if ( newBus instanceof PartP2PTunnel )
        {
          PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
          newTunnel.output = oldOutput;
View Full Code Here

  }

  @Override
  public IGridNode getGridNode(ForgeDirection side)
  {
    IPart part = getPart( side );
    if ( part != null )
    {
      IGridNode n = part.getExternalFacingNode();
      if ( n != null )
        return n;
    }

    if ( getCenter() != null )
View Full Code Here

    IFacadeContainer fc = getFacadeContainer();
    for (ForgeDirection s : ForgeDirection.values())
    {
      IPartCollisionHelper bch = new BusCollisionHelper( boxes, s, e, visual );

      IPart part = getPart( s );
      if ( part != null )
      {
        if ( ignoreCableConnections && part instanceof IPartCable )
          bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 );
        else
          part.getBoxes( bch );
      }

      if ( AEApi.instance().partHelper().getCableRenderMode().opaqueFacades || !visual )
      {
        if ( includeFacades && s != null && s != ForgeDirection.UNKNOWN )
View Full Code Here

  @Override
  public void onEntityCollision(Entity entity)
  {
    for (ForgeDirection s : ForgeDirection.values())
    {
      IPart part = getPart( s );
      if ( part != null )
        part.onEntityCollision( entity );
    }
  }
View Full Code Here

  public boolean isEmpty()
  {
    IFacadeContainer fc = getFacadeContainer();
    for (ForgeDirection s : ForgeDirection.values())
    {
      IPart part = getPart( s );
      if ( part != null )
        return false;

      if ( s != ForgeDirection.UNKNOWN )
      {
View Full Code Here

  {
    hasRedstone = YesNo.UNDECIDED;

    for (ForgeDirection s : ForgeDirection.values())
    {
      IPart part = getPart( s );
      if ( part != null )
        part.onNeighborChanged();
    }
  }
View Full Code Here

TOP

Related Classes of appeng.api.parts.IPart

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.