Advertisement
yarinch

Untitled

Sep 30th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. @Override
  2.     public void readFromNBT(NBTTagCompound compound) {
  3.         super.readFromNBT(compound);
  4.  
  5.         isFormed = compound.getBoolean("isFormed");
  6.         checkBefore = compound.getBoolean("checkBefore");
  7.  
  8.         if (isFormed) {
  9.             byte size = compound.getByte("Size");
  10.  
  11.             components.clear();
  12.  
  13.             for (int i = 0; i < size; i++) {
  14.                 int[] arr = compound.getIntArray("component" + i);
  15.                 TileEntityMachineBase te = (TileEntityMachineBase) worldObj.getTileEntity(arr[0], yCoord, arr[1]);
  16.                 components.add(te);
  17.             }
  18.         }
  19.     }
  20.  
  21.     @Override
  22.     public Packet getDescriptionPacket() {
  23.         NBTTagCompound tagCompound = new NBTTagCompound();
  24.         writeToNBT(tagCompound);
  25.         return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound);
  26.     }
  27.  
  28.  
  29.     @Override
  30.     public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
  31.         NBTTagCompound tag = pkt.func_148857_g();
  32.         readFromNBT(tag);
  33.     }
  34.  
  35.     @Override
  36.     public void writeToNBT(NBTTagCompound compound) {
  37.         super.writeToNBT(compound);
  38.  
  39.         compound.setBoolean("isFormed", isFormed);
  40.         compound.setBoolean("checkBefore", checkBefore);
  41.  
  42.         if (isFormed()) {
  43.             compound.setByte("Size", (byte) components.size());
  44.  
  45.             for (int i = 0; i < components.size(); i++) {
  46.                 TileEntityMachineBase te = components.get(i);
  47.                 System.out.println("Saving te #" + i);
  48.                 compound.setIntArray("component" + i, new int[]{te.xCoord, te.zCoord});
  49.             }
  50.         }
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement