Paper/patches/server/0119-Add-source-to-PlayerExpChangeEvent.patch
2024-04-23 18:25:14 -07:00

42 lines
2.4 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 4d1001666204b2a2c2bf26231bb1b19f9a1bd8ed..1f29ed95ef3d1904a014715028d9d591fe39231f 100644
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
@@ -261,7 +261,7 @@ public class ExperienceOrb extends Entity {
int i = this.repairPlayerItems(player, this.value);
if (i > 0) {
- player.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(player, i).getAmount()); // CraftBukkit - this.value -> event.getAmount()
+ player.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(player, this).getAmount()); // CraftBukkit - this.value -> event.getAmount() // Paper - supply experience orb object
}
--this.count;
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 168f19c754e413286c69ae9cbcbfb3788f05d8ff..3683cf6765741f6422f478fd09ce1ba6a75d6b99 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1146,6 +1146,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 CraftEventFactory.handleBlockGrowEvent(world, pos, block, 3);
}