mojira.dev
MC-84771

Items and blocks can't be put in an item frame with the off-hand

The bug

If you try put an item or a block in an item frame with the off-hand if you have nothing in you main hand, nothing happens.

Code analysis

Based on 1.11 decompiled using MCP 9.35 rc1

The problem is that the method net.minecraft.entity.item.EntityItemFrame.processInitialInteract(EntityPlayer, EnumHand) always returns true even if the no item was placed nor the item in the item frame was rotated. This makes the game skip the offhand. The check whether or not the world is a server world has to be removed as well because otherwise the client would always try to interact with both hands because it would always fail.

Fix

EntityItemFrame.java

public boolean processInitialInteract(EntityPlayer player, EnumHand hand)
    {
        ItemStack itemstack = player.getHeldItem(hand);

//      if (!this.world.isRemote)
//      {
            if (this.getDisplayedItem().isEmpty())
            {
                if (!itemstack.isEmpty())
                {
                    this.setDisplayedItem(itemstack);

                    if (!player.capabilities.isCreativeMode)
                    {
                        itemstack.shrink(1);
                    }

++                  return true;
                }
				
++		return false;
            }
            else
            {
                this.playSound(SoundEvents.ENTITY_ITEMFRAME_ROTATE_ITEM, 1.0F, 1.0F);
                this.setItemRotation(this.getRotation() + 1);
            }
//      }

        return true;
    }

Linked issues

Attachments

Comments 6

I think that if the "use" button is pressed, the main slots are issued first, then if the main slots don't have an action it issues the command to the off-hand slot. Maybe it's just thinking that your hand has an item?

But if you have nothing in your main hand and something in your off-hand , we should be able to put it in the item frame.
Ps: Sorry for the spelling, I'm French ^^

Confirmed for 16w06a

The enviroment is supposed to contain pc details.

Confirmed for 1.12-pre5

Can confirm for MC 1.12.1.

Nathan

lord.quadrato

(Unassigned)

Confirmed

(Unassigned)

item, item-frame, off-hand

Minecraft 15w31c, Minecraft 15w33b, Minecraft 15w44b, Minecraft 16w06a, Minecraft 1.10.2, ..., Minecraft 1.14.3, Minecraft 1.14.4 Pre-Release 5, 1.14.4, 19w39a, 19w40a

19w46a

Retrieved