[SOLVED] Sim-eth-es shows player twice


I tried the sim-eth-es and started to do a simple game with it, just to play with a multiplayer game. So far everything is fine. I now try to make myself familiar and I tried some things out. The first “bug” I found is that when you hit F2 you get the player list and you see two enities (in my case 64 and 65). I tried to find the root cause. The player list shows all entities with the component Name.class. The player and his ship do have this component, therefore in the player list you see your name twice. I now stared to add a new object type PLAYER. And on player creation I do

        public void login(String playerName) {
            ed.setComponents(player, new Name(playerName), ObjectTypes.playerType(ed));

In the PlayerListState I do

        this.players = ed.getEntities(ObjectType.class, Name.class);

But of course also the ship do have a ObjectType.class, so I wanted to use the Filter, but I have absolut no clue how I could do it as the type is an integer which is somehow build up with the Zay-ES (that part I did not completely understood yet).

I tried this:

        this.players = ed.getEntities(Filters.fieldEquals(ObjectType.class, "type",
                ed.getStrings().getStringId(ObjectTypes.PLAYER, true)),
                ObjectType.class, Name.class);

but I get an exception which tells me that this int to string map does not exist on the client side and can not be build on the client side, so I guess it only exist on the server side.

In the end I did an own loop over the player entity list go ObjectType from the endity and checked if it is ObjectTypes.PLAYER. But somehow it feels wrong :slight_smile:

Do you guys have any suggestions? Thanks a lot.


Have you tried to put all your ObjectTypes into an enum. You then can easily can ask for the relevant type like this:

ed.getEntities(new FieldFilter(ObjectType.class, "type", Type.Player), ObjectType.class, Name.class);

In this case Type would be the enum and ObjectType the component containing this enum as attribute.

Note: I am still beginner with Zay-ES but I hope this helps.


Yes true that was also my next idea. Point is that EntityData do “generate” this id out of your string, so I thought that this trickery is not needed. But it seems that only on server side this id to string map exists.
And maybe I better introduce a player component…


The map is available on the client but can only be MODIFIED on the server.

One of the pair, user or ship, has a reference to the other. (I can’t remember which.) For now, you could probably use the existence of that to determine if it’s a ship or a player.

Or create and add a UserId component.