I saw a post when they were speaking about setBlock and I was wondering if anybody could teach me how to use it? Maybe an example ? PHP: $level->setBlock(new Vector3($x, $y, $z), 54);// I don't understand this
What you don't understand? PHP: $lv->setBlock(Vector3($x, $y, $z), Block::get($id, $meta)); $lv is world where you want set Block, example: PHP: $lv = $this->getServer()->getLevelByName("world"); $x,$y,$z are coordinates of block you want to set. They are numbers/variables. $id, $meta are parametres of block you want set. When you write Block::get(35, 1), it will set block with id 35 and meta/damage 1 (= red wool)
SoI can do something like .. PHP: $lv = $this->getServer()->getLevelByName("world");$lv->setBlock(Vector3(getPlayerX(), getPlayerY(), getPlayerZ()), Block::get(1, 0));
I don't know if getPlayerX() can return number. I recommend to use (in events etc...) $ev->getPlayer()->getX()... Anyways, right.
There're two possibilities: 1) $issuer->getPosition(); (Position is Vector3 with player X,Y,Z) 2) $issuer->getX(), $issuer->getY(), $issuer->getZ() If you want set block at issuers coordinates, use: PHP: $issuer->getLevel()->setBlock($issuer->getPosition(), Block::get(1,0)); However, if you don't want set block at player position (e.g. under player), you must write: PHP: $issuer->getLevel()->setBlock(Vector3($issuer->getX(), $issuer->getY()-1, $issuer->getZ()), Block::get(1,0));
PHP: $lv = $this->getServer()->getLevelByName("world");$lv->setBlock(Vector3($issuer->getX(), $issuer->getY(), $issuer->getZ()), Block::get(1, 0)); I am sure you can first do $xyz = newVector3.... But I am too lazy or I don't think mine is right... lol
Your is right, but if player is in world "level", it'll set block at players X,Y,Z, but in different level
PHP: $lv = $this->getServer()->getLevelByName("world");$Player = $this->getServer->getPlayer("Radix");$lv->setBlock($Player,Block::get(1),true,true);
$issuer itself is a position. $Player->getLevel(). Why search for a level again while you already have a level? Man, this is not ModPE... -_-#
Sorry , Use to do ModPE Scripts As you can tell <3 Love u sorry ... PHP: $lv = $this->getServer()->getLevelByName("world");$pep = $issuer->getX(), $issuer->getY(), $issuer->getZ()$Player = $this->getServer->getPlayer($pep);$lv->setBlock($Player,Block::get(1),true,true); Now what is this? PHP: $lv->setBlock($Player,Block::get(1),true,true); Like PHP: $lv->setBlock ($Player,Block::get(1),true,true); // ::get(1) ?
$pep what the... Let me translate the line you are asking into JavaScript: Code: level.setBlock(player, Block.get(1 /* stone ID Happy? First parameter player is the position object. Second parameter is the block, an object containing the target ID and damage. Third parameter is whether to send the packet immediately in an independent packet. (Client lags if many independent packets are sent) fourth parameter is whether to update nearby blocks.
@PEMapModder @Radix How would I get a block at a location? Like this or something(Does not work): PHP: $player->getLevel()->getBlock($pos)->getId();