Entity Event: Animal Tame (#109)

This commit is contained in:
lazynessmind
2021-06-23 17:46:14 +01:00
committed by GitHub
parent c12524b7aa
commit 125494399d
7 changed files with 169 additions and 0 deletions

View File

@@ -27,6 +27,8 @@ import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
@@ -53,6 +55,10 @@ public interface EntityEvent {
* @see EnterSection#enterSection(Entity, int, int, int, int, int, int)
*/
Event<EnterSection> ENTER_SECTION = EventFactory.createLoop();
/**
* @see AnimalTame#tame(Animal, Player)
*/
Event<AnimalTame> ANIMAL_TAME = EventFactory.createEventResult();
interface LivingDeath {
/**
@@ -130,4 +136,18 @@ public interface EntityEvent {
*/
void enterSection(Entity entity, int sectionX, int sectionY, int sectionZ, int prevX, int prevY, int prevZ);
}
interface AnimalTame {
/**
* Invoked before a tamable animal is tamed.
* This event only works on vanilla mobs. Mods implementing their own entities may want to make their own events or invoke this.
* Equivalent to Forge's {@code AnimalTameEvent} event.
*
* @param animal The animal being tamed.
* @param player The tamer.
* @return A {@link EventResult} determining the outcome of the event,
* the action may be cancelled by the result.
*/
EventResult tame(Animal animal, Player player);
}
}