Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/backfill-1.21.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Backfill 1.21.x into v2.0.0

on:
workflow_dispatch:

permissions:
contents: write

env:
RELEASE_TAG: v2.0.0
VERSIONS: 1.21.4 1.21.5 1.21.7 1.21.8 1.21.9 1.21.10 1.21.11

jobs:
backfill:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Check mod_version matches the release
run: |
MOD_VERSION=$(grep '^mod_version=' gradle.properties | cut -d'=' -f2)
if [ "$MOD_VERSION" != "$RELEASE_TAG" ]; then
echo "::error::mod_version '$MOD_VERSION' does not match $RELEASE_TAG"
exit 1
fi

- name: Set up Java 25
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'
cache: gradle

- name: Make Gradle wrapper executable
run: chmod +x gradlew

- name: Build 1.21.x
run: ./gradlew $(for v in $VERSIONS; do printf ':%s:build ' "$v"; done)

- name: Find jars
id: jars
run: |
JARS=""
for v in $VERSIONS; do
JAR="versions/$v/build/libs/ScaledDragonFight-${RELEASE_TAG}+$v.jar"
if [ ! -f "$JAR" ]; then
echo "::error::Missing $JAR"
exit 1
fi
JARS="$JARS $JAR"
done
echo "$JARS"
echo "paths=$JARS" >> "$GITHUB_OUTPUT"

- name: Extract changelog
id: changelog
run: |
CONTENT=$(awk '/^## /{if(p) exit; p=1; next} p' CHANGELOG.md)
if [ -z "$CONTENT" ]; then
echo "::error::No changelog section found in CHANGELOG.md"
exit 1
fi
echo "content<<EOF" >> "$GITHUB_OUTPUT"
echo "$CONTENT" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"

- name: Add jars to the GitHub Release
env:
GH_TOKEN: ${{ github.token }}
JARS: ${{ steps.jars.outputs.paths }}
NOTES: ${{ steps.changelog.outputs.content }}
run: |
gh release upload "$RELEASE_TAG" $JARS --clobber
gh release edit "$RELEASE_TAG" --notes "$NOTES"

- name: Publish 1.21.x to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CHANGELOG: ${{ steps.changelog.outputs.content }}
run: ./gradlew $(for v in $VERSIONS; do printf ':%s:publishMods ' "$v"; done)
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Scaled Dragon Fight - v2.0.0

New config format and one release for Minecraft 26.1, 26.2, and 26.3.
New config format and one release for Minecraft 1.21.4 - 1.21.5, 1.21.7 - 1.21.11, and 26.1 - 26.3.

### Changes
- **New TOML config** - settings now live in `config/scaleddragonfight.toml`, grouped into sections with the default value and a description above each setting
Expand All @@ -16,3 +16,10 @@ New config format and one release for Minecraft 26.1, 26.2, and 26.3.
| 26.3 | 0.20.1+ | 0.166.2+26.3 | 1.13.9+kotlin.2.3.10 |
| 26.2 | 0.20.1+ | 0.161.0+26.2 | 1.13.9+kotlin.2.3.10 |
| 26.1 - 26.1.2 | 0.18.4+ | 0.144.0+26.1 | 1.13.9+kotlin.2.3.10 |
| 1.21.11 | 0.18.4+ | 0.140.2+1.21.11 | 1.13.9+kotlin.2.3.10 |
| 1.21.10 | 0.17.3+ | 0.136.0+1.21.10 | 1.13.9+kotlin.2.3.10 |
| 1.21.9 | 0.17.2+ | 0.133.14+1.21.9 | 1.13.9+kotlin.2.3.10 |
| 1.21.8 | 0.17.2+ | 0.131.0+1.21.8 | 1.13.9+kotlin.2.3.10 |
| 1.21.7 | 0.16.14+ | 0.128.2+1.21.7 | 1.13.9+kotlin.2.3.10 |
| 1.21.5 | 0.16.13+ | 0.120.0+1.21.5 | 1.13.9+kotlin.2.3.10 |
| 1.21.4 | 0.18.4+ | 0.119.4+1.21.4 | 1.13.9+kotlin.2.3.10 |
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ enableCountdownNether = false # Show the countdown to players in the Nethe
|------------------------------|-------------------------------------|
| `/scaleddragonfight reload` | Reloads the mod’s configuration |

Requires permission level 2 (OP status).
Requires permission level 3 or higher (server ops have level 4 by default).

---

Expand All @@ -89,7 +89,7 @@ Please review the new file, since the single countdown option was split into one

## 🔌 Compatibility

- Minecraft: `26.1 - 26.3`
- Minecraft: `1.21.4 - 1.21.5, 1.21.7 - 1.21.11, 26.1 - 26.3`
- Fabric Loader: Latest stable version for your Minecraft version
- Fabric API required
- **Server-side only** — no client-side installation needed
Expand Down
35 changes: 28 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "2.3.0"
id("net.fabricmc.fabric-loom") version "1.15-SNAPSHOT"
id("fabric-loom") version "1.15-SNAPSHOT"
id("maven-publish")
id("me.modmuss50.mod-publish-plugin") version "0.8.4"
}
Expand All @@ -15,9 +15,10 @@ base {
archivesName.set(project.property("archives_base_name") as String)
}

val targetJavaVersion = 25
val obfuscated = stonecutter.eval(stonecutter.current.version, "<26")
val targetJavaVersion = if (obfuscated) 21 else 25
java {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
toolchain.languageVersion = JavaLanguageVersion.of(25)
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
Expand Down Expand Up @@ -47,9 +48,19 @@ repositories {
dependencies {
// To change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
implementation("net.fabricmc:fabric-loader:${project.property("loader_version")}")
implementation("net.fabricmc:fabric-language-kotlin:${project.property("kotlin_loader_version")}")
implementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}")
if (obfuscated) {
mappings(loom.officialMojangMappings())
} else {
// 26.x ships unobfuscated; intermediary 0.0.0 is an identity passthrough that satisfies Loom.
mappings("net.fabricmc:intermediary:0.0.0:v2")
// The remapping plugin leaves Mixin off the compile classpath for unobfuscated versions.
implementation("net.fabricmc:sponge-mixin:${project.property("mixin_version")}")
}
// Obfuscated versions need mod dependencies remapped to Mojang names.
val modDependency = if (obfuscated) "modImplementation" else "implementation"
modDependency("net.fabricmc:fabric-loader:${project.property("loader_version")}")
modDependency("net.fabricmc:fabric-language-kotlin:${project.property("kotlin_loader_version")}")
modDependency("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}")

// Config (bundled into the mod jar via jar-in-jar)
implementation("com.electronwill.night-config:toml:${project.property("night_config_version")}")
Expand Down Expand Up @@ -88,6 +99,16 @@ tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(targetJavaVersion.toString()))
}

// Dev servers run on the Java version real servers use; older loaders can't read Java 25 classes.
tasks.withType<net.fabricmc.loom.task.AbstractRunTask>().configureEach {
javaLauncher.set(javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(targetJavaVersion)) })
}

// The intermediary passthrough has no "named" namespace, so sources can only be remapped for obfuscated versions.
tasks.remapSourcesJar {
enabled = obfuscated
}

tasks.jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName}" }
Expand Down Expand Up @@ -116,7 +137,7 @@ val modVersion = project.version as String
val gameVersionList = (project.property("modrinth_versions") as String).split(",").map { it.trim() }

publishMods {
file.set(tasks.jar.flatMap { it.archiveFile })
file.set(tasks.remapJar.flatMap { it.archiveFile })
version.set(modVersion)
changelog.set(providers.environmentVariable("CHANGELOG").orElse(""))
type.set(
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ stonecutter {
kotlinController = true
centralScript = "build.gradle.kts"
create(rootProject) {
versions("26.1", "26.2", "26.3")
versions("1.21.4", "1.21.5", "1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11", "26.1", "26.2", "26.3")
vcsVersion = "26.3"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.zephbyte.scaleddragonfight.mixin;

//? if >=26 {
import net.minecraft.world.level.dimension.end.EnderDragonFight;
//?} else {
/*import net.minecraft.world.level.dimension.end.EndDragonFight;
*///?}
import net.minecraft.world.entity.boss.enderdragon.EndCrystal;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import java.util.List; // Import List

//? if >=26 {
@Mixin(EnderDragonFight.class)
//?} else {
/*@Mixin(EndDragonFight.class)
*///?}
public interface EnderDragonFightAccessor {
/**
* Allows calling the private 'respawnDragon(List<EndCrystal>)' method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import com.zephbyte.scaleddragonfight.DragonEventHandler;
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
//? if >=26 {
import net.minecraft.world.level.dimension.end.EnderDragonFight;
//?} else {
/*import net.minecraft.world.level.dimension.end.EndDragonFight;
*///?}
import net.minecraft.server.level.ServerLevel;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -12,7 +16,11 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;


//? if >=26 {
@Mixin(EnderDragonFight.class)
//?} else {
/*@Mixin(EndDragonFight.class)
*///?}
public abstract class EnderDragonFightMixin {

@Shadow
Expand All @@ -23,12 +31,16 @@ public abstract class EnderDragonFightMixin {
public abstract boolean hasPreviouslyKilledDragon();

@Inject(
method = "Lnet/minecraft/world/level/dimension/end/EnderDragonFight;createNewDragon()Lnet/minecraft/world/entity/boss/enderdragon/EnderDragon;", // Target createDragon()
method = "createNewDragon()Lnet/minecraft/world/entity/boss/enderdragon/EnderDragon;", // Target createDragon()
at = @At("HEAD"),
cancellable = true
)
private void scaleddragonfight_onPreCreateDragon(CallbackInfoReturnable<EnderDragon> cir) { // Updated parameter
//? if >=26 {
EnderDragonFight fightInstance = (EnderDragonFight) (Object) this;
//?} else {
/*EndDragonFight fightInstance = (EndDragonFight) (Object) this;
*///?}

// We only want to delay the *very first* dragon spawn in this world.
// hasPreviouslyKilled() is the best check for this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import com.zephbyte.scaleddragonfight.mixin.EnderDragonFightAccessor
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerEntityEvents
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents
import net.minecraft.world.entity.boss.enderdragon.EnderDragon
//? if >=26 {
import net.minecraft.world.level.dimension.end.EnderDragonFight
//?} else {
/*import net.minecraft.world.level.dimension.end.EndDragonFight as EnderDragonFight
*///?}
import net.minecraft.world.entity.boss.enderdragon.EndCrystal
import net.minecraft.server.level.ServerLevel
import net.minecraft.network.chat.Component
Expand Down Expand Up @@ -37,7 +41,11 @@ object DragonEventHandler {
}

// Register for world ticks in The End to manage the countdown
//? if >=26 {
ServerTickEvents.END_LEVEL_TICK.register(::onWorldTick)
//?} else {
/*ServerTickEvents.END_WORLD_TICK.register(::onWorldTick)
*///?}

LOGGER.info("DragonEventHandler registered for spawn delay and scaling.")
}
Expand Down Expand Up @@ -124,7 +132,11 @@ object DragonEventHandler {
}

if (shouldSendMessage) {
//? if >=26 {
player.sendOverlayMessage(message)
//?} else {
/*player.displayClientMessage(message, true)
*///?}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import com.electronwill.nightconfig.core.io.WritingMode
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.ChatFormatting
import net.minecraft.network.chat.ClickEvent
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.HoverEvent
import net.minecraft.network.chat.Style
import net.minecraft.server.permissions.Permissions
import java.net.URI
import java.nio.file.Files
import java.nio.file.Path
Expand Down Expand Up @@ -49,7 +46,7 @@ object LegacyConfigMigrator {

// Register an event to notify the first OP that joins
ServerPlayConnectionEvents.JOIN.register { handler, _, _ ->
if (!updateNotificationSent && handler.player.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)) {
if (!updateNotificationSent && handler.player.isGamemaster()) {
handler.player.sendSystemMessage(buildNotification(imported))
updateNotificationSent = true // Ensure we only send this once per server start
}
Expand Down Expand Up @@ -121,8 +118,8 @@ object LegacyConfigMigrator {
val changelogText = Component.literal("[Changelog for v2.0.0]")
.setStyle(
Style.EMPTY
.withClickEvent(ClickEvent.OpenUrl(changelogUrl))
.withHoverEvent(HoverEvent.ShowText(Component.literal("Click to open changelog")))
.withClickEvent(openUrl(changelogUrl))
.withHoverEvent(showText(Component.literal("Click to open changelog")))
.withColor(ChatFormatting.BLUE)
.withUnderlined(true)
.withItalic(true)
Expand All @@ -132,8 +129,8 @@ object LegacyConfigMigrator {
.setStyle(
Style.EMPTY
.withColor(ChatFormatting.AQUA)
.withClickEvent(ClickEvent.SuggestCommand("/scaleddragonfight reload"))
.withHoverEvent(HoverEvent.ShowText(Component.literal("Click to suggest command")))
.withClickEvent(suggestCommand("/scaleddragonfight reload"))
.withHoverEvent(showText(Component.literal("Click to suggest command")))
)

val result = if (importedCount > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback
import net.minecraft.commands.Commands
import net.minecraft.commands.CommandSourceStack
import net.minecraft.network.chat.Component
import net.minecraft.server.permissions.Permissions

object ModCommands {

Expand All @@ -21,7 +20,7 @@ object ModCommands {
dispatcher.register(
Commands.literal(MOD_ID)
.then(Commands.literal("reload")
.requires { source -> source.permissions().hasPermission(Permissions.COMMANDS_ADMIN) } // Only ADMINS can reload
.requires { source -> source.isAdmin() } // Only ADMINS can reload
.executes { context ->
SDFConfig.reload()
val feedbackMsg = if (SDFConfig.general.enableMod) {
Expand Down
Loading
Loading