promotional bannermobile promotional banner

Better Give

Better Give an Better Give
Project Animation

Welcome To Criptonain Industries
by Cript0 panda

1. Command Trigger & Input Parsing
The script listens for a specific in-game script event ID: my:give.
When it detects this event, it splits the message string by spaces to capture the core parameters. The expected format is:
/scriptevent my:give <newItem> <targetPlayer|myself> <amount|objective|none> [Custom Properties]
  • newItem: The Minecraft item namespace ID (e.g., minecraft:diamond_sword).
  • targetPlayer|myself: The username of the player receiving the item, or the word myself to target the player running the command.
  • amount|objective|none: A static number, a scoreboard objective name, or none (defaults to 1).
  • [Custom Properties]: An optional string separated by vertical pipes (|) used to modify the item's metadata.

2. Targeting and Scoreboard Logic
The script runs checks to locate the correct player and calculate the exact item quantity:
  • Target Selection: If the argument isn't myself, it searches all active players in the world for an exact case-insensitive name match. If the player isn't found, the script safely stops.
  • Dynamic Quantity: If a scoreboard objective name is passed instead of a number, the script looks up that specific objective and checks the target player's current score. It uses that score as the item amount.
  • Safety Clamping: No matter what number is generated, the code clamps the final item amount between 1 and 64 to prevent logic crashes caused by negative numbers or oversized item stacks.

3. Smart Delivery System
Before giving the item, the script handles inventory safety:
  • It attempts to neatly insert the item stack directly into the player's primary inventory container.
  • Overflow Protection: If the player's inventory is full, inventory.addItem() returns the remaining items. The script catches this and spawns the item stack on the ground directly at the player's feet (dimension.spawnItem) so the item is never lost.

4. Custom Property Factory (applyCustomProperties)
If extra text arguments are provided after the core parameters, they are handled by a secondary function. It splits the remaining text by a pipe (|) symbol to configure advanced item traits in a strict order:
Position Property Behavior Example Input
1 Name Changes the display name of the item. Excalibur
2 Lore Adds description text lines. Supports \n for new lines. Line 1\nLine 2
3 Keep If set to true, the player keeps this item when they die. true
4 Lock Restricts item movement. Can be locked to a specific slot or the entire inventory. slot
5 Place Defines which blocks this item can be placed on (Adventure mode). minecraft:stone,minecraft:dirt
6 Destroy Defines which blocks this item can break (Adventure mode). minecraft:obsidian
7 Enchants Applies enchantments using a type:level comma-separated list. sharpness:5,unbreaking:3

Example In-Game Usage
To give yourself a custom diamond sword using this script, you would run a command like this in the chat console:
/scriptevent my:give minecraft:diamond_sword myself 1 God Sword | Slays monsters.\nVery shiny.|true|none|none|none|sharpness:5,unbreaking:3

DO NOT PUT SPACES!!! WHEN Sepreating args Excluding 

 
(<newItem>)
 

INCORRECT:

 

| true | slot | minecraft:dirt, minecraft:grass | minecraft:gold_block, minecraft:diamond_block | sharpness:3, unbreaking:3

 

CORRECT:

 

|true|slot|minecraft:dirt,minecraft:grass|minecraft:gold_block,minecraft:diamond_block|sharpness:3,unbreaking:3

 

The Better Give Team

profile avatar
  • 2
    Followers
  • 14
    Projects
  • 272
    Downloads

More from cript0pandaView all