// TileEntity methods
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (!worldObj.isRemote) {
      // Energy consumption is all callback-based now.

      // If we're running, continue the cycle until we're done.
      if (cycledTicks >= 0) {
        cycledTicks++;

        // If we don't have the stuff to begin a cycle, stop now
        if (!canBeginCycle()) {
          cycledTicks = -1;
          this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
        } else if (cycledTicks >= getCycleLength()) {
          onPoweredCycleEnd();
          cycledTicks = -1;
          this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
        }
      }

      // If we've stopped running, but we can start, then start running.
      if (cycledTicks < 0
          && getCycleEnergyCost() <= energyStorage.getEnergyStored()
          && canBeginCycle()) {
        this.energyStorage.extractEnergy(getCycleEnergyCost(), false);
        cycledTicks = 0;
        onPoweredCycleBegin();
        this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
      }
    }
  }
 @Override
 public void writeToNBT(NBTTagCompound tag) {
   super.writeToNBT(tag);
   NBTTagCompound energyTag = new NBTTagCompound();
   this.energyStorage.writeToNBT(energyTag);
   tag.setTag("energyStorage", energyTag);
   tag.setInteger("cycledTicks", cycledTicks);
 }
 // TileEntityBeefBase methods
 @Override
 protected void onSendUpdate(NBTTagCompound updateTag) {
   super.onSendUpdate(updateTag);
   NBTTagCompound energyTag = new NBTTagCompound();
   this.energyStorage.writeToNBT(energyTag);
   updateTag.setTag("energyStorage", energyTag);
   updateTag.setInteger("cycledTicks", this.cycledTicks);
 }
  // TileEntity overrides
  @Override
  public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);

    if (tag.hasKey("energyStorage")) {
      this.energyStorage.readFromNBT(tag.getCompoundTag("energyStorage"));
    }

    if (tag.hasKey("cycledTicks")) {
      cycledTicks = tag.getInteger("cycledTicks");
    }
  }
 @Override
 public void onReceiveUpdate(NBTTagCompound updateTag) {
   super.onReceiveUpdate(updateTag);
   this.energyStorage.readFromNBT(updateTag.getCompoundTag("energyStorage"));
   this.cycledTicks = updateTag.getInteger("cycledTicks");
 }
Ejemplo n.º 6
0
 public ContainerBase(TileEntityInventory entity, InventoryPlayer inventoryPlayer) {
   this.containerSize = entity.getSizeInventory();
   this.entity = entity;
   entity.openChest();
 }