public void setGamemode(GameMode mode, boolean updateClient) {
boolean changeToFromCreative = getGameMode() == GameMode.CREATIVE;
Entity holder = getOwner();
if (holder instanceof Player) {
PlayerGameModeChangedEvent event = holder.getEngine().getEventManager().callEvent(new PlayerGameModeChangedEvent((Player) getOwner(), mode));
if (event.isCancelled()) {
return;
}
changeToFromCreative ^= event.getMode() == GameMode.CREATIVE;
GameMode old = getGameMode();
mode = event.getMode();
//In Survival we shoudn't be able to fly.
setCanFly(mode == GameMode.CREATIVE, updateClient);
if (changeToFromCreative) {
if (callAbilityChangeEvent().isCancelled()) {