From 800d97bba3783e1d24ebed16b4b534dba56e48ac Mon Sep 17 00:00:00 2001 From: Mcayear Date: Sat, 6 Apr 2024 17:27:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20NPC=E7=9A=84=E5=9D=90=E6=A0=87=E9=A1=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20headYaw=20=E5=8F=82=E6=95=B0=20(#42)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../java/com/smallaswater/npc/data/RsNpcConfig.java | 10 ++++++++-- src/main/resources/Npc.yml | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7c15846..33f51a5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.smallaswater RsNPC - 2.4.4 + 2.4.5-SNAPSHOT RsNPC RsNPC -- NPC plugin for Nukkit diff --git a/src/main/java/com/smallaswater/npc/data/RsNpcConfig.java b/src/main/java/com/smallaswater/npc/data/RsNpcConfig.java index 605c5a8..2badba3 100644 --- a/src/main/java/com/smallaswater/npc/data/RsNpcConfig.java +++ b/src/main/java/com/smallaswater/npc/data/RsNpcConfig.java @@ -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) { @@ -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) { @@ -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)*/); } diff --git a/src/main/resources/Npc.yml b/src/main/resources/Npc.yml index b26309a..85c3480 100644 --- a/src/main/resources/Npc.yml +++ b/src/main/resources/Npc.yml @@ -8,6 +8,7 @@ nameTagAlwaysVisible: true y: 0 z: 0 yaw: 0.0 + headYaw: 0.0 level: "world" 手持: "267:0" 头部: ""