fix: sync with latest API change (#3169)

This commit is contained in:
ZX夏夜之风 2024-10-29 19:57:35 +08:00 committed by GitHub
parent 1579aa0e9e
commit 05ebf99d37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 5 deletions

View File

@ -399,7 +399,7 @@ public class CitizensNPC extends AbstractNPC {
if (type == EntityType.PLAYER || Util.isHorse(type)) { if (type == EntityType.PLAYER || Util.isHorse(type)) {
if (SUPPORT_ATTRIBUTES && !hasTrait(AttributeTrait.class) if (SUPPORT_ATTRIBUTES && !hasTrait(AttributeTrait.class)
|| !getTrait(AttributeTrait.class).hasAttribute(Attribute.GENERIC_STEP_HEIGHT)) { || !getTrait(AttributeTrait.class).hasAttribute(Attribute.STEP_HEIGHT)) {
NMS.setStepHeight(entity, 1); NMS.setStepHeight(entity, 1);
} }
} }

View File

@ -15,7 +15,7 @@ import net.citizensnpcs.api.trait.TraitName;
@TraitName("attributetrait") @TraitName("attributetrait")
public class AttributeTrait extends Trait { public class AttributeTrait extends Trait {
@Persist(keyType = Attribute.class) @Persist(keyType = Attribute.class)
private final Map<Attribute, Double> attributes = Maps.newEnumMap(Attribute.class); private final Map<Attribute, Double> attributes = Maps.newHashMap();
public AttributeTrait() { public AttributeTrait() {
super("attributetrait"); super("attributetrait");

View File

@ -918,7 +918,7 @@ public class HologramTrait extends Trait {
disp.setBackgroundColor(color); disp.setBackgroundColor(color);
} }
if (SpigotUtil.getVersion()[1] >= 21 && base.getEntity() instanceof LivingEntity) { if (SpigotUtil.getVersion()[1] >= 21 && base.getEntity() instanceof LivingEntity) {
AttributeInstance inst = ((LivingEntity) base.getEntity()).getAttribute(Attribute.GENERIC_SCALE); AttributeInstance inst = ((LivingEntity) base.getEntity()).getAttribute(Attribute.SCALE);
if (inst != null) { if (inst != null) {
Transformation tf = disp.getTransformation(); Transformation tf = disp.getTransformation();
tf.getScale().set(inst.getValue()); tf.getScale().set(inst.getValue());

View File

@ -143,7 +143,7 @@ public class BossBarTrait extends Trait {
double maxHealth = entity.getMaxHealth(); double maxHealth = entity.getMaxHealth();
if (SUPPORT_ATTRIBUTES) { if (SUPPORT_ATTRIBUTES) {
try { try {
maxHealth = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); maxHealth = entity.getAttribute(Attribute.MAX_HEALTH).getValue();
} catch (Throwable t) { } catch (Throwable t) {
SUPPORT_ATTRIBUTES = false; SUPPORT_ATTRIBUTES = false;
} }

View File

@ -130,7 +130,7 @@ public class NMS {
return; return;
if (SUPPORT_KNOCKBACK_RESISTANCE && npc.getEntity() instanceof Attributable) { if (SUPPORT_KNOCKBACK_RESISTANCE && npc.getEntity() instanceof Attributable) {
AttributeInstance attribute = ((Attributable) npc.getEntity()) AttributeInstance attribute = ((Attributable) npc.getEntity())
.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE); .getAttribute(Attribute.KNOCKBACK_RESISTANCE);
if (attribute != null) { if (attribute != null) {
strength *= 1 - attribute.getValue(); strength *= 1 - attribute.getValue();
} }