@Override
  public void updateEntity() {

    if (!this.created) {
      this.created = true;
      NetworkHelper.requestInitialData(this);
      NetworkHelper.announceBlockUpdate(worldObj, xCoord, yCoord, zCoord);
    }
    super.updateEntity();
    // if (worldObj!=null)
    // worldObj.markBlockForRenderUpdate(xCoord,  yCoord,  zCoord);
  }
Esempio n. 2
0
  @Override
  public void updateEntity() {
    boolean flag = false;
    if (!this.initnal && this.worldObj != null) {
      if (this.worldObj.isRemote) {
        NetworkHelper.requestInitialData(this);
      } else {
        MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
        this.initnal = true;
      }
    }

    if (this.storage > 0) {
      if (this.storage - 16 > 0) {
        this.production = sendEnergy(16);
        this.storage -= 16;
      } else {
        this.production = sendEnergy(this.storage);
        this.storage = 0;
      }
      PacketDispatcher.sendPacketToServer(ClientPacketHandler.sendPacket(this));
    }

    if (isWorking()) {
      if (production > 0) {
        this.storage = this.storage + this.production;
        this.production = 0;
      }
      this.waitTime--;
      if (this.waitTime <= 0 && !this.worldObj.isRemote) {
        if (this.inv[0].getItemDamage() == Atoms.HYDROGEN.id
            && this.inv[1].getItemDamage() == Atoms.OXYGEN.id) {
          this.inv[0] = delSlot(this.inv[0]);
          this.inv[1] = delSlot(this.inv[1]);
          addSlot(new ItemStack(KagacraftItems.testTube, 1), 2);
          addSlot(new ItemStack(KagacraftItems.testTube, 1), 3);
          this.production = sendEnergy(this.hatuden);

          PacketDispatcher.sendPacketToServer(ClientPacketHandler.sendPacket(this));
          flag = true;
        }
        this.waitTime = 0;
      }
      if (this.inv[0] == null || this.inv[1] == null) {
        this.waitTime = 0;
      }
    } else if (this.inv[0] != null
        && this.inv[1] != null
        && this.inv[0].itemID == KagacraftItems.elements.itemID
        && this.inv[1].itemID == KagacraftItems.elements.itemID) {
      if (this.inv[0].getItemDamage() == Atoms.HYDROGEN.id
          && this.inv[1].getItemDamage() == Atoms.OXYGEN.id) {
        if (this.storage + this.hatuden < this.maxStorage) {
          this.waitTime = this.maxWaitTime;
        }
      }
    }

    if (flag) {
      this.onInventoryChanged();
    }
  }