|
2 | 2 |
|
3 | 3 | import com.github.retrooper.packetevents.PacketEventsAPI; |
4 | 4 | import com.github.retrooper.packetevents.protocol.world.Location; |
5 | | -import com.github.retrooper.packetevents.util.Vector3f; |
6 | 5 | import java.util.Map; |
7 | 6 | import java.util.UUID; |
8 | | -import java.util.concurrent.CompletableFuture; |
9 | 7 | import java.util.concurrent.ConcurrentHashMap; |
10 | 8 |
|
11 | 9 | import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityHeadLook; |
12 | 10 | import me.tofaa.entitylib.EntityLib; |
13 | | -import me.tofaa.entitylib.meta.display.AbstractDisplayMeta; |
14 | 11 | import me.tofaa.entitylib.movement.MovementEngine; |
15 | | -import me.tofaa.entitylib.movement.MovementEngine.MovementSettings; |
16 | | -import me.tofaa.entitylib.movement.MovementEngine.Path; |
17 | | -import me.tofaa.entitylib.movement.MovementEngine.PathfindSettings; |
18 | 12 | import me.tofaa.entitylib.movement.SpigotMovementEngine; |
19 | 13 | import me.tofaa.entitylib.npc.path.NPCPath; |
20 | | -import me.tofaa.entitylib.npc.NPCRegistry; |
21 | 14 | import org.bukkit.Bukkit; |
22 | 15 | import org.bukkit.Material; |
23 | 16 | import org.bukkit.World; |
24 | 17 | import org.bukkit.scheduler.BukkitTask; |
25 | 18 | import org.bukkit.entity.Player; |
26 | 19 | import org.jetbrains.annotations.NotNull; |
27 | | -import org.jetbrains.annotations.Nullable; |
28 | 20 |
|
29 | 21 | public class NPCMovement { |
30 | 22 |
|
@@ -166,26 +158,13 @@ private static void processAllNPCHeadRotation() { |
166 | 158 | yaw = npcLocation.getYaw(); |
167 | 159 | } |
168 | 160 | } else if (npc.getOptions().isLookAtPath()) { |
169 | | - yaw = npcLocation.getYaw(); |
| 161 | + // Gets handled by the movement itself |
| 162 | + continue; |
170 | 163 | } else { |
171 | 164 | continue; |
172 | 165 | } |
173 | 166 |
|
174 | | - PacketEventsAPI<?> api = EntityLib.getApi().getPacketEvents(); |
175 | | - for (UUID viewerId : entity.getViewers()) { |
176 | | - Player player = org.bukkit.Bukkit.getPlayer(viewerId); |
177 | | - if (player == null || player.getWorld() != world) continue; |
178 | | - |
179 | | - var headPacket = new com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityHeadLook( |
180 | | - entity.getEntityId(), |
181 | | - yaw |
182 | | - ); |
183 | | - |
184 | | - Object channel = api.getProtocolManager().getChannel(viewerId); |
185 | | - if (channel != null) { |
186 | | - api.getProtocolManager().sendPacket(channel, headPacket); |
187 | | - } |
188 | | - } |
| 167 | + entity.rotateHead(yaw, 0); |
189 | 168 | } |
190 | 169 | } |
191 | 170 |
|
@@ -227,19 +206,6 @@ private static void processPathFollowing() { |
227 | 206 | dy /= len; |
228 | 207 | dz /= len; |
229 | 208 |
|
230 | | - // float yaw = (float) Math.toDegrees(Math.atan2(dz, dx)); |
231 | | - float yaw = getYawTowards( |
232 | | - target, |
233 | | - new org.bukkit.Location( |
234 | | - null, |
235 | | - target.getX(), |
236 | | - target.getY(), |
237 | | - target.getZ(), |
238 | | - target.getYaw(), |
239 | | - target.getPitch() |
240 | | - ) |
241 | | - ); |
242 | | - |
243 | 209 | double newY = current.getY() + dy * speed; |
244 | 210 | double newX = current.getX() + dx * speed; |
245 | 211 | double newZ = current.getZ() + dz * speed; |
@@ -281,13 +247,13 @@ private static void processPathFollowing() { |
281 | 247 | newX, |
282 | 248 | newY, |
283 | 249 | newZ, |
284 | | - yaw, |
| 250 | + npc.getOptions().isLookAtPath() ? npc.getPath().getYaw() : current.getYaw(), |
285 | 251 | 0 |
286 | 252 | ); |
287 | 253 |
|
288 | 254 | entity.teleport(newLoc); |
289 | 255 |
|
290 | | - entity.rotateHead(yaw, 0); |
| 256 | + entity.rotateHead(npc.getPath().getYaw(), 0); |
291 | 257 | } |
292 | 258 | }); |
293 | 259 | } |
|
0 commit comments