Package appeng.api.util

Examples of appeng.api.util.DimensionalCoord


  @Override
  public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
  {
    talkBackTo = player;

    DimensionalCoord loc = new DimensionalCoord( player.worldObj, this.cx << 4, this.cdy << 5, this.cz << 4 );
    WorldSettings.getInstance().getCompass().getCompassDirection( loc, 174, this );
  }
View Full Code Here


  @Override
  public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
  {
    Block b = world.getBlock( x, y, z );
    if ( b != null && !player.isSneaking() && Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) )
    {
      if ( Platform.isClient() )
        return !world.isRemote;

      ForgeDirection mySide = ForgeDirection.getOrientation( side );
View Full Code Here

    if ( !gridProxy.isWorldAccessible() )
      return;

    EnumSet<ForgeDirection> newSecurityConnections = EnumSet.noneOf( ForgeDirection.class );

    DimensionalCoord dc = gridProxy.getLocation();
    for (ForgeDirection f : ForgeDirection.VALID_DIRECTIONS)
    {
      IGridHost te = findGridHost( dc.getWorld(), dc.x + f.offsetX, dc.y + f.offsetY, dc.z + f.offsetZ );
      if ( te != null )
      {
        GridNode node = (GridNode) te.getGridNode( f.getOpposite() );
        if ( node == null )
          continue;

        boolean isValidConnection = this.canConnect( node, f ) && node.canConnect( this, f.getOpposite() );

        IGridConnection con = null; // find the connection for this
                      // direction..
        for (IGridConnection c : getConnections())
        {
          if ( c.getDirection( this ) == f )
          {
            con = c;
            break;
          }
        }

        if ( con != null )
        {
          IGridNode os = con.getOtherSide( this );
          if ( os == node )
          {
            // if this connection is no longer valid, destroy it.
            if ( !isValidConnection )
              con.destroy();
          }
          else
          {
            con.destroy();
            // throw new GridException( "invalid state found, encountered connection to phantom block." );
          }
        }
        else if ( isValidConnection )
        {
          if ( node.lastSecurityKey != -1 )
            newSecurityConnections.add( f );
          else
          {
            // construct a new connection between these two nodes.
            try
            {
              new GridConnection( node, this, f.getOpposite() );
            }
            catch (FailedConnection e)
            {
              TickHandler.instance.addCallable( node.getWorld(), new Callable() {

                @Override
                public Object call() throws Exception
                {
                  getMachine().securityBreak();
                  return null;
                }

              } );

              return;
            }
          }
        }

      }
    }

    for (ForgeDirection f : newSecurityConnections)
    {
      IGridHost te = findGridHost( dc.getWorld(), dc.x + f.offsetX, dc.y + f.offsetY, dc.z + f.offsetZ );
      if ( te != null )
      {
        GridNode node = (GridNode) te.getGridNode( f.getOpposite() );
        if ( node == null )
          continue;
View Full Code Here

  public boolean serverSideToolLogic(ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
  {
    if ( side >= 0 )
    {
      if ( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
        return false;

      Block b = w.getBlock( x, y, z );
      if ( b != null && !p.isSneaking() )
      {
View Full Code Here

    return AECableType.SMART;
  }

  public DimensionalCoord getLocation()
  {
    return new DimensionalCoord( iHost.getTileEntity() );
  }
View Full Code Here

            if ( g != null )
            {
              ISpatialCache sc = g.getCache( ISpatialCache.class );
              if ( sc.isValidRegion() )
              {
                DimensionalCoord min = sc.getMin();
                DimensionalCoord max = sc.getMax();

                x += currentSideOff.offsetX;
                y += currentSideOff.offsetY;
                z += currentSideOff.offsetZ;
View Full Code Here

    ForgeDirection side = ForgeDirection.getOrientation( face );

    if ( held != null && Platform.isWrench( player, held, x, y, z ) && player.isSneaking() )
    {
      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 )
View Full Code Here

  }

  @Override
  public DimensionalCoord getLocation()
  {
    return new DimensionalCoord( this );
  }
View Full Code Here

  }

  @Override
  public DimensionalCoord getLocation()
  {
    return new DimensionalCoord( this );
  }
View Full Code Here

  }

  @Override
  public DimensionalCoord getLocation()
  {
    return new DimensionalCoord( this );
  }
View Full Code Here

TOP

Related Classes of appeng.api.util.DimensionalCoord

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.