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

Solved How to reverse direction block is facing

Discussion in 'Development' started by Indexfire, Feb 29, 2020.

  1. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    I currently have a plugin that flips objects on their axes,but the problem is that the blocks are still facing the same direction even after the flip. How do I reverse the block direction on the relevant axis?
    Code:
    PHP:
    if($args[0] == "rotate") {
                                if(
    $args[1] == "x") {
                                    
    $this->structures[$player->getName()] = array_reverse($this->structures[$player->getName()]);
                                    
    $player->sendMessage("Successfully rotated save on " $args[1] . " axis");
                                    return 
    true;
                                } elseif(
    $args[1] == "y") {
                                    foreach (
    array_keys($this->structures[$player->getName()]) as $block) {
                                        
    $this->structures[$player->getName()][$block] = array_reverse($this->structures[$player->getName()][$block]);
                                    }
                                    
    $player->sendMessage("Successfully rotated save on " $args[1] . " axis");
                                    return 
    true;
                                } elseif(
    $args[1] == "z") {
                                    foreach (
    array_keys($this->structures[$player->getName()]) as $block) {
                                        foreach (
    array_keys($this->structures[$player->getName()][$block]) as $y) {
                                            
    $this->structures[$player->getName()][$block][$y] = array_reverse($this->structures[$player->getName()][$block][$y]);
                                        }
                                    }
                                    
    $player->sendMessage("Successfully rotated save on " $args[1] . " axis");
                                    return 
    true;
                                }
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    This code doesn't rotate objects? Or it works and doesn't rotate directions of objects such as stairs, slabs, vines, etc...?
     
    Last edited: Feb 29, 2020
  3. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    It works and rotates locations of objects, but I don't know how to rotate directions of objects, so doors and stairs and furnaces and whatnot are a huge problem
     
  4. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Directions you change by changing block meta. I don't know how, you must test it or see some

    Block meta can be updated using
    PHP:
    Block->setDamage(int $meta);
     
    jasonwynn10 likes this.
  5. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    You can use BuilderTools plugin to check block meta (//debug command)
     
    jasonwynn10 likes this.
  6. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    BuilderTools refuses to work on my server for some reason, but I can easily write my own plugin to get block meta. Thanks for the tip!
     
  7. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    I appreciate every submitted bug to github.
     
    HimbeersaftLP likes 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.