Skip to content

Commit

Permalink
Merge branch '1.21/dev' into 1.21/stable
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Aug 23, 2024
2 parents b744b75 + 1997c7f commit 3c42629
Show file tree
Hide file tree
Showing 138 changed files with 2,555 additions and 1,337 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Java CI with Gradle

on: [ pull_request, push ]
on: [pull_request, push]

jobs:
build:
Expand All @@ -19,8 +19,13 @@ jobs:
check-latest: true
- name: Build with Gradle
run: ./gradlew build
- name: Upload Build Artifacts
- name: Upload Build Artifacts - Fabric
uses: actions/upload-artifact@v4
with:
name: 'Sodium Extra Artifacts'
path: build/libs
name: 'Sodium Extra Fabric Artifacts'
path: fabric/build/libs
- name: Upload Build Artifacts - NeoForge
uses: actions/upload-artifact@v4
with:
name: 'Sodium Extra NeoForge Artifacts'
path: neoforge/build/libs
29 changes: 25 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- published

jobs:
publish:
build:
if: github.repository_owner == 'FlashyReese'
runs-on: self-hosted
steps:
Expand All @@ -25,8 +25,19 @@ jobs:
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
- name: Publish to Modrinth & CurseForge
uses: Kir-Antipov/[email protected]
publish:
needs: build
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- platform: fabric
name: Fabric
- platform: neoforge
name: NeoForge
steps:
- name: Publish ${{ matrix.name }} to Modrinth, CurseForge & GitHub
uses: Kir-Antipov/[email protected]
with:
modrinth-id: PtjYWJkn
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
Expand All @@ -36,11 +47,21 @@ jobs:

github-token: ${{ secrets.GITHUB_TOKEN }}

name: '[${{ matrix.name }}] ${{ github.event.release.name }}'
version: '${{ github.event.release.tag_name }}+${{ matrix.platform }}'
version-type: release
loaders: fabric

loaders: ${{ matrix.platform }}

dependencies: |
sodium | depends | *
fabric-api | depends | *
reeses-sodium-options | recommends | *
irisshaders | recommends | *
iris | recommends | *
files: |
${{ matrix.platform }}/build/libs/!(*-@(dev|sources|javadoc|dev-shadow)).jar
${{ matrix.platform }}/build/libs/*-@(dev|sources|javadoc|dev-shadow).jar
version-resolver: latest
13 changes: 9 additions & 4 deletions .github/workflows/self-hosted.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Self-Hosted runner CI with Gradle

on: [ push ]
on: [push]

jobs:
selfhost-build:
Expand All @@ -23,8 +23,13 @@ jobs:
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
- name: Upload Auild Artifacts
- name: Upload Build Artifacts - Fabric
uses: actions/upload-artifact@v4
with:
name: 'Sodium Extra Artifacts'
path: build/libs
name: 'Sodium Extra Fabric Artifacts'
path: fabric/build/libs
- name: Upload Build Artifacts - NeoForge
uses: actions/upload-artifact@v4
with:
name: 'Sodium Extra NeoForge Artifacts'
path: neoforge/build/libs
89 changes: 89 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
plugins {
id("java")
id("fabric-loom") version ("1.7.2") apply (false)
}

val MINECRAFT_VERSION by extra { "1.21.1" }
val NEOFORGE_VERSION by extra { "21.1.23" }
val FABRIC_LOADER_VERSION by extra { "0.16.2" }
val FABRIC_API_VERSION by extra { "0.102.1+1.21.1" }

// This value can be set to null to disable Parchment.
val PARCHMENT_VERSION by extra { null }

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

//
val maven_group: String by project
val archives_name: String by project

allprojects {
apply(plugin = "java")
apply(plugin = "maven-publish")
group = maven_group
version = createVersionString()
}

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

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

repositories {
maven("https://maven.parchmentmc.org/")
maven("https://api.modrinth.com/maven")
}

base {
archivesName = "$archives_name-${project.name}"
}

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

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

version = createVersionString()
group = "me.flashyreese.mods"

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

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

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.split('-')[0])
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()
}
85 changes: 85 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import net.fabricmc.loom.task.AbstractRemapJarTask

plugins {
id("java")
id("idea")
id("fabric-loom") version "1.7.2"
}

val MINECRAFT_VERSION: String by rootProject.extra
val PARCHMENT_VERSION: String? by rootProject.extra
val FABRIC_LOADER_VERSION: String by rootProject.extra
val FABRIC_API_VERSION: String by rootProject.extra

// This trick hides common tasks in the IDEA list.
tasks.configureEach {
group = null
}

dependencies {
minecraft(group = "com.mojang", name = "minecraft", version = MINECRAFT_VERSION)
mappings(loom.layered() {
officialMojangMappings()
if (PARCHMENT_VERSION != null) {
parchment("org.parchmentmc.data:parchment-${MINECRAFT_VERSION}:${PARCHMENT_VERSION}@zip")
}
})
compileOnly("io.github.llamalad7:mixinextras-common:0.3.5")
annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.5")
compileOnly("net.fabricmc:sponge-mixin:0.13.2+mixin.0.8.5")

fun addDependentFabricModule(name: String) {
val module = fabricApi.module(name, FABRIC_API_VERSION)
modCompileOnly(module)
}

addDependentFabricModule("fabric-api-base")
addDependentFabricModule("fabric-block-view-api-v2")
addDependentFabricModule("fabric-renderer-api-v1")
addDependentFabricModule("fabric-rendering-data-attachment-v1")

modCompileOnly("net.fabricmc.fabric-api:fabric-renderer-api-v1:3.2.9+1172e897d7")
implementation(group = "com.lodborg", name = "interval-tree", version = "1.0.0")

modImplementation(/*files(rootDir.resolve("sodium-fabric.jar"))*/ "maven.modrinth:sodium:mc1.21-0.6.0-beta.1-fabric")
}

tasks.withType<AbstractRemapJarTask>().forEach {
it.targetNamespace = "named"
}

loom {
mixin {
defaultRefmapName = "sodium-extra.refmap.json"
}

accessWidenerPath = file("src/main/resources/sodium-extra.accesswidener")
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = base.archivesName.get()
from(components["java"])
}
}

repositories {
maven {
name = "FlashyReeseReleases"
url = uri("https://maven.flashyreese.me/releases")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
maven {
name = "FlashyReeseSnapshots"
url = uri("https://maven.flashyreese.me/snapshots")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package me.flashyreese.mods.sodiumextra.client;

import com.google.common.collect.EvictingQueue;
import me.flashyreese.mods.sodiumextra.mixin.gui.MinecraftClientAccessor;
import net.minecraft.client.Minecraft;

import java.util.Comparator;
import java.util.Queue;

public class ClientTickHandler {
private final Queue<Integer> fpsQueue = EvictingQueue.create(200);
private int averageFps, lowestFps, highestFps;

public void onClientTick(Minecraft client) {
int currentFPS = MinecraftClientAccessor.getFPS();
this.fpsQueue.add(currentFPS);
this.averageFps = (int) this.fpsQueue.stream().mapToInt(Integer::intValue).average().orElse(0);
this.lowestFps = this.fpsQueue.stream().min(Comparator.comparingInt(e -> e)).orElse(0);
this.highestFps = this.fpsQueue.stream().max(Comparator.comparingInt(e -> e)).orElse(0);
}

public int getAverageFps() {
return this.averageFps;
}

public int getLowestFps() {
return this.lowestFps;
}

public int getHighestFps() {
return this.highestFps;
}
}
Loading

0 comments on commit 3c42629

Please sign in to comment.