Add combat tracker API (#11853)

This commit is contained in:
Illia Bondar
2025-04-30 20:24:33 +03:00
committed by GitHub
parent 646b80ca53
commit e663f99982
12 changed files with 546 additions and 0 deletions

View File

@@ -9,6 +9,9 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
import net.minecraft.Optionull;
import io.papermc.paper.world.damagesource.CombatTracker;
import io.papermc.paper.world.damagesource.PaperCombatTrackerWrapper;
import io.papermc.paper.world.damagesource.FallLocationType;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.protocol.game.ClientboundHurtAnimationPacket;
import net.minecraft.server.level.ServerLevel;
@@ -90,11 +93,15 @@ import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;
public class CraftLivingEntity extends CraftEntity implements LivingEntity {
private final PaperCombatTrackerWrapper combatTracker;
private CraftEntityEquipment equipment;
public CraftLivingEntity(final CraftServer server, final net.minecraft.world.entity.LivingEntity entity) {
super(server, entity);
this.combatTracker = new PaperCombatTrackerWrapper(entity.getCombatTracker());
if (entity instanceof Mob || entity instanceof ArmorStand) {
this.equipment = new CraftEntityEquipment(this);
}
@@ -1167,4 +1174,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public boolean canUseEquipmentSlot(org.bukkit.inventory.EquipmentSlot slot) {
return this.getHandle().canUseSlot(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot));
}
@Override
public CombatTracker getCombatTracker() {
return this.combatTracker;
}
}