Use speedModifier in a few more places

This commit is contained in:
fullwall 2024-11-28 19:44:16 +08:00
parent 2773304f47
commit f8cc30d7f2
3 changed files with 8 additions and 6 deletions

View File

@ -264,7 +264,8 @@ public class CitizensNPC extends AbstractNPC {
if (destination == null) { if (destination == null) {
NMS.cancelMoveDestination(getEntity()); NMS.cancelMoveDestination(getEntity());
} else { } else {
NMS.setDestination(getEntity(), destination.getX(), destination.getY(), destination.getZ(), 1); NMS.setDestination(getEntity(), destination.getX(), destination.getY(), destination.getZ(),
getNavigator().getDefaultParameters().speedModifier());
} }
} }
@ -398,8 +399,9 @@ public class CitizensNPC extends AbstractNPC {
entity.setRemoveWhenFarAway(false); entity.setRemoveWhenFarAway(false);
if (type == EntityType.PLAYER || Util.isHorse(type)) { if (type == EntityType.PLAYER || Util.isHorse(type)) {
if (SUPPORT_ATTRIBUTES && !hasTrait(AttributeTrait.class) || !getTrait(AttributeTrait.class) if (SUPPORT_ATTRIBUTES && !hasTrait(AttributeTrait.class)
.hasAttribute(Util.getRegistryValue(Registry.ATTRIBUTE, "generic.step_height", "step_height"))) { || !getTrait(AttributeTrait.class).hasAttribute(Util
.getRegistryValue(Registry.ATTRIBUTE, "generic.step_height", "step_height"))) {
NMS.setStepHeight(entity, 1); NMS.setStepHeight(entity, 1);
} }
} }

View File

@ -20,7 +20,7 @@ import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.trait.trait.MobType; import net.citizensnpcs.api.trait.trait.MobType;
import net.citizensnpcs.api.trait.trait.Owner; import net.citizensnpcs.api.trait.trait.Owner;
import net.citizensnpcs.api.trait.trait.PlayerFilter; import net.citizensnpcs.api.trait.trait.PlayerFilter;
import net.citizensnpcs.api.trait.trait.Spawned; import net.citizensnpcs.api.trait.trait.Spawned;
import net.citizensnpcs.trait.Age; import net.citizensnpcs.trait.Age;
import net.citizensnpcs.trait.Anchors; import net.citizensnpcs.trait.Anchors;
import net.citizensnpcs.trait.ArmorStandTrait; import net.citizensnpcs.trait.ArmorStandTrait;
@ -106,7 +106,7 @@ public class CitizensTraitFactory implements TraitFactory {
registerTrait(TraitInfo.create(ItemFrameTrait.class)); registerTrait(TraitInfo.create(ItemFrameTrait.class));
registerTrait(TraitInfo.create(LookClose.class).optInToStats()); registerTrait(TraitInfo.create(LookClose.class).optInToStats());
registerTrait(TraitInfo.create(PaintingTrait.class)); registerTrait(TraitInfo.create(PaintingTrait.class));
registerTrait(TraitInfo.create(MirrorTrait.class).optInToStats()); registerTrait(TraitInfo.create(MirrorTrait.class).optInToStats());
registerTrait(TraitInfo.create(MountTrait.class)); registerTrait(TraitInfo.create(MountTrait.class));
registerTrait(TraitInfo.create(MobType.class).asDefaultTrait()); registerTrait(TraitInfo.create(MobType.class).asDefaultTrait());
registerTrait(TraitInfo.create(OcelotModifiers.class)); registerTrait(TraitInfo.create(OcelotModifiers.class));

View File

@ -115,7 +115,7 @@ public class StraightLineNavigationStrategy extends AbstractPathStrategy {
} }
} else if (npc.getEntity() instanceof LivingEntity) { } else if (npc.getEntity() instanceof LivingEntity) {
NMS.setDestination(npc.getEntity(), destVector.getX(), destVector.getY(), destVector.getZ(), NMS.setDestination(npc.getEntity(), destVector.getX(), destVector.getY(), destVector.getZ(),
params.speed()); params.speedModifier());
} else { } else {
Vector dir = destVector.subtract(currLoc.toVector()).normalize().multiply(0.2); Vector dir = destVector.subtract(currLoc.toVector()).normalize().multiply(0.2);
Block in = currLoc.getBlock(); Block in = currLoc.getBlock();