Advertisement
Guest User

TE

a guest
Mar 8th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. package fr.hugoland.rpmod.common.tileentity;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import net.minecraft.tileentity.TileEntitySign;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.inventory.ISidedInventory;
  8. import net.minecraft.item.Item;
  9. import net.minecraft.item.ItemStack;
  10. import net.minecraft.nbt.NBTTagCompound;
  11. import net.minecraft.network.NetworkManager;
  12. import net.minecraft.network.Packet;
  13. import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
  14. import net.minecraft.tileentity.TileEntity;
  15.  
  16. public class TileEntityPancarte extends TileEntitySign
  17. {
  18. private byte direction;
  19. public String[] signText = new String[] {"", ""};
  20. private boolean editable = true;
  21. private EntityPlayer player;
  22. public int lineBeingEdited = -1;
  23.  
  24. @Override
  25. public void readFromNBT(NBTTagCompound compound)
  26. {
  27. this.editable = false;
  28. super.readFromNBT(compound);
  29. this.direction = compound.getByte("Direction");
  30. for (int i = 0; i < 2; ++i)
  31. {
  32. this.signText[i] = compound.getString("Text" + (i + 1));
  33.  
  34. if (this.signText[i].length() > 15)
  35. {
  36. this.signText[i] = this.signText[i].substring(0, 15);
  37. }
  38. }
  39. }
  40.  
  41. @Override
  42. public void writeToNBT(NBTTagCompound compound)
  43. {
  44. super.writeToNBT(compound);
  45. compound.setByte("Direction", this.direction);
  46. compound.setString("Text1", this.signText[0]);
  47. compound.setString("Text2", this.signText[1]);
  48. }
  49.  
  50. public byte getDirection()
  51. {
  52. return direction;
  53. }
  54.  
  55. public void setDirection(byte direction)
  56. {
  57. this.direction = direction;
  58. this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
  59. }
  60.  
  61. public boolean getEditable()
  62. {
  63. return this.editable;
  64. }
  65.  
  66. @SideOnly(Side.CLIENT)
  67. public void setEditable(boolean p_145913_1_)
  68. {
  69. this.editable = p_145913_1_;
  70.  
  71. if (!p_145913_1_)
  72. {
  73. this.player = null;
  74. }
  75. }
  76.  
  77. public void setPlayer(EntityPlayer player)
  78. {
  79. this.player = player;
  80. }
  81.  
  82. public EntityPlayer getPlayer()
  83. {
  84. return this.player;
  85. }
  86.  
  87. public Packet getDescriptionPacket()
  88. {
  89. NBTTagCompound nbttagcompound = new NBTTagCompound();
  90. this.writeToNBT(nbttagcompound);
  91. return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
  92. }
  93.  
  94. public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
  95. {
  96. this.readFromNBT(pkt.func_148857_g());
  97. this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);
  98. }
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement