0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 03:06:17 +00:00
craftbukkit/nms-patches/net/minecraft/world/entity/Interaction.patch
2024-10-23 02:15:00 +11:00

43 lines
1.9 KiB
Diff

--- a/net/minecraft/world/entity/Interaction.java
+++ b/net/minecraft/world/entity/Interaction.java
@@ -26,6 +26,12 @@
import net.minecraft.world.phys.AxisAlignedBB;
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();
@@ -64,7 +70,7 @@
this.setHeight(nbttagcompound.getFloat("height"));
}
- DataResult dataresult;
+ DataResult<com.mojang.datafixers.util.Pair<Interaction.PlayerAction, net.minecraft.nbt.NBTBase>> dataresult; // CraftBukkit - decompile error
Logger logger;
if (nbttagcompound.contains("attack")) {
@@ -144,9 +150,16 @@
@Override
public boolean skipAttackInteraction(Entity entity) {
if (entity instanceof EntityHuman 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 EntityPlayer entityplayer) {
- CriterionTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, entityhuman.damageSources().generic(), 1.0F, 1.0F, false);
+ CriterionTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, source, (float) event.getFinalDamage(), 1.0F, false); // CraftBukkit
}
return !this.getResponse();