Advertisement
Guest User

TileEntity

a guest
Dec 11th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package dk.adventures.AdvScreen.TileEntity;
  2.  
  3. //import cofh.api.energy.EnergyStorage;
  4. //import cofh.api.energy.IEnergyHandler;
  5. import dk.adventures.AdvScreen.Utils.Logger;
  6. import net.minecraft.client.Minecraft;
  7. import net.minecraft.nbt.NBTTagCompound;
  8. import net.minecraft.network.NetworkManager;
  9. import net.minecraft.network.Packet;
  10. import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
  11. import net.minecraft.tileentity.TileEntity;
  12. import net.minecraftforge.common.util.ForgeDirection;
  13.  
  14. /**
  15. * Created by rem on 03-08-2014.
  16. */
  17. public class TileEntityScreen extends TileEntity
  18. {
  19. //The direction the "front" of the screen is facing.
  20. //0=north, 1=east, 2=south, 3=west, 4,5,6,7=Up/NESW, 8,9,10,11=Down/NESW
  21. public int Orientation = 0;
  22. public float Depth = 1.0f;
  23.  
  24. public static final class TAGS
  25. {
  26. public static String Orientation = "Orientation";
  27. public static String Depth = "Depth";
  28.  
  29. }//class
  30.  
  31.  
  32. public TileEntityScreen()
  33. {
  34. }
  35.  
  36. @Override
  37. public void readFromNBT(NBTTagCompound nbt)
  38. {
  39. super.readFromNBT(nbt);
  40.  
  41. if (nbt.hasKey(TAGS.Orientation))
  42. this.Orientation = nbt.getByte(TAGS.Orientation);
  43.  
  44. if (nbt.hasKey(TAGS.Depth))
  45. this.Depth = nbt.getFloat(TAGS.Depth);
  46. }
  47.  
  48.  
  49. @Override
  50. public void writeToNBT(NBTTagCompound nbt)
  51. {
  52. super.writeToNBT(nbt);
  53.  
  54. nbt.setByte(TAGS.Orientation, (byte)this.Orientation);
  55. nbt.setFloat(TAGS.Depth, this.Depth);
  56. }
  57.  
  58.  
  59. int m_iTimer = 0;
  60. @Override
  61. public void updateEntity()
  62. {
  63. m_iTimer++;
  64.  
  65. if (m_iTimer >= 20)
  66. {
  67. if (!getWorldObj().isRemote)
  68. {
  69. //Minecraft.getMinecraft().thePlayer.sendChatMessage(String.format("Hej!"));
  70. }
  71.  
  72. m_iTimer = 0;
  73. }
  74. }
  75.  
  76.  
  77. @Override
  78. public Packet getDescriptionPacket()
  79. {
  80. Logger.Debug("getDescriptionPacket");
  81. NBTTagCompound nbtTag = new NBTTagCompound();
  82. this.writeToNBT(nbtTag);
  83. return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
  84. }
  85.  
  86. @Override
  87. public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
  88. {
  89. Logger.Debug("onDataPacket");
  90. readFromNBT(packet.func_148857_g());
  91. }
  92.  
  93. }//class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement