Class Animal

All Implemented Interfaces:
CommandSource, SyncedDataHolder, Attackable, EquipmentUser, Leashable, Targeting, EntityAccess, Nameable, ScoreHolder, IAttachmentHolder, IEntityExtension, ILivingEntityExtension, INBTSerializable<CompoundTag>
Direct Known Subclasses:
AbstractHorse, Armadillo, Axolotl, Bee, Chicken, Cow, Fox, Frog, Goat, Hoglin, Ocelot, Panda, Pig, PolarBear, Rabbit, Sheep, Sniffer, Strider, TamableAnimal, Turtle

public abstract class Animal extends AgeableMob
  • Field Details

    • PARENT_AGE_AFTER_BREEDING

      protected static final int PARENT_AGE_AFTER_BREEDING
      See Also:
    • inLove

      private int inLove
    • loveCause

      @Nullable private UUID loveCause
  • Constructor Details

  • Method Details

    • customServerAiStep

      protected void customServerAiStep()
      Overrides:
      customServerAiStep in class Mob
    • aiStep

      public void aiStep()
      Overrides:
      aiStep in class AgeableMob
    • actuallyHurt

      protected void actuallyHurt(DamageSource damageSource, float damageAmount)
      Deals damage to the entity. This will take the armor of the entity into consideration before damaging the health bar.
      Overrides:
      actuallyHurt in class LivingEntity
    • getWalkTargetValue

      public float getWalkTargetValue(BlockPos pos, LevelReader level)
      Overrides:
      getWalkTargetValue in class PathfinderMob
    • addAdditionalSaveData

      public void addAdditionalSaveData(CompoundTag compound)
      Overrides:
      addAdditionalSaveData in class AgeableMob
    • readAdditionalSaveData

      public void readAdditionalSaveData(CompoundTag compound)
      (abstract) Protected helper method to read subclass entity data from NBT.
      Overrides:
      readAdditionalSaveData in class AgeableMob
    • checkAnimalSpawnRules

      public static boolean checkAnimalSpawnRules(EntityType<? extends Animal> animal, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random)
    • isBrightEnoughToSpawn

      protected static boolean isBrightEnoughToSpawn(BlockAndTintGetter level, BlockPos pos)
    • getAmbientSoundInterval

      public int getAmbientSoundInterval()
      Overrides:
      getAmbientSoundInterval in class Mob
    • removeWhenFarAway

      public boolean removeWhenFarAway(double distanceToClosestPlayer)
      Overrides:
      removeWhenFarAway in class Mob
    • getBaseExperienceReward

      protected int getBaseExperienceReward()
      Overrides:
      getBaseExperienceReward in class Mob
    • isFood

      public abstract boolean isFood(ItemStack stack)
      Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on the animal type)
    • mobInteract

      public InteractionResult mobInteract(Player player, InteractionHand hand)
      Overrides:
      mobInteract in class Mob
    • usePlayerItem

      protected void usePlayerItem(Player player, InteractionHand hand, ItemStack stack)
    • canFallInLove

      public boolean canFallInLove()
    • setInLove

      public void setInLove(@Nullable Player player)
    • setInLoveTime

      public void setInLoveTime(int inLove)
    • getInLoveTime

      public int getInLoveTime()
    • getLoveCause

      @Nullable public ServerPlayer getLoveCause()
    • isInLove

      public boolean isInLove()
    • resetLove

      public void resetLove()
    • canMate

      public boolean canMate(Animal otherAnimal)
      Returns true if the mob is currently able to mate with the specified mob.
    • spawnChildFromBreeding

      public void spawnChildFromBreeding(ServerLevel level, Animal mate)
    • finalizeSpawnChildFromBreeding

      public void finalizeSpawnChildFromBreeding(ServerLevel level, Animal animal, @Nullable AgeableMob baby)
    • handleEntityEvent

      public void handleEntityEvent(byte id)
      Handler for
      invalid reference
      World#setEntityState
      Overrides:
      handleEntityEvent in class Mob