mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 02:55:47 +01:00
c97ce029e9
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues. Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong. This is now resolved. Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me. Please as always, backup your worlds and test before updating to 1.16.2! If you update to 1.16.2, there is no going back to an older build than this. --------------------------------- Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com> Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com> Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com> Co-authored-by: stonar96 <minecraft.stonar96@gmail.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Jason <jasonpenilla2@me.com> Co-authored-by: kashike <kashike@vq.lc> Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: KennyTV <kennytv@t-online.de> Co-authored-by: commandblockguy <commandblockguy1@gmail.com> Co-authored-by: DigitalRegent <misterwener@gmail.com> Co-authored-by: ishland <ishlandmc@yeah.net>
94 lines
5.3 KiB
Diff
94 lines
5.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Techcable <Techcable@outlook.com>
|
|
Date: Fri, 16 Dec 2016 21:25:39 -0600
|
|
Subject: [PATCH] Add ProjectileCollideEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
|
index 2fb014c2a20363c94045dd834f771cfd9baf37cd..a7c475454e627e54d6771c5023144d55ad389ae3 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
|
@@ -160,6 +160,17 @@ public abstract class EntityArrow extends IProjectile {
|
|
}
|
|
}
|
|
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ // TODO: flag - noclip - call cancelled?
|
|
+ if (object instanceof MovingObjectPositionEntity) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, (MovingObjectPositionEntity)object);
|
|
+ if (event.isCancelled()) {
|
|
+ object = null;
|
|
+ movingobjectpositionentity = null;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
if (object != null && !flag) {
|
|
this.a((MovingObjectPosition) object);
|
|
this.impulse = true;
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
|
|
index d63b7b53da148ce404124115337e0dadf3357548..19aa9dab2509554417c2952eccd4ad5cb6008eda 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFireball.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
|
|
@@ -57,7 +57,16 @@ public abstract class EntityFireball extends IProjectile {
|
|
|
|
MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a);
|
|
|
|
- if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ if (movingobjectposition instanceof MovingObjectPositionEntity) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = CraftEventFactory.callProjectileCollideEvent(this, (MovingObjectPositionEntity)movingobjectposition);
|
|
+ if (event.isCancelled()) {
|
|
+ movingobjectposition = null;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
+ if (movingobjectposition != null && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { // Paper - add null check in case cancelled
|
|
this.a(movingobjectposition);
|
|
|
|
// CraftBukkit start - Fire ProjectileHitEvent
|
|
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
|
|
index 7391fd31148dbde60e34955841a296f454ac768e..53a8ea7d1eff84abe6c49464d556aa2788a6abcb 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
|
|
@@ -41,7 +41,17 @@ public abstract class EntityProjectile extends IProjectile {
|
|
}
|
|
|
|
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && !flag) {
|
|
+ // Paper start - Call ProjectileCollideEvent
|
|
+ if (movingobjectposition instanceof MovingObjectPositionEntity) {
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, (MovingObjectPositionEntity)movingobjectposition);
|
|
+ if (event.isCancelled()) {
|
|
+ movingobjectposition = null;
|
|
+ }
|
|
+ }
|
|
+ if (movingobjectposition != null) {
|
|
+ // Paper end
|
|
this.a(movingobjectposition);
|
|
+ } // Paper
|
|
}
|
|
|
|
this.checkBlockCollisions();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index a5ca8447b1e403b4ad13a03f9104388fd48d6c7e..dc8186b38930bf32f140a2da822cf359b6004a12 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1189,6 +1189,16 @@ public class CraftEventFactory {
|
|
return CraftItemStack.asNMSCopy(bitem);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public static com.destroystokyo.paper.event.entity.ProjectileCollideEvent callProjectileCollideEvent(Entity entity, MovingObjectPositionEntity position) {
|
|
+ Projectile projectile = (Projectile) entity.getBukkitEntity();
|
|
+ org.bukkit.entity.Entity collided = position.getEntity().getBukkitEntity();
|
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided);
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
+ return event;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public static ProjectileLaunchEvent callProjectileLaunchEvent(Entity entity) {
|
|
Projectile bukkitEntity = (Projectile) entity.getBukkitEntity();
|
|
ProjectileLaunchEvent event = new ProjectileLaunchEvent(bukkitEntity);
|