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

Fixed

[Helper] Lord_Quadrato

Nathan

2015-08-02, 09:18 AM

2021-04-15, 11:52 PM

2020-04-27, 12:25 AM

15

9

Confirmed

(Unassigned)

item, item-frame, off-hand

Minecraft 15w31c - 19w40aMinecraft 15w31c, Minecraft 15w33b, Minecraft 15w44b, Minecraft 16w06a, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w35a, Minecraft 16w36a, Minecraft 16w38a, Minecraft 16w39a, Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w40a, Minecraft 16w41a, Minecraft 16w42a, Minecraft 16w43a, Minecraft 16w44a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11, Minecraft 16w50a, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13a, Minecraft 17w13b, Minecraft 17w14a, Minecraft 17w15a, Minecraft 1.12 Pre-Release 5, Minecraft 1.12 Pre-Release 6, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w45b, Minecraft 17w46a, Minecraft 17w47a, Minecraft 17w47b, Minecraft 17w50a, Minecraft 18w05a, Minecraft 18w11a, Minecraft 18w22a, Minecraft 18w22c, Minecraft 1.13-pre1, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13-pre4, Minecraft 1.13-pre5, Minecraft 1.13-pre6, Minecraft 1.13-pre7, Minecraft 1.13-pre8, Minecraft 1.13-pre9, Minecraft 1.13-pre10, Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, Minecraft 18w32a, Minecraft 1.13.1-pre1, Minecraft 1.13.1-pre2, Minecraft 1.13.1, Minecraft 1.13.2-pre1, Minecraft 1.13.2-pre2, Minecraft 1.13.2, Minecraft 18w43a, Minecraft 18w43b, Minecraft 18w43c, Minecraft 18w44a, Minecraft 18w45a, Minecraft 18w48a, Minecraft 18w48b, Minecraft 18w49a, Minecraft 18w50a, Minecraft 19w02a, Minecraft 19w03a, Minecraft 19w03c, Minecraft 19w04b, Minecraft 19w12b, Minecraft 19w13b, Minecraft 19w14a, Minecraft 1.14 Pre-Release 2, Minecraft 1.14 Pre-Release 3, Minecraft 1.14.3, Minecraft 1.14.4 Pre-Release 5, 1.14.4, 19w39a, 19w40a

19w46a