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-06-11 07:00:00 +02:00
|
|
|
@@ -22,6 +22,10 @@
|
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 {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
@Nullable
|
|
|
|
@@ -31,6 +35,10 @@
|
|
|
|
private boolean leftOwner;
|
|
|
|
private boolean hasBeenShot;
|
2021-05-09 08:51:44 +02:00
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private boolean hitCancelled = false;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
IProjectile(EntityTypes<? extends IProjectile> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -40,6 +48,7 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
this.ownerUUID = entity.getUUID();
|
2021-06-11 07:00:00 +02:00
|
|
|
this.cachedOwner = entity;
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
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-06-11 07:00:00 +02:00
|
|
|
@@ -143,6 +152,16 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
this.setDeltaMovement(this.getDeltaMovement().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) {
|
2021-11-21 23:00:00 +01:00
|
|
|
+ this.onHit(movingobjectposition);
|
2021-05-09 08:51:44 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
protected void onHit(MovingObjectPosition movingobjectposition) {
|
2020-06-25 02:00:00 +02:00
|
|
|
MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType();
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -161,6 +180,11 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {}
|
2021-05-09 08:51:44 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) {
|
2021-05-09 08:51:44 +02:00
|
|
|
+ // CraftBukkit start - cancellable hit event
|
|
|
|
+ if (hitCancelled) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
IBlockData iblockdata = this.level.getBlockState(movingobjectpositionblock.getBlockPos());
|
2021-05-09 08:51:44 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
iblockdata.onProjectileHit(this.level, iblockdata, movingobjectpositionblock, this);
|