The improvement would be an array holding each item, at least thats how I would do it, then you could use a simple loop to get every item in the inventory (except for the armor) that would condense everything to like 4 lines of code
it's like taking a giant list of JSON data, and not parsing it, leaving you to accessing each element by rewriting the same parsing regex over and over again. it makes the code less clean and harder to work with, whereas you could just write a loop to parse that regex and output it to an array requiring much less work.
Yeah, minecraft calls stacks of items, you guessed it ItemStacks, and that is the class for those. I'm assuming t here is an entity, so all this does is take all the items from an entity's inventory as variables for whatever reason
Idk about #copyInventory, but there is getContents() which gives you the contents as array (with null for empty slots), and setContents which takes an ItemStack array
Damn, well I never looked at any source of Minecraft or API of it sounded very familiar and I guessed it right. Good to know tho. Thanks for the replies and upvotes :)
Another dimension, another dimension Another dimension, another dimension Another dimension, another dimension Another dimension, another dimension Another dimension, another dimension Another dimension
33
u/gillymuse Mar 11 '23
I'm curious what the improvement would be. What does the full code try to achieve?
15
u/MinecrAftX0 Mar 11 '23
I see a lot of repetition but honestly I'm not sure the best way to do this, because of the item names
185
u/Krupplefield Mar 11 '23
Leggings, Boots, Chestplate and Helmet... Why does it feel like Minecraft?
120
u/cashewbiscuit Mar 11 '23
If its minecraft, it's probably written by a middle schooler. Give them some grace. They are learning
31
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Mar 11 '23
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/AmyMialee Mar 11 '23
Where's it from?
2
u/sunflower65667 Mar 11 '23
No, a while would have been better.
2
u/Auxilor Mar 11 '23
classic spigot developer moment
1
u/[deleted] Mar 11 '23
What the fuck
1
u/AshPoppet Mar 11 '23
Minecraft intensifies
1
u/BrubMomento Mar 12 '23
This is minecraft isn’t it?
1
u/cavejhonsonslemons Mar 12 '23
hopefully self taught, then it could be justifiable, anyone who takes a coding class, and comes out writing this is a lost cause