Advertisement
Guest User

Updated Entity Class

a guest
Nov 20th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.76 KB | None | 0 0
  1. package mod.blackoutrpg.entities;
  2.  
  3. import net.minecraft.block.BlockState;
  4. import net.minecraft.entity.*;
  5. import net.minecraft.entity.ai.attributes.AttributeModifierMap;
  6. import net.minecraft.entity.ai.attributes.Attributes;
  7. import net.minecraft.entity.ai.goal.*;
  8. import net.minecraft.entity.monster.MonsterEntity;
  9. import net.minecraft.entity.monster.ZombieEntity;
  10. import net.minecraft.entity.monster.piglin.PiglinBruteBrain;
  11. import net.minecraft.entity.player.PlayerEntity;
  12. import net.minecraft.inventory.EquipmentSlotType;
  13. import net.minecraft.item.ItemStack;
  14. import net.minecraft.item.Items;
  15. import net.minecraft.nbt.CompoundNBT;
  16. import net.minecraft.util.DamageSource;
  17. import net.minecraft.util.SoundEvent;
  18. import net.minecraft.util.SoundEvents;
  19. import net.minecraft.util.math.BlockPos;
  20. import net.minecraft.world.Difficulty;
  21. import net.minecraft.world.DifficultyInstance;
  22. import net.minecraft.world.IServerWorld;
  23. import net.minecraft.world.World;
  24.  
  25. import javax.annotation.Nullable;
  26.  
  27. public class OrcWandererEntity extends MonsterEntity {
  28.  
  29.  
  30.     public OrcWandererEntity(EntityType<? extends MonsterEntity> type, World worldIn) {
  31.         super(type, worldIn);
  32.     }
  33.  
  34.     public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
  35.         return MonsterEntity.registerAttributes()
  36.                 .createMutableAttribute(Attributes.MAX_HEALTH, 20.0D)
  37.                 .createMutableAttribute(Attributes.ARMOR, 10.0D)
  38.                 .createMutableAttribute(Attributes.MOVEMENT_SPEED, (double)0.25D)
  39.                 .createMutableAttribute(Attributes.FOLLOW_RANGE, 35.0D)
  40.                 .createMutableAttribute(Attributes.ATTACK_DAMAGE, 5.0D)
  41.                 .createMutableAttribute(Attributes.ATTACK_SPEED, 2.0D)
  42.                 .createMutableAttribute(Attributes.ATTACK_KNOCKBACK, 1.0D);
  43.  
  44.     }
  45.  
  46.     @Override
  47.     protected void registerGoals() {
  48.         super.registerGoals();
  49.         this.goalSelector.addGoal(9, new SwimGoal(this));
  50.         this.goalSelector.addGoal(8, new LookAtGoal(this, PlayerEntity.class, 8.0F));
  51.         this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
  52.         this.goalSelector.addGoal(7, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
  53.         this.goalSelector.addGoal(6, new OpenDoorGoal(this, true));
  54.         this.targetSelector.addGoal(10, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
  55.         this.targetSelector.addGoal(10, new MeleeAttackGoal(this, 1, true));
  56.  
  57.     }
  58.  
  59.     @Override
  60.     public ILivingEntityData onInitialSpawn(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) {
  61.         this.setEquipmentBasedOnDifficulty(difficultyIn);
  62.         return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
  63.     }
  64.     @Override
  65.     protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) {
  66.         this.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(Items.GOLDEN_AXE));
  67.     }
  68.  
  69.     @Override
  70.     protected int getExperiencePoints(PlayerEntity player) { return 1 + this.world.rand.nextInt(4); }
  71.  
  72.     @Override
  73.     protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_PIG_AMBIENT; }
  74.  
  75.     @Override
  76.     protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_PIG_DEATH; }
  77.  
  78.     @Override
  79.     protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.ENTITY_PIG_HURT; }
  80.  
  81.     @Override
  82.     protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.ENTITY_PIG_STEP, 0.15F, 1.0F); }
  83.  
  84.     @Override
  85.     protected SoundEvent getFallSound(int heightIn) { return heightIn > 4 ? SoundEvents.ENTITY_HOSTILE_BIG_FALL : SoundEvents.ENTITY_HOSTILE_SMALL_FALL; }
  86. }
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement