Advertisement
Guest User

EntityChest

a guest
Apr 2nd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.14 KB | None | 0 0
  1. package destinyspork.appliedautomation.tileentity;
  2.  
  3. import com.google.common.collect.ImmutableMap;
  4.  
  5. import destinyspork.appliedautomation.proxy.ClientProxy;
  6. import destinyspork.appliedautomation.proxy.CommonProxy;
  7. import destinyspork.appliedautomation.proxy.ServerProxy;
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.entity.EntityLiving;
  10. import net.minecraft.entity.SharedMonsterAttributes;
  11. import net.minecraft.nbt.NBTTagCompound;
  12. import net.minecraft.tileentity.TileEntity;
  13. import net.minecraft.util.ResourceLocation;
  14. import net.minecraft.world.World;
  15. import net.minecraftforge.client.model.animation.Animation;
  16. import net.minecraftforge.client.model.animation.Event;
  17. import net.minecraftforge.client.model.animation.IAnimationProvider;
  18. import net.minecraftforge.client.model.animation.ITimeValue;
  19. import net.minecraftforge.client.model.animation.TimeValues.VariableValue;
  20. import net.minecraftforge.common.model.animation.IAnimationStateMachine;
  21.  
  22. public class EntityChest extends EntityLiving implements IAnimationProvider {
  23.  
  24.     private final IAnimationStateMachine asm;
  25.     private VariableValue cycleLength;
  26.    
  27.     public EntityChest(World world){
  28.         super(world);
  29.         setSize(1,1);
  30.         if(cycleLength == null){
  31.             cycleLength = new VariableValue(getHealth()/5);
  32.         }
  33.         asm = ClientProxy
  34.                 .load(new ResourceLocation("appliedautomation", "asms/block/engine.json"), ImmutableMap.<String, ITimeValue>of(
  35.                 "cycle_length", cycleLength
  36.                 ));
  37.     }
  38.    
  39.     public void handleEvents(float time, Iterable<Event> pastEvents){
  40.        
  41.     }
  42.    
  43.     public IAnimationStateMachine asm()
  44.     {
  45.         return asm;
  46.     }
  47.    
  48.     @Override
  49.     public void onDataWatcherUpdate(int id)
  50.     {
  51.         super.onDataWatcherUpdate(id);
  52.         if(id == 6) // health
  53.         {
  54.             if(cycleLength == null)
  55.             {
  56.                 cycleLength = new VariableValue(0);
  57.             }
  58.             cycleLength.setValue(getHealth() / 5);
  59.         }
  60.     }
  61.  
  62.     @Override
  63.     protected void applyEntityAttributes()
  64.     {
  65.         super.applyEntityAttributes();
  66.         this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(60);
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement