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 pBuilder)
      Overrides:
      defineSynchedData in class AgeableMob
    • getFlag

      protected boolean getFlag(int pFlagId)
    • setFlag

      protected void setFlag(int pFlagId, boolean pValue)
    • isTamed

      public boolean isTamed()
    • getOwnerUUID

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

      public void setOwnerUUID(@Nullable UUID pUuid)
    • isJumping

      public boolean isJumping()
    • setTamed

      public void setTamed(boolean pTamed)
    • setIsJumping

      public void setIsJumping(boolean pJumping)
    • handleLeashAtDistance

      public boolean handleLeashAtDistance(Entity pLeashHolder, float pDistance)
      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 pBreeding)
    • isSaddleable

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

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

      public void equipBodyArmor(Player pPlayer, ItemStack pStack)
    • isSaddled

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

      public int getTemper()
    • setTemper

      public void setTemper(int pTemper)
    • modifyTemper

      public int modifyTemper(int pAddedTemper)
    • isPushable

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

      private void eating()
    • causeFallDamage

      public boolean causeFallDamage(float pFallDistance, float pMultiplier, DamageSource pSource)
      Overrides:
      causeFallDamage in class LivingEntity
    • getInventorySize

      public final int getInventorySize()
    • getInventorySize

      public static int getInventorySize(int pColumns)
    • createInventory

      protected void createInventory()
    • syncSaddleToClients

      protected void syncSaddleToClients()
    • containerChanged

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

      public boolean hurt(DamageSource pSource, float pAmount)
      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 pPos, BlockState pBlock)
      Overrides:
      playStepSound in class Entity
    • isWoodSoundType

      private boolean isWoodSoundType(SoundType pSoundType)
    • playGallopSound

      protected void playGallopSound(SoundType pSoundType)
    • 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 pPlayer)
      Specified by:
      openCustomInventoryScreen in interface HasCustomInventoryScreen
    • fedFood

      public InteractionResult fedFood(Player pPlayer, ItemStack pStack)
    • handleEating

      protected boolean handleEating(Player pPlayer, ItemStack pStack)
    • doPlayerRide

      protected void doPlayerRide(Player pPlayer)
    • isImmobile

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

      public boolean isFood(ItemStack pStack)
      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 pPlayer, InteractionHand pHand)
      Overrides:
      mobInteract in class Animal
    • openMouth

      private void openMouth()
    • setEating

      public void setEating(boolean pEating)
    • setStanding

      public void setStanding(boolean pStanding)
    • getAmbientStandSound

      @Nullable public SoundEvent getAmbientStandSound()
    • standIfPossible

      public void standIfPossible()
    • makeMad

      public void makeMad()
    • tameWithName

      public boolean tameWithName(Player pPlayer)
    • tickRidden

      protected void tickRidden(Player pPlayer, Vec3 pTravelVector)
      Overrides:
      tickRidden in class LivingEntity
    • getRiddenRotation

      protected Vec2 getRiddenRotation(LivingEntity pEntity)
    • getRiddenInput

      protected Vec3 getRiddenInput(Player pPlayer, Vec3 pTravelVector)
      Overrides:
      getRiddenInput in class LivingEntity
    • getRiddenSpeed

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

      protected void executeRidersJump(float pPlayerJumpPendingScale, Vec3 pTravelVector)
    • playJumpSound

      protected void playJumpSound()
    • addAdditionalSaveData

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

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

      public boolean canMate(Animal pOtherAnimal)
      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 pLevel, AgeableMob pOtherParent)
      Specified by:
      getBreedOffspring in class AgeableMob
    • setOffspringAttributes

      protected void setOffspringAttributes(AgeableMob pParent, AbstractHorse pChild)
    • setOffspringAttribute

      private void setOffspringAttribute(AgeableMob pParent, AbstractHorse pChild, Holder<Attribute> pAttribute, double pMin, double pMax)
    • createOffspringAttribute

      static double createOffspringAttribute(double pValue1, double pValue2, double pMin, double pMax, RandomSource pRandom)
    • getEatAnim

      public float getEatAnim(float pPartialTick)
    • getStandAnim

      public float getStandAnim(float pPartialTick)
    • getMouthAnim

      public float getMouthAnim(float pPartialTick)
    • onPlayerJump

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

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

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

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

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

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

      protected void positionRider(Entity pPassenger, Entity.MoveFunction pCallback)
      Overrides:
      positionRider in class Entity
    • generateMaxHealth

      protected static float generateMaxHealth(IntUnaryOperator pOperator)
    • generateJumpStrength

      protected static double generateJumpStrength(DoubleSupplier pSupplier)
    • generateSpeed

      protected static double generateSpeed(DoubleSupplier pSupplier)
    • onClimbable

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

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

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

      @Nullable private Vec3 getDismountLocationInDirection(Vec3 pDirection, LivingEntity pPassenger)
    • getDismountLocationForPassenger

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

      protected void randomizeAttributes(RandomSource pRandom)
    • finalizeSpawn

      @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor pLevel, DifficultyInstance pDifficulty, MobSpawnType pSpawnType, @Nullable SpawnGroupData pSpawnGroupData)
      Overrides:
      finalizeSpawn in class AgeableMob
    • getInventory

      public Container getInventory()
    • hasInventoryChanged

      public boolean hasInventoryChanged(Container pInventory)
    • getAmbientStandInterval

      public int getAmbientStandInterval()
    • getPassengerAttachmentPoint

      protected Vec3 getPassengerAttachmentPoint(Entity pEntity, EntityDimensions pDimensions, float pPartialTick)
      Overrides:
      getPassengerAttachmentPoint in class Entity
    • getBodyArmorAccess

      public final Container getBodyArmorAccess()
    • getInventoryColumns

      public int getInventoryColumns()