Jump to content

[1.14.x] No Optional.Interface?


eyeonus

Recommended Posts

The modules have to be registered during initialization. The loading phase, the part before you get to the main menu. Whatever you want to call it. I call it init because it's 4 letters.

The modules have to be registered at the same time every other Minecraft item has to be registered, because otherwise they don't exist in the game and can't be crafted.

If it's something you want players to be able to craft, it has to be registered.

The distinction being made between "module" and "item" in my earlier post is to prevent confusion between talking about the item in MPS that acts as an interface to an item on another mod, and the item in the other mod. The modules ARE STILL ITEMS as far as Minecraft is concerned.

 

You can't pass an ItemStack to a method that doesn't take an ItemStack parameter.

 

I never said you can pass an item.

 

Link to comment
Share on other sites

2 minutes ago, eyeonus said:

The modules have to be registered at the same time every other Minecraft item has to be registered, because otherwise they don't exist in the game and can't be crafted.

Well you have to register all of these Module Items anyways. Don't conditionally register them.

3 minutes ago, eyeonus said:

You can't pass an ItemStack to a method that doesn't take an ItemStack parameter.

ItemUseContext has an ItemStack inside it. And ItemUseContext is what is passed to Item#onItemUse.

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.

Link to comment
Share on other sites

You are entirely missing the point.

 

I don't get to choose how the items in the mod are activated.


The vast majority, if not all, of the items in the other mods use

ItemStack modItem = playerIn.getHeldItem(handIn)

to determine what item has just been used.

Edited by eyeonus
Link to comment
Share on other sites

15 minutes ago, eyeonus said:

The vast majority, if not all, of the items in the other mods use

Then you get to be the person to tell them they are doing it wrong. It's passed in as a parameter and should be used as such. The only use case for them to use that method is in Item#onItemRightClick, but once again this doesn't matter. Imagine changing the ItemStack in that slot before before calling their items method. Yes you can totally do that. Just remember to change it back after you call it.

 

onItemRightClick(world, player, hand) {
  originalStack = player.getHeldItem(hand);
  stackWithModuleItem = new ItemStack(getActiveModuleItem(), 1);
  player.setHeldItem(hand, stackWithModuleItem);
  stackWithModuleItem.getItem().onItemRightClick(world, player, hand);
  player.setHeldItem(originalStack);
}

 

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.

Link to comment
Share on other sites

Yes, well, OnRightClick is exactly the use case I'm talking about, so they aren't doing it wrong.

 

I've already spoken with lehjr about going the Morph-O-Tool route and changing the item to be the item from the other mod. In his opinion, that is entirely too much work to be worth it, especially since in his view it's a unstable solution in laggy servers.

 

He's decided to make anything that requires another mod be in an addon package for the main mod, thus avoiding this problem altogether.

 

Thank you for your time.

Link to comment
Share on other sites

2 hours ago, eyeonus said:

The vast majority, if not all, of the items in the other mods use


ItemStack modItem = playerIn.getHeldItem(handIn)

Uh. That's a stack, not an item.

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.

Link to comment
Share on other sites

11 hours ago, eyeonus said:

Yes, thank you for that knee jerk, thoughtless comment that contributes nothing to the conversation.

You still have not

16 hours ago, Draco18s said:

explained why you can't pass an ItemStack but can pass an Item.

 

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.

Link to comment
Share on other sites

5 minutes ago, eyeonus said:

I never said you can pass an item.

Ok. Then you did a bad job of explaining what you CAN do as you just stated over and over what you CAN'T do.

 

In trying to tease out what it is you CAN do from your posts....

 

You know you don't have to extend item and implement an interface on the same class, right? Put the interface stuff off in a soft-dependency area and when the interface methods get called, it can have a reference to your item and pass over (or get) the necessary details to do its thing.

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.

Link to comment
Share on other sites

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.