zvxcusersd

Develop a Minecraft datapack that grants players a stack of random items every 60 seconds. Include customization options for the item pool, the ability to toggle the feature on or off, and a configurable cooldown time. Ensure that the items received are balanced and relevant to the game mode, with a notification message displayed to the player upon receiving the items.

Kodari AI
KodariMay 14 at 1:53 pm 15,855 (v2)

The user is asking for a Minecraft datapack, not a Fabric mod. Datapacks use pure JSON/mcfunction files β€” no Java required. Let me plan this out carefully:

  • Scoreboard objectives for cooldown tracking and toggle state

  • Functions for the main timer loop, item distribution, and commands

  • A configurable item pool using loot tables

  • Commands to toggle on/off and set cooldown

  • Tick-based scheduling using schedule or a repeating function

RandomItemDropDatapack
A Minecraft 1.21.4 datapack that grants players a stack of random items every 60 seconds (configurable). Features a curated item pool balanced for survival gameplay, admin commands to toggle the feature on/off per-world, and a /randomdrops command to adjust the cooldown interval. Players receive a chat notification when items are granted. All configuration is managed via in-game commands and persistent scoreboards.

Here’s the full plan:

  • Scoreboards: rd_timer (per-player countdown), rd_enabled (global toggle, stored on a fake player), rd_cooldown (global cooldown value in seconds)

  • Loot table: A weighted pool of balanced survival items

  • Functions: load, tick, give_items, notify, and command handlers

  • Advancement trigger: Used to run load on world load

  • /randomdrops command: Subcommands on, off, cooldown <seconds>

Now the loot table β€” a weighted pool of balanced survival items, each entry gives a stack (count 16–64 depending on item value):

Now the advancement to auto-run load on world load, and the tick tag to run tick every game tick:


Here’s a summary of everything created:

πŸ“¦ RandomItemDropDatapack

File Structure

Plain Text
pack.mcmeta
data/
  minecraft/tags/function/
    load.json          ← runs randomdrops:load on world load
    tick.json          ← runs randomdrops:tick every game tick
  randomdrops/
    function/
      load.mcfunction           ← initializes scoreboards & defaults
      tick.mcfunction           ← entry point, checks enabled flag
      tick_enabled.mcfunction   ← increments timers, triggers drops
      give_and_reset.mcfunction ← gives loot + notifies player
      cmd/
        help.mcfunction         ← lists all commands
        on.mcfunction           ← enable drops globally
        off.mcfunction          ← disable drops globally
        status.mcfunction       ← show state + your timer progress
        cooldown_30/60/120/300.mcfunction
        reset_timers.mcfunction
    loot_table/
      random_items.json         ← 20 weighted items, balanced for survival

How to Use

Action
Command
Enable drops
/function randomdrops:cmd/on
Disable drops
/function randomdrops:cmd/off
Set 30s cooldown
/function randomdrops:cmd/cooldown_30
Set 60s cooldown (default)
/function randomdrops:cmd/cooldown_60
Set 2min cooldown
/function randomdrops:cmd/cooldown_120
Set 5min cooldown
/function randomdrops:cmd/cooldown_300
Check status
/function randomdrops:cmd/status
Reset all timers
/function randomdrops:cmd/reset_timers

Item Pool (20 items, weighted)

  • Common (weight 10–12): Oak logs, cobblestone, torches, coal, bread

  • Uncommon (weight 6–8): Iron ingots, arrows, string, gunpowder, bone meal, seeds, sugar cane, leather, cooked beef

  • Rare (weight 3–5): Gold ingots, emeralds, ender pearls, XP bottles

  • Very Rare (weight 2): Diamonds, TNT

Kodari can make mistakes. Review important code before using.
Files
data
pack.mcmeta
Code
18 253
data/randomdrops/function/cmd/help.mcfunction
tellraw @s [{"text":"--- RandomDrops Commands ---","color":"gold","bold":true}]
tellraw @s [{"text":"/function randomdrops:cmd/on","color":"aqua"},{"text":" β€” Enable random drops","color":"white"}]
tellraw @s [{"text":"/function randomdrops:cmd/off","color":"aqua"},{"text":" β€” Disable random drops","color":"white"}]
tellraw @s [{"text":"/function randomdrops:cmd/status","color":"aqua"},{"text":" β€” Show current status","color":"white"}]
tellraw @s [{"text":"/function randomdrops:cmd/cooldown_30","color":"aqua"},{"text":" β€” Set cooldown to 30s","color":"white"}]
tellraw @s [{"text":"/function randomdrops:cmd/cooldown_60","color":"aqua"},{"text":" β€” Set cooldown to 60s (default)","color":"white"}]
tellraw @s [{"text":"/function randomdrops:cmd/cooldown_120","color":"aqua"},{"text":" β€” Set cooldown to 120s","color":"white"}]
tellraw @s [{"text":"/function randomdrops:cmd/cooldown_300","color":"aqua"},{"text":" β€” Set cooldown to 300s","color":"white"}]
tellraw @s [{"text":"/function randomdrops:cmd/reset_timers","color":"aqua"},{"text":" β€” Reset all player timers","color":"white"}]