private Float getEyeHeight() { if (eyeHeightSlider != null) { float index = eyeHeightSlider.getValue(); return index; } else { return config.getPlayer().getEyeHeight(); } }
private Float getHeight() { if (heightSlider != null) { float index = heightSlider.getValue(); return index; } else { return config.getPlayer().getHeight(); } }
@Override public void onOpened() { super.onOpened(); if (username != null) { username.setText(config.getPlayer().getName()); } }
private Color getColor() { if (slider != null) { float index = slider.getValue(); return findClosestColor(index); } else { return config.getPlayer().getColor(); } }
private void fetchConfig() { Config config = context.get(Config.class); language = config.getSystem().getLocale().toString(); PlayerConfig playerConfig = config.getPlayer(); playerHeight = playerConfig.getHeight(); playerEyeHeight = playerConfig.getEyeHeight(); } }
private void savePlayerSettings() { Color color = getColor(); config.getPlayer().setColor(color); Float height = getHeight(); config.getPlayer().setHeight(height); Float eyeHeight = getEyeHeight(); config.getPlayer().setEyeHeight(eyeHeight); config.getPlayer().setDiscordPresence(discordPresence.isChecked()); if (nametext != null) { config.getPlayer().setName(nametext.getText().trim()); config.getPlayer().setHasEnteredUsername(true); DiscordRPCSubSystem.updateState(); } if (!config.getSystem().getLocale().equals(language.getSelection())) { config.getSystem().setLocale(language.getSelection()); getManager().invalidate(); } }
@Override public void initialise(GameEngine engine, Context rootContext) { disableLogger(IPCClient.class); disableLogger(WindowsPipe.class); disableLogger(Pipe.class); Config c = rootContext.get(Config.class); enabled = c.getPlayer().isDiscordPresence(); if (!enabled) { return; } try { logger.info("Discord RPC >> Connecting..."); ipcClient.connect(); dontTryAgain = false; } catch (Exception ex) { } // Ignore due to reconnect thread }
@Override public void onOpened() { super.onOpened(); if (nametext != null) { nametext.setText(config.getPlayer().getName()); } if (slider != null) { Color color = config.getPlayer().getColor(); slider.bindValue(new NotifyingBinding(findClosestIndex(color))); } if (heightSlider != null) { heightSlider.bindValue(new NotifyingBinding(config.getPlayer().getHeight())); } if (eyeHeightSlider != null) { eyeHeightSlider.bindValue(new NotifyingBinding(config.getPlayer().getEyeHeight())); } if (discordPresence != null) { discordPresence.setChecked(config.getPlayer().isDiscordPresence()); } if (language != null) { language.setSelection(config.getSystem().getLocale()); } updateImage(); }
@ReceiveEvent public void onPlayerSpawn(OnPlayerSpawnedEvent event, EntityRef character) { if (character.equals(localPlayer.getCharacterEntity())) { // Change height as per PlayerSettings Float height = config.getPlayer().getHeight(); movementDebugCommands.playerHeight(localPlayer.getClientEntity(), height); // Change eyeHeight as per PlayerSettings Float eyeHeight = config.getPlayer().getEyeHeight(); GazeMountPointComponent gazeMountPointComponent = character.getComponent(GazeMountPointComponent.class); gazeMountPointComponent.translate = new Vector3f(0, eyeHeight, 0); // Trigger updating the player camera position as soon as the local player is spawned. // This is not done while the game is still loading, since systems are not updated. // RenderableWorldImpl pre-generates chunks around the player camera and therefore needs // the correct location. lookYaw = 0f; lookPitch = 0f; update(0); } }
@ReceiveEvent public void ensureGazeContainerEntitiesCreated(OnActivatedComponent event, EntityRef entityRef, GazeMountPointComponent gazeMountPointComponent, LocationComponent locationComponent) { if (!gazeMountPointComponent.gazeEntity.exists()) { gazeMountPointComponent.gazeEntity = createGazeEntity(); entityRef.saveComponent(gazeMountPointComponent); } gazeMountPointComponent.translate.y = config.getPlayer().getEyeHeight(); Location.attachChild(entityRef, gazeMountPointComponent.gazeEntity, gazeMountPointComponent.translate, new Quat4f(Quat4f.IDENTITY)); }
/** * Sends a join request from the client upstream to the server. * @param channelHandlerContext */ private void sendJoin(ChannelHandlerContext channelHandlerContext) { Config config = CoreRegistry.get(Config.class); NetData.JoinMessage.Builder bldr = NetData.JoinMessage.newBuilder(); NetData.Color.Builder clrbldr = NetData.Color.newBuilder(); bldr.setName(config.getPlayer().getName()); bldr.setViewDistanceLevel(config.getRendering().getViewDistance().getIndex()); bldr.setColor(clrbldr.setRgba(config.getPlayer().getColor().rgba()).build()); channelHandlerContext.getChannel().write(NetData.NetMessage.newBuilder().setJoin(bldr).build()); }
@Override public boolean step() { PlayerConfig playerConfig = context.get(Config.class).getPlayer(); Client localClient = context.get(NetworkSystem.class).joinLocal(playerConfig.getName(), playerConfig.getColor()); context.get(LocalPlayer.class).setClientEntity(localClient.getEntity()); return true; }
@Override public void onOpened() { super.onOpened(); infoService = new ServerInfoService(); if (!config.getPlayer().hasEnteredUsername()) { getManager().pushScreen(EnterUsernamePopup.ASSET_URI, EnterUsernamePopup.class); } if (storageServiceWorker.hasConflictingIdentities()) { new IdentityConflictHelper(storageServiceWorker, getManager(), translationSystem).runSolver(); } }
public static void setState(String state, boolean timestamp) { if (instance == null) { return; } RichPresence.Builder builder = new RichPresence.Builder(); if (state != null) { builder.setState(state); if (getInstance().lastState == null || (getInstance().lastState != null && !getInstance().lastState.equals(state))) { getInstance().lastState = state; } } if (getInstance().config != null) { String playerName = getInstance().config.getPlayer().getName(); builder.setDetails("Name: " + playerName); } if (timestamp) { builder.setStartTimestamp(OffsetDateTime.now()); } builder.setLargeImage(DISCORD_APP_LARGE_IMAGE); getInstance().sendRichPresence(builder.build()); }
@Override public void initialise() { playerConfig = config.getPlayer();
@Override public void onOpened() { super.onOpened(); if (isValidScreen()) { if (GameProvider.isSavesFolderEmpty()) { final NewGameScreen newGameScreen = getManager().createScreen(NewGameScreen.ASSET_URI, NewGameScreen.class); newGameScreen.setUniverseWrapper(universeWrapper); getManager().pushScreen(newGameScreen); } if (isLoadingAsServer() && !super.config.getPlayer().hasEnteredUsername()) { getManager().pushScreen(EnterUsernamePopup.ASSET_URI, EnterUsernamePopup.class); } refreshGameInfoList(GameProvider.getSavedGames()); } else { final MessagePopup popup = getManager().createScreen(MessagePopup.ASSET_URI, MessagePopup.class); popup.setMessage(translationSystem.translate("${engine:menu#game-details-errors-message-title}"), translationSystem.translate("${engine:menu#game-details-errors-message-body}")); popup.subscribeButton(e -> triggerBackAnimation()); getManager().pushScreen(popup); // disable child widgets setEnabled(false); } }
GROUND_PLANE_HEIGHT_DISPARITY - context.get(Config.class).getPlayer().getEyeHeight()); currentRenderingStage = RenderingStage.LEFT_EYE; } else {