• Hey! Register here to create your account, engage with the community, and talk about what is new!

Code Template Manipulation

  • Thread starter Deleted member 26
  • Start date
D

Deleted member 26

Guest
In this tutorial, I will go over how to be able to edit code templates and manipulate using NBT Editor.

Recommended Programs:
NBT Explorer (For inserting the new code template into a toolbar item)
Text Editor (Copying code/Editing Code)

If you are going to be following this tutorial, please do not use this with malicious intentions. If you are attempting to bypass filters or certain restrictions that are currently in place you may have the chance of being punished.

Accessing the NBT Data

To edit a template, we must first get access to the code templates NBT data. There are multiple ways to do this, so choose whichever one you think is best.

Base+Profile+Screenshot+2019.12.03+-+18.14.45.74_1575415087.png

The code you are looking for is stored under "code" in the item's NBT data.

1. /itemdata and manually copy the code. (I wouldn't do this, as there is room for human error.)
2. /itemdata and accessing your log files in minecraft. (%appdata%\.minecraft\logs\latest.log)
3. Use NBT Explorer to copy the code (save the template in your saved toolbars) (RECOMMENDED)
If you are not going to use NBT Explorer to get the code, please still follow this tutorial as you will need to use it for editing a template.

There is a chance that when you are editing toolbar NBT data, you can corrupt it causing ALL ITEMS to be lost. If you do not want this happening, save your items somewhere else, or please click off this tutorial.

I am not responsible for any lost items... including lost heads.

Please make sure that you saved the template to a saved toolbar.

Open your .minecraft folder (%appdata%\.minecraft) and select hotbar.nbt.
You then should see something like this...
Capture_1575415357.PNG

0-8 represents the number of toolbars, 0 being the first and 8th being the last.
In this example, my code template is stored inside of my first toolbar so I will access 0.
Capture_1575415534.PNG

After that, each "box" looking icon contains an item. Locate the one that contains your code template.
After that, open up the "tag" section. You should then see display and PublicBukkitValues, after that expand PublicBukkitValues.
Capture_1575415708.PNG

Now you see "hypercube:codetemplatedata", if you have gotten to this point great job! Now, all you have to do is double click, locate "code" and copy that.
Capture_1575415794.PNG


Decompressing

DiamondFire compresses the code template data so that it doesn't use as much space in the items NBT. We need to decompress it so that we can edit the data.

Here's how DiamondFire compresses the data...
Base+Profile+Screenshot+2019.12.03+-+18.14.45.74_1575416107.png

As you can see, the data starts as JSON and gets gzipped, then base64 encoded.

Using http://www.txtwizard.net/compression, your text will be decoded and decompressed to display the JSON data.
Annotation 2020-09-07 095433.png
Once you put your compressed data, you need to click decompress.
Then, copy and paste the JSON data that you get inside the result box.
Capture_1575416656.PNG

It should look like this, as you can see it is clearly in the JSON format. Because of this, you can use any JSON editor you want as well.

For this example, we are going to add an action that really doesn't exist currently.
Capture_1575416766.PNG
(I think it should exist)

Okay so, now what?

Exporting our new code template

So now, we want to insert this new code into our item... but how?

Well using the tutorial up above you simply are going to set the code instead of just copying.
(MAKE SURE YOU HAVE A TEMPLATE SAVED IN YOUR TOOLBAR)

Now, we need to compress our JSON back to the format DF uses. So, head back to http://www.txtwizard.net/compression.
Put your JSON in the top box and click compress.

Capture_1575416901.PNG


After you have your string, you need to edit your items NBT again.
Replace the string inside of code with the new string.

Capture_1575415794.PNG


Result

After you have saved and rejoined the game, when you try to place down your code you should see that your changes were made!
Base+Profile+Screenshot+2019.12.03+-+18.56.05.54_1575417384.png


Thanks for following my tutorial, have a great rest of your day/night. Feel free to leave any feedback that you may have. This is my first tutorial, so please correct me if needed.

Make sure to leave a like if you enjoyed it! (y)


Extra Information:

I have a neat program that allows you to interact with templates in very interesting ways. It's called DFVisual, and it's been a project of mine for a while. Please note that it is pretty buggy, and isn't updated that much anymore.

Annotation 2020-09-07 100406.png

Basically, it allows you to create new codeblocks and import them with ease.
If you are interested, please join the discord for more information. https://discord.gg/XMw7vSq
 
Last edited by a moderator:

EmeralDev

Forum adept
Joined
Sep 7, 2020
Messages
193
Reaction score
30
Epic post I will most likely never use this because I don't really code anymore B)
 

Zyborg

Forum adept
Joined
Sep 5, 2020
Messages
218
Reaction score
13
does this make it possible to start code without a func?
I mean like place a player action at the start of a line
 

Zyborg

Forum adept
Joined
Sep 5, 2020
Messages
218
Reaction score
13
@Owen, a few questions:
1. How can you use a custom block (Ex. There is cobblestone for player actions, but I want smooth stone)
2. How can you customize the name? (Ex. Player Action says: "PLAYER ACTION" on the top of the sign)
3. How to you access the fourth line? (well I don't need to give an example for this one...)

Note: if these were answered above, then I really didn't pay attention when reading, so tell me if it was answered.

oh and 4. When you modify the toolbar, do you have to restart MC, rejoin the world, or does it change once you open the saved toolbars tab again? (again, no example...)

Edit: Can you send a link for the DFVisual program thingy software kind of visual way of seeing DF program software thingy?
 
Last edited:

SirObby

New member
Overlord
Joined
Dec 6, 2020
Messages
18
Reaction score
8
This documentation does not look correct.
Its using some other steps than just gzipping the json and then base64 encoding the gzipped.
 

Synsao

Active member
Emperor
Joined
Jan 13, 2021
Messages
42
Reaction score
18
In this tutorial, I will go over how to be able to edit code templates and manipulate using NBT Editor.

Recommended Programs:
NBT Explorer (For inserting the new code template into a toolbar item)
Text Editor (Copying code/Editing Code)



Accessing the NBT Data

To edit a template, we must first get access to the code templates NBT data. There are multiple ways to do this, so choose whichever one you think is best.

Base+Profile+Screenshot+2019.12.03+-+18.14.45.74_1575415087.png

The code you are looking for is stored under "code" in the item's NBT data.

1. /itemdata and manually copy the code. (I wouldn't do this, as there is room for human error.)
2. /itemdata and accessing your log files in minecraft. (%appdata%\.minecraft\logs\latest.log)
3. Use NBT Explorer to copy the code (save the template in your saved toolbars) (RECOMMENDED)
If you are not going to use NBT Explorer to get the code, please still follow this tutorial as you will need to use it for editing a template.



Please make sure that you saved the template to a saved toolbar.

Open your .minecraft folder (%appdata%\.minecraft) and select hotbar.nbt.
You then should see something like this...
Capture_1575415357.PNG

0-8 represents the number of toolbars, 0 being the first and 8th being the last.
In this example, my code template is stored inside of my first toolbar so I will access 0.
Capture_1575415534.PNG

After that, each "box" looking icon contains an item. Locate the one that contains your code template.
After that, open up the "tag" section. You should then see display and PublicBukkitValues, after that expand PublicBukkitValues.
Capture_1575415708.PNG

Now you see "hypercube:codetemplatedata", if you have gotten to this point great job! Now, all you have to do is double click, locate "code" and copy that.
Capture_1575415794.PNG


Decompressing

DiamondFire compresses the code template data so that it doesn't use as much space in the items NBT. We need to decompress it so that we can edit the data.

Here's how DiamondFire compresses the data...
View attachment 27

As you can see, the data starts as JSON and gets gzipped, then base64 encoded.

Using http://www.txtwizard.net/compression, your text will be decoded and decompressed to display the JSON data.
View attachment 31
Once you put your compressed data, you need to click decompress.
Then, copy and paste the JSON data that you get inside the result box.
Capture_1575416656.PNG

It should look like this, as you can see it is clearly in the JSON format. Because of this, you can use any JSON editor you want as well.

For this example, we are going to add an action that really doesn't exist currently.
Capture_1575416766.PNG
(I think it should exist)

Okay so, now what?

Exporting our new code template

So now, we want to insert this new code into our item... but how?

Well using the tutorial up above you simply are going to set the code instead of just copying.
(MAKE SURE YOU HAVE A TEMPLATE SAVED IN YOUR TOOLBAR)

Now, we need to compress our JSON back to the format DF uses. So, head back to http://www.txtwizard.net/compression.
Put your JSON in the top box and click compress.

Capture_1575416901.PNG


After you have your string, you need to edit your items NBT again.
Replace the string inside of code with the new string.

Capture_1575415794.PNG


Result

After you have saved and rejoined the game, when you try to place down your code you should see that your changes were made!
Base+Profile+Screenshot+2019.12.03+-+18.56.05.54_1575417384.png


Thanks for following my tutorial, have a great rest of your day/night. Feel free to leave any feedback that you may have. This is my first tutorial, so please correct me if needed.

Make sure to leave a like if you enjoyed it! (y)


Extra Information:

I have a neat program that allows you to interact with templates in very interesting ways. It's called DFVisual, and it's been a project of mine for a while. Please note that it is pretty buggy, and isn't updated that much anymore.

View attachment 30

Basically, it allows you to create new codeblocks and import them with ease.
If you are interested, please join the discord for more information. https://discord.gg/XMw7vSq
is there a new discord invite
 
Top Bottom