Posted July 28, 201312 yr I would have thought that this.mc.thePlayer.setGameType(EnumGameType.SURVIVAL); was the correct way to change a player's game mode, but that doesn't seem to work. How do you do this?
July 28, 201312 yr Make a EntityPlayer variable and then type player.capabilities.isCreativeMode = true;
July 28, 201312 yr Author Never use the client-side player for stuff like this (Minecraft#thePlayer). You need the serverside player. From where do you want to do this? From a tick handler.
July 28, 201312 yr Author What TickType? That matters. I had it set to client. Whops! I want this to be multiplayer. I just tried this. this.mc.playerController.setGameType(EnumGameType.SURVIVAL); Is that what I'm looking for?
July 28, 201312 yr Author You have to realize that there can always be multiple players. So you need to decide how to determine from the TickHandler which player's gamemode to change. When exactly should the change happen? I knew I would have to do that soon. I was planning on getting an array of all the online players and sorting through them one by one. I have it set to every 20 ticks to get the player's coordinates and compare them with a polygon. If you're inside it, then set the game mode to X.
July 28, 201312 yr Author MinecraftServer.getServer() is the server, yes? How do you select a player? I was expecting a MinecraftServer.getServer().getPlayer(playerName) FOUND IT
July 28, 201312 yr use FMLCommonHandler.instance().getEffectiseSide.isServer() / isClient() just in case or world.isRemote if you have access to a world reference how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 28, 201312 yr Author Good news! I made it work, and it is working just like I imagined. Although, the player gets spammed constantly with "your game mode has been changed" because of the tick handler. Any ideas how I could make it silent? This is how I change the player's game mode. MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername("username").setGameType(EnumGameType.SURVIVAL)
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.