001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 006 public enum EnumGameType 007 { 008 NOT_SET(-1, ""), 009 SURVIVAL(0, "survival"), 010 CREATIVE(1, "creative"), 011 ADVENTURE(2, "adventure"); 012 int id; 013 String name; 014 015 private EnumGameType(int par3, String par4Str) 016 { 017 this.id = par3; 018 this.name = par4Str; 019 } 020 021 /** 022 * Returns the ID of this game type 023 */ 024 public int getID() 025 { 026 return this.id; 027 } 028 029 /** 030 * Returns the name of this game type 031 */ 032 public String getName() 033 { 034 return this.name; 035 } 036 037 /** 038 * Configures the player capabilities based on the game type 039 */ 040 public void configurePlayerCapabilities(PlayerCapabilities par1PlayerCapabilities) 041 { 042 if (this == CREATIVE) 043 { 044 par1PlayerCapabilities.allowFlying = true; 045 par1PlayerCapabilities.isCreativeMode = true; 046 par1PlayerCapabilities.disableDamage = true; 047 } 048 else 049 { 050 par1PlayerCapabilities.allowFlying = false; 051 par1PlayerCapabilities.isCreativeMode = false; 052 par1PlayerCapabilities.disableDamage = false; 053 par1PlayerCapabilities.isFlying = false; 054 } 055 056 par1PlayerCapabilities.allowEdit = !this.isAdventure(); 057 } 058 059 /** 060 * Returns true if this is the ADVENTURE game type 061 */ 062 public boolean isAdventure() 063 { 064 return this == ADVENTURE; 065 } 066 067 /** 068 * Returns true if this is the CREATIVE game type 069 */ 070 public boolean isCreative() 071 { 072 return this == CREATIVE; 073 } 074 075 @SideOnly(Side.CLIENT) 076 077 /** 078 * Returns true if this is the SURVIVAL or ADVENTURE game type 079 */ 080 public boolean isSurvivalOrAdventure() 081 { 082 return this == SURVIVAL || this == ADVENTURE; 083 } 084 085 /** 086 * Returns the game type with the specified ID, or SURVIVAL if none found. Args: id 087 */ 088 public static EnumGameType getByID(int par0) 089 { 090 EnumGameType[] var1 = values(); 091 int var2 = var1.length; 092 093 for (int var3 = 0; var3 < var2; ++var3) 094 { 095 EnumGameType var4 = var1[var3]; 096 097 if (var4.id == par0) 098 { 099 return var4; 100 } 101 } 102 103 return SURVIVAL; 104 } 105 106 @SideOnly(Side.CLIENT) 107 108 /** 109 * Returns the game type with the specified name, or SURVIVAL if none found. This is case sensitive. Args: name 110 */ 111 public static EnumGameType getByName(String par0Str) 112 { 113 EnumGameType[] var1 = values(); 114 int var2 = var1.length; 115 116 for (int var3 = 0; var3 < var2; ++var3) 117 { 118 EnumGameType var4 = var1[var3]; 119 120 if (var4.name.equals(par0Str)) 121 { 122 return var4; 123 } 124 } 125 126 return SURVIVAL; 127 } 128 }