Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. package skymine.redenergy.sow.blocks.tiles;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.nbt.NBTTagCompound;
  6. import net.minecraft.network.NetworkManager;
  7. import net.minecraft.network.Packet;
  8. import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
  9. import net.minecraft.tileentity.TileEntity;
  10. import skymine.redenergy.sow.bonus.BonusManager;
  11. import skymine.redenergy.sow.bonus.IBonus;
  12.  
  13. public class TileEntityGiveAway extends TileEntity{
  14.    
  15.     public IBonus currentBonus;
  16.     private Random rand;
  17.    
  18.     public TileEntityGiveAway(){
  19.         rand = new Random();
  20.         currentBonus = BonusManager.emptyBonus;
  21.     }
  22.    
  23.     @Override
  24.     public void readFromNBT(NBTTagCompound tag) {
  25.         currentBonus = BonusManager.getBonusByName(tag.getString("bonusName"));
  26.         super.readFromNBT(tag);
  27.     }
  28.  
  29.     @Override
  30.     public void writeToNBT(NBTTagCompound tag) {
  31. //      tag.setByteArray("bonus", BonusManager.serialize(currentBonus));
  32.         tag.setString("bonusName", currentBonus.getBonusName());
  33.         super.writeToNBT(tag);
  34.     }
  35.  
  36.     @Override
  37.     public Packet getDescriptionPacket() {
  38.         NBTTagCompound tag = new NBTTagCompound();
  39.         this.writeToNBT(tag);
  40.         return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tag);
  41.     }
  42.  
  43.     @Override
  44.     public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
  45.         this.readFromNBT(pkt.func_148857_g());
  46.     }
  47.  
  48.     @Override
  49.     public void updateEntity() {
  50.         super.updateEntity();
  51.     }
  52.  
  53.     @Override
  54.     public boolean canUpdate() {
  55.         return true;
  56.     }
  57.    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement