Spawn Mob That Is On Fire [Packets]

Discussion in 'Spigot Plugin Development' started by Jonnyo101, Aug 28, 2019.

  1. Hello i am trying to spawn a mob that is on fire for the player through packets.
    The mob is spawn fine with its item but is not on fire, Here is what i have tried.

    Code (Text):
    PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;

            EntityZombie entityZombie = new EntityZombie(((CraftWorld) location.getWorld()).getHandle());
            entityZombie.fireTicks = 20; //DOES NOT WORK
            entityZombie.setOnFire(20); // DOES NOT WORK

            PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(entityZombie);

            PacketPlayOutEntityEquipment equip = new PacketPlayOutEntityEquipment(entityZombie.getId(), EnumItemSlot.HEAD, CraftItemStack.asNMSCopy(ItemBuilder.I(material).Build()));

            PacketPlayOutEntityMetadata metadata = new PacketPlayOutEntityMetadata(entityZombie.getId(), entityZombie.getDataWatcher(), true);
            new Task(TaskType.SYNC, () -> {
                PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityZombie.getId());
            }, timeInTicks).Start();
    Using spigot 1.13.2
  2. Add on fire option in metadata (metadata wiki:
    Metadata possible change in 1.13.2 but you can try (I don't know what is metadata for 1.13.2)

    Try this:
    Code (Text):

    DataWatcher dw = entityZombie.getDataWatcher();

    dw.register(new DataWatcherObject<>(0, DataWatcherRegistry.a), (byte)1);

    PacketPlayOutEntityMetadata metadata = new PacketPlayOutEntityMetadata(entityZombie.getId(), dw, true);
    • Useful Useful x 1
  3. All i can think off is maybe casting the EntityLiving on the zombie

    What you have:
    Code (Text):
    PacketPlayOutSpawnEntityLiving spawnPacket = new PacketOutSpawnEntityLiving(entityZombie);
    Possible solution (not sure cause NMS are pretty difficult to find a reference for)
    Code (Text):
    PacketPlayOutSpawnEntityLiving spawnPacket = new PacketOutSpawnEntityLiving((EntityLiving) entityZombie);
    Rest looks good to me.
  4. O i just skipped right past that flag and didn't notice it
    Thanks got it working.