Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm developing a Minecraft plugin (bukkit) in which a server admin can create 'portals' - a small region that will teleport any players who enter it. I have the teleportation sorted and I know how I could define areas that the player's position could be tested against.

This would involve an ArrayList containing the zones and then hooking the PlayerMoveEvent so that the ArrayList is searched each time for a matching portal region.

Although this method would work, I doubt that it would be very efficient when 100+ players are all moving around at the same time. Is there a better way of checking a player position against a set of 'zones' / regions?

share|improve this question
1  
What you are looking for are broad-phase collision detection algorithms. stackoverflow.com/questions/1616448/… –  user8363 Aug 12 '12 at 22:58
    
Since it is Minecraft, couldn't you just use hidden teleporting command blocks combined with a redstone clock or custom mob spawner for this? Though, it might not be as easy and convenient for admins, I suppose. –  Gigggas Jun 9 '13 at 4:30

2 Answers 2

You should use the bukkit forums and you might get more replies, but anyway. Im a bukkit plugin dev myself, although I haven't been on bukkit a while. If you want to find a useful method you should look at the javadoc.I had a quick skim through and it seems that would be the only way, unless you changed the behaviour of another block to act as a proximity detector.

share|improve this answer
    
Just relised the java section is dead :O –  AidoP Jul 14 '13 at 0:07

There is an open source plugin called VoxelPort that does this, see here: https://github.com/TVPT/VoxelPort/tree/master/src/main/java/com/thevoxelbox/voxelport

It uses Zones as you suggested, and each "Port" calculates whether a player is inside the region & if they are holding the appropriate key. To prevent tons of lag, it has 2 types of ports. Instant ports, and Delayed ports. The delayed ones are used more on our server because they only check if a player is in a zone every so often(Based on set-time). On the server we're on (VoxelBox) it's about every 5 seconds or so.

As for player move events, it stores the data from the event in a HashMap instead of checking every move event. Then a thread "ticks" for when to check players.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.