📄
pasted-code-1790816176944.txt
txt
20 lines
▶
Act as an expert Minecraft Skript developer. Write a clean, optimized, and error-free Skript (.sk) for a "Safari Net" system on a Paper/Spigot server.
Core Mechanics:
1. The Safari Net item should be a Ghast Tear named "&d&lSafari Net" with the lore "&7Left-click a mob to capture it!" when empty.
2. Capturing a mob:
- When a player left-clicks any living mob with an empty Safari Net, cancel the event.
- Store the mob's type (and attributes like name, health, color, or age if possible) inside the item's NBT or data.
- Delete/remove the mob from the world.
- Change the Safari Net item's lore to show the captured mob's name, e.g., "&7Contains: &e[Mob Type]".
3. Releasing a mob:
- When a player left-clicks the ground (or blocks) with a full Safari Net, cancel the event.
- Spawn the stored mob type at the clicked location.
- Reset the Safari Net item back to being empty (change name/lore back to original).
Strict Requirements:
- Use left-click for BOTH capturing (on a mob) and releasing (on a block).
- Ensure it prevents players from capturing blacklisted mobs like the Ender Dragon or Wither.
- Handle item stacking carefully: if a player has a stack of Safari Nets, capturing a mob should only consume ONE net and give them one full net back (to prevent losing items).
- Use modern Skript syntax compatible with Minecraft 1.20+.
- Do not include any external text or explanations, just give me the pure Skript code.
options: safari-net-name: &d&lSafari Net safari-net-empty-lore: &7Left-click a mob to capture it!
on damage of living entity: if attacker is not a player: stop if attacker’s tool is not a ghast tear: stop if name of attacker’s tool is not “{@safari-net-name}”: stop if lore of attacker’s tool does not contain “{@safari-net-empty-lore}”: stop
cancel event
if victim is a player:
send "&cYou cannot capture players." to attacker
stop
if type of victim is ender dragon or type of victim is wither:
send "&cYou cannot capture that mob." to attacker
stop
set {_mobType} to "%type of victim%"
set {_fullNet} to ghast tear named "{@safari-net-name}"
set lore of {_fullNet} to "&7Contains: &e%{_mobType}%" and "&0SafariType:%{_mobType}%"
if amount of attacker's tool is greater than 1:
if attacker cannot hold {_fullNet}:
send "&cMake room in your inventory before capturing a mob." to attacker
stop
delete victim
if amount of attacker's tool is greater than 1:
remove 1 from attacker's tool
give {_fullNet} to attacker
else:
set attacker's tool to {_fullNet}
on left click on block: if player’s tool is not a ghast tear: stop if name of player’s tool is not “{@safari-net-name}”: stop if lore of player’s tool contains “{@safari-net-empty-lore}”: stop
set {_mobTypeText} to ""
loop lore of player's tool:
set {_line} to uncolored loop-value
if {_line} starts with "SafariType:":
replace "SafariType:" with "" in {_line}
set {_mobTypeText} to {_line}
if {_mobTypeText} is "":
stop
set {_mobType} to {_mobTypeText} parsed as entity type
if {_mobType} is not set:
cancel event
send "&cThis Safari Net contains invalid mob data." to player
stop
set {_emptyNet} to ghast tear named "{@safari-net-name}"
set lore of {_emptyNet} to "{@safari-net-empty-lore}"
if amount of player's tool is greater than 1:
if player cannot hold {_emptyNet}:
cancel event
send "&cMake room in your inventory before releasing a mob." to player
stop
cancel event
set {_spawnLocation} to location of clicked block
add 1 to y-coordinate of {_spawnLocation}
spawn 1 of {_mobType} at {_spawnLocation}
if amount of player's tool is greater than 1:
remove 1 from player's tool
give {_emptyNet} to player
else:
set player's tool to {_emptyNet}
add it all into 1 code
options: safari-net-name: &d&lSafari Net safari-net-empty-lore: &7Left-click a mob to capture it!
command /safarinet: permission: safarinet.give trigger: set {_net} to ghast tear named “{@safari-net-name}” set lore of {_net} to “{@safari-net-empty-lore}” give {_net} to player send “&aYou received a Safari Net.” to player
on damage of living entity: if attacker is not a player: stop if attacker’s tool is not a ghast tear: stop if name of attacker’s tool is not “{@safari-net-name}”: stop if lore of attacker’s tool does not contain “{@safari-net-empty-lore}”: stop
cancel event
if victim is a player:
send "&cYou cannot capture players." to attacker
stop
if type of victim is ender dragon or type of victim is wither:
send "&cYou cannot capture that mob." to attacker
stop
set {_mobType} to "%type of victim%"
set {_mobName} to custom name of victim
set {_mobHealth} to health of victim
add 1 to {safari::next-id}
set {_id} to {safari::next-id}
set {safari::%{_id}%::type} to {_mobType}
set {safari::%{_id}%::health} to {_mobHealth}
if {_mobName} is set:
set {safari::%{_id}%::name} to {_mobName}
set {_fullNet} to ghast tear named "{@safari-net-name}"
set lore of {_fullNet} to "&7Contains: &e%{_mobType}%" and "&0SafariNet:%{_id}%"
if amount of attacker's tool is greater than 1:
if attacker cannot hold {_fullNet}:
delete {safari::%{_id}%::*}
send "&cMake room in your inventory before capturing a mob." to attacker
stop
set amount of attacker's tool to (amount of attacker's tool - 1)
give {_fullNet} to attacker
else:
set attacker's tool to {_fullNet}
delete victim
on left click on block: if player’s tool is not a ghast tear: stop if name of player’s tool is not “{@safari-net-name}”: stop if lore of player’s tool contains “{@safari-net-empty-lore}”: stop
cancel event
set {_id} to 0
loop lore of player's tool:
set {_line} to uncolored loop-value
if {_line} starts with "SafariNet:":
replace "SafariNet:" with "" in {_line}
set {_id} to {_line} parsed as integer
if {_id} is not set:
send "&cThis Safari Net contains invalid mob data." to player
stop
if {safari::%{_id}%::type} is not set:
send "&cThis Safari Net contains invalid mob data." to player
stop
set {_mobType} to {safari::%{_id}%::type} parsed as entity type
if {_mobType} is not set:
send "&cThis Safari Net contains an unsupported mob type." to player
stop
set {_emptyNet} to ghast tear named "{@safari-net-name}"
set lore of {_emptyNet} to "{@safari-net-empty-lore}"
if amount of player's tool is greater than 1:
if player cannot hold {_emptyNet}:
send "&cMake room in your inventory before releasing a mob." to player
stop
set {_spawnLocation} to location of clicked block
add 1 to y-coordinate of {_spawnLocation}
spawn 1 of {_mobType} at {_spawnLocation}
set {_releasedMob} to last spawned entity
if {safari::%{_id}%::name} is set:
set custom name of {_releasedMob} to {safari::%{_id}%::name}
if {safari::%{_id}%::health} is set:
set health of {_releasedMob} to {safari::%{_id}%::health}
delete {safari::%{_id}%::*}
if amount of player's tool is greater than 1:
set amount of player's tool to (amount of player's tool - 1)
give {_emptyNet} to player
else:
set player's tool to {_emptyNet}
No files in this session