Advertisement
Telinc1

Untitled

Aug 6th, 2013
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. @Override
  2. public void readFromNBT(NBTTagCompound nbt) {
  3. super.readFromNBT(nbt);
  4. this.playerList = new String[]{MainReferences.UNIDENTIFIED_PLAYER, MainReferences.UNIDENTIFIED_PLAYER, MainReferences.UNIDENTIFIED_PLAYER, MainReferences.UNIDENTIFIED_PLAYER, MainReferences.UNIDENTIFIED_PLAYER};
  5.  
  6. this.setTimer(nbt.getByte("Timer"));
  7. this.setRotation(nbt.getByte("Rotation"));
  8. this.setActive(nbt.getBoolean("Active"));
  9. this.setSingleplayerMode(nbt.getBoolean("SingleplayerMode"));
  10. this.setOwner(nbt.getString("Owner"));
  11.  
  12. if(nbt.hasKey("Players")){
  13. NBTTagList list = nbt.getTagList("Players");
  14.  
  15. for(int i = 0; i < list.tagCount(); i++){
  16. NBTTagCompound player = (NBTTagCompound)list.tagAt(i);
  17. this.setPlayerList(player.getString("Name"), nbt.getByte("Slot"));
  18. }
  19. }
  20. }
  21.  
  22. @Override
  23. public void writeToNBT(NBTTagCompound nbt) {
  24. super.writeToNBT(nbt);
  25.  
  26. nbt.setByte("Timer", this.getTimer());
  27. nbt.setByte("Rotation", this.getRotation());
  28. nbt.setBoolean("Active", this.isActive());
  29. nbt.setBoolean("SingleplayerMode", this.isSingleplayerMode());
  30. nbt.setString("Owner", this.getOwner());
  31.  
  32. NBTTagList list = new NBTTagList();
  33. for(int i = 0; i < this.getPlayerList().length; i++){
  34. if(!this.getPlayerList()[i].equals(MainReferences.UNIDENTIFIED_PLAYER)){
  35. NBTTagCompound player = new NBTTagCompound();
  36. player.setString("Name", this.getPlayerList()[i]);
  37. player.setByte("Slot", (byte)i);
  38. list.appendTag(player);
  39. }
  40. }
  41.  
  42. if(list.tagCount() > 0){
  43. nbt.setTag("Players", list);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement