Hello and welcome back to another tutorial in the last episode we created an entity and today i’m going to be showing you how you can spoil that entity into your world both with natural generation and spawn eggs so let’s start with the spawn eggs in our common package let’s create a new Package called dot item and in here let’s create a new class called custom small egg item this is going to extend spawn egg item and we can hover over this and add a constructor we can see that we have these unmapped parameters here so let’s just rename them let’s change the properties to Properties and then make it a final item dot properties let’s change this to secondary color and make it final and then change this to primary color and also make it final and then let’s change this to entity and make it a final registry object of entity type and then we can press ctrl Shift o to import net.minecraft.item.item and registry object finally let’s rename these over here to properties secondary color and primary color and then we can just pass in null over here let’s create a protected static final list of custom spawn egg item call it eggs to add and set it equal to A new arraylist so then let’s press ctrl shift o to import list and arraylist and that should fix the error then we need a private final lazy of something that extends entity type of any entity i’m going to call this lazy entity then let’s press ctrl shift o to import Lazy and in our constructor we can do this dot lazy entity is equal to lazy dot of and then we can do entity colon colon get then let’s do eggs to add dot add this so now we’ve created our lazy entity supplier and added our egg to our eggs add list Now let’s override get type and we can pass this as our mbt data and all we have to do is return this dot lazy entity dot get next we need a behavior for when we use a dispenser with our items so let’s create a protected default dispense item behavior Behavior is equal to a new default dispense item behavior and then we can open a scope and enter the semicolon and in here we can override dispense stack let’s change this source to a source and this item stack to stack then inside here we’re going to get the directions let’s do direction direction Is equal to source dot get block state dot get dispenser block dot facing so now i’m going to get the facing property of our dispenser and then we can press ctrl shift o to import net.minecraft.util.direction next we’re going to need our entity type so let’s do entity type Of any type and let’s call this e type is equal to and we can open brackets and here we can put stack dot get item and we need to cast this to a spawn egg item and then we’re going to put dot get type and then stack dot get tag So now we’re going to be calling this get type method with the nbt data of our stack after we know what to spawn and where now we can actually spawn it so let’s do e type dot spawn then we need to get the worlds so source dot get world Then the stack null for the player since a dispenser is spawning it then we need to get the offset so source dot get block false dot offset direction then we need to pass in a reason for spawning so we can do spawn reason dot dispenser then we need to check if the direction Doesn’t equal to direction dot up and lastly we can just pass in false and let’s make sure to use the direction class instead of the variable next we need to do snack dot shrink one to make sure that we actually remove the spawn egg from the dispenser and next we can return The stack that was passed in to the dispenser and there we go that’s our dispense item behavior we can also make this static to make sure that we’re only creating one of these for all of the spawn egg items next let’s create a public static void called init spawn eggs so in here We’re going to create a final map of our entity type of any entity to our spawn egg item we’re going to call this eggs i’m going to set it equal to obviation reflection helper dot get private value then we need the class to access our spawn egg item Dot class then we need the instance which is a null because this is a static and then we need the string of the handle which you can get using the bot in our discord all you need to do is type exclamation mark mcp spawn egg item dot eggs and as you can see It gives us that spawn egg item dot x is field 195 987 under school b so we can just copy that and paste it into here then we can press ctrl shift o to import java.util.map and that will fix our errors next we can loop through our final spawn egg item item in Eggs 2 and and then all we need to do is eggs dot put then we need the entity type so item dot get type of null and then the item itself and then we need to register our dispense behavior so let’s do dispenser block dot register dispense behavior Of our item and behavior and finally we need to clear everything from eggs to add so let’s do eggs to add dot clear and there we go that’s our custom spawn egg class done so now we need to call this in its spawnings in our main class So let’s create an at subscribe event of public static void on register entities we need to pass in a final registry event dot register entity type of any entity and we can call this event and in here all we need to do is custom spawn egg item dot init spawn eggs Next let’s create our item in our item in it so after our example item we can create a public static final registry object of custom spawn egg item we can call this example spawn egg going to be equal to items dot register example spawn egg and then We need the supplier for the item so let’s create a new supplier of custom spawn egg item then we need the registry object of the entity so we can do entity types init dot example which is our entity then we need the primary color on the secondary color And then item.properties so we can do new item dot properties dot group tutorial mod item group dot tutorial mod in order to fix the error that we have here we need to go into our custom spawn neck item and change this registry object to something that extends Entity type and that should fix the error now we need to pass in our two colors all you need to do is google color picker then select a color for example this green then copy this go into here and put zero x and paste the color in And same thing over here we can put zero x then let’s go for this purply color copy the hex code and paste it in here and there we go we’ve created our spawning so now let’s create the jason’s for the spawn egg in our lang file let’s create item Dot tutorial mod dot example spawn egg and set it to example spawn egg and in models dot item let’s copy our example and paste it as example spawn egg.json and then we can remove the textures and change it to item slash template spawn egg and that’s actually It now we can launch the game so now if we open the game you can see we have our example spawning item and we can click it to spawn an entity and if we use the dispenser with it you can also spawn an entity and it will use one of our spawning so Next we’re going to cover how we can spawn this entity in the world naturally and all we have to do for that is just add one simple event so in our events package we can create a new class and we’re going to create a new class called Entity events so then let’s go into player events and just copy this event bus subscriber up to here and press ctrl shift o to import it however we want to change the bus dot forge to bus dot mod then let’s add a subscribe event called public static void on biome Load and then we’re going to pass in a biome loading event event and if event dot get name is equal to null we’re going to return so next we can do mob spawn info builder called spawns is equal to event.getspawns and then we can do if events dot get category dot equals Biome dot category dot the end so my mom’s going to spawn in the end we need to do spawns dot with spawner let me pass on an entity classification so i’m going to do creature and then a new mob spawn info dot spawners with our entity types init dot Example dot get then the weights after it spawns the smallest group so three and the largest group i’m also going to put that to 10. so next we can remove the bus equals bus dot mod and make this final And then run the game and now if we launch the game we can see that the entities are spawning in the end that’s it for this video if you need any help join the discord and i’ll see you next time Video Information
This video, titled ‘Minecraft Modding Tutorial 1.16 | 20.0 – Entity Spawning’, was uploaded by Cy4’s Modding on 2021-06-23 11:41:19. It has garnered 2518 views and 86 likes. The duration of the video is 00:10:42 or 642 seconds.
800 :DDD
(ɔ◔‿◔)ɔ ♥ ~ expand me
C://Sources/ TechnoVision’s Forge Tutorials
C://Follow_Me/ Subscribe: https://www.youtube.com/channel/UCJIDXtGpf4wv1ybDzdTA_vQ/ Website: https:/cy4shot.github.io/
C://Help/ Java Tutorial: https://cy4shot.github.io/javatutorial/ Discord: https://discord.gg/x9Mj63m4QG Or comment on this video!
C://Source_Code/ This Episode: https://github.com/Cy4Shot/ModdingTutorial1.16/tree/main/20.0-EntitySpawning All Episodes: https://github.com/Cy4Shot/ModdingTutorial1.16/