Advertisement
Guest User

Untitled

a guest
Jun 16th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. package me.ferdz.placeableitems.tileentity;
  2.  
  3. import net.minecraft.init.Items;
  4. import net.minecraft.item.ItemStack;
  5. import net.minecraft.nbt.NBTTagCompound;
  6. import net.minecraft.network.NetworkManager;
  7. import net.minecraft.network.play.server.SPacketUpdateTileEntity;
  8. import net.minecraft.tileentity.TileEntity;
  9.  
  10. public class TEArrow extends TileEntity {
  11.  
  12. private ItemStack arrow;
  13.  
  14. public TEArrow() {
  15. arrow = new ItemStack(Items.ARROW);
  16. }
  17.  
  18. public ItemStack getType() {
  19. return this.arrow;
  20. }
  21.  
  22. public void setType(ItemStack arrow) {
  23. this.arrow = arrow;
  24. }
  25.  
  26. @Override
  27. public SPacketUpdateTileEntity getUpdatePacket() {
  28. NBTTagCompound tag = new NBTTagCompound();
  29. writeToNBT(tag);
  30. return new SPacketUpdateTileEntity(this.pos, this.getBlockMetadata(), tag);
  31. }
  32.  
  33. @Override
  34. public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
  35. readFromNBT(pkt.getNbtCompound());
  36. }
  37.  
  38. @Override
  39. public void readFromNBT(NBTTagCompound nbttagcompound) {
  40. super.readFromNBT(nbttagcompound);
  41. arrow.readFromNBT(nbttagcompound.getCompoundTag("arrow"));
  42. }
  43.  
  44. @Override
  45. public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
  46. super.writeToNBT(nbttagcompound);
  47. NBTTagCompound nbt2 = arrow.writeToNBT(new NBTTagCompound());
  48. nbttagcompound.setTag("arrow", nbt2);
  49. return nbttagcompound;
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement