rpentity.stopAttack();
rpentity.clearPath();
}
Sheep sheep = null;
Pet pet = null;
/*
* Remove from old zone (if any) during zone change
*/
if (oldZone != null) {
/*
* Player specific pre-remove handling
*/
if (entity instanceof Player) {
final Player player = (Player) entity;
/*
* Remove and remember dependents
*/
sheep = player.getSheep();
if (sheep != null) {
sheep.clearPath();
sheep.stop();
player.removeSheep(sheep);
}
pet = player.getPet();
if (pet != null) {
pet.clearPath();
pet.stop();
player.removePet(pet);
}
}
if (zoneChanged) {
oldZone.remove(entity);
}
}
/*
* [Re]position (possibly while between zones)
*/
entity.setPosition(x, y);
/*
* Place in new zone (if needed)
*/
if (zoneChanged) {
zone.add(entity);
}
/*
* Player specific post-change handling
*/
if (entity instanceof Player) {
final Player player = (Player) entity;
/*
* Move and re-add removed dependents
*/
if (sheep != null) {
if (placePet(zone, player, sheep)) {
player.setSheep(sheep);
sheep.setOwner(player);
} else {
// Didn't fit?
player.sendPrivateText("You seemed to have lost your sheep while trying to squeeze in.");
}
}
if (pet != null) {
if (placePet(zone, player, pet)) {
player.setPet(pet);
pet.setOwner(player);
} else {
// Didn't fit?
player.sendPrivateText("You seemed to have lost your pet while trying to squeeze in.");
}
}