Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package destinyspork.appliedautomation.tileentity;
- import com.google.common.collect.ImmutableMap;
- import destinyspork.appliedautomation.proxy.ClientProxy;
- import destinyspork.appliedautomation.proxy.CommonProxy;
- import destinyspork.appliedautomation.proxy.ServerProxy;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLiving;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.world.World;
- import net.minecraftforge.client.model.animation.Animation;
- import net.minecraftforge.client.model.animation.Event;
- import net.minecraftforge.client.model.animation.IAnimationProvider;
- import net.minecraftforge.client.model.animation.ITimeValue;
- import net.minecraftforge.client.model.animation.TimeValues.VariableValue;
- import net.minecraftforge.common.model.animation.IAnimationStateMachine;
- public class EntityChest extends EntityLiving implements IAnimationProvider {
- private final IAnimationStateMachine asm;
- private VariableValue cycleLength;
- public EntityChest(World world){
- super(world);
- setSize(1,1);
- if(cycleLength == null){
- cycleLength = new VariableValue(getHealth()/5);
- }
- asm = ClientProxy
- .load(new ResourceLocation("appliedautomation", "asms/block/engine.json"), ImmutableMap.<String, ITimeValue>of(
- "cycle_length", cycleLength
- ));
- }
- public void handleEvents(float time, Iterable<Event> pastEvents){
- }
- public IAnimationStateMachine asm()
- {
- return asm;
- }
- @Override
- public void onDataWatcherUpdate(int id)
- {
- super.onDataWatcherUpdate(id);
- if(id == 6) // health
- {
- if(cycleLength == null)
- {
- cycleLength = new VariableValue(0);
- }
- cycleLength.setValue(getHealth() / 5);
- }
- }
- @Override
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(60);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement