fancynpcs: add turn_to_player_distance and center commands

Co-authored-by: Sadat Sahib <58975768+ssquadteam@users.noreply.github.com>
This commit is contained in:
Oliver
2025-03-29 19:27:17 +01:00
parent ef19a48bc5
commit c9fb39adcd
12 changed files with 228 additions and 14 deletions

View File

@@ -20,6 +20,14 @@ public interface FancyNpcsConfig {
int getNpcUpdateVisibilityInterval();
int getTurnToPlayerDistance();
/**
* Sets the distance at which NPCs turn to the player.
*
* @param distance The new distance value
* @return true if the distance was updated successfully, false otherwise
*/
boolean setTurnToPlayerDistance(int distance);
boolean isTurnToPlayerResetToInitialDirection();

View File

@@ -36,6 +36,7 @@ public class NpcData {
private Consumer<Player> onClick;
private Map<ActionTrigger, List<NpcAction.NpcActionData>> actions;
private boolean turnToPlayer;
private int turnToPlayerDistance = -1; // -1 means use the default from config
private float interactionCooldown;
private float scale;
private int visibilityDistance;
@@ -57,6 +58,7 @@ public class NpcData {
EntityType type,
Map<NpcEquipmentSlot, ItemStack> equipment,
boolean turnToPlayer,
int turnToPlayerDistance,
Consumer<Player> onClick,
Map<ActionTrigger, List<NpcAction.NpcActionData>> actions,
float interactionCooldown,
@@ -81,6 +83,7 @@ public class NpcData {
this.onClick = onClick;
this.actions = actions;
this.turnToPlayer = turnToPlayer;
this.turnToPlayerDistance = turnToPlayerDistance;
this.interactionCooldown = interactionCooldown;
this.scale = scale;
this.visibilityDistance = visibilityDistance;
@@ -108,6 +111,7 @@ public class NpcData {
};
this.actions = new ConcurrentHashMap<>();
this.turnToPlayer = false;
this.turnToPlayerDistance = -1; // Use default from config
this.interactionCooldown = 0;
this.scale = 1;
this.visibilityDistance = -1;
@@ -321,6 +325,27 @@ public class NpcData {
return this;
}
/**
* Gets the turn-to-player distance for this NPC.
*
* @return the custom distance value, or -1 if using the default from config
*/
public int getTurnToPlayerDistance() {
return turnToPlayerDistance;
}
/**
* Sets the turn-to-player distance for this NPC.
*
* @param distance the custom distance value, or -1 to use the default from config
* @return this NpcData instance for method chaining
*/
public NpcData setTurnToPlayerDistance(int distance) {
this.turnToPlayerDistance = distance;
isDirty = true;
return this;
}
public float getInteractionCooldown() {
return interactionCooldown;
}

View File

@@ -94,6 +94,7 @@ public class NpcModifyEvent extends Event implements Cancellable {
SHOW_IN_TAB,
SKIN,
TURN_TO_PLAYER,
TURN_TO_PLAYER_DISTANCE,
TYPE,
// Messages.
MESSAGE_ADD,