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

Solved Chests are sometimes invisible setBlockIdAt

Comments in 'Plugin Development' started by cake23, Mar 12, 2016.

  1. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    I wrote a plugin which sets blocks. Anything works, it sets grass-blocks, glas-blocks and so on, except chests. The Chests are sometimes invisible. And if I reload the map, all chest are invisible.
    I tried to set the chests with this code:
    PHP:
    $sender->getLevel()->setBlockIdAt($x$y$z$id);
    $sender->getLevel()->setBlockDataAt($x$y$z$Extraid);
    and with this code:
    PHP:
    $block = new Chest();
    $sender->getLevel()->setBlock(new Vector3($XKiste$YKiste$ZKiste), $blocktruetrue);
    Philipp likes this.
  2. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Your german X, y, z Kiste is nice :p

    I think it is a Pocketmine bug
    Philipp and cake23 like this.
  3. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Okay thanks! :D
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You have to initialize a chest tile object. MCPE wouldn't render the chest model until there is a tile entity at that position.
    Look at the the pocketmine\block\Chest::place() method for how to place a chest.

    No, you are wrong. Please, don't accuse PocketMine as having bugs when it is behaving absolutely correctly and you are using it incorrectly.
    cake23 and Survingo like this.
  5. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    How does place() works? Which parameters I need?
    Philipp likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  7. Philipp
    Offline

    Philipp New Member

    Joined:
    Feb 17, 2016
    Posts:
    6
    Minecraft User:
    Goodstuff4UonYT
    Like this ?
    Code:
    $block = new Chest();
                    $sender->getLevel()->setBlock(new Vector3($XKiste, $YKiste, $ZKiste), $block, true, true);
                    $nbt = new CompoundTag("", [
                        new ListTag("Items", []),
                        new StringTag("id", Tile::CHEST),
                        new IntTag("x", $XKiste),
                        new IntTag("y", $YKiste),
                        new IntTag("z", $ZKiste)
                    ]);
                    $nbt->Items->setTagType(NBT::TAG_Compound);
                    $tile = Tile::createTile("Chest", $sender->getLevel()->getChunk($XKiste >> 4, $ZKiste >> 4), $nbt);
    PEMapModder and cake23 like this.
  8. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Thanks, it works. <3

Share This Page

Advertisement