public void connectTo(int x, int y, int z) { TileEntity tileEntity = worldObj.getTileEntity(x, y, z); if (tileEntity instanceof TileMEWireConnector) { TileMEWireConnector connector = (TileMEWireConnector) tileEntity; try { gridConnections.add( AEApi.instance() .createGridConnection( connector.getGridNode(ForgeDirection.UNKNOWN), getGridNode(ForgeDirection.UNKNOWN))); } catch (FailedConnection failedConnection) { failedConnection.printStackTrace(); ImmersiveIntegration.log.error("Something went wrong connecting the flux wire!"); } } }
@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(); } } } } } } }