JavierLeon9966 / ExtendedBlocks

This plugins adds the ability to add extended blocks in PocketMine 3.0.0+ API.
GNU General Public License v3.0
37 stars 9 forks source link

how can i set a block in onRandomTick y + 1 #53

Closed efor89 closed 3 years ago

efor89 commented 3 years ago

hi i try to set the block y + 1 but its always updateblock with id 255, i hope you can help me

public function onRandomTick(): void{ if($this->getDamage() === 0 and mt_rand(0, 50) == 16 and mt_rand(1, 5) == 3 and mt_rand(1, 6) == 3){ $block = clone $this; $block->setDamage(1); $this->getLevel()->setBlock($block, new Placeholder($block), true, true); $this->getLevel()->setBlock(new Vector3($block->x, $block->y + 1, $block->z), new Placeholder($block), true, true); }

efor89 commented 3 years ago

hallo?

efor89 commented 3 years ago

i try it in place funktion, set 2 blocks at same time 1 on the klick pos and 1 y + 1 its the same result the y + 1 set to update block

DavyCraft648 commented 3 years ago

I try to set the block y + 1 but its always updateblock with id 255

set the block position to y + 1

public function onRandomTick(): void{
    if($this->getDamage() === 0 and mt_rand(0, 50) == 16 and mt_rand(1, 5) == 3 and mt_rand(1, 6) == 3){
        $block = clone $this;
        $block->setDamage(1);

        $block2 = clone $block;
        $pos2 = new Position($this->x, $this->y + 1, $this->z, $this->getLevel());
        $block2->position($pos2);

        $this->getLevel()->setBlock($block, new Placeholder($block), true, true);
        $this->getLevel()->setBlock($pos2, new Placeholder($block2), true, true);
    }
}

my bad, i edited this comment multiple times

efor89 commented 3 years ago

ty very much @DavyCraft648 work perfekt. can you tell me how i set in a other block this block? its for bamboo i try to replace the sepling with the bamboo.

J1b1x commented 3 years ago

ty very much @DavyCraft648 work perfekt. can you tell me how i set in a other block this block? its for bamboo i try to replace the sepling with the bamboo.

Just set the sepling to air and set a bamboo block where the sapling was

DavyCraft648 commented 3 years ago

can you tell me how I set in a other block this block? its for bamboo I try to replace the sapling with the bamboo.

this is how I did it in my BambooSapling class

$bamboo = \pocketmine\block\BlockFactory::get(418, 0, $this); // 418 is bamboo block's id
$this->getLevel()->setBlock($this, new \JavierLeon9966\ExtendedBlocks\block\Placeholder($bamboo), true);
efor89 commented 3 years ago

thx a lot now i have working bamboo 👍

efor89 commented 3 years ago

i close the issue you help me a lot thx @DavyCraft648