Package appeng.api.parts

Examples of appeng.api.parts.IPartHost


  public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer)
  {
    Object object = cb( world, target.blockX, target.blockY, target.blockZ );
    if ( object instanceof IPartHost )
    {
      IPartHost host = (IPartHost) object;

      for (ForgeDirection side : ForgeDirection.values())
      {
        IPart p = host.getPart( side );
        IIcon ico = getIcon( p );

        if ( ico == null )
          continue;
View Full Code Here


  public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
  {
    Object object = cb( world, x, y, z );
    if ( object instanceof IPartHost )
    {
      IPartHost host = (IPartHost) object;

      for (ForgeDirection side : ForgeDirection.values())
      {
        IPart p = host.getPart( side );
        IIcon ico = getIcon( p );

        if ( ico == null )
          continue;
View Full Code Here

  IIcon getConnectedCable(IBlockAccess world, int x, int y, int z, ForgeDirection d, boolean covered)
  {
    TileEntity ne = world.getTileEntity( x + d.offsetX, y + d.offsetY, z + d.offsetZ );
    if ( ne instanceof IGridHost && ne instanceof IPartHost )
    {
      IPartHost ph = (IPartHost) ne;
      IPart pcx = ph.getPart( ForgeDirection.UNKNOWN );
      if ( pcx instanceof PartCable )
      {
        PartCable pc = (PartCable) pcx;
        if ( pc.isConnected( d.getOpposite() ) )
        {
View Full Code Here

    int minX = 1;
    int minY = 1;
    int maxX = 15;
    int maxY = 15;

    IPartHost host = getHost();
    if ( host != null )
    {
      TileEntity te = host.getTile();

      int x = te.xCoord;
      int y = te.yCoord;
      int z = te.zCoord;
View Full Code Here

  private boolean alphaDiff(TileEntity tileEntity, ForgeDirection side, IFacadePart facade)
  {
    if ( tileEntity instanceof IPartHost )
    {
      IPartHost ph = (IPartHost) tileEntity;
      IFacadePart fp = ph.getFacadeContainer().getFacade( side );

      return fp == null || (fp.isTransparent() != facade.isTransparent());
    }

    return true;
View Full Code Here

  @SideOnly(Side.CLIENT)
  public void renderDenseConnection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, int channels, ForgeDirection of)
  {
    TileEntity te = this.tile.getWorldObj().getTileEntity( x + of.offsetX, y + of.offsetY, z + of.offsetZ );
    IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null;
    IGridHost ghh = te instanceof IGridHost ? (IGridHost) te : null;
    boolean isGlass = false;
    AEColor myColor = getCableColor();
    /*
     * ( ghh != null && partHost != null && ghh.getCableConnectionType( of ) == AECableType.GLASS && partHost.getPart(
     * of.getOpposite() ) == null ) { isGlass = true; rh.setTexture( getGlassTexture( myColor = partHost.getColor() ) );
     * } else if ( partHost == null && ghh != null && ghh.getCableConnectionType( of ) != AECableType.GLASS ) {
     * rh.setTexture( getSmartTexture( myColor ) ); switch (of) { case DOWN: rh.setBounds( 3, 0, 3, 13, 4, 13 );
     * break; case EAST: rh.setBounds( 12, 3, 3, 16, 13, 13 ); break; case NORTH: rh.setBounds( 3, 3, 0, 13, 13, 4
     * ); break; case SOUTH: rh.setBounds( 3, 3, 12, 13, 13, 16 ); break; case UP: rh.setBounds( 3, 12, 3, 13, 16,
     * 13 ); break; case WEST: rh.setBounds( 0, 3, 3, 4, 13, 13 ); break; default: return; } rh.renderBlock( x, y,
     * z, renderer );
     *
     * if ( true ) { setSmartConnectionRotations( of, renderer ); IIcon firstIcon = new TaughtIcon( getChannelTex(
     * channels, false ).getIcon(), -0.2f ); IIcon secondIcon = new TaughtIcon( getChannelTex( channels, true ).getIcon(),
     * -0.2f );
     *
     * if ( of == ForgeDirection.EAST || of == ForgeDirection.WEST ) { AEBaseBlock blk = (AEBaseBlock)
     * rh.getBlock(); FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST ); ico.setFlip(
     * false, true ); }
     *
     * Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 ); Tessellator.instance.setColorOpaque_I(
     * myColor.mediumVariant ); rh.setTexture( firstIcon, firstIcon, firstIcon, firstIcon, firstIcon, firstIcon ); renderAllFaces( (AEBaseBlock)
     * rh.getBlock(), x, y, z, renderer );
     *
     * Tessellator.instance.setColorOpaque_I( myColor.whiteVariant ); rh.setTexture( secondIcon, secondIcon, secondIcon, secondIcon, secondIcon,
     * secondIcon ); renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
     *
     * renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth =
     * renderer.uvRotateTop = renderer.uvRotateWest = 0; }
     *
     * rh.setTexture( getTexture( getCableColor() ) ); }
     */

    rh.setFacesToRender( EnumSet.complementOf( EnumSet.of( of, of.getOpposite() ) ) );
    if ( ghh != null && partHost != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && partHost.getColor() != AEColor.Transparent
        && partHost.getPart( of.getOpposite() ) == null )
      rh.setTexture( getTexture( myColor = partHost.getColor() ) );
    else
      rh.setTexture( getTexture( getCableColor() ) );

    switch (of)
    {
View Full Code Here

    rh.setTexture( getTexture( getCableColor() ) );

    EnumSet<ForgeDirection> sides = connections.clone();

    boolean hasBuses = false;
    IPartHost ph = getHost();
    for (ForgeDirection of : EnumSet.complementOf( connections ))
    {
      IPart bp = ph.getPart( of );
      if ( bp instanceof IGridHost )
      {
        if ( of != ForgeDirection.UNKNOWN )
        {
          sides.add( of );
View Full Code Here

    rh.setTexture( getTexture( getCableColor() ) );

    EnumSet<ForgeDirection> sides = connections.clone();

    boolean hasBuses = false;
    IPartHost ph = getHost();
    for (ForgeDirection of : EnumSet.complementOf( connections ))
    {
      IPart bp = ph.getPart( of );
      if ( bp instanceof IGridHost )
      {
        if ( of != ForgeDirection.UNKNOWN )
        {
          sides.add( of );
View Full Code Here

      if ( !Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) )
        return false;

      Block block = world.getBlock( x, y, z );
      TileEntity tile = world.getTileEntity( x, y, z );
      IPartHost host = null;

      if ( tile instanceof IPartHost )
        host = (IPartHost) tile;

      if ( host != null )
      {
        if ( !world.isRemote )
        {
          LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
          MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
          if ( mop != null )
          {
            List<ItemStack> is = new LinkedList<ItemStack>();
            SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );

            if ( sp.part != null )
            {
              is.add( sp.part.getItemStack( PartItemStack.Wrench ) );
              sp.part.getDrops( is, true );
              host.removePart( sp.side, false );
            }

            if ( sp.facade != null )
            {
              is.add( sp.facade.getItemStack() );
              host.getFacadeContainer().removeFacade( host, sp.side );
              Platform.notifyBlocksOfNeighbors( world, x, y, z );
            }

            if ( host.isEmpty() )
              host.cleanup();

            if ( !is.isEmpty() )
            {
              Platform.spawnDrops( world, x, y, z, is );
            }
          }
        }
        else
        {
          player.swingItem();
          NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
        }
        return true;
      }

      return false;
    }

    TileEntity tile = world.getTileEntity( x, y, z );
    IPartHost host = null;

    if ( tile instanceof IPartHost )
      host = (IPartHost) tile;

    if ( held != null )
    {
      IFacadePart fp = isFacade( held, side );
      if ( fp != null )
      {
        if ( host != null )
        {
          if ( !world.isRemote )
          {
            if ( host.getPart( ForgeDirection.UNKNOWN ) == null )
              return false;

            if ( host.canAddPart( held, side ) )
            {
              if ( host.getFacadeContainer().addFacade( fp ) )
              {
                host.markForUpdate();
                if ( !player.capabilities.isCreativeMode )
                {
                  held.stackSize--;
                  if ( held.stackSize == 0 )
                  {
                    player.inventory.mainInventory[player.inventory.currentItem] = null;
                    MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
                  }
                }
                return true;
              }
            }
          }
          else
          {
            player.swingItem();
            NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
            return true;
          }
        }
        return false;
      }
    }

    if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
      host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );

    if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
      host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile );

    // if ( held == null )
    {
      Block block = world.getBlock( x, y, z );
      if ( host != null && player.isSneaking() && block != null )
      {
        LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
        MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
        if ( mop != null )
        {
          mop.hitVec = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
          SelectedPart sPart = selectPart( player, host, mop.hitVec );
          if ( sPart != null && sPart.part != null )
            if ( sPart.part.onShiftActivate( player, mop.hitVec ) )
            {
              if ( world.isRemote )
              {
                NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
              }
              return true;
            }
        }
      }

    }

    if ( held == null || !(held.getItem() instanceof IPartItem) )
      return false;

    int te_x = x;
    int te_y = y;
    int te_z = z;

    if ( host == null && pass == PlaceType.PLACE_ITEM )
    {
      ItemStack is = AEApi.instance().blocks().blockMultiPart.stack( 1 );
      ItemBlock ib = (ItemBlock) is.getItem();
      ForgeDirection offset = ForgeDirection.UNKNOWN;

      Block blkID = world.getBlock( x, y, z );
      if ( blkID != null && !blkID.isReplaceable( world, x, y, z ) )
      {
        offset = side;
        if ( Platform.isServer() )
          side = side.getOpposite();
      }

      te_x = x + offset.offsetX;
      te_y = y + offset.offsetY;
      te_z = z + offset.offsetZ;

      tile = world.getTileEntity( te_x, te_y, te_z );
      if ( tile instanceof IPartHost )
        host = (IPartHost) tile;

      if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
        host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );

      if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
        host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile );

      if ( host == null && AEApi.instance().blocks().blockMultiPart.block().canPlaceBlockAt( world, te_x, te_y, te_z )
          && ib.placeBlockAt( is, player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) )
      {
        if ( !world.isRemote )
        {
          tile = world.getTileEntity( te_x, te_y, te_z );

          if ( tile instanceof IPartHost )
            host = (IPartHost) tile;

          pass = PlaceType.INTERACT_SECOND_PASS;
        }
        else
        {
          player.swingItem();
          NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
          return true;
        }
      }
      else if ( host != null && !host.canAddPart( held, side ) )
        return false;
    }

    if ( host == null )
      return false;

    if ( !host.canAddPart( held, side ) )
    {
      if ( pass == PlaceType.INTERACT_FIRST_PASS || pass == PlaceType.PLACE_ITEM )
      {
        te_x = x + side.offsetX;
        te_y = y + side.offsetY;
        te_z = z + side.offsetZ;

        Block blkID = world.getBlock( te_x, te_y, te_z );
        tile = world.getTileEntity( te_x, te_y, te_z );

        if ( tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
          host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );

        if ( (blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null) && side != ForgeDirection.UNKNOWN )
          return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world,
              pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
      }
      return false;
    }

    if ( !world.isRemote )
    {
      Block block = world.getBlock( x, y, z );
      LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
      MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
      if ( mop != null )
      {
        SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );

        if ( sp.part != null )
        {
          if ( !player.isSneaking() && sp.part.onActivate( player, mop.hitVec ) )
            return false;
        }
      }

      DimensionalCoord dc = host.getLocation();
      if ( !Platform.hasPermissions( dc, player ) )
        return false;

      ForgeDirection mySide = host.addPart( held, side, player );
      if ( mySide != null )
      {
        SoundType ss = AEApi.instance().blocks().blockMultiPart.block().stepSound;

        // ss.getPlaceSound()
View Full Code Here

    int minX = 1;
    int minY = 1;
    int maxX = 15;
    int maxY = 15;

    IPartHost host = getHost();
    if ( host != null )
    {
      TileEntity te = host.getTile();

      int x = te.xCoord;
      int y = te.yCoord;
      int z = te.zCoord;
View Full Code Here

TOP

Related Classes of appeng.api.parts.IPartHost

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.