Guest User

TileEntity

a guest
Dec 8th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. package BlocksPers;
  2.  
  3. import net.minecraft.nbt.NBTTagCompound;
  4. import net.minecraft.network.NetworkManager;
  5. import net.minecraft.network.Packet;
  6. import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
  7. import net.minecraft.tileentity.TileEntity;
  8.  
  9. public class TileEntityFlagSpawn extends TileEntity {
  10.  
  11. private byte direction;
  12.  
  13. @Override
  14. public void readFromNBT(NBTTagCompound compound)
  15. {
  16. super.readFromNBT(compound);
  17. this.direction = compound.getByte("Direction");
  18. }
  19.  
  20. @Override
  21. public void writeToNBT(NBTTagCompound compound)
  22. {
  23. super.writeToNBT(compound);
  24. compound.setByte("Direction", this.direction);
  25. }
  26.  
  27. public byte getDirection()
  28. {
  29. return direction;
  30. }
  31.  
  32. public void setDirection(byte direction)
  33. {
  34. this.direction = direction;
  35. this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
  36. }
  37.  
  38. public Packet getDescriptionPacket()
  39. {
  40. NBTTagCompound nbttagcompound = new NBTTagCompound();
  41. this.writeToNBT(nbttagcompound);
  42. return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
  43. }
  44.  
  45. public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
  46. {
  47. this.readFromNBT(pkt.func_148857_g());
  48. this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);
  49. }
  50.  
  51. }
Add Comment
Please, Sign In to add comment