Invisible Mobs?

Discussion in 'Spigot Plugin Development' started by magicmq, Jun 17, 2015.

  1. Hello Spigot,

    I have a question regarding invisible mobs. Would it be possible to generate mobs (zombies, skeletons, creepers, etc.) and make them only visible to certain players? I do not think that this is possible, but if someone knows how it could be done, I am all ears, as I have no idea how I would go about doing this.

    Thanks Spigot.
     
  2. Should be possible with some packet magic - check out ProtocolLib
     
  3. I have no idea if this will actually work or not, but my first thought would be to try casting the zombie to a player instance, and using the showPlayer and hidePlayer methods. If this doesn't work, you're probably going to need to take the packet route for custom visibility...
     
  4. If I were to make mobs invisible to to some players, wouldn't that create other problems though? For example, the mobs would attack players that cannot see it, or the creeper explosion wouldn't be invisible to the respective players. Would it be possible to fix all of those underlying problems as well?
     
  5. Zombies aren't Players. Casting a Zombie to a Player would throw a ClassCastException.
    All those problems can be fixed as well, yes. You could cancel the EntityTargetEvent if the Zombie targets a Player that can't see the Zombie, for example.
     
    • Like Like x 2
  6. Alright, so I suppose I will be using ProtocolLib to cancel "Spawn Mob" packets, which are packets sent when mobs are spawned, according to http://wiki.vg/Protocol#Spawn_Mob. As long as I cancel the sending of those, will I need to worry about any other packet sending, such as Entity Status, Entity Look, Entity Status, etc.?

    Hopefully accomplishing this task is as simple as that and cancelling a few events. Thanks everyone for your help!
     
  7. the client will get them, find no mob, and give up on the packet :p. So sending them does not harm the client.
     
  8. Alright, thanks!