2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/vehicle/EntityBoat.java
|
|
|
|
+++ b/net/minecraft/world/entity/vehicle/EntityBoat.java
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -55,6 +55,16 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapes;
|
2023-09-21 18:40:00 +02:00
|
|
|
import org.joml.Vector3f;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Location;
|
2023-04-19 11:59:19 +02:00
|
|
|
+import org.bukkit.craftbukkit.util.CraftLocation;
|
2014-11-25 22:32:16 +01:00
|
|
|
+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
|
|
|
|
+
|
2022-12-07 17:00:00 +01:00
|
|
|
public class EntityBoat extends Entity implements VariantHolder<EntityBoat.EnumBoatType> {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT);
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -95,6 +105,14 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
private float bubbleAngle;
|
|
|
|
private float bubbleAngleO;
|
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);
|
2021-06-11 07:00:00 +02:00
|
|
|
this.paddlePositions = new float[2];
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -180,6 +198,19 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
if (this.isInvulnerableTo(damagesource)) {
|
2020-06-25 02:00:00 +02:00
|
|
|
return false;
|
2023-06-07 17:30:00 +02:00
|
|
|
} else if (!this.level().isClientSide && !this.isRemoved()) {
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // 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);
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().getCraftServer().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
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
this.setHurtDir(-this.getHurtDir());
|
|
|
|
this.setHurtTime(10);
|
2020-06-25 02:00:00 +02:00
|
|
|
this.setDamage(this.getDamage() + f * 10.0F);
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -188,6 +219,15 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
|
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);
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().getCraftServer().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
|
2023-06-07 17:30:00 +02:00
|
|
|
if (!flag && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
2022-06-07 18:00:00 +02:00
|
|
|
this.destroy(damagesource);
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -227,9 +267,29 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
public void push(Entity entity) {
|
2016-02-29 22:32:46 +01:00
|
|
|
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
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (!this.isPassengerOfSameVehicle(entity)) {
|
2020-01-24 06:48:48 +01:00
|
|
|
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().getCraftServer().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
|
2021-11-21 23:00:00 +01:00
|
|
|
super.push(entity);
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
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
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (!this.isPassengerOfSameVehicle(entity)) {
|
2020-01-24 06:48:48 +01:00
|
|
|
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().getCraftServer().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
|
2021-11-21 23:00:00 +01:00
|
|
|
super.push(entity);
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -322,6 +382,7 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
return this.getDirection().getClockWise();
|
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() {
|
2021-06-11 07:00:00 +02:00
|
|
|
this.oldStatus = this.status;
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -362,6 +423,22 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
this.setDeltaMovement(Vec3D.ZERO);
|
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
|
2023-06-07 17:30:00 +02:00
|
|
|
+ org.bukkit.Server server = this.level().getCraftServer();
|
|
|
|
+ org.bukkit.World bworld = this.level().getWorld();
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2023-04-19 11:59:19 +02:00
|
|
|
+ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot());
|
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
|
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
this.tickBubbleColumn();
|
2018-07-15 02:00:00 +02:00
|
|
|
|
2016-04-20 12:12:14 +02:00
|
|
|
for (int i = 0; i <= 1; ++i) {
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -845,6 +922,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2023-03-14 17:30:00 +01:00
|
|
|
this.causeFallDamage(this.fallDistance, 1.0F, this.damageSources().fall());
|
2023-06-07 17:30:00 +02:00
|
|
|
if (!this.level().isClientSide && !this.isRemoved()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
|
|
|
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (!destroyEvent.isCancelled()) {
|
2021-11-21 23:00:00 +01:00
|
|
|
this.kill();
|
2023-06-07 17:30:00 +02:00
|
|
|
if (this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
int i;
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -858,6 +940,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
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
this.resetFallDistance();
|