Help with setting inventories

Discussion in 'Plugin Development' started by thechrisanator, Apr 1, 2017.

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

    thechrisanator

    I just want to know how to add to an infinite amount of chests/droppers inventories.
    How would I do that?
    I just want to add items to them, and it has to be random for each case
     
  2. Offline

    mine-care

    @thechrisanator Impossible, computers cannot work with infinite numbers of elements hehe :p
    Well i dont really understand what you are aiming to do? Could you elaborate a bit and show us your code so far?
     
  3. @thechrisanator
    You can save the inventory and everytime someone closes the chest, you re-fill it with the items that were in it previously. As for the dispenser, you can detect the block dispense event and re-add the item to the dispenser.
     
  4. Offline

    thechrisanator

    @mine-care @BananaPuncher714 what I mean by infinite inventory, is that I want to add random items to a dropper every 3 seconds. And this has to work for every dropper (an infinite amount of droppers theoretically)
     
  5. Offline

    Zombie_Striker

    @thechrisanator
    Well, I have two solutions, one that is really efficient, and another that can only be a little intensive. It all depends on whether the dispensers can be placed after the plugin is created.

    The efficient way:
    1. Listen to block place event. If the placed block is a dispencer, add it to an Arraylist.
    2. Use a repeating task. Every 3 seconds, for loop through the arraylist and add random items
    The not-so-efficent way:
    1. Skip #1 from above. Every 3 seconds, for loop through all the chunks on the server. If a chunk is not loaded, skip it.
    2. For loop through the XYZ of the loaded chunk.
    3. If the block at that XYZ is equal to a dispenser, add the random items.
     
    thechrisanator likes this.
  6. Offline

    thechrisanator

    @Zombie_Striker Alright, well I need it to work for all droppers placed after the plugin is installed, and it needs to check for a certain name of dropper for it to work. Ex: (the items will only be put in the dropper if it has a certain name, qnd if its broken, it needs to keep the name it previously had) Im not very good at Java, so are there any websites that you suggest I check out?
    Thanks.
     
    Last edited: Apr 2, 2017
Thread Status:
Not open for further replies.

Share This Page