2022-11-10 04:05:58 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
|
|
Date: Sun, 18 Sep 2022 13:10:18 -0400
|
|
|
|
Subject: [PATCH] Add PrePlayerAttackEntityEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
2024-07-06 21:19:14 +02:00
|
|
|
index fab56040ecf496e74f583ec5d6c6c9861cfa4e13..ad334f149fe1b44d4ebe48489dcd2811ff1b5cd0 100644
|
2022-11-10 04:05:58 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
2024-07-06 21:19:14 +02:00
|
|
|
@@ -1257,8 +1257,17 @@ public abstract class Player extends LivingEntity {
|
2022-11-10 04:05:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void attack(Entity target) {
|
|
|
|
- if (target.isAttackable()) {
|
|
|
|
- if (!target.skipAttackInteraction(this)) {
|
|
|
|
+ // Paper start - PlayerAttackEntityEvent
|
|
|
|
+ boolean willAttack = target.isAttackable() && !target.skipAttackInteraction(this); // Vanilla logic
|
|
|
|
+ io.papermc.paper.event.player.PrePlayerAttackEntityEvent playerAttackEntityEvent = new io.papermc.paper.event.player.PrePlayerAttackEntityEvent(
|
|
|
|
+ (org.bukkit.entity.Player) this.getBukkitEntity(),
|
|
|
|
+ target.getBukkitEntity(),
|
|
|
|
+ willAttack
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable.
|
|
|
|
+ {
|
2024-01-16 12:41:40 +01:00
|
|
|
+ // Paper end - PlayerAttackEntityEvent
|
2024-06-14 03:30:23 +02:00
|
|
|
float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE);
|
|
|
|
ItemStack itemstack = this.getWeaponItem();
|
|
|
|
DamageSource damagesource = this.damageSources().playerAttack(this);
|