3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 20:40:07 +01:00
Paper/Spigot-Server-Patches/0124-Vehicle-Event-Cancellation-Changes.patch
Aikar c148342731 Vehicle Dismount Event Improvements
player.getVehicle() was returning null during the event. Paper had added lots of code to
cause the player to remount the entity on cancel.

I've simplified the diff and made player.getVehicle() work during the event by setting the
vehicle back during the event, and only set it to null if the event is not cancelled.
2016-12-29 00:53:02 -05:00

46 Zeilen
2.1 KiB
Diff

From bfeefa77f4a6e6a10d13927a766fd76a9c492764 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 22 Apr 2016 18:20:05 -0500
Subject: [PATCH] Vehicle Event Cancellation Changes
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index ae6638d39..0818ff854 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -70,7 +70,7 @@ public abstract class Entity implements ICommandListener {
public boolean i;
public final List<Entity> passengers;
protected int j;
- private Entity au;
+ private Entity au;public void setVehicle(Entity entity) { this.au = entity; } // Paper // OBFHELPER
public boolean attachedToPlayer;
public World world;
public double lastX;
@@ -1880,6 +1880,7 @@ public abstract class Entity implements ICommandListener {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
// CraftBukkit start
+ entity.setVehicle(this); // Paper - Set the vehicle back for the event
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
@@ -1895,7 +1896,13 @@ public abstract class Entity implements ICommandListener {
}
}
// CraftBukkit end
- Bukkit.getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity())); // Spigot
+ // Paper start - make EntityDismountEvent cancellable
+ if (!new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()).callEvent()) {
+ return;
+ }
+ entity.setVehicle(null);
+ // Paper end
+
this.passengers.remove(entity);
entity.j = 60;
}
--
2.11.0