3

Functions and What You Can Do With Them

0rlando's Avatar 0rlando1/4/18 9:51 am history
3 emeralds 399 7
1/6/2018 10:48 am
0rlando's Avatar 0rlando
Hello. This is going to be a guide to how use some of the new features added into Minecraft as of the early stages of 1.12. These can be used for amazing things such as making entirely new weapons and sets of armor without mods or plugins, and with a bit of Optifine :)
At least that's what I do. You can do all kinds of things with these!

How I am going to be teaching the commands is in parts just to make it easier to digest (hopefully). The colors correspond and in general you will want to copy and paste, if you copy and paste at all that is, the one with color because the formatting doesn't work with square brackets so I just do vertical lines instead.

However, if you want to be able to use this guide and understand it all there are a few things you should have under your belt.
Requirements
  • First you want a basic knowledge of commands. Without that there isn't much you would want to do with functions as they are entirely created of commands and loot tables and such. You want to be able to do these:
    • Intermediate /give commands, or just know what everything does in MCStacker.
    • Intermediate /summon commands or same as above
    • Fairly advanced /scoreboard commands, which you can't really get from a generator. These will also be partially explained in this guide
    • A general knowledge of all other commands
    • A general knowledge of selectors (@p, @e, @a, @r, and the things inside the brackets after). These will also be partially explained in this guide

  • Second you want to be able to navigate your Minecraft folder. If you can't do that then just look at the picture following.
How to get to Appdata
Getting to %appdata% through the search bar
Getting to %appdata% through the search bar
Then just click .minecraft

  • Something like Sublime Text or Notepad++ (Thanks ShelLuser!)
  • Finally you want to read the entire article otherwise it won't be really helpful. You can't skim functions.

What Functions do is they run many commands from only one command block, repeating or otherwise, of which originate from a text file. This makes it much easier to do many commands in a row. No more giant towers of chain command blocks! I have functions with more than 100 lines, 99% of which are commands. That makes my life much much easier just because of how I don't have to put each and every one in a chain command block. These can create many fairly impressive things. I will be showing you how to make one of the armor sets (eventually) I have made which is a set of armor that lets you turn completely invisible, armor and all with a cool down and activation on shift. But that comes much later. First you need to know how you will actually make the functions.

Making Functions
These are going to basically be additions to your world's file. That means it is a portable mod that is server-side so people wouldn't have to download it for it to work on servers.
Anyways, in your file, you will want to go through this path: Appdata\Roaming\.minecraft\saves\InsertWorldName\data\functions. Next you will want to create a new folder. I called mine Guide, because I will be making a guide, but call yours whatever you want. Just be wary because you will have to type it a ton later. That is where you create your first function. Here you want to make a random text file, Mine will be called Test. I'll open it, I use notepad to do so, File, Save As, and change the file type to All Files and rename it to Test.mcfunction. This will change the file type to one you can now only open with Sublime or something similar to it. Make very sure you typed mcfunction and that you saved it as all files. You can delete the old version of the file because it will do absolutely nothing. Now you have a function. Great! As of now it will do absolutely nothing. That is of course because it is blank.
Pictures of what to do if you are kind of lost :)
No I am not the Spiciest Memelord
This is the file path you will have to go to. As you can see I named my world Function Guide and my function's folder Guide. ↗
No I am not the Spiciest Memelord



The save as notepad thing! ↗


Make sure yours looks very similar to this ↗

Now that you actually have a function, you can now put a bunch of commands into that file you made earlier, for me Test.mcfunction, and you can run them all at once from a repeating command block, but before anything you should know about the /reload command. Whenever you make an edit of some sort to your Test.mcfunction file you will have to do /reload in the game otherwise the changes won't be taken into account. Minecraft does this so that it isn't using the file at all times so that you can edit it without having to close Minecraft. Remember that becuase there have been many times that I was practically steaming because I couldn't find any flaw and it still wasn't doing anything where I just forgot to reload.

Your first commands!
Now we will open the file. Firstly you should probably just do something simple to get used to it. There are a few rules however but none to confusing.
  • Most certainly DO NOT put any / before commands. If you do the command won't work and you will have to facepalm.
  • If you put a # before you say anything you write you will be able to have it completely ignored which is great if you want to write a comment to yourself for later.
Fun. Anyways, something simple. How about a classic hello world? Do whatever you want, but I guess I'm going to walk you through a basic hello world.
If you can tellraw or know a good tellraw generator by all means make it fancy. For now though we are going to go with msg
msg @s Hello World!
msg @s Hello World!
XX
➜ This is the original command. /msg. If you don't know that bit, this guide isn't for you.
XX ➜ This is the selector. @sender. This will target the command at the person who executed the command.
XX ➜ This is the message it's self.

That is how I am going to be demonstrating every command I write just because of how it is probably easier to digest for people who are more new to commands.
Now let's add a bit more stuff just to make it fun. The only reason why [] is replaced with || is because the format gets all weird when you do []s in spoilers.
give @s apple 42 0 {display:{Name:"§cApple",Lore:|"§cHealthy"," ","§cUntil covered in §6caramel"|}}
give @s apple 42 0 {display:{Name:"§c§lApple",Lore:["§cHealthy"," ","§cUntil covered in §6caramel"]}}
XX ➜ Command base, give.
XX ➜ Selector, same as above, to sender.
XX ➜ Item, I chose an apple just because.
XX ➜ This is the data value. Used for blocks with multiple textures, like stone, or items with damage.
XX ➜ This is the first NBT tag. This specifies what the item will be like. This specific tag talks about some smaller ones that fall under the display category
XX ➜ This is the first semi-category. This will specify the name of the item.
XX ➜ This is the name it's self. While you can do it without the quotation marks, I do it just in case I ever want to write something with a space. The §c§l is the color code. It will make it look like Apple. If you don't know these by heart search up Formatting Codes or just go to This Link.
XX ➜ Second semi-category. The lore. The text to display below the item.
XX ➜ In quotes (for certain this time) normally looks purple and italicized, or §5§o, separated by a comma.
XX ➜ This just is a break in the line. I just add a space in there because I have never tested without. To lazy to as well.
XX ➜ Final line, very similar to the rest. Just slightly different

All of these can be manipulated in many ways, you can change the name, lore, item and if you know how to just add or take away data tags. If you don't either use something like MCStacker or just search up Data Tags Minecraft and be confused.
msg @s Have some Apples
Very similar to the other msg. Again, feel free to spruce up with tellraw if you know how to.
Now your file should look similar to this

Running your First Commands
Now you will want to go back into your world, the one that you have all your stuff in. do a /reload and there is one command you will want to run to see if it works.
/function guide:test
/function guide:test
XX ➜ Base command, will be the base command for almost all of the things you will ever have to type just because most of the commands will be in your file.
XX ➜ This will be the name of your first file, mine called Guide.
XX ➜ This is the name of your file. Mine is called Test.
If you have a really cool and custom apple, you should give yourself a pat on the back. If not you did something wrong.
Troubleshooting
  • Check that you didn't type the /function command wrong. If you did you will get some message like Unknown function 'something:something' or Unknown command, try /help for a list of commands of you just typed the command wrong
  • If you didn't put it in the folder you would get Unknown Function 'minecraft:something'
  • If you typed a command wrong only some of the things would happen so just look for the one that isn't correct by cross referencing with the ones that I typed.
  • Other? Just tell me in the comments and I'll tell you how to fix it and update this.

Great! Now that that is out of the way, I promised you a cool function armor set or something. Just a warning, it will include tons of scoreboard and the like.

Assassin's Set
This is what I am going to be showing you. A prime example of function use for sheer accessibility and easiness to install into a world. Once you create this you can use it for just about any world that is up to date and not on a server with plugins that limit commands (such as Essentials or stuff like that). The first thing you will want to do however, is to make some new functions. In total you will have three.
  1. Setup. This will be the first thing you will ask the player to run in a function pack because it will set up all the scoreboards and structures (if you have any).
  2. Give. For testing purposes only, until you have a reliable crafting system you have to just use a function.
  3. Your Set's Name. For now you will only have one set, hence only three files. Eventually you will have more but for now these will suffice.
Now all you have to do is make each of these with nothing in them. The easiest way in my opinion is just to copy and paste your Test.mcfunction three times and just rename it to Setup and Give.
The first one we will be working on is Give.mcfunction
Give.mcfunctionNow would be a great time to whip out your MCStacker if you don't know how to use the Give command very well. What you will want to do is create a base command and build off of it to create the rest of the set. If you make a set of armor then the tooltip would have to be very similar if you want it to look like a set at all. That means all you really have to do is change the name and item type. I'll start with the boots.

give @p minecraft:chainmail_boots 1 0 {display:{Name:"§d§lAssasin's Boots",Lore:|"§5No ordinary Leather Armor","§8§lSet Bonus:","§7 On Sneak:","§7Invisibility§9 45 Secs","§7Speed §3II§9 45 Secs","§7Jump Boost §3II§9 45 Secs","§aCooldown§7: 30 Secs","","§7 On Sprint:","§7Speed §3I","§7Jump Boost§3 I"|}}
give @p minecraft:chainmail_boots 1 0 {display:{Name:"§d§lAssasin's Boots",Lore:["§5No ordinary Leather Armor","§8§lSet Bonus:","§7 On Sneak:","§7Invisibility§9 45 Secs","§7Speed §3II§9 45 Secs","§7Jump Boost §3II§9 45 Secs","§aCooldown§7: 30 Secs","","§7 On Sprint:","§7Speed §3I","§7Jump Boost§3 I"]}}
XX ➜ Base of the command, /give
XX ➜ Selector, @p. In this case it runs from where the player that runs it is standing so it does the same thing as @s
XX ➜ This is the item. We're going to start with the boots. I like Chainmail because it has good armor for the purpose of being a ninja.
XX ➜ Count. This is just the number of items you get.
XX ➜ Data value. Used for blocks with multiple textures, like stone, or items with damage like these. We want it at Zero because otherwise the durability wouldn't be full when you get the item.
XX ➜ The first NBT tag. This specifies what the item will be like. This specific tag talks about some smaller ones that fall under the display category.
XX ➜ The Name. This is one of the few things that will actually be changed when you create the rest of the set.
XX ➜ The actual name. §d§l for Purple and Bold. Assassin's Boots because you are going to be making the boots first
XX ➜ The lore. Also like the tooltip. I use it to describe the item and all that it does. However, as of the moment it means absolutely nothing
XX ➜ First bit of the tooltip. I am eventually going to retexture using the Optifine CIT patch to make it look like leather armor when you give it the certain name. Yes it is possible.
XX ➜ I like to do set bonuses instead of individual things because it means only one scoreboard to be made for the detection of the armor
XX ➜ This will be the condition. When you sneak this happens though as of now it means nothing.
XX ➜ This is now what it says it will do. The invisibility bit.
XX ➜ The speed bit
XX ➜ The jump boost bit
XX ➜ Cooldown. That'll be fun to make. You'll learn soon.
XX ➜ Line break
XX ➜ Condition again, this time on sprint.
XX ➜ Speed bit again
XX ➜ Jump boost again
Now that you've seen that, what it basically will do when you finish is be the ultimate assassin's armor. When you sneak you get 45 seconds of complete invisibility. When you walk it's normal but when you run you're a ninja who can out speed and out jump normal players. And this all happens with nothing but functions. Anyways, now for the next one, Setup.Setup.mcfunction

Spoiler - click to reveal
  • Hidden content here!


  • %MCEPASTEBIN%
    Become a member to vote!
    Posted by 0rlando's Avatar
    0rlando
    Level 1 : New Network
    0

    Create an account or sign in to comment.

    7

    1
    01/04/2018 5:34 pm
    Level 57 : Grandmaster Engineer
    ShelLuser
    ShelLuser's Avatar
    Why the dislike for notepad++? Makes little sense to me, also because it could make it easier on players to add color codes to names and lore which could be a lot of fun too if you want to create customized items.

    Of course that's also doable in plain notepad, but a little more difficult because you'd have to escape the § character with a Â.
    1
    01/04/2018 5:52 pm
    Level 1 : New Network
    0rlando
    0rlando's Avatar
    Believe me I love notepad++. However what it does is with those very custom lore and named items is it reads the § wrong and it becomes as if none of the commands have them which makes lots of purple and ugly. Believe me I've tried with notepad ++
    1
    01/06/2018 10:12 am
    Level 57 : Grandmaster Engineer
    ShelLuser
    ShelLuser's Avatar
    Then you're most likely using the wrong encoding. If you use plain UTF-8 encoding then there won't be any problem. The best part is that you only need to use the well known § character and forget about escaping.

    Just make sure you don't use BOM typed encoding, only plain UTF8.
    2
    01/06/2018 10:48 am
    Level 1 : New Network
    0rlando
    0rlando's Avatar
    I stand (sit) corrected. Thanks, I'll take out the part that says no notepad++. For some reason it just didn't work on my previous computer but it does on my new one.
    Thanks again
    01/04/2018 1:00 pm
    This reply was removed by the poster or a moderator.
    1
    01/04/2018 2:35 pm
    Level 34 : Artisan Birb
    Karrfis
    Karrfis's Avatar
    you changed some things and it needed approval, all sorted now
    1
    01/04/2018 9:53 am
    Level 4 : Apprentice Network
    DeepestDesires
    DeepestDesires's Avatar
    Nice requirements....
    1
    01/04/2018 10:15 am
    Level 1 : New Network
    0rlando
    0rlando's Avatar
    Bam fixed requirements.
    Planet Minecraft

    Website

    © 2010 - 2024
    www.planetminecraft.com

    Welcome