Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.drnickenstein.testmod.entities;
- import com.drnickenstein.testmod.init.EntityTypesInit;
- import com.drnickenstein.testmod.init.SoundInit;
- import net.minecraft.block.BlockState;
- import net.minecraft.entity.AgeableEntity;
- import net.minecraft.entity.EntityType;
- import net.minecraft.entity.ILivingEntityData;
- import net.minecraft.entity.LivingEntity;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.SpawnReason;
- import net.minecraft.entity.ai.goal.FollowOwnerGoal;
- import net.minecraft.entity.ai.goal.LookAtGoal;
- import net.minecraft.entity.ai.goal.SwimGoal;
- import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
- import net.minecraft.entity.monster.CreeperEntity;
- import net.minecraft.entity.passive.TameableEntity;
- import net.minecraft.entity.player.PlayerEntity;
- import net.minecraft.nbt.CompoundNBT;
- import net.minecraft.potion.EffectInstance;
- import net.minecraft.potion.Effects;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.SoundEvent;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- public class Humadillo extends TameableEntity
- {
- //private int timer;
- public Humadillo(EntityType<? extends TameableEntity> type, World worldIn)
- {
- super(type, worldIn);
- }
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- protected void registerGoals()
- {
- super.registerGoals();
- this.goalSelector.addGoal(0, new FollowOwnerGoal(this, 1.5D, 25.0f, 50.0f, false));
- this.goalSelector.addGoal(1, new Humadillo.AvoidEntityGoal(this, CreeperEntity.class, 24.0F, 1.5D, 1.5D));
- this.goalSelector.addGoal(2, new SwimGoal(this));
- this.goalSelector.addGoal(3, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
- this.goalSelector.addGoal(4, new LookAtGoal(this, PlayerEntity.class, 5.0f));
- }
- @Override
- protected void registerAttributes()
- {
- super.registerAttributes();
- this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue((double)0.3F);
- if (this.isTamed())
- {
- this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
- }
- else
- {
- this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
- }
- this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue((double)0.20f);
- }
- public void setTamed(boolean tamed)
- {
- super.setTamed(tamed);
- if (tamed)
- {
- this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
- this.setHealth(20.0F);
- }
- else
- {
- this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
- }
- this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4.0D);
- }
- @SuppressWarnings("unused")
- @Override
- protected void damageEntity(DamageSource damageSrc, float damageAmount)
- {
- this.addPotionEffect(new EffectInstance(Effects.RESISTANCE, 400, 1, false, true));
- this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.0f);
- int i = 0;
- long time = System.currentTimeMillis();
- while(time != time+5000)
- {
- i++;
- }
- if(time < 1)
- {
- this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.20f);
- }
- }
- @Override
- public AgeableEntity createChild(AgeableEntity ageable) {
- Humadillo entity = new Humadillo(EntityTypesInit.HUMADILLO.get(), this.world);
- entity.onInitialSpawn(this.world, this.world.getDifficultyForLocation(new BlockPos(entity)),
- SpawnReason.BREEDING, (ILivingEntityData) null, (CompoundNBT) null);
- entity.setGlowing(true);
- return entity;
- }
- @Override
- public boolean canTrample(BlockState state, BlockPos pos, float fallDistance) {
- return true;
- }
- @Override
- public boolean canBeLeashedTo(PlayerEntity player)
- {
- return true;
- }
- class AvoidEntityGoal<T extends LivingEntity> extends net.minecraft.entity.ai.goal.AvoidEntityGoal<T> {
- @SuppressWarnings("unused")
- private final Humadillo humadillo;
- public AvoidEntityGoal(Humadillo humadilloIn, Class<T> p_i47251_3_, float p_i47251_4_, double p_i47251_5_, double p_i47251_7_) {
- super(humadilloIn, p_i47251_3_, p_i47251_4_, p_i47251_5_, p_i47251_7_);
- this.humadillo = humadilloIn;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement