Hello everyone and welcome back to part two of our creating trinkets and baubles rpg loot in minecraft last time we talked about making cool items with attributes such as this fancy piece of armor that does slow you down a little bit when worn but also has some illegal minecraft protections on it just Don’t don’t tell anyone um you can also do the same kind of thing with weapons uh we had the armor example in the pace been down from last week but that’s all well and cool so you can do this kind of stuff to make awesome rpg gear within your series but for our Purposes we’re going to go a step further now in this medium section we are actually going to learn about offhand trinkets that can give you potion effects when you hold them in your off hand this could be useful for something like holding a golden carrot in your offhand and that will give you Permanent night vision while players are walking around keep in mind this is kind of limited because there is only one offhand slot so the way we set this up even if you have many different trinkets in your world your players will have to decide what they hold in their offhand Whether it’s their normal shield or if they want a specific trinket for a specific quest then they can hold that as well but just like before we’re gonna head over to mcstacker to build ourselves a trinket okay once again we are in the slash give command on mcstacker and we are going to Try and make ourselves an offhand trinket that gives the player fire resistance while they’re holding it and as this is kind of a powerful item as it’s pretty much a permanent fire resistance effect as long as they’re holding it we’re going to make it in the Epic tier which for us can be purple so let’s go ahead and pick our item so we’ll say magma cream and i wanted to take a moment just to talk about when you select your trinket items for players now obviously minecraft has a limited selection of items so players Are going to look at this magma cream and go oh i know what magma cream’s used for that’s used for making fire resistance potions of course that’s true we have a limited library to choose from so when making our choice it’s important to pick an item that doesn’t really have Any other right-click uses in case players accidentally use them and what i mean by this is if you try to make a trinket something like a loaf of bread and a player holds down right click too long on that loaf of bread even if it’s in their offhand they’re gonna eat it And that’s not gonna make your players very happy so generally try and go with the more mundane objects even if they have crafting recipes your players can’t accidentally right click something like magma cream so we’ll start there and we’ll go ahead and add a name and this time we will call it the Lame guard bubble that seems appropriately fantasy and like i said for color we are going to switch it to light purple as this is going to be in our epic category now i mentioned before that you don’t have to add lore to your items but i think to let players know What this one does we will so we’ll go ahead and expand the lore section and on our first line we will write what this item does it provides fire resistance there we go and we don’t really need to color that you can if you want but i won’t and then I’ll actually add a second line so this one happens underneath our first one and say maybe that it’s an offhand item and this will let the player know that this item goes into their offhand because maybe we have some trinkets that also go into their main hand okay so that is our name And lore out of the way we don’t need to do anything fancy with that the only other thing that we’re going to do right now on this item is going to give it an enchantment now i know what you’re thinking you don’t actually want to add something like Sharpness or unbreaking to magma cream it doesn’t make too much sense so what we’re going to do instead is add the glint only effect now i might have mentioned this before what this actually looks like is when you’re adding the enchantment tags to something it’s just an empty array of enchantments right Here you can see a couple of square brackets and then a couple of curly brackets all this does is minecraft thinks that there’s an enchantment on the item but doesn’t actually have an enchantment to put on there so instead just gives it that shiny glint this is a Great way to differentiate to your players what is a trinket item and what isn’t okay now i know what you might be thinking we added an attribute modifier last time right and there is a slot for the offhand so we could just go in here and pop in the attributes and maybe add Some fire resistance when it’s in your offhand unfortunately it’s not that easy you see as i was saying earlier attributes really only affect statistics about players and entities and fire resistance is an effect it’s not really a stat of the players so adding that attribute won’t actually do anything so we can go Ahead and cancel out of that but as of right now we just have a fancy looking item that doesn’t actually do anything so what we’re going to do is actually go set up a little command block magic within the game so we’ll go ahead and copy and we’ll come back into the game Here and just like before we will paste it into our command block so i’ll go ahead ctrl v there we go you can see that this one is actually much more manageable in the chat and if i press our button oh look at that we get our Cool flame guard bubble it says provides fire resistance and an offhand item ah as that text is also purple maybe i’ll go back later and change that to like gray or something so it doesn’t doesn’t kind of conflict but that’s fine that’s fine for now so as you can see i have Our flame guard bubble and if i hold it in my offhand i i don’t have fire resistance i have nothing it has the enchantment glint just like we set up and it has our text but we have nothing else going on for us right now now in a second we’re actually Going to add the effect in a repeating command block simple as that so when the player has something in there offhand it will actually give them a potion effect but just before that i want to actually talk about something that’s really important which is detecting if the Player has a certain item or not which is going to be used in our command block structure here and over there as well this is actually a really really important thing to know for command blocks in minecraft in general and it’s something that i often have to re-google And bookmark just to remind myself because the syntax can get pretty confusing there are many videos and comments that go into it in depth so i’m just going to go over it once here and if you need to pause the video or find it elsewhere i recommend you do so to Get the hang of it basically what we want to do here is we want to detect when the player is holding the magma cream only in their offhand slot so we know when to give them a potion effect you can actually do this in a command block and it’ll look something like this We want to use the good old execute command and for us it’s going to be executing as at a as we learned in our selector video that’s all players and then we’re going to open and close the brackets now within the brackets we are going to say there’s a lot of different Criteria here that pop up but we are looking for nbt now very briefly if you don’t know what nbt data is i’ll talk about this a little bit more but i don’t think i’m going to really do a video delving into nbt data basically nbt stands for named binary tag or in Simpler terms they are tags that certain entities items pretty much anything in minecraft can have on them to help differentiate different aspects about them now as we are looking at all players holding the magma cream that actually is an nbt tag for them it’s the Inventory and bt tag so what we can do here is we can add a set of curly brackets indicating that there is going to be something within here about our npt we’re looking for and then the nbt that we want to look at is the inventory Nbt so go ahead and you can write your npt you can put a colon and then a set of curly brackets to indicate we’re going in deeper now if you’re ever curious as to what different nbts there are within minecraft entities blocks there are loads and i mean loads You can browse the wiki if you’re ever curious but i wouldn’t recommend overwhelming yourself i would look up very specific ones when you need them and learn them as you go or you could get overwhelmed very quickly but for now just know that we are going to look Inside of the inventory nbt data of all players so now that we’re in the inventory we want to point to the offhand slot to see if the magma cream or this specific magma cream is in their offhand slot and i also forgot to mention because this can be an array we Can put in some square brackets in case we want to check anything else within the nbt data of the player so the first thing we want to point to is the slot and luckily for us that is actually called slot and this is as far as i can Tell kind of arbitrary i’m sure there’s math as to why it’s numbered this but the offhand slot specifically is negative 106. and you put a b after that indicating bytes again not sure uh i i did look at there is a good image of uh what each slot corresponds to number wise in Minecraft but i’m pretty sure the offhand slot is the only negative one but again not too sure why that is regardless now we’re pointing at the offhand slot so we can detect if a player is holding something and they’re off hand now we want to look for a Specific item so we want to check the id of that item now because this is going to be a string we want to add our quotes here and we’re going to type in the namespace which for us is just minecraft and then the actual item itself colon Magma cream there we go now we do have to add a couple more parameters but for now i just want to show you what this looks like so if i go ahead and press done you can see that that has saved and we have our little button set up now if I go ahead oh we actually need to very quickly add a test so we can say run say true to the end of that to actually detect if our magma cream is being detected now if i go ahead and press this button you’ll notice that nothing pops up in the chat Don’t panic this is because we actually don’t have any magma cream in our offhand slot so if i go ahead and take this flame guard bubble and press f to put it in the offhand now i press the button and it says true because we have An item and not just any item we have magma cream in the offhand slot which is exactly what we were looking for now before the gears start turning and you think well that’s enough we’re done we can detect that magma cream in your offhand slot so why don’t we just move On to giving it the effects well something that you’ll run into in your early days of detecting items is this is very easily cheatable unless you become very specific for example let’s just say we don’t have the flame guard bubble this is something that we’re looking for in a dungeon but we Come across some normal magma cream and i think to myself hey these are the same item what happens if i put this in my offhand all right so this is just normal magma cream i hit the button and it still says true so no matter what i have in my offhand As long as it’s just magma cream which both of these items are this will return as true when we’re setting up powerful trinkets to have certain potion effects this is very easily exploitable luckily there is a way around this and that is just being more specific with your Actual parameters when detecting for an item so if we jump back into the command block here you can see we’ve currently ended after we looked at just the id for the item but we can go a bit further to detect the exact item that they’re holding in their offhand slot for this Though we’re actually going to have to go into the tags of the item so if i go ahead and write tag and these are the specific parameters that we actually gave to the item things like its name its enchantments and stuff like that so we’ll go ahead and say tag and then a Few more brackets oh and make sure you add a comma between your different parameters here all right now within tag uh the first thing that we have on our item is the name so we want to go into the display section of the item with another colon and another Two brackets and this is where it starts to get really messy don’t worry i’ll have all these commands down in the paste bin i think it’s important to learn uh and to create these via repetition so you can at least know what you’re doing in the future but for now If you just want to copy and paste these commands from pastebin just to test if they work feel free to do so and skip ahead in the video all right after display comes name and then because the next could be an array of text we will have our single quotation marks right There on either side and within that we will put another set of curly brackets because now we’re actually editing the text array within the name now first we want to check the actual text value of the name so we can set up text like that and because that’s a string we need it In our double quotes and we’ll put our little colon and we named our magma cream the blame guard bubble again this is a string so it also has to be put in double quotes and we can’t just stop there because we actually altered more than just the text of the flame guard Bubble we also edited the color of the name if i add a comma we’re still within the name parameter here we’ll add our double quotes again as this is a string we can say color another colon and our color was light underscore purple according to mcstacker So there we go okay luckily we’re done with the name but we still have to go over the lore so we can get out of the array for the name but we’re still in the display so we’ll put a comma after that and we will write lower with another Colon and this one could be a large array of items because we’ll have several lines so we want some square brackets and within that our first set of curly brackets now again because these could be an array of text items we want our single quotes just outside the Curly brackets and then same as before we’ll start with text we said divides fire resistance like that and our double quotes there luckily we didn’t color this one so we don’t have to change the color now that is our first text but we did create another Line so just jumping out of this uh text array here we’ll put a comma open up another text array with two single quotes and then another set of curly brackets this indicates that it’s actually on its own line and for our final time we will write text And we said offhand item now it’s really important to make sure that all of this is case sensitive if you accidentally write a lower case here and your magma cream has an upper case then it will not detect the right magma cream okay now we’re pretty close to the end but if you Remember there was one more thing we added to our magma cream to make it unique and that was the enchantment glint so if we move to this text array we are getting just to the outside of lore which is that little uh box right there and if we move out one more that Should be just outside of the display tag so now because we’re still in the tags of this item we’ll go ahead and put a comma to add another tag now that we’re out of display and this next tag is the enchantments tag and just like i showed you on mcstacker This is a set of square brackets indicating that there could be loads of enchantments but it’s just an empty enchantment so you can go ahead and put a set of empty curly brackets this will just give it the glint and your end of the line should look something like this So if any of your brackets messed up and you want to pause the video here this is what the end of your whole line should look like now i know that was a lot but we made it through we put every single parameter of our item in that command Block again you don’t have to do this you could work on maybe just the name or maybe just put in the fact that it is enchanted but the less specific you become the more your players could exploit this believe me running these tests on servers just proves that people Will go to any length to mimic epic or legendary items but now what happens we’ll pick up this magma cream again i’ll put it in my offhand and if i press the button it does not ring true anymore but if i go ahead and swap for the flame guard It still says true that’s because all of our aspects of this or not that one of this flame guard bubble we have written into this command block now so now only this very specific one and any clones of it that other players may have will rang true when we’re looking for it in The player’s inventory so that was just sort of a mini tutorial on how to detect for specific items because you will very much need that skill in pretty much anything you’re doing when it comes to advanced command blocks uh whether it’s our boss tutorial later on or even the Previous pumpkin boss tutorial i use this a lot like with the hopper detecting the certain slots and things like that so this is a very very important thing to know but now that we’ve done that we can move on to actually giving the magma cream some functionality so if we come back over Here we can just ctrl a ctrl c to copy it all we’ll come into this repeating command block here set it to be always active and repeating and we will just paste the whole thing now you’ll know if i actually hit done here and put this in my offhand this Just does what this command block was doing but on repeat we don’t need to do that but as you can see we’re getting closer to the functionality as now we have something that happens all the time when it’s in my offhand but what we don’t need is the Text saying true all the time what we want is to run the effect command and we want to give at s which is the player that we’ve already checked earlier the one that’s holding this offhand item now that could be anyone multiple players on your server a single player no player But that player or players that’s holding this magma cream that’s what at s means and we’re going to give them fire resistance like we said from the beginning and just for a couple more parameters we will give it to them for two seconds uh with an amplifier of zero We don’t need it to be any stronger and we are definitely hiding those particles and i will click done okay now for the moment of truth we already know that we can detect this specific magma cream in our offhand can we also make sure the player has fire resistance For as long as they hold it in their off hand well i have it in my normal hand and i don’t have any effects but if i go ahead and press f you’ll notice the chat is thoroughly spammed but if i hit inventory sure enough we have fire resistance and it’s currently Flickering between one or two so this is just a quick time to note uh when you are messing around with stuff like this whether you are an operator or you’re working on stuff on your server it’s probably a good idea to turn command block output game rule to false so You’re not constantly spammed with these chats of your repeating items for our purposes though i will keep them on because we will actually need to see if things are successful or if they fail but if i go ahead and press f those chat messages will eventually disappear and So will my fire resistance after just two seconds i’ll show you that again f to take it out of my hand and it just counts down now that’s the reason why we just give the player two seconds of fire resistance because pretty much as soon as they take the trinket off of their Offhand maybe to swap to another one we actually want that to end so it’s only effective while they’re holding it conversely we could change this to be i think whatever the max is uh 990 yeah like that uh six nines in a row like that we go ahead and hit done and i Press f you’ll notice it actually looks a lot better now it’s not flickering we have these nice stars it’s like we have it for infinite time the issue of course then becomes if we take off the flame guard bubble while it still looks really nice we just have permanent flame resistance So your players could just swap all their trinkets in and out really quickly get every potion effect under the sun and not actually have to worry about keeping one in their shield slot so unfortunately unless you want that functionality for some reason uh we are Going to go back and just set it to be two seconds and that’s a good place to wrap up for this second part so in this part we learned that you can not only make trinket off-hand loot but you also don’t have to stick to things like giving it max health or increasing Your movement speed you can actually have potion effects be applied to the player when they’re holding something in their offhand so only one more part coming up after this and that is the hardest one where we learn to do a little bit extra with your inventory slots for trinkets within minecraft but for Today’s video that’s gonna do it so thank you guys all so much for watching if you enjoyed make sure you leave a like down in the video it does help the channel out a lot consider subscribing if you like these type of tutorials we’re trying to make them a lot more Often these days um and yeah until next time guys see ya Video Information
This video, titled ‘Creating CUSTOM TRINKETS in Vanilla Minecraft 1.18+! (Part 2) – Equippable Potions!’, was uploaded by MudkipNinja on 2022-04-15 17:00:16. It has garnered 3815 views and 157 likes. The duration of the video is 00:19:08 or 1148 seconds.
Part 2 of 3 in creating custom equippable loot using command blocks.
Ever wanted to have custom artifacts and armor you can equip without the need for mods like Curios? Well now you can!
In the second part, we continue on what we learned last time, and create an item that gives effects when in the players offhand, but with some command magic, we can have it give the player permanent potion effects when equipped!
https://mcstacker.net/ Pastebin Example Fire Resistance Bauble: https://pastebin.com/AjkZpjQ4
============================================================= 0:00 – Intro 1:12 – MCStacker trinket design 5:16 – Detecting offhand items 10:13 – Specific detection 14:37 – Testing the detection 15:26 – Creating the potion effect 18:23 – Outro