mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
89d51d5f29
Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable. It should be noted that this decision does not promise all future exploits will be configurable.
31 lines
1.5 KiB
Diff
31 lines
1.5 KiB
Diff
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
|
|
index 7c0db708575ef26a1dd73709bf22653f21e0c863..262cefa51856cf6a58ae3b80b1ae93a5dd7bfaa7 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -1234,8 +1234,17 @@ public abstract class Player extends LivingEntity {
|
|
}
|
|
|
|
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.
|
|
+ {
|
|
+ // Paper end - PlayerAttackEntityEvent
|
|
float f = (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE);
|
|
float f1;
|
|
|