Nbt of Block

  • 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 comminuty!

    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!

Status
Not open for further replies.

ShaneBee

Supporter +
Addon Developer
Sep 7, 2017
2,247
241
73
Vancouver, Canada
Skript Version: dev37c
SkStuff: 1.6.4.1-fork-1.12

Okay, so I have figured out how to add NBT to an item. Basically what I am trying to figure out how to do is,
Create a spawner (check)
Give it to the player (check)
Change the spawner that was placed on the ground (help)
So THIS works:
code_language.skript:
command /test:
    trigger:
        give player spawner with nbt "{BlockEntityTag:{SpawnData:{id:""chicken""},SpawnCount:5,MinSpawnDelay:1,MaxSpawnDelay:2,Delay:1,MaxNearbyEntities:100,SpawnPotentials:[{Entity:{id:""chicken""},Weight:1}]},display:{Name:""chicken""}}"

YAY for that... but now I am trying to my damndest to figure out how to add NBT to a block
I placed a spawner, pulled the NBT and tried to add the same NBT back just for testing, and no go.
Here is my test
code_language.skript:
on right click on spawner:
    set nbt of event-block to "{MaxNearbyEntities:6s,RequiredPlayerRange:16s,SpawnCount:4s,SpawnData:{id:""minecraft:cow""},MaxSpawnDelay:800s,Delay:150s,x:287,y:64,z:199,id:""minecraft:mob_spawner"",SpawnRange:4s,MinSpawnDelay:200s,SpawnPotentials:[{Entity:{id:""minecraft:cow""},Weight:1}]}"
The error I get is:
code_language.skript:
[22:53:05 ERROR]: a types.compound can't be set to anything (test.sk, line 47: set nbt of event-block to "{MaxNearbyEntities:6s,RequiredPlayerRange:16s,SpawnCount:4s,SpawnData:{id:""minecraft:cow""},MaxSpawnDelay:800s,Delay:150s,x:287,y:64,z:199,id:""minecraft:mob_spawner"",SpawnRange:4s,MinSpawnDelay:200s,SpawnPotentials:[{Entity:{id:""minecraft:cow""},Weight:1}]}"')
The syntax in the docs is stated as:
code_language.skript:
nbt[[ ]tag[s]] of %entity/block/item%
I feel like I have tried everything. Does anyone have any clue how the heck to do this?
 
Skript Version: dev37c
SkStuff: 1.6.4.1-fork-1.12

Okay, so I have figured out how to add NBT to an item. Basically what I am trying to figure out how to do is,
Create a spawner (check)
Give it to the player (check)
Change the spawner that was placed on the ground (help)
So THIS works:
code_language.skript:
command /test:
    trigger:
        give player spawner with nbt "{BlockEntityTag:{SpawnData:{id:""chicken""},SpawnCount:5,MinSpawnDelay:1,MaxSpawnDelay:2,Delay:1,MaxNearbyEntities:100,SpawnPotentials:[{Entity:{id:""chicken""},Weight:1}]},display:{Name:""chicken""}}"

YAY for that... but now I am trying to my damndest to figure out how to add NBT to a block
I placed a spawner, pulled the NBT and tried to add the same NBT back just for testing, and no go.
Here is my test
code_language.skript:
on right click on spawner:
    set nbt of event-block to "{MaxNearbyEntities:6s,RequiredPlayerRange:16s,SpawnCount:4s,SpawnData:{id:""minecraft:cow""},MaxSpawnDelay:800s,Delay:150s,x:287,y:64,z:199,id:""minecraft:mob_spawner"",SpawnRange:4s,MinSpawnDelay:200s,SpawnPotentials:[{Entity:{id:""minecraft:cow""},Weight:1}]}"
The error I get is:
code_language.skript:
[22:53:05 ERROR]: a types.compound can't be set to anything (test.sk, line 47: set nbt of event-block to "{MaxNearbyEntities:6s,RequiredPlayerRange:16s,SpawnCount:4s,SpawnData:{id:""minecraft:cow""},MaxSpawnDelay:800s,Delay:150s,x:287,y:64,z:199,id:""minecraft:mob_spawner"",SpawnRange:4s,MinSpawnDelay:200s,SpawnPotentials:[{Entity:{id:""minecraft:cow""},Weight:1}]}"')
The syntax in the docs is stated as:
code_language.skript:
nbt[[ ]tag[s]] of %entity/block/item%
I feel like I have tried everything. Does anyone have any clue how the heck to do this?
SkStuff is broken in dev 36+
 
I know ur feel bro, i have to do weird nbt stuff but i cant rip
[doublepost=1534057146,1534057084][/doublepost]However there is a TukeNuke version of it.. Also think its broken tho
Thats actually the version I have been using. Its the only version that allows me to add NBT to an item, just not a block sadly!
 
Instead of setting the nbt of the block, try replacing the event-block with a new one:
code_language.skript:
set event-block to spawner with custom nbt "{}"

or maybe:
code_language.skript:
set {_spawner} to spawner named "asd" with custom nbt "{}"
set event-block to {_spawner}

I know this doesn't make much sense but doing enough hacky stuff like this usually gets SkStuff to do the job, i've been there too
 
Instead of setting the nbt of the block, try replacing the event-block with a new one:
code_language.skript:
set event-block to spawner with custom nbt "{}"

or maybe:
code_language.skript:
set {_spawner} to spawner named "asd" with custom nbt "{}"
set event-block to {_spawner}

I know this doesn't make much sense but doing enough hacky stuff like this usually gets SkStuff to do the job, i've been there too
Hey thanks, I have already tried both of those an no go. They don't throw errors, but it just places a normal pig spawner.
 
IIRC you don't set NBT, you add it. add the text to NBT of event-block.
 
That's still probably due to SkStuff not working on new Skript versions, as other have stated.
 
you can use skript mirror
code_language.skript:
import:
    org.bukkit.entity.EntityType

set {_spawner} to clicked block.getState()
{_spawner}.setSpawnedType(EntityType.CHICKEN!)
whatever else you wanna set
{_spawner}.update()
 
you can use skript mirror
code_language.skript:
import:
    org.bukkit.entity.EntityType

set {_spawner} to clicked block.getState()
{_spawner}.setSpawnedType(EntityType.CHICKEN!)
whatever else you wanna set
{_spawner}.update()
UGH... i really need to learn how to use Skript-Mirror and understand all the Java stuff.. because I know that is probably my best bet in this case.
 
Status
Not open for further replies.