Beispiel #1
0
  protected void sendItemUpdate() {
    TubeItem lowestItem = null;
    if (!flow.contents.isEmpty()) {
      int lowestProgress = Integer.MAX_VALUE;
      for (TubeItem item : flow.contents) {
        if (item.isPacketSent()) {
          return;
        }

        if (item.progress <= lowestProgress) {
          lowestItem = item;
          lowestProgress = item.progress;
        }
      }
    }

    final Packet211TileDesc packet211tiledesc = new Packet211TileDesc();
    packet211tiledesc.subId = 10;
    packet211tiledesc.xCoord = x;
    packet211tiledesc.yCoord = y;
    packet211tiledesc.zCoord = z;
    packet211tiledesc.addUVLC(1); // TubeItem count

    if (lowestItem != null) {
      lowestItem.writeToPacket(packet211tiledesc);
    }

    packet211tiledesc.encode();
    CoreProxy.sendPacketToPosition(packet211tiledesc, x, z);
  }
Beispiel #2
0
 @Override
 public void addTubeItem(TubeItem tubeitem) {
   tubeitem.side ^= 1;
   flow.add(tubeitem);
   hasChanged = true;
   dirtyBlock();
 }
Beispiel #3
0
  @Override
  protected void readFromPacket(Packet211TileDesc packet211tiledesc) throws IOException {
    if (packet211tiledesc.subId == 10) {
      flow.contents.clear();
      int i = (int) packet211tiledesc.getUVLC();
      for (int j = 0; j < i; j++) {
        flow.contents.add(TubeItem.newFromPacket(packet211tiledesc));
      }

    } else {
      super.readFromPacket(packet211tiledesc);
      paintColor = (byte) packet211tiledesc.getByte();
    }
  }
Beispiel #4
0
 @Override
 public boolean tubeItemEnter(int i, int j, TubeItem tubeitem) {
   if (j != 0) {
     return false;
   }
   if (tubeitem.color != 0 && paintColor != 0 && tubeitem.color != paintColor) {
     return false;
   } else {
     tubeitem.side = (byte) i;
     flow.add(tubeitem);
     hasChanged = true;
     dirtyBlock();
     return true;
   }
 }