SPIGOT-8016: Call knockback event for mace area knockback
This commit is contained in:
parent
3f33bb772b
commit
743e59541b
30
nms-patches/net/minecraft/world/item/MaceItem.patch
Normal file
30
nms-patches/net/minecraft/world/item/MaceItem.patch
Normal file
@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/world/item/MaceItem.java
|
||||
+++ b/net/minecraft/world/item/MaceItem.java
|
||||
@@ -27,6 +27,10 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.util.CraftVector;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class MaceItem extends Item {
|
||||
|
||||
private static final int DEFAULT_ATTACK_DAMAGE = 5;
|
||||
@@ -144,7 +148,15 @@
|
||||
Vec3D vec3d1 = vec3d.normalize().scale(d0);
|
||||
|
||||
if (d0 > 0.0D) {
|
||||
- entityliving.push(vec3d1.x, 0.699999988079071D, vec3d1.z);
|
||||
+ // entityliving.push(vec3d1.x, 0.699999988079071D, vec3d1.z); // CraftBukkit - moved below
|
||||
+ // CraftBukkit start - EntityKnockbackEvent
|
||||
+ Vec3D vec3dPush = new Vec3D(vec3d1.x, 0.699999988079071D, vec3d1.z);
|
||||
+ Vec3D result = entity.getDeltaMovement().add(vec3dPush);
|
||||
+ org.bukkit.event.entity.EntityKnockbackEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity(), entity1, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK, d0, result, vec3dPush.x, vec3dPush.y, vec3dPush.z);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ entityliving.push(CraftVector.toNMS(event.getFinalKnockback()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (entityliving instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) entityliving;
|
||||
|
@ -1959,9 +1959,9 @@ public class CraftEventFactory {
|
||||
|
||||
EntityKnockbackEvent event;
|
||||
if (attacker != null) {
|
||||
event = new EntityKnockbackByEntityEvent(entity, attacker.getBukkitEntity(), cause, force, new Vector(-raw.x, raw.y, -raw.z), new Vector(x, y, z));
|
||||
event = new EntityKnockbackByEntityEvent(entity, attacker.getBukkitEntity(), cause, force, bukkitRaw, new Vector(x, y, z));
|
||||
} else {
|
||||
event = new EntityKnockbackEvent(entity, cause, force, new Vector(-raw.x, raw.y, -raw.z), new Vector(x, y, z));
|
||||
event = new EntityKnockbackEvent(entity, cause, force, bukkitRaw, new Vector(x, y, z));
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user