Java Code Examples for net.minecraft.server.network.ServerPlayerEntity#setGameMode()
The following examples show how to use
net.minecraft.server.network.ServerPlayerEntity#setGameMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraModeCommand.java From fabric-carpet with MIT License | 5 votes |
private static int cameraMode(ServerCommandSource source, ServerPlayerEntity player) { if (!(iCanHasPermissions(source, player))) return 0; player.setGameMode(GameMode.SPECTATOR); player.addVelocity(0,0.1,0); player.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(player)); player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 999999, 0, false, false)); player.addStatusEffect(new StatusEffectInstance(StatusEffects.CONDUIT_POWER, 999999, 0, false, false)); return 1; }
Example 2
Source File: CameraModeCommand.java From fabric-carpet with MIT License | 5 votes |
private static int survivalMode(ServerCommandSource source, ServerPlayerEntity player) { if (!(iCanHasPermissions(source, player))) return 0; player.setGameMode(GameMode.SURVIVAL); player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.NIGHT_VISION)); player.removeStatusEffect(StatusEffects.NIGHT_VISION); player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.CONDUIT_POWER)); player.removeStatusEffect(StatusEffects.CONDUIT_POWER); return 1; }