My own WorldBorder it works, but a few problems

Discussion in 'Plugin Development' started by Neilnet, Mar 13, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Neilnet

    Inside a PlayerMoveEvent, I have this:
    Code:
                if (e.getTo().getX() > radius || e.getTo().getX() < -radius || e.getTo().getZ() > radius || e.getTo().getZ() < -radius) 
                {
                    e.setTo(e.getFrom());
                    p.sendMessage(Utils.color("&cYou have reached the border!"));
                }
    
    It works, when the player cannot be past the radius.

    - The radius variable decreases by 500 every x amount of seconds until it hits a certain point.

    Now here's the problem I face:
    - If the radius decreases past the player. Say the player's at the edge, and it decreases 500 blocks inwards. The player will be stuck (from the e.setTo(...)) line of code.

    Is there any way I could also push the player back 500 blocks inwards so circumvent the player from being stuck due to the radius decrease?

    Thanks guys,
    Neil
     
  2. Offline

    teej107

    @Neilnet Teleport, manipulate his velocity, kill....
     
  3. Offline

    Neilnet

    I don't think that will work. It's a UHC plugin. Players can build stuff. What if there is something behind the player which stops him from moving towards the center when I set his velocity. and how do I get the direction to the center from the part of the border he is at?

    Also that isn't the problem. The border only stops the player from moving when he's near there. Though if the border decreases (due to the radius). The player is just stuck. There is no way of detecting to see if the border decreased and the player is completely out of the border.
     
  4. Offline

    teej107

    @Neilnet Would you be fine with teleporting?
     
  5. Offline

    Neilnet

    That's not the problem. Teleporting, setting the velocity is not half the battle. The main problem is detecting if the player is outside the border. Because currently that PlayerMoveEvent only stops the player from going past the border. Though if the border decreases. The player is just completely stuck.

    Or I shall refrase, as I don't think I'm explaining this well:

    The border is just a simple PlayerMoveEvent which checks using the e.getTo() method is greater than the radius.

    If the radius variable is decreased. The border gets decreased. I need to check when the decrease occurs the players that are outside the border will get pushed in. I need to know how to get that check bit to occur before teleporting or setting the velocity.

    @teej107

    Note:

    I can easily fix this bug if there is another way to create a border instead of using this:

    Code:
    if (e.getTo().getX() > radius || e.getTo().getX() < -radius || e.getTo().getZ() > radius || e.getTo().getZ() < -radius)
                {
                    e.setTo(e.getFrom());
                    p.sendMessage(Utils.color("&cYou have reached the border!"));
                }
    
    inside the PlayerMoveEvent method.

    Is there another method which creates a border using the location relative to of which the spawn point?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  6. Offline

    teej107

    @Neilnet
     
  7. Offline

    Neilnet

    That won't work, I need a method which checks if players are outside that border when the border radius decreases. I am unsure how to go about this, you just stated the method I was using again?

    Okay, here's a picture I'm trying to draw what I'm trying to say:

    [​IMG]

    The big box = Border before it decreases by 500 blocks.
    Small box = Border AFTER it decreases by 500 blocks.

    The lines mean players. The pink lines are players within the border AFTER it decreases by 500 blocks. The green lines are players who are outside the border AFTER it decreases by 500 blocks.

    Now the green lines (players outside the border after it decreased by 500 blocks) have to be pushed in towards the center to not be past the border.
     
    Last edited by a moderator: Mar 13, 2015
  8. Offline

    teej107

    @Neilnet I know what you are trying to say. Do you want the player's to be teleported back? or some other means?
     
  9. Offline

    Neilnet

    I want the player to be pushed teleported backwards (towards the center of the border). I'm coding UHC :)
     
  10. Offline

    teej107

    @Neilnet So when a player is outside of the border, you want them to be constantly pushed until they are not in the border?
     
    Last edited: Mar 13, 2015
  11. Offline

    Neilnet

  12. Offline

    teej107

    @Neilnet :p Yes. In the border.
    You will have to make some method to tell which side of the border the player is closest to and then teleport them to the nearest border.
     
  13. Offline

    Neilnet

    @teej107

    I don't even get the
    e.getTo() bit, I mean it isn't even documented what it does? I'm trying to calculate how much past the player is off the border. And these simple methods aren't even documented. :(
     
  14. Offline

    teej107

Thread Status:
Not open for further replies.

Share This Page