Ejemplo n.º 1
0
  public boolean pairWith(BlockEntityChest chest) {
    if (this.isPaired() || chest.isPaired()) {
      return false;
    }

    this.createPair(chest);

    chest.spawnToAll();
    this.spawnToAll();
    this.checkPairing();

    return true;
  }
Ejemplo n.º 2
0
  public boolean unpair() {
    if (!this.isPaired()) {
      return false;
    }

    BlockEntityChest chest = this.getPair();

    this.namedTag.remove("pairx");
    this.namedTag.remove("pairz");

    this.spawnToAll();

    if (chest != null) {
      chest.namedTag.remove("pairx");
      chest.namedTag.remove("pairz");
      chest.checkPairing();
      chest.spawnToAll();
    }
    this.checkPairing();

    return true;
  }
Ejemplo n.º 3
0
  protected void checkPairing() {
    BlockEntityChest pair = this.getPair();
    if (pair != null) {
      if (!pair.isPaired()) {
        pair.createPair(this);
        pair.checkPairing();
      }

      if (this.doubleInventory == null) {
        if ((pair.x + ((int) pair.z << 15))
            > (this.x + ((int) this.z << 15))) { // Order them correctly
          this.doubleInventory = new DoubleChestInventory(pair, this);
        } else {
          this.doubleInventory = new DoubleChestInventory(this, pair);
        }
      }
    } else {
      this.doubleInventory = null;
      this.namedTag.remove("pairx");
      this.namedTag.remove("pairz");
    }
  }