2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityBoat.java
|
|
|
|
+++ b/net/minecraft/server/EntityBoat.java
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -4,6 +4,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 {
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b);
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -38,6 +47,14 @@
|
2020-08-11 23:00:00 +02:00
|
|
|
private float aD;
|
|
|
|
private float aE;
|
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
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
public EntityBoat(EntityTypes<? extends EntityBoat> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
2020-08-11 23:00:00 +02:00
|
|
|
this.ah = new float[2];
|
|
|
|
@@ -108,6 +125,19 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
if (this.isInvulnerable(damagesource)) {
|
|
|
|
return false;
|
|
|
|
} else if (!this.world.isClientSide && !this.dead) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
|
|
|
+ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ // f = event.getDamage(); // TODO Why don't we do this?
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
this.c(-this.o());
|
|
|
|
this.b(10);
|
|
|
|
this.setDamage(this.getDamage() + f * 10.0F);
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -115,6 +145,15 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
if (flag || this.getDamage() > 40.0F) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
+ if (destroyEvent.isCancelled()) {
|
|
|
|
+ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
if (!flag && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
|
|
|
|
this.a((IMaterial) this.g());
|
|
|
|
}
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -149,9 +188,29 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
public void collide(Entity entity) {
|
|
|
|
if (entity instanceof EntityBoat) {
|
2018-10-22 21:00:00 +02:00
|
|
|
if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start
|
2020-01-24 06:48:48 +01:00
|
|
|
+ if (!this.isSameVehicle(entity)) {
|
|
|
|
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
2020-01-24 06:48:48 +01:00
|
|
|
+ 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);
|
|
|
|
}
|
2018-10-22 21:00:00 +02:00
|
|
|
} else if (entity.getBoundingBox().minY <= this.getBoundingBox().minY) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start
|
2020-01-24 06:48:48 +01:00
|
|
|
+ if (!this.isSameVehicle(entity)) {
|
|
|
|
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
2020-01-24 06:48:48 +01:00
|
|
|
+ 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
|
|
|
|
2020-08-11 23:00:00 +02:00
|
|
|
@@ -185,6 +244,7 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
return this.getDirection().g();
|
2016-04-20 12:12:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ private Location lastLocation; // CraftBukkit
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2018-07-15 02:00:00 +02:00
|
|
|
public void tick() {
|
2020-08-11 23:00:00 +02:00
|
|
|
this.ay = this.ax;
|
|
|
|
@@ -225,6 +285,22 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
this.setMot(Vec3D.a);
|
2016-04-20 12:12:14 +02:00
|
|
|
}
|
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
|
|
|
+
|
2019-12-10 23:00:00 +01:00
|
|
|
+ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch);
|
2016-04-20 12:12:14 +02:00
|
|
|
+ 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) {
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -709,6 +785,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
this.b(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();
|
2019-06-21 12:00:00 +02:00
|
|
|
if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
int i;
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -722,6 +803,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;
|