Paper/patches/server-remapped/0123-Add-source-to-PlayerExpChangeEvent.patch
Mariell Hoversholm a207d14a0e
Rename all patches to correct numbering scheme
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
2021-06-11 15:46:44 +02:00

50 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaBlend <whizkid3000@hotmail.com>
Date: Thu, 8 Sep 2016 08:48:33 -0700
Subject: [PATCH] Add source to PlayerExpChangeEvent
diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
index a4a1e836767d0b2b71c3277a28eb72418fa76210..f932fc4f8240b48f8e518af05d1521bc8ff9cbee 100644
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
@@ -202,7 +202,7 @@ public class ExperienceOrb extends Entity {
}
if (this.value > 0) {
- player.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(player, this.value).getAmount()); // CraftBukkit - this.value -> event.getAmount()
+ player.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(player, this).getAmount()); // CraftBukkit - this.value -> event.getAmount() // Paper - supply experience orb object
}
this.remove();
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 81af3e2e0964b6e179f92a342efdae943be18b75..c85fcad33e17c8ae2e4ee5cb873dbd4166fcc7f5 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -109,6 +109,7 @@ import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession;
+import org.bukkit.entity.ExperienceOrb; // Paper
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Result;
@@ -1045,6 +1046,17 @@ public class CraftEventFactory {
return event;
}
+ // Paper start - Add orb
+ public static PlayerExpChangeEvent callPlayerExpChangeEvent(net.minecraft.world.entity.player.Player entity, net.minecraft.world.entity.ExperienceOrb entityOrb) {
+ Player player = (Player) entity.getBukkitEntity();
+ ExperienceOrb source = (ExperienceOrb) entityOrb.getBukkitEntity();
+ int expAmount = source.getExperience();
+ PlayerExpChangeEvent event = new PlayerExpChangeEvent(player, source, expAmount);
+ Bukkit.getPluginManager().callEvent(event);
+ return event;
+ }
+ // Paper end
+
public static boolean handleBlockGrowEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState block) {
return handleBlockGrowEvent(world, pos, block, 3);
}