コード例 #1
0
  @Override
  public void writeToNBT(NBTTagCompound data) {
    super.writeToNBT(data);

    NBTTagList itemList = new NBTTagList();
    NBTTagList sideItemList = new NBTTagList();
    NBTTagCompound configData;

    data.setBoolean("shareRS", isRSShared);

    for (int i = 0; i < 3; i++) {

      if (inventory.getStackInSlot(i) != null) {
        NBTTagCompound itemCompound = new NBTTagCompound();
        itemCompound.setInteger("slot", i);
        inventory.getStackInSlot(i).writeToNBT(itemCompound);
        itemList.appendTag(itemCompound);
      }

      if (tanks[i].getFluid() != null) {
        data.setInteger("tankCap" + i, tanks[i].getCapacity());
        data.setTag("Fluid" + i, tanks[i].getFluid().writeToNBT(new NBTTagCompound()));
      }

      data.setBoolean("rsControl" + i, rsControl[i]);
      data.setBoolean("rsLatch" + i, rsLatch[i]);
    }

    data.setTag("items", itemList);

    for (int i = 0; i < 6; i++) {
      data.setInteger("side" + i, sides[i]);
      configData = new NBTTagCompound();
      configs[i].writeToNBT(configData);
      data.setCompoundTag("config" + i, configData);
      data.setBoolean("rs" + i, sideRS[i]);
      data.setBoolean("lock" + i, sideLocked[i]);
      data.setInteger("facID" + i, facID[i]);
      data.setInteger("facMeta" + i, facMeta[i]);

      if (sideInventory.getStackInSlot(i) != null) {
        NBTTagCompound itemCompound = new NBTTagCompound();
        itemCompound.setInteger("slot", i);
        sideInventory.getStackInSlot(i).writeToNBT(itemCompound);
        sideItemList.appendTag(itemCompound);
      }
    }

    data.setTag("sideItems", sideItemList);

    if (capacitor != null) {
      data.setInteger("realPower", capacitor.getEnergyStored());
      capacitor.writeToNBT(data);
      data.setInteger("powerCap2", capacitor.getMaxEnergyStored());
    }
  }
コード例 #2
0
 @Override
 public void validate() {
   super.validate();
   if (this.worldObj.isRemote) {
     for (int i = 0; i < 6; i++)
       emasher.sockets.client.ClientPacketHandler.instance.requestSideData(this, (byte) i);
     for (int i = 0; i < 3; i++) {
       emasher.sockets.client.ClientPacketHandler.instance.requestInventoryData(this, (byte) i);
       emasher.sockets.client.ClientPacketHandler.instance.requestTankData(this, (byte) i);
     }
   }
 }
コード例 #3
0
  @Override
  public void readFromNBT(NBTTagCompound data) {
    super.readFromNBT(data);

    if (data.hasKey("shareRS")) {
      isRSShared = data.getBoolean("shareRS");
    }

    for (int i = 0; i < 3; i++) {
      if (data.hasKey("tankCap" + i)) {
        tanks[i] = new FluidTank(data.getInteger("tankCap" + i));
      }

      if (data.hasKey("Fluid" + i)) {
        tanks[i].setFluid(FluidStack.loadFluidStackFromNBT(data.getCompoundTag("Fluid" + i)));
      }

      if (data.hasKey("rsControl" + i)) rsControl[i] = data.getBoolean("rsControl" + i);
      if (data.hasKey("rsLatch" + i)) rsLatch[i] = data.getBoolean("rsLatch" + i);
    }

    NBTTagList itemList = data.getTagList("items");

    for (int i = 0; i < itemList.tagCount(); i++) {
      NBTTagCompound itemCompound = (NBTTagCompound) itemList.tagAt(i);
      int slot = itemCompound.getInteger("slot");
      inventory.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(itemCompound));
    }

    for (int i = 0; i < 6; i++) {
      if (data.hasKey("side" + i)) {
        sides[i] = data.getInteger("side" + i);
      }
      if (data.hasKey("config" + i)) {
        configs[i] = new SideConfig();
        configs[i].readFromNBT(data.getCompoundTag("config" + i));
      }
      if (data.hasKey("rs" + i)) {
        sideRS[i] = data.getBoolean("rs" + i);
      }
      if (data.hasKey("lock" + i)) {
        sideLocked[i] = data.getBoolean("lock" + i);
      }
      if (data.hasKey("facID" + i)) {
        facID[i] = data.getInteger("facID" + i);
      }
      if (data.hasKey("facMeta" + i)) {
        facMeta[i] = data.getInteger("facMeta" + i);
      }
    }

    itemList = data.getTagList("sideItems");

    for (int i = 0; i < itemList.tagCount(); i++) {
      NBTTagCompound itemCompound = (NBTTagCompound) itemList.tagAt(i);
      int slot = itemCompound.getInteger("slot");
      sideInventory.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(itemCompound));
    }

    capacitor.readFromNBT(data);
    int power = capacitor.getEnergyStored();
    if (data.hasKey("powerCap2")) this.setMaxEnergyStored((int) data.getInteger("powerCap2"));
    if (data.hasKey("realPower")) power = data.getInteger("realPower");
    capacitor.setEnergyStored(power);
  }
コード例 #4
0
 @Override
 public void onChunkUnload() {
   super.onChunkUnload();
   /*MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
   addedToEnergyNet = false;*/
 }