PaperMC/paper-server/nms-patches/net/minecraft/world/item/ItemChorusFruit.patch
CraftBukkit/Spigot 9da047989c Repackage NMS
By: md_5 <git@md-5.net>
2021-03-16 09:00:00 +11:00

37 lines
1.7 KiB
Diff

--- a/net/minecraft/world/item/ItemChorusFruit.java
+++ b/net/minecraft/world/item/ItemChorusFruit.java
@@ -9,6 +9,13 @@
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import net.minecraft.server.level.EntityPlayer;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
+
public class ItemChorusFruit extends Item {
public ItemChorusFruit(Item.Info item_info) {
@@ -29,6 +36,20 @@
double d4 = MathHelper.a(entityliving.locY() + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.getHeight() - 1));
double d5 = entityliving.locZ() + (entityliving.getRandom().nextDouble() - 0.5D) * 16.0D;
+ // CraftBukkit start
+ if (entityliving instanceof EntityPlayer) {
+ Player player = ((EntityPlayer) entityliving).getBukkitEntity();
+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), new Location(player.getWorld(), d3, d4, d5), PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT);
+ world.getServer().getPluginManager().callEvent(teleEvent);
+ if (teleEvent.isCancelled()) {
+ break;
+ }
+ d3 = teleEvent.getTo().getX();
+ d4 = teleEvent.getTo().getY();
+ d5 = teleEvent.getTo().getZ();
+ }
+ // CraftBukkit end
+
if (entityliving.isPassenger()) {
entityliving.stopRiding();
}