├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml ├── PULL_REQUEST_TEMPLATE │ ├── bug_fix.md │ └── new_feature.md └── workflows │ ├── build-commit.yml │ ├── build-pull-request.yml │ ├── build-release.yml │ └── build-tag.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── kotlin │ ├── BuildConfig.kt │ ├── multiloader-base.gradle.kts │ └── multiloader-platform.gradle.kts ├── common ├── build.gradle.kts └── src │ ├── .gitignore │ ├── api │ └── java │ │ └── net │ │ └── caffeinemc │ │ └── mods │ │ └── sodium │ │ └── api │ │ ├── blockentity │ │ ├── BlockEntityRenderHandler.java │ │ └── BlockEntityRenderPredicate.java │ │ ├── internal │ │ ├── DependencyInjection.java │ │ └── package-info.java │ │ ├── math │ │ └── MatrixHelper.java │ │ ├── memory │ │ └── MemoryIntrinsics.java │ │ ├── texture │ │ └── SpriteUtil.java │ │ ├── util │ │ ├── ColorABGR.java │ │ ├── ColorARGB.java │ │ ├── ColorMixer.java │ │ ├── ColorU8.java │ │ └── NormI8.java │ │ └── vertex │ │ ├── attributes │ │ └── common │ │ │ ├── ColorAttribute.java │ │ │ ├── LightAttribute.java │ │ │ ├── NormalAttribute.java │ │ │ ├── OverlayAttribute.java │ │ │ ├── PositionAttribute.java │ │ │ └── TextureAttribute.java │ │ ├── buffer │ │ └── VertexBufferWriter.java │ │ ├── format │ │ ├── VertexFormatExtensions.java │ │ ├── VertexFormatRegistry.java │ │ └── common │ │ │ ├── ColorVertex.java │ │ │ ├── EntityVertex.java │ │ │ ├── GlyphVertex.java │ │ │ ├── LineVertex.java │ │ │ └── ParticleVertex.java │ │ └── serializer │ │ ├── VertexSerializer.java │ │ └── VertexSerializerRegistry.java │ ├── boot │ ├── java │ │ └── net │ │ │ └── caffeinemc │ │ │ └── mods │ │ │ └── sodium │ │ │ └── client │ │ │ ├── compatibility │ │ │ ├── checks │ │ │ │ ├── BugChecks.java │ │ │ │ ├── GraphicsDriverChecks.java │ │ │ │ ├── ModuleScanner.java │ │ │ │ ├── PostLaunchChecks.java │ │ │ │ └── PreLaunchChecks.java │ │ │ ├── environment │ │ │ │ ├── GlContextInfo.java │ │ │ │ ├── OsUtils.java │ │ │ │ └── probe │ │ │ │ │ ├── GraphicsAdapterInfo.java │ │ │ │ │ ├── GraphicsAdapterProbe.java │ │ │ │ │ └── GraphicsAdapterVendor.java │ │ │ └── workarounds │ │ │ │ ├── Workarounds.java │ │ │ │ ├── intel │ │ │ │ └── IntelWorkarounds.java │ │ │ │ └── nvidia │ │ │ │ ├── NvidiaDriverVersion.java │ │ │ │ └── NvidiaWorkarounds.java │ │ │ ├── console │ │ │ ├── Console.java │ │ │ ├── ConsoleSink.java │ │ │ └── message │ │ │ │ ├── Message.java │ │ │ │ └── MessageLevel.java │ │ │ └── platform │ │ │ ├── MessageBox.java │ │ │ ├── NativeWindowHandle.java │ │ │ ├── PlatformHelper.java │ │ │ ├── unix │ │ │ └── Libc.java │ │ │ └── windows │ │ │ ├── WindowsCommandLine.java │ │ │ ├── WindowsFileVersion.java │ │ │ └── api │ │ │ ├── Gdi32.java │ │ │ ├── Kernel32.java │ │ │ ├── Shell32.java │ │ │ ├── User32.java │ │ │ ├── d3dkmt │ │ │ ├── D3DKMT.java │ │ │ ├── D3DKMTAdapterInfoStruct.java │ │ │ ├── D3DKMTAdapterRegistryInfoStruct.java │ │ │ ├── D3DKMTEnumAdaptersStruct.java │ │ │ ├── D3DKMTOpenGLInfoStruct.java │ │ │ ├── D3DKMTQueryAdapterInfoStruct.java │ │ │ └── D3DKMTQueryAdapterInfoType.java │ │ │ ├── msgbox │ │ │ ├── MsgBoxCallback.java │ │ │ ├── MsgBoxCallbackI.java │ │ │ └── MsgBoxParamSw.java │ │ │ └── version │ │ │ ├── LanguageCodePage.java │ │ │ ├── QueryResult.java │ │ │ ├── Version.java │ │ │ ├── VersionFixedFileInfoStruct.java │ │ │ └── VersionInfo.java │ └── resources │ │ └── META-INF │ │ └── MANIFEST.MF │ ├── desktop │ └── java │ │ └── net │ │ └── caffeinemc │ │ └── mods │ │ └── sodium │ │ └── desktop │ │ ├── LaunchWarn.java │ │ └── utils │ │ └── browse │ │ ├── BrowseUrlHandler.java │ │ ├── CrossPlatformImpl.java │ │ └── XDGImpl.java │ └── main │ ├── java │ └── net │ │ └── caffeinemc │ │ └── mods │ │ └── sodium │ │ ├── client │ │ ├── SodiumClientMod.java │ │ ├── checks │ │ │ ├── ResourcePackScanner.java │ │ │ └── SodiumResourcePackMetadata.java │ │ ├── data │ │ │ ├── config │ │ │ │ └── MixinConfig.java │ │ │ └── fingerprint │ │ │ │ ├── FingerprintMeasure.java │ │ │ │ └── HashedFingerprint.java │ │ ├── gl │ │ │ ├── GlObject.java │ │ │ ├── arena │ │ │ │ ├── GlBufferArena.java │ │ │ │ ├── GlBufferSegment.java │ │ │ │ ├── PendingBufferCopyCommand.java │ │ │ │ ├── PendingUpload.java │ │ │ │ └── staging │ │ │ │ │ ├── FallbackStagingBuffer.java │ │ │ │ │ ├── MappedStagingBuffer.java │ │ │ │ │ └── StagingBuffer.java │ │ │ ├── array │ │ │ │ └── GlVertexArray.java │ │ │ ├── attribute │ │ │ │ ├── GlVertexAttribute.java │ │ │ │ ├── GlVertexAttributeBinding.java │ │ │ │ ├── GlVertexAttributeFormat.java │ │ │ │ └── GlVertexFormat.java │ │ │ ├── buffer │ │ │ │ ├── GlBuffer.java │ │ │ │ ├── GlBufferMapFlags.java │ │ │ │ ├── GlBufferMapping.java │ │ │ │ ├── GlBufferStorageFlags.java │ │ │ │ ├── GlBufferTarget.java │ │ │ │ ├── GlBufferUsage.java │ │ │ │ ├── GlImmutableBuffer.java │ │ │ │ └── GlMutableBuffer.java │ │ │ ├── device │ │ │ │ ├── CommandList.java │ │ │ │ ├── DrawCommandList.java │ │ │ │ ├── GLRenderDevice.java │ │ │ │ ├── MultiDrawBatch.java │ │ │ │ └── RenderDevice.java │ │ │ ├── functions │ │ │ │ ├── BufferStorageFunctions.java │ │ │ │ └── DeviceFunctions.java │ │ │ ├── shader │ │ │ │ ├── GlProgram.java │ │ │ │ ├── GlShader.java │ │ │ │ ├── ShaderConstants.java │ │ │ │ ├── ShaderLoader.java │ │ │ │ ├── ShaderParser.java │ │ │ │ ├── ShaderType.java │ │ │ │ ├── ShaderWorkarounds.java │ │ │ │ └── uniform │ │ │ │ │ ├── GlUniform.java │ │ │ │ │ ├── GlUniformBlock.java │ │ │ │ │ ├── GlUniformFloat.java │ │ │ │ │ ├── GlUniformFloat2v.java │ │ │ │ │ ├── GlUniformFloat3v.java │ │ │ │ │ ├── GlUniformFloat4v.java │ │ │ │ │ ├── GlUniformInt.java │ │ │ │ │ └── GlUniformMatrix4f.java │ │ │ ├── state │ │ │ │ └── GlStateTracker.java │ │ │ ├── sync │ │ │ │ └── GlFence.java │ │ │ ├── tessellation │ │ │ │ ├── GlAbstractTessellation.java │ │ │ │ ├── GlIndexType.java │ │ │ │ ├── GlPrimitiveType.java │ │ │ │ ├── GlTessellation.java │ │ │ │ ├── GlVertexArrayTessellation.java │ │ │ │ └── TessellationBinding.java │ │ │ └── util │ │ │ │ ├── EnumBit.java │ │ │ │ └── EnumBitField.java │ │ ├── gui │ │ │ ├── SodiumGameOptionPages.java │ │ │ ├── SodiumGameOptions.java │ │ │ ├── SodiumOptionsGUI.java │ │ │ ├── console │ │ │ │ ├── ConsoleHooks.java │ │ │ │ └── ConsoleRenderer.java │ │ │ ├── options │ │ │ │ ├── Option.java │ │ │ │ ├── OptionFlag.java │ │ │ │ ├── OptionGroup.java │ │ │ │ ├── OptionImpact.java │ │ │ │ ├── OptionImpl.java │ │ │ │ ├── OptionPage.java │ │ │ │ ├── TextProvider.java │ │ │ │ ├── binding │ │ │ │ │ ├── GenericBinding.java │ │ │ │ │ ├── OptionBinding.java │ │ │ │ │ └── compat │ │ │ │ │ │ └── VanillaBooleanOptionBinding.java │ │ │ │ ├── control │ │ │ │ │ ├── Control.java │ │ │ │ │ ├── ControlElement.java │ │ │ │ │ ├── ControlValueFormatter.java │ │ │ │ │ ├── CyclingControl.java │ │ │ │ │ ├── SliderControl.java │ │ │ │ │ └── TickBoxControl.java │ │ │ │ └── storage │ │ │ │ │ ├── MinecraftOptionsStorage.java │ │ │ │ │ ├── OptionStorage.java │ │ │ │ │ └── SodiumOptionsStorage.java │ │ │ ├── prompt │ │ │ │ ├── ScreenPrompt.java │ │ │ │ └── ScreenPromptable.java │ │ │ ├── screen │ │ │ │ └── ConfigCorruptedScreen.java │ │ │ └── widgets │ │ │ │ ├── AbstractWidget.java │ │ │ │ └── FlatButtonWidget.java │ │ ├── model │ │ │ ├── color │ │ │ │ ├── ColorProvider.java │ │ │ │ ├── ColorProviderRegistry.java │ │ │ │ ├── DefaultColorProviders.java │ │ │ │ └── interop │ │ │ │ │ └── BlockColorsExtension.java │ │ │ ├── light │ │ │ │ ├── LightMode.java │ │ │ │ ├── LightPipeline.java │ │ │ │ ├── LightPipelineProvider.java │ │ │ │ ├── data │ │ │ │ │ ├── ArrayLightDataCache.java │ │ │ │ │ ├── HashLightDataCache.java │ │ │ │ │ ├── LightDataAccess.java │ │ │ │ │ ├── QuadLightData.java │ │ │ │ │ └── SingleBlockLightDataCache.java │ │ │ │ ├── flat │ │ │ │ │ └── FlatLightPipeline.java │ │ │ │ └── smooth │ │ │ │ │ ├── AoCompletionFlags.java │ │ │ │ │ ├── AoFaceData.java │ │ │ │ │ ├── AoNeighborInfo.java │ │ │ │ │ └── SmoothLightPipeline.java │ │ │ └── quad │ │ │ │ ├── BakedQuadView.java │ │ │ │ ├── ModelQuad.java │ │ │ │ ├── ModelQuadView.java │ │ │ │ ├── ModelQuadViewMutable.java │ │ │ │ ├── blender │ │ │ │ └── BlendedColorProvider.java │ │ │ │ └── properties │ │ │ │ ├── ModelQuadFacing.java │ │ │ │ ├── ModelQuadFlags.java │ │ │ │ ├── ModelQuadOrientation.java │ │ │ │ └── ModelQuadWinding.java │ │ ├── render │ │ │ ├── SodiumWorldRenderer.java │ │ │ ├── chunk │ │ │ │ ├── BlockEntityRenderHandlerImpl.java │ │ │ │ ├── ChunkRenderMatrices.java │ │ │ │ ├── ChunkRenderer.java │ │ │ │ ├── ChunkUpdateType.java │ │ │ │ ├── DefaultChunkRenderer.java │ │ │ │ ├── ExtendedBlockEntityType.java │ │ │ │ ├── LocalSectionIndex.java │ │ │ │ ├── NonStoringBuilderPool.java │ │ │ │ ├── RenderSection.java │ │ │ │ ├── RenderSectionFlags.java │ │ │ │ ├── RenderSectionManager.java │ │ │ │ ├── ShaderChunkRenderer.java │ │ │ │ ├── SharedQuadIndexBuffer.java │ │ │ │ ├── compile │ │ │ │ │ ├── BuilderTaskOutput.java │ │ │ │ │ ├── ChunkBuildBuffers.java │ │ │ │ │ ├── ChunkBuildContext.java │ │ │ │ │ ├── ChunkBuildOutput.java │ │ │ │ │ ├── ChunkSortOutput.java │ │ │ │ │ ├── buffers │ │ │ │ │ │ ├── BakedChunkModelBuilder.java │ │ │ │ │ │ ├── ChunkModelBuilder.java │ │ │ │ │ │ └── ChunkVertexConsumer.java │ │ │ │ │ ├── executor │ │ │ │ │ │ ├── ChunkBuilder.java │ │ │ │ │ │ ├── ChunkJob.java │ │ │ │ │ │ ├── ChunkJobCollector.java │ │ │ │ │ │ ├── ChunkJobQueue.java │ │ │ │ │ │ ├── ChunkJobResult.java │ │ │ │ │ │ └── ChunkJobTyped.java │ │ │ │ │ ├── pipeline │ │ │ │ │ │ ├── BlockOcclusionCache.java │ │ │ │ │ │ ├── BlockRenderCache.java │ │ │ │ │ │ ├── BlockRenderContext.java │ │ │ │ │ │ ├── BlockRenderer.java │ │ │ │ │ │ ├── DefaultFluidRenderer.java │ │ │ │ │ │ ├── FluidRenderer.java │ │ │ │ │ │ ├── SpriteContentsExtension.java │ │ │ │ │ │ └── TextureAtlasSpriteExtension.java │ │ │ │ │ └── tasks │ │ │ │ │ │ ├── ChunkBuilderMeshingTask.java │ │ │ │ │ │ ├── ChunkBuilderSortingTask.java │ │ │ │ │ │ └── ChunkBuilderTask.java │ │ │ │ ├── data │ │ │ │ │ ├── BuiltSectionInfo.java │ │ │ │ │ ├── BuiltSectionMeshParts.java │ │ │ │ │ ├── SectionRenderDataStorage.java │ │ │ │ │ └── SectionRenderDataUnsafe.java │ │ │ │ ├── lists │ │ │ │ │ ├── ChunkRenderList.java │ │ │ │ │ ├── ChunkRenderListIterable.java │ │ │ │ │ ├── SortedRenderLists.java │ │ │ │ │ └── VisibleChunkCollector.java │ │ │ │ ├── map │ │ │ │ │ ├── ChunkStatus.java │ │ │ │ │ ├── ChunkTracker.java │ │ │ │ │ ├── ChunkTrackerHolder.java │ │ │ │ │ └── ClientChunkEventListener.java │ │ │ │ ├── occlusion │ │ │ │ │ ├── GraphDirection.java │ │ │ │ │ ├── GraphDirectionSet.java │ │ │ │ │ ├── OcclusionCuller.java │ │ │ │ │ └── VisibilityEncoding.java │ │ │ │ ├── region │ │ │ │ │ ├── RenderRegion.java │ │ │ │ │ └── RenderRegionManager.java │ │ │ │ ├── shader │ │ │ │ │ ├── ChunkFogMode.java │ │ │ │ │ ├── ChunkShaderBindingPoints.java │ │ │ │ │ ├── ChunkShaderFogComponent.java │ │ │ │ │ ├── ChunkShaderInterface.java │ │ │ │ │ ├── ChunkShaderOptions.java │ │ │ │ │ ├── ChunkShaderTextureSlot.java │ │ │ │ │ ├── DefaultShaderInterface.java │ │ │ │ │ └── ShaderBindingContext.java │ │ │ │ ├── terrain │ │ │ │ │ ├── DefaultTerrainRenderPasses.java │ │ │ │ │ ├── TerrainRenderPass.java │ │ │ │ │ └── material │ │ │ │ │ │ ├── DefaultMaterials.java │ │ │ │ │ │ ├── Material.java │ │ │ │ │ │ └── parameters │ │ │ │ │ │ ├── AlphaCutoffParameter.java │ │ │ │ │ │ └── MaterialParameters.java │ │ │ │ ├── translucent_sorting │ │ │ │ │ ├── SortBehavior.java │ │ │ │ │ ├── SortType.java │ │ │ │ │ ├── TQuad.java │ │ │ │ │ ├── TranslucentGeometryCollector.java │ │ │ │ │ ├── bsp_tree │ │ │ │ │ │ ├── BSPBuildFailureException.java │ │ │ │ │ │ ├── BSPNode.java │ │ │ │ │ │ ├── BSPResult.java │ │ │ │ │ │ ├── BSPSortState.java │ │ │ │ │ │ ├── BSPWorkspace.java │ │ │ │ │ │ ├── InnerBinaryPartitionBSPNode.java │ │ │ │ │ │ ├── InnerFixedDoubleBSPNode.java │ │ │ │ │ │ ├── InnerMultiPartitionBSPNode.java │ │ │ │ │ │ ├── InnerPartitionBSPNode.java │ │ │ │ │ │ ├── LeafDoubleBSPNode.java │ │ │ │ │ │ ├── LeafMultiBSPNode.java │ │ │ │ │ │ ├── LeafSingleBSPNode.java │ │ │ │ │ │ └── Partition.java │ │ │ │ │ ├── data │ │ │ │ │ │ ├── AnyOrderData.java │ │ │ │ │ │ ├── CombinedCameraPos.java │ │ │ │ │ │ ├── DynamicBSPData.java │ │ │ │ │ │ ├── DynamicData.java │ │ │ │ │ │ ├── DynamicSorter.java │ │ │ │ │ │ ├── DynamicTopoData.java │ │ │ │ │ │ ├── MixedDirectionData.java │ │ │ │ │ │ ├── NoData.java │ │ │ │ │ │ ├── PresentSortData.java │ │ │ │ │ │ ├── PresentSorter.java │ │ │ │ │ │ ├── PresentTranslucentData.java │ │ │ │ │ │ ├── SharedIndexSorter.java │ │ │ │ │ │ ├── Sorter.java │ │ │ │ │ │ ├── SplitDirectionData.java │ │ │ │ │ │ ├── StaticNormalRelativeData.java │ │ │ │ │ │ ├── StaticSorter.java │ │ │ │ │ │ ├── StaticTopoData.java │ │ │ │ │ │ ├── TopoGraphSorting.java │ │ │ │ │ │ └── TranslucentData.java │ │ │ │ │ └── trigger │ │ │ │ │ │ ├── CameraMovement.java │ │ │ │ │ │ ├── DirectTriggers.java │ │ │ │ │ │ ├── GFNITriggers.java │ │ │ │ │ │ ├── GeometryPlanes.java │ │ │ │ │ │ ├── Group.java │ │ │ │ │ │ ├── NormalList.java │ │ │ │ │ │ ├── NormalPlanes.java │ │ │ │ │ │ └── SortTriggering.java │ │ │ │ └── vertex │ │ │ │ │ ├── builder │ │ │ │ │ └── ChunkMeshBufferBuilder.java │ │ │ │ │ └── format │ │ │ │ │ ├── ChunkMeshFormats.java │ │ │ │ │ ├── ChunkVertexEncoder.java │ │ │ │ │ ├── ChunkVertexType.java │ │ │ │ │ └── impl │ │ │ │ │ ├── CompactChunkVertex.java │ │ │ │ │ └── DefaultChunkMeshAttributes.java │ │ │ ├── frapi │ │ │ │ ├── SodiumRenderer.java │ │ │ │ ├── helper │ │ │ │ │ ├── ColorHelper.java │ │ │ │ │ ├── GeometryHelper.java │ │ │ │ │ ├── NormalHelper.java │ │ │ │ │ └── TextureHelper.java │ │ │ │ ├── material │ │ │ │ │ ├── MaterialFinderImpl.java │ │ │ │ │ ├── MaterialViewImpl.java │ │ │ │ │ └── RenderMaterialImpl.java │ │ │ │ ├── mesh │ │ │ │ │ ├── EncodingFormat.java │ │ │ │ │ ├── MeshImpl.java │ │ │ │ │ ├── MutableMeshImpl.java │ │ │ │ │ ├── MutableQuadViewImpl.java │ │ │ │ │ └── QuadViewImpl.java │ │ │ │ └── render │ │ │ │ │ ├── AbstractBlockRenderContext.java │ │ │ │ │ ├── AbstractRenderContext.java │ │ │ │ │ ├── AmbientOcclusionMode.java │ │ │ │ │ ├── ItemRenderContext.java │ │ │ │ │ ├── NonTerrainBlockRenderContext.java │ │ │ │ │ └── QuadEncoder.java │ │ │ ├── immediate │ │ │ │ ├── CloudRenderer.java │ │ │ │ └── model │ │ │ │ │ ├── BakedModelEncoder.java │ │ │ │ │ ├── EntityRenderer.java │ │ │ │ │ └── ModelCuboid.java │ │ │ ├── texture │ │ │ │ ├── SpriteContentsExtension.java │ │ │ │ ├── SpriteFinderCache.java │ │ │ │ ├── SpriteUtil.java │ │ │ │ └── SpriteUtilImpl.java │ │ │ ├── util │ │ │ │ ├── DeferredRenderTask.java │ │ │ │ └── RenderAsserts.java │ │ │ ├── vertex │ │ │ │ ├── VertexConsumerTracker.java │ │ │ │ ├── VertexConsumerUtils.java │ │ │ │ ├── VertexFormatAttribute.java │ │ │ │ ├── VertexFormatRegistryImpl.java │ │ │ │ ├── buffer │ │ │ │ │ └── BufferBuilderExtension.java │ │ │ │ └── serializers │ │ │ │ │ ├── VertexSerializerRegistryImpl.java │ │ │ │ │ └── generated │ │ │ │ │ └── VertexSerializerFactory.java │ │ │ └── viewport │ │ │ │ ├── CameraTransform.java │ │ │ │ ├── Viewport.java │ │ │ │ ├── ViewportProvider.java │ │ │ │ └── frustum │ │ │ │ ├── Frustum.java │ │ │ │ └── SimpleFrustum.java │ │ ├── services │ │ │ ├── FluidRendererFactory.java │ │ │ ├── PlatformBlockAccess.java │ │ │ ├── PlatformLevelAccess.java │ │ │ ├── PlatformLevelRenderHooks.java │ │ │ ├── PlatformMixinOverrides.java │ │ │ ├── PlatformModelAccess.java │ │ │ ├── PlatformRuntimeInformation.java │ │ │ ├── Services.java │ │ │ ├── SodiumModelData.java │ │ │ └── SodiumModelDataContainer.java │ │ ├── util │ │ │ ├── BitwiseMath.java │ │ │ ├── Dim2i.java │ │ │ ├── DirectionUtil.java │ │ │ ├── FileUtil.java │ │ │ ├── FlawlessFrames.java │ │ │ ├── Int2.java │ │ │ ├── ListUtil.java │ │ │ ├── MathUtil.java │ │ │ ├── ModelQuadUtil.java │ │ │ ├── NativeBuffer.java │ │ │ ├── NativeImageHelper.java │ │ │ ├── TextureUtil.java │ │ │ ├── UInt32.java │ │ │ ├── WeightedRandomListExtension.java │ │ │ ├── collections │ │ │ │ ├── BitArray.java │ │ │ │ ├── DoubleBufferedQueue.java │ │ │ │ ├── ReadQueue.java │ │ │ │ └── WriteQueue.java │ │ │ ├── color │ │ │ │ ├── BoxBlur.java │ │ │ │ ├── ColorSRGB.java │ │ │ │ └── FastCubicSampler.java │ │ │ ├── interval_tree │ │ │ │ ├── DoubleInterval.java │ │ │ │ ├── Interval.java │ │ │ │ ├── IntervalTree.java │ │ │ │ └── TreeNode.java │ │ │ ├── iterator │ │ │ │ ├── ByteArrayIterator.java │ │ │ │ ├── ByteIterator.java │ │ │ │ ├── ReversibleByteArrayIterator.java │ │ │ │ ├── ReversibleObjectArrayIterator.java │ │ │ │ └── WrappedIterator.java │ │ │ ├── sorting │ │ │ │ ├── RadixSort.java │ │ │ │ ├── VertexSorters.java │ │ │ │ └── VertexSortingExtended.java │ │ │ └── task │ │ │ │ └── CancellationToken.java │ │ └── world │ │ │ ├── BiomeSeedProvider.java │ │ │ ├── BitStorageExtension.java │ │ │ ├── LevelRendererExtension.java │ │ │ ├── LevelSlice.java │ │ │ ├── PalettedContainerROExtension.java │ │ │ ├── SodiumAuxiliaryLightManager.java │ │ │ ├── biome │ │ │ ├── BiomeColorMaps.java │ │ │ ├── LevelBiomeSlice.java │ │ │ └── LevelColorCache.java │ │ │ └── cloned │ │ │ ├── ChunkRenderContext.java │ │ │ ├── ClonedChunkSection.java │ │ │ └── ClonedChunkSectionCache.java │ │ └── mixin │ │ ├── MixinOption.java │ │ ├── SodiumMixinPlugin.java │ │ ├── core │ │ ├── MinecraftMixin.java │ │ ├── WindowMixin.java │ │ ├── gui │ │ │ └── LevelLoadStatusManagerMixin.java │ │ ├── model │ │ │ ├── TextureAtlasSpriteMixin.java │ │ │ └── colors │ │ │ │ └── BlockColorsMixin.java │ │ ├── render │ │ │ ├── BlockEntityTypeMixin.java │ │ │ ├── TextureAtlasMixin.java │ │ │ ├── VertexFormatMixin.java │ │ │ ├── frustum │ │ │ │ └── FrustumMixin.java │ │ │ ├── immediate │ │ │ │ └── consumer │ │ │ │ │ ├── BufferBuilderMixin.java │ │ │ │ │ ├── EntityOutlineGeneratorMixin.java │ │ │ │ │ ├── SheetedDecalTextureGeneratorMixin.java │ │ │ │ │ ├── SpriteCoordinateExpanderMixin.java │ │ │ │ │ └── VertexMultiConsumerMixin.java │ │ │ ├── texture │ │ │ │ └── TextureAtlasAccessor.java │ │ │ └── world │ │ │ │ ├── EntityRendererAccessor.java │ │ │ │ ├── LevelRendererMixin.java │ │ │ │ └── RenderBuffersMixin.java │ │ └── world │ │ │ ├── biome │ │ │ └── ClientLevelMixin.java │ │ │ ├── chunk │ │ │ ├── PalettedContainerMixin.java │ │ │ ├── SimpleBitStorageMixin.java │ │ │ └── ZeroBitStorageMixin.java │ │ │ └── map │ │ │ ├── ClientChunkCacheMixin.java │ │ │ ├── ClientLevelMixin.java │ │ │ └── ClientPacketListenerMixin.java │ │ ├── debug │ │ └── checks │ │ │ └── threading │ │ │ └── MixinRenderSystem.java │ │ ├── features │ │ ├── gui │ │ │ ├── hooks │ │ │ │ ├── console │ │ │ │ │ └── GameRendererMixin.java │ │ │ │ ├── debug │ │ │ │ │ └── DebugScreenOverlayMixin.java │ │ │ │ └── settings │ │ │ │ │ └── OptionsScreenMixin.java │ │ │ └── screen │ │ │ │ └── LevelLoadingScreenMixin.java │ │ ├── options │ │ │ ├── overlays │ │ │ │ └── GuiMixin.java │ │ │ ├── render_layers │ │ │ │ ├── ItemBlockRenderTypesMixin.java │ │ │ │ └── LeavesBlockMixin.java │ │ │ └── weather │ │ │ │ └── LevelRendererMixin.java │ │ ├── render │ │ │ ├── compositing │ │ │ │ └── RenderTargetMixin.java │ │ │ ├── entity │ │ │ │ ├── CubeMixin.java │ │ │ │ ├── ModelPartMixin.java │ │ │ │ ├── cull │ │ │ │ │ └── EntityRendererMixin.java │ │ │ │ └── shadows │ │ │ │ │ └── EntityRenderDispatcherMixin.java │ │ │ ├── frapi │ │ │ │ ├── BakedModelMixin.java │ │ │ │ ├── ItemRendererAccessor.java │ │ │ │ ├── ItemRendererMixin.java │ │ │ │ └── ModelBlockRendererMixin.java │ │ │ ├── gui │ │ │ │ ├── font │ │ │ │ │ └── BakedGlyphMixin.java │ │ │ │ └── outlines │ │ │ │ │ └── LevelRendererMixin.java │ │ │ ├── immediate │ │ │ │ ├── DirectionMixin.java │ │ │ │ ├── buffer_builder │ │ │ │ │ ├── intrinsics │ │ │ │ │ │ └── BufferBuilderMixin.java │ │ │ │ │ └── sorting │ │ │ │ │ │ ├── MeshDataAccessor.java │ │ │ │ │ │ ├── MultiBufferSourceMixin.java │ │ │ │ │ │ └── VertexSortingMixin.java │ │ │ │ └── matrix_stack │ │ │ │ │ ├── PoseStackMixin.java │ │ │ │ │ └── VertexConsumerMixin.java │ │ │ ├── model │ │ │ │ ├── ItemBlockRenderTypesMixin.java │ │ │ │ └── item │ │ │ │ │ └── ItemRendererMixin.java │ │ │ ├── particle │ │ │ │ └── SingleQuadParticleMixin.java │ │ │ └── world │ │ │ │ ├── clouds │ │ │ │ └── LevelRendererMixin.java │ │ │ │ └── sky │ │ │ │ ├── ClientLevelMixin.java │ │ │ │ ├── FogRendererMixin.java │ │ │ │ └── LevelRendererMixin.java │ │ ├── shader │ │ │ └── uniform │ │ │ │ └── ShaderInstanceMixin.java │ │ └── textures │ │ │ ├── NativeImageAccessor.java │ │ │ ├── SpriteContentsInvoker.java │ │ │ ├── animations │ │ │ ├── tracking │ │ │ │ ├── AnimatedTextureAccessor.java │ │ │ │ ├── GuiGraphicsMixin.java │ │ │ │ ├── ModelBlockRendererMixin.java │ │ │ │ ├── SpriteContentsFrameInfoAccessor.java │ │ │ │ ├── SpriteContentsMixin.java │ │ │ │ ├── SpriteContentsTickerMixin.java │ │ │ │ ├── TextureAtlasMixin.java │ │ │ │ └── TextureSheetParticleMixin.java │ │ │ └── upload │ │ │ │ ├── SpriteContentsAccessor.java │ │ │ │ ├── SpriteContentsAnimatedTextureAccessor.java │ │ │ │ ├── SpriteContentsFrameInfoAccessor.java │ │ │ │ ├── SpriteContentsInterpolationMixin.java │ │ │ │ └── SpriteContentsTickerAccessor.java │ │ │ ├── mipmaps │ │ │ ├── MipmapGeneratorMixin.java │ │ │ └── SpriteContentsMixin.java │ │ │ └── scan │ │ │ ├── SpriteContentsMixin.java │ │ │ └── TextureAtlasSpriteMixin.java │ │ └── workarounds │ │ ├── context_creation │ │ └── WindowMixin.java │ │ └── event_loop │ │ └── RenderSystemMixin.java │ └── resources │ ├── assets │ ├── minecraft │ │ ├── models │ │ │ └── block │ │ │ │ ├── README.txt │ │ │ │ ├── beacon.json │ │ │ │ ├── bell_floor.json │ │ │ │ ├── brewing_stand.json │ │ │ │ ├── cauldron.json │ │ │ │ ├── composter.json │ │ │ │ ├── cube_all_inner_faces.json │ │ │ │ ├── cube_bottom_top_inner_faces.json │ │ │ │ ├── flower_pot.json │ │ │ │ ├── flower_pot_cross.json │ │ │ │ ├── flower_pot_cross_emissive.json │ │ │ │ ├── heavy_core.json │ │ │ │ ├── hopper.json │ │ │ │ ├── hopper_side.json │ │ │ │ ├── inner_stairs.json │ │ │ │ ├── lightning_rod.json │ │ │ │ ├── lightning_rod_on.json │ │ │ │ ├── mangrove_propagule_hanging_0.json │ │ │ │ ├── mangrove_propagule_hanging_1.json │ │ │ │ ├── mangrove_propagule_hanging_2.json │ │ │ │ ├── mangrove_propagule_hanging_3.json │ │ │ │ ├── mangrove_propagule_hanging_4.json │ │ │ │ ├── potted_bamboo.json │ │ │ │ ├── potted_mangrove_propagule.json │ │ │ │ ├── stairs.json │ │ │ │ ├── template_anvil.json │ │ │ │ ├── template_cake_with_candle.json │ │ │ │ ├── template_cauldron_full.json │ │ │ │ ├── template_cauldron_level1.json │ │ │ │ ├── template_cauldron_level2.json │ │ │ │ ├── template_chorus_flower.json │ │ │ │ ├── template_four_turtle_eggs.json │ │ │ │ ├── template_hanging_lantern.json │ │ │ │ ├── template_item_frame.json │ │ │ │ ├── template_item_frame_map.json │ │ │ │ ├── template_potted_azalea_bush.json │ │ │ │ ├── template_vault.json │ │ │ │ └── tinted_flower_pot_cross.json │ │ └── textures │ │ │ └── block │ │ │ ├── acacia_leaves.png │ │ │ ├── azalea_leaves.png │ │ │ ├── birch_leaves.png │ │ │ ├── cherry_leaves.png │ │ │ ├── dark_oak_leaves.png │ │ │ ├── flowering_azalea_leaves.png │ │ │ ├── jungle_leaves.png │ │ │ ├── mangrove_leaves.png │ │ │ ├── oak_leaves.png │ │ │ ├── pale_oak_leaves.png │ │ │ └── spruce_leaves.png │ └── sodium │ │ ├── lang │ │ └── en_us.json │ │ ├── shaders │ │ ├── blocks │ │ │ ├── block_layer_opaque.fsh │ │ │ └── block_layer_opaque.vsh │ │ ├── clouds.fsh │ │ ├── clouds.json │ │ ├── clouds.vsh │ │ └── include │ │ │ ├── chunk_material.glsl │ │ │ ├── chunk_matrices.glsl │ │ │ ├── chunk_vertex.glsl │ │ │ └── fog.glsl │ │ └── textures │ │ └── gui │ │ └── arrows.png │ ├── programmer_art │ └── assets │ │ └── minecraft │ │ └── textures │ │ └── block │ │ ├── acacia_leaves.png │ │ ├── birch_leaves.png │ │ ├── dark_oak_leaves.png │ │ ├── jungle_leaves.png │ │ ├── oak_leaves.png │ │ └── spruce_leaves.png │ ├── sodium-common.accesswidener │ ├── sodium-common.mixins.json │ └── sodium-icon.png ├── fabric ├── build.gradle.kts └── src │ └── main │ ├── java │ └── net │ │ └── caffeinemc │ │ └── mods │ │ └── sodium │ │ ├── fabric │ │ ├── FabricMixinOverrides.java │ │ ├── FabricRuntimeInformation.java │ │ ├── SodiumFabricMod.java │ │ ├── SodiumPreLaunch.java │ │ ├── block │ │ │ └── FabricBlockAccess.java │ │ ├── level │ │ │ ├── FabricLevelAccess.java │ │ │ └── FabricLevelRenderHooks.java │ │ ├── model │ │ │ └── FabricModelAccess.java │ │ └── render │ │ │ ├── FabricColorProviders.java │ │ │ └── FluidRendererImpl.java │ │ └── mixin │ │ ├── core │ │ └── model │ │ │ └── quad │ │ │ └── BakedQuadMixin.java │ │ └── features │ │ ├── model │ │ ├── DelegateBakedModelMixin.java │ │ ├── MultiPartBakedModelMixin.java │ │ ├── WeightedBakedModelMixin.java │ │ └── WeightedRandomListMixin.java │ │ ├── render │ │ └── model │ │ │ └── block │ │ │ └── ModelBlockRendererMixin.java │ │ └── world │ │ └── biome │ │ └── BiomeMixin.java │ └── resources │ ├── META-INF │ └── services │ │ ├── net.caffeinemc.mods.sodium.client.services.FluidRendererFactory │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformMixinOverrides │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformModelAccess │ │ └── net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation │ ├── fabric.mod.json │ ├── sodium-fabric.accesswidener │ └── sodium-fabric.mixins.json ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── idea └── inspections.xml ├── neoforge ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── net │ │ │ └── caffeinemc │ │ │ └── mods │ │ │ └── sodium │ │ │ ├── mixin │ │ │ ├── core │ │ │ │ └── model │ │ │ │ │ └── quad │ │ │ │ │ └── BakedQuadMixin.java │ │ │ ├── features │ │ │ │ ├── model │ │ │ │ │ ├── DelegateBakedModelMixin.java │ │ │ │ │ ├── MultiPartBakedModelMixin.java │ │ │ │ │ ├── WeightedBakedModelMixin.java │ │ │ │ │ └── WeightedRandomListMixin.java │ │ │ │ ├── render │ │ │ │ │ └── model │ │ │ │ │ │ └── block │ │ │ │ │ │ └── ModelBlockRendererMixin.java │ │ │ │ └── world │ │ │ │ │ └── biome │ │ │ │ │ └── BiomeMixin.java │ │ │ └── platform │ │ │ │ └── neoforge │ │ │ │ ├── AbstractBlockRenderContextMixin.java │ │ │ │ ├── AuxiliaryLightManagerMixin.java │ │ │ │ ├── ChunkRenderTypeSetAccessor.java │ │ │ │ ├── ClientHooksMixin.java │ │ │ │ ├── EntrypointMixin.java │ │ │ │ ├── LevelSliceMixin.java │ │ │ │ ├── ModelDataMixin.java │ │ │ │ ├── ResourcePackLoaderMixin.java │ │ │ │ └── SimpleBakedModelAccessor.java │ │ │ └── neoforge │ │ │ ├── ForgeMixinOverrides.java │ │ │ ├── NeoForgeRuntimeInformation.java │ │ │ ├── SodiumForgeMod.java │ │ │ ├── block │ │ │ └── NeoForgeBlockAccess.java │ │ │ ├── level │ │ │ ├── NeoForgeLevelAccess.java │ │ │ └── NeoForgeLevelRenderHooks.java │ │ │ ├── model │ │ │ └── NeoForgeModelAccess.java │ │ │ └── render │ │ │ ├── FluidRendererImpl.java │ │ │ └── ForgeColorProviders.java │ └── resources │ │ ├── META-INF │ │ ├── accesstransformer.cfg │ │ ├── neoforge.mods.toml │ │ └── services │ │ │ ├── net.caffeinemc.mods.sodium.client.services.FluidRendererFactory │ │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess │ │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess │ │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks │ │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformMixinOverrides │ │ │ ├── net.caffeinemc.mods.sodium.client.services.PlatformModelAccess │ │ │ └── net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation │ │ └── sodium-neoforge.mixins.json │ └── service │ ├── java │ └── net │ │ └── caffeinemc │ │ └── mods │ │ └── sodium │ │ └── service │ │ └── SodiumWorkarounds.java │ └── resources │ └── META-INF │ └── services │ └── net.neoforged.neoforgespi.earlywindow.GraphicsBootstrapper ├── settings.gradle.kts └── thirdparty ├── NOTICE.txt └── licenses ├── LICENSE-APACHE-2.0.txt ├── LICENSE-MIT.txt └── LICENSE-MPL2.txt /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: For help with other issues, join our Discord community 4 | url: https://caffeinemc.net/discord 5 | about: This is the best option for getting help with mod installation, performance issues, and any other support inquiries 6 | # Copied from https://github.com/CaffeineMC/sodium#community 7 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/bug_fix.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug fix 3 | about: Use this template if you're creating a pull request which fixes another bug or issue 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Preface 11 | 12 | Make sure you have read our [Contributor Guidelines](/CONTRIBUTING.md) before submitting any pull requests to this 13 | repository. 14 | 15 | This section (Preface) should be removed before submitting your pull request. Doing so indicates that you have read 16 | and agreed to the terms laid out within. 17 | 18 | ### Linked Issues 19 | Provide links to the issue(s) which will be closed upon merging this pull request. There must be an open issue for 20 | pull requests which fix bugs or other issues. 21 | 22 | ### Proposed Changes 23 | Provide a detailed description of what your pull request changes. 24 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/new_feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug fix 3 | about: Use this template if you're creating a pull request which adds a feature or other enhancement 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Preface 11 | 12 | Make sure you have read our [Contributor Guidelines](/CONTRIBUTING.md) before submitting any pull requests to this 13 | repository. 14 | 15 | This section (Preface) should be removed before submitting your pull request. Doing so indicates that you have read 16 | and agreed to the terms laid out within. 17 | 18 | ### Proposed Changes 19 | 20 | Provide a detailed description of what your pull request changes. 21 | -------------------------------------------------------------------------------- /.github/workflows/build-commit.yml: -------------------------------------------------------------------------------- 1 | # Used when a commit is pushed to the repository 2 | # This makes use of caching for faster builds and uploads the resulting artifacts 3 | name: build-commit 4 | 5 | on: [ push ] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Extract current branch name 13 | shell: bash 14 | # bash pattern expansion to grab branch name without slashes 15 | run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT 16 | id: ref 17 | - name: Checkout sources 18 | uses: actions/checkout@v4 19 | 20 | - name: Validate Gradle Wrapper 21 | uses: gradle/actions/wrapper-validation@v3 22 | 23 | - name: Setup Java 21 24 | uses: actions/setup-java@v4 25 | with: 26 | distribution: temurin 27 | java-version: 21 28 | 29 | - name: Setup Gradle 30 | uses: gradle/actions/setup-gradle@v4 31 | with: 32 | cache-read-only: false 33 | 34 | - name: Execute Gradle build 35 | run: ./gradlew build 36 | 37 | - name: Upload artifacts 38 | uses: actions/upload-artifact@v4 39 | with: 40 | name: sodium-artifacts-${{ steps.ref.outputs.branch }} 41 | path: build/mods/*.jar -------------------------------------------------------------------------------- /.github/workflows/build-pull-request.yml: -------------------------------------------------------------------------------- 1 | # Used when building external pull requests 2 | # We don't want to publish build artifacts or expose our other caches to possibly untrusted code 3 | name: build-pull-request 4 | 5 | on: [ pull_request ] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: gradle/actions/wrapper-validation@v3 14 | - uses: actions/setup-java@v4 15 | with: 16 | distribution: temurin 17 | java-version: 21 18 | 19 | - name: Setup Gradle 20 | uses: gradle/actions/setup-gradle@v4 21 | with: 22 | cache-read-only: true 23 | 24 | - name: Execute Gradle build 25 | run: ./gradlew build 26 | 27 | - name: Upload artifacts 28 | uses: actions/upload-artifact@v4 29 | with: 30 | name: sodium-artifacts-${{ steps.ref.outputs.branch }} 31 | path: build/mods/*.jar -------------------------------------------------------------------------------- /.github/workflows/build-release.yml: -------------------------------------------------------------------------------- 1 | # Used when a release is pushed to GitHub 2 | # This does not make use of any caching as to ensure a clean build 3 | name: build-release 4 | 5 | on: 6 | release: 7 | types: 8 | - published 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: actions/setup-java@v4 16 | with: 17 | distribution: temurin 18 | java-version: 21 19 | 20 | - name: Setup Gradle 21 | uses: gradle/actions/setup-gradle@v4 22 | with: 23 | cache-read-only: true 24 | 25 | - name: Execute Gradle build 26 | run: ./gradlew build -Pbuild.release=true 27 | 28 | - name: Upload assets to GitHub 29 | uses: AButler/upload-release-assets@v2.0 30 | with: 31 | files: 'build/mods/*.jar' 32 | repo-token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/build-tag.yml: -------------------------------------------------------------------------------- 1 | # Used when a commit is tagged and pushed to the repository 2 | # This makes use of caching for faster builds and uploads the resulting artifacts 3 | name: build-tag 4 | 5 | on: 6 | push: 7 | tags: 8 | - '*' 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Extract current branch name 16 | shell: bash 17 | # bash pattern expansion to grab branch name without slashes 18 | run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT 19 | id: ref 20 | - name: Checkout sources 21 | uses: actions/checkout@v4 22 | - uses: actions/setup-java@v4 23 | with: 24 | distribution: temurin 25 | java-version: 21 26 | 27 | - name: Setup Gradle 28 | uses: gradle/actions/setup-gradle@v4 29 | with: 30 | cache-read-only: true 31 | 32 | - name: Execute Gradle build 33 | run: ./gradlew build -Pbuild.release=true 34 | 35 | - name: Upload artifacts 36 | uses: actions/upload-artifact@v4 37 | with: 38 | name: sodium-artifacts-${{ steps.ref.outputs.branch }} 39 | path: build/mods/*.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # idea 9 | 10 | .idea/ 11 | *.iml 12 | *.ipr 13 | *.iws 14 | 15 | # vscode 16 | 17 | .settings/ 18 | .vscode/ 19 | bin/ 20 | .classpath 21 | .project 22 | 23 | # fabric 24 | 25 | run/ 26 | neoforge/runs 27 | # macOS 28 | 29 | .DS_Store 30 | .AppleDouble 31 | .LSOverride 32 | 33 | # Kotlin compiler working directory 34 | .kotlin -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/build.gradle.kts -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | gradlePluginPortal() 8 | } 9 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/multiloader-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | id("idea") 4 | } 5 | 6 | group = "net.caffeinemc" 7 | version = BuildConfig.createVersionString(project) 8 | 9 | java.toolchain.languageVersion = JavaLanguageVersion.of(21) 10 | 11 | tasks.withType { 12 | options.encoding = "UTF-8" 13 | options.release.set(21) 14 | } 15 | 16 | tasks.withType().configureEach { 17 | enabled = false 18 | } 19 | 20 | repositories { 21 | exclusiveContent { 22 | forRepository { 23 | maven { 24 | name = "Modrinth" 25 | url = uri("https://api.modrinth.com/maven") 26 | } 27 | } 28 | filter { 29 | includeGroup("maven.modrinth") 30 | } 31 | } 32 | 33 | exclusiveContent { 34 | forRepository { 35 | maven { 36 | name = "Parchment" 37 | url = uri("https://maven.parchmentmc.org") 38 | } 39 | } 40 | filter { 41 | includeGroup("org.parchmentmc.data") 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /common/src/.gitignore: -------------------------------------------------------------------------------- 1 | jmh -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderPredicate.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.blockentity; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.level.BlockGetter; 5 | import net.minecraft.world.level.block.entity.BlockEntity; 6 | import org.jetbrains.annotations.ApiStatus; 7 | 8 | @ApiStatus.Experimental 9 | @ApiStatus.AvailableSince("0.6.0") 10 | @FunctionalInterface 11 | public interface BlockEntityRenderPredicate { 12 | boolean shouldRender(BlockGetter blockGetter, BlockPos blockPos, T entity); 13 | } 14 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/internal/package-info.java: -------------------------------------------------------------------------------- 1 | @ApiStatus.Internal 2 | package net.caffeinemc.mods.sodium.api.internal; 3 | 4 | import org.jetbrains.annotations.ApiStatus; -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/attributes/common/ColorAttribute.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.attributes.common; 2 | 3 | import org.lwjgl.system.MemoryUtil; 4 | 5 | public class ColorAttribute { 6 | public static void set(long ptr, int color) { 7 | MemoryUtil.memPutInt(ptr, color); 8 | } 9 | 10 | public static int get(long ptr) { 11 | return MemoryUtil.memGetInt(ptr); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/attributes/common/LightAttribute.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.attributes.common; 2 | 3 | import org.lwjgl.system.MemoryUtil; 4 | 5 | public class LightAttribute { 6 | public static void set(long ptr, int light) { 7 | MemoryUtil.memPutInt(ptr + 0, light); 8 | } 9 | 10 | public static int get(long ptr) { 11 | return MemoryUtil.memGetInt(ptr); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/attributes/common/NormalAttribute.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.attributes.common; 2 | 3 | import org.lwjgl.system.MemoryUtil; 4 | 5 | public class NormalAttribute { 6 | public static void set(long ptr, int normal) { 7 | MemoryUtil.memPutInt(ptr, normal); 8 | } 9 | 10 | public static int get(long ptr) { 11 | return MemoryUtil.memGetInt(ptr); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/attributes/common/OverlayAttribute.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.attributes.common; 2 | 3 | import org.lwjgl.system.MemoryUtil; 4 | 5 | public class OverlayAttribute { 6 | public static void set(long ptr, int overlay) { 7 | MemoryUtil.memPutInt(ptr + 0, overlay); 8 | } 9 | 10 | public static int get(long ptr) { 11 | return MemoryUtil.memGetInt(ptr); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/attributes/common/PositionAttribute.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.attributes.common; 2 | 3 | import org.lwjgl.system.MemoryUtil; 4 | 5 | public class PositionAttribute { 6 | public static void put(long ptr, float x, float y, float z) { 7 | MemoryUtil.memPutFloat(ptr + 0L, x); 8 | MemoryUtil.memPutFloat(ptr + 4L, y); 9 | MemoryUtil.memPutFloat(ptr + 8L, z); 10 | } 11 | 12 | public static float getX(long ptr) { 13 | return MemoryUtil.memGetFloat(ptr + 0L); 14 | } 15 | 16 | public static float getY(long ptr) { 17 | return MemoryUtil.memGetFloat(ptr + 4L); 18 | } 19 | 20 | public static float getZ(long ptr) { 21 | return MemoryUtil.memGetFloat(ptr + 8L); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/attributes/common/TextureAttribute.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.attributes.common; 2 | 3 | import org.joml.Vector2f; 4 | import org.lwjgl.system.MemoryUtil; 5 | 6 | public class TextureAttribute { 7 | public static void put(long ptr, Vector2f vec) { 8 | put(ptr, vec.x(), vec.y()); 9 | } 10 | 11 | public static void put(long ptr, float u, float v) { 12 | MemoryUtil.memPutFloat(ptr + 0, u); 13 | MemoryUtil.memPutFloat(ptr + 4, v); 14 | } 15 | 16 | public static Vector2f get(long ptr) { 17 | return new Vector2f(getU(ptr), getV(ptr)); 18 | } 19 | 20 | public static float getU(long ptr) { 21 | return MemoryUtil.memGetFloat(ptr + 0); 22 | } 23 | 24 | public static float getV(long ptr) { 25 | return MemoryUtil.memGetFloat(ptr + 4); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/format/VertexFormatExtensions.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.format; 2 | 3 | public interface VertexFormatExtensions { 4 | /** 5 | * Returns an integer identifier that represents this vertex format in the global namespace. These identifiers 6 | * are valid only for the current process lifetime and should not be saved to disk. 7 | */ 8 | int sodium$getGlobalId(); 9 | } 10 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/format/VertexFormatRegistry.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.format; 2 | 3 | import com.mojang.blaze3d.vertex.VertexFormat; 4 | import net.caffeinemc.mods.sodium.api.internal.DependencyInjection; 5 | 6 | public interface VertexFormatRegistry { 7 | VertexFormatRegistry INSTANCE = DependencyInjection.load(VertexFormatRegistry.class, 8 | "net.caffeinemc.mods.sodium.client.render.vertex.VertexFormatRegistryImpl"); 9 | 10 | static VertexFormatRegistry instance() { 11 | return INSTANCE; 12 | } 13 | 14 | int allocateGlobalId(VertexFormat format); 15 | } -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/format/common/LineVertex.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.format.common; 2 | 3 | import com.mojang.blaze3d.vertex.DefaultVertexFormat; 4 | import com.mojang.blaze3d.vertex.VertexFormat; 5 | import net.caffeinemc.mods.sodium.api.vertex.attributes.common.ColorAttribute; 6 | import net.caffeinemc.mods.sodium.api.vertex.attributes.common.NormalAttribute; 7 | import net.caffeinemc.mods.sodium.api.vertex.attributes.common.PositionAttribute; 8 | 9 | public final class LineVertex { 10 | public static final VertexFormat FORMAT = DefaultVertexFormat.POSITION_COLOR_NORMAL; 11 | 12 | public static final int STRIDE = 20; 13 | 14 | private static final int OFFSET_POSITION = 0; 15 | private static final int OFFSET_COLOR = 12; 16 | private static final int OFFSET_NORMAL = 16; 17 | 18 | public static void put(long ptr, 19 | float x, float y, float z, int color, int normal) { 20 | PositionAttribute.put(ptr + OFFSET_POSITION, x, y, z); 21 | ColorAttribute.set(ptr + OFFSET_COLOR, color); 22 | NormalAttribute.set(ptr + OFFSET_NORMAL, normal); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/serializer/VertexSerializer.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.serializer; 2 | 3 | public interface VertexSerializer { 4 | void serialize(long srcBuffer, long dstBuffer, int count); 5 | } 6 | -------------------------------------------------------------------------------- /common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/serializer/VertexSerializerRegistry.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.api.vertex.serializer; 2 | 3 | import com.mojang.blaze3d.vertex.VertexFormat; 4 | import net.caffeinemc.mods.sodium.api.internal.DependencyInjection; 5 | 6 | public interface VertexSerializerRegistry { 7 | VertexSerializerRegistry INSTANCE = DependencyInjection.load(VertexSerializerRegistry.class, 8 | "net.caffeinemc.mods.sodium.client.render.vertex.serializers.VertexSerializerRegistryImpl"); 9 | 10 | static VertexSerializerRegistry instance() { 11 | return INSTANCE; 12 | } 13 | 14 | VertexSerializer get(VertexFormat srcFormat, VertexFormat dstFormat); 15 | 16 | void registerSerializer(VertexFormat srcFormat, VertexFormat dstFormat, VertexSerializer serializer); 17 | } 18 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/compatibility/environment/GlContextInfo.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.compatibility.environment; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.lwjgl.opengl.GL11C; 5 | 6 | import java.util.Objects; 7 | 8 | public record GlContextInfo(String vendor, String renderer, String version) { 9 | public static GlContextInfo create() { 10 | String vendor = Objects.requireNonNull(GL11C.glGetString(GL11C.GL_VENDOR), 11 | "GL_VENDOR is NULL"); 12 | String renderer = Objects.requireNonNull(GL11C.glGetString(GL11C.GL_RENDERER), 13 | "GL_RENDERER is NULL"); 14 | String version = Objects.requireNonNull(GL11C.glGetString(GL11C.GL_VERSION), 15 | "GL_VERSION is NULL"); 16 | 17 | return new GlContextInfo(vendor, renderer, version); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/compatibility/environment/OsUtils.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.compatibility.environment; 2 | 3 | import java.util.Locale; 4 | 5 | public class OsUtils { 6 | private static final OperatingSystem OS = determineOs(); 7 | 8 | public static OperatingSystem determineOs() { 9 | var name = System.getProperty("os.name"); 10 | 11 | if (name != null) { 12 | var normalized = name.toLowerCase(Locale.ROOT); 13 | 14 | if (normalized.startsWith("windows")) { 15 | return OperatingSystem.WIN; 16 | } else if (normalized.startsWith("mac")) { 17 | return OperatingSystem.MAC; 18 | } else if (normalized.startsWith("linux")) { 19 | return OperatingSystem.LINUX; 20 | } 21 | } 22 | 23 | return OperatingSystem.UNKNOWN; 24 | } 25 | 26 | public static OperatingSystem getOs() { 27 | return OS; 28 | } 29 | 30 | public enum OperatingSystem { 31 | WIN, 32 | MAC, 33 | LINUX, 34 | UNKNOWN 35 | } 36 | } -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/compatibility/environment/probe/GraphicsAdapterInfo.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.compatibility.environment.probe; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public interface GraphicsAdapterInfo { 6 | @NotNull GraphicsAdapterVendor vendor(); 7 | 8 | @NotNull String name(); 9 | 10 | record LinuxPciAdapterInfo( 11 | @NotNull GraphicsAdapterVendor vendor, 12 | @NotNull String name, 13 | 14 | String pciVendorId, 15 | String pciDeviceId 16 | ) implements GraphicsAdapterInfo { 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/compatibility/workarounds/nvidia/NvidiaDriverVersion.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.compatibility.workarounds.nvidia; 2 | 3 | import net.caffeinemc.mods.sodium.client.platform.windows.WindowsFileVersion; 4 | 5 | public record NvidiaDriverVersion(int major, int minor) { 6 | public static NvidiaDriverVersion parse(WindowsFileVersion version) { 7 | // NVIDIA drivers use a strange versioning format, where the major/minor are concatenated into 8 | // the end of the file version. For example, driver 526.47 is represented as X.Y.15.2657, where 9 | // the X and Y values are the usual for WDDM drivers. 10 | int merged = (((version.z() - 10) * 10_000) + version.w()); 11 | int major = merged / 100; 12 | int minor = merged % 100; 13 | 14 | return new NvidiaDriverVersion(major, minor); 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "%d.%d".formatted(this.major, this.minor); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/console/Console.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.console; 2 | 3 | import net.caffeinemc.mods.sodium.client.console.message.Message; 4 | import net.caffeinemc.mods.sodium.client.console.message.MessageLevel; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.ArrayDeque; 8 | import java.util.Deque; 9 | import java.util.Objects; 10 | 11 | public class Console implements ConsoleSink { 12 | public static final Console INSTANCE = new Console(); 13 | 14 | private final ArrayDeque messages = new ArrayDeque<>(); 15 | 16 | @Override 17 | public void logMessage(@NotNull MessageLevel level, @NotNull String text, boolean translatable, double duration) { 18 | Objects.requireNonNull(level); 19 | Objects.requireNonNull(text); 20 | 21 | this.messages.addLast(new Message(level, text, translatable, duration)); 22 | } 23 | 24 | public Deque getMessageDrain() { 25 | return this.messages; 26 | } 27 | 28 | public static ConsoleSink instance() { 29 | return INSTANCE; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/console/ConsoleSink.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.console; 2 | 3 | import net.caffeinemc.mods.sodium.client.console.message.MessageLevel; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public interface ConsoleSink { 7 | void logMessage(@NotNull MessageLevel level, @NotNull String text, boolean translatable, double duration); 8 | } 9 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/console/message/Message.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.console.message; 2 | 3 | public record Message(MessageLevel level, String text, boolean translated, double duration) { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/console/message/MessageLevel.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.console.message; 2 | 3 | public enum MessageLevel { 4 | INFO, 5 | WARN, 6 | SEVERE 7 | } 8 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/platform/NativeWindowHandle.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.platform; 2 | 3 | public interface NativeWindowHandle { 4 | long getWin32Handle(); 5 | } 6 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/platform/unix/Libc.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.platform.unix; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.lwjgl.system.*; 5 | 6 | public class Libc { 7 | private static final SharedLibrary LIBRARY = APIUtil.apiCreateLibrary("libc.so.6"); 8 | 9 | private static final long PFN_setenv; 10 | 11 | static { 12 | PFN_setenv = APIUtil.apiGetFunctionAddress(LIBRARY, "setenv"); 13 | } 14 | 15 | public static void setEnvironmentVariable(String name, @Nullable String value) { 16 | try (var stack = MemoryStack.stackPush()) { 17 | var nameBuf = stack.UTF8(name); 18 | var valueBuf = value != null ? stack.UTF8(value) : null; 19 | 20 | JNI.callPPI(MemoryUtil.memAddress(nameBuf), MemoryUtil.memAddressSafe(valueBuf), 1 /* replace */, PFN_setenv); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/platform/windows/WindowsFileVersion.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.platform.windows; 2 | 3 | import net.caffeinemc.mods.sodium.client.platform.windows.api.version.VersionFixedFileInfoStruct; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public record WindowsFileVersion(int x, int y, int z, int w) { 7 | public static @NotNull WindowsFileVersion fromFileVersion(VersionFixedFileInfoStruct fileVersion) { 8 | int x = (fileVersion.getFileVersionMostSignificantBits() >>> 16) & 0xffff; 9 | int y = (fileVersion.getFileVersionMostSignificantBits() >>> 0) & 0xffff; 10 | int z = (fileVersion.getFileVersionLeastSignificantBits() >>> 16) & 0xffff; 11 | int w = (fileVersion.getFileVersionLeastSignificantBits() >>> 0) & 0xffff; 12 | 13 | return new WindowsFileVersion(x, y, z, w); 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return "%s.%s.%s.%s".formatted(this.x, this.y, this.z, this.w); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/platform/windows/api/User32.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.platform.windows.api; 2 | 3 | import net.caffeinemc.mods.sodium.client.platform.windows.api.msgbox.MsgBoxParamSw; 4 | import org.lwjgl.system.APIUtil; 5 | import org.lwjgl.system.JNI; 6 | import org.lwjgl.system.SharedLibrary; 7 | 8 | import static org.lwjgl.system.APIUtil.apiGetFunctionAddress; 9 | 10 | public class User32 { 11 | private static final SharedLibrary LIBRARY = APIUtil.apiCreateLibrary("user32"); 12 | 13 | private static final long PFN_MessageBoxIndirectW = apiGetFunctionAddress(LIBRARY, "MessageBoxIndirectW"); 14 | 15 | /** 16 | * @see > 16; 13 | 14 | return new LanguageCodePage(languageId, codePage); 15 | } 16 | } -------------------------------------------------------------------------------- /common/src/boot/java/net/caffeinemc/mods/sodium/client/platform/windows/api/version/QueryResult.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.platform.windows.api.version; 2 | 3 | public record QueryResult(long address, int length) { 4 | } 5 | -------------------------------------------------------------------------------- /common/src/boot/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | FMLModType: LIBRARY 2 | -------------------------------------------------------------------------------- /common/src/desktop/java/net/caffeinemc/mods/sodium/desktop/utils/browse/BrowseUrlHandler.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.desktop.utils.browse; 2 | 3 | import java.io.IOException; 4 | 5 | public interface BrowseUrlHandler { 6 | void browseTo(String url) throws IOException; 7 | 8 | static BrowseUrlHandler createImplementation() { 9 | // OpenJDK doesn't use xdg-open and fails to provide an implementation on most systems. 10 | if (XDGImpl.isSupported()) { 11 | return new XDGImpl(); 12 | } else if (CrossPlatformImpl.isSupported()) { 13 | return new CrossPlatformImpl(); 14 | } 15 | 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/desktop/java/net/caffeinemc/mods/sodium/desktop/utils/browse/CrossPlatformImpl.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.desktop.utils.browse; 2 | 3 | import java.awt.*; 4 | import java.io.IOException; 5 | import java.net.URI; 6 | 7 | class CrossPlatformImpl implements BrowseUrlHandler { 8 | public static boolean isSupported() { 9 | return Desktop.getDesktop() 10 | .isSupported(Desktop.Action.BROWSE); 11 | } 12 | 13 | @Override 14 | public void browseTo(String url) throws IOException { 15 | Desktop.getDesktop().browse(URI.create(url)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/desktop/java/net/caffeinemc/mods/sodium/desktop/utils/browse/XDGImpl.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.desktop.utils.browse; 2 | 3 | import java.io.IOException; 4 | import java.util.Locale; 5 | 6 | class XDGImpl implements BrowseUrlHandler { 7 | public static boolean isSupported() { 8 | String os = System.getProperty("os.name") 9 | .toLowerCase(Locale.ROOT); 10 | 11 | return os.equals("linux"); 12 | } 13 | 14 | @Override 15 | public void browseTo(String url) throws IOException { 16 | var process = Runtime.getRuntime() 17 | .exec(new String[] { "xdg-open", url }); 18 | 19 | try { 20 | int result = process.waitFor(); 21 | 22 | if (result != 0 /* success */) { 23 | throw new IOException("xdg-open exited with code: %d".formatted(result)); 24 | } 25 | } catch (InterruptedException e) { 26 | throw new RuntimeException(e); 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/checks/SodiumResourcePackMetadata.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.checks; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import java.util.List; 6 | import net.minecraft.server.packs.metadata.MetadataSectionType; 7 | 8 | /** 9 | * Reads additional metadata for Sodium from a resource pack's `pack.mcmeta` file. This allows the 10 | * resource pack author to specify which shaders from their pack are not usable with Sodium, but that 11 | * the author is aware of and is fine with being ignored. 12 | */ 13 | public record SodiumResourcePackMetadata(List ignoredShaders) { 14 | public static final Codec CODEC = RecordCodecBuilder.create((instance) -> 15 | instance.group(Codec.STRING.listOf().fieldOf("ignored_shaders") 16 | .forGetter(SodiumResourcePackMetadata::ignoredShaders)) 17 | .apply(instance, SodiumResourcePackMetadata::new) 18 | ); 19 | public static final MetadataSectionType SERIALIZER = 20 | new MetadataSectionType<>("sodium", CODEC); 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/arena/PendingBufferCopyCommand.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.arena; 2 | 3 | import net.caffeinemc.mods.sodium.client.util.UInt32; 4 | 5 | class PendingBufferCopyCommand { 6 | private final int readOffset; /* Uint32 */ 7 | private final int writeOffset; /* Uint32 */ 8 | 9 | private int length; 10 | 11 | PendingBufferCopyCommand(long readOffset, long writeOffset, long length) { 12 | this.readOffset = UInt32.downcast(readOffset); 13 | this.writeOffset = UInt32.downcast(writeOffset); 14 | this.length = UInt32.downcast(length); 15 | } 16 | 17 | /* Uint32 */ 18 | public long getReadOffset() { 19 | return UInt32.upcast(this.readOffset); 20 | } 21 | 22 | /* Uint32 */ 23 | public long getWriteOffset() { 24 | return UInt32.upcast(this.writeOffset); 25 | } 26 | 27 | /* Uint32 */ 28 | public long getLength() { 29 | return UInt32.upcast(this.length); 30 | } 31 | 32 | public void setLength(long length /* Uint32 */) { 33 | this.length = UInt32.downcast(length); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/arena/PendingUpload.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.arena; 2 | 3 | import net.caffeinemc.mods.sodium.client.util.NativeBuffer; 4 | 5 | public class PendingUpload { 6 | private final NativeBuffer data; 7 | private GlBufferSegment result; 8 | 9 | public PendingUpload(NativeBuffer data) { 10 | this.data = data; 11 | } 12 | 13 | public NativeBuffer getDataBuffer() { 14 | return this.data; 15 | } 16 | 17 | protected void setResult(GlBufferSegment result) { 18 | if (this.result != null) { 19 | throw new IllegalStateException("Result already provided"); 20 | } 21 | 22 | this.result = result; 23 | } 24 | 25 | public GlBufferSegment getResult() { 26 | if (this.result == null) { 27 | throw new IllegalStateException("Result not computed"); 28 | } 29 | 30 | return this.result; 31 | } 32 | 33 | public int getLength() { 34 | return this.data.getLength(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/arena/staging/StagingBuffer.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.arena.staging; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.buffer.GlBuffer; 4 | import net.caffeinemc.mods.sodium.client.gl.device.CommandList; 5 | 6 | import java.nio.ByteBuffer; 7 | 8 | public interface StagingBuffer { 9 | void enqueueCopy(CommandList commandList, ByteBuffer data, GlBuffer dst, long writeOffset); 10 | 11 | void flush(CommandList commandList); 12 | 13 | void delete(CommandList commandList); 14 | 15 | void flip(); 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/array/GlVertexArray.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.array; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.GlObject; 4 | import org.lwjgl.opengl.GL30C; 5 | 6 | /** 7 | * Provides Vertex Array functionality on supported platforms. 8 | */ 9 | public class GlVertexArray extends GlObject { 10 | public static final int NULL_ARRAY_ID = 0; 11 | 12 | public GlVertexArray() { 13 | this.setHandle(GL30C.glGenVertexArrays()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexAttributeBinding.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.attribute; 2 | 3 | public class GlVertexAttributeBinding extends GlVertexAttribute { 4 | private final int index; 5 | 6 | public GlVertexAttributeBinding(int index, GlVertexAttribute attribute) { 7 | super(attribute.getFormat(), attribute.getSize(), attribute.getCount(), attribute.isNormalized(), attribute.getPointer(), attribute.getStride(), attribute.isIntType()); 8 | 9 | this.index = index; 10 | } 11 | 12 | public int getIndex() { 13 | return this.index; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexAttributeFormat.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.attribute; 2 | 3 | import org.lwjgl.opengl.GL33C; 4 | 5 | /** 6 | * An enumeration over the supported data types that can be used for vertex attributes. 7 | */ 8 | public record GlVertexAttributeFormat(int typeId, int size) { 9 | public static final GlVertexAttributeFormat FLOAT = new GlVertexAttributeFormat(GL33C.GL_FLOAT, 4); 10 | public static final GlVertexAttributeFormat INT = new GlVertexAttributeFormat(GL33C.GL_INT, 4); 11 | public static final GlVertexAttributeFormat SHORT = new GlVertexAttributeFormat(GL33C.GL_SHORT, 2); 12 | public static final GlVertexAttributeFormat BYTE = new GlVertexAttributeFormat(GL33C.GL_BYTE, 1); 13 | public static final GlVertexAttributeFormat UNSIGNED_SHORT = new GlVertexAttributeFormat(GL33C.GL_UNSIGNED_SHORT, 2); 14 | public static final GlVertexAttributeFormat UNSIGNED_BYTE = new GlVertexAttributeFormat(GL33C.GL_UNSIGNED_BYTE, 1); 15 | public static final GlVertexAttributeFormat UNSIGNED_INT = new GlVertexAttributeFormat(GL33C.GL_UNSIGNED_INT, 4); 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/GlBuffer.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.buffer; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.GlObject; 4 | import org.lwjgl.opengl.GL20C; 5 | 6 | public abstract class GlBuffer extends GlObject { 7 | private GlBufferMapping activeMapping; 8 | 9 | protected GlBuffer() { 10 | this.setHandle(GL20C.glGenBuffers()); 11 | } 12 | 13 | public GlBufferMapping getActiveMapping() { 14 | return this.activeMapping; 15 | } 16 | 17 | public void setActiveMapping(GlBufferMapping mapping) { 18 | this.activeMapping = mapping; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/GlBufferMapFlags.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.buffer; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.util.EnumBit; 4 | import org.lwjgl.opengl.GL30C; 5 | import org.lwjgl.opengl.GL33C; 6 | import org.lwjgl.opengl.GL44C; 7 | 8 | public enum GlBufferMapFlags implements EnumBit { 9 | READ(GL30C.GL_MAP_READ_BIT), 10 | WRITE(GL30C.GL_MAP_WRITE_BIT), 11 | PERSISTENT(GL44C.GL_MAP_PERSISTENT_BIT), 12 | INVALIDATE_BUFFER(GL30C.GL_MAP_INVALIDATE_BUFFER_BIT), 13 | INVALIDATE_RANGE(GL30C.GL_MAP_INVALIDATE_RANGE_BIT), 14 | EXPLICIT_FLUSH(GL30C.GL_MAP_FLUSH_EXPLICIT_BIT), 15 | COHERENT(GL44C.GL_MAP_COHERENT_BIT), 16 | UNSYNCHRONIZED(GL33C.GL_MAP_UNSYNCHRONIZED_BIT); 17 | 18 | private final int bit; 19 | 20 | GlBufferMapFlags(int bit) { 21 | this.bit = bit; 22 | } 23 | 24 | @Override 25 | public int getBits() { 26 | return this.bit; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/GlBufferMapping.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.buffer; 2 | 3 | import org.lwjgl.system.MemoryUtil; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | public class GlBufferMapping { 8 | private final GlBuffer buffer; 9 | private final ByteBuffer map; 10 | 11 | protected boolean disposed; 12 | 13 | public GlBufferMapping(GlBuffer buffer, ByteBuffer map) { 14 | this.buffer = buffer; 15 | this.map = map; 16 | } 17 | 18 | public void write(ByteBuffer data, int writeOffset) { 19 | MemoryUtil.memCopy(MemoryUtil.memAddress(data), MemoryUtil.memAddress(this.map, writeOffset), data.remaining()); 20 | } 21 | 22 | public GlBuffer getBufferObject() { 23 | return this.buffer; 24 | } 25 | 26 | public void dispose() { 27 | this.disposed = true; 28 | } 29 | 30 | public boolean isDisposed() { 31 | return this.disposed; 32 | } 33 | 34 | public ByteBuffer getMemoryBuffer() { 35 | return this.map; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/GlBufferStorageFlags.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.buffer; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.util.EnumBit; 4 | import org.lwjgl.opengl.GL30C; 5 | import org.lwjgl.opengl.GL44C; 6 | 7 | public enum GlBufferStorageFlags implements EnumBit { 8 | PERSISTENT(GL44C.GL_MAP_PERSISTENT_BIT), 9 | MAP_READ(GL30C.GL_MAP_READ_BIT), 10 | MAP_WRITE(GL30C.GL_MAP_WRITE_BIT), 11 | CLIENT_STORAGE(GL44C.GL_CLIENT_STORAGE_BIT), 12 | COHERENT(GL44C.GL_MAP_COHERENT_BIT); 13 | 14 | private final int bits; 15 | 16 | GlBufferStorageFlags(int bits) { 17 | this.bits = bits; 18 | } 19 | 20 | @Override 21 | public int getBits() { 22 | return this.bits; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/GlBufferTarget.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.buffer; 2 | 3 | import org.lwjgl.opengl.GL20C; 4 | import org.lwjgl.opengl.GL31C; 5 | 6 | public enum GlBufferTarget { 7 | ARRAY_BUFFER(GL20C.GL_ARRAY_BUFFER, GL20C.GL_ARRAY_BUFFER_BINDING), 8 | ELEMENT_BUFFER(GL20C.GL_ELEMENT_ARRAY_BUFFER, GL20C.GL_ELEMENT_ARRAY_BUFFER_BINDING), 9 | COPY_READ_BUFFER(GL31C.GL_COPY_READ_BUFFER, GL31C.GL_COPY_READ_BUFFER), 10 | COPY_WRITE_BUFFER(GL31C.GL_COPY_WRITE_BUFFER, GL31C.GL_COPY_WRITE_BUFFER); 11 | 12 | public static final GlBufferTarget[] VALUES = GlBufferTarget.values(); 13 | public static final int COUNT = VALUES.length; 14 | 15 | private final int target; 16 | private final int binding; 17 | 18 | GlBufferTarget(int target, int binding) { 19 | this.target = target; 20 | this.binding = binding; 21 | } 22 | 23 | public int getTargetParameter() { 24 | return this.target; 25 | } 26 | 27 | public int getBindingParameter() { 28 | return this.binding; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/GlBufferUsage.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.buffer; 2 | 3 | import org.lwjgl.opengl.GL20C; 4 | 5 | public enum GlBufferUsage { 6 | STREAM_DRAW(GL20C.GL_STREAM_DRAW), 7 | STREAM_READ(GL20C.GL_STREAM_READ), 8 | STREAM_COPY(GL20C.GL_STREAM_COPY), 9 | STATIC_DRAW(GL20C.GL_STATIC_DRAW), 10 | STATIC_READ(GL20C.GL_STATIC_READ), 11 | STATIC_COPY(GL20C.GL_STATIC_COPY), 12 | DYNAMIC_DRAW(GL20C.GL_DYNAMIC_DRAW), 13 | DYNAMIC_READ(GL20C.GL_DYNAMIC_READ), 14 | DYNAMIC_COPY(GL20C.GL_DYNAMIC_COPY); 15 | 16 | private final int id; 17 | 18 | GlBufferUsage(int id) { 19 | this.id = id; 20 | } 21 | 22 | public int getId() { 23 | return this.id; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/GlImmutableBuffer.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.buffer; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.util.EnumBitField; 4 | 5 | public class GlImmutableBuffer extends GlBuffer { 6 | private final EnumBitField flags; 7 | 8 | public GlImmutableBuffer(EnumBitField flags) { 9 | this.flags = flags; 10 | } 11 | 12 | public EnumBitField getFlags() { 13 | return this.flags; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/GlMutableBuffer.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.buffer; 2 | 3 | /** 4 | * A mutable buffer type which is supported with OpenGL 1.5+. The buffer's storage can be reallocated at any time 5 | * without needing to re-create the buffer itself. 6 | */ 7 | public class GlMutableBuffer extends GlBuffer { 8 | private long size = 0L; 9 | 10 | public GlMutableBuffer() { 11 | super(); 12 | } 13 | 14 | public void setSize(long size) { 15 | this.size = size; 16 | } 17 | 18 | public long getSize() { 19 | return this.size; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/device/DrawCommandList.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.device; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.tessellation.GlIndexType; 4 | 5 | public interface DrawCommandList extends AutoCloseable { 6 | void multiDrawElementsBaseVertex(MultiDrawBatch batch, GlIndexType indexType); 7 | 8 | void endTessellating(); 9 | 10 | void flush(); 11 | 12 | @Override 13 | default void close() { 14 | this.flush(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/device/RenderDevice.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.device; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.functions.DeviceFunctions; 4 | import org.lwjgl.opengl.GLCapabilities; 5 | 6 | public interface RenderDevice { 7 | RenderDevice INSTANCE = new GLRenderDevice(); 8 | 9 | CommandList createCommandList(); 10 | 11 | static void enterManagedCode() { 12 | RenderDevice.INSTANCE.makeActive(); 13 | } 14 | 15 | static void exitManagedCode() { 16 | RenderDevice.INSTANCE.makeInactive(); 17 | } 18 | 19 | void makeActive(); 20 | void makeInactive(); 21 | 22 | GLCapabilities getCapabilities(); 23 | 24 | DeviceFunctions getDeviceFunctions(); 25 | 26 | int getSubTexelPrecisionBits(); 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/functions/DeviceFunctions.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.functions; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.device.RenderDevice; 4 | 5 | public class DeviceFunctions { 6 | private final BufferStorageFunctions bufferStorageFunctions; 7 | 8 | public DeviceFunctions(RenderDevice device) { 9 | this.bufferStorageFunctions = BufferStorageFunctions.pickBest(device); 10 | } 11 | 12 | public BufferStorageFunctions getBufferStorageFunctions() { 13 | return this.bufferStorageFunctions; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/ShaderType.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader; 2 | 3 | import org.lwjgl.opengl.GL20C; 4 | import org.lwjgl.opengl.GL32C; 5 | import org.lwjgl.opengl.GL40C; 6 | 7 | /** 8 | * An enumeration over the supported OpenGL shader types. 9 | */ 10 | public enum ShaderType { 11 | VERTEX(GL20C.GL_VERTEX_SHADER), 12 | GEOMETRY(GL32C.GL_GEOMETRY_SHADER), 13 | TESS_CONTROL(GL40C.GL_TESS_CONTROL_SHADER), 14 | TESS_EVALUATION(GL40C.GL_TESS_EVALUATION_SHADER), 15 | FRAGMENT(GL20C.GL_FRAGMENT_SHADER); 16 | 17 | public final int id; 18 | 19 | ShaderType(int id) { 20 | this.id = id; 21 | } 22 | 23 | public static ShaderType fromGlShaderType(int id) { 24 | for (ShaderType type : values()) { 25 | if (type.id == id) { 26 | return type; 27 | } 28 | } 29 | 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/uniform/GlUniform.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader.uniform; 2 | 3 | public abstract class GlUniform { 4 | protected final int index; 5 | 6 | protected GlUniform(int index) { 7 | this.index = index; 8 | } 9 | 10 | public abstract void set(T value); 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/uniform/GlUniformBlock.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader.uniform; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.buffer.GlBuffer; 4 | import org.lwjgl.opengl.GL32C; 5 | 6 | public class GlUniformBlock { 7 | private final int binding; 8 | 9 | public GlUniformBlock(int uniformBlockBinding) { 10 | this.binding = uniformBlockBinding; 11 | } 12 | 13 | public void bindBuffer(GlBuffer buffer) { 14 | GL32C.glBindBufferBase(GL32C.GL_UNIFORM_BUFFER, this.binding, buffer.handle()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/uniform/GlUniformFloat.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader.uniform; 2 | 3 | import org.lwjgl.opengl.GL30C; 4 | 5 | public class GlUniformFloat extends GlUniform { 6 | public GlUniformFloat(int index) { 7 | super(index); 8 | } 9 | 10 | @Override 11 | public void set(Float value) { 12 | this.setFloat(value); 13 | } 14 | 15 | public void setFloat(float value) { 16 | GL30C.glUniform1f(this.index, value); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/uniform/GlUniformFloat2v.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader.uniform; 2 | 3 | import org.lwjgl.opengl.GL30C; 4 | 5 | public class GlUniformFloat2v extends GlUniform { 6 | public GlUniformFloat2v(int index) { 7 | super(index); 8 | } 9 | 10 | @Override 11 | public void set(float[] value) { 12 | if (value.length != 2) { 13 | throw new IllegalArgumentException("value.length != 2"); 14 | } 15 | 16 | GL30C.glUniform2fv(this.index, value); 17 | } 18 | 19 | public void set(float x, float y) { 20 | GL30C.glUniform2f(this.index, x, y); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/uniform/GlUniformFloat3v.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader.uniform; 2 | 3 | import org.lwjgl.opengl.GL30C; 4 | 5 | public class GlUniformFloat3v extends GlUniform { 6 | public GlUniformFloat3v(int index) { 7 | super(index); 8 | } 9 | 10 | @Override 11 | public void set(float[] value) { 12 | if (value.length != 3) { 13 | throw new IllegalArgumentException("value.length != 3"); 14 | } 15 | 16 | GL30C.glUniform3fv(this.index, value); 17 | } 18 | 19 | public void set(float x, float y, float z) { 20 | GL30C.glUniform3f(this.index, x, y, z); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/uniform/GlUniformFloat4v.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader.uniform; 2 | 3 | import org.lwjgl.opengl.GL30C; 4 | 5 | public class GlUniformFloat4v extends GlUniform { 6 | public GlUniformFloat4v(int index) { 7 | super(index); 8 | } 9 | 10 | @Override 11 | public void set(float[] value) { 12 | if (value.length != 4) { 13 | throw new IllegalArgumentException("value.length != 4"); 14 | } 15 | 16 | GL30C.glUniform4fv(this.index, value); 17 | } 18 | 19 | public void set(float x, float y, float z, float w) { 20 | GL30C.glUniform4f(this.index, x, y, z, w); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/uniform/GlUniformInt.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader.uniform; 2 | 3 | import org.lwjgl.opengl.GL30C; 4 | 5 | public class GlUniformInt extends GlUniform { 6 | public GlUniformInt(int index) { 7 | super(index); 8 | } 9 | 10 | @Override 11 | public void set(Integer value) { 12 | this.setInt(value); 13 | } 14 | 15 | public void setInt(int value) { 16 | GL30C.glUniform1i(this.index, value); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/uniform/GlUniformMatrix4f.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.shader.uniform; 2 | 3 | import org.joml.Matrix4fc; 4 | import org.lwjgl.opengl.GL30C; 5 | import org.lwjgl.system.MemoryStack; 6 | 7 | import java.nio.FloatBuffer; 8 | 9 | public class GlUniformMatrix4f extends GlUniform { 10 | public GlUniformMatrix4f(int index) { 11 | super(index); 12 | } 13 | 14 | @Override 15 | public void set(Matrix4fc value) { 16 | try (MemoryStack stack = MemoryStack.stackPush()) { 17 | FloatBuffer buf = stack.callocFloat(16); 18 | value.get(buf); 19 | 20 | GL30C.glUniformMatrix4fv(this.index, false, buf); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/GlIndexType.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.tessellation; 2 | 3 | import org.lwjgl.opengl.GL32C; 4 | 5 | public enum GlIndexType { 6 | UNSIGNED_BYTE(GL32C.GL_UNSIGNED_BYTE, 1), 7 | UNSIGNED_SHORT(GL32C.GL_UNSIGNED_SHORT, 2), 8 | UNSIGNED_INT(GL32C.GL_UNSIGNED_INT, 4); 9 | 10 | private final int id; 11 | private final int stride; 12 | 13 | GlIndexType(int id, int stride) { 14 | this.id = id; 15 | this.stride = stride; 16 | } 17 | 18 | public int getFormatId() { 19 | return this.id; 20 | } 21 | 22 | public int getStride() { 23 | return this.stride; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/GlPrimitiveType.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.tessellation; 2 | 3 | import org.lwjgl.opengl.GL20C; 4 | import org.lwjgl.opengl.GL40C; 5 | 6 | public enum GlPrimitiveType { 7 | POINTS(GL20C.GL_POINTS), 8 | LINES(GL20C.GL_LINES), 9 | TRIANGLES(GL20C.GL_TRIANGLES), 10 | PATCHES(GL40C.GL_PATCHES); 11 | 12 | private final int id; 13 | 14 | GlPrimitiveType(int id) { 15 | this.id = id; 16 | } 17 | 18 | public int getId() { 19 | return this.id; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/GlTessellation.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.tessellation; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.device.CommandList; 4 | 5 | public interface GlTessellation { 6 | void delete(CommandList commandList); 7 | 8 | void bind(CommandList commandList); 9 | 10 | void unbind(CommandList commandList); 11 | 12 | GlPrimitiveType getPrimitiveType(); 13 | } 14 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/GlVertexArrayTessellation.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.tessellation; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.array.GlVertexArray; 4 | import net.caffeinemc.mods.sodium.client.gl.device.CommandList; 5 | 6 | public class GlVertexArrayTessellation extends GlAbstractTessellation { 7 | private final GlVertexArray array; 8 | 9 | public GlVertexArrayTessellation(GlVertexArray array, GlPrimitiveType primitiveType, TessellationBinding[] bindings) { 10 | super(primitiveType, bindings); 11 | 12 | this.array = array; 13 | } 14 | 15 | public void init(CommandList commandList) { 16 | this.bind(commandList); 17 | this.bindAttributes(commandList); 18 | this.unbind(commandList); 19 | } 20 | 21 | @Override 22 | public void delete(CommandList commandList) { 23 | commandList.deleteVertexArray(this.array); 24 | } 25 | 26 | @Override 27 | public void bind(CommandList commandList) { 28 | commandList.bindVertexArray(this.array); 29 | } 30 | 31 | @Override 32 | public void unbind(CommandList commandList) { 33 | commandList.unbindVertexArray(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/TessellationBinding.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.tessellation; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexAttributeBinding; 4 | import net.caffeinemc.mods.sodium.client.gl.buffer.GlBuffer; 5 | import net.caffeinemc.mods.sodium.client.gl.buffer.GlBufferTarget; 6 | 7 | public record TessellationBinding(GlBufferTarget target, 8 | GlBuffer buffer, 9 | GlVertexAttributeBinding[] attributeBindings) { 10 | public static TessellationBinding forVertexBuffer(GlBuffer buffer, GlVertexAttributeBinding[] attributes) { 11 | return new TessellationBinding(GlBufferTarget.ARRAY_BUFFER, buffer, attributes); 12 | } 13 | 14 | public static TessellationBinding forElementBuffer(GlBuffer buffer) { 15 | return new TessellationBinding(GlBufferTarget.ELEMENT_BUFFER, buffer, new GlVertexAttributeBinding[0]); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/util/EnumBit.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.util; 2 | 3 | public interface EnumBit { 4 | int getBits(); 5 | } 6 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gl/util/EnumBitField.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gl.util; 2 | 3 | import java.util.Arrays; 4 | import java.util.EnumSet; 5 | import java.util.List; 6 | import java.util.Set; 7 | 8 | public class EnumBitField & EnumBit> { 9 | private final EnumSet set; 10 | private final int bitfield; 11 | 12 | private EnumBitField(EnumSet set) { 13 | this.set = set; 14 | this.bitfield = computeBitField(set); 15 | } 16 | 17 | private static & EnumBit> int computeBitField(Set set) { 18 | int field = 0; 19 | 20 | for (T e : set) { 21 | field |= e.getBits(); 22 | } 23 | 24 | return field; 25 | } 26 | 27 | @SafeVarargs 28 | public static & EnumBit> EnumBitField of(T... values) { 29 | List list = Arrays.asList(values); 30 | EnumSet set = EnumSet.copyOf(list); 31 | 32 | return new EnumBitField<>(set); 33 | } 34 | 35 | public int getBitField() { 36 | return this.bitfield; 37 | } 38 | 39 | public boolean contains(T flag) { 40 | return this.set.contains(flag); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/console/ConsoleHooks.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.console; 2 | 3 | import net.caffeinemc.mods.sodium.client.console.Console; 4 | import net.minecraft.client.gui.GuiGraphics; 5 | 6 | public class ConsoleHooks { 7 | public static void render(GuiGraphics graphics, double currentTime) { 8 | ConsoleRenderer.INSTANCE.update(Console.INSTANCE, currentTime); 9 | ConsoleRenderer.INSTANCE.draw(graphics); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/Option.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options; 2 | 3 | import net.caffeinemc.mods.sodium.client.gui.options.control.Control; 4 | import net.caffeinemc.mods.sodium.client.gui.options.storage.OptionStorage; 5 | import net.minecraft.network.chat.Component; 6 | import java.util.Collection; 7 | 8 | public interface Option { 9 | Component getName(); 10 | 11 | Component getTooltip(); 12 | 13 | OptionImpact getImpact(); 14 | 15 | Control getControl(); 16 | 17 | T getValue(); 18 | 19 | void setValue(T value); 20 | 21 | void reset(); 22 | 23 | OptionStorage getStorage(); 24 | 25 | boolean isAvailable(); 26 | 27 | boolean hasChanged(); 28 | 29 | void applyChanges(); 30 | 31 | Collection getFlags(); 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/OptionFlag.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options; 2 | 3 | public enum OptionFlag { 4 | REQUIRES_RENDERER_RELOAD, 5 | REQUIRES_RENDERER_UPDATE, 6 | REQUIRES_ASSET_RELOAD, 7 | REQUIRES_VIDEOMODE_RELOAD, 8 | REQUIRES_GAME_RESTART 9 | } 10 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/OptionGroup.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import org.apache.commons.lang3.Validate; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class OptionGroup { 10 | private final ImmutableList> options; 11 | 12 | private OptionGroup(ImmutableList> options) { 13 | this.options = options; 14 | } 15 | 16 | public static Builder createBuilder() { 17 | return new Builder(); 18 | } 19 | 20 | public ImmutableList> getOptions() { 21 | return this.options; 22 | } 23 | 24 | public static class Builder { 25 | private final List> options = new ArrayList<>(); 26 | 27 | public Builder add(Option option) { 28 | this.options.add(option); 29 | 30 | return this; 31 | } 32 | 33 | public OptionGroup build() { 34 | Validate.notEmpty(this.options, "At least one option must be specified"); 35 | 36 | return new OptionGroup(ImmutableList.copyOf(this.options)); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/OptionImpact.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.network.chat.Component; 5 | 6 | public enum OptionImpact implements TextProvider { 7 | LOW(ChatFormatting.GREEN, "sodium.option_impact.low"), 8 | MEDIUM(ChatFormatting.YELLOW, "sodium.option_impact.medium"), 9 | HIGH(ChatFormatting.GOLD, "sodium.option_impact.high"), 10 | VARIES(ChatFormatting.WHITE, "sodium.option_impact.varies"); 11 | 12 | private final Component text; 13 | 14 | OptionImpact(ChatFormatting formatting, String text) { 15 | this.text = Component.translatable(text) 16 | .withStyle(formatting); 17 | } 18 | 19 | @Override 20 | public Component getLocalizedName() { 21 | return this.text; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/OptionPage.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import net.minecraft.network.chat.Component; 5 | 6 | public class OptionPage { 7 | private final Component name; 8 | private final ImmutableList groups; 9 | private final ImmutableList> options; 10 | 11 | public OptionPage(Component name, ImmutableList groups) { 12 | this.name = name; 13 | this.groups = groups; 14 | 15 | ImmutableList.Builder> builder = ImmutableList.builder(); 16 | 17 | for (OptionGroup group : groups) { 18 | builder.addAll(group.getOptions()); 19 | } 20 | 21 | this.options = builder.build(); 22 | } 23 | 24 | public ImmutableList getGroups() { 25 | return this.groups; 26 | } 27 | 28 | public ImmutableList> getOptions() { 29 | return this.options; 30 | } 31 | 32 | public Component getName() { 33 | return this.name; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/TextProvider.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options; 2 | 3 | import net.minecraft.network.chat.Component; 4 | 5 | public interface TextProvider { 6 | Component getLocalizedName(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/binding/GenericBinding.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options.binding; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.Function; 5 | 6 | public class GenericBinding implements OptionBinding { 7 | private final BiConsumer setter; 8 | private final Function getter; 9 | 10 | public GenericBinding(BiConsumer setter, Function getter) { 11 | this.setter = setter; 12 | this.getter = getter; 13 | } 14 | 15 | @Override 16 | public void setValue(S storage, T value) { 17 | this.setter.accept(storage, value); 18 | } 19 | 20 | @Override 21 | public T getValue(S storage) { 22 | return this.getter.apply(storage); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/binding/OptionBinding.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options.binding; 2 | 3 | public interface OptionBinding { 4 | void setValue(S storage, T value); 5 | 6 | T getValue(S storage); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/binding/compat/VanillaBooleanOptionBinding.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options.binding.compat; 2 | 3 | import net.caffeinemc.mods.sodium.client.gui.options.binding.OptionBinding; 4 | import net.minecraft.client.OptionInstance; 5 | import net.minecraft.client.Options; 6 | 7 | public class VanillaBooleanOptionBinding implements OptionBinding { 8 | private final OptionInstance option; 9 | 10 | public VanillaBooleanOptionBinding(OptionInstance option) { 11 | this.option = option; 12 | } 13 | 14 | @Override 15 | public void setValue(Options storage, Boolean value) { 16 | this.option.set(value); 17 | } 18 | 19 | @Override 20 | public Boolean getValue(Options storage) { 21 | return this.option.get(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/control/Control.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options.control; 2 | 3 | import net.caffeinemc.mods.sodium.client.gui.options.Option; 4 | import net.caffeinemc.mods.sodium.client.util.Dim2i; 5 | 6 | public interface Control { 7 | Option getOption(); 8 | 9 | ControlElement createElement(Dim2i dim); 10 | 11 | int getMaxWidth(); 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/storage/MinecraftOptionsStorage.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options.storage; 2 | 3 | import net.caffeinemc.mods.sodium.client.SodiumClientMod; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.Options; 6 | 7 | public class MinecraftOptionsStorage implements OptionStorage { 8 | private final Minecraft minecraft; 9 | 10 | public MinecraftOptionsStorage() { 11 | this.minecraft = Minecraft.getInstance(); 12 | } 13 | 14 | @Override 15 | public Options getData() { 16 | return this.minecraft.options; 17 | } 18 | 19 | @Override 20 | public void save() { 21 | this.getData().save(); 22 | 23 | SodiumClientMod.logger().info("Flushed changes to Minecraft configuration"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/storage/OptionStorage.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options.storage; 2 | 3 | public interface OptionStorage { 4 | T getData(); 5 | 6 | void save(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/storage/SodiumOptionsStorage.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.options.storage; 2 | 3 | import net.caffeinemc.mods.sodium.client.SodiumClientMod; 4 | import net.caffeinemc.mods.sodium.client.gui.SodiumGameOptions; 5 | 6 | import java.io.IOException; 7 | 8 | public class SodiumOptionsStorage implements OptionStorage { 9 | private final SodiumGameOptions options; 10 | 11 | public SodiumOptionsStorage() { 12 | this.options = SodiumClientMod.options(); 13 | } 14 | 15 | @Override 16 | public SodiumGameOptions getData() { 17 | return this.options; 18 | } 19 | 20 | @Override 21 | public void save() { 22 | try { 23 | SodiumGameOptions.writeToDisk(this.options); 24 | } catch (IOException e) { 25 | throw new RuntimeException("Couldn't save configuration changes", e); 26 | } 27 | 28 | SodiumClientMod.logger().info("Flushed changes to Sodium configuration"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/gui/prompt/ScreenPromptable.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.gui.prompt; 2 | 3 | import net.caffeinemc.mods.sodium.client.util.Dim2i; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | public interface ScreenPromptable { 7 | void setPrompt(@Nullable ScreenPrompt prompt); 8 | 9 | @Nullable ScreenPrompt getPrompt(); 10 | 11 | Dim2i getDimensions(); 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/ColorProvider.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.color; 2 | 3 | import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; 4 | import net.caffeinemc.mods.sodium.client.world.LevelSlice; 5 | import net.minecraft.core.BlockPos; 6 | 7 | public interface ColorProvider { 8 | /** 9 | * Computes the per-vertex colors of a model quad and stores the results in {@param output}. The order of 10 | * the output color array is the same as the order of the quad's vertices. 11 | * 12 | * @param slice The level slice which contains the object being colorized 13 | * @param pos The position of the object being colorized 14 | * @param scratchPos A mutable block position for temporary calculations 15 | * @param state The state of the object being colorized 16 | * @param quad The quad geometry which should be colorized 17 | * @param output The output array of vertex colors (in ABGR format) 18 | */ 19 | void getColors(LevelSlice slice, BlockPos pos, BlockPos.MutableBlockPos scratchPos, T state, ModelQuadView quad, int[] output); 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/interop/BlockColorsExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.color.interop; 2 | 3 | import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap; 4 | import it.unimi.dsi.fastutil.objects.ReferenceSet; 5 | import net.minecraft.client.color.block.BlockColor; 6 | import net.minecraft.client.color.block.BlockColors; 7 | import net.minecraft.world.level.block.Block; 8 | 9 | public interface BlockColorsExtension { 10 | static Reference2ReferenceMap getProviders(BlockColors blockColors) { 11 | return ((BlockColorsExtension) blockColors).sodium$getProviders(); 12 | } 13 | 14 | static ReferenceSet getOverridenVanillaBlocks(BlockColors blockColors) { 15 | return ((BlockColorsExtension) blockColors).sodium$getOverridenVanillaBlocks(); 16 | } 17 | 18 | Reference2ReferenceMap sodium$getProviders(); 19 | 20 | ReferenceSet sodium$getOverridenVanillaBlocks(); 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/LightMode.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.light; 2 | 3 | public enum LightMode { 4 | SMOOTH, 5 | FLAT 6 | } 7 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/LightPipelineProvider.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.light; 2 | 3 | import net.caffeinemc.mods.sodium.client.model.light.data.LightDataAccess; 4 | import net.caffeinemc.mods.sodium.client.model.light.flat.FlatLightPipeline; 5 | import net.caffeinemc.mods.sodium.client.model.light.smooth.SmoothLightPipeline; 6 | 7 | import java.util.EnumMap; 8 | 9 | public class LightPipelineProvider { 10 | private final EnumMap lighters = new EnumMap<>(LightMode.class); 11 | 12 | public LightPipelineProvider(LightDataAccess cache) { 13 | this.lighters.put(LightMode.SMOOTH, new SmoothLightPipeline(cache)); 14 | this.lighters.put(LightMode.FLAT, new FlatLightPipeline(cache)); 15 | } 16 | 17 | public LightPipeline getLighter(LightMode type) { 18 | LightPipeline pipeline = this.lighters.get(type); 19 | 20 | if (pipeline == null) { 21 | throw new NullPointerException("No lighter exists for mode: " + type.name()); 22 | } 23 | 24 | return pipeline; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/data/HashLightDataCache.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.light.data; 2 | 3 | import it.unimi.dsi.fastutil.longs.Long2IntLinkedOpenHashMap; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.world.level.BlockAndTintGetter; 6 | 7 | /** 8 | * A light data cache which uses a hash table to store previously accessed values. 9 | */ 10 | public class HashLightDataCache extends LightDataAccess { 11 | private final Long2IntLinkedOpenHashMap map = new Long2IntLinkedOpenHashMap(1024, 0.50f); 12 | 13 | public HashLightDataCache(BlockAndTintGetter level) { 14 | this.level = level; 15 | } 16 | 17 | @Override 18 | public int get(int x, int y, int z) { 19 | long key = BlockPos.asLong(x, y, z); 20 | int word = this.map.getAndMoveToFirst(key); 21 | 22 | if (word == 0) { 23 | if (this.map.size() > 1024) { 24 | this.map.removeLastInt(); 25 | } 26 | 27 | this.map.put(key, word = this.compute(x, y, z)); 28 | } 29 | 30 | return word; 31 | } 32 | 33 | public void clearCache() { 34 | this.map.clear(); 35 | } 36 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/data/QuadLightData.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.light.data; 2 | 3 | /** 4 | * Stores the computed light data for a block model quad. The vertex order of each array is defined as that of the 5 | * quad's vertex order. 6 | */ 7 | public class QuadLightData { 8 | /** 9 | * The brightness of each vertex in the quad as normalized floats. 10 | */ 11 | public final float[] br = new float[4]; 12 | 13 | /** 14 | * The lightmap texture coordinates for each vertex in the quad. 15 | */ 16 | public final int[] lm = new int[4]; 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/smooth/AoCompletionFlags.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.light.smooth; 2 | 3 | /** 4 | * Bit flags to indicate which light properties have been computed for a given face. 5 | */ 6 | class AoCompletionFlags { 7 | /** 8 | * The light data has been retrieved from the cache. 9 | */ 10 | public static final int HAS_LIGHT_DATA = 0b01; 11 | 12 | /** 13 | * The light data has been unpacked into normalized floating point values. 14 | */ 15 | public static final int HAS_UNPACKED_LIGHT_DATA = 0b10; 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/quad/BakedQuadView.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.quad; 2 | 3 | import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFacing; 4 | 5 | public interface BakedQuadView extends ModelQuadView { 6 | ModelQuadFacing getNormalFace(); 7 | 8 | int getFaceNormal(); 9 | 10 | boolean hasShade(); 11 | 12 | boolean hasAO(); 13 | } 14 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/model/quad/properties/ModelQuadWinding.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.model.quad.properties; 2 | 3 | public enum ModelQuadWinding { 4 | CLOCKWISE(new int[] { 0, 1, 2, 2, 3, 0 }), 5 | COUNTERCLOCKWISE(new int[] { 0, 3, 2, 1, 0, 2 }); 6 | 7 | private final int[] indices; 8 | 9 | ModelQuadWinding(int[] indices) { 10 | this.indices = indices; 11 | } 12 | 13 | public int[] getIndices() { 14 | return this.indices; 15 | } 16 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/BlockEntityRenderHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk; 2 | 3 | import java.util.function.Predicate; 4 | 5 | import net.caffeinemc.mods.sodium.api.blockentity.BlockEntityRenderHandler; 6 | import net.caffeinemc.mods.sodium.api.blockentity.BlockEntityRenderPredicate; 7 | import net.minecraft.world.level.block.entity.BlockEntity; 8 | import net.minecraft.world.level.block.entity.BlockEntityType; 9 | 10 | public class BlockEntityRenderHandlerImpl implements BlockEntityRenderHandler { 11 | @Override 12 | public void addRenderPredicate(BlockEntityType type, BlockEntityRenderPredicate predicate) { 13 | ExtendedBlockEntityType.addRenderPredicate(type, predicate); 14 | } 15 | 16 | @Override 17 | public boolean removeRenderPredicate(BlockEntityType type, BlockEntityRenderPredicate predicate) { 18 | return ExtendedBlockEntityType.removeRenderPredicate(type, predicate); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/ChunkRenderMatrices.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import com.mojang.blaze3d.vertex.PoseStack; 5 | import org.joml.Matrix4f; 6 | import org.joml.Matrix4fc; 7 | 8 | public record ChunkRenderMatrices(Matrix4fc projection, Matrix4fc modelView) { 9 | public static ChunkRenderMatrices from(PoseStack stack) { 10 | PoseStack.Pose entry = stack.last(); 11 | return new ChunkRenderMatrices(new Matrix4f(RenderSystem.getProjectionMatrix()), new Matrix4f(entry.pose())); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/NonStoringBuilderPool.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | import java.util.Collections; 6 | import net.minecraft.client.renderer.SectionBufferBuilderPack; 7 | import net.minecraft.client.renderer.SectionBufferBuilderPool; 8 | 9 | public class NonStoringBuilderPool extends SectionBufferBuilderPool { 10 | public NonStoringBuilderPool() { 11 | super(Collections.emptyList()); 12 | } 13 | 14 | @Nullable 15 | @Override 16 | public SectionBufferBuilderPack acquire() { 17 | return null; 18 | } 19 | 20 | @Override 21 | public void release(SectionBufferBuilderPack blockBufferBuilderStorage) { 22 | } 23 | 24 | @Override 25 | public boolean isEmpty() { 26 | return true; 27 | } 28 | 29 | @Override 30 | public int getFreeBufferCount() { 31 | return 0; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSectionFlags.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk; 2 | 3 | public class RenderSectionFlags { 4 | public static final int HAS_BLOCK_GEOMETRY = 0; 5 | public static final int HAS_BLOCK_ENTITIES = 1; 6 | public static final int HAS_ANIMATED_SPRITES = 2; 7 | 8 | public static final int NONE = 0; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.compile; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection; 4 | 5 | public abstract class BuilderTaskOutput { 6 | public final RenderSection render; 7 | public final int submitTime; 8 | 9 | public BuilderTaskOutput(RenderSection render, int buildTime) { 10 | this.render = render; 11 | this.submitTime = buildTime; 12 | } 13 | 14 | public void destroy() { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.compile; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType; 4 | import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderCache; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.multiplayer.ClientLevel; 7 | 8 | public class ChunkBuildContext { 9 | public final ChunkBuildBuffers buffers; 10 | public final BlockRenderCache cache; 11 | 12 | public ChunkBuildContext(ClientLevel level, ChunkVertexType vertexType) { 13 | this.buffers = new ChunkBuildBuffers(vertexType); 14 | this.cache = new BlockRenderCache(Minecraft.getInstance(), level); 15 | } 16 | 17 | public void cleanup() { 18 | this.buffers.destroy(); 19 | this.cache.cleanup(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/executor/ChunkJob.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.compile.executor; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildContext; 4 | import net.caffeinemc.mods.sodium.client.util.task.CancellationToken; 5 | 6 | public interface ChunkJob extends CancellationToken { 7 | void execute(ChunkBuildContext context); 8 | 9 | boolean isStarted(); 10 | 11 | int getEffort(); 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/executor/ChunkJobResult.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.compile.executor; 2 | 3 | import net.minecraft.ReportedException; 4 | 5 | public class ChunkJobResult { 6 | private final OUTPUT output; 7 | private final Throwable throwable; 8 | 9 | private ChunkJobResult(OUTPUT output, Throwable throwable) { 10 | this.output = output; 11 | this.throwable = throwable; 12 | } 13 | 14 | public static ChunkJobResult exceptionally(Throwable throwable) { 15 | return new ChunkJobResult<>(null, throwable); 16 | } 17 | 18 | public static ChunkJobResult successfully(OUTPUT output) { 19 | return new ChunkJobResult<>(output, null); 20 | } 21 | 22 | public OUTPUT unwrap() { 23 | if (this.throwable instanceof ReportedException exception) { 24 | // Propagate ReportedExceptions directly to provide extra information 25 | throw exception; 26 | } else if (this.throwable != null) { 27 | throw new RuntimeException("Exception thrown while executing job", this.throwable); 28 | } 29 | 30 | return this.output; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/FluidRenderer.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; 2 | 3 | import net.caffeinemc.mods.sodium.client.model.color.ColorProviderRegistry; 4 | import net.caffeinemc.mods.sodium.client.model.light.LightPipelineProvider; 5 | import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers; 6 | import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.TranslucentGeometryCollector; 7 | import net.caffeinemc.mods.sodium.client.world.LevelSlice; 8 | import net.minecraft.core.BlockPos; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | import net.minecraft.world.level.material.FluidState; 11 | 12 | public abstract class FluidRenderer { 13 | public abstract void render(LevelSlice level, BlockState blockState, FluidState fluidState, BlockPos blockPos, BlockPos offset, TranslucentGeometryCollector collector, ChunkBuildBuffers buffers); 14 | } 15 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/SpriteContentsExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; 2 | 3 | public interface SpriteContentsExtension { 4 | boolean sodium$hasTransparentPixels(); 5 | 6 | boolean sodium$hasTranslucentPixels(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/TextureAtlasSpriteExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; 2 | 3 | public interface TextureAtlasSpriteExtension { 4 | boolean sodium$hasUnknownImageContents(); 5 | } 6 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/data/BuiltSectionMeshParts.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.data; 2 | 3 | import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFacing; 4 | import net.caffeinemc.mods.sodium.client.util.NativeBuffer; 5 | 6 | public class BuiltSectionMeshParts { 7 | private final int[] vertexSegments; 8 | private final NativeBuffer buffer; 9 | 10 | public BuiltSectionMeshParts(NativeBuffer buffer, int[] vertexCounts) { 11 | this.vertexSegments = vertexCounts; 12 | this.buffer = buffer; 13 | } 14 | 15 | public NativeBuffer getVertexData() { 16 | return this.buffer; 17 | } 18 | 19 | public int[] getVertexSegments() { 20 | return this.vertexSegments; 21 | } 22 | 23 | public int[] computeVertexCounts() { 24 | var vertexCounts = new int[ModelQuadFacing.COUNT]; 25 | 26 | for (int i = 0; i < this.vertexSegments.length; i += 2) { 27 | vertexCounts[this.vertexSegments[i + 1]] = this.vertexSegments[i]; 28 | } 29 | 30 | return vertexCounts; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/lists/ChunkRenderListIterable.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.lists; 2 | 3 | import java.util.Iterator; 4 | 5 | public interface ChunkRenderListIterable { 6 | Iterator iterator(boolean reverse); 7 | 8 | default Iterator iterator() { 9 | return this.iterator(false); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/lists/SortedRenderLists.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.lists; 2 | 3 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 4 | import net.caffeinemc.mods.sodium.client.util.iterator.ReversibleObjectArrayIterator; 5 | 6 | /** 7 | * Stores one render list of sections per region, sorted by the order in which 8 | * they were discovered in the BFS of the occlusion culler. It also generates 9 | * render lists for sections of previously unseen regions. 10 | */ 11 | public class SortedRenderLists implements ChunkRenderListIterable { 12 | private static final SortedRenderLists EMPTY = new SortedRenderLists(ObjectArrayList.of()); 13 | 14 | private final ObjectArrayList lists; 15 | 16 | SortedRenderLists(ObjectArrayList lists) { 17 | this.lists = lists; 18 | } 19 | 20 | @Override 21 | public ReversibleObjectArrayIterator iterator(boolean reverse) { 22 | return new ReversibleObjectArrayIterator<>(this.lists, reverse); 23 | } 24 | 25 | public static SortedRenderLists empty() { 26 | return EMPTY; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/map/ChunkStatus.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.map; 2 | 3 | public class ChunkStatus { 4 | public static final int FLAG_HAS_BLOCK_DATA = 1; 5 | public static final int FLAG_HAS_LIGHT_DATA = 2; 6 | public static final int FLAG_ALL = FLAG_HAS_BLOCK_DATA | FLAG_HAS_LIGHT_DATA; 7 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/map/ChunkTrackerHolder.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.map; 2 | 3 | import net.minecraft.client.multiplayer.ClientLevel; 4 | 5 | public interface ChunkTrackerHolder { 6 | static ChunkTracker get(ClientLevel level) { 7 | return ((ChunkTrackerHolder) level).sodium$getTracker(); 8 | } 9 | 10 | ChunkTracker sodium$getTracker(); 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/map/ClientChunkEventListener.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.map; 2 | 3 | public interface ClientChunkEventListener { 4 | void updateMapCenter(int chunkX, int chunkZ); 5 | 6 | void updateLoadDistance(int loadDistance); 7 | 8 | void onChunkStatusAdded(int x, int z, int flags); 9 | void onChunkStatusRemoved(int x, int z, int flags); 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/occlusion/GraphDirectionSet.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.occlusion; 2 | 3 | public class GraphDirectionSet { 4 | public static final int NONE = 0; 5 | public static final int ALL = (1 << GraphDirection.COUNT) - 1; 6 | 7 | public static int of(int direction) { 8 | return 1 << direction; 9 | } 10 | 11 | public static boolean contains(int set, int direction) { 12 | return (set & GraphDirectionSet.of(direction)) != 0; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkFogMode.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.shader; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | 5 | import java.util.List; 6 | import java.util.function.Function; 7 | 8 | public enum ChunkFogMode { 9 | NONE(ChunkShaderFogComponent.None::new, ImmutableList.of()), 10 | SMOOTH(ChunkShaderFogComponent.Smooth::new, ImmutableList.of("USE_FOG", "USE_FOG_SMOOTH")); 11 | 12 | private final Function factory; 13 | private final List defines; 14 | 15 | ChunkFogMode(Function factory, List defines) { 16 | this.factory = factory; 17 | this.defines = defines; 18 | } 19 | 20 | public Function getFactory() { 21 | return this.factory; 22 | } 23 | 24 | public List getDefines() { 25 | return this.defines; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkShaderBindingPoints.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.shader; 2 | 3 | public class ChunkShaderBindingPoints { 4 | public static final int ATTRIBUTE_POSITION = 0; 5 | public static final int ATTRIBUTE_COLOR = 1; 6 | public static final int ATTRIBUTE_TEXTURE = 2; 7 | public static final int ATTRIBUTE_LIGHT_MATERIAL_INDEX = 3; 8 | 9 | public static final int FRAG_COLOR = 0; 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkShaderInterface.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.shader; 2 | 3 | import org.joml.Matrix4fc; 4 | 5 | public interface ChunkShaderInterface { 6 | @Deprecated 7 | void setupState(); 8 | 9 | @Deprecated 10 | void resetState(); 11 | 12 | void setProjectionMatrix(Matrix4fc matrix); 13 | 14 | void setModelViewMatrix(Matrix4fc matrix); 15 | 16 | void setRegionOffset(float x, float y, float z); 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkShaderOptions.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.shader; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.shader.ShaderConstants; 4 | import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; 5 | import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType; 6 | 7 | public record ChunkShaderOptions(ChunkFogMode fog, TerrainRenderPass pass, ChunkVertexType vertexType) { 8 | public ShaderConstants constants() { 9 | ShaderConstants.Builder constants = ShaderConstants.builder(); 10 | constants.addAll(this.fog.getDefines()); 11 | 12 | if (this.pass.supportsFragmentDiscard()) { 13 | constants.add("USE_FRAGMENT_DISCARD"); 14 | } 15 | 16 | constants.add("USE_VERTEX_COMPRESSION"); // TODO: allow compact vertex format to be disabled 17 | 18 | return constants.build(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkShaderTextureSlot.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.shader; 2 | 3 | public enum ChunkShaderTextureSlot { 4 | BLOCK, 5 | LIGHT; 6 | 7 | public static final ChunkShaderTextureSlot[] VALUES = ChunkShaderTextureSlot.values(); 8 | } 9 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ShaderBindingContext.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.shader; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniform; 4 | import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformBlock; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import java.util.function.IntFunction; 9 | 10 | public interface ShaderBindingContext { 11 | @NotNull 12 | > U bindUniform(String name, IntFunction factory); 13 | 14 | @Nullable 15 | > U bindUniformOptional(String name, IntFunction factory); 16 | 17 | @NotNull 18 | GlUniformBlock bindUniformBlock(String name, int bindingPoint); 19 | 20 | @Nullable 21 | GlUniformBlock bindUniformBlockOptional(String name, int bindingPoint); 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/DefaultTerrainRenderPasses.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.terrain; 2 | 3 | import net.minecraft.client.renderer.RenderType; 4 | 5 | public class DefaultTerrainRenderPasses { 6 | public static final TerrainRenderPass SOLID = new TerrainRenderPass(RenderType.solid(), false, false); 7 | public static final TerrainRenderPass CUTOUT = new TerrainRenderPass(RenderType.cutoutMipped(), false, true); 8 | public static final TerrainRenderPass TRANSLUCENT = new TerrainRenderPass(RenderType.translucent(), true, false); 9 | 10 | 11 | public static final TerrainRenderPass[] ALL = new TerrainRenderPass[] { SOLID, CUTOUT, TRANSLUCENT }; 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.terrain; 2 | 3 | import net.minecraft.client.renderer.RenderType; 4 | 5 | public class TerrainRenderPass { 6 | @Deprecated(forRemoval = true) 7 | private final RenderType renderType; 8 | 9 | private final boolean isTranslucent; 10 | private final boolean fragmentDiscard; 11 | 12 | public TerrainRenderPass(RenderType renderType, boolean isTranslucent, boolean allowFragmentDiscard) { 13 | this.renderType = renderType; 14 | 15 | this.isTranslucent = isTranslucent; 16 | this.fragmentDiscard = allowFragmentDiscard; 17 | } 18 | 19 | public boolean isTranslucent() { 20 | return this.isTranslucent; 21 | } 22 | 23 | @Deprecated 24 | public void startDrawing() { 25 | this.renderType.setupRenderState(); 26 | } 27 | 28 | @Deprecated 29 | public void endDrawing() { 30 | this.renderType.clearRenderState(); 31 | } 32 | 33 | public boolean supportsFragmentDiscard() { 34 | return this.fragmentDiscard; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/material/Material.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.terrain.material; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; 4 | import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.parameters.AlphaCutoffParameter; 5 | import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.parameters.MaterialParameters; 6 | 7 | public class Material { 8 | public final TerrainRenderPass pass; 9 | public final int packed; 10 | 11 | public final AlphaCutoffParameter alphaCutoff; 12 | public final boolean mipped; 13 | 14 | public Material(TerrainRenderPass pass, AlphaCutoffParameter alphaCutoff, boolean mipped) { 15 | this.pass = pass; 16 | this.packed = MaterialParameters.pack(alphaCutoff, mipped); 17 | 18 | this.alphaCutoff = alphaCutoff; 19 | this.mipped = mipped; 20 | } 21 | 22 | public int bits() { 23 | return this.packed; 24 | } 25 | 26 | public boolean isTranslucent() { 27 | return this.pass.isTranslucent(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/material/parameters/AlphaCutoffParameter.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.parameters; 2 | 3 | public enum AlphaCutoffParameter { 4 | ZERO, // 0.0f 5 | ONE_TENTH, // 0.1f 6 | HALF, // 0.5f 7 | ONE // 1.0f 8 | } 9 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/material/parameters/MaterialParameters.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.parameters; 2 | 3 | public class MaterialParameters { 4 | public static final int OFFSET_USE_MIP = 0; 5 | public static final int OFFSET_ALPHA_CUTOFF = 1; 6 | 7 | public static int pack(AlphaCutoffParameter alphaCutoff, boolean useMipmaps) { 8 | return (((useMipmaps ? 1 : 0) << OFFSET_USE_MIP) | 9 | ((alphaCutoff.ordinal()) << OFFSET_ALPHA_CUTOFF)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/bsp_tree/BSPBuildFailureException.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.bsp_tree; 2 | 3 | public class BSPBuildFailureException extends RuntimeException { 4 | BSPBuildFailureException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/bsp_tree/BSPResult.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.bsp_tree; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.trigger.GeometryPlanes; 4 | 5 | /** 6 | * The result of a BSP building operation. Building a BSP returns the root node 7 | * along with the partition planes that need to be added to the trigger system. 8 | */ 9 | public class BSPResult extends GeometryPlanes { 10 | private BSPNode rootNode; 11 | 12 | public BSPNode getRootNode() { 13 | return this.rootNode; 14 | } 15 | 16 | public void setRootNode(BSPNode rootNode) { 17 | this.rootNode = rootNode; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/bsp_tree/LeafDoubleBSPNode.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.bsp_tree; 2 | 3 | import org.joml.Vector3fc; 4 | 5 | /** 6 | * A leaf node of a BSP tree that contains two quads. 7 | */ 8 | public class LeafDoubleBSPNode extends BSPNode { 9 | private final int quadA; 10 | private final int quadB; 11 | 12 | LeafDoubleBSPNode(int quadA, int quadB) { 13 | this.quadA = quadA; 14 | this.quadB = quadB; 15 | } 16 | 17 | @Override 18 | void collectSortedQuads(BSPSortState sortState, Vector3fc cameraPos) { 19 | sortState.writeIndex(this.quadA); 20 | sortState.writeIndex(this.quadB); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/bsp_tree/LeafMultiBSPNode.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.bsp_tree; 2 | 3 | import org.joml.Vector3fc; 4 | 5 | /** 6 | * A leaf node of a BSP tree that contains a set of quads. 7 | */ 8 | class LeafMultiBSPNode extends BSPNode { 9 | private final int[] quads; 10 | 11 | LeafMultiBSPNode(int[] quads) { 12 | this.quads = quads; 13 | } 14 | 15 | @Override 16 | void collectSortedQuads(BSPSortState sortState, Vector3fc cameraPos) { 17 | sortState.writeIndexes(this.quads); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/bsp_tree/LeafSingleBSPNode.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.bsp_tree; 2 | 3 | import org.joml.Vector3fc; 4 | 5 | /** 6 | * A leaf node of a BSP tree that contains a single quad. 7 | */ 8 | class LeafSingleBSPNode extends BSPNode { 9 | private final int quad; 10 | 11 | LeafSingleBSPNode(int quad) { 12 | this.quad = quad; 13 | } 14 | 15 | @Override 16 | void collectSortedQuads(BSPSortState sortState, Vector3fc cameraPos) { 17 | sortState.writeIndex(this.quad); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/bsp_tree/Partition.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.bsp_tree; 2 | 3 | import it.unimi.dsi.fastutil.ints.IntArrayList; 4 | 5 | /** 6 | * Models a partition of the space into a set of quads that lie inside or on the 7 | * plane with the specified distance. If the distance is -1 this is the "end" 8 | * partition after the last partition plane. 9 | */ 10 | record Partition(float distance, IntArrayList quadsBefore, IntArrayList quadsOn) { 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/CombinedCameraPos.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | import org.joml.Vector3dc; 4 | import org.joml.Vector3fc; 5 | 6 | public interface CombinedCameraPos { 7 | Vector3fc getRelativeCameraPos(); 8 | 9 | Vector3dc getAbsoluteCameraPos(); 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/DynamicSorter.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | abstract class DynamicSorter extends PresentSorter { 4 | private final int quadCount; 5 | 6 | DynamicSorter(int quadCount) { 7 | this.quadCount = quadCount; 8 | } 9 | 10 | abstract void writeSort(CombinedCameraPos cameraPos, boolean initial); 11 | 12 | @Override 13 | public void writeIndexBuffer(CombinedCameraPos cameraPos, boolean initial) { 14 | this.initBufferWithQuadLength(this.quadCount); 15 | this.writeSort(cameraPos, initial); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/MixedDirectionData.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFacing; 4 | import net.minecraft.core.SectionPos; 5 | 6 | public abstract class MixedDirectionData extends PresentTranslucentData { 7 | private final int[] vertexCounts = new int[ModelQuadFacing.COUNT]; 8 | 9 | MixedDirectionData(SectionPos sectionPos, int vertexCount, int quadCount) { 10 | super(sectionPos, quadCount); 11 | this.vertexCounts[ModelQuadFacing.UNASSIGNED.ordinal()] = vertexCount; 12 | } 13 | 14 | @Override 15 | public int[] getVertexCounts() { 16 | return this.vertexCounts; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/NoData.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.SortType; 4 | import net.minecraft.core.SectionPos; 5 | 6 | /** 7 | * This class means there is no translucent data and is used to signal that the 8 | * section should be removed from triggering data structures. 9 | * 10 | * If translucent sorting is disabled, not even this class is used, but null is 11 | * passed instead. 12 | */ 13 | public class NoData extends TranslucentData { 14 | private final SortType reason; 15 | 16 | private NoData(SectionPos sectionPos, SortType reason) { 17 | super(sectionPos); 18 | this.reason = reason; 19 | } 20 | 21 | @Override 22 | public SortType getSortType() { 23 | return this.reason; 24 | } 25 | 26 | public static NoData forEmptySection(SectionPos sectionPos) { 27 | return new NoData(sectionPos, SortType.EMPTY_SECTION); 28 | } 29 | 30 | public static NoData forNoTranslucent(SectionPos sectionPos) { 31 | return new NoData(sectionPos, SortType.NO_TRANSLUCENT); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/PresentSortData.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | import net.caffeinemc.mods.sodium.client.util.NativeBuffer; 4 | 5 | import java.nio.IntBuffer; 6 | 7 | public interface PresentSortData { 8 | NativeBuffer getIndexBuffer(); 9 | 10 | default IntBuffer getIntBuffer() { 11 | return this.getIndexBuffer().getDirectBuffer().asIntBuffer(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/PresentSorter.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | import net.caffeinemc.mods.sodium.client.util.NativeBuffer; 4 | 5 | public abstract class PresentSorter implements Sorter { 6 | private NativeBuffer indexBuffer; 7 | 8 | @Override 9 | public NativeBuffer getIndexBuffer() { 10 | return this.indexBuffer; 11 | } 12 | 13 | void initBufferWithQuadLength(int quadCount) { 14 | this.indexBuffer = new NativeBuffer(TranslucentData.quadCountToIndexBytes(quadCount)); 15 | } 16 | 17 | @Override 18 | public void destroy() { 19 | if (this.indexBuffer != null) { 20 | this.indexBuffer.free(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/PresentTranslucentData.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | import net.minecraft.core.SectionPos; 4 | 5 | /** 6 | * Super class for translucent data that contains an actual buffer. 7 | */ 8 | public abstract class PresentTranslucentData extends TranslucentData { 9 | protected final int quadCount; 10 | private int quadHash; 11 | 12 | PresentTranslucentData(SectionPos sectionPos, int quadCount) { 13 | super(sectionPos); 14 | this.quadCount = quadCount; 15 | } 16 | 17 | public abstract int[] getVertexCounts(); 18 | 19 | public abstract Sorter getSorter(); 20 | 21 | public void setQuadHash(int hash) { 22 | this.quadHash = hash; 23 | } 24 | 25 | public int getQuadHash() { 26 | return this.quadHash; 27 | } 28 | 29 | public int getQuadCount() { 30 | return this.quadCount; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/SharedIndexSorter.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | import net.caffeinemc.mods.sodium.client.util.NativeBuffer; 4 | 5 | import java.nio.IntBuffer; 6 | 7 | public record SharedIndexSorter(int quadCount) implements Sorter { 8 | @Override 9 | public NativeBuffer getIndexBuffer() { 10 | return null; 11 | } 12 | 13 | @Override 14 | public IntBuffer getIntBuffer() { 15 | return null; 16 | } 17 | 18 | @Override 19 | public void writeIndexBuffer(CombinedCameraPos cameraPos, boolean initial) { 20 | // no-op 21 | } 22 | 23 | @Override 24 | public void destroy() { 25 | // no-op 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/Sorter.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | public interface Sorter extends PresentSortData { 4 | void writeIndexBuffer(CombinedCameraPos cameraPos, boolean initial); 5 | 6 | void destroy(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/SplitDirectionData.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | import net.minecraft.core.SectionPos; 4 | 5 | /** 6 | * Super class for translucent data that is rendered separately for each facing. 7 | * (block face culling is possible) It's important that the indices are inserted 8 | * starting at zero for each facing. 9 | */ 10 | public abstract class SplitDirectionData extends PresentTranslucentData { 11 | private final int[] vertexCounts; 12 | 13 | public SplitDirectionData(SectionPos sectionPos, int[] vertexCounts, int quadCount) { 14 | super(sectionPos, quadCount); 15 | this.vertexCounts = vertexCounts; 16 | } 17 | 18 | @Override 19 | public int[] getVertexCounts() { 20 | return this.vertexCounts; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/data/StaticSorter.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.data; 2 | 3 | class StaticSorter extends PresentSorter { 4 | StaticSorter(int quadCount) { 5 | this.initBufferWithQuadLength(quadCount); 6 | } 7 | 8 | @Override 9 | public void writeIndexBuffer(CombinedCameraPos cameraPos, boolean initial) { 10 | // no-op 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/translucent_sorting/trigger/CameraMovement.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.trigger; 2 | 3 | import org.joml.Vector3dc; 4 | 5 | public record CameraMovement(Vector3dc start, Vector3dc end) { 6 | public boolean hasChanged() { 7 | return !this.start.equals(this.end); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkMeshFormats.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.vertex.format; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.impl.CompactChunkVertex; 4 | 5 | public class ChunkMeshFormats { 6 | public static final ChunkVertexType COMPACT = new CompactChunkVertex(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkVertexEncoder.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.vertex.format; 2 | 3 | public interface ChunkVertexEncoder { 4 | long write(long ptr, int materialBits, Vertex[] vertices, int sectionIndex); 5 | 6 | class Vertex { 7 | public float x; 8 | public float y; 9 | public float z; 10 | public int color; 11 | public float ao; 12 | public float u; 13 | public float v; 14 | public int light; 15 | 16 | public static Vertex[] uninitializedQuad() { 17 | Vertex[] vertices = new Vertex[4]; 18 | 19 | for (int i = 0; i < 4; i++) { 20 | vertices[i] = new Vertex(); 21 | } 22 | 23 | return vertices; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkVertexType.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.vertex.format; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexFormat; 4 | 5 | public interface ChunkVertexType { 6 | GlVertexFormat getVertexFormat(); 7 | 8 | ChunkVertexEncoder getEncoder(); 9 | } 10 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/DefaultChunkMeshAttributes.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.impl; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexAttributeFormat; 4 | import net.caffeinemc.mods.sodium.client.render.vertex.VertexFormatAttribute; 5 | 6 | public class DefaultChunkMeshAttributes { 7 | public static final VertexFormatAttribute POSITION = new VertexFormatAttribute("POSITION", GlVertexAttributeFormat.UNSIGNED_INT, 2, false, true); 8 | public static final VertexFormatAttribute COLOR = new VertexFormatAttribute("COLOR", GlVertexAttributeFormat.UNSIGNED_BYTE, 4, true, false); 9 | public static final VertexFormatAttribute TEXTURE = new VertexFormatAttribute("TEXTURE", GlVertexAttributeFormat.UNSIGNED_SHORT, 2, false, true); 10 | public static final VertexFormatAttribute LIGHT_MATERIAL_INDEX = new VertexFormatAttribute("LIGHT_MATERIAL_INDEX", GlVertexAttributeFormat.UNSIGNED_BYTE, 4, false, true); 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/AbstractRenderContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, 2017, 2018, 2019 FabricMC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.caffeinemc.mods.sodium.client.render.frapi.render; 18 | 19 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 20 | import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh; 21 | import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView; 22 | import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter; 23 | 24 | import java.util.function.Consumer; 25 | 26 | public abstract class AbstractRenderContext { 27 | abstract QuadEmitter getEmitter(); 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/AmbientOcclusionMode.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.frapi.render; 2 | 3 | public enum AmbientOcclusionMode { 4 | ENABLED, 5 | DEFAULT, 6 | DISABLED 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteContentsExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.texture; 2 | 3 | public interface SpriteContentsExtension { 4 | void sodium$setActive(boolean value); 5 | boolean sodium$isActive(); 6 | 7 | boolean sodium$hasAnimation(); 8 | } 9 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteFinderCache.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.texture; 2 | 3 | import net.fabricmc.fabric.api.renderer.v1.model.SpriteFinder; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.renderer.texture.TextureAtlas; 6 | 7 | /** 8 | * Caches {@link SpriteFinder}s for maximum efficiency. They must be refreshed after each resource reload. 9 | * 10 | *

This class should not be used during a resource reload, as returned SpriteFinders may be null or outdated. 11 | */ 12 | public class SpriteFinderCache { 13 | private static SpriteFinder blockAtlasSpriteFinder; 14 | 15 | public static SpriteFinder forBlockAtlas() { 16 | if (blockAtlasSpriteFinder == null) { 17 | blockAtlasSpriteFinder = SpriteFinder.get(Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS)); 18 | } 19 | 20 | return blockAtlasSpriteFinder; 21 | } 22 | 23 | public static void resetSpriteFinder() { 24 | blockAtlasSpriteFinder = null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtil.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.texture; 2 | 3 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | // Kept for mod compatibility, to be removed in next major release. 7 | @Deprecated(forRemoval = true) 8 | public class SpriteUtil { 9 | @Deprecated(forRemoval = true) 10 | public static void markSpriteActive(@Nullable TextureAtlasSprite sprite) { 11 | if (sprite != null) { 12 | net.caffeinemc.mods.sodium.api.texture.SpriteUtil.INSTANCE.markSpriteActive(sprite); 13 | } 14 | } 15 | 16 | @Deprecated(forRemoval = true) 17 | public static boolean hasAnimation(@Nullable TextureAtlasSprite sprite) { 18 | if (sprite != null) { 19 | return net.caffeinemc.mods.sodium.api.texture.SpriteUtil.INSTANCE.hasAnimation(sprite); 20 | } 21 | 22 | return false; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtilImpl.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.texture; 2 | 3 | import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; 4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Objects; 8 | 9 | public class SpriteUtilImpl implements SpriteUtil { 10 | @Override 11 | public void markSpriteActive(@NotNull TextureAtlasSprite sprite) { 12 | Objects.requireNonNull(sprite); 13 | 14 | ((SpriteContentsExtension) sprite.contents()).sodium$setActive(true); 15 | } 16 | 17 | @Override 18 | public boolean hasAnimation(@NotNull TextureAtlasSprite sprite) { 19 | Objects.requireNonNull(sprite); 20 | 21 | return ((SpriteContentsExtension) sprite.contents()).sodium$hasAnimation(); 22 | } 23 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/DeferredRenderTask.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.util; 2 | 3 | import java.util.concurrent.ConcurrentLinkedDeque; 4 | 5 | public class DeferredRenderTask { 6 | private static final ConcurrentLinkedDeque queue = new ConcurrentLinkedDeque<>(); 7 | 8 | /** 9 | * Schedules a render task to be executed on the main render thread as soon as possible. This is often at the 10 | * start of the next frame. 11 | * @param runnable The task to be executed on the render thread 12 | */ 13 | public static void schedule(Runnable runnable) { 14 | queue.add(runnable); 15 | } 16 | 17 | /** 18 | * Executes all currently pending render tasks. This should only be called from the main render thread! 19 | */ 20 | public static void runAll() { 21 | RenderAsserts.validateCurrentThread(); 22 | 23 | Runnable runnable; 24 | 25 | while ((runnable = queue.poll()) != null) { 26 | try { 27 | runnable.run(); 28 | } catch (Throwable throwable) { 29 | throw new RuntimeException("Failed to execute deferred render task", throwable); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/RenderAsserts.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | 5 | public class RenderAsserts { 6 | /** 7 | * Checks that the thread calling this function is the main render thread. This is useful for ensuring that OpenGL 8 | * APIs are not accessed from off-thread incorrectly, which is known to cause severe issues. 9 | * 10 | * @throws IllegalStateException If the current thread is not the main render thread 11 | * @return Always true, since an exception is thrown otherwise 12 | */ 13 | public static boolean validateCurrentThread() { 14 | if (!RenderSystem.isOnRenderThread()) { 15 | throw new IllegalStateException("Tried to access render state from outside the main render thread! " + 16 | "This was very likely caused by another misbehaving mod -- make sure to examine the stack trace below."); 17 | } 18 | 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerTracker.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.vertex; 2 | 3 | import com.mojang.blaze3d.vertex.VertexConsumer; 4 | import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; 5 | import it.unimi.dsi.fastutil.objects.ReferenceSet; 6 | import it.unimi.dsi.fastutil.objects.ReferenceSets; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | public class VertexConsumerTracker { 11 | private static final Logger LOGGER = LoggerFactory.getLogger("Sodium-VertexConsumerTracker"); 12 | private static final ReferenceSet> BAD_CONSUMERS = ReferenceSets.synchronize(new ReferenceOpenHashSet<>()); 13 | 14 | public static void logBadConsumer(VertexConsumer consumer) { 15 | if (BAD_CONSUMERS.add(consumer.getClass())) { 16 | LOGGER.warn("Class {} does not support optimized vertex writing code paths, which may cause reduced rendering performance", 17 | consumer.getClass().getName()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerUtils.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.vertex; 2 | 3 | import com.mojang.blaze3d.vertex.VertexConsumer; 4 | import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; 5 | 6 | import javax.annotation.Nullable; 7 | 8 | public class VertexConsumerUtils { 9 | /** 10 | * Attempt to convert a {@link VertexConsumer} into a {@link VertexBufferWriter}. If this fails, return null 11 | * and log a message. 12 | * @param consumer the consumer to convert 13 | * @return a {@link VertexBufferWriter}, or null if the consumer does not support this 14 | */ 15 | public static @Nullable VertexBufferWriter convertOrLog(VertexConsumer consumer) { 16 | VertexBufferWriter writer = VertexBufferWriter.tryOf(consumer); 17 | 18 | if (writer == null) { 19 | VertexConsumerTracker.logBadConsumer(consumer); 20 | } 21 | 22 | return writer; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatAttribute.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.vertex; 2 | 3 | import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexAttributeFormat; 4 | 5 | public record VertexFormatAttribute(String name, GlVertexAttributeFormat format, int count, boolean normalized, boolean intType) { 6 | 7 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/buffer/BufferBuilderExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.vertex.buffer; 2 | 3 | import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; 4 | 5 | public interface BufferBuilderExtension extends VertexBufferWriter { 6 | void sodium$duplicateVertex(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/viewport/ViewportProvider.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.viewport; 2 | 3 | public interface ViewportProvider { 4 | Viewport sodium$createViewport(); 5 | } 6 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/viewport/frustum/Frustum.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.viewport.frustum; 2 | 3 | public interface Frustum { 4 | boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ); 5 | } 6 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/render/viewport/frustum/SimpleFrustum.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.render.viewport.frustum; 2 | 3 | import org.joml.FrustumIntersection; 4 | 5 | public final class SimpleFrustum implements Frustum { 6 | private final FrustumIntersection frustum; 7 | 8 | public SimpleFrustum(FrustumIntersection frustumIntersection) { 9 | this.frustum = frustumIntersection; 10 | } 11 | 12 | @Override 13 | public boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { 14 | return this.frustum.testAab(minX, minY, minZ, maxX, maxY, maxZ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformMixinOverrides.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.services; 2 | 3 | import java.util.List; 4 | 5 | public interface PlatformMixinOverrides { 6 | PlatformMixinOverrides INSTANCE = Services.load(PlatformMixinOverrides.class); 7 | 8 | static PlatformMixinOverrides getInstance() { 9 | return INSTANCE; 10 | } 11 | 12 | List applyModOverrides(); 13 | 14 | record MixinOverride(String modId, String option, boolean enabled) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/services/Services.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.services; 2 | 3 | import net.caffeinemc.mods.sodium.client.SodiumClientMod; 4 | 5 | import java.util.ServiceLoader; 6 | 7 | public class Services { 8 | // This code is used to load a service for the current environment. Your implementation of the service must be defined 9 | // manually by including a text file in META-INF/services named with the fully qualified class name of the service. 10 | // Inside the file you should write the fully qualified class name of the implementation to load for the platform. 11 | public static T load(Class clazz) { 12 | final T loadedService = ServiceLoader.load(clazz) 13 | .findFirst() 14 | .orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName())); 15 | SodiumClientMod.logger().debug("Loaded {} for service {}", loadedService, clazz); 16 | return loadedService; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelData.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.services; 2 | 3 | /** 4 | * Template class for the platform's model data. This is used to pass around Forge model data in a multiloader environment seamlessly. 5 | */ 6 | public interface SodiumModelData { 7 | SodiumModelData EMPTY = PlatformModelAccess.getInstance().getEmptyModelData(); 8 | } 9 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelDataContainer.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.services; 2 | 3 | import it.unimi.dsi.fastutil.longs.Long2ObjectMap; 4 | import net.minecraft.core.BlockPos; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * A container that holds the platform's model data. 10 | */ 11 | public class SodiumModelDataContainer { 12 | private final Long2ObjectMap modelDataMap; 13 | private final boolean isEmpty; 14 | 15 | public SodiumModelDataContainer(Long2ObjectMap modelDataMap) { 16 | this.modelDataMap = modelDataMap; 17 | this.isEmpty = modelDataMap.isEmpty(); 18 | } 19 | 20 | public SodiumModelData getModelData(BlockPos pos) { 21 | return modelDataMap.getOrDefault(pos.asLong(), SodiumModelData.EMPTY); 22 | } 23 | 24 | public boolean isEmpty() { 25 | return isEmpty; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/BitwiseMath.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | public class BitwiseMath { 4 | // returns (1) if (a < b), otherwise (0) 5 | // valid for all values of (a) and (b) 6 | public static int lessThan(int a, int b) { 7 | return (a - b) >>> 31; 8 | } 9 | 10 | // returns (1) if (a > b), otherwise (0) 11 | // valid for all values of (a) and (b) 12 | public static int greaterThan(int a, int b) { 13 | return (b - a) >>> 31; 14 | } 15 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/Dim2i.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | public record Dim2i(int x, int y, int width, int height) { 4 | public int getLimitX() { 5 | return this.x + this.width; 6 | } 7 | 8 | public int getLimitY() { 9 | return this.y + this.height; 10 | } 11 | 12 | public boolean containsCursor(double x, double y) { 13 | return x >= this.x && x < this.getLimitX() && y >= this.y && y < this.getLimitY(); 14 | } 15 | 16 | public int getCenterX() { 17 | return this.x + (this.width / 2); 18 | } 19 | 20 | public int getCenterY() { 21 | return this.y + (this.height / 2); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/DirectionUtil.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | import java.util.Arrays; 4 | import net.minecraft.core.Direction; 5 | 6 | /** 7 | * Contains a number of cached arrays to avoid allocations since calling Enum#values() requires the backing array to 8 | * be cloned every time. 9 | */ 10 | public class DirectionUtil { 11 | public static final Direction[] ALL_DIRECTIONS = Direction.values(); 12 | 13 | // Provides the same order as enumerating Direction and checking the axis of each value 14 | public static final Direction[] HORIZONTAL_DIRECTIONS = new Direction[] { Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST }; 15 | 16 | private static final Direction[] OPPOSITE_DIRECTIONS = Arrays.stream(ALL_DIRECTIONS) 17 | .map(Direction::getOpposite) 18 | .toArray(Direction[]::new); 19 | 20 | // Direction#byId is slow in the absence of Lithium 21 | public static Direction getOpposite(Direction dir) { 22 | return OPPOSITE_DIRECTIONS[dir.ordinal()]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/FileUtil.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Path; 6 | import java.nio.file.StandardCopyOption; 7 | 8 | public class FileUtil { 9 | public static void writeTextRobustly(String text, Path path) throws IOException { 10 | // Use a temporary location next to the config's final destination 11 | Path tempPath = path.resolveSibling(path.getFileName() + ".tmp"); 12 | 13 | // Write the file to our temporary location 14 | Files.writeString(tempPath, text); 15 | 16 | // Atomically replace the old config file (if it exists) with the temporary file 17 | Files.move(tempPath, path, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/Int2.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | import java.nio.ByteOrder; 4 | 5 | public class Int2 { 6 | public static long pack(int a, int b) { 7 | if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { 8 | return ((a & 0xFFFFFFFFL) << 0) | ((b & 0xFFFFFFFFL) << 32); 9 | } else { 10 | return ((a & 0xFFFFFFFFL) << 32) | ((b & 0xFFFFFFFFL) << 0); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/ListUtil.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | import java.util.Collection; 4 | 5 | public class ListUtil { 6 | public static void updateList(Collection collection, Collection before, Collection after) { 7 | if (!before.isEmpty()) { 8 | collection.removeAll(before); 9 | } 10 | 11 | if (!after.isEmpty()) { 12 | collection.addAll(after); 13 | } 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/NativeImageHelper.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | import net.caffeinemc.mods.sodium.mixin.features.textures.NativeImageAccessor; 4 | import com.mojang.blaze3d.platform.NativeImage; 5 | 6 | import java.util.Locale; 7 | 8 | public class NativeImageHelper { 9 | public static long getPointerRGBA(NativeImage nativeImage) { 10 | if (nativeImage.format() != NativeImage.Format.RGBA) { 11 | throw new IllegalArgumentException(String.format(Locale.ROOT, 12 | "Tried to get pointer to RGBA pixel data on NativeImage of wrong format; have %s", nativeImage.format())); 13 | } 14 | 15 | return ((NativeImageAccessor) (Object) nativeImage) // duck type since NativeImage is final 16 | .getPixels(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/TextureUtil.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | 5 | public class TextureUtil { 6 | 7 | /** 8 | * NOTE: Must be called while a RenderLayer is active. 9 | */ 10 | public static int getLightTextureId() { 11 | return RenderSystem.getShaderTexture(2); 12 | } 13 | 14 | /** 15 | * NOTE: Must be called while a RenderLayer is active. 16 | */ 17 | public static int getBlockTextureId() { 18 | return RenderSystem.getShaderTexture(0); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/UInt32.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | public class UInt32 { 4 | public static long upcast(int x) { 5 | return Integer.toUnsignedLong(x); 6 | } 7 | 8 | public static int downcast(long x) { 9 | if (x < 0) { 10 | throw new IllegalArgumentException("x < 0"); 11 | } else if (x >= (1L << 32)) { 12 | throw new IllegalArgumentException("x >= (1 << 32)"); 13 | } 14 | 15 | return (int) x; 16 | } 17 | 18 | // Note: This is unsafe when (x) exceeds the maximum range of a UInt32. 19 | public static int uncheckedDowncast(long x) { 20 | return (int) x; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/WeightedRandomListExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util; 2 | 3 | import net.minecraft.util.RandomSource; 4 | 5 | public interface WeightedRandomListExtension { 6 | T sodium$getQuick(RandomSource random); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/collections/ReadQueue.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util.collections; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | public interface ReadQueue { 6 | @Nullable E dequeue(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/collections/WriteQueue.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util.collections; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public interface WriteQueue { 6 | void ensureCapacity(int numElements); 7 | 8 | void enqueue(@NotNull E e); 9 | } 10 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/iterator/ByteArrayIterator.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util.iterator; 2 | 3 | import java.util.NoSuchElementException; 4 | 5 | public class ByteArrayIterator implements ByteIterator { 6 | private final byte[] elements; 7 | private final int lastIndex; 8 | 9 | private int index; 10 | 11 | public ByteArrayIterator(byte[] elements, int lastIndex) { 12 | this.elements = elements; 13 | this.lastIndex = lastIndex; 14 | this.index = 0; 15 | } 16 | 17 | @Override 18 | public boolean hasNext() { 19 | return this.index < this.lastIndex; 20 | } 21 | 22 | @Override 23 | public int nextByteAsInt() { 24 | if (!this.hasNext()) { 25 | throw new NoSuchElementException(); 26 | } 27 | 28 | return Byte.toUnsignedInt(this.elements[this.index++]); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/iterator/ByteIterator.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util.iterator; 2 | 3 | public interface ByteIterator { 4 | boolean hasNext(); 5 | 6 | int nextByteAsInt(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/iterator/ReversibleByteArrayIterator.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util.iterator; 2 | 3 | import java.util.NoSuchElementException; 4 | 5 | 6 | public class ReversibleByteArrayIterator implements ByteIterator { 7 | private final byte[] elements; 8 | 9 | private final int step; 10 | 11 | private int currentIndex; 12 | private int remaining; 13 | 14 | public ReversibleByteArrayIterator(byte[] elements, int size, boolean reverse) { 15 | this.elements = elements; 16 | this.remaining = size; 17 | 18 | this.step = reverse ? -1 : 1; 19 | this.currentIndex = reverse ? size - 1 : 0; 20 | } 21 | 22 | @Override 23 | public boolean hasNext() { 24 | return this.remaining > 0; 25 | } 26 | 27 | @Override 28 | public int nextByteAsInt() { 29 | if (!this.hasNext()) { 30 | throw new NoSuchElementException(); 31 | } 32 | 33 | int result = Byte.toUnsignedInt(this.elements[this.currentIndex]); 34 | 35 | this.currentIndex += this.step; 36 | this.remaining--; 37 | 38 | return result; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/iterator/WrappedIterator.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util.iterator; 2 | 3 | import java.util.Iterator; 4 | 5 | public class WrappedIterator implements Iterator { 6 | private final Iterator delegate; 7 | 8 | private WrappedIterator(Iterator delegate) { 9 | this.delegate = delegate; 10 | } 11 | 12 | public static WrappedIterator create(Iterable iterable) { 13 | return new WrappedIterator<>(iterable.iterator()); 14 | } 15 | 16 | @Override 17 | public boolean hasNext() { 18 | try { 19 | return this.delegate.hasNext(); 20 | } catch (Throwable t) { 21 | throw new Exception("Iterator#hasNext() threw unhandled exception", t); 22 | } 23 | } 24 | 25 | @Override 26 | public T next() { 27 | try { 28 | return this.delegate.next(); 29 | } catch (Throwable t) { 30 | throw new Exception("Iterator#next() threw unhandled exception", t); 31 | } 32 | } 33 | 34 | public static class Exception extends RuntimeException { 35 | private Exception(String message, Throwable t) { 36 | super(message, t); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/sorting/VertexSortingExtended.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util.sorting; 2 | 3 | import com.mojang.blaze3d.vertex.VertexSorting; 4 | import org.joml.Vector3f; 5 | 6 | public interface VertexSortingExtended extends VertexSorting { 7 | float applyMetric(float x, float y, float z); 8 | 9 | default float applyMetric(Vector3f vector) { 10 | return this.applyMetric(vector.x, vector.y, vector.z); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.util.task; 2 | 3 | public interface CancellationToken { 4 | boolean isCancelled(); 5 | 6 | void setCancelled(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/world/BiomeSeedProvider.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.world; 2 | 3 | import net.minecraft.client.multiplayer.ClientLevel; 4 | 5 | public interface BiomeSeedProvider { 6 | static long getBiomeZoomSeed(ClientLevel level) { 7 | return ((BiomeSeedProvider) level).sodium$getBiomeZoomSeed(); 8 | } 9 | 10 | long sodium$getBiomeZoomSeed(); 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/world/BitStorageExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.world; 2 | 3 | import net.minecraft.world.level.chunk.Palette; 4 | 5 | public interface BitStorageExtension { 6 | void sodium$unpack(T[] out, Palette palette); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelRendererExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.world; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; 4 | 5 | public interface LevelRendererExtension { 6 | SodiumWorldRenderer sodium$getWorldRenderer(); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/world/PalettedContainerROExtension.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.world; 2 | 3 | import net.minecraft.world.level.chunk.PalettedContainerRO; 4 | 5 | public interface PalettedContainerROExtension { 6 | @SuppressWarnings("unchecked") 7 | static PalettedContainerROExtension of(PalettedContainerRO container) { 8 | return (PalettedContainerROExtension) container; 9 | } 10 | 11 | static PalettedContainerRO clone(PalettedContainerRO container) { 12 | if (container == null) { 13 | return null; 14 | } 15 | 16 | return of(container).sodium$copy(); 17 | } 18 | 19 | void sodium$unpack(T[] values); 20 | void sodium$unpack(T[] values, int minX, int minY, int minZ, int maxX, int maxY, int maxZ); 21 | 22 | PalettedContainerRO sodium$copy(); 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/world/SodiumAuxiliaryLightManager.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.world; 2 | 3 | /** 4 | * This interface is used to pass Forge's AuxiliaryLightManager around in a multiloader environment. 5 | */ 6 | public interface SodiumAuxiliaryLightManager { 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.client.world.cloned; 2 | 3 | import net.caffeinemc.mods.sodium.client.services.SodiumModelDataContainer; 4 | import net.minecraft.core.SectionPos; 5 | import net.minecraft.world.level.levelgen.structure.BoundingBox; 6 | 7 | import java.util.List; 8 | 9 | public class ChunkRenderContext { 10 | private final SectionPos origin; 11 | private final ClonedChunkSection[] sections; 12 | private final BoundingBox volume; 13 | private final List renderers; 14 | 15 | public ChunkRenderContext(SectionPos origin, ClonedChunkSection[] sections, BoundingBox volume, List renderers) { 16 | this.origin = origin; 17 | this.sections = sections; 18 | this.volume = volume; 19 | this.renderers = renderers; 20 | } 21 | 22 | public ClonedChunkSection[] getSections() { 23 | return this.sections; 24 | } 25 | 26 | public SectionPos getOrigin() { 27 | return this.origin; 28 | } 29 | 30 | public BoundingBox getVolume() { 31 | return this.volume; 32 | } 33 | 34 | public List getRenderers() { 35 | return renderers; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/gui/LevelLoadStatusManagerMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.core.gui; 2 | 3 | import net.minecraft.client.multiplayer.LevelLoadStatusManager; 4 | import net.minecraft.client.player.LocalPlayer; 5 | import net.minecraft.core.BlockPos; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Redirect; 9 | 10 | @Mixin(LevelLoadStatusManager.class) 11 | public class LevelLoadStatusManagerMixin { 12 | @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;blockPosition()Lnet/minecraft/core/BlockPos;")) 13 | private BlockPos redirect$getPlayerBlockPosition(LocalPlayer instance) { 14 | // Ensure the "eye" position (which the chunk rendering code is actually concerned about) is used instead of 15 | // the "feet" position. This solves a problem where the loading screen can become stuck waiting for the chunk 16 | // at the player's feet to load, when it is determined to not be visible due to the true location of the 17 | // player's eyes. 18 | return BlockPos.containing(instance.getX(), instance.getEyeY(), instance.getZ()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/model/TextureAtlasSpriteMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.core.model; 2 | 3 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.Overwrite; 6 | 7 | @Mixin(TextureAtlasSprite.class) 8 | public class TextureAtlasSpriteMixin { 9 | @Overwrite 10 | public float uvShrinkRatio() { 11 | // Vanilla tries to apply a bias to texture coordinates to avoid texture bleeding (see FaceBakery#bakeQuad). 12 | // This is counterproductive with Sodium's terrain rendering, since the bias is applied in the shader instead. 13 | // Overwrite this method instead of adjusting its return value in FaceBakery as other mods may use it to 14 | // manually apply the bias. 15 | return 0.0f; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/TextureAtlasMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.core.render; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.texture.SpriteFinderCache; 4 | import net.minecraft.client.renderer.texture.SpriteLoader; 5 | import net.minecraft.client.renderer.texture.TextureAtlas; 6 | import net.minecraft.resources.ResourceLocation; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @Mixin(TextureAtlas.class) 15 | public class TextureAtlasMixin { 16 | @Shadow 17 | @Final 18 | private ResourceLocation location; 19 | 20 | @Inject(method = "upload", at = @At("RETURN")) 21 | private void sodium$deleteSpriteFinder(SpriteLoader.Preparations preparations, CallbackInfo ci) { 22 | if (this.location.equals(TextureAtlas.LOCATION_BLOCKS)) { 23 | SpriteFinderCache.resetSpriteFinder(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/frustum/FrustumMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.core.render.frustum; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.viewport.frustum.SimpleFrustum; 4 | import net.minecraft.client.renderer.culling.Frustum; 5 | import net.caffeinemc.mods.sodium.client.render.viewport.Viewport; 6 | import net.caffeinemc.mods.sodium.client.render.viewport.ViewportProvider; 7 | import org.joml.FrustumIntersection; 8 | import org.joml.Vector3d; 9 | import org.spongepowered.asm.mixin.Final; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | 13 | @Mixin(Frustum.class) 14 | public class FrustumMixin implements ViewportProvider { 15 | @Shadow 16 | private double camX; 17 | 18 | @Shadow 19 | private double camY; 20 | 21 | @Shadow 22 | private double camZ; 23 | 24 | @Shadow 25 | @Final 26 | private FrustumIntersection intersection; 27 | 28 | @Override 29 | public Viewport sodium$createViewport() { 30 | return new Viewport(new SimpleFrustum(this.intersection), new Vector3d(this.camX, this.camY, this.camZ)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/texture/TextureAtlasAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.core.render.texture; 2 | 3 | import net.minecraft.client.renderer.texture.TextureAtlas; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | @Mixin(TextureAtlas.class) 8 | public interface TextureAtlasAccessor { 9 | @Accessor 10 | int getWidth(); 11 | 12 | @Accessor 13 | int getHeight(); 14 | } 15 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/EntityRendererAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.core.render.world; 2 | 3 | import net.minecraft.client.renderer.entity.EntityRenderer; 4 | import net.minecraft.world.entity.Entity; 5 | import net.minecraft.world.phys.AABB; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.gen.Invoker; 8 | 9 | @Mixin(EntityRenderer.class) 10 | public interface EntityRendererAccessor { 11 | @Invoker("getBoundingBoxForCulling") 12 | AABB getCullingBox(Entity entity); 13 | } 14 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/RenderBuffersMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.core.render.world; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.chunk.NonStoringBuilderPool; 4 | import net.minecraft.client.renderer.RenderBuffers; 5 | import net.minecraft.client.renderer.SectionBufferBuilderPool; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Redirect; 9 | 10 | @Mixin(RenderBuffers.class) 11 | public class RenderBuffersMixin { 12 | @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SectionBufferBuilderPool;allocate(I)Lnet/minecraft/client/renderer/SectionBufferBuilderPool;")) 13 | private SectionBufferBuilderPool sodium$doNotAllocateChunks(int i) { 14 | return new NonStoringBuilderPool(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/world/chunk/ZeroBitStorageMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.core.world.chunk; 2 | 3 | import net.caffeinemc.mods.sodium.client.world.BitStorageExtension; 4 | import net.minecraft.util.ZeroBitStorage; 5 | import net.minecraft.world.level.chunk.Palette; 6 | import org.spongepowered.asm.mixin.Final; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | 10 | import java.util.Arrays; 11 | import java.util.Objects; 12 | 13 | @Mixin(ZeroBitStorage.class) 14 | public class ZeroBitStorageMixin implements BitStorageExtension { 15 | @Shadow 16 | @Final 17 | private int size; 18 | 19 | @Override 20 | public void sodium$unpack(T[] out, Palette palette) { 21 | if (this.size != out.length) { 22 | throw new IllegalArgumentException("Array has mismatched size"); 23 | } 24 | 25 | var defaultValue = Objects.requireNonNull(palette.valueFor(0), "Palette must have default entry"); 26 | Arrays.fill(out, defaultValue); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/gui/hooks/settings/OptionsScreenMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.gui.hooks.settings; 2 | 3 | import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI; 4 | import net.minecraft.client.gui.screens.Screen; 5 | import net.minecraft.client.gui.screens.options.OptionsScreen; 6 | import net.minecraft.network.chat.Component; 7 | import org.spongepowered.asm.mixin.Dynamic; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | 13 | @Mixin(OptionsScreen.class) 14 | public class OptionsScreenMixin extends Screen { 15 | protected OptionsScreenMixin(Component title) { 16 | super(title); 17 | } 18 | 19 | @Dynamic 20 | @Inject(method = { 21 | "method_19828", 22 | "lambda$init$2" 23 | }, require = 1, at = @At("HEAD"), cancellable = true) 24 | private void open(CallbackInfoReturnable ci) { 25 | ci.setReturnValue(SodiumOptionsGUI.createScreen(this)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/options/overlays/GuiMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.options.overlays; 2 | 3 | import net.caffeinemc.mods.sodium.client.SodiumClientMod; 4 | import net.minecraft.client.gui.Gui; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Redirect; 8 | 9 | @Mixin(Gui.class) 10 | public class GuiMixin { 11 | @Redirect(method = "renderCameraOverlays", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;useFancyGraphics()Z")) 12 | private boolean redirectFancyGraphicsVignette() { 13 | return SodiumClientMod.options().quality.enableVignette; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/options/weather/LevelRendererMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.options.weather; 2 | 3 | import net.caffeinemc.mods.sodium.client.SodiumClientMod; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.renderer.LevelRenderer; 6 | import net.minecraft.client.renderer.WeatherEffectRenderer; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Redirect; 10 | 11 | @Mixin(WeatherEffectRenderer.class) 12 | public class LevelRendererMixin { 13 | @Redirect(method = "render(Lnet/minecraft/world/level/Level;Lnet/minecraft/client/renderer/MultiBufferSource;IFLnet/minecraft/world/phys/Vec3;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;useFancyGraphics()Z")) 14 | private boolean redirectGetFancyWeather() { 15 | return SodiumClientMod.options().quality.weatherQuality.isFancy(Minecraft.getInstance().options.graphicsMode().get()); 16 | } 17 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.render.compositing; 2 | 3 | 4 | import com.mojang.blaze3d.pipeline.RenderTarget; 5 | import org.lwjgl.opengl.GL32C; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Shadow; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(RenderTarget.class) 13 | public class RenderTargetMixin { 14 | @Shadow 15 | public int frameBufferId; 16 | 17 | @Shadow 18 | public int width; 19 | 20 | @Shadow 21 | public int height; 22 | 23 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/sorting/MeshDataAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.render.immediate.buffer_builder.sorting; 2 | 3 | import com.mojang.blaze3d.vertex.ByteBufferBuilder; 4 | import com.mojang.blaze3d.vertex.MeshData; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(MeshData.class) 9 | public interface MeshDataAccessor { 10 | @Accessor 11 | void setIndexBuffer(ByteBufferBuilder.Result buffer); 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/ItemBlockRenderTypesMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.render.model; 2 | 3 | import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; 4 | import org.spongepowered.asm.mixin.Final; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Mutable; 7 | import org.spongepowered.asm.mixin.Shadow; 8 | 9 | import java.util.Map; 10 | import net.minecraft.client.renderer.ItemBlockRenderTypes; 11 | import net.minecraft.client.renderer.RenderType; 12 | import net.minecraft.world.level.block.Block; 13 | import net.minecraft.world.level.material.Fluid; 14 | 15 | @Mixin(ItemBlockRenderTypes.class) 16 | public class ItemBlockRenderTypesMixin { 17 | @Mutable 18 | @Shadow 19 | @Final 20 | private static Map TYPE_BY_BLOCK; 21 | 22 | @Mutable 23 | @Shadow 24 | @Final 25 | private static Map TYPE_BY_FLUID; 26 | 27 | static { 28 | // Replace the backing collection types with something a bit faster, since this is a hot spot in chunk rendering. 29 | TYPE_BY_BLOCK = new Reference2ReferenceOpenHashMap<>(TYPE_BY_BLOCK); 30 | TYPE_BY_FLUID = new Reference2ReferenceOpenHashMap<>(TYPE_BY_FLUID); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/world/sky/ClientLevelMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.render.world.sky; 2 | 3 | import net.caffeinemc.mods.sodium.client.util.color.FastCubicSampler; 4 | import net.minecraft.client.multiplayer.ClientLevel; 5 | import net.minecraft.util.CubicSampler; 6 | import net.minecraft.world.level.Level; 7 | import net.minecraft.world.phys.Vec3; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Redirect; 11 | 12 | import java.util.function.Function; 13 | 14 | @Mixin(ClientLevel.class) 15 | public class ClientLevelMixin { 16 | @Redirect(method = "getSkyColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/CubicSampler;gaussianSampleVec3(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/util/CubicSampler$Vec3Fetcher;)Lnet/minecraft/world/phys/Vec3;")) 17 | private Vec3 redirectSampleColor(Vec3 pos, CubicSampler.Vec3Fetcher rgbFetcher) { 18 | Level level = (Level) (Object) this; 19 | 20 | return FastCubicSampler.sampleColor(pos, (x, y, z) -> level.getNoiseBiome(x, y, z).value().getSkyColor(), Function.identity()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/NativeImageAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures; 2 | 3 | import com.mojang.blaze3d.platform.NativeImage; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | @Mixin(NativeImage.class) 8 | public interface NativeImageAccessor { 9 | @Accessor 10 | long getPixels(); 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/SpriteContentsInvoker.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures; 2 | 3 | import com.mojang.blaze3d.platform.NativeImage; 4 | import net.minecraft.client.renderer.texture.SpriteContents; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Invoker; 7 | 8 | @Mixin(SpriteContents.class) 9 | public interface SpriteContentsInvoker { 10 | @Invoker 11 | void invokeUpload(int x, int y, int unpackSkipPixels, int unpackSkipRows, NativeImage[] images); 12 | } -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/AnimatedTextureAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures.animations.tracking; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | import java.util.List; 7 | import net.minecraft.client.renderer.texture.SpriteContents; 8 | 9 | @Mixin(SpriteContents.AnimatedTexture.class) 10 | public interface AnimatedTextureAccessor { 11 | @Accessor("frames") 12 | List getFrames(); 13 | } 14 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/SpriteContentsFrameInfoAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures.animations.tracking; 2 | 3 | import net.minecraft.client.renderer.texture.SpriteContents; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | @Mixin(SpriteContents.FrameInfo.class) 8 | public interface SpriteContentsFrameInfoAccessor { 9 | @Accessor("time") 10 | int getTime(); 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/SpriteContentsMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures.animations.tracking; 2 | 3 | import net.caffeinemc.mods.sodium.client.render.texture.SpriteContentsExtension; 4 | import net.minecraft.client.renderer.texture.SpriteContents; 5 | import org.jetbrains.annotations.Nullable; 6 | import org.spongepowered.asm.mixin.Final; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.Unique; 10 | 11 | @Mixin(SpriteContents.class) 12 | public abstract class SpriteContentsMixin implements SpriteContentsExtension { 13 | @Shadow 14 | @Final 15 | @Nullable 16 | private SpriteContents.AnimatedTexture animatedTexture; 17 | 18 | @Unique 19 | private boolean active; 20 | 21 | @Override 22 | public void sodium$setActive(boolean value) { 23 | this.active = value; 24 | } 25 | 26 | @Override 27 | public boolean sodium$hasAnimation() { 28 | return this.animatedTexture != null; 29 | } 30 | 31 | @Override 32 | public boolean sodium$isActive() { 33 | return this.active; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureAtlasMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures.animations.tracking; 2 | 3 | import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; 4 | import net.minecraft.client.renderer.texture.TextureAtlas; 5 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | 11 | @Mixin(TextureAtlas.class) 12 | public class TextureAtlasMixin { 13 | @Inject(method = "getSprite", at = @At("RETURN")) 14 | private void preReturnSprite(CallbackInfoReturnable cir) { 15 | TextureAtlasSprite sprite = cir.getReturnValue(); 16 | 17 | if (sprite != null) { 18 | SpriteUtil.INSTANCE.markSpriteActive(sprite); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/upload/SpriteContentsAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures.animations.upload; 2 | 3 | import com.mojang.blaze3d.platform.NativeImage; 4 | import net.minecraft.client.renderer.texture.SpriteContents; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(SpriteContents.class) 9 | public interface SpriteContentsAccessor { 10 | @Accessor("byMipLevel") 11 | NativeImage[] getImages(); 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/upload/SpriteContentsAnimatedTextureAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures.animations.upload; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | import java.util.List; 7 | import net.minecraft.client.renderer.texture.SpriteContents; 8 | 9 | @Mixin(SpriteContents.AnimatedTexture.class) 10 | public interface SpriteContentsAnimatedTextureAccessor { 11 | @Accessor 12 | List getFrames(); 13 | 14 | @Accessor 15 | int getFrameRowSize(); 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/upload/SpriteContentsFrameInfoAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures.animations.upload; 2 | 3 | import net.minecraft.client.renderer.texture.SpriteContents; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | @Mixin(SpriteContents.FrameInfo.class) 8 | public interface SpriteContentsFrameInfoAccessor { 9 | @Accessor 10 | int getIndex(); 11 | 12 | @Accessor 13 | int getTime(); 14 | } 15 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/upload/SpriteContentsTickerAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.features.textures.animations.upload; 2 | 3 | import net.minecraft.client.renderer.texture.SpriteContents; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | 7 | @Mixin(SpriteContents.Ticker.class) 8 | public interface SpriteContentsTickerAccessor { 9 | @Accessor 10 | SpriteContents.AnimatedTexture getAnimationInfo(); 11 | 12 | @Accessor("frame") 13 | int getFrameIndex(); 14 | 15 | @Accessor("subFrame") 16 | int getFrameTicks(); 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/caffeinemc/mods/sodium/mixin/workarounds/event_loop/RenderSystemMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.workarounds.event_loop; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.At; 6 | import org.spongepowered.asm.mixin.injection.Redirect; 7 | 8 | @Mixin(RenderSystem.class) 9 | public class RenderSystemMixin { 10 | @SuppressWarnings("EmptyMethod") 11 | @Redirect(method = "flipFrame", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;pollEvents()V", ordinal = 0), remap = false) 12 | private static void removeFirstPoll() { 13 | // noop 14 | // should fix some bugs with minecraft polling events twice for some reason (why does it do that in the first place?) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/models/block/README.txt: -------------------------------------------------------------------------------- 1 | These block models are based on the original game's assets, but with various optimizations applied to reduce 2 | the number of vertices. 3 | 4 | The texture mapping of these block models is identical to the originals, so that resource packs which replace the 5 | textures of blocks will not look any different. 6 | 7 | If you are a resource pack author and find that your models or textures no longer work correctly with these changes, 8 | please let us know. -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/acacia_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/acacia_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/azalea_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/azalea_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/birch_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/birch_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/cherry_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/cherry_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/dark_oak_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/dark_oak_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/flowering_azalea_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/flowering_azalea_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/jungle_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/jungle_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/mangrove_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/mangrove_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/oak_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/oak_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/pale_oak_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/pale_oak_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/minecraft/textures/block/spruce_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/minecraft/textures/block/spruce_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque.fsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | #import 4 | 5 | in vec4 v_Color; // The interpolated vertex color 6 | in vec2 v_TexCoord; // The interpolated block texture coordinates 7 | in float v_FragDistance; // The fragment's distance from the camera 8 | 9 | in float v_MaterialMipBias; 10 | in float v_MaterialAlphaCutoff; 11 | 12 | uniform sampler2D u_BlockTex; // The block texture 13 | 14 | uniform vec4 u_FogColor; // The color of the shader fog 15 | uniform float u_FogStart; // The starting position of the shader fog 16 | uniform float u_FogEnd; // The ending position of the shader fog 17 | 18 | out vec4 fragColor; // The output fragment for the color framebuffer 19 | 20 | void main() { 21 | vec4 diffuseColor = texture(u_BlockTex, v_TexCoord, v_MaterialMipBias); 22 | 23 | // Apply per-vertex color 24 | diffuseColor *= v_Color; 25 | 26 | #ifdef USE_FRAGMENT_DISCARD 27 | if (diffuseColor.a < v_MaterialAlphaCutoff) { 28 | discard; 29 | } 30 | #endif 31 | 32 | fragColor = _linearFog(diffuseColor, v_FragDistance, u_FogColor, u_FogStart, u_FogEnd); 33 | } -------------------------------------------------------------------------------- /common/src/main/resources/assets/sodium/shaders/clouds.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | 5 | uniform mat4 ProjMat; 6 | uniform vec4 ColorModulator; 7 | uniform vec4 FogColor; 8 | uniform float FogStart; 9 | uniform float FogEnd; 10 | 11 | in vec4 vertexColor; 12 | in float vertexDistance; 13 | 14 | out vec4 fragColor; 15 | 16 | // Custom cloud fog algorithm by Balint, for use in Sodium 17 | void main() { 18 | vec4 color = vertexColor * ColorModulator; 19 | 20 | if (color.a < 0.1) { 21 | discard; 22 | } 23 | 24 | float width = FogEnd - FogStart; 25 | float newWidth = width * 4.0; 26 | float fade = linear_fog_fade(vertexDistance, FogStart, FogStart + newWidth) * FogColor.a; 27 | fragColor = vec4(mix(FogColor.rgb, color.rgb, 0.7), clamp(color.a * fade, 0.0, 1.0)); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/sodium/shaders/clouds.json: -------------------------------------------------------------------------------- 1 | { 2 | "vertex": "sodium:clouds", 3 | "fragment": "sodium:clouds", 4 | "defines": { 5 | "values": { 6 | "ALPHA_CUTOUT": "0.1" 7 | } 8 | }, 9 | "samplers": [ 10 | { "name": "Sampler0" } 11 | ], 12 | "uniforms": [ 13 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 14 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 15 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 16 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 17 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 18 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 19 | { "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/sodium/shaders/clouds.vsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | #moj_import 3 | 4 | in vec3 Position; 5 | in vec4 Color; 6 | 7 | uniform mat4 ModelViewMat; 8 | uniform mat4 ProjMat; 9 | uniform int FogShape; 10 | 11 | out float vertexDistance; 12 | out vec4 vertexColor; 13 | 14 | // Custom cloud fog algorithm by Balint, for use in Sodium 15 | void main() { 16 | gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0); 17 | vec4 pos = ModelViewMat * vec4(Position.x, 0.0, Position.z, 1.0); 18 | vertexDistance = length(pos.xyz); 19 | vertexColor = Color; 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/sodium/shaders/include/chunk_material.glsl: -------------------------------------------------------------------------------- 1 | const uint MATERIAL_USE_MIP_OFFSET = 0u; 2 | const uint MATERIAL_ALPHA_CUTOFF_OFFSET = 1u; 3 | 4 | const float[4] ALPHA_CUTOFF = float[4](0.0, 0.1, 0.1, 1.0); 5 | 6 | float _material_mip_bias(uint material) { 7 | return ((material >> MATERIAL_USE_MIP_OFFSET) & 1u) != 0u ? 0.0 : -4.0; 8 | } 9 | 10 | float _material_alpha_cutoff(uint material) { 11 | return ALPHA_CUTOFF[(material >> MATERIAL_ALPHA_CUTOFF_OFFSET) & 3u]; 12 | } -------------------------------------------------------------------------------- /common/src/main/resources/assets/sodium/shaders/include/chunk_matrices.glsl: -------------------------------------------------------------------------------- 1 | // The projection matrix 2 | uniform mat4 u_ProjectionMatrix; 3 | 4 | // The model-view matrix 5 | uniform mat4 u_ModelViewMatrix; 6 | 7 | // The model-view-projection matrix 8 | #define u_ModelViewProjectionMatrix (uProjectionMatrix * u_ModelViewMatrix) -------------------------------------------------------------------------------- /common/src/main/resources/assets/sodium/shaders/include/fog.glsl: -------------------------------------------------------------------------------- 1 | const int FOG_SHAPE_SPHERICAL = 0; 2 | const int FOG_SHAPE_CYLINDRICAL = 1; 3 | 4 | vec4 _linearFog(vec4 fragColor, float fragDistance, vec4 fogColor, float fogStart, float fogEnd) { 5 | #ifdef USE_FOG 6 | if (fragDistance <= fogStart) { 7 | return fragColor; 8 | } 9 | float factor = fragDistance < fogEnd ? smoothstep(fogStart, fogEnd, fragDistance) : 1.0; // alpha value of fog is used as a weight 10 | vec3 blended = mix(fragColor.rgb, fogColor.rgb, factor * fogColor.a); 11 | 12 | return vec4(blended, fragColor.a); // alpha value of fragment cannot be modified 13 | #else 14 | return fragColor; 15 | #endif 16 | } 17 | 18 | float getFragDistance(int fogShape, vec3 position) { 19 | // Use the maximum of the horizontal and vertical distance to get cylindrical fog if fog shape is cylindrical 20 | switch (fogShape) { 21 | case FOG_SHAPE_SPHERICAL: return length(position); 22 | case FOG_SHAPE_CYLINDRICAL: return max(length(position.xz), abs(position.y)); 23 | default: return length(position); // This shouldn't be possible to get, but return a sane value just in case 24 | } 25 | } -------------------------------------------------------------------------------- /common/src/main/resources/assets/sodium/textures/gui/arrows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/assets/sodium/textures/gui/arrows.png -------------------------------------------------------------------------------- /common/src/main/resources/programmer_art/assets/minecraft/textures/block/acacia_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/programmer_art/assets/minecraft/textures/block/acacia_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/programmer_art/assets/minecraft/textures/block/birch_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/programmer_art/assets/minecraft/textures/block/birch_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/programmer_art/assets/minecraft/textures/block/dark_oak_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/programmer_art/assets/minecraft/textures/block/dark_oak_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/programmer_art/assets/minecraft/textures/block/jungle_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/programmer_art/assets/minecraft/textures/block/jungle_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/programmer_art/assets/minecraft/textures/block/oak_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/programmer_art/assets/minecraft/textures/block/oak_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/programmer_art/assets/minecraft/textures/block/spruce_leaves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/programmer_art/assets/minecraft/textures/block/spruce_leaves.png -------------------------------------------------------------------------------- /common/src/main/resources/sodium-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/common/src/main/resources/sodium-icon.png -------------------------------------------------------------------------------- /fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/FabricRuntimeInformation.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.fabric; 2 | 3 | import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation; 4 | import net.fabricmc.loader.api.FabricLoader; 5 | 6 | import java.nio.file.Path; 7 | 8 | public class FabricRuntimeInformation implements PlatformRuntimeInformation { 9 | @Override 10 | public boolean isDevelopmentEnvironment() { 11 | return FabricLoader.getInstance().isDevelopmentEnvironment(); 12 | } 13 | 14 | @Override 15 | public Path getGameDirectory() { 16 | return FabricLoader.getInstance().getGameDir(); 17 | } 18 | 19 | @Override 20 | public Path getConfigDirectory() { 21 | return FabricLoader.getInstance().getConfigDir(); 22 | } 23 | 24 | @Override 25 | public boolean platformHasEarlyLoadingScreen() { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean platformUsesRefmap() { 31 | return true; 32 | } 33 | 34 | @Override 35 | public boolean isModInLoadingList(String modId) { 36 | return FabricLoader.getInstance().isModLoaded(modId); 37 | } 38 | 39 | @Override 40 | public boolean usesAlphaMultiplication() { 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/SodiumFabricMod.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.fabric; 2 | 3 | import net.caffeinemc.mods.sodium.client.SodiumClientMod; 4 | import net.caffeinemc.mods.sodium.client.render.frapi.SodiumRenderer; 5 | import net.caffeinemc.mods.sodium.client.util.FlawlessFrames; 6 | import net.fabricmc.api.ClientModInitializer; 7 | import net.fabricmc.fabric.api.renderer.v1.Renderer; 8 | import net.fabricmc.loader.api.FabricLoader; 9 | import net.fabricmc.loader.api.ModContainer; 10 | import java.util.function.Consumer; 11 | 12 | public class SodiumFabricMod implements ClientModInitializer { 13 | @Override 14 | @SuppressWarnings("unchecked") 15 | public void onInitializeClient() { 16 | ModContainer mod = FabricLoader.getInstance() 17 | .getModContainer("sodium") 18 | .orElseThrow(NullPointerException::new); 19 | 20 | SodiumClientMod.onInitialization(mod.getMetadata().getVersion().getFriendlyString()); 21 | 22 | FabricLoader.getInstance() 23 | .getEntrypoints("frex_flawless_frames", Consumer.class) 24 | .forEach(api -> api.accept(FlawlessFrames.getProvider())); 25 | 26 | Renderer.register(SodiumRenderer.INSTANCE); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/SodiumPreLaunch.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.fabric; 2 | 3 | import net.caffeinemc.mods.sodium.client.compatibility.checks.PreLaunchChecks; 4 | import net.caffeinemc.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterProbe; 5 | import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; 6 | import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; 7 | 8 | public class SodiumPreLaunch implements PreLaunchEntrypoint { 9 | @Override 10 | public void onPreLaunch() { 11 | PreLaunchChecks.checkEnvironment(); 12 | GraphicsAdapterProbe.findAdapters(); 13 | Workarounds.init(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.fabric.render; 2 | 3 | import net.caffeinemc.mods.sodium.client.model.color.ColorProvider; 4 | import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; 5 | import net.caffeinemc.mods.sodium.client.world.LevelSlice; 6 | import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; 7 | import net.minecraft.core.BlockPos; 8 | import net.minecraft.world.level.material.FluidState; 9 | 10 | import java.util.Arrays; 11 | 12 | public class FabricColorProviders { 13 | public static ColorProvider adapt(FluidRenderHandler handler) { 14 | return new FabricFluidAdapter(handler); 15 | } 16 | 17 | private static class FabricFluidAdapter implements ColorProvider { 18 | private final FluidRenderHandler handler; 19 | 20 | public FabricFluidAdapter(FluidRenderHandler handler) { 21 | this.handler = handler; 22 | } 23 | 24 | @Override 25 | public void getColors(LevelSlice slice, BlockPos pos, BlockPos.MutableBlockPos scratchPos, FluidState state, ModelQuadView quad, int[] output) { 26 | Arrays.fill(output, 0xFF000000 | this.handler.getFluidColor(slice, pos, state)); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.FluidRendererFactory: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.fabric.render.FluidRendererImpl$FabricFactory -------------------------------------------------------------------------------- /fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.fabric.block.FabricBlockAccess -------------------------------------------------------------------------------- /fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.fabric.level.FabricLevelAccess -------------------------------------------------------------------------------- /fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.fabric.level.FabricLevelRenderHooks -------------------------------------------------------------------------------- /fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformMixinOverrides: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.fabric.FabricMixinOverrides -------------------------------------------------------------------------------- /fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformModelAccess: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.fabric.model.FabricModelAccess -------------------------------------------------------------------------------- /fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.fabric.FabricRuntimeInformation -------------------------------------------------------------------------------- /fabric/src/main/resources/sodium-fabric.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": "net.caffeinemc.mods.sodium.mixin", 3 | "required": true, 4 | "compatibilityLevel": "JAVA_17", 5 | "injectors": { 6 | "defaultRequire": 1 7 | }, 8 | "overwrites": { 9 | "conformVisibility": true 10 | }, 11 | "client": [ 12 | "core.model.quad.BakedQuadMixin", 13 | "features.model.DelegateBakedModelMixin", 14 | "features.model.MultiPartBakedModelMixin", 15 | "features.model.WeightedBakedModelMixin", 16 | "features.model.WeightedRandomListMixin", 17 | "features.render.model.block.ModelBlockRendererMixin", 18 | "features.world.biome.BiomeMixin" 19 | ] 20 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx2G 3 | org.gradle.caching=true 4 | org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CaffeineMC/sodium/d8fe39c3d2a119d9638c3a5e338a9fbaf4de67fe/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /idea/inspections.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | -------------------------------------------------------------------------------- /neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/platform/neoforge/AuxiliaryLightManagerMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.platform.neoforge; 2 | 3 | import net.caffeinemc.mods.sodium.client.world.SodiumAuxiliaryLightManager; 4 | import net.neoforged.neoforge.common.world.AuxiliaryLightManager; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | 7 | @Mixin(AuxiliaryLightManager.class) 8 | public interface AuxiliaryLightManagerMixin extends SodiumAuxiliaryLightManager { 9 | } 10 | -------------------------------------------------------------------------------- /neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/platform/neoforge/ChunkRenderTypeSetAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.platform.neoforge; 2 | 3 | import net.neoforged.neoforge.client.ChunkRenderTypeSet; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.gen.Accessor; 6 | import org.spongepowered.asm.mixin.gen.Invoker; 7 | 8 | import java.util.BitSet; 9 | 10 | @Mixin(ChunkRenderTypeSet.class) 11 | public interface ChunkRenderTypeSetAccessor { 12 | @Invoker("") 13 | static ChunkRenderTypeSet create(BitSet set) { 14 | throw new IllegalStateException("Not shadowed"); 15 | } 16 | 17 | @Accessor 18 | BitSet getBits(); 19 | } 20 | -------------------------------------------------------------------------------- /neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/platform/neoforge/ClientHooksMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.platform.neoforge; 2 | 3 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 4 | import net.neoforged.neoforge.client.ClientHooks; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Redirect; 8 | 9 | /** 10 | * This mixin is used to fix Forge's item models having drastic seams with Sodium's changed shrink ratio. 11 | */ 12 | @Mixin(ClientHooks.class) 13 | public class ClientHooksMixin { 14 | @Redirect(method = "fixItemModelSeams", at = @At(value = "INVOKE", target = 15 | "Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;uvShrinkRatio()F")) 16 | private static float alterUvShrinkRatio(TextureAtlasSprite sprite) { 17 | return 0.0f; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/platform/neoforge/EntrypointMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.platform.neoforge; 2 | 3 | import net.caffeinemc.mods.sodium.client.SodiumClientMod; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.main.GameConfig; 6 | import net.neoforged.fml.ModList; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | /** 13 | * This Mixin is specially designed so the Sodium initializer always runs even if mod initialization has failed. 14 | */ 15 | @Mixin(Minecraft.class) 16 | public class EntrypointMixin { 17 | @Inject(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Options;loadSelectedResourcePacks(Lnet/minecraft/server/packs/repository/PackRepository;)V")) 18 | private void sodium$loadConfig(GameConfig gameConfig, CallbackInfo ci) { 19 | SodiumClientMod.onInitialization(ModList.get().getModContainerById("sodium").map(t -> t.getModInfo().getVersion().toString()).orElse("UNKNOWN")); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/platform/neoforge/ModelDataMixin.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.platform.neoforge; 2 | 3 | import net.caffeinemc.mods.sodium.client.services.SodiumModelData; 4 | import net.neoforged.neoforge.client.model.data.ModelData; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | 7 | @Mixin(ModelData.class) 8 | public class ModelDataMixin implements SodiumModelData { 9 | } 10 | -------------------------------------------------------------------------------- /neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/platform/neoforge/SimpleBakedModelAccessor.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.mixin.platform.neoforge; 2 | 3 | import net.minecraft.client.resources.model.SimpleBakedModel; 4 | import net.neoforged.neoforge.client.ChunkRenderTypeSet; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.gen.Accessor; 7 | 8 | @Mixin(SimpleBakedModel.class) 9 | public interface SimpleBakedModelAccessor { 10 | @Accessor 11 | ChunkRenderTypeSet getBlockRenderTypes(); 12 | } 13 | -------------------------------------------------------------------------------- /neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/level/NeoForgeLevelAccess.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.neoforge.level; 2 | 3 | import net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess; 4 | import net.caffeinemc.mods.sodium.client.world.SodiumAuxiliaryLightManager; 5 | import net.fabricmc.fabric.api.blockview.v2.RenderDataBlockEntity; 6 | import net.minecraft.core.SectionPos; 7 | import net.minecraft.world.level.block.entity.BlockEntity; 8 | import net.minecraft.world.level.chunk.LevelChunk; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | public class NeoForgeLevelAccess implements PlatformLevelAccess { 12 | @Override 13 | public @Nullable Object getBlockEntityData(BlockEntity blockEntity) { 14 | return ((RenderDataBlockEntity) blockEntity).getRenderData(); 15 | } 16 | 17 | @Override 18 | public @Nullable SodiumAuxiliaryLightManager getLightManager(LevelChunk chunk, SectionPos pos) { 19 | return (SodiumAuxiliaryLightManager) chunk.getAuxLightManager(pos.origin()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /neoforge/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.FluidRendererFactory: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.neoforge.render.FluidRendererImpl$ForgeFactory -------------------------------------------------------------------------------- /neoforge/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.neoforge.block.NeoForgeBlockAccess -------------------------------------------------------------------------------- /neoforge/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.neoforge.level.NeoForgeLevelAccess -------------------------------------------------------------------------------- /neoforge/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.neoforge.level.NeoForgeLevelRenderHooks -------------------------------------------------------------------------------- /neoforge/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformMixinOverrides: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.neoforge.ForgeMixinOverrides -------------------------------------------------------------------------------- /neoforge/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformModelAccess: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.neoforge.model.NeoForgeModelAccess -------------------------------------------------------------------------------- /neoforge/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.neoforge.NeoForgeRuntimeInformation -------------------------------------------------------------------------------- /neoforge/src/main/resources/sodium-neoforge.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "package" : "net.caffeinemc.mods.sodium.mixin", 3 | "required" : true, 4 | "compatibilityLevel" : "JAVA_17", 5 | "injectors" : { 6 | "defaultRequire" : 1 7 | }, 8 | "overwrites" : { 9 | "conformVisibility" : true 10 | }, 11 | "client" : [ 12 | "core.model.quad.BakedQuadMixin", 13 | "features.model.DelegateBakedModelMixin", 14 | "features.model.MultiPartBakedModelMixin", 15 | "features.model.WeightedBakedModelMixin", 16 | "features.model.WeightedRandomListMixin", 17 | "features.render.model.block.ModelBlockRendererMixin", 18 | "features.world.biome.BiomeMixin", 19 | "platform.neoforge.AbstractBlockRenderContextMixin", 20 | "platform.neoforge.AuxiliaryLightManagerMixin", 21 | "platform.neoforge.ChunkRenderTypeSetAccessor", 22 | "platform.neoforge.ClientHooksMixin", 23 | "platform.neoforge.EntrypointMixin", 24 | "platform.neoforge.LevelSliceMixin", 25 | "platform.neoforge.ModelDataMixin", 26 | "platform.neoforge.ResourcePackLoaderMixin", 27 | "platform.neoforge.SimpleBakedModelAccessor" 28 | ] 29 | } -------------------------------------------------------------------------------- /neoforge/src/service/java/net/caffeinemc/mods/sodium/service/SodiumWorkarounds.java: -------------------------------------------------------------------------------- 1 | package net.caffeinemc.mods.sodium.service; 2 | 3 | import net.caffeinemc.mods.sodium.client.compatibility.checks.PreLaunchChecks; 4 | import net.caffeinemc.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterProbe; 5 | import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; 6 | import net.caffeinemc.mods.sodium.client.compatibility.workarounds.nvidia.NvidiaWorkarounds; 7 | import net.neoforged.neoforgespi.earlywindow.GraphicsBootstrapper; 8 | 9 | public class SodiumWorkarounds implements GraphicsBootstrapper { 10 | @Override 11 | public String name() { 12 | return "sodium"; 13 | } 14 | 15 | @Override 16 | public void bootstrap(String[] arguments) { 17 | PreLaunchChecks.checkEnvironment(); 18 | GraphicsAdapterProbe.findAdapters(); 19 | Workarounds.init(); 20 | 21 | // Context creation happens earlier on NeoForge, so we need to apply this now 22 | NvidiaWorkarounds.applyEnvironmentChanges(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /neoforge/src/service/resources/META-INF/services/net.neoforged.neoforgespi.earlywindow.GraphicsBootstrapper: -------------------------------------------------------------------------------- 1 | net.caffeinemc.mods.sodium.service.SodiumWorkarounds -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "sodium" 2 | 3 | pluginManagement { 4 | repositories { 5 | mavenLocal() 6 | maven { url = uri("https://maven.fabricmc.net/") } 7 | maven { url = uri("https://maven.neoforged.net/releases/") } 8 | gradlePluginPortal() 9 | } 10 | } 11 | 12 | include("common") 13 | include("fabric") 14 | include("neoforge") -------------------------------------------------------------------------------- /thirdparty/NOTICE.txt: -------------------------------------------------------------------------------- 1 | Third-Party License Notice 2 | ======================================= 3 | 4 | This project contains source code based upon, or includes source code from, the following third-party 5 | projects. 6 | 7 | The complete text for each software license can be found in the directory "thirdparty/licenses". 8 | 9 | * Fabric API libraries 10 | * Copyright (c) 2016 FabricMC 11 | * License: Apache 2.0 (SPDX: Apache-2.0) 12 | * Original Source: 13 | * https://github.com/FabricMC/fabric 14 | 15 | * lodborg's interval tree library for Java 16 | * Copyright (c) 2016 lodborg 17 | * License: MIT 18 | * Original Source 19 | * https://github.com/lodborg/interval-tree/tree/v1.0.0 20 | * Files: 21 | * common/src/main/java/net/caffeinemc/mods/sodium/client/util/interval_tree 22 | 23 | * coderbot's mip-map generator patches for Minecraft 24 | * Copyright (c) 2021 Coderbot 25 | * License: Mozilla Public License (SPDX: MPL2) 26 | * Original Source: 27 | * https://github.com/IrisShaders/Iris/tree/41095ac23ea0add664afd1b85c414d1f1ed94066/src/main/java/net/coderbot/iris/mixin/bettermipmaps 28 | * Files: 29 | * common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/mipmaps 30 | -------------------------------------------------------------------------------- /thirdparty/licenses/LICENSE-MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. --------------------------------------------------------------------------------