Injecting NBT data into command blocks

  • 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.

YourMCAdmin

Member
Jan 31, 2017
18
0
0
37
Hey everyone! I used to use SkStuff to add NBT data to placed command blocks. Unfortunately that no longer works with 1.12 (maybe 1.11 even?).

I would spawn in a command block then add this code (or something like it):
add "{Command:/summon Item %{_x}% %{_y}% %{_z}% {Item:{id:wooden_sword,Count:1,tag:{display:{Name:""knife""}}}},TrackOutput:0}" to nbt of block at {_loc}

Now it just throws an error in console when it tries to input NBT data into a command block.
I've even tried the forked version of SkStuff. Can anyone think of any work around or another way to inject command blocks with commands?

Thanks :emoji_slight_smile:
 
Hey everyone! I used to use SkStuff to add NBT data to placed command blocks. Unfortunately that no longer works with 1.12 (maybe 1.11 even?).

I would spawn in a command block then add this code (or something like it):
add "{Command:/summon Item %{_x}% %{_y}% %{_z}% {Item:{id:wooden_sword,Count:1,tag:{display:{Name:""knife""}}}},TrackOutput:0}" to nbt of block at {_loc}

Now it just throws an error in console when it tries to input NBT data into a command block.
I've even tried the forked version of SkStuff. Can anyone think of any work around or another way to inject command blocks with commands?

Thanks :emoji_slight_smile:
it would help if you post the error.

An aleternative to nbt is directly setting the command of the command block however i dont see an expression in the docs for this unless im missing it so youll have to use skript-mirror. I dont really know how to use skript mirror but the steps more or less would be: get the block at the command block's loc --> double check its a command block --> cast CommandBlock to the block.getState() --> then commandBlock.setCommand("some command")
 
Error code:
code_language.skript:
[17:23:59] [Server thread/WARN]: [Skript] Error when parsing NBT - Expected value at: {Command:<--[HERE]
[17:23:59] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to Skript v2.2-dev23
java.lang.NoSuchMethodError: net.minecraft.server.v1_12_R1.TileEntity.a(Lnet/minecraft/server/v1_12_R1/NBTTagCompound;)V
    at me.TheBukor.SkStuff.util.NMS_v1_12_R1.setTileNBT(NMS_v1_12_R1.java:528) ~[?:?]
    at me.TheBukor.SkStuff.expressions.ExprNBTOf.change(ExprNBTOf.java:97) ~[?:?]
    at ch.njol.skript.effects.EffChange.execute(EffChange.java:273) ~[?:?]
    at ch.njol.skript.lang.Effect.run(Effect.java:54) ~[?:?]
    at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:65) ~[?:?]
    at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:93) ~[?:?]
    at ch.njol.skript.lang.Trigger.execute(Trigger.java:53) ~[?:?]
    at ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:152) ~[?:?]
    at ch.njol.skript.SkriptEventHandler$1.execute(SkriptEventHandler.java:112) ~[?:?]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:235) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:202) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:198) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1509) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:24) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:5) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_141]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_141]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:843) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [PaperSpigot-latest.jar:git-Paper-1255]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
[17:24:01] [Server thread/WARN]: [Skript] Error when parsing NBT - Expected value at: {Command:<--[HERE]
[17:24:01] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to Skript v2.2-dev23
java.lang.NoSuchMethodError: net.minecraft.server.v1_12_R1.TileEntity.a(Lnet/minecraft/server/v1_12_R1/NBTTagCompound;)V
    at me.TheBukor.SkStuff.util.NMS_v1_12_R1.setTileNBT(NMS_v1_12_R1.java:528) ~[?:?]
    at me.TheBukor.SkStuff.expressions.ExprNBTOf.change(ExprNBTOf.java:97) ~[?:?]
    at ch.njol.skript.effects.EffChange.execute(EffChange.java:273) ~[?:?]
    at ch.njol.skript.lang.Effect.run(Effect.java:54) ~[?:?]
    at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:65) ~[?:?]
    at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:93) ~[?:?]
    at ch.njol.skript.lang.Trigger.execute(Trigger.java:53) ~[?:?]
    at ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:152) ~[?:?]
    at ch.njol.skript.SkriptEventHandler$1.execute(SkriptEventHandler.java:112) ~[?:?]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:235) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerInteractManager.a(PlayerInteractManager.java:460) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:990) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:5) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_141]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_141]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:843) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [PaperSpigot-latest.jar:git-Paper-1255]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]

What I'm attempting to do is use /setblock to place specific player heads nearby on the ground. But that requires NBT data too. And console commands can only do it in the main world. Yet I need the heads to place in all worlds. Pain in the bum! lol
 
Error code:
code_language.skript:
[17:23:59] [Server thread/WARN]: [Skript] Error when parsing NBT - Expected value at: {Command:<--[HERE]
[17:23:59] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to Skript v2.2-dev23
java.lang.NoSuchMethodError: net.minecraft.server.v1_12_R1.TileEntity.a(Lnet/minecraft/server/v1_12_R1/NBTTagCompound;)V
    at me.TheBukor.SkStuff.util.NMS_v1_12_R1.setTileNBT(NMS_v1_12_R1.java:528) ~[?:?]
    at me.TheBukor.SkStuff.expressions.ExprNBTOf.change(ExprNBTOf.java:97) ~[?:?]
    at ch.njol.skript.effects.EffChange.execute(EffChange.java:273) ~[?:?]
    at ch.njol.skript.lang.Effect.run(Effect.java:54) ~[?:?]
    at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:65) ~[?:?]
    at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:93) ~[?:?]
    at ch.njol.skript.lang.Trigger.execute(Trigger.java:53) ~[?:?]
    at ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:152) ~[?:?]
    at ch.njol.skript.SkriptEventHandler$1.execute(SkriptEventHandler.java:112) ~[?:?]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:235) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:202) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:198) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1509) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:24) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:5) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_141]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_141]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:843) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [PaperSpigot-latest.jar:git-Paper-1255]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
[17:24:01] [Server thread/WARN]: [Skript] Error when parsing NBT - Expected value at: {Command:<--[HERE]
[17:24:01] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to Skript v2.2-dev23
java.lang.NoSuchMethodError: net.minecraft.server.v1_12_R1.TileEntity.a(Lnet/minecraft/server/v1_12_R1/NBTTagCompound;)V
    at me.TheBukor.SkStuff.util.NMS_v1_12_R1.setTileNBT(NMS_v1_12_R1.java:528) ~[?:?]
    at me.TheBukor.SkStuff.expressions.ExprNBTOf.change(ExprNBTOf.java:97) ~[?:?]
    at ch.njol.skript.effects.EffChange.execute(EffChange.java:273) ~[?:?]
    at ch.njol.skript.lang.Effect.run(Effect.java:54) ~[?:?]
    at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:65) ~[?:?]
    at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:93) ~[?:?]
    at ch.njol.skript.lang.Trigger.execute(Trigger.java:53) ~[?:?]
    at ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:152) ~[?:?]
    at ch.njol.skript.SkriptEventHandler$1.execute(SkriptEventHandler.java:112) ~[?:?]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:235) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerInteractManager.a(PlayerInteractManager.java:460) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:990) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:5) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[PaperSpigot-latest.jar:git-Paper-1255]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_141]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_141]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:843) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [PaperSpigot-latest.jar:git-Paper-1255]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [PaperSpigot-latest.jar:git-Paper-1255]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]

What I'm attempting to do is use /setblock to place specific player heads nearby on the ground. But that requires NBT data too. And console commands can only do it in the main world. Yet I need the heads to place in all worlds. Pain in the bum! lol
you should definitely not be using command blocks for that... (im not sure why you would ever need them really)
https://forums.skunity.com/threads/about-skull.5297/#post-20880
code_language.skript:
set block at {_loc} to floor head
set skull owner of block at {_loc} to "Etho" parsed as offlineplayer
if you need nbt in the future it might be your skript version, dev23 is really old
 
There is a fork of skstuff that supports 1.12.1, however for 1.12.2 it only work on some server versions for some reason. In addition, you could get a more reliable method using skript-mirror.
 
Last edited:
you should definitely not be using command blocks for that... (im not sure why you would ever need them really)
https://forums.skunity.com/threads/about-skull.5297/#post-20880
code_language.skript:
set block at {_loc} to floor head
set skull owner of block at {_loc} to "Etho" parsed as offlineplayer
if you need nbt in the future it might be your skript version, dev23 is really old

I know that Skript code for player skulls. The issue is, I'm using skins not tied to a username. So, NBT is the only way to go. I know the dev23 version I'm using is old. The newest version is throwing me all kinds of errors when it comes to looping within loops. It won't let me use loop-value-1, loop-value-2, etc anymore. So I'd rather stick to an older version that is stable with the skripts I'm using. It seems I have to pick and choose my battles here :emoji_frowning:

There is a fork of skstuff that supports 1.12.1, however for 1.12.2 it only work on some server versions for some reason. In addition, you could get a more reliable method using skript-mirror.
I'll check out skript-mirror and see if it can help me in anyway!
 
Last edited:
I know that Skript code for player skulls. The issue is, I'm using skins not tied to a username. So, NBT is the only way to go. I know the dev23 version I'm using is old. The newest version is throwing me all kinds of errors when it comes to looping within loops. It won't let me use loop-value-1, loop-value-2, etc anymore. So I'd rather stick to an older version that is stable with the skripts I'm using. It seems I have to pick and choose my battles here :emoji_frowning:


I'll check out skript-mirror and see if it can help me in anyway!
I'm on dev32b 1.12.2 and I don't have that loop issue at all, maybe its an addon bug? I recently discovered that skstuff breaks the ability to parse text as a region and therefore if I have the name of a region stored in a database I cannot use any wordlguard skript effects such as getting the members of a worldguard region because I can't parse the text as a region, anyway that doesn't really have anything to do with the issue you mentioned I just thought I'd give an example of how some addons do mess up vanilla functionality sometimes, it would be cool if you gave us some example code in which you get the loop error so we can test it and let you know if we get it or not.
 
I know that Skript code for player skulls. The issue is, I'm using skins not tied to a username. So, NBT is the only way to go. I know the dev23 version I'm using is old. The newest version is throwing me all kinds of errors when it comes to looping within loops. It won't let me use loop-value-1, loop-value-2, etc anymore. So I'd rather stick to an older version that is stable with the skripts I'm using. It seems I have to pick and choose my battles here :emoji_frowning:


I'll check out skript-mirror and see if it can help me in anyway!
code_language.skript:
function setCommand(commandBlock: block, command: string):
  set {_blockState} to {_commandBlock}.getState()
  {_blockState}.setCommand({_command});
  {_blockState}.update();
with skript-mirror.
[doublepost=1513128755,1513128471][/doublepost]
I know that Skript code for player skulls. The issue is, I'm using skins not tied to a username. So, NBT is the only way to go. I know the dev23 version I'm using is old. The newest version is throwing me all kinds of errors when it comes to looping within loops. It won't let me use loop-value-1, loop-value-2, etc anymore. So I'd rather stick to an older version that is stable with the skripts I'm using. It seems I have to pick and choose my battles here :emoji_frowning:


I'll check out skript-mirror and see if it can help me in anyway!
NBT is not the only way to go, there's other ways to do it . The loop-value issues are more than likely an issue with a shit addon you use, because I don't have this issue on vanilla version dev25 or dev32c.
 
Status
Not open for further replies.