Program: 178722
Project: 178722
Buggy source:
public V10Teleport teleport(Entity entity,Location oloc,V10Location locTo,Vector vector,boolean really){
  if (entity == null || entity.isDead() || blockedEntities.contains(entity))   return null;
  Region regionTo=plugin.regionManager.getRegion(locTo);
  Portal portal=plugin.portalManager.insideBlocks.get(locTo);
  if (portal == null) {
    if ((entity instanceof FallingBlock || entity instanceof TNTPrimed) && vector.getX() == 0.0D && vector.getZ() == 0.0D) {
      portal=plugin.portalManager.awayBlocksY.get(locTo);
    }
 else     if ((Math.abs(vector.getX()) > 0.5 || (Math.abs(vector.getY()) > 1 || (Math.abs(vector.getZ()) > 0.5))) || entity instanceof Boat) {
      portal=plugin.portalManager.awayBlocks.get(locTo);
      if (portal == null)       return null;
      Block to=locTo.getHandle().getBlock();
      for (int i=0; i < 2; i++) {
        BlockFace face=portal.awayBlocksY[i].getHandle().getBlock().getFace(to);
        if (face == null)         continue;
        if (face != BlockFace.SELF) {
          double x=1.0D, z=1.0D;
          boolean nef=false;
          boolean nwf=false;
switch (face) {
case NORTH_WEST:
            z=0.5D;
case NORTH:
          x=0.5D;
        nwf=true;
      break;
case NORTH_EAST:
    x=1.5D;
case EAST:
  z=0.5D;
nef=true;
break;
case SOUTH_EAST:
z=1.5D;
case SOUTH:
x=0.5D;
break;
case SOUTH_WEST:
x=0.5D;
default :
z=0.5D;
}
if (nef) {
if (oloc.getX() - locTo.x > x || oloc.getZ() - locTo.z < z) return null;
}
 else if (nwf) {
if (oloc.getX() - locTo.x < x || oloc.getZ() - locTo.z > z) return null;
}
 else if (oloc.getX() - locTo.x > x || oloc.getZ() - locTo.z > z) return null;
}
 else break;
}
}
 else return null;
}
if (!portal.open || portal.disabled || (Math.abs(vector.getY()) > 1 && !portal.vertical)) return null;
Portal destination=portal.getDestination();
Location teleport=destination.teleport.getHandle();
teleport.setX(teleport.getX() + 0.5D);
teleport.setZ(teleport.getZ() + 0.5D);
float yaw=entity.getLocation().getYaw();
float pitch=entity.getLocation().getPitch();
float startyaw=yaw;
switch (portal.teleportFace) {
case EAST:
yaw-=90;
break;
case SOUTH:
yaw-=180;
break;
case WEST:
yaw-=270;
break;
case DOWN:
teleport.add(0,1,0);
case UP:
yaw=pitch;
pitch=0;
break;
}
double momentum=0.0;
switch (portal.teleportFace) {
case NORTH:
case SOUTH:
momentum=vector.getX();
break;
case EAST:
case WEST:
momentum=vector.getZ();
break;
case UP:
case DOWN:
momentum=vector.getY();
break;
}
momentum=Math.abs(momentum);
momentum*=regionTo.getDouble(RegionSetting.VELOCITY_MULTIPLIER);
Vector outvector=entity.getVelocity().zero();
switch (destination.teleportFace) {
case NORTH:
yaw+=180;
outvector=outvector.setX(momentum);
break;
case EAST:
yaw+=270;
outvector=outvector.setZ(momentum);
break;
case SOUTH:
yaw+=360;
outvector=outvector.setX(-momentum);
break;
case WEST:
yaw+=450;
outvector=outvector.setZ(-momentum);
break;
case DOWN:
if (portal.teleportFace != BlockFace.UP && portal.teleportFace != BlockFace.DOWN) {
yaw=pitch;
pitch=startyaw;
}
 else {
pitch=yaw;
yaw=startyaw;
}
outvector=outvector.setY(momentum);
break;
case UP:
if (portal.teleportFace != BlockFace.UP && portal.teleportFace != BlockFace.DOWN) {
yaw=pitch;
pitch=startyaw + 180;
}
 else {
pitch=yaw;
yaw=startyaw;
}
outvector=outvector.setY(-momentum);
break;
}
if (!(entity instanceof Player) && !(entity instanceof Chicken) && momentum < 0.5 && (portal.teleportFace == BlockFace.UP || portal.teleportFace == BlockFace.DOWN) && (destination.teleportFace == BlockFace.UP || destination.teleportFace == BlockFace.DOWN)) teleport.setX(teleport.getX() + 0.5D);
entity.setFallDistance(0);
teleport.setPitch(pitch);
teleport.setYaw(yaw);
if (entity instanceof Arrow) teleport.setY(teleport.getY() + 0.5);
if (really) {
if (!entity.teleport(teleport)) return null;
entity.setVelocity(outvector);
}
destination.disabled=true;
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,new enablePortal(destination),10L);
if (portal.orange) plugin.util.PlaySound(Sound.PORTAL_EXIT_ORANGE,entity instanceof Player ? (Player)entity : null,new V10Location(teleport));
 else plugin.util.PlaySound(Sound.PORTAL_EXIT_BLUE,entity instanceof Player ? (Player)entity : null,new V10Location(teleport));
return new V10Teleport(teleport,outvector);
}

Fixed version (ground truth):
public V10Teleport teleport(Entity entity,Location oloc,V10Location locTo,Vector vector,boolean really){
  if (entity == null || entity.isDead() || blockedEntities.contains(entity))   return null;
  Region regionTo=plugin.regionManager.getRegion(locTo);
  Portal portal=plugin.portalManager.insideBlocks.get(locTo);
  if (portal == null) {
    if ((entity instanceof FallingBlock || entity instanceof TNTPrimed) && vector.getX() == 0.0D && vector.getZ() == 0.0D) {
      portal=plugin.portalManager.awayBlocksY.get(locTo);
    }
 else     if ((Math.abs(vector.getX()) > 0.5 || (Math.abs(vector.getY()) > 1 || (Math.abs(vector.getZ()) > 0.5))) || entity instanceof Boat) {
      portal=plugin.portalManager.awayBlocks.get(locTo);
      if (portal == null)       return null;
      Block to=locTo.getHandle().getBlock();
      for (int i=0; i < 2; i++) {
        BlockFace face=portal.awayBlocksY[i].getHandle().getBlock().getFace(to);
        if (face == null)         continue;
        if (face != BlockFace.SELF) {
          double x=1.0D, z=1.0D;
          boolean nef=false;
          boolean nwf=false;
switch (face) {
case NORTH_WEST:
            z=0.5D;
case NORTH:
          x=0.5D;
        nwf=true;
      break;
case NORTH_EAST:
    x=1.5D;
case EAST:
  z=0.5D;
nef=true;
break;
case SOUTH_EAST:
z=1.5D;
case SOUTH:
x=0.5D;
break;
case SOUTH_WEST:
x=0.5D;
default :
z=0.5D;
}
if (nef) {
if (oloc.getX() - locTo.x > x || oloc.getZ() - locTo.z < z) return null;
}
 else if (nwf) {
if (oloc.getX() - locTo.x < x || oloc.getZ() - locTo.z > z) return null;
}
 else if (oloc.getX() - locTo.x > x || oloc.getZ() - locTo.z > z) return null;
}
 else break;
}
}
 else return null;
}
if (!portal.open || portal.disabled || (Math.abs(vector.getY()) > 1 && !portal.vertical)) return null;
final Portal destination=portal.getDestination();
Location teleport=destination.teleport.getHandle();
teleport.setX(teleport.getX() + 0.5D);
teleport.setZ(teleport.getZ() + 0.5D);
float yaw=entity.getLocation().getYaw();
float pitch=entity.getLocation().getPitch();
float startyaw=yaw;
switch (portal.teleportFace) {
case EAST:
yaw-=90;
break;
case SOUTH:
yaw-=180;
break;
case WEST:
yaw-=270;
break;
case DOWN:
teleport.add(0,1,0);
case UP:
yaw=pitch;
pitch=0;
break;
}
double momentum=0.0;
switch (portal.teleportFace) {
case NORTH:
case SOUTH:
momentum=vector.getX();
break;
case EAST:
case WEST:
momentum=vector.getZ();
break;
case UP:
case DOWN:
momentum=vector.getY();
break;
}
momentum=Math.abs(momentum);
momentum*=regionTo.getDouble(RegionSetting.VELOCITY_MULTIPLIER);
Vector outvector=entity.getVelocity().zero();
switch (destination.teleportFace) {
case NORTH:
yaw+=180;
outvector=outvector.setX(momentum);
break;
case EAST:
yaw+=270;
outvector=outvector.setZ(momentum);
break;
case SOUTH:
yaw+=360;
outvector=outvector.setX(-momentum);
break;
case WEST:
yaw+=450;
outvector=outvector.setZ(-momentum);
break;
case DOWN:
if (portal.teleportFace != BlockFace.UP && portal.teleportFace != BlockFace.DOWN) {
yaw=pitch;
pitch=startyaw;
}
 else {
pitch=yaw;
yaw=startyaw;
}
outvector=outvector.setY(momentum);
break;
case UP:
if (portal.teleportFace != BlockFace.UP && portal.teleportFace != BlockFace.DOWN) {
yaw=pitch;
pitch=startyaw + 180;
}
 else {
pitch=yaw;
yaw=startyaw;
}
outvector=outvector.setY(-momentum);
break;
}
if (!(entity instanceof Player) && !(entity instanceof Chicken) && momentum < 0.5 && (portal.teleportFace == BlockFace.UP || portal.teleportFace == BlockFace.DOWN) && (destination.teleportFace == BlockFace.UP || destination.teleportFace == BlockFace.DOWN)) teleport.setX(teleport.getX() + 0.5D);
entity.setFallDistance(0);
teleport.setPitch(pitch);
teleport.setYaw(yaw);
if (entity instanceof Arrow) teleport.setY(teleport.getY() + 0.5);
if (really) {
if (!entity.teleport(teleport)) return null;
entity.setVelocity(outvector);
}
destination.disabled=true;
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,new Runnable(){
public void run(){
destination.disabled=false;
}
}
,10L);
if (portal.orange) plugin.util.PlaySound(Sound.PORTAL_EXIT_ORANGE,entity instanceof Player ? (Player)entity : null,new V10Location(teleport));
 else plugin.util.PlaySound(Sound.PORTAL_EXIT_BLUE,entity instanceof Player ? (Player)entity : null,new V10Location(teleport));
return new V10Teleport(teleport,outvector);
}