Skip to content

Commit

Permalink
feat: NPC的坐标项添加 headYaw 参数 (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mcayear authored Apr 6, 2024
1 parent de76e27 commit 800d97b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.smallaswater</groupId>
<artifactId>RsNPC</artifactId>
<version>2.4.4<!-- -SNAPSHOT--></version>
<version>2.4.5-SNAPSHOT</version>

<name>RsNPC</name>
<description>RsNPC -- NPC plugin for Nukkit</description>
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/smallaswater/npc/data/RsNpcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,17 @@ public RsNpcConfig(@NonNull String name, @NonNull Config config) throws RsNpcCon
if (level == null) {
throw new RsNpcLoadException("世界:" + this.levelName + " 不存在!无法加载当前世界的NPC");
}
double yaw = Utils.toDouble(map.getOrDefault("yaw", 0D));
if (!map.containsKey("headYaw")) {
map.put("headYaw", yaw);
}
this.location = new Location(
Utils.toDouble(map.get("x")),
Utils.toDouble(map.get("y")),
Utils.toDouble(map.get("z")),
Utils.toDouble(map.getOrDefault("yaw", 0D)),
yaw,
0,
Utils.toDouble(map.getOrDefault("headYaw", 0D)),
level
);
} catch (Exception e) {
Expand Down Expand Up @@ -298,6 +303,7 @@ public void save() {
map.put("y", this.location.getY());
map.put("z", this.location.getZ());
map.put("yaw", this.location.getYaw());
map.put("headYaw", this.location.getHeadYaw());
this.config.set("坐标", map);

if (this.itemData != null) {
Expand Down Expand Up @@ -380,7 +386,7 @@ public void checkEntity() {
this.entityRsNpc.setPosition(this.location);
}
if (!this.lookAtThePlayer) {
this.entityRsNpc.setRotation(this.location.yaw, this.location.pitch);
this.entityRsNpc.setRotation(this.location.yaw, this.location.pitch, this.location.headYaw);
}
this.entityRsNpc.setNameTag(this.showName /*VariableManage.stringReplace(null, this.showName, this)*/);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/Npc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ nameTagAlwaysVisible: true
y: 0
z: 0
yaw: 0.0
headYaw: 0.0
level: "world"
手持: "267:0"
头部: ""
Expand Down

0 comments on commit 800d97b

Please sign in to comment.