示例#1
0
 @Override
 @Method(modid = "appliedenergistics2")
 public void connectionsChanged() {
   super.connectionsChanged();
   BlockCoord loc = getLocation();
   if (loc != null) {
     onNodeChanged(loc);
     IGridNode node = getNode();
     if (node != null) {
       node.updateState();
       node.getWorld().markBlockForUpdate(loc.x, loc.y, loc.z);
     }
   }
 }
示例#2
0
 @Method(modid = "appliedenergistics2")
 private void onNodeChanged(BlockCoord location) {
   World world = getBundle().getWorld();
   for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
     TileEntity te = location.getLocation(dir).getTileEntity(world);
     if (te != null && te instanceof IGridHost && !(te instanceof IConduitBundle)) {
       IGridNode node = ((IGridHost) te).getGridNode(ForgeDirection.UNKNOWN);
       if (node == null) {
         node = ((IGridHost) te).getGridNode(dir.getOpposite());
       }
       if (node != null) {
         node.updateState();
       }
     }
   }
 }
  @Override
  public void updateEntity() {
    if (!loaded && hasWorldObj() && !worldObj.isRemote) {
      loaded = true;
      createAELink();
      for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity tileEntity =
            worldObj.getTileEntity(
                xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
        if (tileEntity instanceof IGridHost) {
          IGridNode node = ((IGridHost) tileEntity).getGridNode(direction);
          if (node != null) {
            node.updateState();
          }
        }

        for (ImmersiveNetHandler.Connection connection :
            ImmersiveNetHandler.INSTANCE.getConnections(worldObj, Utils.toCC(this))) {
          ChunkCoordinates opposite = connection.end;
          if (connection.end.equals(Utils.toCC(this))) {
            opposite = connection.start;
          }

          TileEntity teOpposite =
              worldObj.getTileEntity(opposite.posX, opposite.posY, opposite.posZ);
          if (teOpposite instanceof TileMEWireConnector) {
            GridNode nodeA =
                (GridNode) ((TileMEWireConnector) teOpposite).getGridNode(ForgeDirection.UNKNOWN);
            GridNode nodeB = (GridNode) getGridNode(ForgeDirection.UNKNOWN);
            if (!nodeA.hasConnection(nodeB) && !nodeB.hasConnection(nodeA)) {
              try {
                gridConnections.add(AEApi.instance().createGridConnection(nodeA, nodeB));
              } catch (FailedConnection failedConnection) {
                failedConnection.printStackTrace();
              }
            }
          }
        }
      }
    }
  }
 public void createAELink() {
   if (!worldObj.isRemote) {
     if (theGridNode == null) theGridNode = AEApi.instance().createGridNode(this);
     theGridNode.updateState();
   }
 }