mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-25 16:16:14 +00:00
114 lines
4.5 KiB
Diff
114 lines
4.5 KiB
Diff
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
@@ -48,6 +48,15 @@
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import net.minecraft.world.phys.shapes.VoxelShapes;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.craftbukkit.util.CraftLocation;
|
|
+import org.bukkit.entity.Vehicle;
|
|
+import org.bukkit.event.entity.EntityRemoveEvent;
|
|
+import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
|
+import org.bukkit.event.vehicle.VehicleMoveEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public abstract class AbstractBoat extends VehicleEntity implements Leashable {
|
|
|
|
private static final DataWatcherObject<Boolean> DATA_ID_PADDLE_LEFT = DataWatcher.defineId(AbstractBoat.class, DataWatcherRegistry.BOOLEAN);
|
|
@@ -87,6 +96,14 @@
|
|
private Leashable.a leashData;
|
|
private final Supplier<Item> dropItem;
|
|
|
|
+ // CraftBukkit start
|
|
+ // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable.
|
|
+ public double maxSpeed = 0.4D;
|
|
+ public double occupiedDeceleration = 0.2D;
|
|
+ public double unoccupiedDeceleration = -1;
|
|
+ public boolean landBoats = false;
|
|
+ // CraftBukkit end
|
|
+
|
|
public AbstractBoat(EntityTypes<? extends AbstractBoat> entitytypes, World world, Supplier<Item> supplier) {
|
|
super(entitytypes, world);
|
|
this.dropItem = supplier;
|
|
@@ -182,9 +199,29 @@
|
|
public void push(Entity entity) {
|
|
if (entity instanceof AbstractBoat) {
|
|
if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
|
|
+ // CraftBukkit start
|
|
+ if (!this.isPassengerOfSameVehicle(entity)) {
|
|
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
super.push(entity);
|
|
}
|
|
} else if (entity.getBoundingBox().minY <= this.getBoundingBox().minY) {
|
|
+ // CraftBukkit start
|
|
+ if (!this.isPassengerOfSameVehicle(entity)) {
|
|
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
super.push(entity);
|
|
}
|
|
|
|
@@ -247,6 +284,7 @@
|
|
return this.getDirection().getClockWise();
|
|
}
|
|
|
|
+ private Location lastLocation; // CraftBukkit
|
|
@Override
|
|
public void tick() {
|
|
this.oldStatus = this.status;
|
|
@@ -287,6 +325,21 @@
|
|
this.setDeltaMovement(Vec3D.ZERO);
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ org.bukkit.Server server = this.level().getCraftServer();
|
|
+ org.bukkit.World bworld = this.level().getWorld();
|
|
+
|
|
+ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot());
|
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
|
+
|
|
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
|
+
|
|
+ if (lastLocation != null && !lastLocation.equals(to)) {
|
|
+ VehicleMoveEvent event = new VehicleMoveEvent(vehicle, lastLocation, to);
|
|
+ server.getPluginManager().callEvent(event);
|
|
+ }
|
|
+ lastLocation = vehicle.getLocation();
|
|
+ // CraftBukkit end
|
|
this.applyEffectsFromBlocks();
|
|
this.applyEffectsFromBlocks();
|
|
this.tickBubbleColumn();
|
|
@@ -790,11 +843,18 @@
|
|
|
|
@Override
|
|
public void remove(Entity.RemovalReason entity_removalreason) {
|
|
+ // CraftBukkit start - add Bukkit remove cause
|
|
+ this.remove(entity_removalreason, null);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
|
|
+ // CraftBukkit end
|
|
if (!this.level().isClientSide && entity_removalreason.shouldDestroy() && this.isLeashed()) {
|
|
this.dropLeash(true, true);
|
|
}
|
|
|
|
- super.remove(entity_removalreason);
|
|
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
|
|
}
|
|
|
|
@Override
|