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.func_82752_c(); 057 } 058 059 public boolean func_82752_c() 060 { 061 return this == ADVENTURE; 062 } 063 064 /** 065 * Returns true if this is the CREATIVE game type 066 */ 067 public boolean isCreative() 068 { 069 return this == CREATIVE; 070 } 071 072 @SideOnly(Side.CLIENT) 073 074 /** 075 * Returns true if this is the SURVIVAL or ADVENTURE game type 076 */ 077 public boolean isSurvivalOrAdventure() 078 { 079 return this == SURVIVAL || this == ADVENTURE; 080 } 081 082 /** 083 * Returns the game type with the specified ID, or SURVIVAL if none found. Args: id 084 */ 085 public static EnumGameType getByID(int par0) 086 { 087 EnumGameType[] var1 = values(); 088 int var2 = var1.length; 089 090 for (int var3 = 0; var3 < var2; ++var3) 091 { 092 EnumGameType var4 = var1[var3]; 093 094 if (var4.id == par0) 095 { 096 return var4; 097 } 098 } 099 100 return SURVIVAL; 101 } 102 103 @SideOnly(Side.CLIENT) 104 105 /** 106 * Returns the game type with the specified name, or SURVIVAL if none found. This is case sensitive. Args: name 107 */ 108 public static EnumGameType getByName(String par0Str) 109 { 110 EnumGameType[] var1 = values(); 111 int var2 = var1.length; 112 113 for (int var3 = 0; var3 < var2; ++var3) 114 { 115 EnumGameType var4 = var1[var3]; 116 117 if (var4.name.equals(par0Str)) 118 { 119 return var4; 120 } 121 } 122 123 return SURVIVAL; 124 } 125 }