From 0bd83b4c4dd057853e1aa667389a06fb410f6a68 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 8 Jun 2023 23:52:18 -0700 Subject: [PATCH] fix missing trigger entity for xp orb from breeding --- ...PI-for-Reason-Source-Triggering-play.patch | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch b/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch index 2dd69fe13a..8361069cbf 100644 --- a/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch +++ b/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch @@ -29,7 +29,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private int count; private Player followingPlayer; + // Paper start ++ @javax.annotation.Nullable + public java.util.UUID sourceEntityId; ++ @javax.annotation.Nullable + public java.util.UUID triggerEntityId; + public org.bukkit.entity.ExperienceOrb.SpawnReason spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN; + @@ -73,11 +75,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this(world, x, y, z, amount, null, null); + } + -+ public ExperienceOrb(Level world, double d0, double d1, double d2, int i, org.bukkit.entity.ExperienceOrb.SpawnReason reason, Entity triggerId) { ++ public ExperienceOrb(Level world, double d0, double d1, double d2, int i, @javax.annotation.Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @javax.annotation.Nullable Entity triggerId) { + this(world, d0, d1, d2, i, reason, triggerId, null); + } + -+ public ExperienceOrb(Level world, double d0, double d1, double d2, int i, org.bukkit.entity.ExperienceOrb.SpawnReason reason, Entity triggerId, Entity sourceId) { ++ public ExperienceOrb(Level world, double d0, double d1, double d2, int i, @javax.annotation.Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @javax.annotation.Nullable Entity triggerId, @javax.annotation.Nullable Entity sourceId) { this(EntityType.EXPERIENCE_ORB, world); - this.setPos(x, y, z); + this.sourceEntityId = sourceId != null ? sourceId.getUUID() : null; @@ -148,12 +150,31 @@ diff --git a/src/main/java/net/minecraft/world/entity/animal/Animal.java b/src/m index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Animal.java +++ b/src/main/java/net/minecraft/world/entity/animal/Animal.java +@@ -0,0 +0,0 @@ public abstract class Animal extends AgeableMob { + + public void finalizeSpawnChildFromBreeding(ServerLevel worldserver, Animal entityanimal, @Nullable AgeableMob entityageable, int experience) { + // CraftBukkit end +- Optional.ofNullable(this.getLoveCause()).or(() -> { +- return Optional.ofNullable(entityanimal.getLoveCause()); +- }).ifPresent((entityplayer) -> { ++ // Paper start ++ ServerPlayer entityplayer = this.getLoveCause(); ++ if (entityplayer == null) entityplayer = entityanimal.getLoveCause(); ++ if (entityplayer != null) { ++ // Paper end + entityplayer.awardStat(Stats.ANIMALS_BRED); + CriteriaTriggers.BRED_ANIMALS.trigger(entityplayer, this, entityanimal, entityageable); +- }); ++ } // Paper + this.setAge(6000); + entityanimal.setAge(6000); + this.resetLove(); @@ -0,0 +0,0 @@ public abstract class Animal extends AgeableMob { if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // CraftBukkit start - use event experience if (experience > 0) { - worldserver.addFreshEntity(new ExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience)); -+ worldserver.addFreshEntity(new ExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, null)); // Paper //TODO trigger ++ worldserver.addFreshEntity(new ExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper } // CraftBukkit end }