1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

PC to PE block and meta conversion

Discussion in 'Development' started by jasonwynn10, Apr 23, 2017.

  1. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    I noticed that when porting pc worlds into PocketMine, many blocks and their metadata are changed. I have started work on a plugin to allow the blocks to be corrected, but I have yet to find all the block ids and meta data that needs changed. Any help in finding the needed data would be much appreciated.
    The project repo is here: https://github.com/jasonwynn10/BlockTypeCorrector
     
    Skullex, Muqsit and SalmonDE like this.
  2. Defications2po

    Defications2po Witch

    Messages:
    51
  3. ICU

    ICU Silverfish

    Messages:
    15
    What blocks do you have so far? I can help

    Btw thank you! I need this tool :)
     
  4. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    I've worked on the same idea and I made a list. However I'm really not sure if the list is correct and up to date.
    The list is json encoded and follows this structure: pcId => peId

    Code:
    {
        "3:2": "243:0",
        "31:1": "2:0",
        "43:7": "43:6",
        "44:7": "44:6",
        "82:0": "337:0",
        "112:0": "405:0",
        "115:0": "372:0",
        "157:0": "126:0",
        "158:0": "125:0",
        "188:0": "85:1",
        "189:0": "85:2",
        "190:0": "85:3",
        "191:0": "85:5",
        "192:0": "85:4",
        "198:0": "208:0",
        "199:0": "240:0",
        "202:0": "201:2",
        "205:0": "44:7",
        "207:0": "244:0",
        "208:0": "198:0",
        "214:0": "115:0",
        "322:1": "466:0",
        "410:0": "422:0",
        "434:0": "457:0",
        "435:0": "458:0",
        "436:0": "459:0",
        "450:0": "445:0"
    }
    
    Edit:
    After looking at your code, I also used the way you let the server do other things by breaking the conversion into multiple tasks. :D
    I was planning to make it public, but I stopped working on it, so I'm really glad you're doing this. Less coding for me when I need this again! :)
     
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    That list is great! Those will be the default blocks to change, but I think there may be other things needed also. I noticed that trapdoors change state and direction in converted worlds too.
     
  6. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    I just want to really clarify the list could be wrong, I autogenerated it. It wasn't created manually.
     
    jasonwynn10 likes this.
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Thank you for letting me know, I will test when I have the chance
     
  8. Harviy

    Harviy Spider

    Messages:
    13
    I do not understand how it works, how can I run it?
     
  9. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    What do you mean? The plugin isn't able to be run yet. It's not finished
     
  10. MK500

    MK500 Slime

    Messages:
    77
    GitHub:
    markkrueg
    MiNET does this on the fly; so maybe you can find the conversion lists in the source?
     
  11. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Where would they even be located??
     
    EdwardHamHam likes this.
  12. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    Maybe, but I can't (although I don't know what it's file name would be if it's there). Keep in mind though, that MiNET is written in another programming language, and something like this conversation list might not be structured exactly like that.
     
    jasonwynn10 likes this.
  13. MK500

    MK500 Slime

    Messages:
    77
    GitHub:
    markkrueg
    Possibly here?

    https://github.com/NiclasOlofsson/M...T/MiNET/Worlds/AnvilWorldProvider.cs#L57-L164

    Yeah, I'm just bringing this up because a bunch of servers do use MiNET; so you should have a tested/working conversion list to work with somewhere in that project. Easier than starting from scratch.
     
    Awzaw and jasonwynn10 like this.
  14. ICU

    ICU Silverfish

    Messages:
    15
    are you gonna work on this?
     
  15. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    The plugin is mostly completed, but the actual corrector task doesn't work
     
  16. mudegg

    mudegg Spider

    Messages:
    6
    GitHub:
    mudegg
    emmm...
    There's a plugin written by boybook earlier than yours
    The delnull plugin here
    I've done more features to this plugins
    It's the modyfied here

    PHP:
    <?php
    namespace DelNull;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\tile\Tile;
    use 
    pocketmine\block\Air;
    use 
    pocketmine\block\Glowstone;


    class 
    Main extends PluginBase implements ListenerCommandExecutor {

        public 
    $pos1 = array();
        public 
    $pos2 = array();
        
        
        public function 
    onLoad() {
        }
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
        
        
    //玩家触碰方块
        
    public function playerBlockTouch(PlayerInteractEvent $event){
            
    $block $event->getBlock();
            
    $x $block->getX();
            
    $y $block->getY();
            
    $z $block->getZ();
            
    $player $event->getPlayer();
            
    $name $player->getName();
        }
        
        public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args){
            switch(
    $cmd->getName()){
                case 
    "dnull":
                    if (
    $args[0] == "pos1") {
                            
    $x $sender->getX();
                            
    $y $sender->getY();
                            
    $z $sender->getZ();
                            
    $level $sender->getLevel();
                            
    $this->pos1["x"] = $x;
                            
    $this->pos1["y"] = $y;
                            
    $this->pos1["z"] = $z;
                            
    $this->pos1["l"] = $level;
                            
    $sender->sendMessage("Position1 setted");

                        return 
    true;
                    }
                    elseif (
    $args[0] == "pos2") {
                            
    $x $sender->getX();
                            
    $y $sender->getY();
                            
    $z $sender->getZ();
                            
    $level $sender->getLevel();
                            
    $this->pos2["x"] = $x;
                            
    $this->pos2["y"] = $y;
                            
    $this->pos2["z"] = $z;
                            
    $this->pos2["l"] = $level;
                            
    $sender->sendMessage("Position2 setted");

                        return 
    true;
                    }
                    elseif (
    $args[0] == "delnull") {
                        if ((
    count($this->pos1) == 0) or (count($this->pos2) == 0)) {
                            
    $sender->sendMessage("Please set the position first!");
                        }
                        else {
                            if (
    $this->pos1["l"]->getName() != $this->pos2["l"]->getName()) {
                                
    $sender->sendMessage("2 Positions are not in the same level!");
                            }
                            else {
                                
    $sender->sendMessage("Start, please wait!");
                                
    $num $this->delnall($this->pos1,$this->pos2);
                                
    $sender->sendMessage("Done! Handled $num blocks.");
                            }
                        }
                        return 
    true;
                    }
                    else {
                        return 
    false;
                    }
                break;
            }
        }
        
        public function    
    delnall($pos1,$pos2) {
            
    $n 0;
            
    $startX min($pos1["x"], $pos2["x"]);
            
    $endX max($pos1["x"], $pos2["x"]);
            
    $startY min($pos1["y"], $pos2["y"]);
            
    $endY max($pos1["y"], $pos2["y"]);
            
    $startZ min($pos1["z"], $pos2["z"]);
            
    $endZ max($pos1["z"], $pos2["z"]);
            
    $level $pos1["l"];
            for(
    $x $startX$x <= $endX; ++$x){
                for(
    $y $startY$y <= $endY; ++$y){
                    for(
    $z $startZ$z <= $endZ; ++$z){
                        
    $v3 = new Vector3($x,$y,$z);
                        
    $block $level->getBlock($v3);
                        
    $id $block->getID();
                        
    $name $block->getName();
                        
    $meta $block->getDamage();
                        switch(
    $id){
                            case 
    126:  //pc上的木板台阶
                                
    $newblock = new Item(158,$meta);
                                
    $newblock $newblock->getBlock();
                                
    $level->setBlock($v3,$newblock);
                                
    $n $n 1;
                            break;
                            case 
    125:  //pc上的双木板台阶
                                
    $newblock = new Item(5,$meta);
                                
    $newblock $newblock->getBlock();
                                
    $level->setBlock($v3,$newblock);
                                
    $n $n 1;
                            break;
                            case 
    28:  //机关铁轨
                                
    $newblock = new Item(66);  //普通铁轨
                                
    $newblock $newblock->getBlock();
                                
    $level->setBlock($v3,$newblock);
                                
    $n $n 1;
                            break;
                            case 
    95:  //彩色玻璃
                                
    $newblock = new Item(35,$meta);  //羊毛
                                
    $newblock $newblock->getBlock();
                                
    $level->setBlock($v3,$newblock);
                                
    $n $n 1;
                            break;
                            case 
    160:  //彩色玻璃片
                                
    $newblock = new Item(35,$meta);  //羊毛
                                
    $newblock $newblock->getBlock();
                                
    $level->setBlock($v3,$newblock);
                                
    $n $n 1;
                            break;
                            case 
    51:  //去除火
                                
    $newblock = new Air;  //获取空气方块对象
                                //$level->setBlock($v3,$newblock);  //替换为空气
                            
    break;
                            default:
                                if (
    $name == "Unknown") {  //为pe不存在的方块
                                    
    $newblock = new Air;  //获取空气方块对象
                                    
    $level->setBlock($v3,$newblock);  //替换为空气
                                
    $n $n 1;
                                }
                            break;
                        }
                        
                    }
                }
            }
            return 
    $n;
        }
    }
     
  17. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    I doubt that this is helpful in any way.
     
    Sandertv likes this.
  18. mudegg

    mudegg Spider

    Messages:
    6
    GitHub:
    mudegg
    doubt or not
    /dnull <pos1|pos2|delnull>
    The plugin is here
    just run and replace yourself
    http://zxda.mudegg.net/DelNull.phar
     
  19. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    That code does not have all wrong IDs nor is the code very fancy. Furthermore, this doesn't really contribute to the thread.
     
    Muqsit, jasonwynn10 and SalmonDE like this.
  20. xXSirButterXx

    xXSirButterXx Witch

    Messages:
    52
    GitHub:
    xxsirbutterxx
    SalmonDE and jasonwynn10 like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.