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

Working with claims (Faction)

Discussion in 'Development' started by DiamondGamer30, Jun 9, 2018.

  1. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    How would I make a claim? I am terrible at math and I am trying to figure out how to make a 30 by 3 by 80 claim based on 1 position. I do not know if this is correct.

    PHP:
    <?php

    namespace fac\faction;

    use 
    pocketmine\math\Vector3;

    class 
    Claim {

        private 
    $faction;

        private 
    $firstPosition;

        private 
    $secondPosition;

        public function 
    __construct(Faction $factionVector3 $claimPosition) {
            
    $this->faction $faction;
            
    $x1 $claimPosition->getX() + 15;
            
    $y1 $claimPosition->getY() - 40;
            
    $z1 $claimPosition->getZ() - 15;
            
    $this->firstPosition = new Vector3($x1$y1$z1);
            
    $x2 $claimPosition->getX() - 14;
            
    $y2 $claimPosition->getY() + 40;
            
    $z2 $claimPosition->getZ() + 14;
            
    $this->secondPosition = new Vector3($x2$y2$z2);
        }
    }
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    You could allow user to select 2 spots which will be the easiest way
    to prevent claiming too much you can calculate the full volume of the player's selection and tell them to reselect if too small

    some servers prefer to work with chunks since it's easier to claim and sort
     
  3. Epic

    Epic Creeper

    Messages:
    4
    The user have to select two positions if you want the claim to be how he like, but if you still want to go like that:
    PHP:

    <?php

    namespace fac\faction;

    use 
    pocketmine\math\Vector3;

    class 
    Claim {

        private 
    $faction;

        private 
    $firstPosition;

        private 
    $secondPosition;

        public function 
    __construct(Faction $factionVector3 $claimPosition) {
            
    $this->faction $faction;
            
    //$y1 = $claimPosition->getY() - 40; Faction claims has the whole Y so no need for that.
            
    $this->firstPosition = ["x" => ($claimPosition->getX() + 15), "z" => ($claimPosition->getZ() + 15)];
            
    //$y2 = $claimPosition->getY() + 40;
            
    $this->secondPosition = ["x" => ($claimPosition->getX() - 14), "z" => ($claimPosition->getZ() - 14)];
        }
    }
     
  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.