I am struggling with changing a spawners nbt to make the entity spawn with a display name based on a variable {spawner::stacksize::%location of event-block%} which is location of spawner. If you know this please reply or for easier communication you can contact me on discord (*K9Lil#5734)
I am trying to use Sk-NBeeT for this
This is what I currently have and works fine for all spawners and stacking just having trouble spawning the entity with a name based on the stack variable
Edit: Edited to add information
I am trying to use Sk-NBeeT for this
This is what I currently have and works fine for all spawners and stacking just having trouble spawning the entity with a name based on the stack variable
Code:
on place of spawner:
cancel event
set event-block to air
if target block is spawner:
if "%spawner(player, mob type of spawner at target block)% &fSpawner" is "%name of player's held item%":
add 1 to {spawner::stacksize::%location of target block%}
remove 1 of player's held item from player's held item
delete hologram {holograms::%location of target block%}
create hologram with lines "&6%{spawner::stacksize::%location of target block%}%&6x &e%spawner(player, mob type of spawner at target block)% &eSpawner" at location 1 meter above target block and store it in {holograms::%location of target block%}
else:
set {_t::*} to (name of player's held item) split at " "
wait 1 tick
set event-block to spawner
remove 1 of player's held item from player's held item
if size of {_t::*} is less than 3:
set mob type of spawner at event-block to "%uncolored {_t::1}%"
create hologram with lines "&61x &e%{_t::1}% &eSpawner" at location 1 meter above event-block and store it in {holograms::%location of event-block%}
set {spawner::stacksize::%location of event-block%} to 1
set {_a} to mob type of spawner at event-block
else:
set mob type of spawner at event-block to "%uncolored {_t::1}%_%uncolored {_t::2}%"
create hologram with lines "&61x &e%{_t::1}% &e%{_t::2}% &eSpawner" at location 1 meter above event-block and store it in {holograms::%location of event-block%}
set {spawner::stacksize::%location of event-block%} to 1
set {_a} to mob type of spawner at event-block
on break of spawner:
cancel event
delete hologram {holograms::%location of event-block%}
give player {spawner::stacksize::%location of event-block%} of spawner named "%spawner(player, mob type of spawner at event-block)% &fSpawner"
delete {spawner::stacksize::%location of event-block%}
set event-block to air
function spawner(p: player , t: text) :: text:
set {_n::*} to {_t} split at ""
set {_t} to "%{_n::1} in uppercase%"
replace all "_" in {_n::*} with " "
loop (size of {_n::*}) times:
add 1 to {_a}
{_a} < (size of {_n::*}) - 1
set {_b} to {_a} + 1
set {_t} to "%{_t}%%{_n::%{_b}%}%"
return "&e%{_t}%"
Edit: Edited to add information
Last edited: