Advertisement
Guest User

EntityClass

a guest
Nov 20th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.14 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.player.PlayerEntity;
  10. import net.minecraft.inventory.EquipmentSlotType;
  11. import net.minecraft.item.ItemStack;
  12. import net.minecraft.item.Items;
  13. import net.minecraft.util.DamageSource;
  14. import net.minecraft.util.SoundEvent;
  15. import net.minecraft.util.SoundEvents;
  16. import net.minecraft.util.math.BlockPos;
  17. import net.minecraft.world.DifficultyInstance;
  18. import net.minecraft.world.World;
  19.  
  20. public class OrcWandererEntity extends MonsterEntity {
  21.  
  22.  
  23.     public OrcWandererEntity(EntityType<? extends MonsterEntity> type, World worldIn) {
  24.         super(type, worldIn);
  25.     }
  26.  
  27.     public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
  28.         return MonsterEntity.registerAttributes()
  29.                 .createMutableAttribute(Attributes.MAX_HEALTH, 20.0D)
  30.                 .createMutableAttribute(Attributes.ARMOR, 10.0D)
  31.                 .createMutableAttribute(Attributes.MOVEMENT_SPEED, (double)0.25D)
  32.                 .createMutableAttribute(Attributes.FOLLOW_RANGE, 35.0D)
  33.                 .createMutableAttribute(Attributes.ATTACK_DAMAGE, 5.0D)
  34.                 .createMutableAttribute(Attributes.ATTACK_SPEED, 2.0D)
  35.                 .createMutableAttribute(Attributes.ATTACK_KNOCKBACK, 1.0D);
  36.     }
  37.     @Override
  38.     protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) {
  39.         this.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(Items.DIAMOND_SWORD));
  40.     }
  41.  
  42.     @Override
  43.     protected void registerGoals() {
  44.         super.registerGoals();
  45.         this.goalSelector.addGoal(9, new SwimGoal(this));
  46.         this.goalSelector.addGoal(8, new LookAtGoal(this, PlayerEntity.class, 8.0F));
  47.         this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
  48.         this.goalSelector.addGoal(7, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
  49.         this.goalSelector.addGoal(6, new OpenDoorGoal(this, true));
  50.         this.targetSelector.addGoal(10, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
  51.         this.targetSelector.addGoal(10, new MeleeAttackGoal(this, 1, true));
  52.  
  53.     }
  54.  
  55.     @Override
  56.     protected int getExperiencePoints(PlayerEntity player) { return 1 + this.world.rand.nextInt(4); }
  57.  
  58.     @Override
  59.     protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_PIG_AMBIENT; }
  60.  
  61.     @Override
  62.     protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_PIG_DEATH; }
  63.  
  64.     @Override
  65.     protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.ENTITY_PIG_HURT; }
  66.  
  67.     @Override
  68.     protected void playStepSound(BlockPos pos, BlockState blockIn) { this.playSound(SoundEvents.ENTITY_PIG_STEP, 0.15F, 1.0F); }
  69.  
  70.     @Override
  71.     protected SoundEvent getFallSound(int heightIn) { return heightIn > 4 ? SoundEvents.ENTITY_HOSTILE_BIG_FALL : SoundEvents.ENTITY_HOSTILE_SMALL_FALL; }
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement