Posted June 7, 20187 yr How would I enchant and add my custom armor and tool sets to a player's inventory on spawn? Edited June 13, 20187 yr by Blue_Atlas
June 8, 20187 yr 8 hours ago, Blue_Atlas said: How would I enchant and add my custom armor and tool sets to a player's inventory on spawn? First off define spawn, even after they die, one time aka the first time they join the world or every time they join the world. You can add an enchanted item to the player's inventory by creating a new instance of an ItemStack and calling ItemStack#addEnchantment(Enchantment, level) and you can get the enchantments from the static variables in Enchantments. Adding the item is easier EntityPlayer#addItemStackToInventory(ItemStack). VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
June 8, 20187 yr Author where do i put the ItemStack#addEnchantment and EntityPlayer#addItemStackToInventory? also what do i replace the # with?
June 8, 20187 yr 47 minutes ago, Blue_Atlas said: where do i put the ItemStack#addEnchantment and EntityPlayer#addItemStackToInventory? also what do i replace the # with? # is a Javadoc notation that means "this is not a static method, you cannot invoke ItemStack.addEnchantment directly, you need an instance of an item stack and then you can call addEnchantment on it." Edited June 8, 20187 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 8, 20187 yr Author okay? still don't quite understand. is there any code you could show me that does this?
June 8, 20187 yr ItemStack someStack = new ItemStack(...); someStack.addEnchantment(...); Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 8, 20187 yr 9 minutes ago, Blue_Atlas said: Okay but where do I put this code? In the class where I register items? And what good would that do? 13 hours ago, Animefan8888 said: one time aka the first time they join the world or every time they join the world You need to give the item to the player when they join the world. That's an event. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 8, 20187 yr Author Ok let me clarify: Where do I put the code for enchanting the items, How do I use the code for putting items in a player's inventory first time they enter the world, And where do I put the code for adding items to player inventory on first time spawning. that is what I am asking.
June 8, 20187 yr In the EntityJoinWorldEvent event handler? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 8, 20187 yr Author i dont have one of those yet. where should i put that class when i make it? also is that where i put the enchanting or do i just put the inventory adding? Edited June 8, 20187 yr by Blue_Atlas
June 8, 20187 yr 3 minutes ago, Blue_Atlas said: i dont have one of those yet. where should i put that class when i make it? http://mcforge.readthedocs.io/en/latest/events/intro/#creating-an-event-handler 3 minutes ago, Blue_Atlas said: also is that where i put the enchanting or do i just put the inventory adding? Do you want the item added to the player's inventory to be enchanted? Yes? Then freaking hell yes you do it there Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 8, 20187 yr Author could you maybe show me some example code for adding the item? where do i cal my RegistryHandler class and how do i call it? i assume its called in my main class but i dont know where Edited June 8, 20187 yr by Blue_Atlas
June 8, 20187 yr 30 minutes ago, Blue_Atlas said: also where do i put this preInit, Init, or postInit? 3 hours ago, Draco18s said: In the EntityJoinWorldEvent event handler http://mcforge.readthedocs.io/en/latest/events/intro/#creating-an-event-handler Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 8, 20187 yr You don't. Its an event. It's called by Forge. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 9, 20187 yr https://mcforge.readthedocs.io/en/latest/events/intro/ Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
June 9, 20187 yr Author Yeah but how do I register it? Do I use the @Mod.EventSubscriber? Edited June 9, 20187 yr by Blue_Atlas
June 9, 20187 yr Read the docs. It clearly states how to make and use an event handler. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
June 9, 20187 yr Author still dont get it. how do i register/use my event handler? do i use a function in my main class? if so what function and where? is it just loaded as long as it is in my package? i cant find anything in the docs saying exactly how to do it
June 9, 20187 yr 2 hours ago, Draco18s said: You don't. Its an event. It's called by Forge. Automatically, as long as you set up the annotations correctly. Edited June 9, 20187 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.