Invisible entity


Just a quick question, is there a way to set entity invisble for one player.
Something like: player.setinvisible(“myentity”) ?
Didn’t found anything about it on the forum and as I know spigot has this, just wanna know if this is simply not implemented yet.

This seems like it would need packets or something.

Invisible or “vanished”? there is a difference.

I want all players to be vanished (=invisible without particles) but still appearing in tab, for a single player or a group of players.

Apply invisibility potion without particles?

@DotDash You could do that but the invisibility effect will be seen (get it?) by all other players. I think K0yk want to choose who can see who. For instance, a player triggers a command which sets all other players invisible for this player (and only this one), like it’s done in some hubs.

It’d have to be done by packets that tells the client to despawn the target players. They still exist, but the client doesn’t know that. You can’t simply use an invisibility potion because it’ll still show those particle effects. All plugins with this functionality in bukkit used packets. I don’t think any 1.8 changes let us do it without.

So much mis-understanding in this thread.

k0yk has mentioned that they want them vanished.

Vanished is a state where players arn’t seen, make noise, make particles, and probably more to other players.

Talked to dev’s in IRC, SpongeAPI/ at 411037993587ae6f46a875198efe13c766b745a0 · SpongePowered/SpongeAPI · GitHub has data associated with whether a given entity is visible to another player, so it probably acts similarly to vanish.

1.8 has a feature where you can have potions without particles.

Regardless of whether it does, the effects remain where it purely only makes the player model invisible, without eliminating sound or other visuals like arrows stuck on players, armor worn, particle effects caused by players and etc.

1 Like

Or hitboxes.

Fact is any hacked client that gets sent any evidence of a player is going to show it. Player sounds could show up as particle effects or tracers. Invisible players will be visible etc.

Vanish != invisibility status effects, Why is this even still an argument.

1 Like

So I tried this code by following the given link, but this didn’t work:

public void OnBreakBlock(PlayerBreakBlockEvent event)
    Player player = (Player) event.getUser();
    player.getOrCreate(InvisibilityData.class).get().setInvisibleTo(player2, true);

DId I miss something?

Don’t cast Player to event.getUser() it already returns a player.

It’s likely not yet implemented.

You have to offer that data back, it won’t change by itself.

InvisibilityData invisibilityData= player.getOrCreate(InvisibilityData.class).get();
invisibilityData.setInvisibleTo(player2, true);
1 Like

If it seems verbose don’t worry, the values API is coming soon that will make the code a lot shorter.

Well still an error: “cannot be called on absent value”
Not implemented so ?

@K0yk That sounds like you aren’t using Optionals right.

“Cannot be called on an absent value” is something thats thrown when you try to get() from an Optional that doesn’t have anything. Make sure the value is present first using isPresent().

Well i’m sure the player is present, I send test message at same time. And the function getorcreate should get or create one, isn’t it ? ^^"