mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-25 15:06:14 +00:00
76 lines
3.5 KiB
Diff
76 lines
3.5 KiB
Diff
--- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java
|
|
+++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java
|
|
@@ -25,6 +25,11 @@
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
|
import net.minecraft.world.phys.Vec3D;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.entity.Vehicle;
|
|
+import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class OldMinecartBehavior extends MinecartBehavior {
|
|
|
|
private static final double MINECART_RIDABLE_THRESHOLD = 0.01D;
|
|
@@ -454,8 +459,26 @@
|
|
Entity entity = (Entity) iterator.next();
|
|
|
|
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.minecart.isVehicle() && !entity.isPassenger()) {
|
|
+ // CraftBukkit start
|
|
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity());
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent);
|
|
+
|
|
+ if (collisionEvent.isCancelled()) {
|
|
+ continue;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
entity.startRiding(this.minecart);
|
|
} else {
|
|
+ // CraftBukkit start
|
|
+ if (!this.minecart.isPassengerOfSameVehicle(entity)) {
|
|
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity.getBukkitEntity());
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent);
|
|
+
|
|
+ if (collisionEvent.isCancelled()) {
|
|
+ continue;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
entity.push((Entity) this.minecart);
|
|
}
|
|
}
|
|
@@ -467,6 +490,14 @@
|
|
Entity entity1 = (Entity) iterator1.next();
|
|
|
|
if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) {
|
|
+ // CraftBukkit start
|
|
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.minecart.getBukkitEntity(), entity1.getBukkitEntity());
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent);
|
|
+
|
|
+ if (collisionEvent.isCancelled()) {
|
|
+ continue;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
entity1.push((Entity) this.minecart);
|
|
}
|
|
}
|
|
@@ -487,11 +518,17 @@
|
|
|
|
@Override
|
|
public double getMaxSpeed(WorldServer worldserver) {
|
|
+ // CraftBukkit start
|
|
+ Double maxSpeed = this.minecart.maxSpeed;
|
|
+ if (maxSpeed != null) {
|
|
+ return (this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
return this.minecart.isInWater() ? 0.2D : 0.4D;
|
|
}
|
|
|
|
@Override
|
|
public double getSlowdownFactor() {
|
|
- return this.minecart.isVehicle() ? 0.997D : 0.96D;
|
|
+ return this.minecart.isVehicle() || !this.minecart.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty
|
|
}
|
|
}
|