This utility file contains methods which are in my opinion commonly used inside of the API but sometimes take a little bit of work to actually use for example the get entity from view direction or get block from view direction and so on hope this helps you guys I'm still updating it
Here is the link: https://www.mediafire.com/file/4p40zhn32csefmr/utility.js/file
Here is a small example video in the video I was using my laptop that is why I type slowly
#Script utility file to help(Beginners) with scripting hope this helps
1 messages · Page 1 of 1 (latest)
Also forgot to add that the enchantment method currently only works for the armour I will add in the ability to target and item in the inventory via the ID also not all the methods have examples but they have descriptions on how to use them and all of the methods have identification for each of the parameters
So you know which parameter uses what
You should look into making prototypes of the core classes if you haven't already, it would probably this idea to a much more polished state
very nice by itself though
The thing is this isn't just about the core classes it allows you to do things like get the block IDs get states and even switch states of blocks with one of the methods and also I know what prototypes but I like using static functions inside of me class because of the fact that you don't need to go looking into for example the entity class to find certain methods or the block class to find others They're all just in one class called utility it means they're all combined together rather than spread amongst other classes
very true honestly, prototypes usually end up being a giant mess of file orgnaiztion (in my experience at least)
what's the extencion u're using for minecraft api??
i wanna move to vsc but cant find an extension to write scripts with
It's not an extension you need to get node.js and then you need to go to NPM and then you need to install the @Minecraft/server package and server UI package then you need to go into your vsc and using the terminal you need to paste the link that it'll give you to download it and press enter and it will download it once it's done that you'll have auto fills for the API in vsc you will need to keep up to date on the various APIs depending on if you want to use stable API or experimental API
Why would you need an extension to write scripts lol
I mean there are extensions that help writing scripts so yes you don't need one but they do help
some folks are starting coding using this API. Without any explanation they can think you would need an extension to get intellisense.
I get that
intellisense is very nice to have
Update
Ver 1.0.3
- added
itemInInventory(inventoryType, itemtype)Searches the inventory for the item. - added
getEntityHealth(Entitytype)Get the Entities Health. - added
setEntityHealth(Entitytype, value)Set The Entities Health - added
GetPlayer()GetPlayer in the world without the need for a for loop - added
GetQueryPlayer(options)Allows for filtered player searches without the use of a for loop - added
getQueryEntity(dimension, options)Gets filtered entity in specified dimension without the use of a for loop - added
setItemInInventory(inventoryType, item, slot, amount)Sets item in a specified inventory and slot
link in the first message
What is this?
It is a utility class Which can be imported into your scripts and contains methods that make it easier to write scripts without having to use things like for loops and also allows for your code to be cleaner and easier to read
bruh
To be honest,
You can just do world.getPlayers() instead of importing a function and its the same as typing your function GetPlayer() its just PascalCase
That's stupid and scripting is not that hard how does it make easier to write
yes but you still need to use a for loop in the code for it return the player methods and with the method in the utility class you don't have to do that and besides it is not meant to be for everyone anyways i created this for those who want to avoid using for loops and made there code cleaner if you don't like it then you don't have to use it have a look at this video and you will see why created this.
World.getPlayer()[0] returns the first player
Also you can do world.getplayers().find()
Or foreach()
Yeah well in my opinion using those functions whilst useful can make the code messy if you use it too much and I understand what you mean by using index 0 but you need to remember that people who are new to the scripting aren't going to know to do that they aren't even going to know what a for loop is let alone how to use find or for each that is the reason why I created that method for those people and as I said to the previous person you don't have to use it if you don't want to it's there for those who want it
bruh
you still used for loop inside your function
just typing a for loop won't hurt
the people who would use your utility atleast had to learn scripting in order to do anything with that player
Ik you mean beginners
but well who the fuck is the begginer who don't know how to loop players
It is not about guiding the coder, it is about making writing code faster and cleaner.
well if only that GetPlayer() make a code look ✨ clean ✨ .. okay....
Clean is ✨ subjective ✨
ok bro seriously what is your problem if you don't want to use it then don't simple as that i understand criticism but at this point your criticism is not providing anything to either me or or others if you think you can do better by all means do but there is no need for this attitude and if this continues i will report you also if you goanna reply to someone sarcastically you might as well not bother even touching a key on your keyboard act like an adult not a child have a good day. @jagged rune
your criticism is rather destructive than constructive
there are may who don't even know want the difference between a const and a let is so don't go saying things no know nothing about clearly you just have not helped may true beginners
they should learn javascript before even going into scripting api dev
but in reality they do not, so they struggle
yes i agree but people are notoriously impatient and some people like to learn by doing rather than reading
thats what I did for the most part
yeah same because i learned from yours and others scripts too along with a bit of reading and research here and there
you know that though, if you paid attention to me in GLM lol
I didnt post that many examples, but im glad that my stuff was helpful for you
But remember you also sent me examples of code privately
my memory
I forgot what I specifically helped you with though
okay bro calm down 😭
yea ok my bad dude I'm a very chill person you don't have to report me
I really was not wanting to critisize you ;-;
Let me make this clear it is not about you criticising me that I'm upset I'm okay with you criticising you have the right to do so but the way you responded to the person who was just simply letting their opinion be known that's what upset me because you in your response did not make it an adult response you made it a childishly sarcastic response that is what upset me I'm ok with you criticising me because criticism helps me improve not only my coding but the utility file itself
and also waste a lot of performance
if i was you i would use a custom script api npm and use .prototype to create the methods and also to simplify long things not to shortner alredy small things
a good example would be
player.inventory.container
instead of getComponent

💀 no way this was a real argument
the idea of the "project"(i think i can call that so) is good, but It'd be better if the functions did something really complex than
function GetPlayers(){return world.getPlayers()[0];}
or wrappers for the minecraft api itself
you could try to make caching via weakmaps for example to dont call the api's so much
The whole point of this project wasn't to do some complex things it was make it simpler for beginners to use because I know many beginners who don't know things such as for loops or try catch or error handling or even don't know how to begin a script that was the point of this project and yet people seem to be missing the point entirely perhaps I didn't make it clear enough Which is my bad but to put it simply I wanted to make something that makes the scripting API more friendly to new people with simple functions such as the get player function
Script utility file to help(Beginners) with scripting hope this helps
Script utility file to help(Beginners) with scripting hope this helps
well, now that makes sense the purpose of the project, even tho i dont think it makes sense to it exist, but, anyways, good job with the project
Well it does make sense for the project to exist because with the amount of people I have helped to don't know even the difference between a const and a let variable it makes sense for me but I appreciate that it may not make sense to you but thanks for your feedback I may try and make another utility file that doesn't actually use the API per se but uses more of the raw JavaScript capability
i mean, thats a javascript issue, not scripting. When i say it doesnt make sense for me to the project exist is that it sounds like you are trying to solve a problem that doesn't have anything to do with scripting itself. As you said, people who don't know tje difference between const and let, ajd peoole who dont know for loops, thats a problem with js, not the api
The problem is partially with JavaScript as you saybut it is also with people wanting to jump into add-on development but either not having the time or the patience to learn a scripting language beforehand before jumping into the deep end as I like to call it but if they use this utility file they can use it to write scripts and also learn from it by looking at the actual code in the description of the code that is provided along with the examples because the examples I tried to provide include snippets of code like how to use the item use after event and stuff like that. And since you require the API to do most of the interactions such as abilities with items and so on you really can't go without using scripts
An example would be me prior to the scripting API being released we had the event-based triggers and I had learnt a lot with those event-based triggers and when they were taken away I had almost quit add-on development entirely as a result but then I decided to learn off of other people's scripts and eventually got proficient enough to do it on my own
The point is that beginners that dont know for loops, cant know anything about scripting the for loop is the base, and they dont even know how to import a file
You should teach what a for loop is instead of going for an utility file that avoids it making teaching you the wrong way of scripting
Well that's why you're wrong because even though the method itself it doesn't use a loop the explanation and even the example is there so those people can actually see how a loop is used and even if they don't know how to import the file just yet they can also go into the utility file and see how imports are done and with things like vs code all they need to do is have the file within their file structure and type utility and then it's imported for them or did you forget that
If you don’t have the patience to learn, you don’t learn. There’s no shortcut other than using your brain
This is not about having impatience to learn though this is also about the fact that a lot of people learn by doing not by reading or things like that a lot of people are not the type of people to just sit there and read documentation for hours they want to try things and work out by trial and error I know because I did this very same thing when learning scripts myself I couldn't bring myself to sit there for hours reading documentation because I would have literally fallen asleep at my desk
Impatience is part of it yes but not the entire whole of the problem
And as I have said many times if people want to use it it's there if they don't they don't simple as that
So I don't know why people are still arguing over the usefulness of this file there are better things to do with life
You re right I’m just wasting my time
Why are you so passive aggressive??
am i? actually English is not my native language and its been a while since i talked in English, so im practicing, i might sound like that but it's not what i meant, it's just the way i can think on a phrase
What? i dont think so