コード例 #1
0
 protected boolean moveTo(ForgeDirection side, boolean simulate) {
   TileEntity tile = owner.getNeighborTile(side);
   if (tile instanceof TileConveyorBelt) {
     return ((TileConveyorBelt) tile).injectObject(this, output.getOpposite(), true, simulate);
   }
   return false;
 }
コード例 #2
0
  protected boolean chooseOutput() {
    List<ForgeDirection> conveyorSides = new ArrayList<ForgeDirection>();
    List<ForgeDirection> machineSides = new ArrayList<ForgeDirection>();
    List<ForgeDirection> emptySides = new ArrayList<ForgeDirection>();
    List<ForgeDirection> sides;

    for (ForgeDirection d : allowedOutputs) {
      if (moveTo(d, true)) {
        TileEntity tile = owner.getNeighborTile(d);
        if (tile instanceof ITravellingObjectContainer) {
          conveyorSides.add(d);
        } else if (tile != null) {
          machineSides.add(d);
        } else {
          emptySides.add(d);
        }
      }
    }

    sides =
        machineSides.size() > 0
            ? machineSides
            : (conveyorSides.size() > 0 ? conveyorSides : emptySides);
    if (sides.size() > 0) {
      Collections.shuffle(sides);
      output = sides.get(0);
      return true;
    }
    return false;
  }