Jump to content

Recommended Posts

Posted
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.

Posted (edited)
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 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.

Posted
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.

Posted
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.

Posted

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.

Posted

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.

Posted (edited)

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 by Blue_Atlas
Posted
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.

Posted (edited)

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 by Blue_Atlas
Posted
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.

Posted

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.

Posted

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

Posted (edited)
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 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.