Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: NPC的坐标项添加 headYaw 参数 #42

Merged
merged 3 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading