Class AbstractHorse

All Implemented Interfaces:
CommandSource, SyncedDataHolder, ContainerListener, Attackable, EquipmentUser, HasCustomInventoryScreen, Leashable, OwnableEntity, PlayerRideable, PlayerRideableJumping, Saddleable, Targeting, EntityAccess, Nameable, ScoreHolder, IAttachmentHolder, IEntityExtension, ILivingEntityExtension, INBTSerializable<CompoundTag>
Direct Known Subclasses:
AbstractChestedHorse, Camel, Horse, SkeletonHorse, ZombieHorse

public abstract class AbstractHorse extends Animal implements ContainerListener, HasCustomInventoryScreen, OwnableEntity, PlayerRideableJumping, Saddleable
  • Field Details

    • EQUIPMENT_SLOT_OFFSET

      public static final int EQUIPMENT_SLOT_OFFSET
      See Also:
    • CHEST_SLOT_OFFSET

      public static final int CHEST_SLOT_OFFSET
      See Also:
    • INVENTORY_SLOT_OFFSET

      public static final int INVENTORY_SLOT_OFFSET
      See Also:
    • BREEDING_CROSS_FACTOR

      public static final double BREEDING_CROSS_FACTOR
      See Also:
    • MIN_MOVEMENT_SPEED

      private static final float MIN_MOVEMENT_SPEED
    • MAX_MOVEMENT_SPEED

      private static final float MAX_MOVEMENT_SPEED
    • MIN_JUMP_STRENGTH

      private static final float MIN_JUMP_STRENGTH
    • MAX_JUMP_STRENGTH

      private static final float MAX_JUMP_STRENGTH
    • MIN_HEALTH

      private static final float MIN_HEALTH
    • MAX_HEALTH

      private static final float MAX_HEALTH
    • BACKWARDS_MOVE_SPEED_FACTOR

      private static final float BACKWARDS_MOVE_SPEED_FACTOR
      See Also:
    • SIDEWAYS_MOVE_SPEED_FACTOR

      private static final float SIDEWAYS_MOVE_SPEED_FACTOR
      See Also:
    • PARENT_HORSE_SELECTOR

      private static final Predicate<LivingEntity> PARENT_HORSE_SELECTOR
    • MOMMY_TARGETING

      private static final TargetingConditions MOMMY_TARGETING
    • DATA_ID_FLAGS

      private static final EntityDataAccessor<Byte> DATA_ID_FLAGS
    • FLAG_TAME

      private static final int FLAG_TAME
      See Also:
    • FLAG_SADDLE

      private static final int FLAG_SADDLE
      See Also:
    • FLAG_BRED

      private static final int FLAG_BRED
      See Also:
    • FLAG_EATING

      private static final int FLAG_EATING
      See Also:
    • FLAG_STANDING

      private static final int FLAG_STANDING
      See Also:
    • FLAG_OPEN_MOUTH

      private static final int FLAG_OPEN_MOUTH
      See Also:
    • INV_SLOT_SADDLE

      public static final int INV_SLOT_SADDLE
      See Also:
    • INV_BASE_COUNT

      public static final int INV_BASE_COUNT
      See Also:
    • eatingCounter

      private int eatingCounter
    • mouthCounter

      private int mouthCounter
    • standCounter

      private int standCounter
    • tailCounter

      public int tailCounter
    • sprintCounter

      public int sprintCounter
    • isJumping

      protected boolean isJumping
    • inventory

      protected SimpleContainer inventory
    • temper

      protected int temper
      The higher this value, the more likely the horse is to be tamed next time a player rides it.
    • playerJumpPendingScale

      protected float playerJumpPendingScale
    • allowStandSliding

      protected boolean allowStandSliding
    • eatAnim

      private float eatAnim
    • eatAnimO

      private float eatAnimO
    • standAnim

      private float standAnim
    • standAnimO

      private float standAnimO
    • mouthAnim

      private float mouthAnim
    • mouthAnimO

      private float mouthAnimO
    • canGallop

      protected boolean canGallop
    • gallopSoundCounter

      protected int gallopSoundCounter
      Used to determine the sound that the horse should make when it steps
    • owner

      @Nullable private UUID owner
    • bodyArmorAccess

      private final Container bodyArmorAccess
  • Constructor Details

  • Method Details

    • registerGoals

      protected void registerGoals()
      Overrides:
      registerGoals in class Mob
    • addBehaviourGoals

      protected void addBehaviourGoals()
    • defineSynchedData

      protected void defineSynchedData(SynchedEntityData.Builder builder)
      Overrides:
      defineSynchedData in class AgeableMob
    • getFlag

      protected boolean getFlag(int flagId)
    • setFlag

      protected void setFlag(int flagId, boolean value)
    • isTamed

      public boolean isTamed()
    • getOwnerUUID

      @Nullable public UUID getOwnerUUID()
      Specified by:
      getOwnerUUID in interface OwnableEntity
    • setOwnerUUID

      public void setOwnerUUID(@Nullable UUID uuid)
    • isJumping

      public boolean isJumping()
    • setTamed

      public void setTamed(boolean tamed)
    • setIsJumping

      public void setIsJumping(boolean jumping)
    • handleLeashAtDistance

      public boolean handleLeashAtDistance(Entity leashHolder, float distance)
      Specified by:
      handleLeashAtDistance in interface Leashable
      Overrides:
      handleLeashAtDistance in class PathfinderMob
    • isEating

      public boolean isEating()
    • isStanding

      public boolean isStanding()
    • isBred

      public boolean isBred()
    • setBred

      public void setBred(boolean breeding)
    • isSaddleable

      public boolean isSaddleable()
      Specified by:
      isSaddleable in interface Saddleable
    • equipSaddle

      public void equipSaddle(ItemStack stack, @Nullable SoundSource soundSource)
      Specified by:
      equipSaddle in interface Saddleable
    • equipBodyArmor

      public void equipBodyArmor(Player player, ItemStack stack)
    • isSaddled

      public boolean isSaddled()
      Specified by:
      isSaddled in interface Saddleable
    • getTemper

      public int getTemper()
    • setTemper

      public void setTemper(int temper)
    • modifyTemper

      public int modifyTemper(int addedTemper)
    • isPushable

      public boolean isPushable()
      Overrides:
      isPushable in class LivingEntity
    • eating

      private void eating()
    • causeFallDamage

      public boolean causeFallDamage(float fallDistance, float multiplier, DamageSource source)
      Overrides:
      causeFallDamage in class LivingEntity
    • getInventorySize

      public final int getInventorySize()
    • getInventorySize

      public static int getInventorySize(int columns)
    • createInventory

      protected void createInventory()
    • syncSaddleToClients

      protected void syncSaddleToClients()
    • containerChanged

      public void containerChanged(Container invBasic)
      Called by InventoryBasic.onInventoryChanged() on an array that is never filled.
      Specified by:
      containerChanged in interface ContainerListener
    • hurt

      public boolean hurt(DamageSource source, float amount)
      Called when the entity is attacked.
      Overrides:
      hurt in class LivingEntity
    • canPerformRearing

      protected boolean canPerformRearing()
    • getEatingSound

      @Nullable protected SoundEvent getEatingSound()
    • getAngrySound

      @Nullable protected SoundEvent getAngrySound()
    • playStepSound

      protected void playStepSound(BlockPos pos, BlockState block)
      Overrides:
      playStepSound in class Entity
    • isWoodSoundType

      private boolean isWoodSoundType(SoundType soundType)
    • playGallopSound

      protected void playGallopSound(SoundType soundType)
    • createBaseHorseAttributes

      public static AttributeSupplier.Builder createBaseHorseAttributes()
    • getMaxSpawnClusterSize

      public int getMaxSpawnClusterSize()
      Overrides:
      getMaxSpawnClusterSize in class Mob
    • getMaxTemper

      public int getMaxTemper()
    • getSoundVolume

      protected float getSoundVolume()
      Overrides:
      getSoundVolume in class LivingEntity
    • getAmbientSoundInterval

      public int getAmbientSoundInterval()
      Overrides:
      getAmbientSoundInterval in class Animal
    • openCustomInventoryScreen

      public void openCustomInventoryScreen(Player player)
      Specified by:
      openCustomInventoryScreen in interface HasCustomInventoryScreen
    • fedFood

      public InteractionResult fedFood(Player player, ItemStack stack)
    • handleEating

      protected boolean handleEating(Player player, ItemStack stack)
    • doPlayerRide

      protected void doPlayerRide(Player player)
    • isImmobile

      public boolean isImmobile()
      Overrides:
      isImmobile in class LivingEntity
    • isFood

      public 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)
      Specified by:
      isFood in class Animal
    • moveTail

      private void moveTail()
    • dropEquipment

      protected void dropEquipment()
      Overrides:
      dropEquipment in class LivingEntity
    • aiStep

      public void aiStep()
      Overrides:
      aiStep in class Animal
    • followMommy

      protected void followMommy()
    • canEatGrass

      public boolean canEatGrass()
    • tick

      public void tick()
      Overrides:
      tick in class Mob
    • mobInteract

      public InteractionResult mobInteract(Player player, InteractionHand hand)
      Overrides:
      mobInteract in class Animal
    • openMouth

      private void openMouth()
    • setEating

      public void setEating(boolean eating)
    • setStanding

      public void setStanding(boolean standing)
    • getAmbientStandSound

      @Nullable public SoundEvent getAmbientStandSound()
    • standIfPossible

      public void standIfPossible()
    • makeMad

      public void makeMad()
    • tameWithName

      public boolean tameWithName(Player player)
    • tickRidden

      protected void tickRidden(Player player, Vec3 travelVector)
      Overrides:
      tickRidden in class LivingEntity
    • getRiddenRotation

      protected Vec2 getRiddenRotation(LivingEntity entity)
    • getRiddenInput

      protected Vec3 getRiddenInput(Player player, Vec3 travelVector)
      Overrides:
      getRiddenInput in class LivingEntity
    • getRiddenSpeed

      protected float getRiddenSpeed(Player player)
      Overrides:
      getRiddenSpeed in class LivingEntity
    • executeRidersJump

      protected void executeRidersJump(float playerJumpPendingScale, Vec3 travelVector)
    • playJumpSound

      protected void playJumpSound()
    • addAdditionalSaveData

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

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

      public boolean canMate(Animal otherAnimal)
      Returns true if the mob is currently able to mate with the specified mob.
      Overrides:
      canMate in class Animal
    • canParent

      protected boolean canParent()
    • getBreedOffspring

      @Nullable public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob otherParent)
      Specified by:
      getBreedOffspring in class AgeableMob
    • setOffspringAttributes

      protected void setOffspringAttributes(AgeableMob parent, AbstractHorse child)
    • setOffspringAttribute

      private void setOffspringAttribute(AgeableMob parent, AbstractHorse child, Holder<Attribute> attribute, double min, double max)
    • createOffspringAttribute

      static double createOffspringAttribute(double value1, double value2, double min, double max, RandomSource random)
    • getEatAnim

      public float getEatAnim(float partialTick)
    • getStandAnim

      public float getStandAnim(float partialTick)
    • getMouthAnim

      public float getMouthAnim(float partialTick)
    • onPlayerJump

      public void onPlayerJump(int jumpPower)
      Specified by:
      onPlayerJump in interface PlayerRideableJumping
    • canJump

      public boolean canJump()
      Specified by:
      canJump in interface PlayerRideableJumping
    • handleStartJump

      public void handleStartJump(int jumpPower)
      Specified by:
      handleStartJump in interface PlayerRideableJumping
    • handleStopJump

      public void handleStopJump()
      Specified by:
      handleStopJump in interface PlayerRideableJumping
    • spawnTamingParticles

      protected void spawnTamingParticles(boolean tamed)
      Spawns particles for the horse entity.
      Parameters:
      tamed - whether to spawn hearts or smoke.
    • handleEntityEvent

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

      protected void positionRider(Entity passenger, Entity.MoveFunction callback)
      Overrides:
      positionRider in class Entity
    • generateMaxHealth

      protected static float generateMaxHealth(IntUnaryOperator operator)
    • generateJumpStrength

      protected static double generateJumpStrength(DoubleSupplier supplier)
    • generateSpeed

      protected static double generateSpeed(DoubleSupplier supplier)
    • onClimbable

      public boolean onClimbable()
      Overrides:
      onClimbable in class LivingEntity
    • getSlot

      public SlotAccess getSlot(int slot)
      Overrides:
      getSlot in class LivingEntity
    • getControllingPassenger

      @Nullable public LivingEntity getControllingPassenger()
      Overrides:
      getControllingPassenger in class Mob
    • getDismountLocationInDirection

      @Nullable private Vec3 getDismountLocationInDirection(Vec3 direction, LivingEntity passenger)
    • getDismountLocationForPassenger

      public Vec3 getDismountLocationForPassenger(LivingEntity livingEntity)
      Overrides:
      getDismountLocationForPassenger in class Entity
    • randomizeAttributes

      protected void randomizeAttributes(RandomSource random)
    • finalizeSpawn

      @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnGroupData)
      Overrides:
      finalizeSpawn in class AgeableMob
    • getInventory

      public Container getInventory()
    • hasInventoryChanged

      public boolean hasInventoryChanged(Container inventory)
    • getAmbientStandInterval

      public int getAmbientStandInterval()
    • getPassengerAttachmentPoint

      protected Vec3 getPassengerAttachmentPoint(Entity entity, EntityDimensions dimensions, float partialTick)
      Overrides:
      getPassengerAttachmentPoint in class Entity
    • getBodyArmorAccess

      public final Container getBodyArmorAccess()
    • getInventoryColumns

      public int getInventoryColumns()