legobear154/MyTown — pull request #1 by Torins (2013-07-08 22:56:08+00:00)
Title: PortalGun protection

Hey Legobear.

Protection against portal gun portals wasn't working so I went and changed it.
There were two problems:
1) if it was a default portal, getBlock was called with block x and z, while it should be called with chunk dimensions.
2) When shot from very close the update method is called only once, but it ends after checking if the entity is moving, skipping protection checks.

I've redid the whole update method, so it does permission checking only when the ball collides with something, that way in case number two the very first update call has a collision and ends up checking permissions.
A side effect is that portal balls can now fly through towns, as long as they land on an area where they are permitted to create a portal.

Hopefully this way requires less processing than the previous one, but not sure about that.

There's one slight bug though: due to checking permissions for all blocks around the collided one, portals may refuse to work one block away from a town chunk. I would have to know on which block the 2nd part of the portal will appear, to correct this.