Problems with insertNewClothingItem() :(

  • English

We've posted an important announcement regarding the current situation and the future of the game: Announcement

  • Problems with insertNewClothingItem() :(

    Hi @red51 I'm trying to insert clothing and object kits to an inventory via plugin,

    I'm using javadoc.rising-world.net/net/r…em-short-int-int-int-int- as a reference as how this is achieved.

    This is how I'm doing it (the clothes bit - objects obviously different)

    Source Code

    1. Item i = event.getItem();
    2. Item.Attribute attribute = i.getAttribute();
    3. if(attribute != null){
    4. if(attribute instanceof ClothingAttribute){
    5. //Type-cast to clothing attribute
    6. Item.ClothingAttribute clothing = (Item.ClothingAttribute) attribute;
    7. System.out.println("ClothingAttribute: " + clothing.getClothingID());
    8. inventory.insertNewClothingItem(clothing.getClothingID(), 0, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF);
    9. }
    10. }
    Display All

    Problem is, when I first call this, i.e. add an item of clothing to the player inventory I get a "broken" item. Which strangely gets fixed when I call the code a second time, OR equip another working item of clothes.

    For visualisation:

    Here I have moved a medieval armour over to my inventory, cancelling the event, then called the above code. As you can see in the inventory slot 1 there is a "broken" item.




    I did the same thing again (no changes to code) inserting the rag clothes into slot 2. At this point slot 1 magically became the working item it was supposed to be and slot 2 was broken.



    This behaviour continues with each added item.


    It also appears that equipping an item fixes the broken inventory items. For example, in the above screenshot, as soon as I equip the armour the rag clothing in slot 2 appears normal.



    Any idea what's going on here? ?(
    play: server.medievalrealms.co.uk website: medievalrealms.co.uk discord: discord.medievalrealms.co.uk
  • This is unfortunately a bug: if an item which uses a certain attribute was added to the inventory, the attribute was only stored serverside and not properly synced with the client. As a result, the client received a "broken" item, but as soon as the inventory was re-synced with the server (which happens in certain situations, e.g. if the client or server detect the desync, or if the player reconnects to the server), the item was fixed.

    This annoying bug will be fixed with the next update :)