Skip to content

(1.16 ) Script Structure

Xaikii edited this page Jun 23, 2021 · 3 revisions

I consider you have followed the instruction in (1.16+) Getting Started, if so we'll start with the Basics.

Now that you have generated the Documentation, I want you to open these.
It's the Folder called "scavenge_doc" within your Minecraft Instance Folder.
There you'll find a file called "example_script.json".

All your Files need to be JSON Files, which have the extension ".json" the name however should be unique.

The first things you'll see is a "scripts" section, that will include the Scripts to load, by default this is using '{}' where it'll try to load 1 Script.
You can theoretically change this to '[{}]', wherein you can now have multiple so called "Objects" within this Array (these --> []).
This can look like this '[{},{},{}] wherein this would be have 3 Scripts within 1 File.
For your own sanity, I'd highly recommend to not do this and work with 1 Script per File to reduce unnecessary confusion.

The "id" is an Unique Identifier, meaning every Script should have a Unique Name. If by any means you happen to forget to change it, and now 2 Script have the same ID, don't worry. Nothing is lost, when 2 Scripts have the same on the Script loaded last will be executed. Simply go back into the File and change the ID.

Next, we have "swing". A simple little option that will make your Hand swing when a Script is working, or not swing. While it's neat, it's not necessary and is up to your preference.

Now we have the very first thing that effects our Scripts outcome, "dropRule".
As the name implies, it will change the way your Loot will be distributed.
Possible values are:
'block' [Spawns Item at the Block],
'player' [The Player will drop it(visually)],
'player_inv' [Adds it straight into the inventory of the Entity that triggers the Script]

"loot_seed" is a very specific option, honestly 99.99% cases you won't need this option and can leave it out.
However for those 0.01% of cases, you can use it to specify the seed your Loot should generate of.
To explain: every World has a unique seed, and so it does uniquely generated loot within the various chests.
Using "loot_seed" you can specify the desired seed.

And here we have the body of every Script "properties".
This beautiful thing will be filled with all your Conditions and Effects, like "if in Dimension x" or "Add Exhaustion".
What can be explained quite easily, can get extremely complex the further you dive into it. But in the later Page I will help you understand these.

As previously mentioned, you can specify some Loot your Script should drop under certain Conditions.
This is done in "loot". It simply requires the loot_table location.
If this is something you have problems with, I'd recommend you'll checkout the Page (1.16+) Pebble.

Now we have "type", here you will specify how the Script should be triggered.
With a left-click? Or maybe a right-click?
Do you want to consume the Interaction, and prevent e.g. Chests from opening if the Scripts conditions are met?
That's done with "type".

Coming to the final piece, "targets".
As you might have noticed or guessed already, this will specify the blocks that should be targeted.
It can take 3 different target_types, "block" [specifies 1 block], "blocks" [can specify as many blocks as you wish], "tag" [will target every block within the specified tag].
Unsure what tags a block has?
Either press "f3" and look at a block you want to know the tags of. At the right side, every line below "Targeted Block", that starts with a #, is a tag.
Want to look which blocks are within a certain tag?
If you are a sane person, you'll have JEI(Just Enough Items) installed. If so, just use the search bar. JEI allows for Tag searchs with the prefix $.
If you want to know what blocks in your Pack have the tag "minecraft:logs", just type in "$minecraft:logs" or even shorter "$logs".

Just a final note.
Your Script has to have Loot or a Script Effect Property included, otherwise it will not be recognized as Script and will not be loaded.

Clone this wiki locally