2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/projectile/IProjectile.java
|
|
|
|
+++ b/net/minecraft/world/entity/projectile/IProjectile.java
|
2021-05-09 08:51:44 +02:00
|
|
|
@@ -15,12 +15,20 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2020-06-25 02:00:00 +02:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2020-07-06 00:50:27 +02:00
|
|
|
+import org.bukkit.projectiles.ProjectileSource;
|
2020-06-25 02:00:00 +02:00
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public abstract class IProjectile extends Entity {
|
|
|
|
|
|
|
|
private UUID shooter;
|
2021-05-09 08:51:44 +02:00
|
|
|
private int c;
|
|
|
|
private boolean d;
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private boolean hitCancelled = false;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
IProjectile(EntityTypes<? extends IProjectile> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
|
|
|
}
|
|
|
|
@@ -30,6 +38,7 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
this.shooter = entity.getUniqueID();
|
|
|
|
this.c = entity.getId();
|
|
|
|
}
|
2020-07-06 09:51:33 +02:00
|
|
|
+ this.projectileSource = (entity != null && entity.getBukkitEntity() instanceof ProjectileSource) ? (ProjectileSource) entity.getBukkitEntity() : null; // CraftBukkit
|
2020-06-25 02:00:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-05-09 08:51:44 +02:00
|
|
|
@@ -111,6 +120,16 @@
|
|
|
|
this.setMot(this.getMot().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z));
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
|
|
|
|
2021-05-09 08:51:44 +02:00
|
|
|
+ // CraftBukkit start - call projectile hit event
|
|
|
|
+ protected void preOnHit(MovingObjectPosition movingobjectposition) {
|
|
|
|
+ org.bukkit.event.entity.ProjectileHitEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition);
|
|
|
|
+ this.hitCancelled = event != null && event.isCancelled();
|
|
|
|
+ if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK || !this.hitCancelled) {
|
|
|
|
+ this.a(movingobjectposition); // PAIL rename onHit
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
protected void a(MovingObjectPosition movingobjectposition) {
|
|
|
|
MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType();
|
|
|
|
|
2021-05-09 08:51:44 +02:00
|
|
|
@@ -125,6 +144,11 @@
|
|
|
|
protected void a(MovingObjectPositionEntity movingobjectpositionentity) {}
|
|
|
|
|
|
|
|
protected void a(MovingObjectPositionBlock movingobjectpositionblock) {
|
|
|
|
+ // CraftBukkit start - cancellable hit event
|
|
|
|
+ if (hitCancelled) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
IBlockData iblockdata = this.world.getType(movingobjectpositionblock.getBlockPosition());
|
|
|
|
|
|
|
|
iblockdata.a(this.world, iblockdata, movingobjectpositionblock, this);
|