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

Nether portal block

Comments in 'Plugin Development' started by MrGenga, Oct 19, 2015.

  1. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    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 $itemBlock $blockBlock $target$face$fx$fy$fzPlayer $player null){
            
    $ret $this->getLevel()->setBlock($this$thistruefalse);
            
    $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?
  2. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    Block:: 90?
  3. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    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...
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    actually, it isn't really necessary to add the constants.
  5. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    Contants is the final variables, but $id and key of $list not must to be a constants. It is must to be an integer.
  6. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Extends Liquid?
  7. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    extends Solid
  8. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Sure? not transparent?
  9. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Transparent! I wrote Solid and when players walked to portal they were killed
    thebigsmileXD likes this.
  10. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    ;) Told you so ^^
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    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.
    Creeperface and Artide like this.
  12. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Solid = Suffocation
  13. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    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
  14. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Well, we have to see until @shoghicp adds portals.
  15. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Well, @MrGenga could also do a pull request on github. But you are right
  16. PhoenixChicken
    Offline

    PhoenixChicken Active Member

    Joined:
    Sep 7, 2015
    Posts:
    41
    Minecraft User:
    Phoenix_Chicken
    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
  17. PhoenixChicken
    Offline

    PhoenixChicken Active Member

    Joined:
    Sep 7, 2015
    Posts:
    41
    Minecraft User:
    Phoenix_Chicken
    Like I added the const to the Block.php, but wha now? Where do I put this?


    Block::$list[90] = Portal::class;
  18. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Blocks.php, where the other blocks are listed.
  19. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    One more thing: canPassThrough must be set to true. And its replaceable by water. and Transparent

Share This Page

Advertisement