Creeper Loot - legopitstop/Record_API Wiki

Record API introduces a way to easily make your disc drop from a creeper that has been killed by a skeleton shooting a bow and arrow.

Give Function

Add the following line inside your give function. Note that your function must contain a /loot command to drop your music disc as an item.

scoreboard players add #total creeper_drop_music_disc 1

Example

# Handles the discs dropping from a creeper
scoreboard players add #total creeper_drop_music_disc 1

# Spawns the disc from loot_tables
loot spawn ~ ~ ~ loot example:item/music_disc_5

Function Tag

Add your give function from above to a tag/functions file. Location

<datapack>/data/record/tags/functions/creeper.json

Example

{
   "replace": false,
   "values": [
     "example:music_disc_5"
   ]
}

How does it work?

When a creeper gets killed by a skeleton with a bow it calls function #record:creeper which spawns all the items that have been added using this API (Including normal vanilla Minecraft discs). Using scoreboard players add #total creeper_drop_music_disc 1 to keep track of the total number of spawned disks, subtracting 1 at the end (Because we only want to drop one disc at a time). Then it slowly kills off one random item (using @r) each time it does this it removes one value from the scoreboard and repeats until one item is left giving you the resulting dropped item.

Cons

  • Could cause a lag spike when you have A LOT of custom music discs.
⚠️ **GitHub.com Fallback** ⚠️