Skip to content

Instantly share code, notes, and snippets.

@Aresiel
Created March 4, 2025 00:27
Show Gist options
  • Save Aresiel/c7c951de694fa92bdc1bbb47387180c4 to your computer and use it in GitHub Desktop.
Save Aresiel/c7c951de694fa92bdc1bbb47387180c4 to your computer and use it in GitHub Desktop.
A Skript to enable carrying mobs. Carry a mob by shift-clicking it with a lead, click to place it down again or punch to throw it. See what happens if you try to carry another while you're already carrying one :3
function CARRYMOBapplyEffect(e: entity, effect: potioneffecttype, min_tier: number, duration: timespan):
set {_flag} to false
loop potion effects of {_e}:
type of loop-value is {_effect}
set {_duration} to {_duration} - (potion duration of loop-value)
{_duration} > 0 seconds
potion tier of loop-value > {_min_tier}
set {_flag} to true
if {_flag} is true:
stop
apply potion of {_effect} of tier {_min_tier} without any particles whilst hiding the potion icon to {_e} for {_duration}
function CARRYMOBremoveEffect(e: entity, effect: potioneffecttype, max_tier: number, max_duration: timespan):
set {_flag} to true
loop potion effects of {_e}:
type of loop-value is {_effect}
(potion tier of loop-value) <= {_max_tier}
(potion duration of loop-value) <= {_max_duration}
set {_flag} to false
if {_flag} is true:
stop
remove {_effect} from {_e}
function CARRYMOBplaceEntity(e: entity, l: location):
if passengers of {_e} is set:
loop passengers of {_e}:
CARRYMOBplaceEntity(loop-entity, {_l})
teleport {_e} to {_l}
make loop-entity ride {_e}
else:
teleport {_e} to {_l}
CARRYMOBremoveEffect({_e}, resistance, 255, 2 seconds)
function CARRYMOBplacePassengers(p: player, l: location):
loop passengers of {_p}:
CARRYMOBplaceEntity(loop-entity, {_l})
CARRYMOBremoveEffect({_p}, slowness, 2, 2 seconds)
CARRYMOBremoveEffect({_p}, hunger, 1, 2 seconds)
function CARRYMOBtransferPassengers(orig: entity, new: entity):
set passengers of {_new} to passengers of {_orig}
CARRYMOBremoveEffect({_orig}, slowness, 2, 2 seconds)
CARRYMOBremoveEffect({_orig}, hunger, 1, 2 seconds)
function CARRYMOBpickupEntity(carried: entity, carrying: entity):
make {_carried} ride {_carrying}
CARRYMOBapplyEffect({_carrying}, slowness, 2, 2 seconds)
CARRYMOBapplyEffect({_carrying}, hunger, 1, 2 seconds)
CARRYMOBapplyEffect({_carried}, resistance, 255, 2 seconds)
every second:
loop all players:
if passengers of loop-player is set:
CARRYMOBapplyEffect(loop-player, slowness, 2, 2 seconds)
CARRYMOBapplyEffect(loop-player, hunger, 1, 2 seconds)
loop passengers of loop-player:
CARRYMOBapplyEffect(loop-value-2, resistance, 255, 2 seconds)
on rightclick holding a lead: # Place
passengers of the player is set
if event-block is set:
CARRYMOBplacePassengers(player, location of event-block ~ vector 0, 1, 0)
cancel event
else if the entity is set:
CARRYMOBtransferPassengers(player, the entity)
cancel event
on damage of an entity by a player:
if passengers of the attacker contains the victim:
cancel event
on leftclick holding a lead: # Throw
passengers of the player is set
cancel event
set food level of the player to (food level of the player) - 1
loop passenger of the player:
CARRYMOBplaceEntity(loop-entity, location of the player ~ vector 0, 1, 0)
if loop-entity is a player:
send actionbar "Sorry, throwing players unfortunately isn't supported. Please contact §dLeisera§r or §dYuna§r if you know how to push a player with Skript. §c<3§r" to the player
else:
push loop-entity in direction of the player with velocity 0.8
on rightclick holding a lead on an entity: # Pickup
player is sneaking
cancel event
CARRYMOBpickupEntity(the entity, the player)
on player tool change:
passengers of the player is set
CARRYMOBplacePassengers(player, location of player)
on player drop of a lead:
passengers of the player is set
CARRYMOBplacePassengers(player, location of player)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment