1.15.2 How to get client-side glowing entities

Discussion in 'Spigot Plugin Development' started by FullPotato, Jan 19, 2020.

  1. So I've been trying to make a plugin that gives certain players abilities like Xray where they can see other players, entities and ores through walls.
    I'm starting with the ores. For the ores, my plan is to make fake glowing slimes using ProtocolLib packets and plant them in the blocks.
    Here's my testing code (that's just supposed to spawn a slime right where the player is right now)

    Code (Java):
    ProtocolManager manager = ProtocolLibrary.getProtocolManager();
    PacketContainer slime_spawn = manager.createPacket(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
    slime_spawn.getIntegers().write(0, slime_id).write(1, (int) EntityType.SLIME.getTypeId()); //doesn't spawn a slime
    slime_spawn.getUUIDs().write(0, UUID.randomUUID());
    slime_spawn.getDoubles().write(0, x).write(1, y).write(2, z);
    slime_id--;

    PacketContainer slime_meta = manager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
    //what to put here?

    manager.sendServerPacket(event.getPlayer(), slime_spawn);
    manager.sendServerPacket(event.getPlayer(), slime_meta);
    When I run this code, it spawns a pig instead of a slime for some reason. Also I have no idea where to go from here (how to set the slime's size and make it glowing). Are there any resources I can read up on on how to do this, or am I doing something completely wrong? (this is my first time using ProtocolLib)
     
  2. What is slime_id? As it could be due to that variable for it spawning a pig
     
  3. that's just the ID of entity (as someone explained to me). they said that the first entity in the world has id 1, and so on, and that it's separate from the actual type ID. so, i put it at Integer.MAX_VALUE (2147483647) to start and decrement it after every spawn as to not interfere with pre-existing mobs

    i know the line that changes entity type is definitely
    Code (Text):
    slime_spawn.getIntegers().write(0, slime_id).write(1, (int) EntityType.SLIME.getTypeId());
    because when i change EntityType.SLIME.getTypeId() to different entities, it changes, but not to the right entity. for example, i put in COW, and it spawned a wither skeleton, if i recall correctly