forked from BisUmTo/scarpet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvillagerleash.sc
28 lines (24 loc) · 884 Bytes
/
villagerleash.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
__config() -> {'stay_loaded' -> true, 'scope' -> 'global'};
__on_player_interacts_with_entity(player, entity, hand) -> (
if(player~'gamemode'=='spectator',return());
if(entity~'type' != 'villager',return());
if(player~'holds':0 != 'lead',
if(!player~'holds' && query(player,'holds','offhand'):0 == 'lead',
hand = 'offhand';
,
return();
);
,
hand = 'mainhand';
);
if(parse_nbt(entity~'nbt'):'Leash':'UUID',return());
__leash_to(player,entity);
if(player~'gamemode' != 'creative',
slot = if(hand=='mainhand',player~'selected_slot',-1);
prev = inventory_get(player,slot);
inventory_set(player,slot,(prev:1)-1,prev:0,prev:2);
);
);
__leash_to(player,entity) -> (
run(str('data modify entity %s Leash.UUID set from entity %s UUID',entity~'uuid',player~'uuid'));
);