Skip to content

Commit cc60aea

Browse files
committed
Fixed wrong NPC positions
1 parent e21b441 commit cc60aea

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.pascalpex</groupId>
88
<artifactId>PexNPC</artifactId>
9-
<version>1.22</version>
9+
<version>1.23</version>
1010
<packaging>jar</packaging>
1111

1212
<name>PexNPC</name>

src/main/java/net/pascalpex/npc/Main.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void onEnable() {
9595
NPC.addJoinPacket(player);
9696
}
9797
}
98-
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "PexNPC 1.22 von Pascalpex Aktiviert.");
98+
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "PexNPC 1.23 von Pascalpex Aktiviert.");
9999
}
100100

101101
private void fetchNewestVersion() {
@@ -131,7 +131,7 @@ public void onDisable() {
131131
}
132132
}
133133
this.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
134-
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "PexNPC 1.22 von Pascalpex Deaktiviert.");
134+
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "PexNPC 1.23 von Pascalpex Deaktiviert.");
135135
}
136136

137137
@Override
@@ -142,7 +142,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
142142
if (player.hasPermission("pexnpc.command")) {
143143

144144
if (args.length == 0) {
145-
player.sendMessage(prefix + "PexNPC 1.22 von Pascalpex");
145+
player.sendMessage(prefix + "PexNPC 1.23 von Pascalpex");
146146
player.sendMessage(prefix + "Verfügbare Befehle:");
147147
player.sendMessage(prefix + "/pexnpc help " + ChatColor.DARK_GRAY + "| " + ChatColor.GOLD + "Zeigt diese Seite an");
148148
player.sendMessage(prefix + "/pexnpc reload " + ChatColor.DARK_GRAY + "| " + ChatColor.GOLD + "Lädt die NPCs und Dateien neu");
@@ -159,7 +159,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
159159
}
160160
if (args.length == 1) {
161161
if (args[0].equalsIgnoreCase("help")) {
162-
player.sendMessage(prefix + "PexNPC 1.22 von Pascalpex");
162+
player.sendMessage(prefix + "PexNPC 1.23 von Pascalpex");
163163
player.sendMessage(prefix + "Verfügbare Befehle:");
164164
player.sendMessage(prefix + "/pexnpc help " + ChatColor.DARK_GRAY + "| " + ChatColor.GOLD + "Zeigt diese Seite an");
165165
player.sendMessage(prefix + "/pexnpc reload " + ChatColor.DARK_GRAY + "| " + ChatColor.GOLD + "Lädt die NPCs und Dateien neu");

src/main/java/net/pascalpex/npc/util/NPC.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.mojang.brigadier.LiteralMessage;
88
import com.mojang.datafixers.util.Pair;
99
import net.minecraft.Optionull;
10+
import net.minecraft.core.BlockPos;
1011
import net.minecraft.network.chat.ComponentUtils;
1112
import net.minecraft.network.chat.RemoteChatSession;
1213
import net.minecraft.network.protocol.game.*;
@@ -20,6 +21,7 @@
2021
import net.minecraft.server.level.ServerPlayer;
2122
import net.minecraft.server.network.ServerGamePacketListenerImpl;
2223
import net.minecraft.world.entity.EquipmentSlot;
24+
import net.minecraft.world.phys.Vec3;
2325
import net.minecraft.world.scores.PlayerTeam;
2426
import net.minecraft.world.scores.Scoreboard;
2527
import net.pascalpex.npc.Config;
@@ -231,7 +233,8 @@ public static void addNPCPacket(ServerPlayer npc, String suffix) {
231233
if (player.getWorld().equals(worldMap.get(npc.getId()))) {
232234
ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection;
233235
connection.send(createInitPacket(npc));
234-
connection.send(new ClientboundAddEntityPacket(npc, 0, npc.blockPosition()));
236+
Vec3 pos = npc.position();
237+
connection.send(new ClientboundAddEntityPacket(npc.getId(), npc.getUUID(), pos.x(), pos.y(), pos.z(), npc.getXRot(), npc.getYRot(), npc.getType(), 0, npc.getDeltaMovement(), npc.getYHeadRot()));
235238
connection.send(new ClientboundRotateHeadPacket(npc, (byte) (NpcData.getLocation(getID(npc)).getYaw() * 256f / 360f)));
236239
Scoreboard scoreboard = new Scoreboard();
237240
PlayerTeam team = new PlayerTeam(scoreboard, npc.getUUID().toString());
@@ -266,7 +269,8 @@ public static void addJoinPacket(Player player) {
266269
ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection;
267270
connection.send(createInitPacket(npc));
268271
connection.send(new ClientboundEntityEventPacket(npc, (byte) 1));
269-
connection.send(new ClientboundAddEntityPacket(npc, 0, npc.blockPosition()));
272+
Vec3 pos = npc.position();
273+
connection.send(new ClientboundAddEntityPacket(npc.getId(), npc.getUUID(), pos.x(), pos.y(), pos.z(), npc.getXRot(), npc.getYRot(), npc.getType(), 0, npc.getDeltaMovement(), npc.getYHeadRot()));
270274
connection.send(new ClientboundRotateHeadPacket(npc, (byte) (NpcData.getLocation(getID(npc)).getYaw() * 256f / 360f)));
271275
Scoreboard scoreboard = new Scoreboard();
272276
PlayerTeam team = new PlayerTeam(scoreboard, npc.getUUID().toString());

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
main: net.pascalpex.npc.Main
22
name: PexNPC
3-
version: 1.22
3+
version: 1.23
44
author: Pascalpex
55
prefix: PexNPC
66
softdepend:

0 commit comments

Comments
 (0)