Set array of data in set item NBT procedure blocks

Published by Eyllan on Sat, 05/16/2020 - 18:02
Upvotes: 3
Issue description

Hello, i have some troubles to add NBT Tags as custom as I woud like...

For instant with the procedure system you are able to add Boolean, String or number NBTags but i didnt find any soluce/tricks to generate an Array of string inside an NBTags.... 

 

The goal would be to make an equivalent of the command when the user craft a new pickaxe, to set the CanDestroy Tag to an array of string with all the blocks that he can destroy. (for adventure mod). When you use command below, there is not trouble but when i try to make it with your procedures or with my own code, it doesn't work... 

 /give PLAYER minecraft:diamond_pickaxe{CanDestroy:["mod:specialblock"]} 1

 

On the minecraft.gamepedia page, i didn't find anything about a tag for array of string (same in forge source code)... So i don't know if it would be possible to add a feature to make those NBTags. And for the moment, would someone be able to help me how to handle this issue? I'll continue to try and find soluce and responses. But last night and couple of hours today made me be so mad. :D

https://minecraft.gamepedia.com/NBT_format

Issue comments

I tried to use the plugin but the porblem is that in the best case (when I replace the code that the export send back as string) is that in any case, the result is a string and not an array. And about the related issue, it's not the same question... I'm trying to find a way to put an array to an NBT tag and not simply to use it in procedure.

So it give ingame NBT like this: {CanDestroy: "["elem1","elem2"]"}

Instead of {CanDestroy: ["elem1","elem2"]}

(So the same result that when i tried by my self to put a string or anything like it inside.

 

And this change everything about how minecraft understant it... Any tips or recommandation?

OKay, i found a soluce which was not so complicated... --' just not used to develop on minecraft (and/or with the Forge API)

Those 4 lines are enough to make exactly what i was looking for. I only need to put it in the onCreated event (or in a procedure called from this event and everything is fine...) 

ListNBT list = new ListNBT();
StringNBT st = StringNBT.valueOf("eyatsu:test_block");
list.add(st);
(itemstack).getOrCreateTag().put("CanDestroy", list);

I think it would be interesting to add a feature like this in the procedure (not so hard to implement i think)



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.