2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityBoat.java
|
|
|
|
+++ b/net/minecraft/server/EntityBoat.java
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -3,6 +3,15 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.List;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Location;
|
|
|
|
+import org.bukkit.entity.Vehicle;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleDamageEvent;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleMoveEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class EntityBoat extends Entity {
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b);
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -37,6 +46,14 @@
|
|
|
|
private float aR;
|
|
|
|
private float aS;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable.
|
2014-11-25 22:32:16 +01:00
|
|
|
+ public double maxSpeed = 0.4D;
|
|
|
|
+ public double occupiedDeceleration = 0.2D;
|
|
|
|
+ public double unoccupiedDeceleration = -1;
|
|
|
|
+ public boolean landBoats = false;
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public EntityBoat(World world) {
|
2018-07-15 02:00:00 +02:00
|
|
|
super(EntityTypes.BOAT, world);
|
|
|
|
this.h = new float[2];
|
|
|
|
@@ -94,6 +111,19 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
if (damagesource instanceof EntityDamageSourceIndirect && damagesource.getEntity() != null && this.w(damagesource.getEntity())) {
|
2014-11-25 22:32:16 +01:00
|
|
|
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.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // f = event.getDamage(); // TODO Why don't we do this?
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
this.c(-this.o());
|
|
|
|
this.b(10);
|
|
|
|
this.setDamage(this.m() + f * 10.0F);
|
|
|
|
@@ -101,6 +131,15 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
if (flag || this.m() > 40.0F) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
|
|
|
|
+
|
|
|
|
+ if (destroyEvent.isCancelled()) {
|
|
|
|
+ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) {
|
2018-07-15 02:00:00 +02:00
|
|
|
this.a((IMaterial) this.f());
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -134,9 +173,25 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
public void collide(Entity entity) {
|
|
|
|
if (entity instanceof EntityBoat) {
|
|
|
|
if (entity.getBoundingBox().b < this.getBoundingBox().e) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
super.collide(entity);
|
|
|
|
}
|
|
|
|
} else if (entity.getBoundingBox().b <= this.getBoundingBox().b) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
super.collide(entity);
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -173,6 +228,7 @@
|
2016-04-20 12:12:14 +02:00
|
|
|
return this.getDirection().e();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ private Location lastLocation; // CraftBukkit
|
2018-07-15 02:00:00 +02:00
|
|
|
public void tick() {
|
|
|
|
this.aM = this.aL;
|
|
|
|
this.aL = this.s();
|
|
|
|
@@ -217,6 +273,22 @@
|
2016-04-20 12:12:14 +02:00
|
|
|
this.motZ = 0.0D;
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-04-20 12:12:14 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.Server server = this.world.getServer();
|
|
|
|
+ org.bukkit.World bworld = this.world.getWorld();
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-04-20 12:12:14 +02:00
|
|
|
+ Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
|
|
|
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-04-20 12:12:14 +02:00
|
|
|
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-04-20 12:12:14 +02:00
|
|
|
+ if (lastLocation != null && !lastLocation.equals(to)) {
|
|
|
|
+ VehicleMoveEvent event = new VehicleMoveEvent(vehicle, lastLocation, to);
|
|
|
|
+ server.getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+ lastLocation = vehicle.getLocation();
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
this.q();
|
|
|
|
|
2016-04-20 12:12:14 +02:00
|
|
|
for (int i = 0; i <= 1; ++i) {
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -737,6 +809,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
this.c(this.fallDistance, 1.0F);
|
2016-02-29 22:32:46 +01:00
|
|
|
if (!this.world.isClientSide && !this.dead) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
|
|
|
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
|
|
|
|
+ if (!destroyEvent.isCancelled()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.die();
|
|
|
|
if (this.world.getGameRules().getBoolean("doEntityDrops")) {
|
|
|
|
int i;
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -750,6 +827,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
+ } // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.fallDistance = 0.0F;
|