Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package io.github.choiceisme.common.entity;
- import net.minecraft.entity.EntityType;
- import net.minecraft.entity.MobEntity;
- import net.minecraft.entity.ai.attributes.AttributeModifierMap;
- import net.minecraft.entity.ai.attributes.Attributes;
- import net.minecraft.entity.ai.goal.LookAtGoal;
- import net.minecraft.entity.ai.goal.LookRandomlyGoal;
- import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
- import net.minecraft.entity.ai.goal.RandomWalkingGoal;
- import net.minecraft.entity.ai.goal.SwimGoal;
- import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
- import net.minecraft.entity.passive.IronGolemEntity;
- import net.minecraft.entity.player.PlayerEntity;
- import net.minecraft.network.IPacket;
- import net.minecraft.util.SoundEvent;
- import net.minecraft.util.SoundEvents;
- import net.minecraft.world.World;
- import net.minecraftforge.fml.network.NetworkHooks;
- public class ExampleEntity extends MobEntity {
- public ExampleEntity(EntityType<? extends MobEntity> p_i48549_1_, World p_i48549_2_) {
- super(p_i48549_1_, p_i48549_2_);
- }
- public static AttributeModifierMap.MutableAttribute setAttributes() {
- return MobEntity.createMobAttributes()
- .add(Attributes.MAX_HEALTH, 30.0f)
- .add(Attributes.ATTACK_DAMAGE, 5.0f)
- .add(Attributes.ATTACK_SPEED, 2.0f)
- .add(Attributes.ATTACK_KNOCKBACK, 3.0f)
- .add(Attributes.JUMP_STRENGTH, 5.0f)
- .add(Attributes.MOVEMENT_SPEED, 5.0f)
- .add(Attributes.ARMOR, 5.0f)
- .add(Attributes.FOLLOW_RANGE, 35.0D)
- .add(Attributes.SPAWN_REINFORCEMENTS_CHANCE, 5.0f);
- }
- @Override
- protected void registerGoals() {
- super.registerGoals();
- this.goalSelector.addGoal(6, new LookRandomlyGoal(this));
- this.goalSelector.addGoal(4, new LookAtGoal(this, PlayerEntity.class, 8.0f));
- this.goalSelector.addGoal(4, new RandomWalkingGoal(this, 1.0D));
- this.goalSelector.addGoal(0, new SwimGoal(this));
- this.addBehaviourGoals();
- }
- protected void addBehaviourGoals() {
- this.goalSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
- this.goalSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, IronGolemEntity.class, true));
- }
- @Override
- protected SoundEvent getDeathSound() {
- return SoundEvents.POLAR_BEAR_DEATH;
- }
- @Override
- public IPacket<?> getAddEntityPacket() {
- return NetworkHooks.getEntitySpawningPacket(this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement