#(lyamray) Give a NPC loot (like from a player inventory directly to an NPC)

7 messages · Page 1 of 1 (latest)

woeful spear
#

I've seen that you can give a NPC a loottable, but how does this work exactly?

    public void spawnNPC(Player player, ItemStack[] inventoryContent, ItemStack[] armorContent) {
        NPC npc = (NPC) CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, player.getName());

        LootTable lootTable =

        npc.getEquipment().setArmorContents(armorContent);
        npc.setLootTable(lootTable);
        npc.spawnAt(player.getLocation());
        npc.setHealth(20);
    }
}
regal fernBOT
#

(lyamray) Give a NPC loot (like from a player inventory directly to an NPC)

regal fernBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

bitter shale
#

@woeful spear if you want to do a loot table yourself you can just listen for NPCDeathEvent yourself and drop at that time

honest tokenBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@woeful spear