Advertisement
Guest User

Hi

a guest
Aug 11th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. package com.chef.mod.tileentity;
  2.  
  3. import com.chef.mod.Debugger;
  4. import com.chef.mod.blocks.ButterChurn;
  5.  
  6. import net.minecraft.block.state.IBlockState;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.entity.player.InventoryPlayer;
  9. import net.minecraft.inventory.Container;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.nbt.NBTTagCompound;
  12. import net.minecraft.server.gui.IUpdatePlayerListBox;
  13. import net.minecraft.tileentity.TileEntity;
  14. import net.minecraft.util.IChatComponent;
  15. import net.minecraft.world.IInteractionObject;
  16. import net.minecraft.world.ILockableContainer;
  17. import net.minecraft.world.LockCode;
  18.  
  19. public class TileEntityButterChurn extends TileEntity implements IUpdatePlayerListBox  {
  20.  
  21.     private int butterTime;
  22.  
  23.     @Override
  24.     public void update() {
  25.  
  26.         Debugger.log(butterTime);
  27.         IBlockState state = this.worldObj.getBlockState(pos);
  28.         int level = ((Integer) state.getValue(ButterChurn.LEVEL)).intValue();
  29.  
  30.         if (level == 5) {
  31.  
  32.             if (butterTime < 12000) {
  33.  
  34.                 butterTime++;
  35.  
  36.             } else {
  37.  
  38.                 this.worldObj.setBlockState(this.pos, state.withProperty(ButterChurn.LEVEL, level + 1), 2);
  39.  
  40.             }
  41.  
  42.         } else {
  43.  
  44.             butterTime = 0;
  45.  
  46.         }
  47.         this.markDirty();
  48.     }
  49.  
  50.     public void readFromNBT(NBTTagCompound compound) {
  51.  
  52.         Debugger.log("NBT");
  53.         super.readFromNBT(compound);
  54.         this.butterTime = compound.getShort("ButterTime");
  55.  
  56.     }
  57.  
  58.     public void writeToNBT(NBTTagCompound compound) {
  59.  
  60.         Debugger.log("NBT");
  61.         super.writeToNBT(compound);
  62.         compound.setShort("ButterTime", (short) this.butterTime);
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement