Hello it is I dr. Bryan Oregon 111 and today I am the Mario maker it’s a me Mario get it I made Mario appear therefore I am the Mario maker and today in today’s episode of learning command blocks we are going to learn how to do how to make something Like this make scripted events where things happen over time which will be interesting because up until now we’ve only learned how to either make a bunch of commands run all at once in a row like these command blocks that say ABCDE or make things run in a loop 20 times a Second such as this command block right here that’s running after the purple but just get seeing loop over and over again what we haven’t learned to do is something you probably know how to do using kind of old-school redstone things like repeaters I could set up some Repeaters over here and print this out and it says 1 2 3 4 5 but there’s a little bit of a delay in between each of those commands and so what we want to do today is move into the modern day into Minecraft 1.9 snapshots and figure out How we can create a command a block that does the same thing that repeaters would do back in the day which is to create a delay between different commands so that I could do the same kind of thing over here and run this again and print 1 2 3 4 5 only with a delay among the commands and so we’re going to learn about that today so let’s get started potato chips I am back now in our learning command blocks world because that’s what we need to do some learning and to start things off I want to teach you guys about Scoreboard tags which can be used to identify a particular entities in the world so as we’ve seen before I could summon an armor stand and we know from drawing the checkerboard and serpents each triangle we know that we can move things all around I could say teleport @e type equals armored stand till the 1 tilde tilde in order to move it 1 to face the X direction just like that and it will teleport the armor stand which is pretty great but something you may be aware of that we haven’t really discussed before is if I Were to summon another armored stand over here and then I were to run this command again teleport @e type equals armored stand till the 1 tilde tilde both of these armor stands are going to move because both of them match the entity selector in the command the santi Type equals armor stand both of these entities are described by that entity selector and so we’re going to move both of them and so the question is suppose I only wanted to move this one but not that one how would I do it well there’s actually I mentioned when we first Learned about entity selectors or bout @e a few episodes ago that it’s actually a very rich mechanism and there’s a number of different ways that we could do things for example I could say type equals armorstand r equals 2 to only find the our stands within a radius of 2 of where I’m Standing and then this guy moves but that guy doesn’t because he’s too far away so that’s one way we can do things but what I really want to do is teach you guys about scoreboard tags because they’re very useful and versatile especially in programming and so let’s Go ahead let’s summon up fresh armor stand and I’m going to give this armor stand a tag by saying scoreboard players tag @e type equals armor stand ad and we’ll call him Fred tag Fred added so basically if this armor stand has now been tagged with a tag Fred and what That means is I could summon another R stand over here and then if I wanted to operate only on Fred I could update my entity selector in this teleport command teleport @e type equals R stand tag equals Fred to tilde 1 tilde tilde and only Fred moves and Indeed now that I have the tag since that’s the only entity in the world that is tagged with Fred I don’t even need the type equals armorstand I could just say a tag equals Fred and we’ll only move this our stand over here and yeah you can have a number of different Entities that have the same tag if you do have a group of entities that you want tag and so for example I could add a tag to this guy as well and have both these guys tagged Fred and move those two without moving this one the tag mechanism is very Versatile but let’s describe it in a bit more detail in terms of exactly how to tag x’ are represented in the world of Minecraft next step let’s learn another new command called entity data which will allow us to see the data that’s associated with entities so I’m going to Be summon an armor stand I’ve got a retag this our stand is Fred just as we did before but then I’m going to run entity data at E tag equals Fred to tell entity data to run in this guy open curly brace close curly brace and it’s Going to print a bunch of gobbledygook on the screen the data tag did not change and then all the stuff over here and these are all of the bits of data associated with this particular entity this armorstand and there’s some interesting bits it here for example over my cursor invisible 0b and right Over here you’ll see tags 0 Fred and so you’ll start getting a sense of how we just stored some data in that this entity saying that he was Fred and so entity data if you run it with just empty curly braces it just shows you what the current entity data is but we Could go and change some of the entity data for example I could say invisible can I spell invisible : 1 and poof the armorstand is disappeared and if we take a look at its entity data entity data updated 2 it’s the same stuff except for invisible is now 1 and similarly if I Ran the same thing again and said invisible 0 now it’s visible again because invisible has been converted back to zero and so entity data gives you a way to print out all of the data associated with an entity stored in its nvt data as well as make changes to some Bits of it for example invisible and as we can see in here oops after you get off the screen as we can see in here in addition to invisible there’s actually an array of eggs and so we could use entity data to actually set up tags on one of these Guys as well and so for example I could say tags and then arrays or in square brackets and let’s give them two tags this time let’s given the tag a and the tag B just like that and now it says this entity data has been updated and if We take a look at where my cursor is tags the 0th entry is a and the first entry is B so now this guy has two different tags to identify him and as a result if I try to run this command again nothing happens because the Command I just tried to run is looking for tag Eagles Fred and there’s nobody there but if instead let’s try to make him invisible if instead I say tag Eagles a invisible it turns the armorstand visible because he is tagged a and similarly I could make him uninvited Goolsbee because he’s also tagged B and so basically any one of the tags will match in the entity selector at E tag equals whatever so long as that tag is among the many tags that a particular entity might have in its entity data then it will match that entity selector For running commands and so as a result I could say teleport a D tag equals B tilde 1 tilde tilde and since this guy has the B tag he will be one of the entities that gets teleported one Square to the side finally you can put NBT data In an entity when you first summon that entity we’ve actually kind of seen that before when we have summoned armorstands with no gravity and so I’m going to do tilde tilde v tilde and then I’m going to say no gravity : one in order to summon a Fresh R stand that is going to hang in the sky but additionally I’m also going to give him a list of tags and specifically I’ll just give him one tag called floaties and so object successfully summoned sure enough there is an armor stand floating up here in The sky and he’s been tagged with floaties as I summoned him which means all future commands I can go ahead and address him using the entity selector let’s do entity data @e with a tag and so I can say tag equals floaty as a way to address that particular entity whose Hanging up in the sky and I could say for example no gravity : 0 and now gravity affects the sky and so basically by summoning entities with tags we immediately get a name or a handle or a way to address that particular entity and that is going to be very useful Because it’s very useful to be able to act on a particular entity in the world rather than all the entities of a particular type I’m now in a fresh copy of the learning world because I want to show off what could go wrong when you don’t specifically address particular Armorstands this is the sierpinski triangle drawer that we made last time and it’s just teleporting all armorstands under the assumption that this one armorstand who is kind of like the cursor of the drawing thing is the only armorstand in the world and so long as that assumption is true everything Works fine but you may recall that we have other things that use armorstands in this world such as Z and so recall that I could use nudge Z in order to nudge these blocks over or to nudge them back and nudge Z works it’s pretty self-contained and works on its own but If it’s the case that this thing is running and teleporting all armorstands all the time and I try to run a nudge Z at the same time which also uses armorstands then all manner of bad things might happen in this case it didn’t nudge things and I think something actually just happened above Me in the checkerboard pattern over here can i replicate that we put some more blocks over here and try to run nudge Z again alright it did not move any of these blocks yeah and it did weird things the checkerboard up here so basically we completely broken uh Jersey By virtue of the fact that this guy is teleporting all the armor stands in the world rather than just the armor stand that he is responsible for and so in terms of the best practice when programming with command blocks I would suggest for any entities that are going to be long-lived entities there To be doing number of things with make sure you summon them with particular tags and then address them with those tags so that you don’t end up addressing all of the entities of a certain type in the world because doing so is very dangerous because it could interfere With other mechanisms that are also operating in the same world so we’ve learned about scoreboard tags we’ve learned that we can summon an entity with tags in it already and we’ve learned that we can use entity data in order to see the all of the NBT data associated with a particular entity as You might be able to guess and I think we possibly have seen a little bit in passing in the past in addition to entity data there’s also NBT data associated with blocks so for example if I sit down this command block that says hi I can have my Cursor on this block and I can run block data and say tab tab tab to fill out three coordinates that my cursor is currently on and once again empty curly braces and it will behave just like entity data except on a block rather than on entity and here’s the entity Data the data tag did not change condition Met is one auto zero custom name at powered command say hi you’ll recognize that one definitely XYZ coordinates control success count track output these are all the things associated with this command block and so if I change it to saying bye and I Run this block data command again we will see that it now says command say bye and we can also update things just like we could with entity data we could update the entity data kind of in place with block data we can do the same thing And so I could change the command to say hello and now I’ve updated the command associated with this block and if I right-click the peek inside it sure enough now it says say hello so entity data allows you to see and change the data associated with a particular entity And block data allows you to see and change the data associated with a particular block so far when we’ve needed the summon entities for our various programming contraptions we’ve used armorstands and when i first introduced armorstands I talked about the various properties that they have that make them a good for doing at Various command block programming for moving things around the world and it turns out in Minecraft 1.9 that they introduced another type of empty that’s actually a very useful for command block programming as well and it’s called an area effect cloud and so I’m going to summon an area effect cloud Let’s do tilde to tilde to tilde and if I do that it says object successfully summoned and should be right here and you don’t see anything here and the reason is it’s not there anymore because area effect clouds actually have a duration they will expire after a Certain amount of time and so let’s change things and say duration 100 which will be 5 seconds since ticks are 20 times a second it will last 100 ticks which would be 5 seconds so I’ll summon one of those guys up there but once again even though it should be asking For 5 seconds we don’t see it and the reason we don’t see it is they’re also invisible by default they don’t have any kind of rendering thing by default but if you hold down f3 and press B that will change things so that you can see hitboxes on entities and it shows the Direction that they’re facing and so once again that’s f3 + B to toggle its but basically this shows the hitbox of this armorstand and shows the direction that the armorstand is currently looking and so if I go ahead and try to summon that area effect cloud once again aha There is here is the area effect cloud who’s looking this way but he only lasted for 5 seconds we gave them a duration of 100 and then you went away let me give them a duration of a thousand so he’ll last a longer time so We can see I’m on the screen for a bit but area effect clouds like armorstands have a couple of properties that make them super useful for doing certain types of things one is they have no collision they can travel right through players can travel through them and mobs Can travel through them there’s nothing to collide with they also don’t collide with blocks and so an area effective lab can like live inside of a block and that’s not a problem it’s still there just fine I can break the blocks all around it kind of doesn’t interact with The world in that regard they don’t have gravity which means once you summon them in a certain place even if it’s in the sky they’re just going to sit there and they have this duration they have this age property which can be useful in and of itself to both to make them kind Of go away after time as well as kind of like make them automatically counting ticks in the scoreboard our fifty seconds is expired on that guy and so he just went away but let me summon him again for a thousand ticks another fifty seconds and if I do I didn’t give this Guy a tag when I just summoned him but I’m going to do entity data @e type equals area effects cloud with empty curly braces so we can see its data tags the data tag not change and so if we look through the data tags here at the Very end I will see age 350 and if I run it again now age is 611 and so basically every tick disguise age is counting up now it’s up to 755 and so that just keeps counting up and up until eventually it reaches whatever we set as The duration tag and I can see it right here duration 1000 and so basically once it reaches a thousand and it just did then the area effect cloud disappears because that’s what area effect flouds do what they actually do is they’re meant for setting up lingering potions so kind of Like potion area of effect things where you could have you know like a poison cloud that was sitting here and if you walked into it you get poisoned and eventually would dissipate over a small amount of time but just like armor stands in terms of survival minecraft Are kind of made for hanging hanging armor on them area effect clouds are made for lingering potions but if you are a programmer a minecraft command block programmer you don’t use entities for what they were intended for in survival minecraft instead you use them based on the properties that they have And the fact that area effect clouds have no collision the fact that they float the fact that they automatically age and expire is very useful for a number of contraptions such as delays potato chips so let’s come back to this little Mario World and you’ll recall that we had some command Blocks here that were behaving kind of like repeaters and now it’s finally time to take a look inside this command block and see exactly what it’s doing it is summoning an area effect cloud one block over in the z direction with a tag n ticks later and an age of negative 8 and Somehow this is making these commands run and sequence after a little bit of delay and the somehow isn’t magic I guess you could call it magic but really what it is is it’s these command blocks right here so I have a command that’s running a loop over and over again and It is running these three things let’s take a look what they do the first one says tag every entity that is n ticks later and I can’t remember if we’ve seen this in scoreboard commands before but at the very end of the scoreboard command you can look for specific NBT Data and it will only affect entities with that NBT data and so we’re going to tag everyone whose tags and n ticks later and whose age is exactly negative 1 that is an age value that’s exactly that as we count up we’re going to add The tag end ticks later done and then at every n takes light are done entity we are going to say block data Auto one B and then execute it at that same entity we’re going to say a block data Auto zero B and that’s going to turn on and Off a command block at that location and so basically we have an area effect cloud that I’ve given a negative age so it’s starting at negative 8 and kind of counting up towards zero and right before that area effect cloud expires it’s going to get a new tag and as a Result then these blocks are going to see that new tag and cause Auto one B to be toggled on a particular command block and you may recall there’s down here needs redstone and always active I turn to always act this will say 5 and needs redstone versus always active the NBT Commands are auto zero and auto 1 which we can see looking at the block data so if I do block data tab tab tab to look at the NBT data inside this command block we will see that is currently auto zero B zero and it’s just a byte and so the B Just means bytes but in any case it has an auto value of zero if I toggle it to always active and then I take a look at its block data everything else is the same but now Auto is one B and so always active it means Auto one and needs Redstone oops means Auto zero and so basically toggling between Auto zero and Auto one is the same thing as toggling between needs redstone and always active and whenever you set an orange command block to always active that actually runs the command you see each time I’ve Turned it to Auto one or always active it’s going and actually saying 5 in the chat and so now you probably have a good sense of how this mechanism works basically I’m going to run this command and it is going to say 1 and then summon An area effect clad with an age of negative 8 area effect clouds automatically age their age increases by one every tick so eight ticks later eight 20th of a second later this thing will dissipate but before it does seven ticks later it will get up to an age Score of negative one and then this logic will kick in and it will execute at the location of the area effect cloud which is inside this block it will then execute Auto 1b and auto zero B which will quickly switch this guy on and off Which will cause him to say 2 and then make this one run which summons a new area effector out over here and a few ticks later this one will wake up and say three and summon an area effect go out inside this block and so that is how We can kind of emulate what repeaters give us with command blocks but they’re much more flexible because repeaters if you know how repeaters work they only give you kind of four time settings 1 2 3 & 4 with these we can use any number that we want and so for example if I Wanted to wait 5 seconds between 1 & 2 I could say age minus 100 and 100 ticks is 5 seconds so now it’s gonna say 1 and then it’s going to wait for 5 seconds before this area effect cloud disappears and then say 2 3 4 5 and the other ones still Have the short delay that they used to have before and you’re probably noticed on the screen that there’s these crazy particle effects area effect clouds give off particle effects that particle effects if their age value is less than their wait time we didn’t take a look at Wait time but it defaults to zero and so we’ve got negative ages but I think it’s actually kind of cool to see the particle effects so you can see where the area effect clouds are and how they’re kind of like moving through the system or expiring in the system and the New ones get summoned but the long and the short of it is by adding these four blocks into your world that just look for area effect clouds with an age of negative one and then cause the corresponding blocks to get black theta toggled between 1 and 0 you can Basically create kind of repeater delays inside command block chains but then wake up the next orange in order to kind of start a new chain of commands and we can do that then in order to run all kinds of cool scripted behaviors where things take place Over a certain amount of time such as our Mario maker over here where we’re summoning a zombie wearing certain pieces of armor who takes some time to walk around the corner and simultaneously we have a bunch of blocks that play sounds in order to play different notes at a certain kind of Frequency and amount of time in between them in general in the early episodes of these programming tutorials learning command blocks I’m going to focus more on the programming and less on the Minecraft but I know people will be curious about this and so in order to Play this music I am using the play sound command in each one of these orange blocks to play a particular note and you can change the particular note that they’re playing make the note sounds you know lower or higher in frequency by changing one of the Parameters over here you can look at the details of how the play sound command works but basically it’s just playing individual notes and then there are certain delays for ticks between these two eight ticks between these two eight ticks between these two there’s a long delay between The next 16 ticks between the last two notes of this little Mario riff but that’s all it is it’s a bunch of play sounds separated by a number of these different delay blocks that are all exactly the same except for they have different age numbers right here at the End and then inside a world where we have these command blocks that are always running and so that’s how the music goes and this just kills all the entities in the world but what we have over here that summons Mario and has him come around the corner and talk to us Basically summons zombie at a particular location no AI means he’s not going to try to walk around by himself silent means he’s not going to make any noise or like zombies always do tags Mario so that we can address him and then a bunch of armor items leather Boots leather leggings of a certain color leather chest plate of a certain color and a skull damage value three means a player head skull owner sethbling the guy you may know looks kind of like Mario they’re often confused in public and then once again we’ll wait for three ticks and we will Teleport him as 0.5 blocks to the side and we’ll wait for three more ticks and we’ll tell affordable point five blocks to the side and we’ll wait for three more ticks and teleport him 0.5 blocks to the side and it just so happens that that is kind of a good speed of movement Of slowly teleporting a zombie that it just kind of looks like he’s walking towards you and whenever you teleport a zombie or some other walking entity while they’re kind of along the ground the game as it’s rendering it just kind of like automatically does that walking animation so it looks like he’s walking Over and then at some point he makes a right turn over here because there’s part of the teleport command that we haven’t learned about there’s two other numbers you can give one is degrees in this direction and so we started out at 0 degrees then he turns to 90 degrees Which is looking this way and then the other number is degrees in this direction up and down and at the end if we take a look at this little scripted series I have when he’s talking to you he kind of nods his head it kind Of looks down and looks up and so if we go over to the end of this sequence over here we’ll see some more teleport commands oops where yeah we went from 90 zero which is looking directly this way to 90 20 which is still this direction And this axis 90 degrees but then 20 degree down angle so we went from 20 to 0 to 20 to zero in order to make him not his head a couple of times as we said it’s a me Mario so I’m not going to explain kind of all the full details of Those commands but hopefully that gives you a sense of what’s going on and how just by being able to teleport an entity around and have delays between different commands that run between different oranges that start other chains we can do all kinds of interesting things in terms of scripting little animations and Making little cutscenes here in Minecraft so I encourage you to go nuts with this kind of programming now you might try this yourself and discover that some things aren’t working as expected if I grab an empty impulse command block and say say hi currently needing redstone and I say a Block data of that block to auto 1 B which should turn it to always active and cause it activates block data updated but it did not say hi there is currently a bug I’m currently in a 15-week 37a you can see at the top of the screen there is a bug in command Blocks where the first time they are used they didn’t work properly by set redstone next to it actually let me turn it back to needs redstone if I set redstone next to it to activate it like that and now it says hi in the chat and then break the Redstone now this command Block will work and so if I do this block beta command boom it says hi and now every time I try to toggle from auto zero to auto one from needs read stoned always active it will work properly and say hi but in order to get it working the first time You have to do something my recommendation to you to avoid this bug this is a bug that Mojang knows about and Sarge says he’s fixed it and so the next snapshot is should be fixed but what I recommend to you is when you first get a command block when you first Get an impulse command block set it down on the ground put redstone next to it to activate it once then throw away this empty command block that you have in your inventory and instead control click on the sky which will now be a command block with MBT it’s still going to look You know empty in terms of all its other fields but now it’s going to be in the working state as opposed to the broken state that it is when you first put one down in the world and so just use this command block build with anywhere you’re Going to build or if you discover that one of your command blocks appears to be broken just set some redstone down in it when it’s in need redstone state so that it activates for the first time and yeah I won’t go into the details of the bug But it’s a simple bug and it should be fixed in a future snapshot but in any case that’s important for any time you’re trying to activate blocks with Auto 1b because that’s when the bug actually occurs potato chips if you want to add this delay mechanism in your own world it’s Really simple we just need a purple followed by three greens with the commands that are here scoreboard players tags @e tag equals n ticks later add antics later done for anybody whose age is negative one and then for anybody tagged with n ticks later done block data Auto one B and Then black data auto zero B is all that you need just always running in a competing loop and then anytime you want to introduce a delay if we take a look at the white command up on the top some an area effect out tilde tilde tilde one Or more generally in the area of the block that we want to wake up after some time passes tag it with n ticks later and give it an age of negative and however many ticks later you want things to run negative eight was my little Example right here and so we can see it actually working in an example over here where if activate the orange block at the top it will run this first chain the first three command blocks the orange one is empty but it will say say something but after two seconds someone an area effect Cloud tilde tilde tilde one will summon an area effect cloud down inside of this orange block right here that will wake up and time at negative 40 40 is 40 ticks is two seconds since it’s 20 ticks a second is how fast minecraft runs command box and so at two seconds later This orange one will be activated and then say something else and so if I run this it’ll say say something but after two seconds say something else and that’s all there is to it in terms of doing things with delays so to sum things up we learned about four major Things today first we learned about tags we learned ways that you could tag an entity so that you could refer to a particular entity in the world rather than all the entities of that type in the world we learned about entity data that one could use on an entity both to Just kind of print to the screen all of its entity data associated with an entity as well as to update some bits of entity data then we learned the block data command which like entity data goes and prints out the data associated with the block or allows you to update the Data associated with the block but works on blocks like command blocks rather than entities like armorstands and finally we learned about a new entity called area effect cloud that like armorstand which has a number of advantages and certain programming things area effect to out has a number of advantages in certain programming Things as well especially related to aging and delays and we used area effect clouds to make our delay mechanism and I’m holding a diamond sword right here I don’t know this is something that I showed off in creative mode but yeah if you are just trying to swing your fist To gesture at things you will break them but they’ve made it in creative mode such that if you swing a sword at things it doesn’t break them and so when I want to gesture as I’m talking at blocks I will hold the sword so that I can gesture at these signs without actually Breaking them but I’ll go ahead and break them now as well as this block apparently in any case that’s all for today I hope is always that you guys are having a great day and I will see you again soon for more learning mBLAQ’s bye-bye but wait there’s more I probably told some lies in this episode but I think this episode is long enough already for today so obviously there go forth I’m not going to give an explicit homework assignment but if you like making music you can always try to do something similar to what I did with the Play sound if you like animating mobs you can try to do that but I’d encourage you to play around with just trying to make certain events happen on kind of scripted delays because there’s a lot of fun things that you can do until then see you next time Video Information
This video, titled ‘Learning Minecraft Command Block Programming, Part 7 – Time delays’, was uploaded by lorgon111 – Brian’s Gaming Videos! on 2015-09-16 13:00:30. It has garnered 66633 views and 1149 likes. The duration of the video is 00:33:53 or 2033 seconds.
Mario maker incoming! 😛
I’ll teach you Minecraft command block programming! This series will help you learn step-by-step using the 1.9 snapshots of Minecraft for PC.
Today we cover time delays, which enable us to make ‘scripted scenes’ where events unfold over time.
This episode covers – scoreboard tags, added via ‘scoreboard players tag’ commands – the /entitydata command, for inspecting and changing the NBT data associated with an entity – summoning entities with initial tags – entity selectors using tags: @e[tag=blah] – the /blockdata command, for inspecting and changing the NBT data associated with a block – the AreaEffectCloud entity, another useful entity to summon – a tiny mechanism to utilize an AreaEffectCloud as a ‘delay timer’ to activate a chain in the future after N ticks Using these features, I show off how I animated ‘mario’ and played the music.
Teaching programming to a wide audience is a challenge. I’ll try to go at a slow, detailed pace that most viewers can follow. If you know a topic well, you might want to watch at 1.5x or 2x speed to skim.
Teaching complicated subject matter is a challenge. During an episode, I sometimes do ‘handwaving’, or tell white lies or lies of omission, for simplicity to teach beginners. At the end of each epsiode, I’ll have a segment where I try to clear up the lies I know I told, going into more gory detail.
Subscribe for more videos & tutorials here: https://www.youtube.com/user/lorgon111
This playlist: https://www.youtube.com/playlist?list=PLHYAYMSbpcvulT34yXXN6SjTgpi0bOgka
Follow me on twitter @lorgon111 : https://twitter.com/lorgon111