Guest User

Untitled

a guest
Sep 9th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 KB | None | 0 0
  1. public class TileEntityMaterializer extends TileEntity {
  2.    
  3.     private EnumSoulType soulType;
  4.     private int level;
  5.    
  6.     public TileEntityMaterializer() {
  7.        
  8.     }
  9.    
  10.     public TileEntityMaterializer(EnumSoulType soulType, int level) {
  11.         this.soulType = soulType;
  12.         this.level = level;
  13.     }
  14.    
  15.     @Override
  16.     public NBTTagCompound writeToNBT(NBTTagCompound compound) {
  17.         super.writeToNBT(compound);
  18.         compound.setString("SoulType", soulType.getName());
  19.         compound.setInteger("Level", level);
  20.         return compound;
  21.     }
  22.  
  23.     @Override
  24.     public void readFromNBT(NBTTagCompound compound) {
  25.         super.readFromNBT(compound);
  26.         soulType = EnumSoulType.getTypeFromName(compound.getString("SoulType"));
  27.         level = compound.getInteger("Level");
  28.     }
  29.    
  30.     @Override
  31.     public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) {
  32.         return (oldState.getBlock() != newState.getBlock());
  33.     }
  34.    
  35.     @Override
  36.     public NBTTagCompound getUpdateTag()
  37.     {
  38.         return this.writeToNBT(new NBTTagCompound());
  39.     }
  40.    
  41.     @Override
  42.     public void handleUpdateTag(NBTTagCompound compound)
  43.     {
  44.         readFromNBT(compound);
  45.     }
  46.  
  47.     @Override
  48.     public SPacketUpdateTileEntity getUpdatePacket()
  49.     {
  50.         return new SPacketUpdateTileEntity(this.pos, 1, writeToNBT(new NBTTagCompound()));
  51.     }
  52.  
  53.     @Override
  54.     public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
  55.     {      
  56.         readFromNBT(pkt.getNbtCompound());        
  57.     }
  58.    
  59.     public int getLevel() {
  60.         return level;
  61.     }
  62.    
  63.     public void setLevel(int level) {
  64.         this.level = level;
  65.     }
  66.    
  67.     public EnumSoulType getSoulType() {
  68.         return soulType;
  69.     }
  70.    
  71.     public void setSoulType(EnumSoulType soulType) {
  72.         this.soulType = soulType;
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment