private float getHeightOf(ComponentContainer prefab) { BoxShapeComponent box = prefab.getComponent(BoxShapeComponent.class); if (box != null) { return box.extents.getY(); } CylinderShapeComponent cylinder = prefab.getComponent(CylinderShapeComponent.class); if (cylinder != null) { return cylinder.height; } CapsuleShapeComponent capsule = prefab.getComponent(CapsuleShapeComponent.class); if (capsule != null) { return capsule.height; } SphereShapeComponent sphere = prefab.getComponent(SphereShapeComponent.class); if (sphere != null) { return sphere.radius * 2.0f; } HullShapeComponent hull = prefab.getComponent(HullShapeComponent.class); if (hull != null) { AABB aabb = hull.sourceMesh.getAABB(); return aabb.maxY() - aabb.minY(); } logger.warn("entity {} does not have any known extent specification - using default", prefab); return 1.0f; }
if (!Float.isNaN(relMove.getX()) && !Float.isNaN(relMove.getY()) && !Float.isNaN(relMove.getZ())) { entity.send(new CharacterMoveInputEvent(inputSequenceNumber++, lookPitch, lookYaw, relMove, run, crouch, jump, time.getGameDeltaInMs()));
@Command(shortDescription = "Sets the height of the player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION) public String playerHeight(@Sender EntityRef client, @CommandParam("height") float amount) { try { ClientComponent clientComp = client.getComponent(ClientComponent.class); CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class); if (move != null) { float prevHeight = move.height; move.height = amount; clientComp.character.saveComponent(move); LocationComponent loc = client.getComponent(LocationComponent.class); Vector3f currentPosition = loc.getWorldPosition(); clientComp.character .send(new CharacterTeleportEvent(new Vector3f(currentPosition.getX(), currentPosition.getY() + (amount - prevHeight) / 2, currentPosition.getZ()))); physics.removeCharacterCollider(clientComp.character); physics.getCharacterCollider(clientComp.character); return "Height of player set to " + amount + " (was " + prevHeight + ")"; } return ""; } catch (NullPointerException e) { e.printStackTrace(); return ""; } }