Hello! I want to create the nether portal to tp to nether, and as multiserver portal. Here is my Portal.php(EntityEnterPortalEvent is a simple event): PHP: <?php/* * * ____ _ _ __ __ _ __ __ ____ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * @author PocketMine Team * @link http://www.pocketmine.net/ * **/namespace pocketmine\block;use pocketmine\entity\Entity;use pocketmine\item\Item;use pocketmine\Player;use pocketmine\block\Liquid;class Portal extends Liquid{ protected $id = 90; public function __construct($meta = 0){ $this->meta = $meta; } public function getName(){ return "Portal"; } //TODO: getLightLevel public function onEntityCollide(Entity $entity){ Server::getInstance()->getPluginManager()->callEvent($ev = new EntityEnterPortalEvent($this, $entity); if(!$ev->isCancelled()) { //TODO: Delayed teleport entity to nether world. } } public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ $ret = $this->getLevel()->setBlock($this, $this, true, false); $this->getLevel()->scheduleUpdate($this, $this->tickRate()); return $ret; }} And init it with: PHP: Block::$list[90] = Portal::class; And use event to create multiserver portals. How do you think: it will works?
Firstly, add PHP: const NETHER_PORTAL = 90;const PORTAL = 90; to the Block.php and init it to class NetherPortal.php. In NetherPortal, you must write class NetherPortal extends Transparent. And with moving, check PlayerMoveEvent, create a timer... Then, add your event. Portal can't work like in Singleplayer if you don't do all of this. It'll work, but it'll kill the players...
Contants is the final variables, but $id and key of $list not must to be a constants. It is must to be an integer.
Solid, Transparent, Liquid, etc. would only affect the physics of the blocks. Liquid sounds like a good idea, since players can walk into it. But Nether Portal reminds me of cobwebs, which extends Flowable.
Cobwebs? Why that? Portals don't slow you down and don't have an x-shape xD Liquid would be wrong i guess. You can swim in liquids. Not in portal blocks. I think transparent Would be right, and you still have to add a check if one of the portal blocks is broken. Remember, they can only be broken by source blocks
For those of us who dont understand where we put all this code - can someone say a step by step tutorial on how to do this
Like I added the const to the Block.php, but wha now? Where do I put this? Block::$list[90] = Portal::class;