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

    NBTTagCompound energyTag = new NBTTagCompound();
    this.storage.writeToNBT(energyTag);
    nbt.setTag("storage", energyTag);
    nbt.setBoolean("flag", this.flag);
    nbt.setBoolean("flag1", this.flag1);
    NBTTagList list = new NBTTagList();

    for (int i = 0; i < this.slots.length; ++i) {
      if (this.slots[i] != null) {
        NBTTagCompound compound = new NBTTagCompound();
        compound.setByte("Slot", (byte) i);
        this.slots[i].writeToNBT(compound);
        list.appendTag(compound);
      }
    }

    nbt.setTag("Items", list);

    if (this.isInventoryNameLocalized()) {
      nbt.setString("CustomName", this.localizedName);
    }
  }
コード例 #2
0
 public void updateEntity() {
   super.updateEntity();
   if (tickCount >= NuclearCraft.EMUpdateRate) {
     if (!this.worldObj.isRemote) energy();
     if (flag != flag1) {
       flag1 = flag;
       BlockSuperElectromagnet.updateBlockState(
           flag, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
     }
     tickCount = 0;
   } else tickCount++;
   /*if (soundCount >= 67) {
   	if (flag1) worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "nc:shield5", 0.5F, 1F);
   	soundCount = 0;
   } else soundCount ++;*/
   markDirty();
 }
コード例 #3
0
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    if (nbt.hasKey("storage")) {
      this.storage.readFromNBT(nbt.getCompoundTag("storage"));
    }
    this.flag = nbt.getBoolean("flag");
    this.flag1 = nbt.getBoolean("flag1");
    NBTTagList list = nbt.getTagList("Items", 10);
    this.slots = new ItemStack[this.getSizeInventory()];

    for (int i = 0; i < list.tagCount(); ++i) {
      NBTTagCompound compound = list.getCompoundTagAt(i);
      byte b = compound.getByte("Slot");

      if (b >= 0 && b < this.slots.length) {
        this.slots[b] = ItemStack.loadItemStackFromNBT(compound);
      }
    }
  }
コード例 #4
0
 public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
   super.onDataPacket(net, packet);
   readEnergy(packet.func_148857_g());
 }