Setting gamemode of Humans

I’ve always changed the gamemode of players by

player.offer(Keys.GAME_MODE, GameModes.GAMEMODE);

But I’ve tried this with human entities (that aren’t players) and their gamemode doesn’t seem to change. I’ve tried offering it before and after spawning them.

Just a guess here, but gamemodes could possibly purposefully not be implemented for Humans, but rather just Players. I can not guarantee that though. I’m curious though, what is your use case for this? Are you trying to protect the Human from damage?

Human entities are not meant to be Players. They don’t have Gamemodes, nor flight ability, or any of that.

Basically treat them like Zombies or Skeletons…the only difference is they just look like us.

5 Likes

So I should just listen to the interaction or damange event for the humans and just do it that way?

Yes, that would be appropriate.

How would you define gamemode on a Human? What makes the gamemodes different?

Humans should have GameModes, if we set them in creative it would avoid to cancel a damage event sent by the client, but the main point is : if I want to set them in spectator ? (with just a transparent head) Without GameModes I should send fake packets to achieve that (and use NMS)

An Human should have all properties of a Player since for the client it’s a Player.

3 Likes

No, that is not the goal of Human in SpongeAPI. They are NOT to have the attributes of a Player (beyond skin and arm swinging). They ARE NOT PLAYERS.

1 Like

Why do you want a transparent head?

Of course they are not Players but they appear as a Player to the client. I don’t need a transparent head but it was just an example, for personal use, I don’t care if Humans have GameModes or not, I was just thinking that someone may needs to attach attributes to an Human if he needs to modify the appearance.

Create new moments:notes: