style: ignore to control the same entity
@@ -2,8 +2,8 @@ package nullengine.player;
import nullengine.Platform;
import nullengine.entity.Entity;
-import nullengine.server.network.NetworkHandler;
import nullengine.event.player.PlayerControlEntityEvent;
+import nullengine.server.network.NetworkHandler;
import nullengine.world.World;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -52,6 +52,10 @@ public class PlayerImpl implements Player {
@NonNull
@Override
public Entity controlEntity(@Nonnull Entity entity) {
+ if (controlledEntity == entity) {
+ return controlledEntity;
+ }
+
var old = controlledEntity;
var event = new PlayerControlEntityEvent.Pre(this, old, entity);
if (Platform.getEngine().getEventBus().post(event)) {
