package net.minecraft.world.entity.animal.horse; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; public class Donkey extends AbstractChestedHorse { public Donkey(EntityType entityType, Level level) { super(entityType, level); } @Override protected SoundEvent getAmbientSound() { return SoundEvents.DONKEY_AMBIENT; } @Override protected SoundEvent getAngrySound() { return SoundEvents.DONKEY_ANGRY; } @Override protected SoundEvent getDeathSound() { return SoundEvents.DONKEY_DEATH; } @Nullable @Override protected SoundEvent getEatingSound() { return SoundEvents.DONKEY_EAT; } @Override protected SoundEvent getHurtSound(DamageSource damageSource) { return SoundEvents.DONKEY_HURT; } @Override public boolean canMate(Animal otherAnimal) { if (otherAnimal == this) { return false; } else { return !(otherAnimal instanceof Donkey) && !(otherAnimal instanceof Horse) ? false : this.canParent() && ((AbstractHorse)otherAnimal).canParent(); } } @Override protected void playJumpSound() { this.playSound(SoundEvents.DONKEY_JUMP, 0.4F, 1.0F); } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob otherParent) { EntityType entityType = otherParent instanceof Horse ? EntityType.MULE : EntityType.DONKEY; AbstractHorse abstractHorse = entityType.create(level, EntitySpawnReason.BREEDING); if (abstractHorse != null) { this.setOffspringAttributes(otherParent, abstractHorse); } return abstractHorse; } }