I need help on how to preserve the color of a mob after it spawns from an item.

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Monitor

Member
Jan 31, 2025
1
0
1
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.

image.png


image.png



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
 
Save string tag "variant" too. It defines the texture of entity you wanna save.

Your code is a bit complicated. Contact me on Discord if you still have a problem with that.

Discord: 0mustafa