aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/entity/vehicle/VehicleEntity.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/og/net/minecraft/world/entity/vehicle/VehicleEntity.patch')
-rw-r--r--patch-remap/og/net/minecraft/world/entity/vehicle/VehicleEntity.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/entity/vehicle/VehicleEntity.patch b/patch-remap/og/net/minecraft/world/entity/vehicle/VehicleEntity.patch
new file mode 100644
index 0000000000..ea7db6b296
--- /dev/null
+++ b/patch-remap/og/net/minecraft/world/entity/vehicle/VehicleEntity.patch
@@ -0,0 +1,62 @@
+--- a/net/minecraft/world/entity/vehicle/VehicleEntity.java
++++ b/net/minecraft/world/entity/vehicle/VehicleEntity.java
+@@ -13,6 +13,12 @@
+ import net.minecraft.world.level.World;
+ import net.minecraft.world.level.gameevent.GameEvent;
+
++// CraftBukkit start
++import org.bukkit.entity.Vehicle;
++import org.bukkit.event.vehicle.VehicleDamageEvent;
++import org.bukkit.event.vehicle.VehicleDestroyEvent;
++// CraftBukkit end
++
+ public abstract class VehicleEntity extends Entity {
+
+ protected static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(VehicleEntity.class, DataWatcherRegistry.INT);
+@@ -29,6 +35,18 @@
+ if (this.isInvulnerableTo(damagesource)) {
+ return false;
+ } else {
++ // CraftBukkit start
++ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
++ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
++
++ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
++ this.level().getCraftServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return false;
++ }
++ f = (float) event.getDamage();
++ // CraftBukkit end
+ this.setHurtDir(-this.getHurtDir());
+ this.setHurtTime(10);
+ this.markHurt();
+@@ -38,9 +56,27 @@
+
+ if ((flag || this.getDamage() <= 40.0F) && !this.shouldSourceDestroy(damagesource)) {
+ if (flag) {
++ // CraftBukkit start
++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
++ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent);
++
++ if (destroyEvent.isCancelled()) {
++ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away
++ return true;
++ }
++ // CraftBukkit end
+ this.discard();
+ }
+ } else {
++ // CraftBukkit start
++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
++ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent);
++
++ if (destroyEvent.isCancelled()) {
++ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away
++ return true;
++ }
++ // CraftBukkit end
+ this.destroy(damagesource);
+ }
+