Jump to content

[1.11.2] Make item invalid for offhand


ThexXTURBOXx

Recommended Posts

Hello community,

 

is there a way to make a item invalid for use in offhand, so, that you can't even get it into the offhand-slot?

Do I have to cancel the keypress-event for the "hand change"-keybinding and cancel it for the slot-change in inventory or is there an easier way (such as isItemValidForSlot in the Item-class, which I didn't find yet...)?

Bringing the best mod back alive! Our mod REFORGED!

Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases

Link to comment
Share on other sites

I can see a method 'isValidArmor' in the Item.class. I haven't used it, but it seems the right one, so here is example:

@Override
public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity)
{
	return armorType!=EntityEquipmentSlot.OFFHAND;
}

 

Link to comment
Share on other sites

Item::isValidArmor is only fired for armor, hence the name.

I do not see a not-ugly/hacky way to make the item invalid for offhand slot - it is initialized as a regular Slot without additional checks and swap hotkey has no hooks at all.

Even if you cancel the keybind and handle the slot click some mods that have that slot in their own container will allow the item to go in regardless as you can't reliably handle that. 

Why are you trying to prohibit the use of the offhand slot fot your item to begin with? There is nothing special about that slot unless you explicitly handle your item being in that exact slot. Most methods that do something with the item do have an EnumHand parameter that will allow you to check if the item is not in that slot.

Link to comment
Share on other sites

Hmm... The items are not transformed the right way, if they are in the offhand slot. I need to transform Every item, which is nearly suicide. Right now, I always cancel everything, if the item is in the offhand. The Transformation nevertheless looks terrible. I just dont want the item to be in the offhand slot :/

Bringing the best mod back alive! Our mod REFORGED!

Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases

Link to comment
Share on other sites

Unfortunately that's the way it is. You can't reliably prohibit your item from going into the offhand slot(apart from ugly sollutions like dropping them if they are in that slot) so you have to handle it somehow.

Unless all your items have their item-unique custom transform creating correct transforms for the offhand is just going to be figuring it out for one item and copy-pasting it to others. Even if each item is unique there has to be some kind of pattern for their transformation you can use.

In any case you should do this. Imagine a mod adding a mannequin. That mannequin is it's own entity with it's own slots. It indeed can have items in the offhand slot. A user puts your item in there and... yeah. You know what is even worse? The name of that mod is Minecraft and the name of that item is Armor stand. 

Edited by V0idWa1k3r
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.