I am using a net on my server that allows me to catch mobs and later retrieve them, but I ran into a problem: if I catch a cat or another mob that has multiple textures, after spawning, they don't retain their texture. I've been trying to figure out how to solve this issue for two days now.
Code:
function UseCatchingNet(player: player):
set {_target} to target entity of {_player}
set {_block} to target block of {_player}
# Проверка на сущность
if {_target} is a mob:
if {_target} is not a monster:
if distance between {_target} and {_player} > 5:
stop
if {_target} is ender dragon or iron golem or wither or warden or ghast or vindicator or armor stand:
stop
if metadata value "custom_mob" of {_target} is set:
stop
# Получаем NBT-данные из инструмента игрока
set {_nbt} to custom nbt of {_player}'s tool
# Проверяем наличие тега "mob"
set {_mob} to string tag "mob" of {_nbt}
# Сохраняем возраст как метаданные
if age of {_target} < 0:
set metadata value "baby_status" of {_target} to "baby"
if {_mob} is not set:
if difference between metadata value "catching_net_delay" of {_player} and now < 0.5 seconds:
stop
set metadata value "catching_net_delay" of {_player} to now
# Воспроизводим звуки
play sound "entity.player.attack.sweep" with volume 0.3 and pitch 1.5 at location of {_target}
play sound "entity.item.pickup" with volume 0.6 and pitch 1.5 at location of {_target}
# Эффект
draw 6 poof at location 1 meter above {_block} with offset vector(0, 0, 0) with extra 0.3
# Записываем данные в NBT
set string tag "mob" of {_nbt} to "%{_target}%"
set float tag "hp" of {_nbt} to health of {_target}
# Записываем статус baby
if metadata value "baby_status" of {_target} is "baby":
set string tag "is_baby" of {_nbt} to "true"
# Телепортация моба
teleport {_target} to location(x coordinate of {_target}, -100, z coordinate of {_target})
# Обновляем лор предмета игрока
set line 4 of lore of {_player}'s tool to "&fВнутри %capitalize(string tag "mob" of {_nbt})%"
set damage value of {_player}'s tool to damage value of {_player}'s tool + 2
stop
# Если цель не выбрана
if {_target} is not set:
if {_block} is set:
if distance between {_block} and {_player} > 5:
stop
# Получаем NBT-данные из инструмента игрока
set {_nbt} to custom nbt of {_player}'s tool
set {_mob} to string tag "mob" of {_nbt}
set {_hp} to float tag "hp" of {_nbt}
set {_is_baby} to string tag "is_baby" of {_nbt}
set {_mob} to {_mob} parsed as entitytype
if {_mob} is set:
if difference between metadata value "catching_net_delay" of {_player} and now < 0.5 seconds:
stop
set metadata value "catching_net_delay" of {_player} to now
# Воспроизводим звуки
play sound "entity.player.attack.sweep" with volume 0.2 and pitch 1.5 at {_block}
play sound "entity.item.pickup" with volume 0.6 and pitch 1.5 at {_block}
# Эффект
draw 3 poof at location 1 meter above {_block} with offset vector(0.2, 0.2, 0.2) with extra 0.01
# Создаем моба и устанавливаем возраст
spawn {_mob} at location 0.5 meter above {_block}
set {_spawned} to last spawned mob
# Если моб - младенец, устанавливаем возраст
if {_is_baby} is "true":
set age of {_spawned} to -24000
# Устанавливаем здоровье моба
set health of {_spawned} to {_hp}
# Удаляем теги
delete string tag "mob" of {_nbt}
delete float tag "hp" of {_nbt}
delete string tag "is_baby" of {_nbt}
# Обновляем лор предмета игрока
set line 4 of lore of {_player}'s tool to "&fПусто."
set damage value of {_player}'s tool to damage value of {_player}'s tool + 2