Clone chest content

Discussion in 'Plugin Development' started by Moon_werewolf, Jul 10, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Moon_werewolf

    I trying to clone the chest content with this code


    Code:
    if(b.getState() instanceof Chest)
            {
                Chest c = (Chest)b.getState();
                items = c.getInventory().getContents().clone();
            }
    but if the chest get destroyed and after that i use

    Code:
    if(items != null && inv != null)
            {
                inv.setContents(items);
            }
    i get all content but all items are a infinite stack. why?
     
  2. Offline

    ninjayoshi

    you probly have to give it a number of items u want in the chest or else it will just go to 0 which is infinite
     
  3. Offline

    Moon_werewolf

    That is kind of silly i thought that clone content would clone everything
     
  4. Offline

    captainawesome7

    Um, why use .clone() in the first place?
    Just use getContents();
     
  5. Offline

    ItsHarry

    Use getContents and then use setContents on the new chest
     
  6. Offline

    Shamebot

    Arrays are reference types, and destroying one chest may spawn the items and clear the contents arrays, dunno.
     
Thread Status:
Not open for further replies.

Share This Page