Exemplo n.º 1
0
 protected boolean middleReached(TravelingItem item) {
   float middleLimit = item.getSpeed() * 1.01F;
   return (Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit
       && Math.abs(
               container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()) - item.yCoord)
           < middleLimit
       && Math.abs(container.zCoord + 0.5 - item.zCoord) < middleLimit);
 }
Exemplo n.º 2
0
  private void readjustPosition(TravelingItem item) {
    double x = item.xCoord;
    double y = item.yCoord;
    double z = item.zCoord;

    x = Math.max(x, container.xCoord + 0.01);
    y = Math.max(y, container.yCoord + 0.01);
    z = Math.max(z, container.zCoord + 0.01);

    x = Math.min(x, container.xCoord + 0.99);
    y = Math.min(y, container.yCoord + 0.99);
    z = Math.min(z, container.zCoord + 0.99);

    if (item.input != ForgeDirection.UP && item.input != ForgeDirection.DOWN) {
      y = container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack());
    }

    item.setPosition(x, y, z);
  }
Exemplo n.º 3
0
  private void moveSolids() {
    items.performLoad();
    items.performRemoval();

    for (TravelingItem item : items) {
      if (item.isCorrupted()) {
        items.scheduleRemoval(item);
        continue;
      }

      if (item.getContainer() != this.container) {
        items.scheduleRemoval(item);
        continue;
      }

      Position motion = new Position(0, 0, 0, item.toCenter ? item.input : item.output);
      motion.moveForwards(item.getSpeed());

      item.movePosition(motion.x, motion.y, motion.z);

      if ((item.toCenter && middleReached(item)) || outOfBounds(item)) {
        item.toCenter = false;

        // Reajusting to the middle
        item.setPosition(
            container.xCoord + 0.5,
            container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()),
            container.zCoord + 0.5);

        if (item.output == ForgeDirection.UNKNOWN) {
          if (travelHook != null) {
            travelHook.drop(this, item);
          }

          EntityItem dropped = null;

          if (items.scheduleRemoval(item)) {
            dropped = item.toEntityItem(item.input);
          }

          if (dropped != null) {
            onDropped(dropped);
          }
        } else {
          if (travelHook != null) {
            travelHook.centerReached(this, item);
          }
        }

      } else if (!item.toCenter && endReached(item)) {
        TileEntity tile = container.getTile(item.output);

        boolean handleItem = true;
        if (travelHook != null) {
          handleItem = !travelHook.endReached(this, item, tile);
        }

        // If the item has not been scheduled to removal by the hook
        if (handleItem && items.scheduleRemoval(item)) {
          handleTileReached(item, tile);
        }
      }
    }

    items.performRemoval();
  }