Hello everybody Welcome to today’s special episode about armor stands we’re going to be creating a plugin for 3D drops that’s right it’s going to be pretty damn amazing now I have one ask to you guys please subscribe to this channel if you haven’t already most people are watching this for free and They never even subscribe takes me a lot of work and effort to make these videos the least you can do is give it a nice Thumbs Up And subscribe before I reveal this code to you and yes of course the full source code will be available able At the end of this video I’m going to reveal the link however it’s not advisable that you just copy paste this you should understand line by line so please keep watching also if you want to learn more about Minecraft plugins even if you’ve never coded anything we have project Orient course that includes a full Java training a full 30-day money back guarantee and of course it has live coaching calls because why not I’m on there and I’m going to review your code personally the link to the course is in this video description so the first Thing I’m going to do I’m going to be listening to a new event when the player drops an item and by the way guys if this sounds like too much if you don’t understand what the event handler means and what the public void means you need to learn Java project Orient can help You with that however if you just want to learn about the event handlers and how to catch different game events I do have a fre video it’s one of the First videos in this Minecraft plug-in tutorial uh development Series so just look back and I’ll explain how these Events work so basically what we have to listen to is whenever I drop an item like this right and then we have to inside this event what I’m going to do well first of all I’m interested in getting the dropped item so I’m going to get event. getet item drop like this one The item is not the same as item stack if you’ve coded for plug-in uh for bucket before the item stack is an abstract class holding the same information which you have in your inventory such as hell break has a custom name whereas the item represents an actual entity that means this flying Thing is an actual item uh is an actual entity sorry and this invisible armor stand is also an entity so big difference here the item is an actual entity that ticks in the world exist outside of your inventory whereas this only holds uh information about the Actual item so if you want to get the item stack from the actual enery all you have to do is call get item stack on there just to make that very clear now what we’re going to do we’re going to make a new bucket runable that’s right And we’re going to be running this run as a timer then we have to pass in the instance that we made a couple of videos earlier and then basically I’m going to be starting this right away and then every single tick or maybe for performance sake I can increase it to Every two ticks so 20 ticks equals to 1 1 second right so so pretty much 10 times per second we’re going to be checking if the item is on ground and if the item is in fact on ground then awesome because I can cancel the task I can Delete the item and I can actually spawn the armor stand also important thing if the item for some reason is dead or is no longer valid for example you have an antiac plugin I also want to just cancel the ask and return the code how because then it doesn’t make sense to spawn Anything now what I’m going to do I’m going to get the items location and if you get the location of any living entity this is going to return a clone of its location so even if I add some some things into it the entity will not move because the modification will only Happen inside your code here since this returns a clone now when I’m going to get the location I do want to make sure to add plus um 0.5 to the xaxis and minus 0.5 to The Zed axis and then decrease the Y AIS by 0.8 reason being Is that if I did not do that then these items will appear you know with an offset it’s going to appear weird like it’s going to it’s instead of it being here it’s actually going to be there right and so or it’s going to it’s going To be floating in the air you can of course not do this and then just see what I’m talking about I just spent a couple of minutes looking through the F3 right and tweak in the position you can of course tweak it further to achieve maximum Perfection the first thing the Other thing we need to uh Delete the rotation from the item because then it’s just going to look weird although maybe you can keep it right because all of these as you can see they have the same rotation so I keep that up to you of Course in this video I’m just going to give you the basic setup if you want to learn the more advanced version check out project orian or you can try playing with this yourself and then what I can do I can can get the world and I can Simply spawn at the given location the custom armor stand entity now first things first we have to do we’re going to set this enery not to be visible and I’m going to disable its gravity if you don’t do this the armor stand is just going to fall through the ground if you Don’t do this properly and if you obviously set it to visible maybe I can show this to how it’s going to look like you’re you’re actually going to see the entire stand and then we also going to set the arms to true this is going to Set whether this has arms or not and then we can actually set the item in hand to the arms and set it to item get item stack as I explained earlier so next up what I’m going to do I’m going to actually Mark The Entity with invisible persistent data container I do Have a full video on how this works so I’m not going to explain this in details but basically what this will do this will set a custom item drop time which is a key that I created a field four right here in a separate Keys class so You can just create the same and basically Asser assert the current time in milliseconds which is going to be a long type this is really stupid that they have to that you have to explicitly set the type that paper cannot figure it out from the actual system but if you Look at this this method it’ll return long right here so basically just duplicate the same return type and why am I doing this well because if I drop the item you can see that there’s a slight delay and this simulates vanilla when you drop it you have to wait for as Much as you want before you can actually pick it up cool so that’s the first thing I guess that’s pretty much it for the start of course you can play around with the armor stand more and if you want more rotation with the armor stand you can get the arms right here for Example you can get the right arm pose and then you can simply use the set methods to set its angle you can just you can just experiment with this and you’ll see how that is going to work on the screen I think it’s the best if you See this visually on the screen great in the main class what I’m actually going to do I’m actually going to just duplicate the scheduler task and the reason we don’t use bucket we use task I believe yes because we added Folia support so if you don’t have this code Which you sure don’t you can check the video that I put out about Folia or you can just stick with bucket and in this case you you’re just going to need to type bucket enable and if you don’t understand how tasks work we have a custom video that I put out about bucket Task I believe it’s one of the first 10 videos that I put up so I’m just going to duplicate that field there we go and then I’m just going to create this as a timer it’s going to run for every say two uh ticks and then this One tablist task I can just duplicate this right here and be item pick up task like this one there we go and here inside I can just delete everything clean it nice and smooth there we go and then go back here and type in item pickup task and also don’t Forget to add reload support right here I can just cancel it when the plug-in is being disabled or reloaded now inside this thing right here what I’m going to do first of all I have to iterate through all players that are currently connected there we go and then we have To find if they are nearby an armor stand let me just finish up the Imports so basically I’m going to create a custom field here and then I can take advantage of the player get World get nearby energies method provided by bucket which is going to take in the center location right and From the center location I want to have a look at the XY Z3 so the radius is going to be three blocks and then this is the filter so this is actually a new predicate let me just show this to you the good good old way and this one will Return if the enery is an armor stand right and this whole thing can then be simplified to Lambda looking like this however if you are pro then you can just use method reference and call the class is instance method not a lot of people actually know about this which is pretty Cool great so this is the first thing how to automatically get all of these nearby entities in case I’m standing less than three blocks away from them and then if and then this one is actually remember I was uh tweaking the location inside the listener I was Adding this so here I just subtract this location to make it closer to the player to add to the accuracy if I’m standing less than 1.5 Blocks close as you can see how this will work right so if I’m standing oh there we go that was about One block and then 0.5 right so if I’m standing close to it then automatically I’m going to be um collecting that item that means that I can assign the first item to collect to the field and then just break out of that Loop and then we Have to check if the item was found otherwise nothing will happen and then I have to get the time that it was placed or time dropped so item drop Time by opening the persistent data container getting the key and then again I have to specify this long thing don’t worry About that too much and then this one cannot actually be a primitive type because if you open up this this get method it’ll it’ll say that it’s nullable so it can actually return null Java will complain if you use Primitives and return null to them because they Need to have a value however you can use wrapper type and rapper type can also can be null so here we can simply check if the item drop time has been set and then if the time right now minus the time so this is the current time which Is always going to be greater minus the placed time if the difference is um greater than 800 milliseconds which is 0.5 seconds then what I can do I can get the item in main hand and then okay so I can delete this check if the item is not Air and if we have a slot ready to collect the item in the inventory meaning that there is an empty slot to it then what I can do I can just play the player a nice entity pickup sound and then I can just add the item from The ground to the inventory and then finally I’ll just destroy the uh the placed entity the armor stack right here so it disappears if you didn’t do this you could just collect you know duplicate as many items as you wish which is obviously not desirable anyways Guys let me Crack into the game again let me check if everything is working correctly awesome guys so if I drop anything you can see that the armor stand actually appears this is because I deliberately desable this just to show you how this will work however if I make This armor stand invisible and I place an item there we go now the item appears on the ground and this works for 3D items as well as these 2D item models and even for swarts and armor which actually makes them look pretty damn cool when dropped the only thing that I Didn’t do is I didn’t make them automatically rotate so the sword will always appear in the same rotation this is something that you can actually do as a homework for this video as an extension of this training which is going to be cool and you can also see That when I’m getting closer to them I can actually collect them right however I can’t collect them right away so if I place them I have to wait 0.8 seconds before collection so it simulates buckets Behavior plus also I don’t know if you can hear it but there is nice pop Sound anyways guys that’s it for me for from me for today I hope that you enjoy this very cool stuff again we have project orian with me personally seven weeks of coaching including this including so much more it’s very Advanced doesn’t require you to have any coding experience I’ll leave the link For it in the description check it out if you want to learn more otherwise I hope that you enjoy this video subscribe to the channel if you haven’t already comment below give it a nice thumbs up if you enjoyed and I’ll see you next time by the way as I mentioned the link With the source code is in the block post and there is a link to the block post with resources uh Below in this video thank you cheers Video Information
This video, titled ‘Ep46. Armor Stands Hacks – Minecraft Plugin Development’, was uploaded by Matej on 2023-12-14 17:00:20. It has garnered 329 views and 16 likes. The duration of the video is 00:13:44 or 824 seconds.
In this sexy video I will show you how to create 3D item drops using invisible armor stands.
In this video, we’ll cover:
– Armor Stand hacks — All the juicy stuff about armor stand manipulation such as Euler angle tricks etc. – 3D realistic item drops — How to drop them items on the ground like a boss.
== COURSES == Minecraft plugin development: https://mineacademy.org/project-orion?st=yt&sc=tut_ep46 Forge Modding: https://mineacademy.org/forge-mastery?st=yt&sc=tut_ep46
== RESOURCES == Blog post: https://mineacademy.org/tutorial-46/?st=yt&sc=tut_ep46
#coding #code #tutorial #money #developer #java #minecraft #minecraftplugin #bukkit #spigot #spigotmc #paper #paperspigot #programming