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

SetBlock to Chest

Comments in 'Plugin Development' started by elfin8er, Mar 25, 2014.

  1. elfin8er
    Offline

    elfin8er New Member

    Joined:
    Feb 1, 2014
    Posts:
    25
    Minecraft User:
    elfin8er
    I'm trying to set a block to a chest using the following code, however when I do, the chest is made invisible.
    Code:
     
    $issuer->entity->level->setBlock(new Vector3($issuer->entity->x, $issuer->entity->y, $issuer->entity->z, $issuer->entity->level), BlockAPI::get(54,0));
    
    I've tried changing the ID to 1, and it worked. It just doesn't work with the ID 54. How would I do this?
  2. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    Beaches I'd 1 is a air block :) I think that its because there is a id 54 is maybe already taken
  3. elfin8er
    Offline

    elfin8er New Member

    Joined:
    Feb 1, 2014
    Posts:
    25
    Minecraft User:
    elfin8er
    Nope, ID 0 is air. 1 is stone. What do you mean by there's an id 54 is already taken?
    Darunia18 likes this.
  4. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    That's weird, although tapping makes it appear. Maybe an MCPE issue?
  5. elfin8er
    Offline

    elfin8er New Member

    Joined:
    Feb 1, 2014
    Posts:
    25
    Minecraft User:
    elfin8er
    Hmm. Maybe there's some way to "update" that block?
  6. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    Oh Yes That Happens When I Import A MapTo My Server A Imported Breeze Island And I had to talk all over the place to get chest to apear
  7. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    Tap Lol
  8. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Gimme a few minutes to test some stuff :)
  9. elfin8er
    Offline

    elfin8er New Member

    Joined:
    Feb 1, 2014
    Posts:
    25
    Minecraft User:
    elfin8er
    Awesome, thanks! If you think this is a big, should I report it on github a while?
  10. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    It isn't a bug, the chest needs to be initialized via it's place function, I just don't know exactly how to use it.
  11. elfin8er
    Offline

    elfin8er New Member

    Joined:
    Feb 1, 2014
    Posts:
    25
    Minecraft User:
    elfin8er
    Ah. If you're still willing to try to figure it out, it would be much appreciated.
  12. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    I will work on it.
  13. elfin8er
    Offline

    elfin8er New Member

    Joined:
    Feb 1, 2014
    Posts:
    25
    Minecraft User:
    elfin8er
    Thanks :) take your time.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You just set the block. You didn't set the tile part of it.

    Just like a sign. In MCPE 0.6.1 (and maybe later until idk when) there had been a bug that occasionally signs are invisible until you re-render the world (e.g. by tapping "home" and then back). It is because the tile part of it wasn't loaded.

    You can initialize the tile by
    PHP:
    ServerAPI::request()->api->tile->add($issuer->entity->levelTILE_CHEST$issuer->entity->x$issuer->entity->y$issuer->z);
    Also $player->entity is instanceof Entity, subclass of Position, subclass of Vector3, so you can use
    PHP:
    $issuer->entity->level->setBlock($issuer->entityBlockAPI::get(54));
    directly. But wait, won't that become inside their feet?
    elfin8er and Falk like this.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then do the chests contain what they are supposed to contain?
  16. elfin8er
    Offline

    elfin8er New Member

    Joined:
    Feb 1, 2014
    Posts:
    25
    Minecraft User:
    elfin8er
    Hmm. Do I initialize the tile then spawn the block, or vise versa? Either way, it didn't work for me. I tried them both. Here's what I've got.

    PHP:
    public function test($cmd$params$issuer$alias$args$issuer){
            if(
    $issuer instanceof Player){
                
    $player $issuer->username;
                if(
    $params[0] == "newloot"){
                    
    ServerAPI::request()->api->tile->add($issuer->entity->levelTILE_CHEST$issuer->entity->x$issuer->entity->y$issuer->z);
                    
    $issuer->entity->level->setBlock($issuer->entityBlockAPI::get(54,0));
                }
            }
        }
    No errors in the console or anything. It just didn't work. Also, yes it would spawn the chest at the players feet. I'm just experimenting atm.
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I think you should add an array() of data after the $issuer->z parameter. I didn't look into the details, but the parameter is called $data and I thought leaving it blank would make an empty chest.
  18. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    PHP:
           $this->api->tile->add($issuer->entity->levelTILE_CHEST$issuer->entity->x$issuer->entity->y$issuer->entity->z, array(
                
    "Items" => array(),
                
    "id" => TILE_CHEST,
                
    "x" => $issuer->entity->x,
                
    "y" => $issuer->entity->y,
                
    "z" => $issuer->entity->z
            
    ));
    PEMapModder likes this.
  19. elfin8er
    Offline

    elfin8er New Member

    Joined:
    Feb 1, 2014
    Posts:
    25
    Minecraft User:
    elfin8er
    Still nothing :eek:

    PHP:
    public function test($cmd$params$issuer$alias$args$issuer){
            if(
    $issuer instanceof Player){
                
    $player $issuer->username;
                 
    $this->api->tile->add($issuer->entity->levelTILE_CHEST$issuer->entity->x$issuer->entity->y$issuer->entity->z, array(
                     
    "Items" => array(),
                     
    "id" => TILE_CHEST,
                     
    "x" => $issuer->entity->x,
                     
    "y" => $issuer->entity->y,
                     
    "z" => $issuer->entity->z
                 
    ));
                 
    $issuer->entity->level->setBlock($issuer->entityBlockAPI::get(54,0));
                 
    $this->api->chat->broadcast("Chest Spawned!");
            }
        }
    Edit: Can the Items array not be empty?
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What is meant by "nothing"? What do you want?

Share This Page

Advertisement