示例#1
0
  @Override
  public TMultiPart newPart(
      ItemStack stack,
      EntityPlayer player,
      World world,
      BlockCoord coord,
      int face,
      Vector3 vecHit) {
    TransmitterType type = TransmitterType.values()[stack.getItemDamage()];

    if (type.getTransmission() != TransmissionType.ITEM) {
      Coord4D obj = new Coord4D(coord.x, coord.y, coord.z, world.provider.dimensionId);

      List<ITransmitterNetwork<?, ?>> networks = new ArrayList<ITransmitterNetwork<?, ?>>();

      for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity tile = obj.getFromSide(side).getTileEntity(world);

        if (tile instanceof IGridTransmitter
            && TransmissionType.checkTransmissionType(tile, type.getTransmission())) {
          networks.add(((IGridTransmitter) tile).getTransmitterNetwork());
        }
      }

      if (networks.size() > 0) {
        if (!networks.iterator().next().canMerge(networks)) {
          return null;
        }
      }
    }

    return PartTransmitter.getPartType(TransmitterType.values()[getDamage(stack)]);
  }
  private void doPlenish() {
    if (usedNodes.size() >= MAX_NODES) {
      finishedCalc = true;
      return;
    }

    if (activeNodes.isEmpty()) {
      if (usedNodes.isEmpty()) {
        Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN);

        if (!canReplace(below, true, true)) {
          finishedCalc = true;
          return;
        }

        activeNodes.add(below);
      } else {
        finishedCalc = true;
        return;
      }
    }

    Set<Coord4D> toRemove = new HashSet<Coord4D>();

    for (Coord4D coord : activeNodes) {
      if (coord.exists(worldObj)) {
        if (canReplace(coord, true, false)) {
          worldObj.setBlock(
              coord.xCoord,
              coord.yCoord,
              coord.zCoord,
              MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()),
              0,
              3);

          setEnergy(getEnergy() - usage.fluidicPlenisherUsage);
          fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
        }

        for (ForgeDirection dir : dirs) {
          Coord4D sideCoord = coord.getFromSide(dir);

          if (sideCoord.exists(worldObj) && canReplace(sideCoord, true, true)) {
            activeNodes.add(sideCoord);
          }
        }

        toRemove.add(coord);
        break;
      } else {
        toRemove.add(coord);
      }
    }

    for (Coord4D coord : toRemove) {
      activeNodes.remove(coord);
      usedNodes.add(coord);
    }
  }
示例#3
0
  /**
   * Gets the adjacent connections to a TileEntity, from a subset of its sides.
   *
   * @param tileEntity - center TileEntity
   * @param sides - set of sides to check
   * @return boolean[] of adjacent connections
   */
  public static boolean[] getConnections(TileEntity tileEntity, Set<ForgeDirection> sides) {
    boolean[] connectable = new boolean[] {false, false, false, false, false, false};
    Coord4D coord = Coord4D.get(tileEntity);

    for (ForgeDirection side : sides) {
      TileEntity tile = coord.getFromSide(side).getTileEntity(tileEntity.getWorldObj());

      connectable[side.ordinal()] |=
          isEnergyAcceptor(tile) && isConnectable(tileEntity, tile, side);
      connectable[side.ordinal()] |= isCable(tile);
      connectable[side.ordinal()] |= isOutputter(tile, side);
    }

    return connectable;
  }