Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to fill chests?

Comments in 'Plugin Development' started by SuperChipsLP, Oct 31, 2013.

  1. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Hey there! I have another question to you pros :D

    Well, i want to fill chests... I have 100 Chests on a Map.
    I need to clear them and put an iron sword in each.

    How do i do that?

    Thanks!
  2. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    I'm guessing you don't want to do it manually?
  3. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    No. I have to use it so it will be done every 20 minutes or so. I know how to do this.


    Can you please help with the question above?
  4. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    You could save the map and reset it, not quite sure though
  5. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    I know how to do that. Thats what i'm currently doing. But i want the Iron swords to be other items. So it will be dynamic...
  6. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    392
    Here's a script that accomplish the job:
    PHP:
    $cheststemplate = array(
        
    => array(
            
    'x' => 10,
            
    'y' => 10,
            
    'z' => 10,
            
    'items' => array(
                
    => array(
                    
    'id' => 1,
                    
    'meta' => 0,
                    
    'count' => 64
                
    ),
                
    =>  array(
                    
    'id' => 264,
                    
    'meta' => 0,
                    
    'count' => 1
                
    ),
            ),
        ),
        
    => array(
            
    'x' => 20,
            
    'y' => 20,
            
    'z' => 20,
            
    'items' => array(
                
    => array(
                    
    'id' => 3,
                    
    'meta' => 0,
                    
    'count' => 1
                
    ),
            ),
        ),

    );

    foreach(
    $cheststemplate as $chestnumber => $chestinfo){
        
    $position = new Position($chestinfo['x'], $chestinfo['y'], $chestinfo['z']);
        
    $chest $this->api->tile->get($position);
        foreach(
    $val['items'] as $slot => $iteminfo){
            
    $item BlockAPI::getItem($iteminfo['id'], $iteminfo['meta'], $iteminfo['count']);
            
    $chest->setSlot($slot$item);
        }
    }

    console('chests refilled!');
    You can change an add as many chests and items to the $cheststemplate

    edit:
    Or do you mean to get all the chests on your server (not by position )and fill them with a iron sword? If so, than you can use this:
    PHP:
    $ironsword BlockAPI::getItem(26701);
    $tiles $this->api->tile->getAll();
    foreach(
    $tiles as $tile){
        if(
    $tile->class === TILE_CHEST){
            
    $tile->setSlot(0$ironsword);
        }
    }
    Last edited: Oct 31, 2013
  7. Let It Snow!
    Offline

    Let It Snow! Active Member

    Joined:
    Oct 30, 2013
    Posts:
    60
    Minecraft User:
    LetItSnow_
    Well you couple go from pc
  8. Let It Snow!
    Offline

    Let It Snow! Active Member

    Joined:
    Oct 30, 2013
    Posts:
    60
    Minecraft User:
    LetItSnow_
    Could*
  9. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Thank you so much! You helped me a lot!
  10. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    how would you add that to a command
  11. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    like add /refillchests and then it will do it
  12. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    I think that it could be something like:
  13. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    I just thought I'd say this helps me a lot with one of my plugin ideas! Thanks @wies! :) Hopefully I'll find enough time to make it for the plugin contest though :p
  14. Dark
    Offline

    Dark New Member

    Joined:
    Jan 18, 2015
    Posts:
    1
    Minecraft User:
    Dark
    I'm 70% noob in php, even don't know new api on 100%...
    Can you help me with plugin?
    I need chest refill plugin, working on 100% (Folk's plugin crashes my server)
    For more details contact me in skype - wtf_one
    P.S: I can paid $ for good work...

Share This Page

Advertisement