Showing preview only (1,815K chars total). Download the full file or copy to clipboard to get everything.
Repository: stackotter/delta-client
Branch: main
Commit: 70cd0ed48c67
Files: 754
Total size: 1.6 MB
Directory structure:
gitextract_hv9a6jeo/
├── .editorconfig
├── .github/
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ ├── pull_request_template.md
│ └── workflows/
│ ├── build.yml
│ ├── swiftlint.yml
│ └── test.yml
├── .gitignore
├── .swift-format
├── .swiftlint.yml
├── AppIcon.icns
├── Bundler.toml
├── Contributing.md
├── LICENSE
├── Notes/
│ ├── Caching.md
│ ├── ChunkPreparation.md
│ ├── DebuggingDeadlocks.md
│ ├── GUIRendering.md
│ ├── PluginSystem.md
│ ├── Readme.md
│ └── RenderPipeline.md
├── Package.resolved
├── Package.swift
├── Readme.md
├── Roadmap.md
├── Security.md
├── Sources/
│ ├── Client/
│ │ ├── CommandLineArguments.swift
│ │ ├── Components/
│ │ │ ├── AddressField.swift
│ │ │ ├── ButtonStyles/
│ │ │ │ ├── DisabledButtonStyle.swift
│ │ │ │ ├── PrimaryButtonStyle.swift
│ │ │ │ └── SecondaryButtonStyle.swift
│ │ │ ├── EditableList/
│ │ │ │ ├── EditableList.swift
│ │ │ │ └── EditorView.swift
│ │ │ ├── EmailField.swift
│ │ │ ├── IconButton.swift
│ │ │ ├── LegacyFormattedTextView.swift
│ │ │ ├── OptionalNumberField.swift
│ │ │ ├── PingIndicator.swift
│ │ │ └── PixellatedBorder.swift
│ │ ├── Config/
│ │ │ ├── Config.swift
│ │ │ ├── ConfigError.swift
│ │ │ └── ManagedConfig.swift
│ │ ├── DeltaClientApp.swift
│ │ ├── Discord/
│ │ │ ├── DiscordManager.swift
│ │ │ └── DiscordPresenceState.swift
│ │ ├── Extensions/
│ │ │ ├── Binding+onChange.swift
│ │ │ ├── Box+ObservableObject.swift
│ │ │ ├── TaskProgress+ObservableObject.swift
│ │ │ └── View.swift
│ │ ├── GitHub/
│ │ │ ├── GitHubBranch.swift
│ │ │ ├── GitHubCommit.swift
│ │ │ ├── GitHubComparison.swift
│ │ │ └── GitHubReleasesAPIResponse.swift
│ │ ├── Input/
│ │ │ ├── Controller.swift
│ │ │ ├── ControllerHub.swift
│ │ │ └── InputMethod.swift
│ │ ├── Logger.swift
│ │ ├── Modal.swift
│ │ ├── State/
│ │ │ ├── AppState.swift
│ │ │ └── StateWrapper.swift
│ │ ├── StorageDirectory.swift
│ │ ├── Utility/
│ │ │ ├── Clipboard.swift
│ │ │ ├── Updater.swift
│ │ │ └── Utils.swift
│ │ ├── Views/
│ │ │ ├── Play/
│ │ │ │ ├── DirectConnectView.swift
│ │ │ │ ├── GameView.swift
│ │ │ │ ├── InGameMenu.swift
│ │ │ │ ├── InputView.swift
│ │ │ │ ├── JoinServerAndThen.swift
│ │ │ │ ├── MetalView.swift
│ │ │ │ ├── PlayView.swift
│ │ │ │ ├── SelectAccountAndThen.swift
│ │ │ │ ├── SelectInputMethodAndThen.swift
│ │ │ │ ├── SelectOption.swift
│ │ │ │ ├── WithController.swift
│ │ │ │ ├── WithRenderCoordinator.swift
│ │ │ │ └── WithSelectedAccount.swift
│ │ │ ├── RouterView.swift
│ │ │ ├── ServerList/
│ │ │ │ ├── LANServerList.swift
│ │ │ │ ├── ServerDetail.swift
│ │ │ │ ├── ServerListItem.swift
│ │ │ │ └── ServerListView.swift
│ │ │ ├── Settings/
│ │ │ │ ├── Account/
│ │ │ │ │ ├── AccountLoginView.swift
│ │ │ │ │ ├── AccountSettingsView.swift
│ │ │ │ │ ├── MicrosoftLoginView.swift
│ │ │ │ │ ├── MojangLoginView.swift
│ │ │ │ │ └── OfflineLoginView.swift
│ │ │ │ ├── ControlsSettingsView.swift
│ │ │ │ ├── KeymapEditorView.swift
│ │ │ │ ├── PluginSettingsView.swift
│ │ │ │ ├── Server/
│ │ │ │ │ ├── EditServerListView.swift
│ │ │ │ │ └── ServerEditorView.swift
│ │ │ │ ├── SettingsView.swift
│ │ │ │ ├── TroubleShootingView.swift
│ │ │ │ ├── UpdateView.swift
│ │ │ │ └── VideoSettingsView.swift
│ │ │ └── Startup/
│ │ │ ├── LoadAndThen.swift
│ │ │ ├── ProgressLoadingView.swift
│ │ │ └── StartupStep.swift
│ │ └── main.swift
│ ├── ClientGtk/
│ │ ├── ChatView.swift
│ │ ├── DeltaClientApp.swift
│ │ ├── GameView.swift
│ │ ├── ServerListView.swift
│ │ ├── Settings/
│ │ │ ├── AccountInspectionView.swift
│ │ │ ├── AccountListView.swift
│ │ │ ├── MicrosoftLoginView.swift
│ │ │ ├── OfflineLoginView.swift
│ │ │ └── SettingsView.swift
│ │ └── Storage/
│ │ ├── Config.swift
│ │ ├── ConfigError.swift
│ │ ├── ConfigManager.swift
│ │ └── StorageManager.swift
│ ├── Core/
│ │ ├── Logger/
│ │ │ └── Logger.swift
│ │ ├── Package.resolved
│ │ ├── Package.swift
│ │ ├── Renderer/
│ │ │ ├── Camera/
│ │ │ │ ├── Camera.swift
│ │ │ │ └── Frustum.swift
│ │ │ ├── CameraUniforms.swift
│ │ │ ├── CaptureState.swift
│ │ │ ├── CelestialBodyUniforms.swift
│ │ │ ├── ChunkUniforms.swift
│ │ │ ├── EndSkyUniforms.swift
│ │ │ ├── EndSkyVertex.swift
│ │ │ ├── Entity/
│ │ │ │ ├── EntityRenderer.swift
│ │ │ │ └── EntityVertex.swift
│ │ │ ├── EntityUniforms.swift
│ │ │ ├── FogUniforms.swift
│ │ │ ├── GUI/
│ │ │ │ ├── GUIContext.swift
│ │ │ │ ├── GUIElementMesh.swift
│ │ │ │ ├── GUIElementMeshArray.swift
│ │ │ │ ├── GUIElementUniforms.swift
│ │ │ │ ├── GUIQuad.swift
│ │ │ │ ├── GUIRenderer.swift
│ │ │ │ ├── GUIRendererError.swift
│ │ │ │ ├── GUIUniforms.swift
│ │ │ │ ├── GUIVertex.swift
│ │ │ │ ├── GUIVertexStorage.swift
│ │ │ │ ├── TextMeshBuilder.swift
│ │ │ │ └── TextMeshBuilderError.swift
│ │ │ ├── Logger.swift
│ │ │ ├── Mesh/
│ │ │ │ ├── BlockMeshBuilder.swift
│ │ │ │ ├── BlockNeighbour.swift
│ │ │ │ ├── ChunkSectionMesh.swift
│ │ │ │ ├── ChunkSectionMeshBuilder.swift
│ │ │ │ ├── CubeGeometry.swift
│ │ │ │ ├── EntityMeshBuilder.swift
│ │ │ │ ├── FluidMeshBuilder.swift
│ │ │ │ ├── Geometry.swift
│ │ │ │ ├── Mesh.swift
│ │ │ │ ├── SortableMesh.swift
│ │ │ │ └── SortableMeshElement.swift
│ │ │ ├── RenderCoordinator.swift
│ │ │ ├── RenderError.swift
│ │ │ ├── Renderer.swift
│ │ │ ├── RenderingMeasurement.swift
│ │ │ ├── Resources/
│ │ │ │ ├── Font+Metal.swift
│ │ │ │ └── MetalTexturePalette.swift
│ │ │ ├── ScreenRenderer.swift
│ │ │ ├── Shader/
│ │ │ │ ├── ChunkOITShaders.metal
│ │ │ │ ├── ChunkShaders.metal
│ │ │ │ ├── ChunkTypes.metal
│ │ │ │ ├── EntityShaders.metal
│ │ │ │ ├── GUIShaders.metal
│ │ │ │ ├── GUITypes.metal
│ │ │ │ ├── ScreenShaders.metal
│ │ │ │ └── SkyShaders.metal
│ │ │ ├── SkyBoxRenderer.swift
│ │ │ ├── SkyPlaneUniforms.swift
│ │ │ ├── StarUniforms.swift
│ │ │ ├── SunriseDiscUniforms.swift
│ │ │ ├── Util/
│ │ │ │ └── MetalUtil.swift
│ │ │ └── World/
│ │ │ ├── BlockVertex.swift
│ │ │ ├── LightMap.swift
│ │ │ ├── Visibility/
│ │ │ │ ├── ChunkSectionFace.swift
│ │ │ │ ├── ChunkSectionFaceConnectivity.swift
│ │ │ │ ├── ChunkSectionVoxelGraph.swift
│ │ │ │ ├── VisibilityGraph+SearchQueueEntry.swift
│ │ │ │ └── VisibilityGraph.swift
│ │ │ ├── WorldMesh.swift
│ │ │ ├── WorldMeshWorker+Job.swift
│ │ │ ├── WorldMeshWorker.swift
│ │ │ └── WorldRenderer.swift
│ │ ├── Sources/
│ │ │ ├── Account/
│ │ │ │ ├── Account.swift
│ │ │ │ ├── Microsoft/
│ │ │ │ │ ├── MicrosoftAPI.swift
│ │ │ │ │ ├── MicrosoftAccessToken.swift
│ │ │ │ │ ├── MicrosoftAccount.swift
│ │ │ │ │ ├── Request/
│ │ │ │ │ │ ├── MinecraftXboxAuthenticationRequest.swift
│ │ │ │ │ │ ├── XSTSAuthenticationRequest.swift
│ │ │ │ │ │ └── XboxLiveAuthenticationRequest.swift
│ │ │ │ │ ├── Response/
│ │ │ │ │ │ ├── GameOwnershipResponse.swift
│ │ │ │ │ │ ├── MicrosoftAccessTokenResponse.swift
│ │ │ │ │ │ ├── MicrosoftDeviceAuthorizationResponse.swift
│ │ │ │ │ │ ├── MicrosoftMinecraftProfileResponse.swift
│ │ │ │ │ │ ├── MinecraftXboxAuthenticationResponse.swift
│ │ │ │ │ │ ├── XSTSAuthenticationError.swift
│ │ │ │ │ │ ├── XSTSAuthenticationResponse.swift
│ │ │ │ │ │ └── XboxLiveAuthenticationResponse.swift
│ │ │ │ │ └── XboxLiveToken.swift
│ │ │ │ ├── MinecraftAccessToken.swift
│ │ │ │ ├── Mojang/
│ │ │ │ │ ├── MojangAPI.swift
│ │ │ │ │ ├── MojangAccount.swift
│ │ │ │ │ ├── Request/
│ │ │ │ │ │ ├── MojangAuthenticationRequest.swift
│ │ │ │ │ │ ├── MojangJoinRequest.swift
│ │ │ │ │ │ └── MojangRefreshTokenRequest.swift
│ │ │ │ │ └── Response/
│ │ │ │ │ ├── MojangAuthenticationResponse.swift
│ │ │ │ │ └── MojangRefreshTokenResponse.swift
│ │ │ │ ├── OfflineAccount.swift
│ │ │ │ └── OnlineAccount.swift
│ │ │ ├── Cache/
│ │ │ │ ├── BinaryCacheable.swift
│ │ │ │ ├── BinarySerialization.swift
│ │ │ │ ├── BlockModelPalette+BinaryCacheable.swift
│ │ │ │ ├── Cacheable.swift
│ │ │ │ ├── FontPalette+BinaryCacheable.swift
│ │ │ │ ├── ItemModelPalette+BinaryCacheable.swift
│ │ │ │ ├── Registry/
│ │ │ │ │ ├── BiomeRegistry+JSONCacheable.swift
│ │ │ │ │ ├── BlockRegistry+BinaryCacheable.swift
│ │ │ │ │ ├── EntityRegistry+JSONCacheable.swift
│ │ │ │ │ ├── FluidRegistry+JSONCacheable.swift
│ │ │ │ │ ├── ItemRegistry+JSONCacheable.swift
│ │ │ │ │ └── JSONCacheable.swift
│ │ │ │ └── TexturePalette+BinaryCacheable.swift
│ │ │ ├── Chat/
│ │ │ │ ├── Chat.swift
│ │ │ │ ├── ChatComponent/
│ │ │ │ │ ├── ChatComponent.swift
│ │ │ │ │ ├── ChatComponentColor.swift
│ │ │ │ │ ├── ChatComponentContent.swift
│ │ │ │ │ ├── ChatComponentError.swift
│ │ │ │ │ ├── ChatComponentLocalizedContent.swift
│ │ │ │ │ ├── ChatComponentScoreContent.swift
│ │ │ │ │ └── ChatComponentStyle.swift
│ │ │ │ ├── ChatMessage.swift
│ │ │ │ └── LegacyFormattedText/
│ │ │ │ ├── LegacyFormattedText.swift
│ │ │ │ ├── LegacyFormattedTextColor.swift
│ │ │ │ ├── LegacyFormattedTextError.swift
│ │ │ │ ├── LegacyFormattedTextFormattingCode.swift
│ │ │ │ ├── LegacyFormattedTextStyle.swift
│ │ │ │ └── LegacyFormattedTextToken.swift
│ │ │ ├── Client.swift
│ │ │ ├── ClientConfiguration.swift
│ │ │ ├── Constants.swift
│ │ │ ├── Datatypes/
│ │ │ │ ├── Axis.swift
│ │ │ │ ├── BlockPosition.swift
│ │ │ │ ├── CardinalDirection.swift
│ │ │ │ ├── Difficulty.swift
│ │ │ │ ├── Direction.swift
│ │ │ │ ├── DirectionSet.swift
│ │ │ │ ├── DominantHand.swift
│ │ │ │ ├── Equipment.swift
│ │ │ │ ├── Gamemode.swift
│ │ │ │ ├── Hand.swift
│ │ │ │ ├── Identifier.swift
│ │ │ │ ├── IdentifierError.swift
│ │ │ │ ├── ItemStack.swift
│ │ │ │ ├── NBT/
│ │ │ │ │ ├── NBT.swift
│ │ │ │ │ ├── NBTCompound.swift
│ │ │ │ │ ├── NBTList.swift
│ │ │ │ │ ├── NBTTag.swift
│ │ │ │ │ └── NBTTagType.swift
│ │ │ │ ├── PlayerEntityAction.swift
│ │ │ │ ├── PlayerFlags.swift
│ │ │ │ ├── Slot.swift
│ │ │ │ ├── Statistic.swift
│ │ │ │ └── UUID.swift
│ │ │ ├── Duration.swift
│ │ │ ├── ECS/
│ │ │ │ ├── BlockEntity.swift
│ │ │ │ ├── Components/
│ │ │ │ │ ├── EnderDragonParts.swift
│ │ │ │ │ ├── EntityAcceleration.swift
│ │ │ │ │ ├── EntityAttributes.swift
│ │ │ │ │ ├── EntityCamera.swift
│ │ │ │ │ ├── EntityExperience.swift
│ │ │ │ │ ├── EntityFlying.swift
│ │ │ │ │ ├── EntityHeadYaw.swift
│ │ │ │ │ ├── EntityHealth.swift
│ │ │ │ │ ├── EntityHitBox.swift
│ │ │ │ │ ├── EntityId.swift
│ │ │ │ │ ├── EntityKindId.swift
│ │ │ │ │ ├── EntityLerpState.swift
│ │ │ │ │ ├── EntityMetadata.swift
│ │ │ │ │ ├── EntityNutrition.swift
│ │ │ │ │ ├── EntityOnGround.swift
│ │ │ │ │ ├── EntityPosition.swift
│ │ │ │ │ ├── EntityRotation.swift
│ │ │ │ │ ├── EntitySneaking.swift
│ │ │ │ │ ├── EntitySprinting.swift
│ │ │ │ │ ├── EntityUUID.swift
│ │ │ │ │ ├── EntityVelocity.swift
│ │ │ │ │ ├── Marker/
│ │ │ │ │ │ ├── ClientPlayerEntity.swift
│ │ │ │ │ │ ├── LivingEntity.swift
│ │ │ │ │ │ ├── NonLivingEntity.swift
│ │ │ │ │ │ └── PlayerEntity.swift
│ │ │ │ │ ├── ObjectData.swift
│ │ │ │ │ ├── ObjectUUID.swift
│ │ │ │ │ ├── PlayerAttributes.swift
│ │ │ │ │ ├── PlayerCollisionState.swift
│ │ │ │ │ ├── PlayerFOV.swift
│ │ │ │ │ ├── PlayerGamemode.swift
│ │ │ │ │ └── PlayerInventory.swift
│ │ │ │ ├── Singles/
│ │ │ │ │ ├── ClientboundEntityPacketStore.swift
│ │ │ │ │ ├── GUIStateStorage.swift
│ │ │ │ │ └── InputState.swift
│ │ │ │ └── Systems/
│ │ │ │ ├── EntityMovementSystem.swift
│ │ │ │ ├── EntitySmoothingSystem.swift
│ │ │ │ ├── PacketHandlingSystem.swift
│ │ │ │ ├── PlayerAccelerationSystem.swift
│ │ │ │ ├── PlayerBlockBreakingSystem.swift
│ │ │ │ ├── PlayerClimbSystem.swift
│ │ │ │ ├── PlayerCollisionSystem.swift
│ │ │ │ ├── PlayerFOVSystem.swift
│ │ │ │ ├── PlayerFlightSystem.swift
│ │ │ │ ├── PlayerFrictionSystem.swift
│ │ │ │ ├── PlayerGravitySystem.swift
│ │ │ │ ├── PlayerInputSystem.swift
│ │ │ │ ├── PlayerJumpSystem.swift
│ │ │ │ ├── PlayerPacketSystem.swift
│ │ │ │ ├── PlayerPositionSystem.swift
│ │ │ │ ├── PlayerSmoothingSystem.swift
│ │ │ │ ├── PlayerVelocitySystem.swift
│ │ │ │ └── System.swift
│ │ │ ├── FileSystem.swift
│ │ │ ├── GUI/
│ │ │ │ ├── BossBar.swift
│ │ │ │ ├── Constraints.swift
│ │ │ │ ├── GUIBuilder.swift
│ │ │ │ ├── GUIElement.swift
│ │ │ │ ├── GUISprite.swift
│ │ │ │ ├── GUISpriteDescriptor.swift
│ │ │ │ ├── HorizontalConstraint.swift
│ │ │ │ ├── HorizontalOffset.swift
│ │ │ │ ├── InGameGUI.swift
│ │ │ │ ├── RenderStatistics.swift
│ │ │ │ ├── VerticalConstraint.swift
│ │ │ │ ├── VerticalOffset.swift
│ │ │ │ ├── Window.swift
│ │ │ │ ├── WindowArea.swift
│ │ │ │ └── WindowType.swift
│ │ │ ├── GUIState.swift
│ │ │ ├── Game.swift
│ │ │ ├── Input/
│ │ │ │ ├── Input.swift
│ │ │ │ ├── Key.swift
│ │ │ │ ├── Keymap.swift
│ │ │ │ └── ModifierKey.swift
│ │ │ ├── Logger.swift
│ │ │ ├── Network/
│ │ │ │ ├── Cipher.swift
│ │ │ │ ├── ConnectionState.swift
│ │ │ │ ├── Endianness.swift
│ │ │ │ ├── LANServerEnumerator.swift
│ │ │ │ ├── Protocol/
│ │ │ │ │ ├── Buffer.swift
│ │ │ │ │ ├── BufferError.swift
│ │ │ │ │ ├── PacketRegistry.swift
│ │ │ │ │ ├── PacketState.swift
│ │ │ │ │ ├── Packets/
│ │ │ │ │ │ ├── ClientboundEntityPacket.swift
│ │ │ │ │ │ ├── ClientboundPacket.swift
│ │ │ │ │ │ ├── Handshaking/
│ │ │ │ │ │ │ └── Serverbound/
│ │ │ │ │ │ │ └── HandshakePacket.swift
│ │ │ │ │ │ ├── Login/
│ │ │ │ │ │ │ ├── Clientbound/
│ │ │ │ │ │ │ │ ├── EncryptionRequestPacket.swift
│ │ │ │ │ │ │ │ ├── LoginDisconnectPacket.swift
│ │ │ │ │ │ │ │ ├── LoginPluginRequestPacket.swift
│ │ │ │ │ │ │ │ ├── LoginSuccessPacket.swift
│ │ │ │ │ │ │ │ └── SetCompressionPacket.swift
│ │ │ │ │ │ │ └── Serverbound/
│ │ │ │ │ │ │ ├── EncryptionResponsePacket.swift
│ │ │ │ │ │ │ ├── LoginPluginResponsePacket.swift
│ │ │ │ │ │ │ └── LoginStartPacket.swift
│ │ │ │ │ │ ├── PacketReader.swift
│ │ │ │ │ │ ├── PacketReaderError.swift
│ │ │ │ │ │ ├── PacketWriter.swift
│ │ │ │ │ │ ├── Play/
│ │ │ │ │ │ │ ├── Clientbound/
│ │ │ │ │ │ │ │ ├── AcknowledgePlayerDiggingPacket.swift
│ │ │ │ │ │ │ │ ├── AdvancementsPacket.swift
│ │ │ │ │ │ │ │ ├── AttachEntityPacket.swift
│ │ │ │ │ │ │ │ ├── BlockActionPacket.swift
│ │ │ │ │ │ │ │ ├── BlockBreakAnimationPacket.swift
│ │ │ │ │ │ │ │ ├── BlockChangePacket.swift
│ │ │ │ │ │ │ │ ├── BlockEntityDataPacket.swift
│ │ │ │ │ │ │ │ ├── BossBarPacket.swift
│ │ │ │ │ │ │ │ ├── CameraPacket.swift
│ │ │ │ │ │ │ │ ├── ChangeGameStatePacket.swift
│ │ │ │ │ │ │ │ ├── ChatMessageClientboundPacket.swift
│ │ │ │ │ │ │ │ ├── ChunkDataPacket.swift
│ │ │ │ │ │ │ │ ├── CloseWindowClientboundPacket.swift
│ │ │ │ │ │ │ │ ├── CollectItemPacket.swift
│ │ │ │ │ │ │ │ ├── CombatEventPacket.swift
│ │ │ │ │ │ │ │ ├── CraftRecipeResponsePacket.swift
│ │ │ │ │ │ │ │ ├── DeclareCommandsPacket.swift
│ │ │ │ │ │ │ │ ├── DeclareRecipesPacket.swift
│ │ │ │ │ │ │ │ ├── DestroyEntitiesPacket.swift
│ │ │ │ │ │ │ │ ├── DisplayScoreboardPacket.swift
│ │ │ │ │ │ │ │ ├── EffectPacket.swift
│ │ │ │ │ │ │ │ ├── EntityAnimationPacket.swift
│ │ │ │ │ │ │ │ ├── EntityAttributesPacket.swift
│ │ │ │ │ │ │ │ ├── EntityEffectPacket.swift
│ │ │ │ │ │ │ │ ├── EntityEquipmentPacket.swift
│ │ │ │ │ │ │ │ ├── EntityHeadLookPacket.swift
│ │ │ │ │ │ │ │ ├── EntityMetadataPacket.swift
│ │ │ │ │ │ │ │ ├── EntityMovementPacket.swift
│ │ │ │ │ │ │ │ ├── EntityPositionAndRotationPacket.swift
│ │ │ │ │ │ │ │ ├── EntityPositionPacket.swift
│ │ │ │ │ │ │ │ ├── EntityRotationPacket.swift
│ │ │ │ │ │ │ │ ├── EntitySoundEffectPacket.swift
│ │ │ │ │ │ │ │ ├── EntityStatusPacket.swift
│ │ │ │ │ │ │ │ ├── EntityTeleportPacket.swift
│ │ │ │ │ │ │ │ ├── EntityVelocityPacket.swift
│ │ │ │ │ │ │ │ ├── ExplosionPacket.swift
│ │ │ │ │ │ │ │ ├── FacePlayerPacket.swift
│ │ │ │ │ │ │ │ ├── HeldItemChangePacket.swift
│ │ │ │ │ │ │ │ ├── JoinGamePacket.swift
│ │ │ │ │ │ │ │ ├── KeepAliveClientboundPacket.swift
│ │ │ │ │ │ │ │ ├── MapDataPacket.swift
│ │ │ │ │ │ │ │ ├── MultiBlockUpdatePacket.swift
│ │ │ │ │ │ │ │ ├── NBTQueryResponsePacket.swift
│ │ │ │ │ │ │ │ ├── NamedSoundEffectPacket.swift
│ │ │ │ │ │ │ │ ├── OpenBookPacket.swift
│ │ │ │ │ │ │ │ ├── OpenHorseWindowPacket.swift
│ │ │ │ │ │ │ │ ├── OpenSignEditorPacket.swift
│ │ │ │ │ │ │ │ ├── OpenWindowPacket.swift
│ │ │ │ │ │ │ │ ├── ParticlePacket.swift
│ │ │ │ │ │ │ │ ├── PlayDisconnectPacket.swift
│ │ │ │ │ │ │ │ ├── PlayerAbilitiesPacket.swift
│ │ │ │ │ │ │ │ ├── PlayerInfoPacket.swift
│ │ │ │ │ │ │ │ ├── PlayerListHeaderAndFooterPacket.swift
│ │ │ │ │ │ │ │ ├── PlayerPositionAndLookClientboundPacket.swift
│ │ │ │ │ │ │ │ ├── PluginMessagePacket.swift
│ │ │ │ │ │ │ │ ├── RemoveEntityEffectPacket.swift
│ │ │ │ │ │ │ │ ├── ResourcePackSendPacket.swift
│ │ │ │ │ │ │ │ ├── RespawnPacket.swift
│ │ │ │ │ │ │ │ ├── ScoreboardObjectivePacket.swift
│ │ │ │ │ │ │ │ ├── SelectAdvancementTabPacket.swift
│ │ │ │ │ │ │ │ ├── ServerDifficultyPacket.swift
│ │ │ │ │ │ │ │ ├── SetCooldownPacket.swift
│ │ │ │ │ │ │ │ ├── SetExperiencePacket.swift
│ │ │ │ │ │ │ │ ├── SetPassengersPacket.swift
│ │ │ │ │ │ │ │ ├── SetSlotPacket.swift
│ │ │ │ │ │ │ │ ├── SoundEffectPacket.swift
│ │ │ │ │ │ │ │ ├── SpawnEntityPacket.swift
│ │ │ │ │ │ │ │ ├── SpawnExperienceOrbPacket.swift
│ │ │ │ │ │ │ │ ├── SpawnLivingEntityPacket.swift
│ │ │ │ │ │ │ │ ├── SpawnPaintingPacket.swift
│ │ │ │ │ │ │ │ ├── SpawnPlayerPacket.swift
│ │ │ │ │ │ │ │ ├── SpawnPositionPacket.swift
│ │ │ │ │ │ │ │ ├── StatisticsPacket.swift
│ │ │ │ │ │ │ │ ├── StopSoundPacket.swift
│ │ │ │ │ │ │ │ ├── TabCompleteClientboundPacket.swift
│ │ │ │ │ │ │ │ ├── TagsPacket.swift
│ │ │ │ │ │ │ │ ├── TeamsPacket.swift
│ │ │ │ │ │ │ │ ├── TimeUpdatePacket.swift
│ │ │ │ │ │ │ │ ├── TitlePacket.swift
│ │ │ │ │ │ │ │ ├── TradeListPacket.swift
│ │ │ │ │ │ │ │ ├── UnloadChunkPacket.swift
│ │ │ │ │ │ │ │ ├── UnlockRecipesPacket.swift
│ │ │ │ │ │ │ │ ├── UpdateHealthPacket.swift
│ │ │ │ │ │ │ │ ├── UpdateLightPacket.swift
│ │ │ │ │ │ │ │ ├── UpdateScorePacket.swift
│ │ │ │ │ │ │ │ ├── UpdateViewDistancePacket.swift
│ │ │ │ │ │ │ │ ├── UpdateViewPositionPacket.swift
│ │ │ │ │ │ │ │ ├── VehicleMoveClientboundPacket.swift
│ │ │ │ │ │ │ │ ├── WindowConfirmationClientboundPacket.swift
│ │ │ │ │ │ │ │ ├── WindowItemsPacket.swift
│ │ │ │ │ │ │ │ ├── WindowPropertyPacket.swift
│ │ │ │ │ │ │ │ └── WorldBorderPacket.swift
│ │ │ │ │ │ │ └── Serverbound/
│ │ │ │ │ │ │ ├── AdvancementTabPacket.swift
│ │ │ │ │ │ │ ├── AnimationServerboundPacket.swift
│ │ │ │ │ │ │ ├── ChatMessageServerboundPacket.swift
│ │ │ │ │ │ │ ├── ClickWindowButtonPacket.swift
│ │ │ │ │ │ │ ├── ClickWindowPacket.swift
│ │ │ │ │ │ │ ├── ClientSettingsPacket.swift
│ │ │ │ │ │ │ ├── ClientStatusPacket.swift
│ │ │ │ │ │ │ ├── CloseWindowServerboundPacket.swift
│ │ │ │ │ │ │ ├── CraftRecipeRequestPacket.swift
│ │ │ │ │ │ │ ├── CreativeInventoryActionPacket.swift
│ │ │ │ │ │ │ ├── EditBookPacket.swift
│ │ │ │ │ │ │ ├── EntityActionPacket.swift
│ │ │ │ │ │ │ ├── GenerateStructurePacket.swift
│ │ │ │ │ │ │ ├── HeldItemChangeServerboundPacket.swift
│ │ │ │ │ │ │ ├── InteractEntityPacket.swift
│ │ │ │ │ │ │ ├── KeepAliveServerboundPacket.swift
│ │ │ │ │ │ │ ├── LockDifficultyPacket.swift
│ │ │ │ │ │ │ ├── NameItemPacket.swift
│ │ │ │ │ │ │ ├── PickItemPacket.swift
│ │ │ │ │ │ │ ├── PlayerAbilitiesServerboundPacket.swift
│ │ │ │ │ │ │ ├── PlayerBlockPlacementPacket.swift
│ │ │ │ │ │ │ ├── PlayerDiggingPacket.swift
│ │ │ │ │ │ │ ├── PlayerMovementPacket.swift
│ │ │ │ │ │ │ ├── PlayerPositionAndRotationServerboundPacket.swift
│ │ │ │ │ │ │ ├── PlayerPositionPacket.swift
│ │ │ │ │ │ │ ├── PlayerRotationPacket.swift
│ │ │ │ │ │ │ ├── PluginMessageServerboundPacket.swift
│ │ │ │ │ │ │ ├── QueryBlockNBTPacket.swift
│ │ │ │ │ │ │ ├── QueryEntityNBTPacket.swift
│ │ │ │ │ │ │ ├── RecipeBookDataPacket.swift
│ │ │ │ │ │ │ ├── ResourcePackStatusPacket.swift
│ │ │ │ │ │ │ ├── SelectTradePacket.swift
│ │ │ │ │ │ │ ├── SetBeaconEffectPacket.swift
│ │ │ │ │ │ │ ├── SetDifficultyPacket.swift
│ │ │ │ │ │ │ ├── SpectatePacket.swift
│ │ │ │ │ │ │ ├── SteerBoatPacket.swift
│ │ │ │ │ │ │ ├── SteerVehiclePacket.swift
│ │ │ │ │ │ │ ├── TabCompleteServerboundPacket.swift
│ │ │ │ │ │ │ ├── TeleportConfirmPacket.swift
│ │ │ │ │ │ │ ├── UpdateCommandBlockMinecartPacket.swift
│ │ │ │ │ │ │ ├── UpdateCommandBlockPacket.swift
│ │ │ │ │ │ │ ├── UpdateJigsawBlockPacket.swift
│ │ │ │ │ │ │ ├── UpdateSignPacket.swift
│ │ │ │ │ │ │ ├── UpdateStructureBlockPacket.swift
│ │ │ │ │ │ │ ├── UseItemPacket.swift
│ │ │ │ │ │ │ ├── VehicleMoveServerboundPacket.swift
│ │ │ │ │ │ │ └── WindowConfirmationServerboundPacket.swift
│ │ │ │ │ │ ├── ServerboundPacket.swift
│ │ │ │ │ │ └── Status/
│ │ │ │ │ │ ├── Clientbound/
│ │ │ │ │ │ │ ├── PongPacket.swift
│ │ │ │ │ │ │ └── StatusResponsePacket.swift
│ │ │ │ │ │ └── Serverbound/
│ │ │ │ │ │ ├── PingPacket.swift
│ │ │ │ │ │ └── StatusRequestPacket.swift
│ │ │ │ │ └── ProtocolVersion.swift
│ │ │ │ ├── ServerConnection.swift
│ │ │ │ ├── Socket+Darwin.swift
│ │ │ │ ├── Socket+Glibc.swift
│ │ │ │ ├── Socket.swift
│ │ │ │ ├── SocketError.swift
│ │ │ │ ├── SocketOption.swift
│ │ │ │ └── Stack/
│ │ │ │ ├── Layers/
│ │ │ │ │ ├── CompressionLayer.swift
│ │ │ │ │ ├── EncryptionLayer.swift
│ │ │ │ │ ├── PacketLayer.swift
│ │ │ │ │ └── SocketLayer.swift
│ │ │ │ └── NetworkStack.swift
│ │ │ ├── Physics/
│ │ │ │ ├── AxisAlignedBoundingBox.swift
│ │ │ │ ├── CompoundBoundingBox.swift
│ │ │ │ ├── PhysicsConstants.swift
│ │ │ │ ├── Ray.swift
│ │ │ │ └── VoxelRay.swift
│ │ │ ├── Player/
│ │ │ │ ├── Player.swift
│ │ │ │ ├── PlayerInfo.swift
│ │ │ │ └── PlayerProperty.swift
│ │ │ ├── Plugin/
│ │ │ │ ├── Event/
│ │ │ │ │ ├── CaptureCursorEvent.swift
│ │ │ │ │ ├── ChatMessageReceivedEvent.swift
│ │ │ │ │ ├── Connection/
│ │ │ │ │ │ ├── ConnectionFailedEvent.swift
│ │ │ │ │ │ ├── ConnectionReadyEvent.swift
│ │ │ │ │ │ ├── LoginDisconnectEvent.swift
│ │ │ │ │ │ ├── LoginStartEvent.swift
│ │ │ │ │ │ ├── LoginSuccessEvent.swift
│ │ │ │ │ │ ├── PacketDecodingErrorEvent.swift
│ │ │ │ │ │ ├── PacketHandlingErrorEvent.swift
│ │ │ │ │ │ └── PlayDisconnectEvent.swift
│ │ │ │ │ ├── ErrorEvent.swift
│ │ │ │ │ ├── Event.swift
│ │ │ │ │ ├── EventBus.swift
│ │ │ │ │ ├── Input/
│ │ │ │ │ │ ├── KeyPressEvent.swift
│ │ │ │ │ │ ├── KeyReleaseEvent.swift
│ │ │ │ │ │ ├── OpenInGameMenuEvent.swift
│ │ │ │ │ │ └── ReleaseCursorEvent.swift
│ │ │ │ │ ├── Render/
│ │ │ │ │ │ └── FinishFrameCaptureEvent.swift
│ │ │ │ │ └── World/
│ │ │ │ │ ├── AddChunk.swift
│ │ │ │ │ ├── JoinWorldEvent.swift
│ │ │ │ │ ├── MultiBlockUpdate.swift
│ │ │ │ │ ├── RemoveChunk.swift
│ │ │ │ │ ├── SingleBlockUpdate.swift
│ │ │ │ │ ├── TerrainDownloadCompletionEvent.swift
│ │ │ │ │ ├── TimeUpdate.swift
│ │ │ │ │ ├── UpdateChunk.swift
│ │ │ │ │ ├── UpdateChunkLighting.swift
│ │ │ │ │ └── WorldEvent.swift
│ │ │ │ ├── Plugin.swift
│ │ │ │ ├── PluginBuilder.swift
│ │ │ │ ├── PluginEnvironment.swift
│ │ │ │ ├── PluginLoadingError.swift
│ │ │ │ └── PluginManifest.swift
│ │ │ ├── Recipe/
│ │ │ │ ├── BlastingRecipe.swift
│ │ │ │ ├── CampfireCookingRecipe.swift
│ │ │ │ ├── CraftingRecipe.swift
│ │ │ │ ├── CraftingShaped.swift
│ │ │ │ ├── CraftingShapeless.swift
│ │ │ │ ├── HeatRecipe.swift
│ │ │ │ ├── Ingredient.swift
│ │ │ │ ├── RecipeItem.swift
│ │ │ │ ├── RecipeRegistry.swift
│ │ │ │ ├── SmeltingRecipe.swift
│ │ │ │ ├── SmithingRecipe.swift
│ │ │ │ ├── SmokingRecipe.swift
│ │ │ │ ├── SpecialCrafting/
│ │ │ │ │ ├── ArmorDyeRecipe.swift
│ │ │ │ │ ├── BannerAddPatternRecipe.swift
│ │ │ │ │ ├── BannerDuplicateRecipe.swift
│ │ │ │ │ ├── BookCloningRecipe.swift
│ │ │ │ │ ├── FireworkRocketRecipe.swift
│ │ │ │ │ ├── FireworkStarFadeRecipe.swift
│ │ │ │ │ ├── FireworkStarRecipe.swift
│ │ │ │ │ ├── MapCloningRecipe.swift
│ │ │ │ │ ├── MapExtendingRecipe.swift
│ │ │ │ │ ├── RepairItemRecipe.swift
│ │ │ │ │ ├── ShieldDecorationRecipe.swift
│ │ │ │ │ ├── ShulkerBoxColouringRecipe.swift
│ │ │ │ │ ├── SpecialRecipe.swift
│ │ │ │ │ ├── SuspiciousStewRecipe.swift
│ │ │ │ │ └── TippedArrowRecipe.swift
│ │ │ │ └── StonecuttingRecipe.swift
│ │ │ ├── Registry/
│ │ │ │ ├── Biome/
│ │ │ │ │ ├── Biome.swift
│ │ │ │ │ ├── BiomeCategory.swift
│ │ │ │ │ ├── BiomeCriteria.swift
│ │ │ │ │ ├── BiomeModifiers.swift
│ │ │ │ │ └── BiomePrecipitationType.swift
│ │ │ │ ├── BiomeRegistry.swift
│ │ │ │ ├── Block/
│ │ │ │ │ ├── Block.swift
│ │ │ │ │ ├── BlockLightMaterial.swift
│ │ │ │ │ ├── BlockOffset.swift
│ │ │ │ │ ├── BlockPhysicalMaterial.swift
│ │ │ │ │ ├── BlockShape.swift
│ │ │ │ │ ├── BlockSoundMaterial.swift
│ │ │ │ │ ├── BlockStateProperties.swift
│ │ │ │ │ └── BlockTint.swift
│ │ │ │ ├── BlockRegistry.swift
│ │ │ │ ├── Entity/
│ │ │ │ │ ├── EntityAttributeKey.swift
│ │ │ │ │ ├── EntityAttributeModifier.swift
│ │ │ │ │ ├── EntityAttributeValue.swift
│ │ │ │ │ └── EntityKind.swift
│ │ │ │ ├── EntityRegistry.swift
│ │ │ │ ├── Fluid/
│ │ │ │ │ ├── Fluid.swift
│ │ │ │ │ └── FluidState.swift
│ │ │ │ ├── FluidRegistry.swift
│ │ │ │ ├── Item/
│ │ │ │ │ ├── Item.swift
│ │ │ │ │ └── ItemRarity.swift
│ │ │ │ ├── ItemRegistry.swift
│ │ │ │ ├── Pixlyzer/
│ │ │ │ │ ├── PixlyzerAABB.swift
│ │ │ │ │ ├── PixlyzerBiome.swift
│ │ │ │ │ ├── PixlyzerBlock.swift
│ │ │ │ │ ├── PixlyzerBlockModelDescriptor.swift
│ │ │ │ │ ├── PixlyzerBlockState.swift
│ │ │ │ │ ├── PixlyzerEntity.swift
│ │ │ │ │ ├── PixlyzerFluid.swift
│ │ │ │ │ ├── PixlyzerFormatter.swift
│ │ │ │ │ ├── PixlyzerItem.swift
│ │ │ │ │ ├── PixlyzerShapeRegistry.swift
│ │ │ │ │ └── SingleOrMultiple.swift
│ │ │ │ └── RegistryStore.swift
│ │ │ ├── RenderConfiguration.swift
│ │ │ ├── RenderMode.swift
│ │ │ ├── Resources/
│ │ │ │ ├── Biome/
│ │ │ │ │ ├── BiomeColorMap.swift
│ │ │ │ │ └── BiomeColors.swift
│ │ │ │ ├── Font/
│ │ │ │ │ ├── BitmapFontProvider.swift
│ │ │ │ │ ├── CharacterDescriptor.swift
│ │ │ │ │ ├── Font.swift
│ │ │ │ │ ├── FontManifest.swift
│ │ │ │ │ ├── FontPalette.swift
│ │ │ │ │ ├── FontProvider.swift
│ │ │ │ │ ├── LegacyUnicodeFontProvider.swift
│ │ │ │ │ └── TrueTypeFontProvider.swift
│ │ │ │ ├── GUI/
│ │ │ │ │ ├── GUITexturePalette.swift
│ │ │ │ │ └── GUITextureSlice.swift
│ │ │ │ ├── Locale/
│ │ │ │ │ ├── LocalizationFormatter.swift
│ │ │ │ │ └── MinecraftLocale.swift
│ │ │ │ ├── MCMeta/
│ │ │ │ │ ├── AnimationMCMeta.swift
│ │ │ │ │ └── PackMCMeta.swift
│ │ │ │ ├── Manifest/
│ │ │ │ │ ├── VersionManifest.swift
│ │ │ │ │ └── VersionsManifest.swift
│ │ │ │ ├── Model/
│ │ │ │ │ ├── Block/
│ │ │ │ │ │ ├── BlockModel.swift
│ │ │ │ │ │ ├── BlockModelElement.swift
│ │ │ │ │ │ ├── BlockModelFace.swift
│ │ │ │ │ │ ├── BlockModelPalette.swift
│ │ │ │ │ │ ├── BlockModelPaletteError.swift
│ │ │ │ │ │ ├── BlockModelPart.swift
│ │ │ │ │ │ ├── BlockModelRenderDescriptor.swift
│ │ │ │ │ │ ├── Intermediate/
│ │ │ │ │ │ │ ├── IntermediateBlockModel.swift
│ │ │ │ │ │ │ ├── IntermediateBlockModelElement.swift
│ │ │ │ │ │ │ ├── IntermediateBlockModelElementRotation.swift
│ │ │ │ │ │ │ ├── IntermediateBlockModelFace.swift
│ │ │ │ │ │ │ └── IntermediateBlockModelPalette.swift
│ │ │ │ │ │ └── JSON/
│ │ │ │ │ │ ├── JSONBlockModel.swift
│ │ │ │ │ │ ├── JSONBlockModelAxis.swift
│ │ │ │ │ │ ├── JSONBlockModelElement.swift
│ │ │ │ │ │ ├── JSONBlockModelElementRotation.swift
│ │ │ │ │ │ ├── JSONBlockModelFace.swift
│ │ │ │ │ │ └── JSONBlockModelFaceName.swift
│ │ │ │ │ ├── Entity/
│ │ │ │ │ │ ├── EntityModelPalette.swift
│ │ │ │ │ │ └── JSON/
│ │ │ │ │ │ └── JSONEntityModel.swift
│ │ │ │ │ ├── Item/
│ │ │ │ │ │ ├── ItemModel.swift
│ │ │ │ │ │ ├── ItemModelPalette.swift
│ │ │ │ │ │ ├── ItemModelPaletteError.swift
│ │ │ │ │ │ ├── ItemModelTexture.swift
│ │ │ │ │ │ └── JSON/
│ │ │ │ │ │ ├── JSONItemModel.swift
│ │ │ │ │ │ ├── JSONItemModelGUILight.swift
│ │ │ │ │ │ └── JSONItemModelOverride.swift
│ │ │ │ │ ├── JSON/
│ │ │ │ │ │ ├── JSONModelDisplayTransforms.swift
│ │ │ │ │ │ └── JSONModelTransform.swift
│ │ │ │ │ └── ModelDisplayTransforms.swift
│ │ │ │ ├── ResourcePack.swift
│ │ │ │ ├── Resources.swift
│ │ │ │ └── Texture/
│ │ │ │ ├── ColorMap.swift
│ │ │ │ ├── Texture.swift
│ │ │ │ ├── TextureAnimation.swift
│ │ │ │ ├── TextureAnimationState.swift
│ │ │ │ ├── TexturePalette.swift
│ │ │ │ ├── TexturePaletteAnimationState.swift
│ │ │ │ └── TextureType.swift
│ │ │ ├── Server/
│ │ │ │ ├── Ping/
│ │ │ │ │ ├── PingError.swift
│ │ │ │ │ ├── Pinger.swift
│ │ │ │ │ └── StatusResponse.swift
│ │ │ │ ├── ServerDescriptor.swift
│ │ │ │ └── TabList.swift
│ │ │ ├── Util/
│ │ │ │ ├── Array.swift
│ │ │ │ ├── ArrayBinding.swift
│ │ │ │ ├── BinaryFloatingPoint.swift
│ │ │ │ ├── BinaryUtil.swift
│ │ │ │ ├── Box.swift
│ │ │ │ ├── Character.swift
│ │ │ │ ├── ColorUtil.swift
│ │ │ │ ├── CompressionUtil.swift
│ │ │ │ ├── ContentType.swift
│ │ │ │ ├── CryptoUtil.swift
│ │ │ │ ├── CustomJSONDecoder.swift
│ │ │ │ ├── Dictionary.swift
│ │ │ │ ├── Either.swift
│ │ │ │ ├── FileManager.swift
│ │ │ │ ├── FontUtil.swift
│ │ │ │ ├── FunctionalProgramming.swift
│ │ │ │ ├── Image.swift
│ │ │ │ ├── Int.swift
│ │ │ │ ├── MathUtil.swift
│ │ │ │ ├── Matrix.swift
│ │ │ │ ├── MatrixUtil.swift
│ │ │ │ ├── Profiler.swift
│ │ │ │ ├── RGBColor.swift
│ │ │ │ ├── Random.swift
│ │ │ │ ├── ReadWriteLock.swift
│ │ │ │ ├── Request.swift
│ │ │ │ ├── RequestMethod.swift
│ │ │ │ ├── RequestUtil.swift
│ │ │ │ ├── RichError.swift
│ │ │ │ ├── SIMD.swift
│ │ │ │ ├── Stopwatch.swift
│ │ │ │ ├── Task/
│ │ │ │ │ ├── TaskProgress.swift
│ │ │ │ │ └── TaskStep.swift
│ │ │ │ ├── ThreadUtil.swift
│ │ │ │ ├── TickScheduler.swift
│ │ │ │ ├── URL.swift
│ │ │ │ └── Vector.swift
│ │ │ └── World/
│ │ │ ├── BreakingBlock.swift
│ │ │ ├── Chunk/
│ │ │ │ ├── Chunk.swift
│ │ │ │ ├── ChunkNeighbours.swift
│ │ │ │ ├── ChunkPosition.swift
│ │ │ │ ├── ChunkSection.swift
│ │ │ │ ├── ChunkSectionPosition.swift
│ │ │ │ └── HeightMap.swift
│ │ │ ├── DaylightCyclePhase.swift
│ │ │ ├── Dimension/
│ │ │ │ └── Dimension.swift
│ │ │ ├── Fog.swift
│ │ │ ├── Light/
│ │ │ │ ├── ChunkLighting.swift
│ │ │ │ ├── ChunkLightingUpdateData.swift
│ │ │ │ ├── LightLevel.swift
│ │ │ │ └── LightingEngine.swift
│ │ │ ├── Targeted.swift
│ │ │ ├── Thing.swift
│ │ │ └── World.swift
│ │ └── Tests/
│ │ └── DeltaCoreUnitTests/
│ │ ├── BufferTests.swift
│ │ ├── ChatComponentTests.swift
│ │ ├── IdentifierTests.swift
│ │ ├── LegacyFormattedTextTests.swift
│ │ └── LocalizationFormatterTests.swift
│ └── Exporters/
│ ├── DynamicShim/
│ │ └── Exports.swift
│ └── StaticShim/
│ └── Exports.swift
├── build.sh
└── lint.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
root = true
[*]
indent_style = space
indent_size = 2
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: stackotter
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Logs**
If applicable, obtain the logs at `~/Library/Application Support/dev.stackotter.delta-client/logs/delta-client.log`
and attach the relevant part here (probably the last few lines). This is made easy by the `View > Logs`
menu bar item.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Extra information (please complete the following information**
- OS: [e.g. macOS 11.5.1]
- Hardware: [e.g. M1 MacBook Air]
- Build: [e.g. commit 060e29e or Snapshot 9]
**Additional context**
Add any other context about the problem here.
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/pull_request_template.md
================================================
# Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
Fixes # (issue) (delete if these changes aren't for fixing an issue)
## Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
# Checklist:
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation comments
- [ ] My changes generate no new warnings
================================================
FILE: .github/workflows/build.yml
================================================
name: Build
on:
push:
pull_request:
workflow_dispatch:
jobs:
build-macos:
runs-on: macOS-15
steps:
- name: Checkout
uses: actions/checkout@v6
- name: List Xcodes
run: ls /Applications
- name: Force Xcode 16.4
run: sudo xcode-select -switch /Applications/Xcode_16.4.app
- name: Version
run: swift --version
- name: Cache swift-bundler
id: cache-swift-bundler
uses: actions/cache@v5
with:
path: sbun
key: ${{ runner.os }}-swift-bundler
- name: Build swift-bundler
if: steps.cache-swift-bundler.outputs.cache-hit != 'true'
run: |
git clone https://github.com/moreSwift/swift-bundler
cd swift-bundler
git checkout 6d72c4f442cc2c57c2559f3df21b3777b1d0a917
swift build --product swift-bundler
cp .build/debug/swift-bundler ../sbun
- name: Build arm64
run: |
./sbun bundle -c release --arch arm64
mv "$(./sbun bundle --show-bundle-path)" DeltaClient-arm64.app
- name: Build x86
run: |
./sbun bundle -c release --arch x86_64
mv "$(./sbun bundle --show-bundle-path)" DeltaClient-x86_64.app
- name: Zip .app (arm64)
run: zip -r DeltaClient-arm64.zip DeltaClient-arm64.app
- name: Zip .app (x86_64)
run: zip -r DeltaClient-x86_64.zip DeltaClient-x86_64.app
- name: Upload artifact (arm64)
uses: actions/upload-artifact@v7
with:
name: DeltaClient-arm64
path: ./DeltaClient-arm64.zip
- name: Upload artifact (x86_64)
uses: actions/upload-artifact@v7
with:
name: DeltaClient-x86_64
path: ./DeltaClient-x86_64.zip
build-linux:
runs-on: ubuntu-latest
steps:
- name: Setup Swift
uses: SwiftyLab/setup-swift@latest
with:
swift-version: "5.9"
- name: Checkout
uses: actions/checkout@v6
- name: Build
run: |
cd Sources/Core
swift build
================================================
FILE: .github/workflows/swiftlint.yml
================================================
name: Lint
on:
push:
pull_request:
workflow_dispatch:
jobs:
swift-lint:
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Lint
run: |
URL="https://github.com/realm/SwiftLint/releases/download/0.50.3/portable_swiftlint.zip"
curl -LO "$URL"
unzip portable_swiftlint -d ./swiftlint
rm -rf portable_swiftlint.zip
echo "Linting with swiftlint $(./swiftlint/swiftlint version)"
./swiftlint/swiftlint lint --reporter github-actions-logging
shell: bash
================================================
FILE: .github/workflows/test.yml
================================================
name: Test
on:
push:
pull_request:
workflow_dispatch:
jobs:
test-macos:
runs-on: macOS-15
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Force Xcode 16.4
run: sudo xcode-select -switch /Applications/Xcode_16.4.app
- name: Version
run: swift --version
- name: Test
run: |
cd Sources/Core
swift test
test-linux:
runs-on: ubuntu-latest
steps:
- name: Setup Swift
uses: SwiftyLab/setup-swift@latest
with:
swift-version: "5.9"
- name: Checkout
uses: actions/checkout@v6
- name: Test
run: |
cd Sources/Core
swift test
================================================
FILE: .gitignore
================================================
.DS_Store
.build
.docc-build
/Packages
*.xcodeproj
xcuserdata/
*.xcworkspace
/DeltaClient.app
/.swiftpm
/.vscode
.swiftpm
/assets
/cache
/registry
================================================
FILE: .swift-format
================================================
{
"version": 1,
"indentation": {
"spaces": 2
},
"indentSwitchCaseLabels": true
}
================================================
FILE: .swiftlint.yml
================================================
excluded:
- "**/.build"
- "Sources/Core/Sources/Cache/Protobuf/Generated/BlockRegistry.pb.swift"
- "Sources/Core/Sources/Cache/Protobuf/Generated/BlockModelPalette.pb.swift"
# TODO: Reexclude once swiftlint github action is updated to support globs
# - "**/*.pb.swift"
disabled_rules:
- switch_case_alignment
- trailing_whitespace
- identifier_name
- opening_brace # Has false positives in the code base
# TODO: Re-enable these rules later once more warnings are fixed
- nesting
- todo
line_length: 160
type_body_length: 300
function_parameter_count: 8
file_length: 500
function_body_length: 50
cyclomatic_complexity:
error: 40 # TODO: reset once more occurrences are fixed
# Custom rules
custom_rules:
comments_space: # from https://github.com/brandenr/swiftlintconfig
name: "Space After Comment"
regex: '(^ *//\w+)'
message: "There should be a space after //"
severity: error
# TODO: Once there are less warnings and violations, make the rules stricter and add some opt in ones
================================================
FILE: Bundler.toml
================================================
format_version = 2
[apps.DeltaClient]
product = 'DeltaClient'
version = 'v0.1.0-alpha.1'
identifier = 'dev.stackotter.delta-client'
category = 'public.app-category.games'
icon = 'AppIcon.icns'
[apps.DeltaClient.plist]
# Append the current commit hash to the user-facing version string
CFBundleShortVersionString = "$(VERSION), commit: $(COMMIT_HASH)"
GCSupportsControllerUserInteraction = "True"
MetalCaptureEnabled = true
================================================
FILE: Contributing.md
================================================
# Contributing
Delta Client is completely open source and I welcome contributions of all kinds. If you're
interested in contributing, you can checkout the [delta client issues](https://github.com/stackotter/delta-client/issues)
and [delta client website issues](https://github.com/stackotter/delta-website) ( on GitHub for some
tasks. Some of the tasks don't even require Swift! But before you get too excited, make sure that
you've read the contributing guidelines, and make sure that your contributions follow them. If you
need any help with a contribution, feel free to join the [Discord](https://discord.gg/xZPyDbmR6k)
and chat :)
Note: when you've decided on an issue to work on, please leave a comment on it so that everyone else
knows not to work on it.
## Guidelines
If your contributions follow these guidelines, they'll be much more likely to get accepted first try
:thumbsup:
1. Make sure your indent size matches the repository (in the case of delta-client that's 2 spaces).
2. Be conscious of copyright and don't include any files distributed by Mojang in these
repositories.
3. Be concise, only make changes that are required to achieve your end goal. The smaller your pull
request, the faster I'll get around to reviewing it.
7. Add documentation comments for any methods or properties you create unless their usage is
completely self-evident. Be sure to also document potentially unexpected side-effects or
non-obvious requirements of methods.
4. Remove file headers from all files you create, they're unnecessary. `swift-bundler` will
automatically remove them for you whenever you build.
5. Use `log` for logging (not just print statements everywhere).
6. If in doubt, consult [Google's Swift style guide](https://google.github.io/swift/#function-declarations)
because that's the one I try to follow.
## Getting setup
### Delta Client
**Important**: Only Xcode 14+ is supported, Xcode 12 builds don't work because Delta Client uses new
automatic `Codable` conformance and there are some weird discrepancies between Xcode 12's swift
compiler and Xcode 14+'s swift compiler. Xcode 13 isn't supported because it causes some weird memory
corruption issues.
[Delta Client](https://github.com/stackotter/delta-client) uses the
[swift-bundler](https://github.com/stackotter/swift-bundler) build system so make sure you install
that.
You can use any ide you want to work on Delta Client (vscode and xcode are the best supported), but
you'll need Xcode installed anyway because sadly that's currently the only way to get Metal and
SwiftUI build support.
Next, fork Delta Client and then clone it.
```sh
git clone [url of your delta-client fork]
cd delta-client
```
To run Delta Client, you can run `swift bundler run -c release`. If you are working on the UI you
can leave out the `-c release`, it is only required when working with computationally intense parts
of the client such as rendering, because without optimizations those parts of the client are
unusable. See the [swift-bundler repo](https://github.com/stackotter/swift-bundler) for more
commands and options.
If you are using Xcode as your IDE run `swift bundler generate-xcode-support` and then open
Package.swift with Xcode (`open Package.swift` should work unless you've changed your default
program for opening swift files). **Make sure to choose the `DeltaClient` target in the top bar
instead of the `DeltaClient-Package` target.**
**Note: Xcode puts DeltaCore in the dependencies section of the file navigator instead of at its
physical location in the directory structure. This is due to the way the plugin system had to be
implemented.**
You can now make changes and when you're done, just open a pull request on GitHub.
### Website
The [website](https://delta.stackotter.dev) is built with svelte. Just follow these steps to get
started;
1. Fork and clone [delta-website](https://github.com/stackotter/delta-website)
2. Run `npm i`
3. Run `npm run dev` to start a development server. Whenever you save changes to a file, the page
will almost instantly reload with the changes, and most of the time it'll retain its state too
(pretty cool)
================================================
FILE: LICENSE
================================================
### GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
### Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom
to share and change all versions of a program--to make sure it remains
free software for all its users. We, the Free Software Foundation, use
the GNU General Public License for most of our software; it applies
also to any other work released this way by its authors. You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you
have certain responsibilities if you distribute copies of the
software, or if you modify it: responsibilities to respect the freedom
of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the
manufacturer can do so. This is fundamentally incompatible with the
aim of protecting users' freedom to change the software. The
systematic pattern of such abuse occurs in the area of products for
individuals to use, which is precisely where it is most unacceptable.
Therefore, we have designed this version of the GPL to prohibit the
practice for those products. If such problems arise substantially in
other domains, we stand ready to extend this provision to those
domains in future versions of the GPL, as needed to protect the
freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish
to avoid the special danger that patents applied to a free program
could make it effectively proprietary. To prevent this, the GPL
assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
### TERMS AND CONDITIONS
#### 0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds
of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of
an exact copy. The resulting work is called a "modified version" of
the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user
through a computer network, with no transfer of a copy, is not
conveying.
An interactive user interface displays "Appropriate Legal Notices" to
the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
#### 1. Source Code.
The "source code" for a work means the preferred form of the work for
making modifications to it. "Object code" means any non-source form of
a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can
regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same
work.
#### 2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey,
without conditions so long as your license otherwise remains in force.
You may convey covered works to others for the sole purpose of having
them make modifications exclusively for you, or provide you with
facilities for running those works, provided that you comply with the
terms of this License in conveying all material for which you do not
control copyright. Those thus making or running the covered works for
you must do so exclusively on your behalf, under your direction and
control, on terms that prohibit them from making any copies of your
copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the
conditions stated below. Sublicensing is not allowed; section 10 makes
it unnecessary.
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such
circumvention is effected by exercising rights under this License with
respect to the covered work, and you disclaim any intention to limit
operation or modification of the work as a means of enforcing, against
the work's users, your or third parties' legal rights to forbid
circumvention of technological measures.
#### 4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
#### 5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these
conditions:
- a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
released under this License and any conditions added under
section 7. This requirement modifies the requirement in section 4
to "keep intact all notices".
- c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
#### 6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of
sections 4 and 5, provided that you also convey the machine-readable
Corresponding Source under the terms of this License, in one of these
ways:
- a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the Corresponding
Source from a network server at no charge.
- c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
- d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
- e) Convey the object code using peer-to-peer transmission,
provided you inform other peers where the object code and
Corresponding Source of the work are being offered to the general
public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal,
family, or household purposes, or (2) anything designed or sold for
incorporation into a dwelling. In determining whether a product is a
consumer product, doubtful cases shall be resolved in favor of
coverage. For a particular product received by a particular user,
"normally used" refers to a typical or common use of that class of
product, regardless of the status of the particular user or of the way
in which the particular user actually uses, or expects or is expected
to use, the product. A product is a consumer product regardless of
whether the product has substantial commercial, industrial or
non-consumer uses, unless such uses represent the only significant
mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to
install and execute modified versions of a covered work in that User
Product from a modified version of its Corresponding Source. The
information must suffice to ensure that the continued functioning of
the modified object code is in no case prevented or interfered with
solely because modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or
updates for a work that has been modified or installed by the
recipient, or for the User Product in which it has been modified or
installed. Access to a network may be denied when the modification
itself materially and adversely affects the operation of the network
or violates the rules and protocols for communication across the
network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
#### 7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders
of that material) supplement the terms of this License with terms:
- a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
- c) Prohibiting misrepresentation of the origin of that material,
or requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
- d) Limiting the use for publicity purposes of names of licensors
or authors of the material; or
- e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
- f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions
of it) with contractual assumptions of liability to the recipient,
for any liability that these contractual assumptions directly
impose on those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions; the
above requirements apply either way.
#### 8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
#### 9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run
a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
#### 10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
#### 11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned
or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within the
scope of its coverage, prohibits the exercise of, or is conditioned on
the non-exercise of one or more of the rights that are specifically
granted under this License. You may not convey a covered work if you
are a party to an arrangement with a third party that is in the
business of distributing software, under which you make payment to the
third party based on the extent of your activity of conveying the
work, and under which the third party grants, to any of the parties
who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by
you (or copies made from those copies), or (b) primarily for and in
connection with specific products or compilations that contain the
covered work, unless you entered into that arrangement, or that patent
license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
#### 12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under
this License and any other pertinent obligations, then as a
consequence you may not convey it at all. For example, if you agree to
terms that obligate you to collect a royalty for further conveying
from those to whom you convey the Program, the only way you could
satisfy both those terms and this License would be to refrain entirely
from conveying the Program.
#### 13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
#### 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions
of the GNU General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in
detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies that a certain numbered version of the GNU General Public
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that numbered version or
of any later version published by the Free Software Foundation. If the
Program does not specify a version number of the GNU General Public
License, you may choose any version ever published by the Free
Software Foundation.
If the Program specifies that a proxy can decide which future versions
of the GNU General Public License can be used, that proxy's public
statement of acceptance of a version permanently authorizes you to
choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
#### 15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
#### 16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#### 17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
### How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively state
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper
mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands \`show w' and \`show c' should show the
appropriate parts of the General Public License. Of course, your
program's commands might be different; for a GUI interface, you would
use an "about box".
You should also get your employer (if you work as a programmer) or
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. For more information on this, and how to apply and follow
the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your
program into proprietary programs. If your program is a subroutine
library, you may consider it more useful to permit linking proprietary
applications with the library. If this is what you want to do, use the
GNU Lesser General Public License instead of this License. But first,
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
================================================
FILE: Notes/Caching.md
================================================
# Caching
Delta Client uses caching to speed up launches by orders of magnitude. The only thing I cache at the moment are block models because these can take up to 30 seconds to load from the JSON model descriptors with my current method (optimisation attempts are very welcome). To decide which serialization technique to use I created a test project and implemented multiple methods of caching the vanilla block model palette. Below is my interpretation of the [results](#the-numbers);
The first implementation was made using [Flatbuffers](https://github.com/google/flatbuffers) and the other was made using [Protobuf](https://github.com/protocolbuffers/protobuf). In release builds, Flatbuffers was faster at deserialization but slower than serialization. In this use case, deserialization performance is really the only thing we care about. To an end user only release build performance matters but when I'm developing the client, debug build performance greatly affects development speed. Interestingly, in debug builds, the fastest at serialization was Flatbuffers (by quite a bit), and Protobuf was over 3 times faster than Flatbuffers at deserialization.
Now that I understood how Flatbuffers worked, I created an implementation that took a similar approach to my neater Protobuf-base implementation. This new Flatbuffers-based implementation was close enough to Protobuf deserialization speed in debug builds, and the serialization speed was pretty much the same as the original Flatbuffers-based implementation. However, in release builds deserialization speeds were now almost twice as slow as Protobuf and serialization speeds were also the slowest out of all three. Somehow, a change that almost doubled debug build performance significantly slowed down release performance?
I have also previously tried out FastBinaryEncoding but it was quite a bit slower at deserialization (more like 2 seconds in release builds). To its credit, it did manage to encode it all into only 13mb which is pretty impressive. But that matters less than performance to me.
## The verdict
For now I will be using Protobufs for caching because they are nicer to use and their performance is more consistent between debug and release builds. They also have the fastest debug build deserialization speed which is what I really care about right now, and the release build serialization speed wasn't too far off the fastest solution in the grand scheme of things. It also has the fastest release build serialization by far. It's only main downfall is that its debug build serialization speed is dismal. Oh, and It also had the smallest serialized size as an added bonus.
## The numbers
### Flatbuffers (with messy code)
Serialized size: 21601644 bytes
| Operation | Debug | Release |
| ----------- | ------- | ------- |
| Serialize | 17676ms | 2185ms |
| Deserialize | 23190ms | 368ms |
### Flatbuffers, cleaner code
Serialized size: 21601644 bytes
| Operation | Debug | Release |
| ----------- | ------- | ------- |
| Serialize | 18661ms | 2601ms |
| Deserialize | 11760ms | 972ms |
### Protobuf
Serialized size: 16630993 bytes
| Operation | Debug | Release |
| ----------- | ------- | ------- |
| Serialize | 29436ms | 1219ms |
| Deserialize | 7490ms | 551ms |
## Sticky encoding
[Sticky encoding](https://github.com/stickytools/sticky-encoding) looks quite enticing too so I tried it out. All it requires is adding Codable conformance to the types that need to be serialized. However, I tried it out and it's awfully slow (likely because of limitations of Swift's Codable implementation). In debug builds, both serialize and deserialize took over 50 seconds, and in release builds, serialize took around 14 seconds and deserialize took around 12 seconds. It would be nice to use such a nice solution, but it just can't meet our performance requirements.
## Custom binary serialization
As an experiment, I have started implementing a custom serialization and deserialization API that
uses the Minecraft network protocol's binary format behind the scenes. The initial implementation
with no optimization was quite promisingsd. Given that I've gotten a new laptop and the block model
format has changed a lot, here are the initial results including the new Protobuf and Flatbuffer
times. I've removed `Flatbuffers (with messy code)` because it would've been too much work to
reimplement it for the newer block model palette format, and realistically it's not how I would
implement it in Delta Client because it's just too difficult to maintain. I will also not be testing
debug build performance because that's not important to me anymore now that my laptop can demolish
release builds and run debug builds at a reasonable speed.
| Method & Operation | Release |
| --------------------------- | ----------- |
| Flatbuffers serialization | 470.42799ms |
| Flatbuffers deserialization | 341.62700ms |
| Protobuf serialization | 342.27204ms |
| Protobuf deserialization | 181.43606ms |
| Custom serialization | 54.83699ms |
| Custom deserialization | 516.13605ms |
The serialization speed is almost 7x faster than Protobuf! The order of magnitude difference between
serialization and deserialization tells me that deserialization should have some pretty easy
optimizations to make.
| Method | Serialized size |
| ----------- | --------------- |
| Flatbuffers | 21472396 bytes |
| Protobuf | 15105882 bytes |
| Custom | 22136216 bytes |
As you can see, the new custom method takes significantly more storage than Protobuf, and a tiny bit
more than Flatbuffers, but this isn't very important to me because it's still only 22ish megabytes
which is completely acceptable for a cache.
### Optimizing custom serialization and deserialization
Using Xcode instruments, I found that the `uvs` property of `BlockModelFace` is the most expensive
part of deserializing the block model palette. Optimizing the float decoding code path (which uses
the fixed length integer decoding code path of `Buffer`) by rearranging code to avoid a call to
`Array.reversed` managed to speed up deserialization by 1.7x (to 294.46900ms).
Because `uvs` is so performance critical, I ended up using some unsafe pointer stuff to avoid
unnecessary copies and byte reordering (caused by MC protocol). I basically just store the Float
array's raw bytes in the cache directly because it's a fixed length array. This increased the
deserialization speed by 2.09x (to 140.65397ms). This change also decreased the serialized size to
20229880 bytes (almost a 9% decrease).
After some further optimization of `Buffer.readInteger(size:endianness:)` I managed to get another
2x deserialization speed improvement (down to 69.15092ms).
I ended up deviating from the Minecraft protocol for integers to allow the use of unsafe pointers to
decode them which gave another 1.23x increase in deserialization speed (down to 56.47790ms).
Essentially I just store integers by copying their raw bytes so that while deserializing I can just
get a pointer into the reader's buffer and cast it to a pointer to an integer.
The next optimization gave a massive improvement by greatly simplifying the serialization and
deserialization process for bitwise copyable types. These types can simply just have their raw bytes
copied into the output and subsequently these bytes can be copied out as that type when
deserializing (using unsafe pointer tricks). This gave another 1.52x improvement in deserialization
speed (down to 37.13298ms). It also gave us our first big improvement in serialization speed of 1.3x
(down to 38.87498ms).
Given that `BlockModelFace` is the most performance critical part of serializing/deserializing the
block model palette and it's technically a fixed amount of data, I decided to try making it a
bitwise copyable type. All this involved was converting the fixed length array of `uvs` to a
tuple-equivalent `struct`. I wasn't able to use a tuple because I needed `uvs` to be `Equatable` and
tuples can't conform to protocols (how silly). After removing all use of indirection from
`BlockModelFace` I was able to improve deserialization times by a factor of around 4.5 (to around
8.6ms).
At this point, a large majority of the serialization time is allocations and appending to arrays. I
tried using `Array.init(unsafeUninitializedCapacity:initializingWith:)` to avoid unnecessary
allocations and append operations, however this ended up making the code slower. Either way, 8ms is
definitely fast enough for this application :sweat_smile:.
### Results
| Method & Operation | Release |
| --------------------------- | ----------- |
| Flatbuffers serialization | 470.42799ms |
| Flatbuffers deserialization | 341.62700ms |
| Protobuf serialization | 343.40799ms |
| Protobuf deserialization | 181.43606ms |
| Custom serialization | 50.11296ms |
| Custom deserialization | 8.18300ms |
Somewhere along the way I managed to reverse a majority of the progress that I made on serialization
performance, but this is fine for my caching needs because cache generation shouldn't happen very
often at all.
| Method | Serialized size |
| ----------- | --------------- |
| Flatbuffers | 21472396 bytes |
| Protobuf | 15105882 bytes |
| Custom | 18839177 bytes |
I'm not quite sure exactly what optimizations ended up decreasing the serialized so much for the
custom serializer, but I guess it's a pleasant side effect!
### Conclusion
I managed to create a custom binary serialization solution that is 22.2x faster at deserialization
than Protobuf, 6.85x faster at serialization than Protobuf, and way more maintainable than an
equivalent Protobuf-based caching system.
Although I started out with the plan to use the Minecraft network protocol binary format to store
the cache, I quickly realised that the Minecraft network protocol just isn't built for high
performance serialization and deserialization. That's why I ended up just creating an approach that
is essentially a fancy memdump that can handle indirection and complicated data structures.
### Aftermath
I've implemented binary caching for the item model palette, block registry, font palette, and
texture palettes (almost all of the expensive things to load). Overall this amounted to a 4x faster
app launch time which is pretty amazing. The caching code is also way nicer than the old Protobuf
stuff, and any optimization of BinarySerializable will basically have an effect on all of the
expensive start up tasks making it a very appealing target. However, startup time is now 160ms (when
files have been cached in memory by previous launches; it's around 200ms when they haven't been), so
I don't think I need to put in any more work for now :sweat_smile:.
================================================
FILE: Notes/ChunkPreparation.md
================================================
# Chunk preparation optimisation
Chunk mesh preparation is one of the prime areas of focus for optimisation efforts. Fast chunk loading is extremely important for that snappy feeling. There a few ideas for optimising chunk preparation that I have and here they are;
## Initial benchmarks
I have created a swiftpm executable that can download specified chunks from a server and then save them to allow repeated consistent tests. This is what I will be evaluating performance gains with. I have gathered data on the time spent in each of the main high level tasks required when meshing each block and ordered them by which requires more attention (which ones take the longest). Initial measurements were of delta-core commit c9f0d1c6dab773802fd69bedf3675d0255fadf13. The chunk section being prepared is section -20 0 -14 in seed -6243685378508790499.
1. getCullingNeighbours: 0.0178ms, the longest task by far
2. getBlockModels: 0.0026ms, this one is surprising given it's just a quick lookup, perhaps this is why getCullingNeighbours is so slow
3. getNeighbourLightLevels: 0.0025ms
4. adding the block models to the mesh: 0.0010ms
Total time: 102.8528ms
## Improving getCullingNeighbours
getBlockModels was the main issue in this case, accessing the resources of a resource pack was super slow because of the use of a computed property called `vanillaResources` that took a stupidly large amount of time. First I tried changing the block models storage to use an array instead of a dictionary but there was no noticable performance difference. Fixing this issue made getCullingNeighbours 5x faster.
1. getCullingNeighbours: 0.0038ms, still the longest task
2. getNeighbourLightLevels: 0.0026ms
3. adding the block models to the mesh: 0.0011ms
4. getBlockModels: 0.0002ms, that's more like it
New total time: 28.0777ms (3.7x faster than original)
## Improving getNeighbourLightLevels and getCullingNeighbours
The second biggest bottleneck was calculating neighbour indices, lots of branching could be eliminated from this function I think but it would greatly complicate the logic of the function and make it massive. So instead of optimising the function I just calculate neighbour indices once instead of twice and pass them to both functions that require them.
1. getCullingNeighbours: 0.0025ms
2. getNeighbourLightLevels: 0.0016ms
3. getNeighbourIndices: 0.0012ms
4. add block models: 0.0010ms
New total time: 22.8666ms (4.5x faster than original)
## Improving getNeighbourIndices
Reserve capacity was the big winner here. Reserving a capacity of 6 won 0.0007ms (more than 2x faster). I also tried wrapping arithmetic (unchecked), but that didn't seem to make a noticable difference. Probably because the function is mostly bottlenecked by branching and collection operations.
1. getCullingNeighbours: 0.00253ms
2. getNeighbourLightLevels: 0.00160ms
3. getNeighbourIndices: 0.00055ms (more than 2x faster)
4. add block models: 0.00092ms
## Improving getNeighbourLightLevels
I tried reserve capacity for this getting light levels and culling faces too and it made light levels more than 2x faster as well! Not such a big gain for getCullingNeighbours, but still like a 20% reduction.
1. getCullingNeighbours: 0.00208ms
2. add block models: 0.00096ms
3. getNeighbourLightLevels: 0.00084ms
4. getNeighbourIndices: 0.00053ms
New total time: 15.8036 (6.5x faster than original, 1.45x faster than previous total time measurement)
## Improving getNeighbourBlockStates and adding block models
I also added reserve capacity to getNeighbourBlockStates which made getCullingNeighbours 1.6x faster. I then fixed the way texture info was accessed (same issue as getting block models had before). This made adding block models 1.8x faster.
1. getCullingNeighbours: 0.00129ms, 1.6x faster than before
2. getNeighbourLightLevels: 0.00080ms
3. add block models: 0.00051ms, 1.8x faster than before
4. getNeighbourIndices: 0.00049ms
New total time: 11.6262 (8.8x faster than original, 1.35x faster than previous)
## Improving everything
I moved some work from mesh preparation to resource pack loading time, just flattened some information and added a list of cullable and noncullable faces too. This information also makes it easier to detect that a block isn't visible earlier. I also now only do light level lookups for required faces
From now on times will be as total time spent in that task over the course of preparing the whole section because the flow of what tasks are done for each block is more complex now. There will be discrepancies between the sum of the measurements and the 'New total time' because the timer has some overhead.
1. calculate face visibility: 7.65150ms
2. get block models: 1.37812ms
3. get neighbour indices: 1.01480ms
4. add block models: 0.46374ms
New total time: 7.5382ms (13.4x faster than original, 1.54x faster than previous)
## Improving face visibility calculation
I added two ifs to early exit the calculation for most blocks, and use arrays and iteration instead of a dictionary for neighbour indices.
1. get culling neighbours: 4.48527ms
2. get block models: 1.41321ms
3. calculate face visibility: 0.98564ms
4. get neighbour indices: 0.86533ms
New total time: 5.7885ms
## Improving block model getting
I now store block models in an array instead of a dictionary because dictionaries are slow.
1. get culling neighbours: 4.12294ms
2. calculate face visibility: 1.03458ms
3. get neighbour indices: 0.96912ms
4. get block models: 0.87172ms
5. add block models: 0.49894ms
New total time: 4.9672ms
It now takes 8-9 seconds to prepare all chunks within 10 render distance.
## Replacing Set<Direction> with DirectionSet (a bitset-based implementation)
This is just overall a much better data structure for the situation. It also ended up improving the
block model cache loading time by a bit over 20% because the data structure is much better suited to
binary caching (fixed size and just a single integer).
Original total time: 6.03ms (not sure whether my computer was slower or the mesh builder slowly got
slower)
New total time: 3.35ms (1.8x faster than with Set<Direction>)
================================================
FILE: Notes/DebuggingDeadlocks.md
================================================
# Debugging deadlocks
The more high performance parts of Delta Client use locks to ensure threadsafety (instead of higher
level and slower concepts such as dispatch queues). This is all well and good until a subtle bug
causes a deadlock and ruins your day. This document will hopefully help you find the cause faster.
## The basics
Where applicable, many methods have an `acquireLock` parameter to allow callers to have more control
over how locking occurs. The most common use case for this is calling a locking function from within
another locking function. If either of the functions requires a write lock, you're in trouble, and
the easiest way to avoid this issue is to call the inner function with `acquireLock: false`. Make
sure that the outer function acquires a lock that is at least as permissive as the inner function
requires. For example, if the inner function normally acquires a write lock, the outer function must
acquire a write lock too.
## Pay attention to lock levels
Often locks are arranged into levels, `World` has `terrainLock` for accessing chunks from the chunk
storage, and then `Chunk` has `lock` for accessing its stored information. If some code has a chunk
lock and wants to acquire a terrain lock, but some other code already has a terrain lock and is
waiting for a chunk lock, you will get a deadlock. This can be a lot more subtle than a regular
deadlock. The rule of thumb here is to only get more and more specific locks when locking and avoid
having a specific lock while getting a general lock. If impossible (or tedious) to obey this rule in
a certain bit of code, it is also possible to use caution and carefully ensure that one of the
offending bits of code only takes one lock at a time (as seen in commit
[17fb74bc36ad5b6619d6a6066ebf47073ff22659](https://github.com/stackotter/delta-client/commit/17fb74bc36ad5b6619d6a6066ebf47073ff22659)).
## `ClientboundEntityPacket`'s
When implementing the `handle` method of a `ClientboundEntityPacket`, ensure that you do not attempt
to acquire any locks on the ECS nexus. This is because these packets are handled in the
`EntityPacketSystem` which is run during the game tick, and the tick scheduler always acquires a
write lock on the nexus before running any systems.
## Finding the offending code (in trickier cases)
If you are struggling to identify a deadlock cause, try defining the `DEBUG_LOCKS` flag. This
enabled the `lastLockedBy` property on `ReadWriteLock` which stores the file, line and column where
the lock was most recently acquired. Use the [`swiftSettings`](https://github.com/apple/swift-package-manager/blob/11ae0a7bbfaab580c5695eea2c76db9ab092b8a4/Documentation/PackageDescription.md#methods-9)
property of the Swift package target you are building to define the flag.
After defining the `DEBUG_LOCKS` flag, run the program under lldb or the Xcode debugger and wait for
the deadlock to occur. Find a thread that is stuck waiting for a lock and inspect the lock's
`lastLockedBy` property. This will hopefully help you find the code path that either forgot to unlock
the lock or is acquiring a lock twice.
================================================
FILE: Notes/GUIRendering.md
================================================
# GUI rendering
## Optimisation
GUI rendering should be a relatively cheap operation in the Delta Client pipeline, but at the moment
it isn't (at least compared to what it should be). It takes close to 4ms per frame on my Intel
MacBook Air (on a superflat world on low render distance that's 8 times higher than world rendering).
If GUI rendering were put on a scale of optimisability, it would probably be pretty high because
most GUI elements don't change from frame to frame.
The main source of slow downs is that no mesh buffers are being reused at all. A new
buffer is created for each mesh each frame.
### Avoid updating uniforms unless they have changed
This made almost no difference to CPU or GPU time, but it's good practice.
### Combine meshes that use the same array texture where possible
The only measurement that is affected by this improvement is `gui.encode`. The differences in other
measurements are just due to external factors. Overall it seems to be a pretty fair comparison: some
measurements that should be constant are slightly more and some are slightly less by they seem to be
relatively consistent.
This improvement gave a 2.36x reduction in encode time which is pretty great.
This improvement isn't foolproof, it should be conservative enough to always retain ordering when required,
but it doesn't seem to always combine meshes when they can be combined. This can be worked around by
refactoring mesh generation to group by array texture when possible. I had to do this with
`GUIList`'s row background generation (by putting all the backgrounds first) and it worked a charm.
I don't quite know why it doesn't manage to combine the meshes in these cases, the text is probably
overlapping in the transparent parts or something. This could be investigated by adding a mesh
bounding box rendering feature to the GUI.
```
waitForRenderPassDescriptor 8.21971ms
updateCamera 0.01754ms
createRenderCommandEncoder 0.07330ms
world 0.53691ms
entities 0.06140ms
gui 3.30120ms
updateUniforms 0.03868ms
updateContent 0.52186ms
createMeshes 1.07536ms
encode 1.63316ms
commitToGPU 0.07620ms
```
Figure 1: *before*
```
=== Start profiler summary ===
waitForRenderPassDescriptor 13.06693ms
updateCamera 0.02092ms
createRenderCommandEncoder 0.07628ms
world 0.60788ms
entities 0.03953ms
gui 2.37221ms
updateUniforms 0.03809ms
updateContent 0.64521ms
createMeshes 0.95568ms
encode 0.69374ms
commitToGPU 0.05965ms
=== End profiler summary ===
```
Figure 2: *after*
### Reuse vertex buffers
This was implemented simply by keeping an array of previous meshes and then when rendering a mesh,
use the previous mesh at the same index if one exists. This means that in general a mesh will mostly
reuse itself meaning that the size should be similar and the creation of a new vertex buffer can be
avoided. This also means that as long as there aren't more meshes than there were in a previous
frame (true most of the time), no uniforms buffers need to be created.
Vertex buffers are created with enough head room to fit 20 more quads which reduced the number of
new buffers created by my repeatable GUI test from 91 to 17 (the minimum possible being 10 which is
the number of meshes the GUI uses with chat open, the number of items in the hotbar of the account I
was using and the debug overlay activated).
This cut down the `gui.encode` measurement by 2.5x (for a total 6x improvement so far).
```
=== Start profiler summary ===
waitForRenderPassDescriptor 13.51036ms
updateCamera 0.01717ms
createRenderCommandEncoder 0.07296ms
world 0.57931ms
entities 0.04536ms
gui 2.22940ms
updateUniforms 0.04108ms
updateContent 0.81972ms
createMeshes 1.07331ms
encode 0.27231ms
commitToGPU 0.06338ms
=== End profiler summary ===
```
Figure 3: *after*
### Micro optimization time
At the moment I can't spot any other obvious causes for slow down so I just opened up Instruments
and started optimizing slow codepaths. By using some unsafe pointers, smarter algorithms and tuples
instead of arrays when size is fixed I managed to get quite a big improvement. I think this
performance is finally getting pretty reasonable. Total CPU time for GUI rendering is now 2.5x lower
than before I started optimizing.
```
=== Start profiler summary ===
waitForRenderPassDescriptor 14.55348ms
updateCamera 0.01872ms
createRenderCommandEncoder 0.07736ms
world 0.66486ms
entities 0.03725ms
gui 1.35770ms
updateUniforms 0.03743ms
updateContent 0.43399ms
createMeshes 0.51876ms
encode 0.34344ms
commitToGPU 0.05536ms
=== End profiler summary ===
```
================================================
FILE: Notes/PluginSystem.md
================================================
# Plugin System
This document explains how the plugin system is designed and implemented.
## `PluginEnvironment`
The `PluginEnvironment` manages loading, unloading and reloading of plugins. All errors to do with
plugin loading are added to `PluginEnvironment.errors` so that they can be accessed at a later time
(e.g. in the plugin settings view). `PluginEnvironment` also has a method called `addEventBus` which
is used to add all loaded plugins to an event bus as listeners. And a method `handleWillJoinServer`
which should be replaced by an event at a later date when the events part is cleaned up.
## Dynamic linking
All of a plugin's code is contained within a dynamic library (`libPlugin.dylib`). The dynamic
library exposes a function called `buildPlugin` (exported using `@_cdecl("buildPlugin")`) which is
called by the client to get a reference to a `PluginBuilder`. The plugin builder is then used to
create an instance of the plugin and the plugin is installed into the main `PluginEnvironment`
(`DeltaClientApp.pluginEnvironment`).
For typecasting to work correctly in plugins, both the client and the plugin have to be using the
same copies of types. This means that both the client and plugin have to be dynamically linked
against `DeltaCore` (which contains the common code that both plugins and the client have access
to). Due to limitations of Swift Package Manager, this means that `DeltaCore` has to be its own
swift package which has a dynamic library product (see `Sources/Core/Package.swift`). The root swift
package includes `Sources/Core` as a package dependency and the `DeltaClient` target in the root
package has this as a dependency.
To allow use of `DeltaCore` outside of `DeltaClient` (i.e. in plugins), the root package exposes two
products: `DynamicShim` and `StaticShim`. `DynamicShim` re-exports the `DeltaCore` dynamic library
for use in plugins (which must dynamically link to `DeltaCore`). However, not all projects require
`DeltaCore` to be dynamically link (e.g. a simple bot client), therefore the `StaticShim` product
was also exposed which re-exports a statically linked version of `DeltaCore`.
## Loading order
If a feature only supports one plugin using it at a time (such as custom render coordinators), the
client will use the first plugin that uses the feature. Until proper sorting support is added this
can be worked around by unloading all and manually loading the plugins in the order you want (will
not persist across launches).
## Manifest files
A plugin's manifest file is just a JSON file containing basic information about the client such as
its identifier, description and display name. The identifier is used to uniquely identify each
plugin.
## Directory structure
Plugins are just directories with the `deltaplugin` extension. They currently only contain a
`manifest.json` and a `libPlugin.dylib`.
================================================
FILE: Notes/Readme.md
================================================
# Notes
In this directory I will be documenting the reasoning behind certain design decisions. I will also be documenting the results of investigations I identify the most efficient solutions to certain bottlenecking problems. Hopefully this documentation will help you understand the design of Delta Core/Client and make better contributions.
================================================
FILE: Notes/RenderPipeline.md
================================================
# Render pipeline optimisation
The CPU usage of the render pipeline is currently bottlenecking fps much more than the actual GPU usage. This document will contain my findings as I try to optimise the CPU part of the render pipeline.
All measurements of pipeline performance will be measured at -312 140 -216 with yaw 0 and pitch 90 (looking straight down) in seed -6243685378508790499 with render distance 5. It will always be measured in full screen on my laptop's screen not my monitor's.
## Initial measurements
- WorldRenderer.draw: ~25ms
Just did a bunch of cleanup and now it's a bunch faster somehow;
- WorldRenderer.draw: ~7ms
I don't quite believe that it sped up that much so i probably measured it incorrectly
================================================
FILE: Package.resolved
================================================
{
"pins" : [
{
"identity" : "asn1parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/ASN1Parser",
"state" : {
"branch" : "main",
"revision" : "f92a5b26f5c92d38ae858a5a77048e9af82331a3"
}
},
{
"identity" : "async-http-client",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "037b70291941fe43de668066eb6fb802c5e181d2",
"version" : "1.1.1"
}
},
{
"identity" : "bigint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/attaswift/BigInt.git",
"state" : {
"revision" : "e07e00fa1fd435143a2dcf8b7eec9a7710b2fdfe",
"version" : "5.7.0"
}
},
{
"identity" : "bluesocket",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/BlueSocket.git",
"state" : {
"branch" : "master",
"revision" : "31e92ab743a9ffc2a4a6e7e2f1043f5fe1d97e80"
}
},
{
"identity" : "circuitbreaker",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kitura/CircuitBreaker.git",
"state" : {
"revision" : "bd4255762e48cc3748a448d197f1297a4ba705f7",
"version" : "5.1.0"
}
},
{
"identity" : "cryptoswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift",
"state" : {
"revision" : "e45a26384239e028ec87fbcc788f513b67e10d8f",
"version" : "1.9.0"
}
},
{
"identity" : "ecs",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/ecs.git",
"state" : {
"branch" : "master",
"revision" : "c7660bcd24e31ef2fc3457f56a2bf4a58c3ad6ee"
}
},
{
"identity" : "fireblade-math",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/fireblade-math.git",
"state" : {
"branch" : "matrix2x2",
"revision" : "750239647673b07457bea80b39438a6db52198f1"
}
},
{
"identity" : "jjliso8601dateformatter",
"kind" : "remoteSourceControl",
"location" : "https://github.com/michaeleisel/JJLISO8601DateFormatter",
"state" : {
"revision" : "50d5ea26ffd3f82e3db8516d939d80b745e168cf",
"version" : "0.2.0"
}
},
{
"identity" : "jpeg",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/jpeg",
"state" : {
"revision" : "a27e47f49479993b2541bc5f5c95d9354ed567a0",
"version" : "1.0.2"
}
},
{
"identity" : "libpng",
"kind" : "remoteSourceControl",
"location" : "https://github.com/the-swift-collective/libpng",
"state" : {
"revision" : "0eff23aca92a086b7892831f5cb4f58e15be9449",
"version" : "1.6.45"
}
},
{
"identity" : "libwebp",
"kind" : "remoteSourceControl",
"location" : "https://github.com/the-swift-collective/libwebp",
"state" : {
"revision" : "5f745a17b9a5c2a4283f17c2cde4517610ab5f99",
"version" : "1.4.1"
}
},
{
"identity" : "loggerapi",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kitura/LoggerAPI.git",
"state" : {
"revision" : "e82d34eab3f0b05391082b11ea07d3b70d2f65bb",
"version" : "1.9.200"
}
},
{
"identity" : "opencombine",
"kind" : "remoteSourceControl",
"location" : "https://github.com/OpenCombine/OpenCombine.git",
"state" : {
"revision" : "8576f0d579b27020beccbccc3ea6844f3ddfc2c2",
"version" : "0.14.0"
}
},
{
"identity" : "puppy",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sushichop/Puppy",
"state" : {
"revision" : "80ebe6ab25fb7050904647cb96f6ad7bee77bad6",
"version" : "0.9.0"
}
},
{
"identity" : "rainbow",
"kind" : "remoteSourceControl",
"location" : "https://github.com/onevcat/Rainbow",
"state" : {
"revision" : "cdf146ae671b2624917648b61c908d1244b98ca1",
"version" : "4.2.1"
}
},
{
"identity" : "swift-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-algorithms.git",
"state" : {
"revision" : "87e50f483c54e6efd60e885f7f5aa946cee68023",
"version" : "1.2.1"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "626b5b7b2f45e1b0b1c6f4a309296d1d21d7311b",
"version" : "1.7.1"
}
},
{
"identity" : "swift-asn1",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-asn1.git",
"state" : {
"revision" : "9f542610331815e29cc3821d3b6f488db8715517",
"version" : "1.6.0"
}
},
{
"identity" : "swift-async-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-async-algorithms.git",
"state" : {
"revision" : "9d349bcc328ac3c31ce40e746b5882742a0d1272",
"version" : "1.1.3"
}
},
{
"identity" : "swift-async-dns-resolver",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-async-dns-resolver.git",
"state" : {
"revision" : "36eedf108f9eda4feeaf47f3dfce657a88ef19aa",
"version" : "0.6.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "b601256eab081c0f92f059e12818ac1d4f178ff7",
"version" : "1.3.0"
}
},
{
"identity" : "swift-case-paths",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "206cbce3882b4de9aee19ce62ac5b7306cadd45b",
"version" : "1.7.3"
}
},
{
"identity" : "swift-certificates",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-certificates.git",
"state" : {
"revision" : "24ccdeeeed4dfaae7955fcac9dbf5489ed4f1a25",
"version" : "1.18.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "6675bc0ff86e61436e615df6fc5174e043e57924",
"version" : "1.4.1"
}
},
{
"identity" : "swift-cross-ui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/swift-cross-ui",
"state" : {
"revision" : "835c9ea90a3b1d2dc20436eb2c87b00037b4eb9c",
"version" : "0.4.0"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "bb4ba815dab96d4edc1e0b86d7b9acf9ff973a84",
"version" : "4.3.1"
}
},
{
"identity" : "swift-cwinrt",
"kind" : "remoteSourceControl",
"location" : "https://github.com/moreSwift/swift-cwinrt",
"state" : {
"revision" : "601287a2a89e8e56e8aa53782b6054db8be0bce8",
"version" : "0.1.2"
}
},
{
"identity" : "swift-http-structured-headers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-structured-headers.git",
"state" : {
"revision" : "76d7627bd88b47bf5a0f8497dd244885960dde0b",
"version" : "1.6.0"
}
},
{
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types.git",
"state" : {
"revision" : "45eb0224913ea070ec4fba17291b9e7ecf4749ca",
"version" : "1.5.1"
}
},
{
"identity" : "swift-image",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/swift-image.git",
"state" : {
"branch" : "master",
"revision" : "7160e2d8799f8b182498ab699aa695cb66cf4ea6"
}
},
{
"identity" : "swift-image-formats",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/swift-image-formats",
"state" : {
"revision" : "2e5dc1ead747afab9fd517d81316d961969e3610",
"version" : "0.3.3"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "ce592ae52f982c847a4efc0dd881cc9eb32d29f2",
"version" : "1.6.4"
}
},
{
"identity" : "swift-macro-toolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/swift-macro-toolkit",
"state" : {
"revision" : "d319bcc2586f7dbc6a09c05792105078263f1ed3",
"version" : "0.7.2"
}
},
{
"identity" : "swift-mutex",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swhitty/swift-mutex",
"state" : {
"revision" : "1770152df756b54c28ef1787df1e957d93cc62d5",
"version" : "0.0.6"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "558f24a4647193b5a0e2104031b71c55d31ff83a",
"version" : "2.97.1"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "abcf5312eb8ed2fb11916078aef7c46b06f20813",
"version" : "1.33.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "6d8d596f0a9bfebb925733003731fe2d749b7e02",
"version" : "1.42.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "df9c3406028e3297246e6e7081977a167318b692",
"version" : "2.36.1"
}
},
{
"identity" : "swift-numerics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-numerics.git",
"state" : {
"revision" : "0c0290ff6b24942dadb83a929ffaaa1481df04a2",
"version" : "1.1.1"
}
},
{
"identity" : "swift-package-zlib",
"kind" : "remoteSourceControl",
"location" : "https://github.com/fourplusone/swift-package-zlib",
"state" : {
"revision" : "03ecd41814d8929362f7439529f9682536a8de13",
"version" : "1.2.11"
}
},
{
"identity" : "swift-parsing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-parsing",
"state" : {
"revision" : "3432cb81164dd3d69a75d0d63205be5fbae2c34b",
"version" : "0.14.1"
}
},
{
"identity" : "swift-png",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/swift-png",
"state" : {
"revision" : "b68a5662ef9887c8f375854720b3621f772bf8c5"
}
},
{
"identity" : "swift-service-lifecycle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/swift-service-lifecycle.git",
"state" : {
"revision" : "9829955b385e5bb88128b73f1b8389e9b9c3191a",
"version" : "2.11.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax.git",
"state" : {
"revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2",
"version" : "601.0.1"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "7c6ad0fc39d0763e0b699210e4124afd5041c5df",
"version" : "1.6.4"
}
},
{
"identity" : "swift-uwp",
"kind" : "remoteSourceControl",
"location" : "https://github.com/moreSwift/swift-uwp",
"state" : {
"revision" : "a0a86467514eaa63272eae848c70d49e6874ede4",
"version" : "0.1.0"
}
},
{
"identity" : "swift-webview2core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/moreSwift/swift-webview2core",
"state" : {
"revision" : "a8ed52a57f6d81ee06c8db692f8ee0431174379a",
"version" : "0.1.0"
}
},
{
"identity" : "swift-windowsappsdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/moreSwift/swift-windowsappsdk",
"state" : {
"revision" : "3c06cb36da9711e24a76c35861e0b97702448015",
"version" : "0.1.1"
}
},
{
"identity" : "swift-windowsfoundation",
"kind" : "remoteSourceControl",
"location" : "https://github.com/moreSwift/swift-windowsfoundation",
"state" : {
"revision" : "94d56a5aea472672bc5d041c091f6cdf72e3cc44",
"version" : "0.1.0"
}
},
{
"identity" : "swift-winui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/moreSwift/swift-winui",
"state" : {
"revision" : "73d5d19c39c523c92355027dd13aee445fc627a7",
"version" : "0.1.1"
}
},
{
"identity" : "swiftcpudetect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/JWhitmore1/SwiftCPUDetect",
"state" : {
"branch" : "main",
"revision" : "5ca694c6ad7eef1199d69463fa956c24c202465f"
}
},
{
"identity" : "swiftpackagesbase",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ITzTravelInTime/SwiftPackagesBase",
"state" : {
"revision" : "79477622b5dbacc3722d485c5060c46a90740016",
"version" : "0.0.23"
}
},
{
"identity" : "swiftyrequest",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kitura/SwiftyRequest.git",
"state" : {
"revision" : "2c543777a5088bed811503a68551a4b4eceac198",
"version" : "3.2.200"
}
},
{
"identity" : "swordrpc",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/SwordRPC",
"state" : {
"revision" : "3ddf125eeb3d83cb17a6e4cda685f9c80e0d4bed"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "dfd70507def84cb5fb821278448a262c6ff2bbad",
"version" : "1.9.0"
}
},
{
"identity" : "zipfoundation",
"kind" : "remoteSourceControl",
"location" : "https://github.com/weichsel/ZIPFoundation.git",
"state" : {
"revision" : "22787ffb59de99e5dc1fbfe80b19c97a904ad48d",
"version" : "0.9.20"
}
},
{
"identity" : "zippyjson",
"kind" : "remoteSourceControl",
"location" : "https://github.com/michaeleisel/ZippyJSON",
"state" : {
"revision" : "ddbbc024ba5a826f9676035a0a090a0bc2d40755",
"version" : "1.2.15"
}
},
{
"identity" : "zippyjsoncfamily",
"kind" : "remoteSourceControl",
"location" : "https://github.com/michaeleisel/ZippyJSONCFamily",
"state" : {
"revision" : "c1c0f88977359ea85b81e128b2d988e8250dfdae",
"version" : "1.2.14"
}
},
{
"identity" : "zlib",
"kind" : "remoteSourceControl",
"location" : "https://github.com/the-swift-collective/zlib.git",
"state" : {
"revision" : "f1d153b90420f9fcc6ef916cd67ea96f0e68d137",
"version" : "1.3.2"
}
}
],
"version" : 2
}
================================================
FILE: Package.swift
================================================
// swift-tools-version:5.9
import PackageDescription
var products: [Product] = [
.executable(
name: "DeltaClientGtk",
targets: ["DeltaClientGtk"]
),
// Importing DynamicShim as a dependency in your own project will in effect just import
// DeltaCore using dynamic linking
.library(
name: "DynamicShim",
targets: ["DynamicShim"]
),
// Importing StaticShim as a dependency in your own project will just import DeltaCore
// using static linking
.library(
name: "StaticShim",
targets: ["StaticShim"]
),
]
#if canImport(Darwin)
products.append(
.executable(
name: "DeltaClient",
targets: ["DeltaClient"]
)
)
#endif
var targets: [Target] = [
.executableTarget(
name: "DeltaClientGtk",
dependencies: [
.product(name: "DeltaCore", package: "DeltaCore"),
.product(name: "SwiftCrossUI", package: "swift-cross-ui"),
.product(name: "GtkBackend", package: "swift-cross-ui"),
],
path: "Sources/ClientGtk"
),
.target(
name: "DynamicShim",
dependencies: [
.product(name: "DeltaCore", package: "DeltaCore")
],
path: "Sources/Exporters/DynamicShim"
),
.target(
name: "StaticShim",
dependencies: [
.product(name: "StaticDeltaCore", package: "DeltaCore")
],
path: "Sources/Exporters/StaticShim"
),
]
#if canImport(Darwin)
targets.append(
.executableTarget(
name: "DeltaClient",
dependencies: [
"DynamicShim",
.product(name: "SwordRPC", package: "SwordRPC", condition: .when(platforms: [.macOS])),
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
path: "Sources/Client"
)
)
#endif
let package = Package(
name: "DeltaClient",
platforms: [.macOS(.v11), .iOS(.v15), .tvOS(.v15)],
products: products,
dependencies: [
// See Notes/PluginSystem.md for more details on the architecture of the project in regards to dependencies, targets and linking
// In short, the dependencies for DeltaCore can be found in Sources/Core/Package.swift
.package(name: "DeltaCore", path: "./Sources/Core"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
.package(
url: "https://github.com/stackotter/SwordRPC",
revision: "3ddf125eeb3d83cb17a6e4cda685f9c80e0d4bed"
),
.package(
url: "https://github.com/stackotter/swift-cross-ui",
.upToNextMinor(from: "0.4.0")
),
],
targets: targets
)
================================================
FILE: Readme.md
================================================
# Delta Client - Changing the meaning of speed
[](https://deltaclient.app/discord)
An open source rewrite of the *Minecraft: Java Edition* client, written in Swift for macOS and iOS (experimental). Currently Delta Client only supports connecting to **1.16.1** servers.
## Disclaimers
This client is not finished yet. If you're looking for a client to use to play Minecraft today, then this is not for you. **I am NOT responsible for anti-cheat bans, the client has not been thoroughly tested yet and is still deep in development.**
**This software is not affiliated with Mojang AB, the original developer of Minecraft.**
## Overview
The main focus of this project is to create a highly efficient Java Edition compatible client written in Swift for macOS. The client also has experimental support for iOS, and is in the process of getting ported to Linux using SwiftCrossUI and eventually Kinzoku (once it is ready).
If you want to have a say in the development of the client or have any questions, feel free to join the community on [Discord](https://deltaclient.app/discord).

## Performance
One of the biggest advantages of Delta Client is its performance. Epic comparison graphs are in progress, but for now have some dot-points.
- Start-up time:
- M2 MacBook Air: 0.9 seconds (vanilla takes 43 seconds)
- i5 MacBook Air: 2.7 seconds (vanilla takes ~60 seconds)
- FPS on 10 render distance in the mountains (bad for fps):
- M2 MacBook Air (on 1080p monitor): ~120 fps (vanilla gets ~75 fps)
- i5 MacBook Air: ~70 fps (vanilla gets ~35fps)
## Installation
### Prebuilt
1. Visit [Delta Client's downloads page](https://delta.stackotter.dev/downloads) and download the
latest build from the `main` branch.
2. Unzip the downloaded zip archive and open the app inside
3. You will get a security alert, click ok
4. Right click the app in finder and select open
5. You should get another pop-up, click 'Open'
6. Delta Client will now open and start downloading the required assets (this only has to happen once and should take around 40s with a mediocre internet speed)
7. You can move Delta Client to your Applications folder for ease of use if you want
To view application logs, click `View > Logs` in the menu bar while Delta Client is open.
### Building from source
To build Delta Client you'll first need to install Xcode 14+ and the latest version of [Swift Bundler](https://github.com/stackotter/swift-bundler). Please note that using Xcode 13 is ok but you may run into some weird memory corruption issues, so test with Xcode 14+ before assuming that it's a Delta Client bug. Once you've installed the requirements, run the following commands in terminal;
```sh
# Clone Delta Client
git clone https://github.com/stackotter/delta-client
cd delta-client
# Perform a release build and output the bundled app to the current directory
sh ./build.sh
# If you want to develop Delta Client using Xcode, run the following command
swift bundler generate-xcode-support
# And then open Package.swift with Xcode and you'll be able to build it from Xcode too
```
## Minecraft version support
At the moment the client only supports joining **1.16.1** servers. In the future I plan to support more versions.
Not every version will be perfectly supported but I will try and have the most polished support for the following versions;
- 1.8.9
- the latest speedrunning version (currently 1.16.1)
- the latest stable version
## Features
- [x] Networking
- [x] Basic networking
- [x] Server list ping
- [x] Encryption (for non-offline mode servers)
- [x] Mojang accounts
- [x] Microsoft accounts
- [x] LAN server detection
- [x] Basic config system
- [x] Multi-accounting
- [ ] Rendering
- [x] World
- [x] Basic block rendering
- [x] Basic chunk rendering
- [x] Block culling
- [x] Block models
- [x] Multipart structures (e.g. fences)
- [x] Multiple chunks
- [x] Lighting
- [x] Animated textures (e.g. lava)
- [x] Translucency
- [x] Fluids (lava and water)
- [x] Chunk frustum culling
- [x] Biome blending (mostly)
- [x] [Sky box](https://github.com/stackotter/delta-client/pull/188)
- [ ] Entities
- [x] Basic entity rendering (just coloured cubes)
- [x] Render entity models
- [ ] Block entities (e.g. chests)
- [ ] Item entities
- [ ] Entity animations
- [ ] GUI
- [x] Chat
- [x] F3-style stuff
- [x] Bossbars
- [ ] Scoreboard
- [x] Tab list
- [x] Health, hunger and experience
- [x] Hotbar
- [ ] Inventory
- [x] Basic inventory
- [x] Basic crafting
- [x] Inventory actions
- [ ] Using recipe blocks (like crafting tables and stuff)
- [ ] Creative inventory
- [ ] Sound
- [ ] Basic sounds system
- [x] Physics
- [x] Physics loop
- [x] Input system
- [x] Collision system
- [x] Interaction
- [x] Block placing
- [x] Block breaking
- [x] Block entity interaction
- [x] Entity interaction
- [ ] Particles
- [ ] Basic particle system
- [ ] Block break particles
- [ ] Ambient particles
- [ ] Hit particles
- [ ] Particles from server
## Contributing
First, please check out the [contributing guidelines](Contributing.md). Then you can checkout the [issues](https://github.com/stackotter/delta-client/issues) for a place to get started. Make sure to leave a comment on the issue you choose so that people know that someone's already working on it.
## Servers
We now have an official testing server (`play.deltaclient.app`)! However, if you want to mess around to your hearts content you can run a server on your computer for full control (see below).
To start a test server, download a 1.16.1 server jar from [here](https://mcversions.net/download/1.16.1). Then in Terminal type `java -jar ` and then drag the downloaded .jar file onto the terminal window and then hit enter. Wait for the server to start up. Now add a new server with the address `localhost` in Delta Client and you should be able to connect to it. Keep in mind the server may use a significant amount of resources and slow down Delta Client.
## More screenshots


================================================
FILE: Roadmap.md
================================================
# **This is outdated, please ignore for now**
# Demo Versions
The demo versions are just proof-of-concepts.
## Demo 1 - Efficient Launch, Basic Rendering & All Networking *(Released)*
### Features
- smooth first launch flow (downloading assets and creating default config and stuff)
- login flow for mojang accounts
- fast subsequent startups
- rendering player's current chunk
- the view can be moved around using ```tp``` commands from another player
- basic config screens (account settings and server settings)
### Todo
- [x] refactor networking
- [x] add compression support
- [x] add encryption support
- [x] basic config system
- [x] sign in screen on first launch
- [x] config screen for changing account details (used a logout button for now instead)
- [x] remove need for minecraft to be already installed
- [x] add basic way to exit game and get back to server list
- [x] prettyprint config json
- [x] way to re-order servers
- [x] move some things to menu bar instead of tool bar (like account stuff)
## Demo 2 - Critical Bug Fixes for Demo 1 *(Released)*
### New Features
- none, just fixes some critical bugs from demo 1
### Todo
- [x] refresh access token before each server join
- [x] fix first time server join
# Alpha Versions
The demo versions were just proof-of-concepts. The alpha versions will still be far from complete but will be looking a lot more promising.
## Alpha 1 - Basically Spectator Mode *(WIP)*
### New Features
- rendering
- proper lighting
- multipart structures (e.g. fences)
- random block rotations
- multichunk rendering
- complete redesigned rendering system
- animated textures
- frustum culling
- mip maps
- proper tints (redstone, leaves, water and grass etc.)
- fluids
- proper transparency and translucency rendering
- movements
- basic input system
- basic spectator mode movement (freecam)
- ui
- cleaner ui and ui code
- edit server list screen
- accounts screen
- multi-accounting (allow easily switching between accounts)
- improved memory usage
### Todo
- [x] multipart structure reading (from pixlyzer)
- [x] multipart structure rendering
- [x] parallelise generating chunk meshes
- [x] order chunks based on distance from player when generating meshes
- [x] order chunks based off frustum as well
- [x] basic shading (face normal based) (bake light levels into block models)
- [x] mip maps
- [x] rewrite block model loading system
- [x] lighting
- [x] animated textures
- [x] fix gpu ram usage (clear buffers when not being used, possibly use private mode buffers, possibly use a big default size buffer and transfer things through that)
- [x] fix indices (either use 6 vertices to a face or do the fancy shader thing from before (adjusting the vertex indices))
- [x] optimise chunk mesh preparation
- [x] proper transparent and translucent rendering
- [x] non-transparent leaves for now (better performance)
- [x] reduce cpu time for frames (gpu frame time is well below 16ms, cpu is taking up the majority of the time each frame)
- [x] possibly use section based rendering instead of chunk based
- [x] basic multichunk rendering
- [x] fix hypixel chunk loading
- [x] fix grass block sides
- [x] implement rescale
- [x] random block variants (that match vanilla)
- [x] frustum culling for chunks
- [x] create an input system
- [x] keyboard
- [x] mouse
- [x] create a physics loop
- [x] make a loop that runs at a consistent interval
- [x] add basic physics simulation
- [x] add basis for multi-accounting
- [x] config
- [x] login code
- [x] add offline account support
- [x] ui for switching accounts
- [x] fix memory usage errors (when leaving a server or starting the app for the first time a lot of memory doesn't get freed for some reason)
- [x] fluids
- [x] waterlogging
- [x] block id refactor (issue #25)
## Alpha 2 - Creative Mode Without Inventory
### New Features
- collision system
- auto-jump
- gravity
### Todo
- [x] load hitboxes
- [x] wireframe hitboxes
- [x] detect player-block collisions
- [x] handle collisions
- [ ] auto-jump
- [x] add gravity to physics
## Alpha 3 - Basic Survival Mode
### New Features - Basic HUD & Inventory
- f3
- hotbar
- health
- xp bar
- bubbles (the indicator for drowning stuff)
- basic inventory view
### Todo
- [x] font rendering
- [x] modular hud system
- [x] bars
- [x] health
- [x] hunger
- [x] xp
- [ ] bubbles
- [x] item rendering
- [x] hotbar
- [x] basic inventory (just for viewing)
================================================
FILE: Security.md
================================================
# Security Policy
## Supported Versions
Only bugs present in the latest commit on a branch will be acted on (because all others have clearly been fixed). However, if there's a security bug in one of the GitHub releases, a security advisory will be added to release's description. And if it's the latest release, a new release will be made once the bug is fixed.
## Reporting a Vulnerability
Create an issue for the vulnerability unless publicising the issue before it is fixed would put users at risk. In the case that creating a public GitHub issue is not sensible, contact me directly on Discord (stackotter#3100). If the bug does turn out to be serious after further investigation, it will be prioritised and fixed as soon as possible. If it's not serious, it will have the same priority as any other issue.
================================================
FILE: Sources/Client/CommandLineArguments.swift
================================================
import ArgumentParser
import Foundation
import Logging
/// An error thrown while parsing ``CommandLineArguments``.
enum CommandLineArgumentsError: LocalizedError {
case invalidLogLevel(String)
var errorDescription: String? {
switch self {
case .invalidLogLevel(let level):
return "Invalid log level '\(level)'. Must be one of \(Logger.Level.allCases.map(\.rawValue))"
}
}
}
/// The command line arguments for Delta Client.
struct CommandLineArguments: ParsableCommand {
static let configuration = CommandConfiguration(commandName: "DeltaClient")
/// A replacement for the default plugins directory.
@Option(
name: .customLong("plugins-dir"),
help: "A directory to load plugins from instead of the default plugins directory.",
transform: URL.init(fileURLWithPath:))
var pluginsDirectory: URL?
/// The minimum log level to output to stdout.
@Option(
help: "The minimum log level to output to stdout.",
transform: { string in
switch string {
case "trace":
return .trace
case "verbose":
return .verbose
case "debug":
return .debug
case "info":
return .info
case "notice":
return .notice
case "warning":
return .warning
case "error":
return .error
case "critical":
return .critical
default:
throw CommandLineArgumentsError.invalidLogLevel(string)
}
})
var logLevel = LogLevel.info
/// Xcode passes the `-NSDocumentRevisionsDebugMode` flag when running applications (no clue why).
/// It needs to be defined here because otherwise it throws an error due to strict parsing.
@Option(
name: .customLong("NSDocumentRevisionsDebugMode", withSingleDash: true),
help: .init("Ignore this, just Xcode being weird.", visibility: .hidden))
var nsDocumentRevisionsDebugMode: String?
}
================================================
FILE: Sources/Client/Components/AddressField.swift
================================================
import SwiftUI
import Combine
struct AddressField: View {
// swiftlint:disable:next force_try
static private let ipRegex = try! NSRegularExpression(
pattern: "^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)(\\.(?!$)|$)){4}$"
)
// swiftlint:disable:next force_try
static private let domainRegex = try! NSRegularExpression(
pattern: "^[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*$"
)
let title: String
@State private var string: String
@Binding private var host: String
@Binding private var port: UInt16?
@Binding private var isValid: Bool
init(_ title: String, host: Binding<String>, port: Binding<UInt16?>, isValid: Binding<Bool>) {
self.title = title
_host = host
_port = port
if let port = port.wrappedValue {
_string = State(initialValue: "\(host.wrappedValue):\(port)")
} else {
_string = State(initialValue: host.wrappedValue)
}
_isValid = isValid
}
private func update(_ newValue: String) {
let components = newValue.split(separator: ":")
if components.count == 0 {
log.trace("Invalid ip, empty string")
isValid = false
} else if components.count > 2 {
log.trace("Invalid ip, too many components: '\(newValue)'")
isValid = false
} else if newValue.hasSuffix(":") {
log.trace("Invalid ip, empty port: '\(newValue)'")
isValid = false
}
// Check host component
if components.count > 0 {
let hostString = String(components[0])
let range = NSRange(location: 0, length: hostString.utf16.count)
let isIp = Self.ipRegex.firstMatch(in: hostString, options: [], range: range) != nil
let isDomain = Self.domainRegex.firstMatch(in: hostString, options: [], range: range) != nil
if isIp || isDomain {
host = hostString
isValid = true
} else {
log.trace("Invalid host component: '\(hostString)'")
isValid = false
}
}
// Check port component
if components.count == 2 {
let portString = components[1]
if let port = UInt16(portString) {
self.port = port
isValid = true
} else {
log.trace("Invalid port component: '\(portString)'")
isValid = false
}
} else {
port = nil
}
}
var body: some View {
TextField(title, text: $string)
.onReceive(Just(string), perform: update)
.onAppear {
update(string)
}
}
}
================================================
FILE: Sources/Client/Components/ButtonStyles/DisabledButtonStyle.swift
================================================
import SwiftUI
struct DisabledButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
HStack {
Spacer()
configuration.label.foregroundColor(.gray)
Spacer()
}
.padding(6)
.background(Color.secondary.brightness(-0.4).cornerRadius(4))
}
}
================================================
FILE: Sources/Client/Components/ButtonStyles/PrimaryButtonStyle.swift
================================================
import SwiftUI
#if os(tvOS)
typealias PrimaryButtonStyle = DefaultButtonStyle
#else
struct PrimaryButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
HStack {
Spacer()
configuration.label.foregroundColor(.white)
Spacer()
}
.padding(6)
.background(Color.accentColor.brightness(configuration.isPressed ? 0.15 : 0).cornerRadius(4))
}
}
#endif
================================================
FILE: Sources/Client/Components/ButtonStyles/SecondaryButtonStyle.swift
================================================
import SwiftUI
#if os(tvOS)
typealias SecondaryButtonStyle = DefaultButtonStyle
#else
struct SecondaryButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
HStack {
Spacer()
configuration.label.foregroundColor(.white)
Spacer()
}
.padding(6)
.background(Color.secondary.brightness(configuration.isPressed ? 0 : -0.15).cornerRadius(4))
}
}
#endif
================================================
FILE: Sources/Client/Components/EditableList/EditableList.swift
================================================
import SwiftUI
enum EditableListAction {
case delete
case edit
case moveUp
case moveDown
case select
}
enum EditableListState {
case list
case addItem
case editItem(Int)
}
struct EditableList<Row: View, ItemEditor: EditorView>: View {
@State var state: EditableListState = .list
#if os(tvOS)
@Namespace var focusNamespace
#endif
@Binding var items: [ItemEditor.Item]
@Binding var selected: Int?
let itemEditor: ItemEditor.Type
let row: (
_ item: ItemEditor.Item,
_ selected: Bool,
_ isFirst: Bool,
_ isLast: Bool,
_ handler: @escaping (EditableListAction) -> Void
) -> Row
let save: (() -> Void)?
let cancel: (() -> Void)?
/// Message to display when the list is empty.
let emptyMessage: String
init(
_ items: Binding<[ItemEditor.Item]>,
selected: Binding<Int?> = Binding<Int?>(get: { nil }, set: { _ in }),
itemEditor: ItemEditor.Type,
@ViewBuilder row: @escaping (
_ item: ItemEditor.Item,
_ selected: Bool,
_ isFirst: Bool,
_ isLast: Bool,
_ handler: @escaping (EditableListAction) -> Void
) -> Row,
saveAction: (() -> Void)?,
cancelAction: (() -> Void)?,
emptyMessage: String = "No items",
forceShowCreation: Bool = false
) {
self._items = items
self._selected = selected
self.itemEditor = itemEditor
self.row = row
self.emptyMessage = emptyMessage
save = saveAction
cancel = cancelAction
if forceShowCreation {
_state = State(wrappedValue: .addItem)
}
}
func handleItemEditableListAction(_ index: Int, _ action: EditableListAction) {
switch action {
case .delete:
if selected == index {
if items.count == 1 {
selected = nil
} else {
selected = 0
}
} else if let selectedIndex = selected, selectedIndex > index {
selected = selectedIndex - 1
}
items.remove(at: index)
case .edit:
state = .editItem(index)
case .moveUp:
if index != 0 {
let item = items.remove(at: index)
items.insert(item, at: index - 1)
}
case .moveDown:
if index != items.count - 1 {
let item = items.remove(at: index)
items.insert(item, at: index + 1)
}
case .select:
selected = index
}
}
var body: some View {
Group {
switch state {
case .list:
VStack(alignment: .center, spacing: 16) {
if items.count == 0 {
Text(emptyMessage).italic()
}
ScrollView(showsIndicators: true) {
ForEach(items.indices, id: \.self) { index in
VStack(alignment: .leading) {
Divider()
let isFirst = index == 0
let isLast = index == items.count - 1
row(items[index], selected == index, isFirst, isLast, { action in
handleItemEditableListAction(index, action)
})
if index == items.count - 1 {
Divider()
}
}
}
}
#if os(tvOS)
.focusSection()
#endif
VStack {
Button("Add") {
state = .addItem
}
#if os(tvOS)
.prefersDefaultFocus(in: focusNamespace)
#endif
.buttonStyle(SecondaryButtonStyle())
if save != nil || cancel != nil {
HStack {
if let cancel = cancel {
Button("Cancel", action: cancel)
.buttonStyle(SecondaryButtonStyle())
}
if let save = save {
Button("Save", action: save)
.buttonStyle(PrimaryButtonStyle())
}
}
}
}
#if !os(tvOS)
.frame(width: 200)
#else
.focusSection()
#endif
}
#if os(tvOS)
.focusSection()
#endif
case .addItem:
itemEditor.init(nil, completion: { newItem in
items.append(newItem)
selected = items.count - 1
state = .list
}, cancelation: {
state = .list
})
case let .editItem(index):
itemEditor.init(items[index], completion: { editedItem in
items[index] = editedItem
state = .list
}, cancelation: {
state = .list
})
}
}
#if !os(tvOS)
.frame(width: 400)
#else
.focusScope(focusNamespace)
#endif
}
}
================================================
FILE: Sources/Client/Components/EditableList/EditorView.swift
================================================
import SwiftUI
protocol EditorView: View {
associatedtype Item
init(_ item: Item?, completion: @escaping (Item) -> Void, cancelation: (() -> Void)?)
}
================================================
FILE: Sources/Client/Components/EmailField.swift
================================================
import SwiftUI
import Combine
struct EmailField: View {
// swiftlint:disable:next force_try
static private let regex = try! NSRegularExpression(
pattern: "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
)
private let title: String
@Binding private var email: String
@Binding private var isValid: Bool
init(
_ title: String,
email: Binding<String>,
isValid: Binding<Bool> = Binding<Bool>(get: { false }, set: { _ in })
) {
self.title = title
_email = email
_isValid = isValid
}
private func validate(_ email: String) {
let range = NSRange(location: 0, length: email.utf16.count)
isValid = Self.regex.firstMatch(in: email, options: [], range: range) != nil
}
var body: some View {
TextField(title, text: $email)
.onReceive(Just(email), perform: validate)
.onAppear {
validate(email)
}
}
}
================================================
FILE: Sources/Client/Components/IconButton.swift
================================================
import SwiftUI
struct IconButton: View {
let icon: String
let isDisabled: Bool
let action: () -> Void
init(_ icon: String, isDisabled: Bool = false, action: @escaping () -> Void) {
self.icon = icon
self.isDisabled = isDisabled
self.action = action
}
var body: some View {
Button(action: action, label: {
Image(systemName: icon)
})
#if !os(tvOS)
.buttonStyle(BorderlessButtonStyle())
#endif
.disabled(isDisabled)
}
}
================================================
FILE: Sources/Client/Components/LegacyFormattedTextView.swift
================================================
import Foundation
import DeltaCore
import SwiftUI
/// SwiftUI view for displaying text that is formatted using Legacy formatting codes.
///
/// See ``LegacyTextFormatter``.
struct LegacyFormattedTextView: View {
/// The legacy formatted string.
var string: String
/// The formatted text.
var attributedString = NSAttributedString(string: "")
/// The font size.
var fontSize: CGFloat
/// The alignment of the text.
var alignment: NSTextAlignment = .center
init(legacyString: String, fontSize: CGFloat, alignment: NSTextAlignment = .center) {
self.string = legacyString
self.attributedString = LegacyFormattedText(legacyString).attributedString(fontSize: fontSize)
self.fontSize = fontSize
self.alignment = alignment
}
var body: some View {
#if os(tvOS)
Text(attributedString.string)
#else
NSAttributedTextView(
attributedString: attributedString,
alignment: alignment
).frame(width: attributedString.size().width)
#endif
}
}
#if canImport(AppKit)
struct NSAttributedTextView: NSViewRepresentable {
var attributedString: NSAttributedString
var alignment: NSTextAlignment
func makeNSView(context: Context) -> some NSView {
let label = NSTextField()
label.backgroundColor = .clear
label.isBezeled = false
label.isEditable = false
return label
}
func updateNSView(_ nsView: NSViewType, context: Context) {
guard let label = nsView as? NSTextField else { return }
label.attributedStringValue = attributedString
label.alignment = .left
}
}
#elseif canImport(UIKit)
struct NSAttributedTextView: UIViewRepresentable {
var attributedString: NSAttributedString
var alignment: NSTextAlignment
func makeUIView(context: Context) -> some UIView {
let label = UILabel()
label.backgroundColor = .clear
label.autoresizingMask = [.flexibleWidth, .flexibleHeight]
return label
}
func updateUIView(_ uiView: UIViewType, context: Context) {
guard let label = uiView as? UILabel else { return }
label.attributedText = attributedString
}
}
#else
#error("Unsupported platform, no NSAttributedTextView")
#endif
================================================
FILE: Sources/Client/Components/OptionalNumberField.swift
================================================
import SwiftUI
import Combine
struct OptionalNumberField<Number: FixedWidthInteger>: View {
let title: String
@State private var string: String
@Binding private var number: Number?
@Binding private var isValid: Bool
init(_ title: String, number: Binding<Number?>, isValid: Binding<Bool>) {
self.title = title
_number = number
_string = State(initialValue: number.wrappedValue?.description ?? "")
_isValid = isValid
}
var body: some View {
TextField(title, text: $string)
.onReceive(Just(string)) { newValue in
if newValue == "" {
number = nil
isValid = false
}
if let number = Number(newValue) {
self.number = number
isValid = true
} else {
isValid = false
}
}
}
}
================================================
FILE: Sources/Client/Components/PingIndicator.swift
================================================
import SwiftUI
struct PingIndicator: View {
let color: Color
var body: some View {
Circle()
.foregroundColor(color)
.fixedSize()
}
}
================================================
FILE: Sources/Client/Components/PixellatedBorder.swift
================================================
import SwiftUI
struct PixellatedBorder: InsettableShape {
public var insetAmount: CGFloat = 0
private let borderCorner: CGFloat = 4
func path(in rect: CGRect) -> Path {
var path = Path()
// Top
path.move(to: CGPoint(x: borderCorner + insetAmount, y: borderCorner / 2 + insetAmount))
path.addLine(to: CGPoint(x: rect.width - borderCorner - insetAmount, y: borderCorner / 2 + insetAmount))
// Right
path.move(to: CGPoint(x: rect.width - borderCorner / 2 - insetAmount, y: borderCorner + insetAmount))
path.addLine(to: CGPoint(x: rect.width - borderCorner/2 - insetAmount, y: rect.height - borderCorner - insetAmount))
// Bottom
path.move(to: CGPoint(x: rect.width - borderCorner - insetAmount, y: rect.height - borderCorner / 2 - insetAmount))
path.addLine(to: CGPoint(x: borderCorner + insetAmount, y: rect.height - borderCorner / 2 - insetAmount))
// Left
path.move(to: CGPoint(x: borderCorner / 2 + insetAmount, y: rect.height - borderCorner - insetAmount))
path.addLine(to: CGPoint(x: borderCorner / 2 + insetAmount, y: borderCorner + insetAmount))
return path
}
func inset(by amount: CGFloat) -> some InsettableShape {
var border = self
border.insetAmount += amount
return border
}
}
================================================
FILE: Sources/Client/Config/Config.swift
================================================
import Foundation
import DeltaCore
import OrderedCollections
/// The client's configuration. Usually stored in a JSON file.
struct Config: Codable, ClientConfiguration {
/// The current config version used by the client.
static let currentVersion: Float = 0
/// The config format version. Used to detect outdated config files (and maybe
/// in future to migrate them). Completely independent from the actual Delta
/// Client version.
var version: Float = currentVersion
/// The random token used to identify ourselves to Mojang's API
var clientToken = UUID().uuidString
/// The id of the currently selected account.
var selectedAccountId: String?
/// The dictionary containing all of the user's accounts.
var accounts: [String: Account] = [:]
/// The user's server list.
var servers: [ServerDescriptor] = []
/// Rendering related configuration.
var render = RenderConfiguration(enableOrderIndependentTransparency: true)
/// Plugins that the user has explicitly unloaded.
var unloadedPlugins: [String] = []
/// The user's keymap.
var keymap = Keymap.default
/// Whether to use the sprint key as a toggle.
var toggleSprint = false
/// Whether to use the sneak key as a toggle.
var toggleSneak = false
/// The in game mouse sensitivity
var mouseSensitivity: Float = 1
/// The user's accounts, ordered by username.
var orderedAccounts: [Account] {
accounts.values.sorted { $0.username <= $1.username }
}
/// The account the user has currently selected.
var selectedAccount: Account? {
if let id = selectedAccountId {
return accounts[id]
} else {
return nil
}
}
/// Creates the default config.
init() {}
/// Loads a configuration from a JSON configuration file.
static func load(from file: URL) throws -> Config {
let data = try Data(contentsOf: file)
let json = try JSONSerialization.jsonObject(with: data) as? [String: Any]
guard let version = json?["version"] as? Float else {
throw ConfigError.missingVersion
}
guard version == currentVersion else {
throw ConfigError.unsupportedVersion(version)
}
return try JSONDecoder().decode(Self.self, from: data)
}
/// Saves the configuration to a JSON file.
func save(to file: URL) throws {
let encoder = JSONEncoder()
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
let data = try encoder.encode(self)
try data.write(to: file)
}
/// Adds an account to the configuration. If an account with the same id already
/// exists, it gets replaced.
mutating func addAccount(_ account: Account) {
accounts[account.id] = account
}
/// Sets the selected account id. If the `id` is `nil`, then no account is selected.
mutating func selectAccount(withId id: String?) {
selectedAccountId = id
}
/// Adds a collection of accounts to the configuration. Any existing accounts with
/// overlapping ids are replaced.
mutating func addAccounts(_ accounts: [Account]) {
for account in accounts {
addAccount(account)
}
}
}
================================================
FILE: Sources/Client/Config/ConfigError.swift
================================================
import Foundation
public enum ConfigError: LocalizedError {
/// The config file is missing a version.
case missingVersion
/// The config file is using an unsupported version.
case unsupportedVersion(Float)
/// The account in question is of an invalid type.
case invalidAccountType
/// No account exists with the given id.
case invalidAccountId
/// The currently selected account is of an invalid type.
case invalidSelectedAccountType
/// Failed to refresh an account.
case accountRefreshFailed
/// Not account has been selected.
case noAccountSelected
public var errorDescription: String? {
switch self {
case .missingVersion:
return "Your config file is missing a 'version' field."
case let .unsupportedVersion(version):
return "Your config file version (\(version)) is unsupported. " +
"\(Config.currentVersion) is the current supported version."
case .invalidAccountType:
return "The account in question is of an invalid type."
case .invalidAccountId:
return "No such account."
case .invalidSelectedAccountType:
return "The currently selected account is of an invalid type."
case .accountRefreshFailed:
return "Failed to refresh the given account."
case .noAccountSelected:
return "No account has been selected."
}
}
}
================================================
FILE: Sources/Client/Config/ManagedConfig.swift
================================================
import Foundation
import DeltaCore
/// Manages the config stored in a config file.
@dynamicMemberLookup
final class ManagedConfig: ObservableObject {
/// The current config.
var config: Config {
willSet {
objectWillChange.send()
}
didSet {
do {
// TODO: Reduce the number of writes to disk, perhaps by asynchronously
// debouncing. Often multiple config changes will happen in very quick
// succession.
try config.save(to: file)
} catch {
saveErrorHandler?(error)
}
}
}
subscript<T>(dynamicMember member: WritableKeyPath<Config, T>) -> T {
get {
config[keyPath: member]
}
set {
config[keyPath: member] = newValue
}
}
/// The file the configuration is stored in.
let file: URL
/// A handler for errors which occur when attempting to save the configuration
/// to disk in the background.
let saveErrorHandler: ((any Error) -> Void)?
/// Manages a configuration backed by a given file.
init(_ config: Config, backedBy file: URL, saveErrorHandler: ((any Error) -> Void)?) {
self.file = file
self.config = config
self.saveErrorHandler = saveErrorHandler
}
/// Resets the configuration to defaults.
func reset() throws {
config = Config()
}
/// Refreshes the specified account if necessary, saves it, and returns it (if
/// an account exists with the given id).
func refreshAccount(withId id: String) async throws -> Account {
// Takes an id instead of a whole account to make it clear that it's
// operating in-place on the config (taking an account would make it
// unclear whether the account must be in the underlying config and
// whether it gets saved after getting refreshed).
guard let account = config.accounts[id] else {
throw ConfigError.invalidAccountId.with("Id", id)
}
guard account.online?.accessToken.hasExpired == true else {
return account
}
do {
let refreshedAccount = try await account.refreshed(withClientToken: config.clientToken)
config.addAccount(refreshedAccount)
return refreshedAccount
} catch {
throw ConfigError.accountRefreshFailed
.with("Username", account.username)
.becauseOf(error)
}
}
/// Gets the currently selected account (throws if no account is selected),
/// and refreshes the account if necessary. May seem like the function is
/// doing too much, but it's beneficial for usage of this to be concise.
func selectedAccountRefreshedIfNecessary() async throws -> Account {
guard let account = config.selectedAccount else {
throw ConfigError.noAccountSelected
}
return try await refreshAccount(withId: account.id)
}
// TODO: Maybe we just shouldn't even refresh at app start, we could just refresh at time of
// use.
/// Refreshes all accounts which are close to expiring or have expired.
/// - Returns: Any errors which occurred during account refreshing.
func refreshAccounts() async -> [any Error] {
var errors: [any Error] = []
for account in config.accounts.values {
do {
_ = try await refreshAccount(withId: account.id)
} catch {
errors.append(error)
}
}
return errors
}
}
extension ManagedConfig: ClientConfiguration {
var render: RenderConfiguration {
get {
config.render
}
set {
config.render = newValue
}
}
var keymap: Keymap {
get {
config.keymap
}
set {
config.keymap = newValue
}
}
var toggleSprint: Bool {
get {
config.toggleSprint
}
set {
config.toggleSprint = newValue
}
}
var toggleSneak: Bool {
get {
config.toggleSneak
}
set {
config.toggleSneak = newValue
}
}
}
================================================
FILE: Sources/Client/DeltaClientApp.swift
================================================
import SwiftUI
import DeltaCore
/// The entry-point for Delta Client.
struct DeltaClientApp: App {
@StateObject var appState = StateWrapper<AppState>(initial: .serverList)
@StateObject var pluginEnvironment = PluginEnvironment()
@StateObject var modal = Modal()
@StateObject var controllerHub = ControllerHub()
@State var storage: StorageDirectory?
@State var hasLoaded = false
let arguments: CommandLineArguments
/// A Delta Client version.
enum Version {
/// A version such as `1.0.0`.
case semantic(String)
/// A nightly build's version (e.g. `ae348f8...`).
case commit(String)
}
/// Gets the current client's version. `nil` if the app doesn't have an `Info.plist` or
/// the `CFBundleShortVersionString` key is missing.
static var version: Version? {
guard let versionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else {
return nil
}
if versionString.hasPrefix("commit: ") {
return .commit(String(versionString.dropFirst("commit: ".count)))
} else {
return .semantic(versionString)
}
}
init() {
arguments = CommandLineArguments.parseOrExit()
setConsoleLogLevel(arguments.logLevel)
DiscordManager.shared.updateRichPresence(to: .menu)
}
var body: some Scene {
WindowGroup {
LoadAndThen(arguments, $hasLoaded, $storage) { managedConfig, resourcePack, pluginEnvironment in
RouterView()
.environmentObject(resourcePack)
.environmentObject(pluginEnvironment)
.environmentObject(managedConfig)
.onAppear {
// TODO: Make a nice clean onboarding experience
if managedConfig.selectedAccountId == nil {
appState.update(to: .login)
}
}
}
.environment(\.storage, storage ?? StorageDirectoryEnvironmentKey.defaultValue)
.environmentObject(modal)
.environmentObject(appState)
.environmentObject(controllerHub)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.navigationTitle("Delta Client")
.alert(isPresented: modal.isPresented) {
Alert(title: Text("Error"), message: (modal.content?.message).map(Text.init), dismissButton: Alert.Button.default(Text("OK")))
}
}
#if os(macOS)
.commands {
// Add preferences menu item and shortcut (cmd+,)
CommandGroup(after: .appSettings, addition: {
Button("Preferences") {
guard hasLoaded, modal.content == nil else {
return
}
switch appState.current {
case .serverList, .editServerList, .accounts, .login, .directConnect:
appState.update(to: .settings(nil))
case .playServer, .settings:
break
}
}
.keyboardShortcut(KeyboardShortcut(KeyEquivalent(","), modifiers: [.command]))
})
CommandGroup(after: .toolbar, addition: {
Button("Logs") {
guard let file = storage?.currentLogFile else {
modal.error("File logging not enabled yet")
return
}
NSWorkspace.shared.open(file)
}
})
CommandGroup(after: .windowSize, addition: {
Button("Toggle Full Screen") {
NSApp?.windows.first?.toggleFullScreen(nil)
}
.keyboardShortcut(KeyboardShortcut(KeyEquivalent("f"), modifiers: [.control, .command]))
})
}
#endif
}
}
================================================
FILE: Sources/Client/Discord/DiscordManager.swift
================================================
import Foundation
#if os(macOS)
import SwordRPC
#endif
/// Manages discord interactions
final class DiscordManager {
/// ``DiscordManager`` shared instance.
public static let shared = DiscordManager()
/// The discord rich presence currently being displayed on the user's profile.
private var currentPresenceState: RichPresenceState?
#if os(macOS)
/// Manages discord rich presence.
private let richPresenceManager = SwordRPC(appId: "907736809990148107")
#endif
private init() {
#if os(macOS)
_ = richPresenceManager.connect()
#endif
}
/// Updates the user's discord rich presence state for Delta Client if the current OS is supported.
/// - Parameter state: the preset to be used to configure the rich presence.
public func updateRichPresence(to state: RichPresenceState) {
#if os(macOS)
guard currentPresenceState != state else {
return
}
var presence = RichPresence()
presence.assets.largeImage = "dark"
presence.details = state.title
presence.state = state.subtitle
presence.timestamps.start = Date()
richPresenceManager.setPresence(presence)
currentPresenceState = state
#endif
}
}
================================================
FILE: Sources/Client/Discord/DiscordPresenceState.swift
================================================
import Foundation
extension DiscordManager {
/// State of Discord rich presence.
enum RichPresenceState: Equatable {
/// The user is not currently connected to a server.
case menu
/// The user is playing on a server.
case game(server: String?)
/// Shown as the state of the game in Discord. Displayed under the name 'Delta Client'.
var title: String {
switch self {
case .menu:
return "Main menu"
case .game:
return "In game"
}
}
/// Shown under `title` by Discord.
var subtitle: String? {
switch self {
case .menu:
return nil
case .game(let server):
if let server = server {
return "Playing on '\(server)'"
}
return nil
}
}
}
}
================================================
FILE: Sources/Client/Extensions/Binding+onChange.swift
================================================
import Foundation
import SwiftUI
// This excellent solution is from https://www.hackingwithswift.com/quick-start/swiftui/how-to-run-some-code-when-state-changes-using-onchange
extension Binding {
func onChange(_ handler: @escaping (Value) -> Void) -> Binding<Value> {
Binding(
get: { self.wrappedValue },
set: { newValue in
self.wrappedValue = newValue
handler(newValue)
}
)
}
}
================================================
FILE: Sources/Client/Extensions/Box+ObservableObject.swift
================================================
import Combine
import DeltaCore
extension Box: ObservableObject {
public var objectWillChange: ObservableObjectPublisher {
ObservableObjectPublisher()
}
}
================================================
FILE: Sources/Client/Extensions/TaskProgress+ObservableObject.swift
================================================
import Combine
import DeltaCore
extension TaskProgress: ObservableObject {
public var objectWillChange: ObservableObjectPublisher {
let publisher = ObservableObjectPublisher()
onChange { _ in
ThreadUtil.runInMain {
publisher.send()
}
}
return publisher
}
}
================================================
FILE: Sources/Client/Extensions/View.swift
================================================
import SwiftUI
extension View {
/// Returns a copy of self with the specified property set to the given value.
/// Useful for implementing custom view modifiers.
func with<T>(_ keyPath: WritableKeyPath<Self, T>, _ value: T) -> Self {
var view = self
view[keyPath: keyPath] = value
return view
}
/// Appends an action to an action stored property. Useful for implementing custom
/// view modifiers such as `onClick` etc. Allows the modifier to be called multiple
/// times without overwriting previous actions. If the stored action is nil, the
/// given action becomes the stored action, otherwise the new action is appended to
/// the existing action.
func appendingAction<T>(
to keyPath: WritableKeyPath<Self, ((T) -> Void)?>,
_ action: @escaping (T) -> Void
) -> Self {
with(keyPath) { argument in
self[keyPath: keyPath]?(argument)
action(argument)
}
}
/// Appends an action to an action stored property. Useful for implementing custom
/// view modifiers such as `onClick` etc. Allows the modifier to be called multiple
/// times without overwriting previous actions. If the stored action is nil, the
/// given action becomes the stored action, otherwise the new action is appended to
/// the existing action.
func appendingAction<T, U>(
to keyPath: WritableKeyPath<Self, ((T, U) -> Void)?>,
_ action: @escaping (T, U) -> Void
) -> Self {
with(keyPath) { argument1, argument2 in
self[keyPath: keyPath]?(argument1, argument2)
action(argument1, argument2)
}
}
/// Appends an action to an action stored property. Useful for implementing custom
/// view modifiers such as `onClick` etc. Allows the modifier to be called multiple
/// times without overwriting previous actions. If the stored action is nil, the
/// given action becomes the stored action, otherwise the new action is appended to
/// the existing action.
func appendingAction<T, U, V>(
to keyPath: WritableKeyPath<Self, ((T, U, V) -> Void)?>,
_ action: @escaping (T, U, V) -> Void
) -> Self {
with(keyPath) { argument1, argument2, argument3 in
self[keyPath: keyPath]?(argument1, argument2, argument3)
action(argument1, argument2, argument3)
}
}
/// Appends an action to an action stored property. Useful for implementing custom
/// view modifiers such as `onClick` etc. Allows the modifier to be called multiple
/// times without overwriting previous actions. If the stored action is nil, the
/// given action becomes the stored action, otherwise the new action is appended to
/// the existing action.
func appendingAction<T, U, V, W>(
to keyPath: WritableKeyPath<Self, ((T, U, V, W) -> Void)?>,
_ action: @escaping (T, U, V, W) -> Void
) -> Self {
with(keyPath) { argument1, argument2, argument3, argument4 in
self[keyPath: keyPath]?(argument1, argument2, argument3, argument4)
action(argument1, argument2, argument3, argument4)
}
}
}
================================================
FILE: Sources/Client/GitHub/GitHubBranch.swift
================================================
import Foundation
struct GitHubBranch: Decodable {
var name: String
var commit: GitHubCommit
}
================================================
FILE: Sources/Client/GitHub/GitHubCommit.swift
================================================
import Foundation
struct GitHubCommit: Decodable {
var sha: String
var url: String
}
================================================
FILE: Sources/Client/GitHub/GitHubComparison.swift
================================================
import Foundation
/// Represents a comparison between GitHub branches and/or commits
struct GitHubComparison: Decodable {
/// The position difference between the compared objects in the tree
enum Status: String, Decodable {
case diverged
case ahead
case behind
case identical
}
var status: Status
}
================================================
FILE: Sources/Client/GitHub/GitHubReleasesAPIResponse.swift
================================================
import Foundation
struct GitHubReleasesAPIResponse: Codable {
var tagName: String
var assets: [Asset]
struct Asset: Codable {
var browserDownloadURL: String
enum CodingKeys: String, CodingKey {
case browserDownloadURL = "browserDownloadUrl"
}
}
}
================================================
FILE: Sources/Client/Input/Controller.swift
================================================
import GameController
import Combine
/// A control on a controller (a button, a thumbstick, a trigger, etc).
protocol Control {
associatedtype Element: GCControllerElement
mutating func update(with element: Element)
}
/// A game controller (e.g. a PlayStation 5 controller).
class Controller: ObservableObject {
/// A display name for the controller.
var name: String {
var name = gcController.productCategory
if gcController.playerIndex != GCControllerPlayerIndex.indexUnset {
name = "\(name) (player \(gcController.playerIndex.rawValue + 1))"
}
return name
}
/// The underlying controller getting wrapped. I usually wouldn't prefix
/// a property like that to match its type, but ``ControllerHub`` was getting
/// so confusing with the two different types of controllers both getting
/// referred to as `controller` and `controller.controller` and stuff.
let gcController: GCController
/// A publisher for subscribing to controller input events.
var eventPublisher: AnyPublisher<Event, Never> {
eventSubject.eraseToAnyPublisher()
}
/// The states of all buttons, indexed by ``Button/rawValue``. Assumes that the
/// raw values form a contiguous range starting from 0.
private var buttonStates = Array(repeating: false, count: Button.allCases.count)
/// The states of all thumbsticks, indexed by ``Thumbstick/rawValue``. Assumes that the
/// raw values form a contiguous range starting from 0.
private var thumbstickStates = Array(
repeating: ThumbstickState(),
count: Thumbstick.allCases.count
)
/// Private to prevent users from publishing their own events and messing things up.
private var eventSubject = PassthroughSubject<Event, Never>()
/// Wraps a controller to make it easily observable. Returns `nil` if the
/// controller isn't supported (doesn't have an extended gamepad).
init?(for gcController: GCController) {
guard let pad = gcController.extendedGamepad else {
return nil
}
self.gcController = gcController
pad.valueChangedHandler = { [weak self] pad, element in
guard let self = self else { return }
// We could use `element` to skip buttons which haven't been updated,
// but that wouldn't work for the dpad buttons, because in that case
// the element is the dpad instead of the invidual dpad button that
// changed.
for button in Button.allCases {
// Get the button's new state, skipping buttons which the controller doesn't have.
let newState: Bool
switch button.keyPath {
case let .required(keyPath):
newState = pad[keyPath: keyPath].isPressed
case let .optional(keyPath):
guard let buttonElement = pad[keyPath: keyPath] else {
continue
}
newState = buttonElement.isPressed
}
// Some buttons set multiple updates when changing states because they're
// analog (like the triggers on the PS5 controller), so we need to filter
// those updates out.
guard newState != self.buttonStates[button.rawValue] else {
continue
}
self.buttonStates[button.rawValue] = newState
if newState {
self.eventSubject.send(.buttonPressed(button))
} else {
self.eventSubject.send(.buttonReleased(button))
}
}
for thumbstick in Thumbstick.allCases {
let thumbstickElement = pad[keyPath: thumbstick.keyPath]
// Ignore updates which don't affect this thumbstick
guard thumbstickElement == element else {
continue
}
let x = thumbstickElement.xAxis.value
let y = thumbstickElement.yAxis.value
self.thumbstickStates[thumbstick.rawValue].x = x
self.thumbstickStates[thumbstick.rawValue].y = y
self.eventSubject.send(.thumbstickMoved(thumbstick, x: x, y: y))
}
}
NotificationCenter.default.addObserver(
self,
selector: #selector(handlePossibleDisconnect),
name: NSNotification.Name.GCControllerDidDisconnect,
object: nil
)
}
/// Due to how vague the NotificationCenter observation API is, we just know
/// that *a* controller was disconnected. If it was this one, do something
/// about it.
@objc private func handlePossibleDisconnect() {
guard !GCController.controllers().contains(gcController) else {
// We survive another day, do nothing
return
}
// TODO: Do something when a controller disconnects
}
}
extension Controller {
enum Event {
/// A specific button was pressed.
case buttonPressed(Button)
/// A specific button was released.
case buttonReleased(Button)
/// The thumbstick moved to a new position `(x, y)`.
case thumbstickMoved(Thumbstick, x: Float, y: Float)
}
/// `GCControllerButtonInput`s are sometimes optional, but we want to treat
/// them all the same way so we need an enum.
enum GCControllerButtonKeyPath {
case required(KeyPath<GCExtendedGamepad, GCControllerButtonInput>)
case optional(KeyPath<GCExtendedGamepad, GCControllerButtonInput?>)
}
/// A controller button (includes triggers, shoulders, thumbstick buttons, etc). The
/// raw value is used as an index when storing buttons in arrays.
enum Button: Int, CaseIterable {
case leftTrigger
case rightTrigger
case leftShoulder
case rightShoulder
case leftThumbstickButton
case rightThumbstickButton
case buttonA
case buttonB
case buttonX
case buttonY
case dpadUp
case dpadDown
case dpadLeft
case dpadRight
var keyPath: GCControllerButtonKeyPath {
switch self {
case .leftTrigger:
return .required(\.leftTrigger)
case .rightTrigger:
return .required(\.rightTrigger)
case .leftShoulder:
return .required(\.leftShoulder)
case .rightShoulder:
return .required(\.rightShoulder)
case .leftThumbstickButton:
return .optional(\.leftThumbstickButton)
case .rightThumbstickButton:
return .optional(\.rightThumbstickButton)
case .buttonA:
return .required(\.buttonA)
case .buttonB:
return .required(\.buttonB)
case .buttonX:
return .required(\.buttonX)
case .buttonY:
return .required(\.buttonY)
case .dpadUp:
return .required(\.dpad.up)
case .dpadDown:
return .required(\.dpad.down)
case .dpadLeft:
return .required(\.dpad.left)
case .dpadRight:
return .required(\.dpad.right)
}
}
}
/// A controller thumbstick (often called a joystick). The raw value is used as
/// an index when storing thumbsticks in arrays.
enum Thumbstick: Int, CaseIterable {
case left
case right
var keyPath: KeyPath<GCExtendedGamepad, GCControllerDirectionPad> {
switch self {
case .left:
return \.leftThumbstick
case .right:
return \.rightThumbstick
}
}
}
/// The current state of a thumbstick.
struct ThumbstickState {
var x: Float = 0
var y: Float = 0
}
}
extension Controller: Equatable {
static func ==(_ lhs: Controller, _ rhs: Controller) -> Bool {
lhs.gcController == rhs.gcController
}
}
extension Controller: Hashable {
func hash(into hasher: inout Hasher) {
hasher.combine(ObjectIdentifier(gcController))
}
}
================================================
FILE: Sources/Client/Input/ControllerHub.swift
================================================
import GameController
import DeltaCore
class ControllerHub: ObservableObject {
@Published var controllers: [Controller] = []
@Published var currentController: Controller?
init() {
// Register notification observers.
observe(NSNotification.Name.GCControllerDidConnect)
observe(NSNotification.Name.GCControllerDidDisconnect)
observe(NSNotification.Name.GCControllerDidBecomeCurrent)
observe(NSNotification.Name.GCControllerDidStopBeingCurrent)
// Check for controllers that might already be connected.
updateControllers()
}
/// Registers an observer to update all controllers when a given event occurs.
private func observe(_ event: NSNotification.Name) {
NotificationCenter.default.addObserver(
self,
selector: #selector(updateControllers),
name: event,
object: nil
)
}
@objc private func updateControllers() {
// If we jump to the main thread synchronously then some sort of internal GCController
// lock never gets dropped and `GCController.current` causes a deadlock (strange).
DispatchQueue.main.async {
let gcControllers = GCController.controllers()
// Handle newly connected controllers
for gcController in gcControllers {
guard
!self.controllers.contains(where: { $0.gcController == gcController }),
let controller = Controller(for: gcController)
else {
continue
}
gcController.playerIndex = GCControllerPlayerIndex(rawValue: self.controllers.count) ?? .indexUnset
self.controllers.append(controller)
log.info("Connected \(controller.name) controller")
}
// Handle newly disconnected controllers
for (i, controller) in self.controllers.enumerated() {
if !gcControllers.contains(controller.gcController) {
self.controllers.remove(at: i)
log.info("Disconnected \(controller.name) controller")
}
}
// Update the current controller (last used)
var current: Controller? = nil
for controller in self.controllers {
if controller.gcController == GCController.current {
current = controller
}
}
if self.currentController != current {
self.currentController = current
}
}
}
}
================================================
FILE: Sources/Client/Input/InputMethod.swift
================================================
enum InputMethod: Hashable {
case keyboardAndMouse
case controller(Controller)
var name: String {
switch self {
case .keyboardAndMouse:
return "Keyboard and mouse"
case let .controller(controller):
return controller.gcController.productCategory
}
}
var detail: String? {
switch self {
case .keyboardAndMouse:
return nil
case let .controller(controller):
let player = controller.gcController.playerIndex
if player != .indexUnset {
return "player \(player.rawValue + 1)"
} else {
return nil
}
}
}
var isController: Bool {
switch self {
case .keyboardAndMouse:
return false
case .controller:
return true
}
}
var controller: Controller? {
switch self {
case .keyboardAndMouse:
return nil
case let .controller(controller):
return controller
}
}
}
================================================
FILE: Sources/Client/Logger.swift
================================================
@_exported import DeltaLogger
================================================
FILE: Sources/Client/Modal.swift
================================================
import DeltaCore
import SwiftUI
class Modal: ObservableObject {
enum Content {
case warning(String)
case errorMessage(String)
case error(Error)
var message: String {
switch self {
case let .warning(message):
return message
case let .errorMessage(message):
return message
case let .error(error):
if let richError = error as? RichError {
return richError.richDescription
} else {
return error.localizedDescription
}
}
}
}
var isPresented: Binding<Bool> {
Binding {
self.content != nil
} set: { newValue in
if !newValue {
self.content = nil
self.dismissHandler?()
}
}
}
@Published var content: Content?
private var dismissHandler: (() -> Void)?
/// Handlers to call when an error occurs. Guaranteed to be called on the
/// main thread.
private var errorHandlers: [(Error) -> Void] = []
func onError(_ action: @escaping (Error) -> Void) {
errorHandlers.append(action)
}
func warning(_ message: String, onDismiss dismissHandler: (() -> Void)? = nil) {
log.warning(message)
ThreadUtil.runInMain {
content = .warning(message)
self.dismissHandler = dismissHandler
}
}
func error(_ message: String, onDismiss dismissHandler: (() -> Void)? = nil) {
log.error(message)
ThreadUtil.runInMain {
content = .errorMessage(message)
self.dismissHandler = dismissHandler
for errorHandler in errorHandlers {
errorHandler(RichError(message))
}
}
}
func error(_ error: Error, onDismiss dismissHandler: (() -> Void)? = nil) {
log.error(error.localizedDescription)
ThreadUtil.runInMain {
content = .error(error)
self.dismissHandler = dismissHandler
for errorHandler in errorHandlers {
errorHandler(error)
}
}
}
}
================================================
FILE: Sources/Client/State/AppState.swift
================================================
import Foundation
import DeltaCore
/// App states
indirect enum AppState: Equatable {
case serverList
case editServerList
case accounts
case login
case directConnect
case playServer(ServerDescriptor, paneCount: Int)
case settings(SettingsState?)
}
================================================
FILE: Sources/Client/State/StateWrapper.swift
================================================
import Foundation
import DeltaCore
/// An observable wrapper around a state enum for use with SwiftUI
final class StateWrapper<State>: ObservableObject {
@Published private(set) var current: State
private var history: [State] = []
/// Create a new state wrapper with the specified initial state
init(initial: State) {
current = initial
}
/// Update the app state to the state specified, on the main thread.
func update(to newState: State) {
ThreadUtil.runInMain {
// Update state
let current = self.current
self.current = newState
// Simplify state history
if let index = history.firstIndex(where: { name(of: $0) == name(of: current) }) {
history.removeLast(history.count - index)
}
if let index = history.firstIndex(where: { name(of: $0) == name(of: newState) }) {
history.removeLast(history.count - index)
}
// Update state history
history.append(current)
}
}
/// Return to the previous app state
func pop() {
ThreadUtil.runInMain {
if !history.isEmpty {
let previousState = history.removeLast()
update(to: previousState)
} else {
log.warning("failed to pop app state, no previous state to return to")
}
}
}
private func name(of state: State) -> String {
return String(describing: state)
}
}
================================================
FILE: Sources/Client/StorageDirectory.swift
================================================
import Foundation
import SwiftUI
import DeltaCore
/// An error thrown by ``StorageDirectory``.
enum StorageDirectoryError: LocalizedError {
case failedToCreateBackup
var errorDescription: String? {
switch self {
case .failedToCreateBackup:
return "Failed to create backup of storage directory."
}
}
}
struct StorageDirectoryEnvironmentKey: EnvironmentKey {
static let defaultValue: StorageDirectory = StorageDirectory(URL(fileURLWithPath: "."))
}
extension EnvironmentValues {
var storage: StorageDirectory {
get { self[StorageDirectoryEnvironmentKey.self] }
set { self[StorageDirectoryEnvironmentKey.self] = newValue }
}
}
// TODO: Find if there's a way to just have this as a struct (it's just immutable data, but needs
// to be a class).
/// A wrapper around Delta Client's storage directory URL. Used to define a consistent structure,
/// and house useful helper methods. Never guarantees that the described directories exist.
struct StorageDirectory {
/// The default storage directory for the current platform.
static var platformDefault: StorageDirectory? {
#if os(macOS) || os(iOS)
let options = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)
let base = options.first?.appendingPathComponent("dev.stackotter.delta-client")
return base.map(StorageDirectory.init)
#elseif os(tvOS)
let base = FileManager.default.temporaryDirectory.appendingPathComponent("dev.stackotter.delta-client")
try? FileManager.default.createDirectory(at: base, withIntermediateDirectories: true)
return StorageDirectory(base)
#elseif os(Linux)
#error("Linux storage directory not implemented")
#endif
}
/// The root of the storage directory.
private(set) var baseDirectory: URL
/// A custom plugin directory which overrides the default plugin directory
/// location. Set to `nil` for ``StorageDirectory/pluginDirectory`` to go
/// back to the default.
var pluginDirectoryOverride: URL?
/// The directory for assets (e.g. the vanilla resource pack).
var assetDirectory: URL {
baseDirectory.appendingPathComponent("assets")
}
/// The directory for registries (e.g. the block registry and item registry).
var registryDirectory: URL {
baseDirectory.appendingPathComponent("registries")
}
/// The directory for user-installed plugins.
var pluginDirectory: URL {
pluginDirectoryOverride ?? baseDirectory.appendingPathComponent("plugins")
}
/// The directory for performance-enhancing caches.
var cacheDirectory: URL {
baseDirectory.appendingPathComponent("cache")
}
/// The directory for GPU captures (traces).
var gpuCaptureDirectory: URL {
baseDirectory.appendingPathComponent("captures")
}
/// The directory to store log files.
var logDirectory: URL {
baseDirectory.appendingPathComponent("logs")
}
/// The current log file.
var currentLogFile: URL {
logDirectory.appendingPathComponent("delta-client.log")
}
/// The client configuration file.
var configFile: URL {
baseDirectory.appendingPathComponent("config.json")
}
/// Initializes a storage directory (without guaranteeing that it exists).
init(_ base: URL) {
baseDirectory = base
}
/// Creates a unique GPU capture output file path of the form
/// `capture_dd-MM-yyyy_HH-mm-ss.gputrace`.
func uniqueGPUCaptureFile() -> URL {
let date = Date()
let formatter = DateFormatter()
formatter.dateFormat = "dd-MM-yyyy_HH-mm-ss"
let fileName = "capture_\(formatter.string(from: date)).gputrace"
return gpuCaptureDirectory.appendingPathComponent(fileName)
}
/// Creates the storage directory if it doesn't already exist.
func ensureCreated() throws {
guard !FileSystem.itemExists(baseDirectory) else {
return
}
try FileSystem.createDirectory(baseDirectory)
}
/// Gets the location of the resource pack cache for the pack with the given name.
func cache(forResourcePackNamed name: String) -> URL {
cacheDirectory.appendingPathComponent("\(name).rpcache")
}
/// Gets the URL to a file with the given name in the storage directory.
func file(_ name: String) -> URL {
baseDirectory.appendingPathComponent(name)
}
/// Creates a backup of the storage directory. If an output file isn't supplied, a
/// filename is autogenerated from the current datetime, and the backup is stored
/// in the base of the storage directory.
///
/// If `zipFile` is provided, and the file already exists, its existing contents
/// get overwritten.
func backup(to zipFile: URL? = nil) throws {
let backupFile: URL
if let zipFile = zipFile {
backupFile = zipFile
} else {
let date = Date()
let formatter = DateFormatter()
formatter.dateFormat = "dd-MM-yyyy_HH-mm-ss"
let backupName = "backup_\(formatter.string(from: date))"
backupFile = file("\(backupName).zip")
}
do {
try FileManager.default.zipItem(at: baseDirectory, to: backupFile)
} catch {
throw StorageDirectoryError.failedToCreateBackup.becauseOf(error)
}
}
/// Resets the contents of the storage directory. If `keepBackups` is true, then
/// any files which begin with `backup` won't get deleted.
func reset(keepBackups: Bool = true) throws {
let contents = try FileSystem.children(of: baseDirectory)
for item in contents {
// Remove item if it is not a backup
if !(keepBackups && item.lastPathComponent.hasPrefix("backup")) {
try FileSystem.remove(item)
}
}
}
/// Removes all caches from the storage directory.
func removeCache() throws {
try FileSystem.remove(cacheDirectory)
}
}
================================================
FILE: Sources/Client/Utility/Clipboard.swift
================================================
#if canImport(AppKit)
import AppKit
#elseif canImport(UIKit)
import UIKit
#endif
/// A simple helper for managing the user's clipboard.
enum Clipboard {
/// Sets the contents of the user's clipboard to a given string.
static func copy(_ contents: String) {
#if canImport(AppKit)
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(contents, forType: .string)
#elseif os(iOS)
UIPasteboard.general.string = contents
#elseif os(tvOS)
#warning("Remove dependence on copy on tvOS")
#else
#error("Unsupported platform, unknown clipboard implementation")
#endif
}
}
================================================
FILE: Sources/Client/Utility/Updater.swift
================================================
#if os(macOS)
import SwiftUI
import DeltaCore
/// An error thrown by ``Updater``.
enum UpdaterError: LocalizedError {
case failedToGetDownloadURL
case failedToGetDownloadURLFromGitHubReleases
case alreadyUpToDate
case failedToGetBranches
case failedToGetGitHubAPIResponse
case failedToDownloadUpdate
case failedToSaveDownload
case failedToUnzipUpdate
case failedToDeleteCache
case invalidReleaseURL
case invalidNightlyURL
case invalidGitHubComparisonURL
var errorDescription: String? {
switch self {
case .failedToGetDownloadURL:
return "Failed to get download URL."
case .failedToGetDownloadURLFromGitHubReleases:
return "Failed to get download URL from GitHub Releases."
case .alreadyUpToDate:
return "You are already up to date."
case .failedToGetBranches:
return "Failed to get branches."
case .failedToGetGitHubAPIResponse:
return "Failed to get GitHub API response."
case .failedToDownloadUpdate:
return "Failed to download update."
case .failedToSaveDownload:
return "Failed to save download to disk."
case .failedToUnzipUpdate:
return "Failed to unzip update."
case .failedToDeleteCache:
return "Failed to delete cache."
case .invalidReleaseURL:
return "Invalid release URL."
case .invalidNightlyURL:
return "Invalid nightly URL."
case .invalidGitHubComparisonURL:
return "Invalid GitHub comparison URL."
}
}
}
/// An update to perform.
enum Update {
/// Update from GitHub releases.
case latestRelease
/// Update from latest CI build.
case nightly(branch: String)
/// Whether the update is nightly or not.
var isNightly: Bool {
switch self {
case .latestRelease:
return false
case .nightly:
return true
}
}
}
/// A download for an update.
struct Download {
/// The download's URL.
var url: URL
/// The version to display.
var version: String
}
/// Used to update the client to either the latest successful CI build or the latest GitHub release.
enum Updater {
/// A step in an update. Used to track progress.
enum UpdateStep: TaskStep {
case downloadUpdate
case unzipUpdate
case unzipUpdateSecondLayer
case deleteCache
case tMinus3
case tMinus2
case tMinus1
var message: String {
switch self {
case .downloadUpdate:
return "Downloading update"
case .unzipUpdate:
return "Unzipping update"
case .unzipUpdateSecondLayer:
return "Unzipping second layer of update"
case .deleteCache:
return "Deleting cache"
case .tMinus3:
return "Restarting app in 3"
case .tMinus2:
return "Restarting app in 2"
case .tMinus1:
return "Restarting app in 1"
}
}
var relativeDuration: Double {
switch self {
case .downloadUpdate:
return 10
case .unzipUpdate:
return 2
case .unzipUpdateSecondLayer:
return 2
case .deleteCache:
return 1
case .tMinus3:
return 1
case .tMinus2:
return 1
case .tMinus1:
return 1
}
}
}
/// Performs a given update. Once the update's version string is known, `displayVersion`
/// is updated (allowing a UI to display the version before the update has finished).
/// `storage` is used to delete the cache before restarting the app.
///
/// Never returns (unless an error occurs) because it restarts the app to allow the
/// update to take effect.
static func performUpdate(download: Download, isNightly: Bool, storage: StorageDirectory, progress: TaskProgress<UpdateStep>? = nil) async throws -> Never {
let progress = progress ?? TaskProgress()
// Download the release
let data = try await progress.perform(.downloadUpdate) { observeStepProgress in
try await withCheckedThrowingContinuation { continuation in
let task = URLSession.shared.dataTask(with: download.url) { data, response, error in
if let data = data {
continuation.resume(returning: data)
} else {
var richError: any LocalizedError = UpdaterError.failedToDownloadUpdate
if let error = error {
richError = richError.becauseOf(error)
}
continuation.resume(throwing: richError)
}
}
observeStepProgress(task.progress)
task.resume()
}
}
try Task.checkCancellation()
let temp = FileManager.default.temporaryDirectory
let zipFile = temp.appendingPathComponent("DeltaClient.zip")
let outputDirectory = temp.appendingPathComponent("DeltaClient-\(UUID().uuidString)")
do {
try data.write(to: zipFile)
} catch {
throw UpdaterError.failedToSaveDownload.becauseOf(error)
}
try Task.checkCancellation()
try await progress.perform(.unzipUpdate) { observeStepProgress in
do {
let progress = Progress()
observeStepProgress(progress)
try FileManager.default.unzipItem(at: zipFile, to: outputDirectory, skipCRC32: true, progress: progress)
} catch {
throw UpdaterError.failedToUnzipUpdate.becauseOf(error)
}
}
try Task.checkCancellation()
// Nightly builds have two layers of zip for whatever reason
try await progress.perform(.unzipUpdateSecondLayer, if: isNightly) { observeStepProgress in
let progress = Progress()
observeStepProgress(progress)
try FileManager.default.unzipItem(
at: outputDirectory.appendingPathComponent("DeltaClient.zip"),
to: outputDirectory,
skipCRC32: true,
progress: progress
)
}
try Task.checkCancellation()
// Delete the cache to avoid common issues which can occur after updating
try progress.perform(.deleteCache) {
do {
try FileSystem.remove(storage.cacheDirectory)
} catch {
throw UpdaterError.failedToDeleteCache.becauseOf(error)
}
}
try Task.checkCancellation()
progress.update(to: .tMinus3)
try await Task.sleep(nanoseconds: 1_000_000_000)
try Task.checkCancellation()
progress.update(to: .tMinus2)
try await Task.sleep(nanoseconds: 1_000_000_000)
try Task.checkCancellation()
progress.update(to: .tMinus1)
try await Task.sleep(nanoseconds: 1_000_000_000)
try Task.checkCancellation()
// Create a background task to replace the app and relaunch
let newApp = outputDirectory
.appendingPathComponent("DeltaClient.app").path
.replacingOccurrences(of: " ", with: "\\ ")
let currentApp = Bundle.main.bundlePath.replacingOccurrences(of: " ", with: "\\ ")
let logFile = storage.baseDirectory
.appendingPathComponent("output.log").path
.replacingOccurrences(of: " ", with: "\\ ")
// TODO: Refactor to avoid potential for command injection attacks (relatively low impact anyway,
// Delta Client doesn't run with elevated privileges, and this requires user interaction).
Utils.shell(
#"nohup sh -c 'sleep 3; rm -rf \#(currentApp); mv \#(newApp) \#(currentApp); open \#(currentApp); open \#(currentApp)' >\#(logFile) 2>&1 &"#
)
Foundation.exit(0)
}
/// Gets the download for a given update.
static func getDownload(for update: Update) throws -> Download {
switch update {
case .latestRelease:
return try getLatestReleaseDownload()
case .nightly(let branch):
return try getLatestNightlyDownload(branch: branch)
}
}
/// Gets the download for the latest GitHub release.
static func getLatestReleaseDownload() throws -> Download {
var decoder = CustomJSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let apiURL = URL(string: "https://api.github.com/repos/stackotter/delta-client/releases")!
let data: Data
let response: [GitHubReleasesAPIResponse]
do {
data = try Data(contentsOf: apiURL)
response = try decoder.decode([GitHubReleasesAPIResponse].self, from: data)
} catch {
throw UpdaterError.failedToGetGitHubAPIResponse.becauseOf(error)
}
guard
let tagName = response.first?.tagName,
let downloadURL = response.first?.assets.first?.browserDownloadURL
else {
throw UpdaterError.failedToGetDownloadURLFromGitHubReleases
}
guard let url = URL(string: downloadURL) else {
throw UpdaterError.invalidReleaseURL.with("URL", downloadURL)
}
return Download(url: url, version: tagName)
}
/// Gets the download for the artifact uploaded by the latest successful GitHub action run
/// on a given branch.
static func getLatestNightlyDownload(branch: String) throws -> Download {
let branches = try getBranches()
guard let commit = (branches.filter { $0.name == branch }.first?.commit) else {
throw UpdaterError.failedToGetDownloadURL.with("Reason", "Branch '\(branch)' doesn't exist.")
}
if case let .commit(currentCommit) = DeltaClientApp.version {
guard currentCommit != commit.sha else {
throw UpdaterError.alreadyUpToDate.with("Current commit", currentCommit)
}
}
let hash = commit.sha.prefix(7)
let url = "https://backend.deltaclient.app/download/\(branch)/latest/DeltaClient.app.zip"
guard let url = URL(string: url) else {
throw UpdaterError.invalidNightlyURL.with("URL", url)
}
return Download(url: url, version: "commit \(hash) (latest)")
}
/// Gets basic information about all branches of the Delta Client GitHub repository.
static func getBranches() throws -> [GitHubBranch] {
let url = URL(string: "https://api.github.com/repos/stackotter/delta-client/branches")!
do {
let data = try Data(contentsOf: url)
let response = try CustomJSONDecoder().decode([GitHubBranch].self, from: data)
return response
} catch {
throw UpdaterError.failedToGetBranches.becauseOf(error)
}
}
/// Compares two gitrefs in the Delta Client GitHub repository.
static func compareGitRefs(_ first: String, _ second: String) throws -> GitHubComparison.Status {
let url = "https://api.github.com/repos/stackotter/delta-client/compare/\(first)...\(second)"
guard let url = URL(string: url) else {
throw UpdaterError.invalidGitHubComparisonURL.with("URL", url)
}
let data = try Data(contentsOf: url)
return try CustomJSONDecoder().decode(GitHubComparison.self, from: data).status
}
/// Checks if the user is on the main branch and a newer commit is available.
static func isUpdateAvailable() throws -> Bool {
guard case let .commit(commit) = DeltaClientApp.version else {
return false
}
// TODO: When releases are supported again, check for newer releases if the user if on a release build.
let status = try compareGitRefs(commit, "main")
return status == .behind
}
}
#endif
================================================
FILE: Sources/Client/Utility/Utils.swift
================================================
import Foundation
enum Utils {
#if os(macOS)
/// Runs a shell command.
static func shell(_ command: String) {
let task = Process()
task.arguments = ["-c", command]
task.launchPath = "/bin/bash"
task.launch()
}
/// Relaunches the application.
static func relaunch() {
log.info("Relaunching Delta Client")
let url = URL(fileURLWithPath: Bundle.main.resourcePath!)
let path = url.deletingLastPathComponent().deletingLastPathComponent().absoluteString
let task = Process()
task.launchPath = "/usr/bin/open"
task.arguments = [path]
task.launch()
exit(0)
}
#endif
}
================================================
FILE: Sources/Client/Views/Play/DirectConnectView.swift
================================================
import SwiftUI
import DeltaCore
struct DirectConnectView: View {
@EnvironmentObject var appState: StateWrapper<AppState>
@State var host: String = ""
@State var port: UInt16? = nil
@State var errorMessage: String? = nil
@State var isAddressValid = false
private func verify() -> Bool {
if !isAddressValid {
errorMessage = "Invalid IP"
} else {
return true
}
return false
}
var body: some View {
VStack {
AddressField("Server address", host: $host, port: $port, isValid: $isAddressValid)
if let message = errorMessage {
Text(message)
.bold()
}
HStack {
Button("Cancel") {
appState.update(to: .serverList)
}
.buttonStyle(SecondaryButtonStyle())
Button("Connect") {
if verify() {
let descriptor = ServerDescriptor(name: "Direct Connect", host: host, port: port)
appState.update(to: .playServer(descriptor, paneCount: 1))
}
}
.buttonStyle(PrimaryButtonStyle())
}
.padding(.top, 16)
}
#if !os(tvOS)
.frame(width: 200)
#endif
#if !os(iOS)
.onExitCommand {
appState.update(to: .serverList)
}
#endif
}
}
================================================
FILE: Sources/Client/Views/Play/GameView.swift
================================================
import SwiftUI
import DeltaCore
import DeltaRenderer
import Combine
/// Where the real Minecraft stuff happens. This renders the actual game itself and
/// also handles user input.
struct GameView: View {
enum GameState {
case playing
case gpuFrameCaptureComplete(file: URL)
}
@EnvironmentObject var appState: StateWrapper<AppState>
@EnvironmentObject var managedConfig: ManagedConfig
@EnvironmentObject var modal: Modal
@Environment(\.storage) var storage: StorageDirectory
@State var state: GameState = .playing
@State var inputCaptured = true
@State var cursorCaptured = true
@Binding var inGameMenuPresented: Bool
var serverDescriptor: ServerDescriptor
var account: Account
var controller: Controller?
var controllerOnly: Bool
init(
connectingTo serverDescriptor: ServerDescriptor,
with account: Account,
controller: Controller?,
controllerOnly: Bool,
inGameMenuPresented: Binding<Bool>
) {
self.serverDescriptor = serverDescriptor
self.account = account
self.controller = controller
self.controllerOnly = controllerOnly
_inGameMenuPresented = inGameMenuPresented
}
var body: some View {
JoinServerAndThen(serverDescriptor, with: account) { client in
WithRenderCoordinator(for: client) { renderCoordinator in
VStack {
switch state {
case .playing:
ZStack {
WithController(controller, listening: $inputCaptured) {
if controllerOnly {
gameView(client: client, renderCoordinator: renderCoordinator)
} else {
InputView(listening: $inputCaptured, cursorCaptured: !inGameMenuPresented && cursorCaptured) {
gameView(client: client, renderCoordinator: renderCoordinator)
}
.onKeyPress { [weak client] key, characters in
client?.press(key, characters)
}
.onKeyRelease { [weak client] key in
client?.release(key)
}
.onMouseMove { [weak client] x, y, deltaX, deltaY in
// TODO: Formalise this adjustment factor somewhere
let sensitivityAdjustmentFactor: Float = 0.004
let sensitivity = sensitivityAdjustmentFactor * managedConfig.mouseSensitivity
client?.moveMouse(x: x, y: y, deltaX: sensitivity * deltaX, deltaY: sensitivity * deltaY)
}
.passthroughClicks(!cursorCaptured)
}
}
.onButtonPress { [weak client] button in
guard let input = input(for: button) else {
return
}
client?.press(input)
}
.onButtonRelease { [weak client] button in
guard let input = input(for: button) else {
return
}
client?.release(input)
}
.onThumbstickMove { [weak client] thumbstick, x, y in
switch thumbstick {
case .left:
client?.moveLeftThumbstick(x, y)
case .right:
client?.moveRightThumbstick(x, y)
}
}
#if os(tvOS)
.focusable(!inGameMenuPresented)
.onExitCommand {
inGameMenuPresented = true
}
#endif
}
case .gpuFrameCaptureComplete(let file):
frameCaptureResult(file)
.onAppear {
cursorCaptured = false
inputCaptured = false
}
}
}
.onAppear {
modal.onError { [weak client] _ in
client?.game.tickScheduler.cancel()
cursorCaptured = false
inputCaptured = false
}
registerEventHandler(client, renderCoordinator)
}
} cancellationHandler: {
appState.update(to: .serverList)
}
} cancellationHandler: {
appState.update(to: .serverList)
}
.onChange(of: inGameMenuPresented) { presented in
if presented {
cursorCaptured = false
inputCaptured = false
} else {
cursorCaptured = true
inputCaptured = true
}
}
}
func registerEventHandler(_ client: Client, _ renderCoordinator: RenderCoordinator) {
client.eventBus.registerHandler { event in
switch event {
case _ as OpenInGameMenuEvent:
inGameMenuPresented = true
client.releaseAllInputs()
case _ as ReleaseCursorEvent:
cursorCaptured = false
case _ as CaptureCursorEvent:
cursorCaptured = true
case let event as KeyPressEvent where event.input == .performGPUFrameCapture:
let outputFile = storage.uniqueGPUCaptureFile()
do {
try renderCoordinator.captureFrames(count: 10, to: outputFile)
} catch {
modal.error(RichError("Failed to start frame capture").becauseOf(error))
}
case let event as FinishFrameCaptureEvent:
ThreadUtil.runInMain {
state = .gpuFrameCaptureComplete(file: event.file)
}
default:
break
}
}
}
func gameView(client: Client, renderCoordinator: RenderCoordinator) -> some View {
ZStack {
if #available(macOS 13, iOS 16, *) {
MetalView(renderCoordinator: renderCoordinator)
.onAppear {
cursorCaptured = true
inputCaptured = true
}
} else {
MetalViewClass(renderCoordinator: renderCoordinator)
.onAppear {
cursorCaptured = true
inputCaptured = true
}
}
#if os(iOS)
movementControls(client)
#endif
}
}
/// Gets the input associated with a particular controller button.
func input(for button: Controller.Button) -> Input? {
switch button {
case .buttonA:
return .jump
case .leftTrigger:
return .place
case .rightTrigger:
return .destroy
case .leftShoulder:
return .previousSlot
case .rightShoulder:
return .nextSlot
case .leftThumbstickButton:
return .sprint
case .buttonB:
return .sneak
case .dpadUp:
return .changePerspective
case .dpadRight:
return .openChat
default:
return nil
}
}
func frameCaptureResult(_ file: URL) -> some View {
VStack {
Text("GPU frame capture complete")
Group {
#if os(macOS)
Button("Show in finder") {
NSWorkspace.shared.activateFileViewerSelecting([file])
}.buttonStyle(SecondaryButtonStyle())
#else
// TODO: Add a file sharing menu for iOS and tvOS
Text("I have no clue how to get hold of the file")
#endif
Button("OK") {
state = .playing
}.buttonStyle(PrimaryButtonStyle())
}.frame(width: 200)
}
}
#if os(iOS)
func movementControls(_ client: Client) -> some View {
VStack {
Spacer()
HStack {
HStack(alignment: .bottom) {
movementControl("a", .strafeLeft, client)
VStack {
movementControl("w", .moveForward, client)
movementControl("s", .moveBackward, client)
}
movementControl("d", .strafeRight, client)
}
Spacer()
VStack {
movementControl("*", .jump, client)
movementControl("_", .sneak, client)
}
}
}
}
func movementControl(_ label: String, _ input: Input, _ client: Client) -> some View {
return ZStack {
Color.blue.frame(width: 50, height: 50)
Text(label)
}.onLongPressGesture(
minimumDuration: 100000000000,
maximumDistance: 50,
perform: { return },
onPressingChanged: { [weak client] isPressing in
if isPressing {
client?.press(input)
} else {
client?.release(input)
}
}
)
}
#endif
}
================================================
FILE: Sources/Client/Views/Play/InGameMenu.swift
================================================
import SwiftUI
struct InGameMenu: View {
enum InGameMenuState {
case menu
case settings
}
@EnvironmentObject var appState: StateWrapper<AppState>
@Binding var presented: Bool
@State var state: InGameMenuState = .menu
#if os(tvOS)
@FocusState var focusState: FocusElements?
func moveFocus(_ direction: MoveCommandDirection) {
if let focusState = focusState {
let step: Int
switch direction {
case .down:
step = 1
case .up:
step = -1
case .left, .right:
return
}
let count = FocusElements.allCases.count
// Add an extra count before taking the modulo cause Swift's mod operator isn't
// the real mathematical modulo.
let index = (focusState.rawValue + step + count) % count
self.focusState = FocusElements.allCases[index]
}
}
enum FocusElements: Int, CaseIterable {
case backToGame
case settings
case disconnect
}
#endif
init(presented: Binding<Bool>) {
_presented = presented
}
var body: some View {
if presented {
GeometryReader { geometry in
VStack {
switch state {
case .menu:
VStack {
Button("Back to game") {
presented = false
}
#if os(tvOS)
.focused($focusState, equals: .backToGame)
#else
.buttonStyle(PrimaryButtonStyle())
.keyboardShortcut(.escape, modifiers: [])
#endif
Button("Settings") {
state = .settings
}
#if os(tvOS)
.focused($focusState, equals: .settings)
#endif
.buttonStyle(SecondaryButtonStyle())
Button("Disconnect") {
appState.update(to: .serverList)
}
#if os(tvOS)
.focused($focusState, equals: .disconnect)
#endif
.buttonStyle(SecondaryButtonStyle())
}
#if !os(tvOS)
.frame(width: 200)
#endif
case .settings:
SettingsView(isInGame: true) {
state = .menu
}
}
}
.frame(width: geometry.size.width, height: geometry.size.height)
.background(Color.black.opacity(0.702), alignment: .center)
#if os(tvOS)
.onAppear {
focusState = .backToGame
}
.focusSection()
#endif
}
}
}
}
================================================
FILE: Sources/Client/Views/Play/InputView.swift
================================================
import SwiftUI
import DeltaCore
import DeltaRenderer
struct InputView<Content: View>: View {
@EnvironmentObject var modal: Modal
@EnvironmentObject var appState: StateWrapper<AppState>
@State var monitorsAdded = false
@State var scrollWheelDeltaY: Float = 0
#if os(macOS)
@State var previousModifierFlags: NSEvent.ModifierFlags?
#endif
@Binding var listening: Bool
private var content: () -> Content
private var handleKeyRelease: ((Key) -> Void)?
private var handleKeyPress: ((Key, [Character]) -> Void)?
private var handleMouseMove: ((
_ x: Float,
_ y: Float,
_ deltaX: Float,
_ deltaY: Float
) -> Void)?
private var handleScroll: ((_ deltaY: Float) -> Void)?
private var shouldPassthroughClicks = false
private var shouldAvoidGeometryReader = false
init(
listening: Binding<Bool>,
cursorCaptured: Bool,
@ViewBuilder _ content: @escaping () -> Content
) {
_listening = listening
self.content = content
if cursorCaptured {
Self.captureCursor()
} else {
Self.releaseCursor()
}
}
/// Captures the cursor (locks it in place and makes it invisible).
private static func captureCursor() {
#if os(macOS)
CGAssociateMouseAndMouseCursorPosition(0)
NSCursor.hide()
#endif
}
/// Releases the cursor, making it visible and able to move around.
private static func releaseCursor() {
#if os(macOS)
CGAssociateMouseAndMouseCursorPosition(1)
NSCursor.unhide()
#endif
}
/// If listening, the view will still process clicks, but the click will
/// get passed through for the underlying view to process as well.
func passthroughClicks(_ passthroughClicks: Bool = true) -> Self {
with(\.shouldPassthroughClicks, passthroughClicks)
}
/// When `true`, `GeometryReader` won't be used, but mouse movements
/// won't be tracked. This can be used when mouse movements aren't
/// required but the `GeometryReader` is messing with layouts.
func avoidGeometryReader(_ avoidGeometryReader: Bool = true) -> Self {
with(\.shouldAvoidGeometryReader, avoidGeometryReader)
}
/// Adds an action to run when a key is released.
func onKeyRelease(_ action: @escaping (Key) -> Void) -> Self {
appendingAction(to: \.handleKeyRelease, action)
}
/// Adds an action to run when a key is pressed.
func onKeyPress(_ action: @escaping (Key, [Character]) -> Void) -> Self {
appendingAction(to: \.handleKeyPress, action)
}
/// Adds an action to run when the mouse is moved.
func onMouseMove(_ action: @escaping (_ x: Float, _ y: Float, _ deltaX: Float, _ deltaY: Float) -> Void) -> Self {
appendingAction(to: \.handleMouseMove, action)
}
/// Adds an action to run when scrolling occurs.
func onScroll(_ action: @escaping (_ deltaY: Float) -> Void) -> Self {
appendingAction(to: \.handleScroll, action)
}
#if os(macOS)
func mousePositionInView(with geometry: GeometryProxy) -> (x: Float, y: Float)? {
// This assumes that there's only one window and that this is only called once
// the view's body has been evaluated at least once.
guard let window = NSApplication.shared.orderedWindows.first else {
return nil
}
let viewFrame = geometry.frame(in: .global)
let x = (NSEvent.mouseLocation.x - window.frame.minX) - viewFrame.minX
let y = window.frame.maxY - NSEvent.mouseLocation.y - viewFrame.minY
// AppKit gives us the position scaled by the screen's scaling factor, so we
// adjust it back to get the position in terms of true pixels.
let scalingFactor = CGFloat(GUIRenderer.screenScalingFactor())
return (Float(x * scalingFactor), Float(y * scalingFactor))
}
#endif
var body: some View {
VStack {
if shouldAvoidGeometryReader {
contentWithEventListeners()
} else {
GeometryReader { geometry in
contentWithEventListeners(geometry)
}
}
}
}
func contentWithEventListeners(_ geometry: GeometryProxy? = nil) -> some View {
// Make sure that the latest position is known to any observers (e.g. if
// listening was disabled and now isn't, observers won't have been told
// about any changes that occured during the period in which listening
// was disabled).
#if os(macOS)
if let geomet
gitextract_hv9a6jeo/ ├── .editorconfig ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.md │ │ └── feature_request.md │ ├── pull_request_template.md │ └── workflows/ │ ├── build.yml │ ├── swiftlint.yml │ └── test.yml ├── .gitignore ├── .swift-format ├── .swiftlint.yml ├── AppIcon.icns ├── Bundler.toml ├── Contributing.md ├── LICENSE ├── Notes/ │ ├── Caching.md │ ├── ChunkPreparation.md │ ├── DebuggingDeadlocks.md │ ├── GUIRendering.md │ ├── PluginSystem.md │ ├── Readme.md │ └── RenderPipeline.md ├── Package.resolved ├── Package.swift ├── Readme.md ├── Roadmap.md ├── Security.md ├── Sources/ │ ├── Client/ │ │ ├── CommandLineArguments.swift │ │ ├── Components/ │ │ │ ├── AddressField.swift │ │ │ ├── ButtonStyles/ │ │ │ │ ├── DisabledButtonStyle.swift │ │ │ │ ├── PrimaryButtonStyle.swift │ │ │ │ └── SecondaryButtonStyle.swift │ │ │ ├── EditableList/ │ │ │ │ ├── EditableList.swift │ │ │ │ └── EditorView.swift │ │ │ ├── EmailField.swift │ │ │ ├── IconButton.swift │ │ │ ├── LegacyFormattedTextView.swift │ │ │ ├── OptionalNumberField.swift │ │ │ ├── PingIndicator.swift │ │ │ └── PixellatedBorder.swift │ │ ├── Config/ │ │ │ ├── Config.swift │ │ │ ├── ConfigError.swift │ │ │ └── ManagedConfig.swift │ │ ├── DeltaClientApp.swift │ │ ├── Discord/ │ │ │ ├── DiscordManager.swift │ │ │ └── DiscordPresenceState.swift │ │ ├── Extensions/ │ │ │ ├── Binding+onChange.swift │ │ │ ├── Box+ObservableObject.swift │ │ │ ├── TaskProgress+ObservableObject.swift │ │ │ └── View.swift │ │ ├── GitHub/ │ │ │ ├── GitHubBranch.swift │ │ │ ├── GitHubCommit.swift │ │ │ ├── GitHubComparison.swift │ │ │ └── GitHubReleasesAPIResponse.swift │ │ ├── Input/ │ │ │ ├── Controller.swift │ │ │ ├── ControllerHub.swift │ │ │ └── InputMethod.swift │ │ ├── Logger.swift │ │ ├── Modal.swift │ │ ├── State/ │ │ │ ├── AppState.swift │ │ │ └── StateWrapper.swift │ │ ├── StorageDirectory.swift │ │ ├── Utility/ │ │ │ ├── Clipboard.swift │ │ │ ├── Updater.swift │ │ │ └── Utils.swift │ │ ├── Views/ │ │ │ ├── Play/ │ │ │ │ ├── DirectConnectView.swift │ │ │ │ ├── GameView.swift │ │ │ │ ├── InGameMenu.swift │ │ │ │ ├── InputView.swift │ │ │ │ ├── JoinServerAndThen.swift │ │ │ │ ├── MetalView.swift │ │ │ │ ├── PlayView.swift │ │ │ │ ├── SelectAccountAndThen.swift │ │ │ │ ├── SelectInputMethodAndThen.swift │ │ │ │ ├── SelectOption.swift │ │ │ │ ├── WithController.swift │ │ │ │ ├── WithRenderCoordinator.swift │ │ │ │ └── WithSelectedAccount.swift │ │ │ ├── RouterView.swift │ │ │ ├── ServerList/ │ │ │ │ ├── LANServerList.swift │ │ │ │ ├── ServerDetail.swift │ │ │ │ ├── ServerListItem.swift │ │ │ │ └── ServerListView.swift │ │ │ ├── Settings/ │ │ │ │ ├── Account/ │ │ │ │ │ ├── AccountLoginView.swift │ │ │ │ │ ├── AccountSettingsView.swift │ │ │ │ │ ├── MicrosoftLoginView.swift │ │ │ │ │ ├── MojangLoginView.swift │ │ │ │ │ └── OfflineLoginView.swift │ │ │ │ ├── ControlsSettingsView.swift │ │ │ │ ├── KeymapEditorView.swift │ │ │ │ ├── PluginSettingsView.swift │ │ │ │ ├── Server/ │ │ │ │ │ ├── EditServerListView.swift │ │ │ │ │ └── ServerEditorView.swift │ │ │ │ ├── SettingsView.swift │ │ │ │ ├── TroubleShootingView.swift │ │ │ │ ├── UpdateView.swift │ │ │ │ └── VideoSettingsView.swift │ │ │ └── Startup/ │ │ │ ├── LoadAndThen.swift │ │ │ ├── ProgressLoadingView.swift │ │ │ └── StartupStep.swift │ │ └── main.swift │ ├── ClientGtk/ │ │ ├── ChatView.swift │ │ ├── DeltaClientApp.swift │ │ ├── GameView.swift │ │ ├── ServerListView.swift │ │ ├── Settings/ │ │ │ ├── AccountInspectionView.swift │ │ │ ├── AccountListView.swift │ │ │ ├── MicrosoftLoginView.swift │ │ │ ├── OfflineLoginView.swift │ │ │ └── SettingsView.swift │ │ └── Storage/ │ │ ├── Config.swift │ │ ├── ConfigError.swift │ │ ├── ConfigManager.swift │ │ └── StorageManager.swift │ ├── Core/ │ │ ├── Logger/ │ │ │ └── Logger.swift │ │ ├── Package.resolved │ │ ├── Package.swift │ │ ├── Renderer/ │ │ │ ├── Camera/ │ │ │ │ ├── Camera.swift │ │ │ │ └── Frustum.swift │ │ │ ├── CameraUniforms.swift │ │ │ ├── CaptureState.swift │ │ │ ├── CelestialBodyUniforms.swift │ │ │ ├── ChunkUniforms.swift │ │ │ ├── EndSkyUniforms.swift │ │ │ ├── EndSkyVertex.swift │ │ │ ├── Entity/ │ │ │ │ ├── EntityRenderer.swift │ │ │ │ └── EntityVertex.swift │ │ │ ├── EntityUniforms.swift │ │ │ ├── FogUniforms.swift │ │ │ ├── GUI/ │ │ │ │ ├── GUIContext.swift │ │ │ │ ├── GUIElementMesh.swift │ │ │ │ ├── GUIElementMeshArray.swift │ │ │ │ ├── GUIElementUniforms.swift │ │ │ │ ├── GUIQuad.swift │ │ │ │ ├── GUIRenderer.swift │ │ │ │ ├── GUIRendererError.swift │ │ │ │ ├── GUIUniforms.swift │ │ │ │ ├── GUIVertex.swift │ │ │ │ ├── GUIVertexStorage.swift │ │ │ │ ├── TextMeshBuilder.swift │ │ │ │ └── TextMeshBuilderError.swift │ │ │ ├── Logger.swift │ │ │ ├── Mesh/ │ │ │ │ ├── BlockMeshBuilder.swift │ │ │ │ ├── BlockNeighbour.swift │ │ │ │ ├── ChunkSectionMesh.swift │ │ │ │ ├── ChunkSectionMeshBuilder.swift │ │ │ │ ├── CubeGeometry.swift │ │ │ │ ├── EntityMeshBuilder.swift │ │ │ │ ├── FluidMeshBuilder.swift │ │ │ │ ├── Geometry.swift │ │ │ │ ├── Mesh.swift │ │ │ │ ├── SortableMesh.swift │ │ │ │ └── SortableMeshElement.swift │ │ │ ├── RenderCoordinator.swift │ │ │ ├── RenderError.swift │ │ │ ├── Renderer.swift │ │ │ ├── RenderingMeasurement.swift │ │ │ ├── Resources/ │ │ │ │ ├── Font+Metal.swift │ │ │ │ └── MetalTexturePalette.swift │ │ │ ├── ScreenRenderer.swift │ │ │ ├── Shader/ │ │ │ │ ├── ChunkOITShaders.metal │ │ │ │ ├── ChunkShaders.metal │ │ │ │ ├── ChunkTypes.metal │ │ │ │ ├── EntityShaders.metal │ │ │ │ ├── GUIShaders.metal │ │ │ │ ├── GUITypes.metal │ │ │ │ ├── ScreenShaders.metal │ │ │ │ └── SkyShaders.metal │ │ │ ├── SkyBoxRenderer.swift │ │ │ ├── SkyPlaneUniforms.swift │ │ │ ├── StarUniforms.swift │ │ │ ├── SunriseDiscUniforms.swift │ │ │ ├── Util/ │ │ │ │ └── MetalUtil.swift │ │ │ └── World/ │ │ │ ├── BlockVertex.swift │ │ │ ├── LightMap.swift │ │ │ ├── Visibility/ │ │ │ │ ├── ChunkSectionFace.swift │ │ │ │ ├── ChunkSectionFaceConnectivity.swift │ │ │ │ ├── ChunkSectionVoxelGraph.swift │ │ │ │ ├── VisibilityGraph+SearchQueueEntry.swift │ │ │ │ └── VisibilityGraph.swift │ │ │ ├── WorldMesh.swift │ │ │ ├── WorldMeshWorker+Job.swift │ │ │ ├── WorldMeshWorker.swift │ │ │ └── WorldRenderer.swift │ │ ├── Sources/ │ │ │ ├── Account/ │ │ │ │ ├── Account.swift │ │ │ │ ├── Microsoft/ │ │ │ │ │ ├── MicrosoftAPI.swift │ │ │ │ │ ├── MicrosoftAccessToken.swift │ │ │ │ │ ├── MicrosoftAccount.swift │ │ │ │ │ ├── Request/ │ │ │ │ │ │ ├── MinecraftXboxAuthenticationRequest.swift │ │ │ │ │ │ ├── XSTSAuthenticationRequest.swift │ │ │ │ │ │ └── XboxLiveAuthenticationRequest.swift │ │ │ │ │ ├── Response/ │ │ │ │ │ │ ├── GameOwnershipResponse.swift │ │ │ │ │ │ ├── MicrosoftAccessTokenResponse.swift │ │ │ │ │ │ ├── MicrosoftDeviceAuthorizationResponse.swift │ │ │ │ │ │ ├── MicrosoftMinecraftProfileResponse.swift │ │ │ │ │ │ ├── MinecraftXboxAuthenticationResponse.swift │ │ │ │ │ │ ├── XSTSAuthenticationError.swift │ │ │ │ │ │ ├── XSTSAuthenticationResponse.swift │ │ │ │ │ │ └── XboxLiveAuthenticationResponse.swift │ │ │ │ │ └── XboxLiveToken.swift │ │ │ │ ├── MinecraftAccessToken.swift │ │ │ │ ├── Mojang/ │ │ │ │ │ ├── MojangAPI.swift │ │ │ │ │ ├── MojangAccount.swift │ │ │ │ │ ├── Request/ │ │ │ │ │ │ ├── MojangAuthenticationRequest.swift │ │ │ │ │ │ ├── MojangJoinRequest.swift │ │ │ │ │ │ └── MojangRefreshTokenRequest.swift │ │ │ │ │ └── Response/ │ │ │ │ │ ├── MojangAuthenticationResponse.swift │ │ │ │ │ └── MojangRefreshTokenResponse.swift │ │ │ │ ├── OfflineAccount.swift │ │ │ │ └── OnlineAccount.swift │ │ │ ├── Cache/ │ │ │ │ ├── BinaryCacheable.swift │ │ │ │ ├── BinarySerialization.swift │ │ │ │ ├── BlockModelPalette+BinaryCacheable.swift │ │ │ │ ├── Cacheable.swift │ │ │ │ ├── FontPalette+BinaryCacheable.swift │ │ │ │ ├── ItemModelPalette+BinaryCacheable.swift │ │ │ │ ├── Registry/ │ │ │ │ │ ├── BiomeRegistry+JSONCacheable.swift │ │ │ │ │ ├── BlockRegistry+BinaryCacheable.swift │ │ │ │ │ ├── EntityRegistry+JSONCacheable.swift │ │ │ │ │ ├── FluidRegistry+JSONCacheable.swift │ │ │ │ │ ├── ItemRegistry+JSONCacheable.swift │ │ │ │ │ └── JSONCacheable.swift │ │ │ │ └── TexturePalette+BinaryCacheable.swift │ │ │ ├── Chat/ │ │ │ │ ├── Chat.swift │ │ │ │ ├── ChatComponent/ │ │ │ │ │ ├── ChatComponent.swift │ │ │ │ │ ├── ChatComponentColor.swift │ │ │ │ │ ├── ChatComponentContent.swift │ │ │ │ │ ├── ChatComponentError.swift │ │ │ │ │ ├── ChatComponentLocalizedContent.swift │ │ │ │ │ ├── ChatComponentScoreContent.swift │ │ │ │ │ └── ChatComponentStyle.swift │ │ │ │ ├── ChatMessage.swift │ │ │ │ └── LegacyFormattedText/ │ │ │ │ ├── LegacyFormattedText.swift │ │ │ │ ├── LegacyFormattedTextColor.swift │ │ │ │ ├── LegacyFormattedTextError.swift │ │ │ │ ├── LegacyFormattedTextFormattingCode.swift │ │ │ │ ├── LegacyFormattedTextStyle.swift │ │ │ │ └── LegacyFormattedTextToken.swift │ │ │ ├── Client.swift │ │ │ ├── ClientConfiguration.swift │ │ │ ├── Constants.swift │ │ │ ├── Datatypes/ │ │ │ │ ├── Axis.swift │ │ │ │ ├── BlockPosition.swift │ │ │ │ ├── CardinalDirection.swift │ │ │ │ ├── Difficulty.swift │ │ │ │ ├── Direction.swift │ │ │ │ ├── DirectionSet.swift │ │ │ │ ├── DominantHand.swift │ │ │ │ ├── Equipment.swift │ │ │ │ ├── Gamemode.swift │ │ │ │ ├── Hand.swift │ │ │ │ ├── Identifier.swift │ │ │ │ ├── IdentifierError.swift │ │ │ │ ├── ItemStack.swift │ │ │ │ ├── NBT/ │ │ │ │ │ ├── NBT.swift │ │ │ │ │ ├── NBTCompound.swift │ │ │ │ │ ├── NBTList.swift │ │ │ │ │ ├── NBTTag.swift │ │ │ │ │ └── NBTTagType.swift │ │ │ │ ├── PlayerEntityAction.swift │ │ │ │ ├── PlayerFlags.swift │ │ │ │ ├── Slot.swift │ │ │ │ ├── Statistic.swift │ │ │ │ └── UUID.swift │ │ │ ├── Duration.swift │ │ │ ├── ECS/ │ │ │ │ ├── BlockEntity.swift │ │ │ │ ├── Components/ │ │ │ │ │ ├── EnderDragonParts.swift │ │ │ │ │ ├── EntityAcceleration.swift │ │ │ │ │ ├── EntityAttributes.swift │ │ │ │ │ ├── EntityCamera.swift │ │ │ │ │ ├── EntityExperience.swift │ │ │ │ │ ├── EntityFlying.swift │ │ │ │ │ ├── EntityHeadYaw.swift │ │ │ │ │ ├── EntityHealth.swift │ │ │ │ │ ├── EntityHitBox.swift │ │ │ │ │ ├── EntityId.swift │ │ │ │ │ ├── EntityKindId.swift │ │ │ │ │ ├── EntityLerpState.swift │ │ │ │ │ ├── EntityMetadata.swift │ │ │ │ │ ├── EntityNutrition.swift │ │ │ │ │ ├── EntityOnGround.swift │ │ │ │ │ ├── EntityPosition.swift │ │ │ │ │ ├── EntityRotation.swift │ │ │ │ │ ├── EntitySneaking.swift │ │ │ │ │ ├── EntitySprinting.swift │ │ │ │ │ ├── EntityUUID.swift │ │ │ │ │ ├── EntityVelocity.swift │ │ │ │ │ ├── Marker/ │ │ │ │ │ │ ├── ClientPlayerEntity.swift │ │ │ │ │ │ ├── LivingEntity.swift │ │ │ │ │ │ ├── NonLivingEntity.swift │ │ │ │ │ │ └── PlayerEntity.swift │ │ │ │ │ ├── ObjectData.swift │ │ │ │ │ ├── ObjectUUID.swift │ │ │ │ │ ├── PlayerAttributes.swift │ │ │ │ │ ├── PlayerCollisionState.swift │ │ │ │ │ ├── PlayerFOV.swift │ │ │ │ │ ├── PlayerGamemode.swift │ │ │ │ │ └── PlayerInventory.swift │ │ │ │ ├── Singles/ │ │ │ │ │ ├── ClientboundEntityPacketStore.swift │ │ │ │ │ ├── GUIStateStorage.swift │ │ │ │ │ └── InputState.swift │ │ │ │ └── Systems/ │ │ │ │ ├── EntityMovementSystem.swift │ │ │ │ ├── EntitySmoothingSystem.swift │ │ │ │ ├── PacketHandlingSystem.swift │ │ │ │ ├── PlayerAccelerationSystem.swift │ │ │ │ ├── PlayerBlockBreakingSystem.swift │ │ │ │ ├── PlayerClimbSystem.swift │ │ │ │ ├── PlayerCollisionSystem.swift │ │ │ │ ├── PlayerFOVSystem.swift │ │ │ │ ├── PlayerFlightSystem.swift │ │ │ │ ├── PlayerFrictionSystem.swift │ │ │ │ ├── PlayerGravitySystem.swift │ │ │ │ ├── PlayerInputSystem.swift │ │ │ │ ├── PlayerJumpSystem.swift │ │ │ │ ├── PlayerPacketSystem.swift │ │ │ │ ├── PlayerPositionSystem.swift │ │ │ │ ├── PlayerSmoothingSystem.swift │ │ │ │ ├── PlayerVelocitySystem.swift │ │ │ │ └── System.swift │ │ │ ├── FileSystem.swift │ │ │ ├── GUI/ │ │ │ │ ├── BossBar.swift │ │ │ │ ├── Constraints.swift │ │ │ │ ├── GUIBuilder.swift │ │ │ │ ├── GUIElement.swift │ │ │ │ ├── GUISprite.swift │ │ │ │ ├── GUISpriteDescriptor.swift │ │ │ │ ├── HorizontalConstraint.swift │ │ │ │ ├── HorizontalOffset.swift │ │ │ │ ├── InGameGUI.swift │ │ │ │ ├── RenderStatistics.swift │ │ │ │ ├── VerticalConstraint.swift │ │ │ │ ├── VerticalOffset.swift │ │ │ │ ├── Window.swift │ │ │ │ ├── WindowArea.swift │ │ │ │ └── WindowType.swift │ │ │ ├── GUIState.swift │ │ │ ├── Game.swift │ │ │ ├── Input/ │ │ │ │ ├── Input.swift │ │ │ │ ├── Key.swift │ │ │ │ ├── Keymap.swift │ │ │ │ └── ModifierKey.swift │ │ │ ├── Logger.swift │ │ │ ├── Network/ │ │ │ │ ├── Cipher.swift │ │ │ │ ├── ConnectionState.swift │ │ │ │ ├── Endianness.swift │ │ │ │ ├── LANServerEnumerator.swift │ │ │ │ ├── Protocol/ │ │ │ │ │ ├── Buffer.swift │ │ │ │ │ ├── BufferError.swift │ │ │ │ │ ├── PacketRegistry.swift │ │ │ │ │ ├── PacketState.swift │ │ │ │ │ ├── Packets/ │ │ │ │ │ │ ├── ClientboundEntityPacket.swift │ │ │ │ │ │ ├── ClientboundPacket.swift │ │ │ │ │ │ ├── Handshaking/ │ │ │ │ │ │ │ └── Serverbound/ │ │ │ │ │ │ │ └── HandshakePacket.swift │ │ │ │ │ │ ├── Login/ │ │ │ │ │ │ │ ├── Clientbound/ │ │ │ │ │ │ │ │ ├── EncryptionRequestPacket.swift │ │ │ │ │ │ │ │ ├── LoginDisconnectPacket.swift │ │ │ │ │ │ │ │ ├── LoginPluginRequestPacket.swift │ │ │ │ │ │ │ │ ├── LoginSuccessPacket.swift │ │ │ │ │ │ │ │ └── SetCompressionPacket.swift │ │ │ │ │ │ │ └── Serverbound/ │ │ │ │ │ │ │ ├── EncryptionResponsePacket.swift │ │ │ │ │ │ │ ├── LoginPluginResponsePacket.swift │ │ │ │ │ │ │ └── LoginStartPacket.swift │ │ │ │ │ │ ├── PacketReader.swift │ │ │ │ │ │ ├── PacketReaderError.swift │ │ │ │ │ │ ├── PacketWriter.swift │ │ │ │ │ │ ├── Play/ │ │ │ │ │ │ │ ├── Clientbound/ │ │ │ │ │ │ │ │ ├── AcknowledgePlayerDiggingPacket.swift │ │ │ │ │ │ │ │ ├── AdvancementsPacket.swift │ │ │ │ │ │ │ │ ├── AttachEntityPacket.swift │ │ │ │ │ │ │ │ ├── BlockActionPacket.swift │ │ │ │ │ │ │ │ ├── BlockBreakAnimationPacket.swift │ │ │ │ │ │ │ │ ├── BlockChangePacket.swift │ │ │ │ │ │ │ │ ├── BlockEntityDataPacket.swift │ │ │ │ │ │ │ │ ├── BossBarPacket.swift │ │ │ │ │ │ │ │ ├── CameraPacket.swift │ │ │ │ │ │ │ │ ├── ChangeGameStatePacket.swift │ │ │ │ │ │ │ │ ├── ChatMessageClientboundPacket.swift │ │ │ │ │ │ │ │ ├── ChunkDataPacket.swift │ │ │ │ │ │ │ │ ├── CloseWindowClientboundPacket.swift │ │ │ │ │ │ │ │ ├── CollectItemPacket.swift │ │ │ │ │ │ │ │ ├── CombatEventPacket.swift │ │ │ │ │ │ │ │ ├── CraftRecipeResponsePacket.swift │ │ │ │ │ │ │ │ ├── DeclareCommandsPacket.swift │ │ │ │ │ │ │ │ ├── DeclareRecipesPacket.swift │ │ │ │ │ │ │ │ ├── DestroyEntitiesPacket.swift │ │ │ │ │ │ │ │ ├── DisplayScoreboardPacket.swift │ │ │ │ │ │ │ │ ├── EffectPacket.swift │ │ │ │ │ │ │ │ ├── EntityAnimationPacket.swift │ │ │ │ │ │ │ │ ├── EntityAttributesPacket.swift │ │ │ │ │ │ │ │ ├── EntityEffectPacket.swift │ │ │ │ │ │ │ │ ├── EntityEquipmentPacket.swift │ │ │ │ │ │ │ │ ├── EntityHeadLookPacket.swift │ │ │ │ │ │ │ │ ├── EntityMetadataPacket.swift │ │ │ │ │ │ │ │ ├── EntityMovementPacket.swift │ │ │ │ │ │ │ │ ├── EntityPositionAndRotationPacket.swift │ │ │ │ │ │ │ │ ├── EntityPositionPacket.swift │ │ │ │ │ │ │ │ ├── EntityRotationPacket.swift │ │ │ │ │ │ │ │ ├── EntitySoundEffectPacket.swift │ │ │ │ │ │ │ │ ├── EntityStatusPacket.swift │ │ │ │ │ │ │ │ ├── EntityTeleportPacket.swift │ │ │ │ │ │ │ │ ├── EntityVelocityPacket.swift │ │ │ │ │ │ │ │ ├── ExplosionPacket.swift │ │ │ │ │ │ │ │ ├── FacePlayerPacket.swift │ │ │ │ │ │ │ │ ├── HeldItemChangePacket.swift │ │ │ │ │ │ │ │ ├── JoinGamePacket.swift │ │ │ │ │ │ │ │ ├── KeepAliveClientboundPacket.swift │ │ │ │ │ │ │ │ ├── MapDataPacket.swift │ │ │ │ │ │ │ │ ├── MultiBlockUpdatePacket.swift │ │ │ │ │ │ │ │ ├── NBTQueryResponsePacket.swift │ │ │ │ │ │ │ │ ├── NamedSoundEffectPacket.swift │ │ │ │ │ │ │ │ ├── OpenBookPacket.swift │ │ │ │ │ │ │ │ ├── OpenHorseWindowPacket.swift │ │ │ │ │ │ │ │ ├── OpenSignEditorPacket.swift │ │ │ │ │ │ │ │ ├── OpenWindowPacket.swift │ │ │ │ │ │ │ │ ├── ParticlePacket.swift │ │ │ │ │ │ │ │ ├── PlayDisconnectPacket.swift │ │ │ │ │ │ │ │ ├── PlayerAbilitiesPacket.swift │ │ │ │ │ │ │ │ ├── PlayerInfoPacket.swift │ │ │ │ │ │ │ │ ├── PlayerListHeaderAndFooterPacket.swift │ │ │ │ │ │ │ │ ├── PlayerPositionAndLookClientboundPacket.swift │ │ │ │ │ │ │ │ ├── PluginMessagePacket.swift │ │ │ │ │ │ │ │ ├── RemoveEntityEffectPacket.swift │ │ │ │ │ │ │ │ ├── ResourcePackSendPacket.swift │ │ │ │ │ │ │ │ ├── RespawnPacket.swift │ │ │ │ │ │ │ │ ├── ScoreboardObjectivePacket.swift │ │ │ │ │ │ │ │ ├── SelectAdvancementTabPacket.swift │ │ │ │ │ │ │ │ ├── ServerDifficultyPacket.swift │ │ │ │ │ │ │ │ ├── SetCooldownPacket.swift │ │ │ │ │ │ │ │ ├── SetExperiencePacket.swift │ │ │ │ │ │ │ │ ├── SetPassengersPacket.swift │ │ │ │ │ │ │ │ ├── SetSlotPacket.swift │ │ │ │ │ │ │ │ ├── SoundEffectPacket.swift │ │ │ │ │ │ │ │ ├── SpawnEntityPacket.swift │ │ │ │ │ │ │ │ ├── SpawnExperienceOrbPacket.swift │ │ │ │ │ │ │ │ ├── SpawnLivingEntityPacket.swift │ │ │ │ │ │ │ │ ├── SpawnPaintingPacket.swift │ │ │ │ │ │ │ │ ├── SpawnPlayerPacket.swift │ │ │ │ │ │ │ │ ├── SpawnPositionPacket.swift │ │ │ │ │ │ │ │ ├── StatisticsPacket.swift │ │ │ │ │ │ │ │ ├── StopSoundPacket.swift │ │ │ │ │ │ │ │ ├── TabCompleteClientboundPacket.swift │ │ │ │ │ │ │ │ ├── TagsPacket.swift │ │ │ │ │ │ │ │ ├── TeamsPacket.swift │ │ │ │ │ │ │ │ ├── TimeUpdatePacket.swift │ │ │ │ │ │ │ │ ├── TitlePacket.swift │ │ │ │ │ │ │ │ ├── TradeListPacket.swift │ │ │ │ │ │ │ │ ├── UnloadChunkPacket.swift │ │ │ │ │ │ │ │ ├── UnlockRecipesPacket.swift │ │ │ │ │ │ │ │ ├── UpdateHealthPacket.swift │ │ │ │ │ │ │ │ ├── UpdateLightPacket.swift │ │ │ │ │ │ │ │ ├── UpdateScorePacket.swift │ │ │ │ │ │ │ │ ├── UpdateViewDistancePacket.swift │ │ │ │ │ │ │ │ ├── UpdateViewPositionPacket.swift │ │ │ │ │ │ │ │ ├── VehicleMoveClientboundPacket.swift │ │ │ │ │ │ │ │ ├── WindowConfirmationClientboundPacket.swift │ │ │ │ │ │ │ │ ├── WindowItemsPacket.swift │ │ │ │ │ │ │ │ ├── WindowPropertyPacket.swift │ │ │ │ │ │ │ │ └── WorldBorderPacket.swift │ │ │ │ │ │ │ └── Serverbound/ │ │ │ │ │ │ │ ├── AdvancementTabPacket.swift │ │ │ │ │ │ │ ├── AnimationServerboundPacket.swift │ │ │ │ │ │ │ ├── ChatMessageServerboundPacket.swift │ │ │ │ │ │ │ ├── ClickWindowButtonPacket.swift │ │ │ │ │ │ │ ├── ClickWindowPacket.swift │ │ │ │ │ │ │ ├── ClientSettingsPacket.swift │ │ │ │ │ │ │ ├── ClientStatusPacket.swift │ │ │ │ │ │ │ ├── CloseWindowServerboundPacket.swift │ │ │ │ │ │ │ ├── CraftRecipeRequestPacket.swift │ │ │ │ │ │ │ ├── CreativeInventoryActionPacket.swift │ │ │ │ │ │ │ ├── EditBookPacket.swift │ │ │ │ │ │ │ ├── EntityActionPacket.swift │ │ │ │ │ │ │ ├── GenerateStructurePacket.swift │ │ │ │ │ │ │ ├── HeldItemChangeServerboundPacket.swift │ │ │ │ │ │ │ ├── InteractEntityPacket.swift │ │ │ │ │ │ │ ├── KeepAliveServerboundPacket.swift │ │ │ │ │ │ │ ├── LockDifficultyPacket.swift │ │ │ │ │ │ │ ├── NameItemPacket.swift │ │ │ │ │ │ │ ├── PickItemPacket.swift │ │ │ │ │ │ │ ├── PlayerAbilitiesServerboundPacket.swift │ │ │ │ │ │ │ ├── PlayerBlockPlacementPacket.swift │ │ │ │ │ │ │ ├── PlayerDiggingPacket.swift │ │ │ │ │ │ │ ├── PlayerMovementPacket.swift │ │ │ │ │ │ │ ├── PlayerPositionAndRotationServerboundPacket.swift │ │ │ │ │ │ │ ├── PlayerPositionPacket.swift │ │ │ │ │ │ │ ├── PlayerRotationPacket.swift │ │ │ │ │ │ │ ├── PluginMessageServerboundPacket.swift │ │ │ │ │ │ │ ├── QueryBlockNBTPacket.swift │ │ │ │ │ │ │ ├── QueryEntityNBTPacket.swift │ │ │ │ │ │ │ ├── RecipeBookDataPacket.swift │ │ │ │ │ │ │ ├── ResourcePackStatusPacket.swift │ │ │ │ │ │ │ ├── SelectTradePacket.swift │ │ │ │ │ │ │ ├── SetBeaconEffectPacket.swift │ │ │ │ │ │ │ ├── SetDifficultyPacket.swift │ │ │ │ │ │ │ ├── SpectatePacket.swift │ │ │ │ │ │ │ ├── SteerBoatPacket.swift │ │ │ │ │ │ │ ├── SteerVehiclePacket.swift │ │ │ │ │ │ │ ├── TabCompleteServerboundPacket.swift │ │ │ │ │ │ │ ├── TeleportConfirmPacket.swift │ │ │ │ │ │ │ ├── UpdateCommandBlockMinecartPacket.swift │ │ │ │ │ │ │ ├── UpdateCommandBlockPacket.swift │ │ │ │ │ │ │ ├── UpdateJigsawBlockPacket.swift │ │ │ │ │ │ │ ├── UpdateSignPacket.swift │ │ │ │ │ │ │ ├── UpdateStructureBlockPacket.swift │ │ │ │ │ │ │ ├── UseItemPacket.swift │ │ │ │ │ │ │ ├── VehicleMoveServerboundPacket.swift │ │ │ │ │ │ │ └── WindowConfirmationServerboundPacket.swift │ │ │ │ │ │ ├── ServerboundPacket.swift │ │ │ │ │ │ └── Status/ │ │ │ │ │ │ ├── Clientbound/ │ │ │ │ │ │ │ ├── PongPacket.swift │ │ │ │ │ │ │ └── StatusResponsePacket.swift │ │ │ │ │ │ └── Serverbound/ │ │ │ │ │ │ ├── PingPacket.swift │ │ │ │ │ │ └── StatusRequestPacket.swift │ │ │ │ │ └── ProtocolVersion.swift │ │ │ │ ├── ServerConnection.swift │ │ │ │ ├── Socket+Darwin.swift │ │ │ │ ├── Socket+Glibc.swift │ │ │ │ ├── Socket.swift │ │ │ │ ├── SocketError.swift │ │ │ │ ├── SocketOption.swift │ │ │ │ └── Stack/ │ │ │ │ ├── Layers/ │ │ │ │ │ ├── CompressionLayer.swift │ │ │ │ │ ├── EncryptionLayer.swift │ │ │ │ │ ├── PacketLayer.swift │ │ │ │ │ └── SocketLayer.swift │ │ │ │ └── NetworkStack.swift │ │ │ ├── Physics/ │ │ │ │ ├── AxisAlignedBoundingBox.swift │ │ │ │ ├── CompoundBoundingBox.swift │ │ │ │ ├── PhysicsConstants.swift │ │ │ │ ├── Ray.swift │ │ │ │ └── VoxelRay.swift │ │ │ ├── Player/ │ │ │ │ ├── Player.swift │ │ │ │ ├── PlayerInfo.swift │ │ │ │ └── PlayerProperty.swift │ │ │ ├── Plugin/ │ │ │ │ ├── Event/ │ │ │ │ │ ├── CaptureCursorEvent.swift │ │ │ │ │ ├── ChatMessageReceivedEvent.swift │ │ │ │ │ ├── Connection/ │ │ │ │ │ │ ├── ConnectionFailedEvent.swift │ │ │ │ │ │ ├── ConnectionReadyEvent.swift │ │ │ │ │ │ ├── LoginDisconnectEvent.swift │ │ │ │ │ │ ├── LoginStartEvent.swift │ │ │ │ │ │ ├── LoginSuccessEvent.swift │ │ │ │ │ │ ├── PacketDecodingErrorEvent.swift │ │ │ │ │ │ ├── PacketHandlingErrorEvent.swift │ │ │ │ │ │ └── PlayDisconnectEvent.swift │ │ │ │ │ ├── ErrorEvent.swift │ │ │ │ │ ├── Event.swift │ │ │ │ │ ├── EventBus.swift │ │ │ │ │ ├── Input/ │ │ │ │ │ │ ├── KeyPressEvent.swift │ │ │ │ │ │ ├── KeyReleaseEvent.swift │ │ │ │ │ │ ├── OpenInGameMenuEvent.swift │ │ │ │ │ │ └── ReleaseCursorEvent.swift │ │ │ │ │ ├── Render/ │ │ │ │ │ │ └── FinishFrameCaptureEvent.swift │ │ │ │ │ └── World/ │ │ │ │ │ ├── AddChunk.swift │ │ │ │ │ ├── JoinWorldEvent.swift │ │ │ │ │ ├── MultiBlockUpdate.swift │ │ │ │ │ ├── RemoveChunk.swift │ │ │ │ │ ├── SingleBlockUpdate.swift │ │ │ │ │ ├── TerrainDownloadCompletionEvent.swift │ │ │ │ │ ├── TimeUpdate.swift │ │ │ │ │ ├── UpdateChunk.swift │ │ │ │ │ ├── UpdateChunkLighting.swift │ │ │ │ │ └── WorldEvent.swift │ │ │ │ ├── Plugin.swift │ │ │ │ ├── PluginBuilder.swift │ │ │ │ ├── PluginEnvironment.swift │ │ │ │ ├── PluginLoadingError.swift │ │ │ │ └── PluginManifest.swift │ │ │ ├── Recipe/ │ │ │ │ ├── BlastingRecipe.swift │ │ │ │ ├── CampfireCookingRecipe.swift │ │ │ │ ├── CraftingRecipe.swift │ │ │ │ ├── CraftingShaped.swift │ │ │ │ ├── CraftingShapeless.swift │ │ │ │ ├── HeatRecipe.swift │ │ │ │ ├── Ingredient.swift │ │ │ │ ├── RecipeItem.swift │ │ │ │ ├── RecipeRegistry.swift │ │ │ │ ├── SmeltingRecipe.swift │ │ │ │ ├── SmithingRecipe.swift │ │ │ │ ├── SmokingRecipe.swift │ │ │ │ ├── SpecialCrafting/ │ │ │ │ │ ├── ArmorDyeRecipe.swift │ │ │ │ │ ├── BannerAddPatternRecipe.swift │ │ │ │ │ ├── BannerDuplicateRecipe.swift │ │ │ │ │ ├── BookCloningRecipe.swift │ │ │ │ │ ├── FireworkRocketRecipe.swift │ │ │ │ │ ├── FireworkStarFadeRecipe.swift │ │ │ │ │ ├── FireworkStarRecipe.swift │ │ │ │ │ ├── MapCloningRecipe.swift │ │ │ │ │ ├── MapExtendingRecipe.swift │ │ │ │ │ ├── RepairItemRecipe.swift │ │ │ │ │ ├── ShieldDecorationRecipe.swift │ │ │ │ │ ├── ShulkerBoxColouringRecipe.swift │ │ │ │ │ ├── SpecialRecipe.swift │ │ │ │ │ ├── SuspiciousStewRecipe.swift │ │ │ │ │ └── TippedArrowRecipe.swift │ │ │ │ └── StonecuttingRecipe.swift │ │ │ ├── Registry/ │ │ │ │ ├── Biome/ │ │ │ │ │ ├── Biome.swift │ │ │ │ │ ├── BiomeCategory.swift │ │ │ │ │ ├── BiomeCriteria.swift │ │ │ │ │ ├── BiomeModifiers.swift │ │ │ │ │ └── BiomePrecipitationType.swift │ │ │ │ ├── BiomeRegistry.swift │ │ │ │ ├── Block/ │ │ │ │ │ ├── Block.swift │ │ │ │ │ ├── BlockLightMaterial.swift │ │ │ │ │ ├── BlockOffset.swift │ │ │ │ │ ├── BlockPhysicalMaterial.swift │ │ │ │ │ ├── BlockShape.swift │ │ │ │ │ ├── BlockSoundMaterial.swift │ │ │ │ │ ├── BlockStateProperties.swift │ │ │ │ │ └── BlockTint.swift │ │ │ │ ├── BlockRegistry.swift │ │ │ │ ├── Entity/ │ │ │ │ │ ├── EntityAttributeKey.swift │ │ │ │ │ ├── EntityAttributeModifier.swift │ │ │ │ │ ├── EntityAttributeValue.swift │ │ │ │ │ └── EntityKind.swift │ │ │ │ ├── EntityRegistry.swift │ │ │ │ ├── Fluid/ │ │ │ │ │ ├── Fluid.swift │ │ │ │ │ └── FluidState.swift │ │ │ │ ├── FluidRegistry.swift │ │ │ │ ├── Item/ │ │ │ │ │ ├── Item.swift │ │ │ │ │ └── ItemRarity.swift │ │ │ │ ├── ItemRegistry.swift │ │ │ │ ├── Pixlyzer/ │ │ │ │ │ ├── PixlyzerAABB.swift │ │ │ │ │ ├── PixlyzerBiome.swift │ │ │ │ │ ├── PixlyzerBlock.swift │ │ │ │ │ ├── PixlyzerBlockModelDescriptor.swift │ │ │ │ │ ├── PixlyzerBlockState.swift │ │ │ │ │ ├── PixlyzerEntity.swift │ │ │ │ │ ├── PixlyzerFluid.swift │ │ │ │ │ ├── PixlyzerFormatter.swift │ │ │ │ │ ├── PixlyzerItem.swift │ │ │ │ │ ├── PixlyzerShapeRegistry.swift │ │ │ │ │ └── SingleOrMultiple.swift │ │ │ │ └── RegistryStore.swift │ │ │ ├── RenderConfiguration.swift │ │ │ ├── RenderMode.swift │ │ │ ├── Resources/ │ │ │ │ ├── Biome/ │ │ │ │ │ ├── BiomeColorMap.swift │ │ │ │ │ └── BiomeColors.swift │ │ │ │ ├── Font/ │ │ │ │ │ ├── BitmapFontProvider.swift │ │ │ │ │ ├── CharacterDescriptor.swift │ │ │ │ │ ├── Font.swift │ │ │ │ │ ├── FontManifest.swift │ │ │ │ │ ├── FontPalette.swift │ │ │ │ │ ├── FontProvider.swift │ │ │ │ │ ├── LegacyUnicodeFontProvider.swift │ │ │ │ │ └── TrueTypeFontProvider.swift │ │ │ │ ├── GUI/ │ │ │ │ │ ├── GUITexturePalette.swift │ │ │ │ │ └── GUITextureSlice.swift │ │ │ │ ├── Locale/ │ │ │ │ │ ├── LocalizationFormatter.swift │ │ │ │ │ └── MinecraftLocale.swift │ │ │ │ ├── MCMeta/ │ │ │ │ │ ├── AnimationMCMeta.swift │ │ │ │ │ └── PackMCMeta.swift │ │ │ │ ├── Manifest/ │ │ │ │ │ ├── VersionManifest.swift │ │ │ │ │ └── VersionsManifest.swift │ │ │ │ ├── Model/ │ │ │ │ │ ├── Block/ │ │ │ │ │ │ ├── BlockModel.swift │ │ │ │ │ │ ├── BlockModelElement.swift │ │ │ │ │ │ ├── BlockModelFace.swift │ │ │ │ │ │ ├── BlockModelPalette.swift │ │ │ │ │ │ ├── BlockModelPaletteError.swift │ │ │ │ │ │ ├── BlockModelPart.swift │ │ │ │ │ │ ├── BlockModelRenderDescriptor.swift │ │ │ │ │ │ ├── Intermediate/ │ │ │ │ │ │ │ ├── IntermediateBlockModel.swift │ │ │ │ │ │ │ ├── IntermediateBlockModelElement.swift │ │ │ │ │ │ │ ├── IntermediateBlockModelElementRotation.swift │ │ │ │ │ │ │ ├── IntermediateBlockModelFace.swift │ │ │ │ │ │ │ └── IntermediateBlockModelPalette.swift │ │ │ │ │ │ └── JSON/ │ │ │ │ │ │ ├── JSONBlockModel.swift │ │ │ │ │ │ ├── JSONBlockModelAxis.swift │ │ │ │ │ │ ├── JSONBlockModelElement.swift │ │ │ │ │ │ ├── JSONBlockModelElementRotation.swift │ │ │ │ │ │ ├── JSONBlockModelFace.swift │ │ │ │ │ │ └── JSONBlockModelFaceName.swift │ │ │ │ │ ├── Entity/ │ │ │ │ │ │ ├── EntityModelPalette.swift │ │ │ │ │ │ └── JSON/ │ │ │ │ │ │ └── JSONEntityModel.swift │ │ │ │ │ ├── Item/ │ │ │ │ │ │ ├── ItemModel.swift │ │ │ │ │ │ ├── ItemModelPalette.swift │ │ │ │ │ │ ├── ItemModelPaletteError.swift │ │ │ │ │ │ ├── ItemModelTexture.swift │ │ │ │ │ │ └── JSON/ │ │ │ │ │ │ ├── JSONItemModel.swift │ │ │ │ │ │ ├── JSONItemModelGUILight.swift │ │ │ │ │ │ └── JSONItemModelOverride.swift │ │ │ │ │ ├── JSON/ │ │ │ │ │ │ ├── JSONModelDisplayTransforms.swift │ │ │ │ │ │ └── JSONModelTransform.swift │ │ │ │ │ └── ModelDisplayTransforms.swift │ │ │ │ ├── ResourcePack.swift │ │ │ │ ├── Resources.swift │ │ │ │ └── Texture/ │ │ │ │ ├── ColorMap.swift │ │ │ │ ├── Texture.swift │ │ │ │ ├── TextureAnimation.swift │ │ │ │ ├── TextureAnimationState.swift │ │ │ │ ├── TexturePalette.swift │ │ │ │ ├── TexturePaletteAnimationState.swift │ │ │ │ └── TextureType.swift │ │ │ ├── Server/ │ │ │ │ ├── Ping/ │ │ │ │ │ ├── PingError.swift │ │ │ │ │ ├── Pinger.swift │ │ │ │ │ └── StatusResponse.swift │ │ │ │ ├── ServerDescriptor.swift │ │ │ │ └── TabList.swift │ │ │ ├── Util/ │ │ │ │ ├── Array.swift │ │ │ │ ├── ArrayBinding.swift │ │ │ │ ├── BinaryFloatingPoint.swift │ │ │ │ ├── BinaryUtil.swift │ │ │ │ ├── Box.swift │ │ │ │ ├── Character.swift │ │ │ │ ├── ColorUtil.swift │ │ │ │ ├── CompressionUtil.swift │ │ │ │ ├── ContentType.swift │ │ │ │ ├── CryptoUtil.swift │ │ │ │ ├── CustomJSONDecoder.swift │ │ │ │ ├── Dictionary.swift │ │ │ │ ├── Either.swift │ │ │ │ ├── FileManager.swift │ │ │ │ ├── FontUtil.swift │ │ │ │ ├── FunctionalProgramming.swift │ │ │ │ ├── Image.swift │ │ │ │ ├── Int.swift │ │ │ │ ├── MathUtil.swift │ │ │ │ ├── Matrix.swift │ │ │ │ ├── MatrixUtil.swift │ │ │ │ ├── Profiler.swift │ │ │ │ ├── RGBColor.swift │ │ │ │ ├── Random.swift │ │ │ │ ├── ReadWriteLock.swift │ │ │ │ ├── Request.swift │ │ │ │ ├── RequestMethod.swift │ │ │ │ ├── RequestUtil.swift │ │ │ │ ├── RichError.swift │ │ │ │ ├── SIMD.swift │ │ │ │ ├── Stopwatch.swift │ │ │ │ ├── Task/ │ │ │ │ │ ├── TaskProgress.swift │ │ │ │ │ └── TaskStep.swift │ │ │ │ ├── ThreadUtil.swift │ │ │ │ ├── TickScheduler.swift │ │ │ │ ├── URL.swift │ │ │ │ └── Vector.swift │ │ │ └── World/ │ │ │ ├── BreakingBlock.swift │ │ │ ├── Chunk/ │ │ │ │ ├── Chunk.swift │ │ │ │ ├── ChunkNeighbours.swift │ │ │ │ ├── ChunkPosition.swift │ │ │ │ ├── ChunkSection.swift │ │ │ │ ├── ChunkSectionPosition.swift │ │ │ │ └── HeightMap.swift │ │ │ ├── DaylightCyclePhase.swift │ │ │ ├── Dimension/ │ │ │ │ └── Dimension.swift │ │ │ ├── Fog.swift │ │ │ ├── Light/ │ │ │ │ ├── ChunkLighting.swift │ │ │ │ ├── ChunkLightingUpdateData.swift │ │ │ │ ├── LightLevel.swift │ │ │ │ └── LightingEngine.swift │ │ │ ├── Targeted.swift │ │ │ ├── Thing.swift │ │ │ └── World.swift │ │ └── Tests/ │ │ └── DeltaCoreUnitTests/ │ │ ├── BufferTests.swift │ │ ├── ChatComponentTests.swift │ │ ├── IdentifierTests.swift │ │ ├── LegacyFormattedTextTests.swift │ │ └── LocalizationFormatterTests.swift │ └── Exporters/ │ ├── DynamicShim/ │ │ └── Exports.swift │ └── StaticShim/ │ └── Exports.swift ├── build.sh └── lint.sh
Condensed preview — 754 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,763K chars).
[
{
"path": ".editorconfig",
"chars": 54,
"preview": "root = true\n\n[*]\nindent_style = space\nindent_size = 2\n"
},
{
"path": ".github/FUNDING.yml",
"chars": 66,
"preview": "# These are supported funding model platforms\n\ngithub: stackotter\n"
},
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 952,
"preview": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: ''\nlabels: bug\nassignees: ''\n\n---\n\n**Describe the "
},
{
"path": ".github/ISSUE_TEMPLATE/feature_request.md",
"chars": 604,
"preview": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: ''\nlabels: enhancement\nassignees: ''\n\n---\n\n**Is"
},
{
"path": ".github/pull_request_template.md",
"chars": 855,
"preview": "# Description\n\nPlease include a summary of the change and which issue is fixed. Please also include relevant motivation "
},
{
"path": ".github/workflows/build.yml",
"chars": 2084,
"preview": "name: Build\n\non:\n push:\n pull_request:\n workflow_dispatch:\n\njobs:\n build-macos:\n runs-on: macOS-15\n steps:\n "
},
{
"path": ".github/workflows/swiftlint.yml",
"chars": 589,
"preview": "name: Lint\n\non:\n push:\n pull_request:\n workflow_dispatch:\n\njobs:\n swift-lint:\n runs-on: macOS-latest\n steps:\n "
},
{
"path": ".github/workflows/test.yml",
"chars": 707,
"preview": "name: Test\n\non:\n push:\n pull_request:\n workflow_dispatch:\n\njobs:\n test-macos:\n runs-on: macOS-15\n steps:\n "
},
{
"path": ".gitignore",
"chars": 147,
"preview": ".DS_Store\n.build\n.docc-build\n/Packages\n*.xcodeproj\nxcuserdata/\n*.xcworkspace\n/DeltaClient.app\n/.swiftpm\n/.vscode\n.swiftp"
},
{
"path": ".swift-format",
"chars": 105,
"preview": "{\n \"version\": 1,\n \"indentation\": {\n \"spaces\": 2\n },\n \"indentSwitchCaseLabels\": true\n}\n"
},
{
"path": ".swiftlint.yml",
"chars": 1005,
"preview": "excluded:\n- \"**/.build\"\n- \"Sources/Core/Sources/Cache/Protobuf/Generated/BlockRegistry.pb.swift\"\n- \"Sources/Core/Sources"
},
{
"path": "Bundler.toml",
"chars": 425,
"preview": "format_version = 2\n\n[apps.DeltaClient]\nproduct = 'DeltaClient'\nversion = 'v0.1.0-alpha.1'\nidentifier = 'dev.stackotter.d"
},
{
"path": "Contributing.md",
"chars": 4164,
"preview": "# Contributing\n\nDelta Client is completely open source and I welcome contributions of all kinds. If you're\ninterested in"
},
{
"path": "LICENSE",
"chars": 34916,
"preview": "### GNU GENERAL PUBLIC LICENSE\n\nVersion 3, 29 June 2007\n\nCopyright (C) 2007 Free Software Foundation, Inc.\n<https://fsf."
},
{
"path": "Notes/Caching.md",
"chars": 10831,
"preview": "# Caching\n\nDelta Client uses caching to speed up launches by orders of magnitude. The only thing I cache at the moment a"
},
{
"path": "Notes/ChunkPreparation.md",
"chars": 6143,
"preview": "# Chunk preparation optimisation\n\nChunk mesh preparation is one of the prime areas of focus for optimisation efforts. Fa"
},
{
"path": "Notes/DebuggingDeadlocks.md",
"chars": 3121,
"preview": "# Debugging deadlocks \n\nThe more high performance parts of Delta Client use locks to ensure threadsafety (instead of hig"
},
{
"path": "Notes/GUIRendering.md",
"chars": 5011,
"preview": "# GUI rendering\n\n## Optimisation\n\nGUI rendering should be a relatively cheap operation in the Delta Client pipeline, but"
},
{
"path": "Notes/PluginSystem.md",
"chars": 2871,
"preview": "# Plugin System\n\nThis document explains how the plugin system is designed and implemented.\n\n## `PluginEnvironment`\n\nThe "
},
{
"path": "Notes/Readme.md",
"chars": 346,
"preview": "# Notes\n\nIn this directory I will be documenting the reasoning behind certain design decisions. I will also be documenti"
},
{
"path": "Notes/RenderPipeline.md",
"chars": 728,
"preview": "# Render pipeline optimisation\n\nThe CPU usage of the render pipeline is currently bottlenecking fps much more than the a"
},
{
"path": "Package.resolved",
"chars": 16448,
"preview": "{\n \"pins\" : [\n {\n \"identity\" : \"asn1parser\",\n \"kind\" : \"remoteSourceControl\",\n \"location\" : \"https://"
},
{
"path": "Package.swift",
"chars": 2490,
"preview": "// swift-tools-version:5.9\n\nimport PackageDescription\n\nvar products: [Product] = [\n .executable(\n name: \"DeltaClient"
},
{
"path": "Readme.md",
"chars": 6673,
"preview": "# Delta Client - Changing the meaning of speed\r\n\r\n[ -> some View {\n "
},
{
"path": "Sources/Client/Components/ButtonStyles/PrimaryButtonStyle.swift",
"chars": 437,
"preview": "import SwiftUI\n\n#if os(tvOS)\n typealias PrimaryButtonStyle = DefaultButtonStyle\n#else\n struct PrimaryButtonStyle: Butt"
},
{
"path": "Sources/Client/Components/ButtonStyles/SecondaryButtonStyle.swift",
"chars": 440,
"preview": "import SwiftUI\n\n#if os(tvOS)\n typealias SecondaryButtonStyle = DefaultButtonStyle\n#else\n struct SecondaryButtonStyle: "
},
{
"path": "Sources/Client/Components/EditableList/EditableList.swift",
"chars": 4776,
"preview": "import SwiftUI\n\nenum EditableListAction {\n case delete\n case edit\n case moveUp\n case moveDown\n case select\n}\n\nenum "
},
{
"path": "Sources/Client/Components/EditableList/EditorView.swift",
"chars": 159,
"preview": "import SwiftUI\n\nprotocol EditorView: View {\n associatedtype Item\n \n init(_ item: Item?, completion: @escaping (Item) "
},
{
"path": "Sources/Client/Components/EmailField.swift",
"chars": 898,
"preview": "import SwiftUI\nimport Combine\n\nstruct EmailField: View {\n // swiftlint:disable:next force_try\n static private let rege"
},
{
"path": "Sources/Client/Components/IconButton.swift",
"chars": 479,
"preview": "import SwiftUI\n\nstruct IconButton: View {\n let icon: String\n let isDisabled: Bool\n let action: () -> Void\n \n init(_"
},
{
"path": "Sources/Client/Components/LegacyFormattedTextView.swift",
"chars": 2171,
"preview": "import Foundation\nimport DeltaCore\nimport SwiftUI\n\n/// SwiftUI view for displaying text that is formatted using Legacy f"
},
{
"path": "Sources/Client/Components/OptionalNumberField.swift",
"chars": 830,
"preview": "import SwiftUI\nimport Combine\n\nstruct OptionalNumberField<Number: FixedWidthInteger>: View {\n let title: String\n \n @S"
},
{
"path": "Sources/Client/Components/PingIndicator.swift",
"chars": 159,
"preview": "import SwiftUI\n\nstruct PingIndicator: View {\n let color: Color\n \n var body: some View {\n Circle()\n .foregroun"
},
{
"path": "Sources/Client/Components/PixellatedBorder.swift",
"chars": 1280,
"preview": "import SwiftUI\n\nstruct PixellatedBorder: InsettableShape {\n public var insetAmount: CGFloat = 0\n \n private let border"
},
{
"path": "Sources/Client/Config/Config.swift",
"chars": 3072,
"preview": "import Foundation\nimport DeltaCore\nimport OrderedCollections\n\n/// The client's configuration. Usually stored in a JSON f"
},
{
"path": "Sources/Client/Config/ConfigError.swift",
"chars": 1374,
"preview": "import Foundation\n\npublic enum ConfigError: LocalizedError {\n /// The config file is missing a version.\n case missingV"
},
{
"path": "Sources/Client/Config/ManagedConfig.swift",
"chars": 3818,
"preview": "import Foundation\nimport DeltaCore\n\n/// Manages the config stored in a config file.\n@dynamicMemberLookup\nfinal class Man"
},
{
"path": "Sources/Client/DeltaClientApp.swift",
"chars": 3543,
"preview": "import SwiftUI\nimport DeltaCore\n\n/// The entry-point for Delta Client.\nstruct DeltaClientApp: App {\n @StateObject var a"
},
{
"path": "Sources/Client/Discord/DiscordManager.swift",
"chars": 1195,
"preview": "import Foundation\n\n#if os(macOS)\nimport SwordRPC\n#endif\n\n/// Manages discord interactions\nfinal class DiscordManager {\n "
},
{
"path": "Sources/Client/Discord/DiscordPresenceState.swift",
"chars": 814,
"preview": "import Foundation\n\nextension DiscordManager {\n /// State of Discord rich presence.\n enum RichPresenceState: Equatable "
},
{
"path": "Sources/Client/Extensions/Binding+onChange.swift",
"chars": 427,
"preview": "import Foundation\nimport SwiftUI\n\n// This excellent solution is from https://www.hackingwithswift.com/quick-start/swiftu"
},
{
"path": "Sources/Client/Extensions/Box+ObservableObject.swift",
"chars": 164,
"preview": "import Combine\nimport DeltaCore\n\nextension Box: ObservableObject {\n public var objectWillChange: ObservableObjectPublis"
},
{
"path": "Sources/Client/Extensions/TaskProgress+ObservableObject.swift",
"chars": 298,
"preview": "import Combine\nimport DeltaCore\n\nextension TaskProgress: ObservableObject {\n public var objectWillChange: ObservableObj"
},
{
"path": "Sources/Client/Extensions/View.swift",
"chars": 2999,
"preview": "import SwiftUI\n\nextension View {\n /// Returns a copy of self with the specified property set to the given value.\n /// "
},
{
"path": "Sources/Client/GitHub/GitHubBranch.swift",
"chars": 100,
"preview": "import Foundation\n\nstruct GitHubBranch: Decodable {\n var name: String\n var commit: GitHubCommit\n}\n"
},
{
"path": "Sources/Client/GitHub/GitHubCommit.swift",
"chars": 90,
"preview": "import Foundation\n\nstruct GitHubCommit: Decodable {\n var sha: String\n var url: String\n}\n"
},
{
"path": "Sources/Client/GitHub/GitHubComparison.swift",
"chars": 327,
"preview": "import Foundation\n\n/// Represents a comparison between GitHub branches and/or commits\nstruct GitHubComparison: Decodable"
},
{
"path": "Sources/Client/GitHub/GitHubReleasesAPIResponse.swift",
"chars": 278,
"preview": "import Foundation\n\nstruct GitHubReleasesAPIResponse: Codable {\n var tagName: String\n var assets: [Asset]\n \n struct A"
},
{
"path": "Sources/Client/Input/Controller.swift",
"chars": 7497,
"preview": "import GameController\nimport Combine\n\n/// A control on a controller (a button, a thumbstick, a trigger, etc).\nprotocol C"
},
{
"path": "Sources/Client/Input/ControllerHub.swift",
"chars": 2302,
"preview": "import GameController\nimport DeltaCore\n\nclass ControllerHub: ObservableObject {\n @Published var controllers: [Controlle"
},
{
"path": "Sources/Client/Input/InputMethod.swift",
"chars": 958,
"preview": "enum InputMethod: Hashable {\n case keyboardAndMouse\n case controller(Controller) \n\n var name: String {\n switch "
},
{
"path": "Sources/Client/Logger.swift",
"chars": 30,
"preview": "@_exported import DeltaLogger\n"
},
{
"path": "Sources/Client/Modal.swift",
"chars": 1923,
"preview": "import DeltaCore\nimport SwiftUI\n\nclass Modal: ObservableObject {\n enum Content {\n case warning(String)\n case erro"
},
{
"path": "Sources/Client/State/AppState.swift",
"chars": 263,
"preview": "import Foundation\nimport DeltaCore\n\n/// App states\nindirect enum AppState: Equatable {\n case serverList\n case editServ"
},
{
"path": "Sources/Client/State/StateWrapper.swift",
"chars": 1389,
"preview": "import Foundation\nimport DeltaCore\n\n/// An observable wrapper around a state enum for use with SwiftUI\nfinal class State"
},
{
"path": "Sources/Client/StorageDirectory.swift",
"chars": 5730,
"preview": "import Foundation\nimport SwiftUI\nimport DeltaCore\n\n/// An error thrown by ``StorageDirectory``.\nenum StorageDirectoryErr"
},
{
"path": "Sources/Client/Utility/Clipboard.swift",
"chars": 632,
"preview": "#if canImport(AppKit)\nimport AppKit\n#elseif canImport(UIKit)\nimport UIKit\n#endif\n\n/// A simple helper for managing the u"
},
{
"path": "Sources/Client/Utility/Updater.swift",
"chars": 11015,
"preview": "#if os(macOS)\nimport SwiftUI\nimport DeltaCore\n\n/// An error thrown by ``Updater``.\nenum UpdaterError: LocalizedError {\n "
},
{
"path": "Sources/Client/Utility/Utils.swift",
"chars": 628,
"preview": "import Foundation\n\nenum Utils {\n #if os(macOS)\n /// Runs a shell command.\n static func shell(_ command: String) {\n "
},
{
"path": "Sources/Client/Views/Play/DirectConnectView.swift",
"chars": 1276,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct DirectConnectView: View {\n @EnvironmentObject var appState: StateWrapper<AppSta"
},
{
"path": "Sources/Client/Views/Play/GameView.swift",
"chars": 8329,
"preview": "import SwiftUI\nimport DeltaCore\nimport DeltaRenderer\nimport Combine\n\n/// Where the real Minecraft stuff happens. This re"
},
{
"path": "Sources/Client/Views/Play/InGameMenu.swift",
"chars": 2654,
"preview": "import SwiftUI\n\nstruct InGameMenu: View {\n enum InGameMenuState {\n case menu\n case settings\n }\n\n @EnvironmentOb"
},
{
"path": "Sources/Client/Views/Play/InputView.swift",
"chars": 10538,
"preview": "import SwiftUI\nimport DeltaCore\nimport DeltaRenderer\n\nstruct InputView<Content: View>: View {\n @EnvironmentObject var m"
},
{
"path": "Sources/Client/Views/Play/JoinServerAndThen.swift",
"chars": 7163,
"preview": "import SwiftUI\nimport DeltaCore\n\nenum ServerJoinState {\n case connecting\n case loggingIn\n case downloadingChunks(rece"
},
{
"path": "Sources/Client/Views/Play/MetalView.swift",
"chars": 3029,
"preview": "import Foundation\nimport DeltaCore\nimport DeltaRenderer\nimport MetalKit\nimport SwiftUI\n\n@available(macOS 13, *)\n@availab"
},
{
"path": "Sources/Client/Views/Play/PlayView.swift",
"chars": 2468,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct PlayView: View {\n @EnvironmentObject var appState: StateWrapper<AppState>\n @En"
},
{
"path": "Sources/Client/Views/Play/SelectAccountAndThen.swift",
"chars": 956,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct SelectAccountAndThen<Content: View>: View {\n @EnvironmentObject var managedConf"
},
{
"path": "Sources/Client/Views/Play/SelectInputMethodAndThen.swift",
"chars": 1096,
"preview": "import SwiftUI\n\nstruct SelectInputMethodAndThen<Content: View>: View {\n @EnvironmentObject var controllerHub: Controlle"
},
{
"path": "Sources/Client/Views/Play/SelectOption.swift",
"chars": 2290,
"preview": "import SwiftUI\n\n// TODO: The init is starting to get a bit bloated, perhaps a sign that this\n// view is doing too much"
},
{
"path": "Sources/Client/Views/Play/WithController.swift",
"chars": 1874,
"preview": "import SwiftUI\nimport Combine\n\nstruct WithController<Content: View>: View {\n @State var cancellable: AnyCancellable?\n "
},
{
"path": "Sources/Client/Views/Play/WithRenderCoordinator.swift",
"chars": 1393,
"preview": "import SwiftUI\nimport DeltaCore\nimport DeltaRenderer\n\n/// A helper view which can be used to create a render coordinator"
},
{
"path": "Sources/Client/Views/Play/WithSelectedAccount.swift",
"chars": 872,
"preview": "import SwiftUI\nimport DeltaCore\n\n/// Gets the currently selected account, or redirects the user to settings to select an"
},
{
"path": "Sources/Client/Views/RouterView.swift",
"chars": 1632,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct RouterView: View {\n @EnvironmentObject var appState: StateWrapper<AppState>\n @"
},
{
"path": "Sources/Client/Views/ServerList/LANServerList.swift",
"chars": 509,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct LANServerList: View {\n @ObservedObject var lanServerEnumerator: LANServerEnumer"
},
{
"path": "Sources/Client/Views/ServerList/ServerDetail.swift",
"chars": 2266,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct ServerDetail: View {\n @EnvironmentObject var appState: StateWrapper<AppState>\n "
},
{
"path": "Sources/Client/Views/ServerList/ServerListItem.swift",
"chars": 757,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct ServerListItem: View {\n @StateObject var pinger: Pinger\n \n var indicatorColor"
},
{
"path": "Sources/Client/Views/ServerList/ServerListView.swift",
"chars": 3964,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct ServerListView: View {\n @EnvironmentObject var appState: StateWrapper<AppState>"
},
{
"path": "Sources/Client/Views/Settings/Account/AccountLoginView.swift",
"chars": 1865,
"preview": "import SwiftUI\nimport DeltaCore\n\nenum LoginViewState {\n case chooseAccountType\n case loginMicrosoft\n case loginMojang"
},
{
"path": "Sources/Client/Views/Settings/Account/AccountSettingsView.swift",
"chars": 3327,
"preview": "import SwiftUI\nimport DeltaCore\n\n// TODO: Use Config.orderedAccounts to ensure that account ordering is at least consist"
},
{
"path": "Sources/Client/Views/Settings/Account/MicrosoftLoginView.swift",
"chars": 3232,
"preview": "import SwiftUI\nimport DeltaCore\n\nenum MicrosoftLoginViewError: LocalizedError {\n case failedToAuthorizeDevice\n case fa"
},
{
"path": "Sources/Client/Views/Settings/Account/MojangLoginView.swift",
"chars": 1715,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct MojangLoginView: View {\n @EnvironmentObject var managedConfig: ManagedConfig\n "
},
{
"path": "Sources/Client/Views/Settings/Account/OfflineLoginView.swift",
"chars": 1080,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct OfflineLoginView: View {\n @State private var username = \"\"\n @State private var"
},
{
"path": "Sources/Client/Views/Settings/ControlsSettingsView.swift",
"chars": 2122,
"preview": "import SwiftUI\n\n#if !os(tvOS)\nstruct ControlsSettingsView: View {\n @EnvironmentObject var managedConfig: ManagedConfig\n"
},
{
"path": "Sources/Client/Views/Settings/KeymapEditorView.swift",
"chars": 2740,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct KeymapEditorView: View {\n @EnvironmentObject var managedConfig: ManagedConfig\n\n"
},
{
"path": "Sources/Client/Views/Settings/PluginSettingsView.swift",
"chars": 3363,
"preview": "import SwiftUI\nimport DeltaCore\n\n#if os(macOS)\nenum PluginSettingsViewError: LocalizedError {\n case failedToLoadPlugin("
},
{
"path": "Sources/Client/Views/Settings/Server/EditServerListView.swift",
"chars": 1429,
"preview": "import SwiftUI\nimport DeltaCore\nimport Combine\n\nstruct EditServerListView: View {\n @EnvironmentObject var appState: Sta"
},
{
"path": "Sources/Client/Views/Settings/Server/ServerEditorView.swift",
"chars": 1544,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct ServerEditorView: EditorView {\n @State var descriptor: ServerDescriptor\n @Stat"
},
{
"path": "Sources/Client/Views/Settings/SettingsView.swift",
"chars": 2507,
"preview": "import SwiftUI\nimport DeltaCore\n\nenum SettingsState: CaseIterable {\n case video\n case controls\n case accounts\n case "
},
{
"path": "Sources/Client/Views/Settings/TroubleShootingView.swift",
"chars": 4030,
"preview": "import SwiftUI\nimport DeltaCore\n\n/// An error which can occur during troubleshooting; how ironic.\nenum TroubleshootingEr"
},
{
"path": "Sources/Client/Views/Settings/UpdateView.swift",
"chars": 3138,
"preview": "import SwiftUI\nimport ZIPFoundation\nimport DeltaCore\n\n#if os(macOS)\nstruct UpdateView: View {\n enum UpdateViewState {\n "
},
{
"path": "Sources/Client/Views/Settings/VideoSettingsView.swift",
"chars": 2486,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct VideoSettingsView: View {\n @EnvironmentObject var managedConfig: ManagedConfig\n"
},
{
"path": "Sources/Client/Views/Startup/LoadAndThen.swift",
"chars": 5870,
"preview": "import Combine\nimport DeltaCore\nimport SwiftUI\n\nstruct LoadResult {\n var managedConfig: ManagedConfig\n var resourcePac"
},
{
"path": "Sources/Client/Views/Startup/ProgressLoadingView.swift",
"chars": 2038,
"preview": "import SwiftUI\nimport DeltaCore\n\nstruct ProgressLoadingView: View {\n // MARK: Public properties\n\n /// Loader progress\n"
},
{
"path": "Sources/Client/Views/Startup/StartupStep.swift",
"chars": 818,
"preview": "import Foundation\nimport DeltaCore\n\n/// All major startup steps in order.\nenum StartupStep: CaseIterable, TaskStep {\n c"
},
{
"path": "Sources/Client/main.swift",
"chars": 53,
"preview": "// Start the main SwiftUI loop\nDeltaClientApp.main()\n"
},
{
"path": "Sources/ClientGtk/ChatView.swift",
"chars": 1225,
"preview": "import DeltaCore\nimport SwiftCrossUI\n\nclass ChatViewState: Observable {\n @Observed var error: String?\n @Observed var m"
},
{
"path": "Sources/ClientGtk/DeltaClientApp.swift",
"chars": 3138,
"preview": "import DefaultBackend\nimport DeltaCore\nimport Dispatch\nimport Foundation\nimport SwiftCrossUI\n\n@main\nstruct DeltaClientAp"
},
{
"path": "Sources/ClientGtk/GameView.swift",
"chars": 3078,
"preview": "import DeltaCore\nimport Dispatch\nimport SwiftCrossUI\n\nclass GameViewState: Observable {\n enum State {\n case error(St"
},
{
"path": "Sources/ClientGtk/ServerListView.swift",
"chars": 4485,
"preview": "import DeltaCore\nimport SwiftCrossUI\n\nindirect enum DetailState {\n case server(_ index: Int)\n case adding\n case editi"
},
{
"path": "Sources/ClientGtk/Settings/AccountInspectionView.swift",
"chars": 649,
"preview": "import DeltaCore\nimport SwiftCrossUI\n\nstruct AccountInspectorView: View {\n var account: Account\n\n var selectAccount: ("
},
{
"path": "Sources/ClientGtk/Settings/AccountListView.swift",
"chars": 702,
"preview": "import DeltaCore\nimport SwiftCrossUI\n\nstruct AccountListView: View {\n var inspectAccount: (Account) -> Void\n var offli"
},
{
"path": "Sources/ClientGtk/Settings/MicrosoftLoginView.swift",
"chars": 1826,
"preview": "import DeltaCore\nimport SwiftCrossUI\n\nenum MicrosoftState {\n case authorizingDevice\n case login(MicrosoftDeviceAuthori"
},
{
"path": "Sources/ClientGtk/Settings/OfflineLoginView.swift",
"chars": 666,
"preview": "import DeltaCore\nimport SwiftCrossUI\n\nclass OfflineLoginViewState: Observable {\n @Observed var username = \"\"\n @Observe"
},
{
"path": "Sources/ClientGtk/Settings/SettingsView.swift",
"chars": 2122,
"preview": "import DeltaCore\nimport SwiftCrossUI\n\nenum SettingsPage {\n case accountList\n case inspectAccount(Account)\n case offli"
},
{
"path": "Sources/ClientGtk/Storage/Config.swift",
"chars": 1179,
"preview": "import Foundation\nimport DeltaCore\n\npublic struct Config: Codable {\n /// The random token used to identify ourselves to"
},
{
"path": "Sources/ClientGtk/Storage/ConfigError.swift",
"chars": 888,
"preview": "import Foundation\n\npublic enum ConfigError: LocalizedError {\n /// The account in question is of an invalid type.\n case"
},
{
"path": "Sources/ClientGtk/Storage/ConfigManager.swift",
"chars": 5190,
"preview": "import DeltaCore\nimport Foundation\n\n/// Manages the config stored in a config file.\npublic final class ConfigManager {\n "
},
{
"path": "Sources/ClientGtk/Storage/StorageManager.swift",
"chars": 3371,
"preview": "import DeltaCore\nimport Foundation\n\nfinal class StorageManager {\n static var `default` = StorageManager()\n\n public var"
},
{
"path": "Sources/Core/Logger/Logger.swift",
"chars": 2539,
"preview": "import Puppy\nimport Foundation\nimport Rainbow\n\n@_exported import enum Puppy.LogLevel\n\nstruct ConsoleLogFormatter: LogFor"
},
{
"path": "Sources/Core/Package.resolved",
"chars": 11836,
"preview": "{\n \"pins\" : [\n {\n \"identity\" : \"asn1parser\",\n \"kind\" : \"remoteSourceControl\",\n \"location\" : \"https://"
},
{
"path": "Sources/Core/Package.swift",
"chars": 3765,
"preview": "// swift-tools-version:5.9\n\nimport PackageDescription\n\nlet debugLocks = false\n\n// MARK: Products\n\nvar productTargets = ["
},
{
"path": "Sources/Core/Renderer/Camera/Camera.swift",
"chars": 6190,
"preview": "import Foundation\nimport Metal\nimport FirebladeMath\nimport DeltaCore\n\n/// Holds information about a camera to render fro"
},
{
"path": "Sources/Core/Renderer/Camera/Frustum.swift",
"chars": 1416,
"preview": "import Foundation\nimport FirebladeMath\nimport DeltaCore\n\n// method from: http://web.archive.org/web/20120531231005/http:"
},
{
"path": "Sources/Core/Renderer/CameraUniforms.swift",
"chars": 385,
"preview": "import FirebladeMath\n\npublic struct CameraUniforms {\n /// Translation and rotation (sets up the camera's framing).\n pu"
},
{
"path": "Sources/Core/Renderer/CaptureState.swift",
"chars": 268,
"preview": "import Foundation\n\nextension RenderCoordinator {\n /// The state of a GPU frame capture.\n struct CaptureState {\n ///"
},
{
"path": "Sources/Core/Renderer/CelestialBodyUniforms.swift",
"chars": 309,
"preview": "import FirebladeMath\n\npublic struct CelestialBodyUniforms {\n public var transformation: Mat4x4f\n public var textureInd"
},
{
"path": "Sources/Core/Renderer/ChunkUniforms.swift",
"chars": 418,
"preview": "import DeltaCore\nimport FirebladeMath\n\npublic struct ChunkUniforms {\n /// The translation to convert chunk-space coordi"
},
{
"path": "Sources/Core/Renderer/EndSkyUniforms.swift",
"chars": 105,
"preview": "import FirebladeMath\n\nstruct EndSkyUniforms {\n var transformation: Mat4x4f\n var textureIndex: UInt16\n}\n"
},
{
"path": "Sources/Core/Renderer/EndSkyVertex.swift",
"chars": 84,
"preview": "import FirebladeMath\n\nstruct EndSkyVertex {\n var position: Vec3f\n var uv: Vec2f\n}\n"
},
{
"path": "Sources/Core/Renderer/Entity/EntityRenderer.swift",
"chars": 10186,
"preview": "import DeltaCore\nimport FirebladeECS\nimport FirebladeMath\nimport Foundation\nimport MetalKit\n\n/// Renders all entities in"
},
{
"path": "Sources/Core/Renderer/Entity/EntityVertex.swift",
"chars": 1038,
"preview": "/// The vertex format used by the entity shader.\npublic struct EntityVertex {\n public var x: Float\n public var y: Floa"
},
{
"path": "Sources/Core/Renderer/EntityUniforms.swift",
"chars": 335,
"preview": "import FirebladeMath\n\npublic struct EntityUniforms {\n /// The transformation for an instance of the generic entity hitb"
},
{
"path": "Sources/Core/Renderer/FogUniforms.swift",
"chars": 196,
"preview": "import FirebladeMath\n\n/// Uniforms used to render distance fog.\nstruct FogUniforms {\n var fogColor: Vec3f\n var fogStar"
},
{
"path": "Sources/Core/Renderer/GUI/GUIContext.swift",
"chars": 420,
"preview": "import Metal\nimport DeltaCore\n\nstruct GUIContext {\n var font: Font\n var fontArrayTexture: MTLTexture\n var guiTextureP"
},
{
"path": "Sources/Core/Renderer/GUI/GUIElementMesh.swift",
"chars": 4794,
"preview": "import MetalKit\nimport FirebladeMath\nimport DeltaCore\n\n/// A generic texture-backed GUI element.\nstruct GUIElementMesh {"
},
{
"path": "Sources/Core/Renderer/GUI/GUIElementMeshArray.swift",
"chars": 929,
"preview": "import FirebladeMath\n\nextension Array where Element == GUIElementMesh {\n mutating func translate(amount: Vec2i) {\n f"
},
{
"path": "Sources/Core/Renderer/GUI/GUIElementUniforms.swift",
"chars": 140,
"preview": "import FirebladeMath\n\n/// The uniforms for a GUI element.\nstruct GUIElementUniforms {\n /// The element's position.\n va"
},
{
"path": "Sources/Core/Renderer/GUI/GUIQuad.swift",
"chars": 3472,
"preview": "import Metal\nimport FirebladeMath\nimport DeltaCore\n\n/// A convenient way to construct the vertices for a GUI quad.\nstruc"
},
{
"path": "Sources/Core/Renderer/GUI/GUIRenderer.swift",
"chars": 16228,
"preview": "import DeltaCore\nimport FirebladeMath\nimport MetalKit\n\n#if canImport(UIKit)\n import UIKit\n#endif\n\n/// The renderer for "
},
{
"path": "Sources/Core/Renderer/GUI/GUIRendererError.swift",
"chars": 1411,
"preview": "import Foundation\n\n/// An error thrown by ``GUIRenderer``.\nenum GUIRendererError: LocalizedError {\n case failedToCreate"
},
{
"path": "Sources/Core/Renderer/GUI/GUIUniforms.swift",
"chars": 261,
"preview": "import FirebladeMath\n\n/// The GUI's uniforms.\npublic struct GUIUniforms: Equatable {\n /// The transformation to convert"
},
{
"path": "Sources/Core/Renderer/GUI/GUIVertex.swift",
"chars": 402,
"preview": "import FirebladeMath\n\n/// A vertex in the GUI.\nstruct GUIVertex: Equatable {\n /// The position.\n var position: Vec2f\n "
},
{
"path": "Sources/Core/Renderer/GUI/GUIVertexStorage.swift",
"chars": 3994,
"preview": "/// Vertices are stored in tuples as an optimisation.\ntypealias GUIQuadVertices = (GUIVertex, GUIVertex, GUIVertex, GUIV"
},
{
"path": "Sources/Core/Renderer/GUI/TextMeshBuilder.swift",
"chars": 5146,
"preview": "import Metal\nimport FirebladeMath\nimport DeltaCore\n\nstruct TextMeshBuilder {\n var font: Font\n\n func descriptor(for cha"
},
{
"path": "Sources/Core/Renderer/GUI/TextMeshBuilderError.swift",
"chars": 91,
"preview": "import Foundation\n\nenum TextMeshBuilderError: Error {\n case invalidCharacter(Character)\n}\n"
},
{
"path": "Sources/Core/Renderer/Logger.swift",
"chars": 30,
"preview": "@_exported import DeltaLogger\n"
},
{
"path": "Sources/Core/Renderer/Mesh/BlockMeshBuilder.swift",
"chars": 6579,
"preview": "import DeltaCore\nimport FirebladeMath\n\n/// Builds the mesh for a single block.\nstruct BlockMeshBuilder {\n let model: Bl"
},
{
"path": "Sources/Core/Renderer/Mesh/BlockNeighbour.swift",
"chars": 3008,
"preview": "import DeltaCore\n\n/// A representation of a neighbouring block that can be used efficiently when generating meshes.\nstru"
},
{
"path": "Sources/Core/Renderer/Mesh/ChunkSectionMesh.swift",
"chars": 2500,
"preview": "import FirebladeMath\nimport Foundation\nimport MetalKit\n\n/// A renderable mesh of a chunk section.\npublic struct ChunkSec"
},
{
"path": "Sources/Core/Renderer/Mesh/ChunkSectionMeshBuilder.swift",
"chars": 16811,
"preview": "import DeltaCore\nimport FirebladeMath\nimport Foundation\nimport MetalKit\n\n/// Builds renderable meshes from chunk section"
},
{
"path": "Sources/Core/Renderer/Mesh/CubeGeometry.swift",
"chars": 1379,
"preview": "import Foundation\nimport FirebladeMath\nimport DeltaCore\n\nstruct CubeGeometry {\n static let faceWinding: [UInt32] = [0, "
},
{
"path": "Sources/Core/Renderer/Mesh/EntityMeshBuilder.swift",
"chars": 13471,
"preview": "import CoreFoundation\nimport DeltaCore\nimport FirebladeECS\nimport Foundation\n\npublic struct EntityMeshBuilder {\n /// As"
},
{
"path": "Sources/Core/Renderer/Mesh/FluidMeshBuilder.swift",
"chars": 12755,
"preview": "import DeltaCore\nimport FirebladeMath\n\n/// Builds the fluid mesh for a block.\nstruct FluidMeshBuilder { // TODO: Make f"
},
{
"path": "Sources/Core/Renderer/Mesh/Geometry.swift",
"chars": 457,
"preview": "import Foundation\n\n/// The simplest representation of renderable geometry data. Just vertices and vertex winding.\npublic"
},
{
"path": "Sources/Core/Renderer/Mesh/Mesh.swift",
"chars": 5081,
"preview": "import Foundation\nimport Metal\n\npublic enum MeshError: LocalizedError {\n case failedToCreateBuffer\n\n public var errorD"
},
{
"path": "Sources/Core/Renderer/Mesh/SortableMesh.swift",
"chars": 3184,
"preview": "import FirebladeMath\nimport Foundation\nimport MetalKit\n\n/// A mesh that can be sorted after the initial preparation.\n///"
},
{
"path": "Sources/Core/Renderer/Mesh/SortableMeshElement.swift",
"chars": 1364,
"preview": "import FirebladeMath\nimport Foundation\n\n/// An element of a ``SortableMesh``.\npublic struct SortableMeshElement {\n /// "
},
{
"path": "Sources/Core/Renderer/RenderCoordinator.swift",
"chars": 14002,
"preview": "import Foundation\nimport FirebladeMath\nimport MetalKit\nimport DeltaCore\n\npublic enum RendererError: LocalizedError {\n c"
},
{
"path": "Sources/Core/Renderer/RenderError.swift",
"chars": 6272,
"preview": "import DeltaCore\nimport Foundation\n\npublic enum RenderError: LocalizedError {\n /// Failed to create a metal array textu"
},
{
"path": "Sources/Core/Renderer/Renderer.swift",
"chars": 486,
"preview": "import Metal\nimport MetalKit\n\n/// A protocol that renderers should conform to.\npublic protocol Renderer {\n /// Renders "
},
{
"path": "Sources/Core/Renderer/RenderingMeasurement.swift",
"chars": 646,
"preview": "public enum RenderingMeasurement: String, Hashable {\n case waitForRenderPassDescriptor\n case updateCamera\n case creat"
},
{
"path": "Sources/Core/Renderer/Resources/Font+Metal.swift",
"chars": 2876,
"preview": "import MetalKit\nimport DeltaCore\n\nextension Font {\n /// Creates an array texture containing the font's atlases.\n /// -"
},
{
"path": "Sources/Core/Renderer/Resources/MetalTexturePalette.swift",
"chars": 8942,
"preview": "import Metal\nimport DeltaCore\n\n/// An error thrown by ``MetalTexturePalette``.\npublic enum MetalTexturePaletteError: Loc"
},
{
"path": "Sources/Core/Renderer/ScreenRenderer.swift",
"chars": 5199,
"preview": "import Foundation\nimport MetalKit\nimport DeltaCore\nimport FirebladeMath\n\n/// The renderer managing offscreen rendering a"
},
{
"path": "Sources/Core/Renderer/Shader/ChunkOITShaders.metal",
"chars": 5041,
"preview": "#include <metal_stdlib>\n#include \"ChunkTypes.metal\"\n\nusing namespace metal;\n\n// These shaders are used in the order inde"
},
{
"path": "Sources/Core/Renderer/Shader/ChunkShaders.metal",
"chars": 3769,
"preview": "#include <metal_stdlib>\n#include \"ChunkTypes.metal\"\n\nusing namespace metal;\n\nconstexpr sampler textureSampler (mag_filte"
},
{
"path": "Sources/Core/Renderer/Shader/ChunkTypes.metal",
"chars": 1032,
"preview": "#include <metal_stdlib>\n\nusing namespace metal;\n\nstruct TextureState {\n uint16_t currentFrameIndex;\n uint16_t nextFram"
},
{
"path": "Sources/Core/Renderer/Shader/EntityShaders.metal",
"chars": 1949,
"preview": "#include <metal_stdlib>\n#include \"ChunkTypes.metal\"\n\nusing namespace metal;\n\nstruct EntityVertex {\n float x;\n float y;"
},
{
"path": "Sources/Core/Renderer/Shader/GUIShaders.metal",
"chars": 1482,
"preview": "#include <metal_stdlib>\n#include \"GUITypes.metal\"\n\nusing namespace metal;\n\nconstant const uint vertexIndexLookup[] = {0,"
},
{
"path": "Sources/Core/Renderer/Shader/GUITypes.metal",
"chars": 382,
"preview": "#include <metal_stdlib>\n\nusing namespace metal;\n\nstruct GUIVertex {\n float2 position;\n float2 uv;\n float4 tint;\n uin"
},
{
"path": "Sources/Core/Renderer/Shader/ScreenShaders.metal",
"chars": 970,
"preview": "#include <metal_stdlib>\nusing namespace metal;\n\nconstant float2 quadVertices[] = {\n float2(-1.0, 1.0),\n float2(-1.0, "
},
{
"path": "Sources/Core/Renderer/Shader/SkyShaders.metal",
"chars": 5469,
"preview": "#include <metal_stdlib>\nusing namespace metal;\n\nstruct SkyPlaneVertex {\n float4 transformedPosition [[position]];\n // "
},
{
"path": "Sources/Core/Renderer/SkyBoxRenderer.swift",
"chars": 24536,
"preview": "import MetalKit\nimport DeltaCore\n\n/// The sky box consists of a sky plane (above the player), and a void plane\n/// (belo"
},
{
"path": "Sources/Core/Renderer/SkyPlaneUniforms.swift",
"chars": 266,
"preview": "import FirebladeMath\n\npublic struct SkyPlaneUniforms {\n public var skyColor: Vec4f\n public var fogColor: Vec4f\n publi"
},
{
"path": "Sources/Core/Renderer/StarUniforms.swift",
"chars": 171,
"preview": "import FirebladeMath\n\n/// Uniforms for the star mesh rendered at night.\npublic struct StarUniforms {\n public var transf"
},
{
"path": "Sources/Core/Renderer/SunriseDiscUniforms.swift",
"chars": 414,
"preview": "import FirebladeMath\n\n// TODO: Maybe to be more clear that it's not just sunrise, but sunset too, the\n// sunrise disc "
},
{
"path": "Sources/Core/Renderer/Util/MetalUtil.swift",
"chars": 10183,
"preview": "import Metal\n\npublic enum MetalUtil {\n /// Makes a render pipeline state with the given properties.\n public static fun"
},
{
"path": "Sources/Core/Renderer/World/BlockVertex.swift",
"chars": 347,
"preview": "import Foundation\n\n/// The vertex format used by the chunk block shader.\npublic struct BlockVertex {\n var x: Float\n va"
},
{
"path": "Sources/Core/Renderer/World/LightMap.swift",
"chars": 5226,
"preview": "import Foundation\nimport Metal\nimport FirebladeMath\n// TODO: Move Vec3 and extensions of FirebladeMath into FirebladeMat"
},
{
"path": "Sources/Core/Renderer/World/Visibility/ChunkSectionFace.swift",
"chars": 1177,
"preview": "import DeltaCore\n\n/// Used by ``ChunkSectionFaceConnectivity`` to efficiently identify pairs of faces.\n///\n/// If the va"
},
{
"path": "Sources/Core/Renderer/World/Visibility/ChunkSectionFaceConnectivity.swift",
"chars": 2407,
"preview": "import DeltaCore\n\n/// Stores which pairs faces in a chunk section are connected to each other. Not threadsafe.\n///\n/// `"
},
{
"path": "Sources/Core/Renderer/World/Visibility/ChunkSectionVoxelGraph.swift",
"chars": 8092,
"preview": "import DeltaCore\n\n/// A 3d data structure used for flood filling chunk sections. Each 'voxel' is represented by an integ"
},
{
"path": "Sources/Core/Renderer/World/Visibility/VisibilityGraph+SearchQueueEntry.swift",
"chars": 318,
"preview": "import DeltaCore\n\nextension VisibilityGraph {\n /// An entry in the breadth-first-search queue. Used when traversing a `"
},
{
"path": "Sources/Core/Renderer/World/Visibility/VisibilityGraph.swift",
"chars": 11125,
"preview": "import DeltaCore\nimport Collections\n\n/// A graph structure used to determine which chunk sections are visible from a giv"
},
{
"path": "Sources/Core/Renderer/World/WorldMesh.swift",
"chars": 13549,
"preview": "import DeltaCore\n\n/// Holds all the meshes for a world. Completely threadsafe.\npublic struct WorldMesh {\n // MARK: Priv"
},
{
"path": "Sources/Core/Renderer/World/WorldMeshWorker+Job.swift",
"chars": 1245,
"preview": "import Collections\nimport DeltaCore\n\nextension WorldMeshWorker {\n /// A chunk section mesh creation job.\n struct Job {"
},
{
"path": "Sources/Core/Renderer/World/WorldMeshWorker.swift",
"chars": 3922,
"preview": "import Foundation\nimport Atomics\nimport Metal\nimport DeltaCore\n\n/// A multi-threaded worker that creates and updates the"
},
{
"path": "Sources/Core/Renderer/World/WorldRenderer.swift",
"chars": 24846,
"preview": "import DeltaCore\nimport FirebladeMath\nimport Foundation\nimport MetalKit\n\n/// A renderer that renders a `World` along wit"
},
{
"path": "Sources/Core/Sources/Account/Account.swift",
"chars": 2528,
"preview": "import Foundation\n\n/// An account which can be a Microsoft, Mojang or offline account.\npublic enum Account: Codable, Ide"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/MicrosoftAPI.swift",
"chars": 14001,
"preview": "import Foundation\n\npublic enum MicrosoftAPIError: LocalizedError {\n case noUserHashInResponse\n case failedToDeserializ"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/MicrosoftAccessToken.swift",
"chars": 1475,
"preview": "import Foundation\nimport CoreFoundation\n\n/// An access token used for refreshing Minecraft access tokens attached to Mic"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/MicrosoftAccount.swift",
"chars": 838,
"preview": "import Foundation\n\n/// A user account that authenticates using the new Microsoft method.\npublic struct MicrosoftAccount:"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Request/MinecraftXboxAuthenticationRequest.swift",
"chars": 102,
"preview": "import Foundation\n\nstruct MinecraftXboxAuthenticationRequest: Codable {\n var identityToken: String\n}\n"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Request/XSTSAuthenticationRequest.swift",
"chars": 580,
"preview": "import Foundation\n\nstruct XSTSAuthenticationRequest: Codable {\n struct Properties: Codable {\n var sandboxId: String\n"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Request/XboxLiveAuthenticationRequest.swift",
"chars": 644,
"preview": "import Foundation\n\nstruct XboxLiveAuthenticationRequest: Codable {\n struct Properties: Codable {\n var authMethod: St"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Response/GameOwnershipResponse.swift",
"chars": 210,
"preview": "import Foundation\n\nstruct GameOwnershipResponse: Codable {\n struct License: Codable {\n var name: String\n var sign"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Response/MicrosoftAccessTokenResponse.swift",
"chars": 393,
"preview": "import Foundation\n\nstruct MicrosoftAccessTokenResponse: Decodable {\n var tokenType: String\n var expiresIn: Int\n var s"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Response/MicrosoftDeviceAuthorizationResponse.swift",
"chars": 512,
"preview": "import Foundation\n\npublic struct MicrosoftDeviceAuthorizationResponse: Decodable {\n public var deviceCode: String\n pub"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Response/MicrosoftMinecraftProfileResponse.swift",
"chars": 406,
"preview": "import Foundation\n\nstruct MicrosoftMinecraftProfileResponse: Decodable {\n var id: String\n var name: String\n var skins"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Response/MinecraftXboxAuthenticationResponse.swift",
"chars": 376,
"preview": "import Foundation\n\nstruct MinecraftXboxAuthenticationResponse: Codable {\n var username: String\n var roles: [String]\n "
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Response/XSTSAuthenticationError.swift",
"chars": 342,
"preview": "import Foundation\n\npublic struct XSTSAuthenticationError: Codable {\n public let identity: String\n public let code: Int"
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Response/XSTSAuthenticationResponse.swift",
"chars": 553,
"preview": "import Foundation\n\nstruct XSTSAuthenticationResponse: Codable {\n struct Claims: Codable {\n var xui: [XUIClaim]\n }\n "
},
{
"path": "Sources/Core/Sources/Account/Microsoft/Response/XboxLiveAuthenticationResponse.swift",
"chars": 614,
"preview": "import Foundation\n\nstruct XboxLiveAuthenticationResponse: Codable {\n struct Claims: Codable {\n var xui: [XUIClaim]\n "
},
{
"path": "Sources/Core/Sources/Account/Microsoft/XboxLiveToken.swift",
"chars": 169,
"preview": "struct XboxLiveToken {\n var token: String\n var userHash: String\n \n init(token: String, userHash: String) {\n self."
},
{
"path": "Sources/Core/Sources/Account/MinecraftAccessToken.swift",
"chars": 1314,
"preview": "import Foundation\nimport CoreFoundation\n\n/// An access token attached to an online account. Used for connecting to onlin"
}
]
// ... and 554 more files (download for full content)
About this extraction
This page contains the full source code of the stackotter/delta-client GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 754 files (1.6 MB), approximately 422.3k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.