diff options
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/ExperienceOrb.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/ExperienceOrb.java.patch | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/ExperienceOrb.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/ExperienceOrb.java.patch new file mode 100644 index 0000000000..7d59276054 --- /dev/null +++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -0,0 +1,121 @@ +--- a/net/minecraft/world/entity/ExperienceOrb.java ++++ b/net/minecraft/world/entity/ExperienceOrb.java +@@ -20,6 +20,12 @@ + import net.minecraft.world.level.entity.EntityTypeTest; + import net.minecraft.world.phys.AABB; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.event.entity.EntityTargetLivingEntityEvent; ++import org.bukkit.event.entity.EntityTargetEvent; ++import org.bukkit.event.player.PlayerExpCooldownChangeEvent; ++// CraftBukkit end + + public class ExperienceOrb extends Entity { + +@@ -62,6 +65,7 @@ + @Override + public void tick() { + super.tick(); ++ Player prevTarget = this.followingPlayer;// CraftBukkit - store old target + this.xo = this.getX(); + this.yo = this.getY(); + this.zo = this.getZ(); +@@ -87,10 +91,25 @@ + this.followingPlayer = null; + } + +- if (this.followingPlayer != null) { +- Vec3 vec3 = new Vec3(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ()); +- double d0 = vec3.lengthSqr(); ++ // CraftBukkit start ++ boolean cancelled = false; ++ if (this.followingPlayer != prevTarget) { ++ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, followingPlayer, (followingPlayer != null) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.FORGOT_TARGET); ++ LivingEntity target = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); ++ cancelled = event.isCancelled(); + ++ if (cancelled) { ++ followingPlayer = prevTarget; ++ } else { ++ followingPlayer = (target instanceof Player) ? (Player) target : null; ++ } ++ } ++ ++ if (this.followingPlayer != null && !cancelled) { ++ // CraftBukkit end ++ Vec3 vec3d = new Vec3(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ()); ++ double d0 = vec3d.lengthSqr(); ++ + if (d0 < 64.0D) { + double d1 = 1.0D - Math.sqrt(d0) / 8.0D; + +@@ -235,13 +248,13 @@ + @Override + public void playerTouch(Player player) { + if (!this.level().isClientSide) { +- if (player.takeXpDelay == 0) { +- player.takeXpDelay = 2; +- player.take(this, 1); +- int i = this.repairPlayerItems(player, this.value); ++ if (entity.takeXpDelay == 0) { ++ entity.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(entity, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2; ++ entity.take(this, 1); ++ int i = this.repairPlayerItems(entity, this.value); + + if (i > 0) { +- player.giveExperiencePoints(i); ++ entity.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(entity, i).getAmount()); // CraftBukkit - this.value -> event.getAmount() + } + + --this.count; +@@ -258,10 +271,18 @@ + + if (entry != null) { + ItemStack itemstack = (ItemStack) entry.getValue(); +- int j = Math.min(this.xpToDurability(i), itemstack.getDamageValue()); ++ int j = Math.min(this.xpToDurability(repairAmount), itemstack.getDamageValue()); ++ // CraftBukkit start ++ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, entry.getKey(), j); ++ j = event.getRepairAmount(); ++ if (event.isCancelled()) { ++ return repairAmount; ++ } ++ // CraftBukkit end + + itemstack.setDamageValue(itemstack.getDamageValue() - j); +- int k = i - this.durabilityToXp(j); ++ int k = repairAmount - this.durabilityToXp(j); ++ this.value = k; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls + + return k > 0 ? this.repairPlayerItems(player, k) : 0; + } else { +@@ -285,8 +306,26 @@ + return this.value >= 2477 ? 10 : (this.value >= 1237 ? 9 : (this.value >= 617 ? 8 : (this.value >= 307 ? 7 : (this.value >= 149 ? 6 : (this.value >= 73 ? 5 : (this.value >= 37 ? 4 : (this.value >= 17 ? 3 : (this.value >= 7 ? 2 : (this.value >= 3 ? 1 : 0))))))))); + } + +- public static int getExperienceValue(int i) { +- return i >= 2477 ? 2477 : (i >= 1237 ? 1237 : (i >= 617 ? 617 : (i >= 307 ? 307 : (i >= 149 ? 149 : (i >= 73 ? 73 : (i >= 37 ? 37 : (i >= 17 ? 17 : (i >= 7 ? 7 : (i >= 3 ? 3 : 1))))))))); ++ public static int getExperienceValue(int expValue) { ++ // CraftBukkit start ++ if (expValue > 162670129) return expValue - 100000; ++ if (expValue > 81335063) return 81335063; ++ if (expValue > 40667527) return 40667527; ++ if (expValue > 20333759) return 20333759; ++ if (expValue > 10166857) return 10166857; ++ if (expValue > 5083423) return 5083423; ++ if (expValue > 2541701) return 2541701; ++ if (expValue > 1270849) return 1270849; ++ if (expValue > 635413) return 635413; ++ if (expValue > 317701) return 317701; ++ if (expValue > 158849) return 158849; ++ if (expValue > 79423) return 79423; ++ if (expValue > 39709) return 39709; ++ if (expValue > 19853) return 19853; ++ if (expValue > 9923) return 9923; ++ if (expValue > 4957) return 4957; ++ // CraftBukkit end ++ return expValue >= 2477 ? 2477 : (expValue >= 1237 ? 1237 : (expValue >= 617 ? 617 : (expValue >= 307 ? 307 : (expValue >= 149 ? 149 : (expValue >= 73 ? 73 : (expValue >= 37 ? 37 : (expValue >= 17 ? 17 : (expValue >= 7 ? 7 : (expValue >= 3 ? 3 : 1))))))))); + } + + @Override |