Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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;
}

 

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.

  • Author

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

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.