Advertisement
Corosus

forge tile entity packets

Oct 18th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. //to send: MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(this.getDescriptionPacket());
  2.  
  3.     public void readFromNBT(NBTTagCompound par1NBTTagCompound)
  4.     {
  5.         super.readFromNBT(par1NBTTagCompound);
  6.         this.itemIndex = par1NBTTagCompound.getInteger("itemIndex");
  7.         this.cycleCurDelay = par1NBTTagCompound.getInteger("cycleCurDelay");
  8.         cycleItems = par1NBTTagCompound.getBoolean("cycleItems");
  9.        
  10.         //this.delay = par1NBTTagCompound.getShort("Delay");
  11.     }
  12.  
  13.     /**
  14.      * Writes a tile entity to NBT.
  15.      */
  16.     public void writeToNBT(NBTTagCompound par1NBTTagCompound)
  17.     {
  18.         super.writeToNBT(par1NBTTagCompound);
  19.         par1NBTTagCompound.setInteger("itemIndex", this.itemIndex);
  20.         par1NBTTagCompound.setInteger("cycleCurDelay", this.cycleCurDelay);
  21.         par1NBTTagCompound.setBoolean("cycleItems", cycleItems);
  22.         //par1NBTTagCompound.setShort("Delay", (short)this.delay);
  23.     }
  24.    
  25.     @Override
  26.     public void onDataPacket(NetworkManager net, Packet132TileEntityData pkt) {
  27.         this.readFromNBT(pkt.customParam1);
  28.     }
  29.    
  30.     @Override
  31.     public Packet getDescriptionPacket()
  32.     {
  33.         NBTTagCompound var1 = new NBTTagCompound();
  34.         this.writeToNBT(var1);
  35.         return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 0, var1);
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement