aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
new file mode 100644
index 0000000000..3300c9d219
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
@@ -0,0 +1,72 @@
+--- 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.Level;
+ 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 EntityDataAccessor<Integer> DATA_ID_HURT = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.INT);
+ protected static final EntityDataAccessor<Integer> DATA_ID_HURTDIR = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.INT);
+@@ -40,9 +35,54 @@
+ this.discard();
+ }
+ } else {
+- this.destroy(source);
+- }
++ // CraftBukkit start
++ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
++ org.bukkit.entity.Entity attacker = (source.getEntity() == null) ? null : source.getEntity().getBukkitEntity();
+
++ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) amount);
++ this.level().getCraftServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return false;
++ }
++ amount = (float) event.getDamage();
++ // CraftBukkit end
++ this.setHurtDir(-this.getHurtDir());
++ this.setHurtTime(10);
++ this.markHurt();
++ this.setDamage(this.getDamage() + amount * 10.0F);
++ this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity());
++ boolean flag = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild;
++
++ if ((flag || this.getDamage() <= 40.0F) && !this.shouldSourceDestroy(source)) {
++ 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(source);
++ }
++
++ return true;
++ }
++ } else {
+ return true;
+ }
+ }