2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/entity/projectile/IProjectile.java
|
|
|
|
+++ b/net/minecraft/world/entity/projectile/IProjectile.java
|
2024-04-24 01:15:00 +10:00
|
|
|
@@ -26,6 +26,10 @@
|
2021-03-16 09:00:00 +11:00
|
|
|
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2020-06-25 10:00:00 +10:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2020-07-06 08:50:27 +10:00
|
|
|
+import org.bukkit.projectiles.ProjectileSource;
|
2020-06-25 10:00:00 +10:00
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2023-03-15 03:30:00 +11:00
|
|
|
public abstract class IProjectile extends Entity implements TraceableEntity {
|
2020-06-25 10:00:00 +10:00
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
@Nullable
|
2024-04-24 01:15:00 +10:00
|
|
|
@@ -35,6 +39,10 @@
|
2021-06-11 15:00:00 +10:00
|
|
|
private boolean leftOwner;
|
|
|
|
private boolean hasBeenShot;
|
2021-05-09 16:51:44 +10:00
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private boolean hitCancelled = false;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
IProjectile(EntityTypes<? extends IProjectile> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
|
|
|
}
|
2024-04-24 01:15:00 +10:00
|
|
|
@@ -44,6 +52,7 @@
|
2021-11-22 09:00:00 +11:00
|
|
|
this.ownerUUID = entity.getUUID();
|
2021-06-11 15:00:00 +10:00
|
|
|
this.cachedOwner = entity;
|
2020-06-25 10:00:00 +10:00
|
|
|
}
|
2020-07-06 17:51:33 +10:00
|
|
|
+ this.projectileSource = (entity != null && entity.getBukkitEntity() instanceof ProjectileSource) ? (ProjectileSource) entity.getBukkitEntity() : null; // CraftBukkit
|
2020-06-25 10:00:00 +10:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-24 01:15:00 +10:00
|
|
|
@@ -170,6 +179,17 @@
|
2023-06-08 01:30:00 +10:00
|
|
|
this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.onGround() ? 0.0D : vec3d.y, vec3d.z));
|
2020-06-25 10:00:00 +10:00
|
|
|
}
|
|
|
|
|
2021-05-09 16:51:44 +10:00
|
|
|
+ // CraftBukkit start - call projectile hit event
|
2024-04-24 01:15:00 +10:00
|
|
|
+ protected ProjectileDeflection preHitTargetOrDeflectSelf(MovingObjectPosition movingobjectposition) {
|
2021-05-09 16:51:44 +10:00
|
|
|
+ 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) {
|
2024-04-24 01:15:00 +10:00
|
|
|
+ return this.hitTargetOrDeflectSelf(movingobjectposition);
|
2021-05-09 16:51:44 +10:00
|
|
|
+ }
|
2024-04-24 01:15:00 +10:00
|
|
|
+ return ProjectileDeflection.NONE;
|
2021-05-09 16:51:44 +10:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2024-04-24 01:15:00 +10:00
|
|
|
protected ProjectileDeflection hitTargetOrDeflectSelf(MovingObjectPosition movingobjectposition) {
|
|
|
|
if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
|
|
|
|
MovingObjectPositionEntity movingobjectpositionentity = (MovingObjectPositionEntity) movingobjectposition;
|
|
|
|
@@ -225,6 +245,11 @@
|
2021-11-22 09:00:00 +11:00
|
|
|
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {}
|
2021-05-09 16:51:44 +10:00
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) {
|
2021-05-09 16:51:44 +10:00
|
|
|
+ // CraftBukkit start - cancellable hit event
|
|
|
|
+ if (hitCancelled) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2023-06-08 01:30:00 +10:00
|
|
|
IBlockData iblockdata = this.level().getBlockState(movingobjectpositionblock.getBlockPos());
|
2021-05-09 16:51:44 +10:00
|
|
|
|
2023-06-08 01:30:00 +10:00
|
|
|
iblockdata.onProjectileHit(this.level(), iblockdata, movingobjectpositionblock, this);
|