mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 02:22:12 +01:00
a929f0aff3
Changes the Interaction entity's trigger to use the vanilla generic damage source Fixes a couple places where the original damage and modified damage were passed in the reverse order to the advancement triggers
42 lines
1.9 KiB
Diff
42 lines
1.9 KiB
Diff
--- a/net/minecraft/world/entity/Interaction.java
|
|
+++ b/net/minecraft/world/entity/Interaction.java
|
|
@@ -27,6 +27,12 @@
|
|
import net.minecraft.world.phys.Vec3;
|
|
import org.slf4j.Logger;
|
|
|
|
+// CraftBukkit start
|
|
+import net.minecraft.world.damagesource.DamageSource;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.EntityDamageEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class Interaction extends Entity implements Attackable, Targeting {
|
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
@@ -65,7 +71,7 @@
|
|
this.setHeight(nbt.getFloat("height"));
|
|
}
|
|
|
|
- DataResult dataresult;
|
|
+ DataResult<com.mojang.datafixers.util.Pair<Interaction.PlayerAction, net.minecraft.nbt.Tag>> dataresult; // CraftBukkit - decompile error
|
|
Logger logger;
|
|
|
|
if (nbt.contains("attack")) {
|
|
@@ -145,9 +151,16 @@
|
|
@Override
|
|
public boolean skipAttackInteraction(Entity attacker) {
|
|
if (attacker instanceof Player entityhuman) {
|
|
+ // CraftBukkit start
|
|
+ DamageSource source = entityhuman.damageSources().playerAttack(entityhuman);
|
|
+ EntityDamageEvent event = CraftEventFactory.callNonLivingEntityDamageEvent(this, source, 1.0F, false);
|
|
+ if (event.isCancelled()) {
|
|
+ return true;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.attack = new Interaction.PlayerAction(entityhuman.getUUID(), this.level().getGameTime());
|
|
if (entityhuman instanceof ServerPlayer entityplayer) {
|
|
- CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, entityhuman.damageSources().generic(), 1.0F, 1.0F, false);
|
|
+ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, entityhuman.damageSources().generic(), 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit // Paper - use correct source and fix taken/dealt param order
|
|
}
|
|
|
|
return !this.getResponse();
|