Iron Backpacks

Iron Backpacks

54M Downloads

Renaming one backpack also renames another when they are both in the inventory

ribbanya opened this issue ยท 1 comments

commented

Issue Description:

When renaming a backpack while more than one is in the inventory, another is sometimes also renamed.

What happens:

The inspected backpack is renamed, but so is one other backpack (which other backpack is affected is not clear, if there are three or more).

What you expected to happen:

Only the inspected backpack should be renamed.

Steps to reproduce (important):

  1. Hold two or more IronBackpacks backpacks of any type in the inventory.
  2. Shift-right click one of them to open the Alternate GUI.
  3. Rename the backpack.

Speculation:

The problem is likely due to the two alternative attempts to rename the item; I suspect that stack and itemStack sometimes point to different backpacks.

// ContainerAlternateGUI.java : 181

public void renameBackpack(String toName){

    //client side is easy
    stack.setStackDisplayName(ConfigHandler.makeRenamedBackpacksNamesItalic ? toName : "\u00A7r" + toName); //client

    ItemStack itemStack = IronBackpacksHelper.getBackpackFromPlayersInventory(this.player); //works only for opening w/out nested, change to currPack?
    if (itemStack == null)
        itemStack = PlayerWearingBackpackCapabilities.getEquippedBackpack(player);
    if (itemStack != null)
        itemStack.setStackDisplayName(ConfigHandler.makeRenamedBackpacksNamesItalic ? toName : "\u00A7r" + toName); //server (not really, but this way works...)
    //        ItemStack itemStack1 = CommonProxy.getCurrBackpack(player); //need something like this if you can open alt gui in nested packs

}

Affected Versions (Do not use "latest"):

  • IronBackpacks: 2.2.9
  • Minecraft: 1.10.2
  • Forge: 12.18.2.2116

The client and server are running WyldLife 1.2.2, with no relevant alterations.

commented

I couldn't replicate this error for some reason (despite your awesome bug report), but I did just look at the code and refactor it to what it should be. If this pops up again feel free to reopen this issue.