0
\$\begingroup\$

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?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ What you are looking for are broad-phase collision detection algorithms. stackoverflow.com/questions/1616448/… \$\endgroup\$
    – user8363
    Aug 12, 2012 at 22:58
  • \$\begingroup\$ 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. \$\endgroup\$
    – Gigggas
    Jun 9, 2013 at 4:30

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ Just relised the java section is dead :O \$\endgroup\$
    – AidoP
    Jul 14, 2013 at 0:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .