Skip to content

Commit

Permalink
Upstreamed/combine draw commands (#8)
Browse files Browse the repository at this point in the history
* rename some things for clarity

* fix waterlogged glass panes (once again, but more this time) by avoiding distance sorting through
the detection of primary intersectors when geometry is intersecting and then sorting them in a fixed order

* use Mth.clamp for clarity

* refactor buffer and sort result handling, buffers are now freed immediately instead of keeping them to avoid memory usage
buffer caching would be a better solution but that's complicated and doesn't currently work correctly

* reduce number of unique triggers by around 5 percent without impacting sorting or building performance

* importantly sort a little farther away, sort tasks are fast

* use defer zero frames for important sort tasks by default

* fix build

* clarify authorship of BitArray

* fix bug with radix sort for SNR heuristic in BSP partition generating wrong indexes

* combine draw commands

* correctly reset accumulated element count

* remove draw call combining for indexed rendering as it's broken and hard to fix

* skip heuristic if there's no quads

* refactor primary intersector detection to handle large cases better,
also removed the warning message about unpartitionable geometry as it seems to not be a relevant problem

* fix topo sorting in some situations where the dot product was wrongly not recalculated when the normal is quantized.
also fixed aligned quads not receiving the more accurate center based on the average of the unique vertexes.

* reorder vertex ranges before uploaded to optimize for combined draw commands

* tune primary intersector detection to handle situations where only a small amount of geometry is intersecting

* Correctly handle colorization on NeoForge

* Combine the vertex position attributes (CaffeineMC#2753)

This improves terrain rendering performance significantly
on Intel Xe-LP graphics under Linux.

* Add option for Fullscreen Resolution (CaffeineMC#2642)

The resolution controls would not fit in the allocated space, so the
rendering of slider controls was changed to enable rendering the slider
bar and the value text on separate lines.

Co-authored-by: MeeniMc <[email protected]>

* Only enable Fullscreen Resolution option on Windows

Additionally, adjust the rendering of the controls
to be less confusing when disabled, and provide an
explanation as to what the option does.

* fix draw command combining, remove aggressive non-empty command skipping because it seems broken

* Use consistent vertex ordering in entity rendering

Some core shaders were relying on the model part faces being
written out in a specific order. We still don't support
core shaders, but the fix here is trivial enough.

Fixes CaffeineMC#2745

* Add check for NeoForge per-quad AO flag

* Disable mod entrypoint on Forge when running on servers (CaffeineMC#2773)

* fix graphical corruption when there's a lot of geometry by appropriately picking the size of the required shared index buffer

* cleanup unused and broken code

* cleanup calculation of mask bit and element count

* cleanup meshing, storage, and renderer

* fix translucent rendering by correctly decoding vertex segments

* cleanup misc, remove unused code

* refactor translucent AnyOrderData to not generate its own trivial index buffer and instead share this type of data within regions

* add Index Pool arena size

* add arena content caching

* Fix excessively large allocations in chunk meshing

The requested capacity was being multiplied by the vertex
stride more than once, which resulted in far too much
memory being allocated.

Closes CaffeineMC#2792

* Fix some issues with Uint32 representation

This increases the maximum size of vertex and index buffers
to 4 billion elements, since the Uint32 types stored in memory are
now safely represented with Int64.

For vertex buffers, this increases their maximum size to 80 GiB,
and index buffers have a maximum size of 16 GiB, whereas both
were limited to 2 GiB prior.

* refactor storage to cope with larger amounts of geometry and use less ugly hacks, rename a bunch of methods to be consistent and clearer

* remove debug code

* Fix cull bitmask ordering in entity rendering

Closes CaffeineMC#2788

* Add support for Maven Local publishing

* Fix incorrect warning message when D3DKMT is not supported

* Add Flawless Frames handler for NeoForge

* Add angle-based section visibility path occlusion (CaffeineMC#2811)

This eliminates 8-13% of the rendered sections at higher render distances on average in testing, and correspondingly reduces graph search time by a similar amount.

* Disable material downgrading on Intel Gen8 and older

Fixes CaffeineMC#2830

* Delay normal face calculation to use

This potentially fixes some cases of CaffeineMC#2835.

* Skip particle rendering optimizations for incompatible mods

Fixes CaffeineMC#2827

* Update project URLs in source and documentation

We're no longer a Fabric-exclusive mod, so let's get rid of
the suffix.

* Add third-party license notice for Fabric API

* Optimizations for some block models (CaffeineMC#2508)

Co-authored-by: muzikbike <[email protected]>

* Fix sorting failures on rotated cuboids (CaffeineMC#2812)

Use the accurate vertex positions for unaligned and aligned (but rotated) quads.

* Rework the Gradle build scripts for multi-loader

* Shared logic is moved into a build plugin where possible
* Build time is significantly improved when the Gradle daemon is warmed
* Mixins are remapped in-place now, eliminating the need for refmaps
  at runtime. This also gets rid of some warning messages at startup.
* Module relationships are now correctly represented in IDEA for other
  source sets (fixes a lot of code analysis features)
* Split Java source and resources into different configurations
* Run configurations are now consistent between NeoForge/Fabric
* The common project is no longer remapped unnecessarily
* Updated Gradle and build plugins

* Restore versioning schema to build script

* Make organization of platform mixin packages consistent

Fixes CaffeineMC#2688

* Exclude README documentation from processed resources

These files are only meant to be in the source distribution, and
Minecraft doesn't like them.

* Don't try to load a refmap from the mixin plugin

* Enumerate additional PCI classes in the graphics adapter probe

Some integrated GPUs, such as RDNA3.5, appear to use
the PCI_CLASS_DISPLAY_OTHER class.

* Remove KDE and GNOME specific backends for browsing URLs

The bugs with xdg-open have been resolved upstream and most
Linux distributions are shipping the patches.

Also, make sure we get a successful exit code from the XDG
implementation.

* Remove Minecraft from classpath of the pre-launch source set

This will help to avoid class-load issues and makes the code more
hygienic.

* Update to Minecraft 1.21.3

* Ensure tooltips are constrained to the screen (CaffeineMC#2845)

* Update authors and contributors list

* Remove leftover popPose

* Trust existing fog color

* Block the Overwolf Overlay due to graphical corruption

The overlay does not correctly restore the texture unit state
in OpenGL, which causes problems when Minecraft thinks a texture
has already been bound to a slot.

Since disabling the OpenGL state cache globally is not an
acceptable solution (it would severely hurt performance) and
their software doesn't give us any method to detect the
problematic version, we block all versions.

gep_minecraft.dll is the payload they actually inject, which
has no version information or description.

Fixes CaffeineMC#2862

* Avoid static memory allocation in EntityRenderer

Just allocate on the stack, since it's a small amount of
memory (<1 KiB) and avoids needing complex finalizers.

* Fix y-offset calculation for back face culling in cloud rendering (CaffeineMC#2864)

* Fix memory leak and double free in CloudRenderer

* Improve color mixing functions

The existing functions did not implement rounding
correctly (often leading to off-by-one errors).

Additionally, the improved variants are both slightly
faster and easier to understand.

* Fixup documentation in ColorMixer

* Unify color mixing/swizzling utilities

The Fabric integration code was re-implementing a lot
of the utilities that already exist in Sodium unnecessarily.

Also, improve the documentation so that ABGR and RGBA are
not used interchangeably.

* Add optimized function for bi-linear interpolation

This reduces the number of ALU ops significantly and
creates a common utility function in the project.

* Reduce time complexity for box blurs

Measuring the time spent per box blur in biome blending,
the following results were observed.

Radius      Before      After       % Improvement
7 blocks    9100ns      3700ns      59%
3 blocks    5400ns      3200ns      41%
1 blocks    3700ns      2600ns      29%

* Revert detection of Overwolf Overlay

They claim this has since been fixed. We will re-examine in
the future if we see additional reports.

This reverts commit e7ea6f7.

* Bump version to 0.6.0-beta.5

* Bump version to 0.6.0-final

* Update render code for chunk status map

Fixes CaffeineMC#2881

* Rollup of fixes and improvements for cloud rendering

Some changes were made to cloud rendering in newer versions
that needed to be replicated in Sodium.

- The alpha cutoff for clouds was changed to (a < 10).
- Texture loading can now gracefully fail, and it is
expected that rendering is skipped when this happens.
- The movement/positioning of clouds was slightly changed.
- The render pass system now needs to be told about
render target usages (fixes CaffeineMC#2883).

This commit also improves mesh building time by around 35% on
a fast processor (AMD Ryzen HX AI 370) through various
micro-optimizations.

* Fix culling behavior between transparent and opaque blocks

Minecraft 1.21.2 changed some of the rules, and this was
causing the faces of transparent blocks to be rendered
even when they were hidden by full opaque blocks.

Fixes CaffeineMC#2850

* Fix precision issues in cloud rendering at far distances

* Use alternative workaround for NVIDIA drivers

The NVIDIA driver enables a driver feature called
"Threaded Optimizations" when it finds Minecraft,
which causes severe performance issues and sometimes
even crashes.

Newer versions of the driver seem to use a slightly
different heuristic which our workaround doesn't
address.

So, instead, use an alternative method that enables
GL_DEBUG_OUTPUT_SYNCHRONOUS. This seems to reliably
disable the functionality *even if* the user has
configured it otherwise in their driver settings.

Additionally, on Windows, we now always indicate to
the driver that Minecraft is running, so that users
with hybrid graphics don't see regressed performance.

* Sort render lists for regions and sections after traversal (CaffeineMC#2780)

Render sections and regions are sorted after the graph traversal is performed. This decouples their ordering from the graph, which isn't entirely correct for draw call sorting.

Fixes CaffeineMC#2266

* Add support for new NeoForge fluid overlay API

* Ensure depth test is configured when rendering clouds

The state of the depth test prior to cloud rendering is
undefined. After rendering, it is expected to be
disabled again.

* Fix rounding error in ColorMixer#mix

Rounding of the values now happens after the 16-bit
intermediaries are added together.

This affected some animated textures, causing them to
exhibit flickering behavior.

* Add additional optimized block models

This covers the following additional blocks:
- Cauldrons
- Brewing Stands
- Bells

Co-authored-by: JellySquid <[email protected]>

* Avoid marking the section graph as dirty if state didn't change (CaffeineMC#2886)

Avoids rebuilding the render lists and doing a graph search
more often than necessary by checking if the section actually
changed in a way that's relevant to the graph search.

For worlds that update their blocks frequently (every tick or
every redstone tick) this avoids half the graph searches. Some
graph searches are still necessary to schedule rebuild tasks,
but when the task results come back, this doesn't do another
graph search unless the section's visibility data or build state
changed in a way that needs the render list to be updated.

* Use larger bounding box for nearby sections in frustum check (CaffeineMC#2879)

This fixes some problems where very large block entities in
nearby sections may be incorrectly culled. But it does not
comprehensively fix the problem for all other sections,
since that would require visiting the 27-neighborhood of
every section, which is too slow.

* Bump version to 0.6.1

* Bump dependency versions

* Update mod manifest

* Ensure ItemRenderContext.isDefaultTranslucent is initialized

* Update compatible mods listing

* Update mod manifest to restrict Minecraft versions

* Update to Minecraft 1.21.4

* Update NeoForge manifest for Minecraft 1.21.4

* Fix glyph effect orientation

* Fix hidden surface elimination in fluid rendering for waterlogged blocks (CaffeineMC#2907)

* Fix detection for specific Intel OpenGL ICDs

The OpenGL ICD name now includes the file extension,
which the regex expressions were not matching.

* Avoid showing the incompatible driver error in some cases

For systems with hybrid graphics, it may be the case
that an incompatible graphics driver is installed, but that
it isn't used for the OpenGL context.

We can avoid showing errors in this situation by checking
the vendor string of the context immediately after
creation.

This is not the most robust check, but in practice, a single
system should not have multiple graphics drivers installed
from the same vendor, so checking the string should be
relatively safe.

* Fix lambda mappings

* Bump version and dependency requirements

* Use correct coordinates for sorting chunk sections (CaffeineMC#2924)

Fix section and region sorting by using the correct section coordinate instead of the integer part of the camera transform, which is incorrect near the origin.

Closes CaffeineMC#2918

* Update README.md

---------

Co-authored-by: douira <[email protected]>
Co-authored-by: IMS212 <[email protected]>
Co-authored-by: JellySquid <[email protected]>
Co-authored-by: douira <[email protected]>
Co-authored-by: MeeniMc <[email protected]>
Co-authored-by: JellySquid <[email protected]>
Co-authored-by: IThundxr <[email protected]>
Co-authored-by: muzikbike <[email protected]>
  • Loading branch information
9 people authored Dec 15, 2024
1 parent b758900 commit c6b1c06
Show file tree
Hide file tree
Showing 260 changed files with 7,865 additions and 3,056 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ body:
- **Have you ensured that all of your mods (including Sodium) are up-to-date?** The latest version of Sodium
can always be found [on Modrinth](https://modrinth.com/mod/sodium).
- **Have you read the [list of known driver incompatibilities](https://github.com/CaffeineMC/sodium-fabric/wiki/Driver-Compatibility)?** Most problems
- **Have you read the [list of known driver incompatibilities](https://github.com/CaffeineMC/sodium/wiki/Driver-Compatibility)?** Most problems
(including "poor performance") are caused by out-of-date or incompatible graphics drivers.
- **Have you used the [search tool](https://github.com/CaffeineMC/sodium-fabric/issues) to check whether your issue
- **Have you used the [search tool](https://github.com/CaffeineMC/sodium/issues) to check whether your issue
has already been reported?** If it has been, then consider adding more information to the existing issue instead.
- **Have you determined the minimum set of instructions to reproduce the issue?** If your problem only occurs
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ contact_links:
- name: For help with other issues, join our Discord community
url: https://caffeinemc.net/discord
about: This is the best option for getting help with mod installation, performance issues, and any other support inquiries
# Copied from https://github.com/CaffeineMC/sodium-fabric#community
# Copied from https://github.com/CaffeineMC/sodium#community
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ body:
- type: markdown
attributes:
value: >-
Make sure you have used the [search tool](https://github.com/CaffeineMC/sodium-fabric/issues) to see if a similar
Make sure you have used the [search tool](https://github.com/CaffeineMC/sodium/issues) to see if a similar
request already exists. If we have previously closed a feature request, then please do not create another request.
- type: textarea
id: description
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: sodium-artifacts-${{ steps.ref.outputs.branch }}
path: build/libs/*.jar
path: build/mods/*.jar
2 changes: 1 addition & 1 deletion .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: sodium-artifacts-${{ steps.ref.outputs.branch }}
path: build/libs/*.jar
path: build/mods/*.jar
3 changes: 1 addition & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ jobs:
- name: Upload assets to GitHub
uses: AButler/[email protected]
with:
# Filter built files to disregard -sources and -dev, and leave only the minecraft-compatible jars.
files: 'build/libs/*[0-9].jar;LICENSE'
files: 'build/mods/*.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: sodium-artifacts-${{ steps.ref.outputs.branch }}
path: build/libs/*.jar
path: build/mods/*.jar
85 changes: 54 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,53 @@
Sodium is a powerful rendering engine and optimization mod for the Minecraft client which improves frame rates and reduces
micro-stutter, while fixing many graphical issues in Minecraft.

### 📥 Installation
**This mod is the result of thousands of hours of development, and is made possible thanks to players like you.** If you
would like to show a token of your appreciation for my work, and help support the development of Sodium in the process,
then consider [buying me a coffee](https://caffeinemc.net/donate).

The latest version of Sodium can be downloaded from our official [Modrinth](https://modrinth.com/mod/sodium) and
[CurseForge](https://www.curseforge.com/minecraft/mc-mods/sodium) pages.
<a href="https://caffeinemc.net/donate"><img src="https://storage.ko-fi.com/cdn/kofi2.png?v=3" width="180"/></a>

---

### 📥 Downloads

#### Stable builds

The latest stable release of Sodium can be downloaded from our official [Modrinth](https://modrinth.com/mod/sodium) and
[CurseForge](https://www.curseforge.com/minecraft/mc-mods/sodium) pages.

#### Nightly builds (for developers)

We also provide bleeding-edge builds ("nightlies") which are useful for testing the very latest changes before they're
packaged into a release. These builds are only provided for other mod developers and users with expert skills, and do
not come with any support or warranty. It is often the case they have issues and lack compatibility with other mods.

The latest nightly build for each current branch of development can be downloaded below.

- Minecraft 1.21.4 (latest): [Download nightly](https://nightly.link/CaffeineMC/sodium/workflows/build-commit/dev/sodium-artifacts-dev.zip) or [View all builds](https://github.com/CaffeineMC/sodium/actions/workflows/build-commit.yml?query=branch%3Adev)
- Minecraft 1.21.3: [Download nightly](https://nightly.link/CaffeineMC/sodium/workflows/build-commit/1.21.3%2Fstable/sodium-artifacts-1.21.3-stable.zip) or [View all builds](https://github.com/CaffeineMC/sodium/actions/workflows/build-commit.yml?query=branch%3A1.21.3%2Fstable)
- Minecraft 1.21.1: [Download nightly](https://nightly.link/CaffeineMC/sodium/workflows/build-commit/1.21.1%2Fstable/sodium-artifacts-1.21.1-stable.zip) or [View all builds](https://github.com/CaffeineMC/sodium/actions/workflows/build-commit.yml?query=branch%3A1.21.1%2Fstable)

### 🖥️ Installation

Since the release of Sodium 0.6.0, both the _Fabric_ and _NeoForge_ mod loaders are supported. We generally recommend
that new users prefer to use the _Fabric_ mod loader, since it is more lightweight and stable (for the time being.)

For more information about downloading and installing the mod, please refer to our [Installation Guide](https://github.com/CaffeineMC/sodium-fabric/wiki/Installation).
For more information about downloading and installing the mod, please refer to our [Installation Guide](https://github.com/CaffeineMC/sodium/wiki/Installation).

### 🐛 Reporting Issues
### 🙇 Getting Help

You can report bugs and crashes by opening an issue on our [issue tracker](https://github.com/CaffeineMC/sodium-fabric/issues).
Before opening a new issue, use the search tool to make sure that your issue has not already been reported and ensure
that you have completely filled out the issue template. Issues that are duplicates or do not contain the necessary
information to triage and debug may be closed.
For technical support (including help with mod installation problems and game crashes), please use our
[official Discord server](https://caffeinemc.net/discord).

### 📬 Reporting Issues

If you do not need technical support and would like to report an issue (bug, crash, etc.) or otherwise request changes
(for mod compatibility, new features, etc.), then we encourage you to open an issue on the
[project issue tracker](https://github.com/CaffeineMC/sodium/issues).

Please note that while the issue tracker is open to feature requests, development is primarily focused on
improving hardware compatibility, performance, and finishing any unimplemented features necessary for parity with
improving compatibility, performance, and finishing any unimplemented features necessary for parity with
the vanilla renderer.

### 💬 Join the Community
Expand All @@ -36,45 +64,40 @@ We have an [official Discord community](https://caffeinemc.net/discord) for all

## ✅ Hardware Compatibility

We only provide support for graphics cards which have up-to-date drivers for OpenGL 4.6. Most graphics cards which have
been released since year 2010 are supported, such as the...
We only provide official support for graphics cards which have up-to-date drivers that are compatible with OpenGL 4.5
or newer. Most graphics cards released in the past 12 years will meet these requirements, including the following:

- AMD Radeon HD 7000 Series (GCN 1) or newer
- NVIDIA GeForce 400 Series (Fermi) or newer
- Intel HD Graphics 500 Series (Skylake) or newer

In some cases, older graphics cards may also work (so long as they have up-to-date drivers which have support for
OpenGL 3.3), but they are not officially supported, and may not be compatible with future versions of Sodium.
Nearly all graphics cards that are already compatible with Minecraft (which requires OpenGL 3.3) should also work
with Sodium. But our team cannot ensure compatibility or provide support for older graphics cards, and they may
not work with future versions of Sodium.

#### OpenGL Compatibility Layers

Devices which need to use OpenGL translation layers (such as GL4ES, ANGLE, etc) are not supported and will very likely
not work with Sodium. These translation layers do not implement required functionality and they suffer from underlying
driver bugs which cannot be worked around.

## 🛠️ Developer Guide

### Building from sources
## 🛠️ Building from sources

Sodium uses a typical Gradle project structure and can be compiled by simply running the default `build` task. The build
artifacts (typical mod binaries, and their sources) can be found in the `build/libs` directory.
Sodium uses the [Gradle build tool](https://gradle.org/) and can be built with the `gradle build` command. The build
artifacts (production binaries and their source bundles) can be found in the `build/mods` directory.

#### Requirements
The [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:using_wrapper) is provided for ease of use and will automatically download and install the
appropriate version of Gradle for the project build. To use the Gradle wrapper, substitute `gradle` in build commands
with `./gradlew.bat` (Windows) or `./gradlew` (macOS and Linux).

We recommend using a package manager (such as [SDKMAN](https://sdkman.io/)) to manage toolchain dependencies and keep
them up to date. For many Linux distributions, these dependencies will be standard packages in your software
repositories.
### Build Requirements

- OpenJDK 21
- We recommend using the [Eclipse Temurin](https://adoptium.net/) distribution, as it's known to be high quality
and to work without issues.
- Gradle 8.6.x (optional)
- The [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:using_wrapper) is provided
in this repository can be used instead of installing a suitable version of Gradle yourself. However, if you are
building many projects, you may prefer to install it yourself through a suitable package manager as to save disk
space and to avoid many different Gradle daemons sitting around in memory.
- We recommend using the [Eclipse Temurin](https://adoptium.net/) distribution as it's regularly tested by our developers and known
to be of high quality.
- Gradle 8.10.x
- Typically, newer versions of Gradle will work without issues, but the build script is only tested against the
version specified by the wrapper script.
version used by the [wrapper script](/gradle/wrapper/gradle-wrapper.properties).

## 📜 License

Expand Down
80 changes: 0 additions & 80 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,80 +0,0 @@
plugins {
id("java")
id("fabric-loom") version ("1.7.3") apply (false)
}

val MINECRAFT_VERSION by extra { "1.21.1" }
val NEOFORGE_VERSION by extra { "21.1.46" }
val FABRIC_LOADER_VERSION by extra { "0.16.4" }
val FABRIC_API_VERSION by extra { "0.103.0+1.21.1" }

// This value can be set to null to disable Parchment.
// TODO: Re-add Parchment
val PARCHMENT_VERSION by extra { null }

// https://semver.org/
val MOD_VERSION by extra { "0.6.0-beta.2" }

allprojects {
apply(plugin = "java")
apply(plugin = "maven-publish")
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}

tasks.jar {
enabled = false
}

subprojects {
apply(plugin = "maven-publish")

java.toolchain.languageVersion = JavaLanguageVersion.of(21)


fun createVersionString(): String {
val builder = StringBuilder()

val isReleaseBuild = project.hasProperty("build.release")
val buildId = System.getenv("GITHUB_RUN_NUMBER")

if (isReleaseBuild) {
builder.append(MOD_VERSION)
} else {
builder.append(MOD_VERSION.substringBefore('-'))
builder.append("-snapshot")
}

builder.append("+mc").append(MINECRAFT_VERSION)

if (!isReleaseBuild) {
if (buildId != null) {
builder.append("-build.${buildId}")
} else {
builder.append("-local")
}
}

return builder.toString()
}

tasks.processResources {
filesMatching("META-INF/neoforge.mods.toml") {
expand(mapOf("version" to createVersionString()))
}
}

version = createVersionString()
group = "net.caffeinemc.mods"

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(21)
}

tasks.withType<GenerateModuleMetadata>().configureEach {
enabled = false
}
}
8 changes: 8 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}
41 changes: 41 additions & 0 deletions buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import org.gradle.api.Project

object BuildConfig {
val MINECRAFT_VERSION: String = "1.21.4"
val NEOFORGE_VERSION: String = "21.4.3-beta"
val FABRIC_LOADER_VERSION: String = "0.16.9"
val FABRIC_API_VERSION: String = "0.110.5+1.21.4"

// This value can be set to null to disable Parchment.
// TODO: Re-add Parchment
val PARCHMENT_VERSION: String? = null

// https://semver.org/
var MOD_VERSION: String = "0.6.3"

fun createVersionString(project: Project): String {
val builder = StringBuilder()

val isReleaseBuild = project.hasProperty("build.release")
val buildId = System.getenv("GITHUB_RUN_NUMBER")

if (isReleaseBuild) {
builder.append(MOD_VERSION)
} else {
builder.append(MOD_VERSION.substringBefore('-'))
builder.append("-snapshot")
}

builder.append("+mc").append(MINECRAFT_VERSION)

if (!isReleaseBuild) {
if (buildId != null) {
builder.append("-build.${buildId}")
} else {
builder.append("-local")
}
}

return builder.toString()
}
}
44 changes: 44 additions & 0 deletions buildSrc/src/main/kotlin/multiloader-base.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id("java-library")
id("idea")
}

group = "net.caffeinemc"
version = BuildConfig.createVersionString(project)

java.toolchain.languageVersion = JavaLanguageVersion.of(21)

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(21)
}

tasks.withType<GenerateModuleMetadata>().configureEach {
enabled = false
}

repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = uri("https://api.modrinth.com/maven")
}
}
filter {
includeGroup("maven.modrinth")
}
}

exclusiveContent {
forRepository {
maven {
name = "Parchment"
url = uri("https://maven.parchmentmc.org")
}
}
filter {
includeGroup("org.parchmentmc.data")
}
}
}
Loading

0 comments on commit c6b1c06

Please sign in to comment.