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
2 changes: 1 addition & 1 deletion .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
java-version: 25

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version "${fabric_loom_version}" apply false
id 'net.fabricmc.fabric-loom' version "${fabric_loom_version}" apply false
id 'net.neoforged.moddev' version "${neoforge_moddev_version}" apply false
id 'com.modrinth.minotaur' version "${minotaur_plugin_version}" apply false
id 'net.darkhax.curseforgegradle' version "${curseforgegradle_plugin_version}" apply false
Expand Down Expand Up @@ -417,4 +417,3 @@ tasks.register('release') {
println ""
}
}

3 changes: 1 addition & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom'
id 'net.fabricmc.fabric-loom'
}

repositories {
Expand All @@ -11,7 +11,6 @@ repositories {

dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()

compileOnly "org.spongepowered:mixin:${spongepowered_version}"
annotationProcessor "org.spongepowered:mixin:${spongepowered_version}:processor"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* FastBack - Fast, incremental Minecraft backups powered by Git.
* Copyright (C) 2022 pcal.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; If not, see <http://www.gnu.org/licenses/>.
*/
package net.pcal.fastback.common.mixins;

import net.minecraft.util.filefix.FileFixerUpper;
import net.minecraft.util.filefix.virtualfilesystem.CopyOnWriteFileSystem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.PathMatcher;

/**
* Prevents MC 26.1+'s CopyOnWriteFileSystem (used during world upgrade) from choking
* on read-only git object files inside the .git directory.
*
* @author pcal
* @since 0.31.2
*/
@Mixin(FileFixerUpper.class)
public class FileFixerUpperMixin {

@Redirect(
method = "applyFileFixersOnCow",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/util/filefix/virtualfilesystem/CopyOnWriteFileSystem;create(Ljava/lang/String;Ljava/nio/file/Path;Ljava/nio/file/Path;Ljava/nio/file/PathMatcher;)Lnet/minecraft/util/filefix/virtualfilesystem/CopyOnWriteFileSystem;",
remap = false
),
remap = false
)
private CopyOnWriteFileSystem fastback_skipGitDir(
String name, Path baseDir, Path tmpDir, PathMatcher original) throws IOException {
PathMatcher withGitSkip = path -> {
for (Path component : path) {
if (".git".equals(component.toString())) return true;
}
return original.matches(path);
};
return CopyOnWriteFileSystem.create(name, baseDir, tmpDir, withGitSkip);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package net.pcal.fastback.common.mixins;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.GenericMessageScreen;
import net.pcal.fastback.common.mod.Mod;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -34,8 +34,8 @@
@Mixin(GenericMessageScreen.class)
public class MessageScreenMixin {

@Inject(method = "renderBackground", at = @At("TAIL"), remap = false)
public void fastback_render(GuiGraphics context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
@Inject(method = "extractBackground", at = @At("TAIL"), remap = false)
public void fastback_render(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
Mod.mod().renderMessageScreen(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package net.pcal.fastback.common.mod;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.GenericMessageScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -82,11 +82,11 @@ public void setMessageScreenText(UserMessage userMessage) {
}
}

public void renderMessageScreen(GuiGraphics guiGraphics) {
public void renderMessageScreen(GuiGraphicsExtractor guiGraphics) {
renderHud(guiGraphics);
}

public void renderHud(GuiGraphics guiGraphics) {
public void renderHud(GuiGraphicsExtractor guiGraphics) {
if (this.client == null) return;
if (this.hudText == null) return;
if (!this.client.options.showAutosaveIndicator().get()) return;
Expand All @@ -95,6 +95,6 @@ public void renderHud(GuiGraphics guiGraphics) {
syslog().debug("hud text timed out. somebody forgot to clean up");
return;
}
guiGraphics.drawString(this.client.font, this.hudText, 2, 2, 0xFFFFFFFF);
guiGraphics.text(this.client.font, this.hudText, 2, 2, 0xFFFFFF, false);
}
}
6 changes: 3 additions & 3 deletions common/src/main/java/net/pcal/fastback/common/mod/Mod.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package net.pcal.fastback.common.mod;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.MinecraftServer;
import net.pcal.fastback.common.logging.UserMessage;
Expand Down Expand Up @@ -87,7 +87,7 @@ static void initializeForClient(LoaderHelper loaderHelper, ClientHelper clientHe
/**
* Allows loaders to plugin HUD rendering.
*/
void renderHud(GuiGraphics drawContext);
void renderHud(GuiGraphicsExtractor drawContext);

// ======================================================================
// Mixin-facing methods
Expand All @@ -108,7 +108,7 @@ static void initializeForClient(LoaderHelper loaderHelper, ClientHelper clientHe
/**
* Called from the shutdown message screen mixins to render additional text.
*/
void renderMessageScreen(GuiGraphics drawContext);
void renderMessageScreen(GuiGraphicsExtractor drawContext);


// ======================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package net.pcal.fastback.common.mod;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.storage.LevelStorageSource;
Expand Down Expand Up @@ -239,7 +239,7 @@ public void autoSaveCompleted() {
}

@Override
public void renderMessageScreen(GuiGraphics drawContext) {
public void renderMessageScreen(GuiGraphicsExtractor drawContext) {
if (this.clientHelper != null) {
this.clientHelper.renderMessageScreen(drawContext);
} else {
Expand All @@ -248,7 +248,7 @@ public void renderMessageScreen(GuiGraphics drawContext) {
}

@Override
public void renderHud(GuiGraphics drawContext) {
public void renderHud(GuiGraphicsExtractor drawContext) {
if (this.clientHelper != null) {
this.clientHelper.renderHud(drawContext);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public class UserMessageUtil {
public static Component messageToText(final UserMessage m) {
final MutableComponent out;
if (m.localized() != null) {
out = Component.translatable(m.localized().key(), m.localized().params());
out = Component.translatable(
m.localized().key(),
messageParamsToComponentArgs(m.localized().params())
);
} else {
out = Component.literal(m.raw());
}
Expand All @@ -53,6 +56,20 @@ public static Component messageToText(final UserMessage m) {
return out;
}

private static Object[] messageParamsToComponentArgs(final Object[] params) {
if (params == null) return new Object[0];

final Object[] out = new Object[params.length];
for (int i = 0; i < params.length; i++) {
final Object param = params[i];
if (param instanceof Component) {
out[i] = param;
} else {
out[i] = String.valueOf(param);
}
}
return out;
}

private UserMessageUtil() {}
}

3 changes: 2 additions & 1 deletion common/src/main/resources/fastback.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"required": true,
"minVersion": "0.8",
"package": "net.pcal.fastback.common.mixins",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_25",
"mixins": [
"FileFixerUpperMixin",
"MinecraftServerMixin",
"ServerAccessors",
"SessionAccessors"
Expand Down
32 changes: 14 additions & 18 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom'
id 'net.fabricmc.fabric-loom'
id 'com.modrinth.minotaur'
id 'net.darkhax.curseforgegradle'
}
Expand All @@ -17,33 +17,32 @@ repositories {

dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
implementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"

modImplementation("me.lucko:fabric-permissions-api:${fabric_permissions_version}") { transitive = false }
implementation("me.lucko:fabric-permissions-api:${fabric_permissions_version}") { transitive = false }
include("me.lucko:fabric-permissions-api:${fabric_permissions_version}") { transitive = false }

modImplementation("xyz.nucleoid:server-translations-api:${server_translations_version}")
implementation("xyz.nucleoid:server-translations-api:${server_translations_version}")
include("xyz.nucleoid:server-translations-api:${server_translations_version}")

// jgit and dependencies
modImplementation("org.eclipse.jgit:org.eclipse.jgit:${jgit_version}") { transitive = false }
implementation("org.eclipse.jgit:org.eclipse.jgit:${jgit_version}") { transitive = false }
include("org.eclipse.jgit:org.eclipse.jgit:${jgit_version}") { transitive = false }

modImplementation("com.googlecode.javaewah:JavaEWAH:${JavaEWAH_version}") { transitive = false }
implementation("com.googlecode.javaewah:JavaEWAH:${JavaEWAH_version}") { transitive = false }
include("com.googlecode.javaewah:JavaEWAH:${JavaEWAH_version}") { transitive = false }

modImplementation("org.eclipse.jgit:org.eclipse.jgit.ssh.apache:${jgit_version}") { transitive = false }
implementation("org.eclipse.jgit:org.eclipse.jgit.ssh.apache:${jgit_version}") { transitive = false }
include("org.eclipse.jgit:org.eclipse.jgit.ssh.apache:${jgit_version}") { transitive = false }

modImplementation("org.apache.sshd:sshd-core:${apache_sshd_version}") { transitive = false }
implementation("org.apache.sshd:sshd-core:${apache_sshd_version}") { transitive = false }
include("org.apache.sshd:sshd-core:${apache_sshd_version}") { transitive = false }

modImplementation("org.apache.sshd:sshd-common:${apache_sshd_version}") { transitive = false }
implementation("org.apache.sshd:sshd-common:${apache_sshd_version}") { transitive = false }
include("org.apache.sshd:sshd-common:${apache_sshd_version}") { transitive = false }

modImplementation("net.i2p.crypto:eddsa:${eddsa_version}") { transitive = false }
implementation("net.i2p.crypto:eddsa:${eddsa_version}") { transitive = false }
include("net.i2p.crypto:eddsa:${eddsa_version}") { transitive = false }

compileOnly project(':common')
Expand Down Expand Up @@ -84,9 +83,6 @@ loom {
runDir("run")
}
}
mixin {
defaultRefmapName = "fastback-refmap.json"
}
mods {
"fastback" {
sourceSet sourceSets.main
Expand All @@ -107,7 +103,7 @@ modrinth {
versionNumber = mod_version
versionName = "${mod_version} (fabric)"
versionType = "release"
uploadFile = remapJar
uploadFile = jar
changelog = "<p><a href='${github_projectUrl}/releases/tag/${mod_version}'>${github_projectUrl}/releases/tag/${mod_version}</a></p>"
gameVersions = [minecraft_version]
loaders = ["fabric"]
Expand All @@ -120,11 +116,11 @@ import net.darkhax.curseforgegradle.TaskPublishCurseForge

tasks.register('publishCurseForge', TaskPublishCurseForge) {
apiToken = System.getenv("CURSEFORGE_TOKEN") ?: 'CURSEFORGE_TOKEN NOT_SET'
def mainFile = upload(curseforge_projectId, remapJar)
def mainFile = upload(curseforge_projectId, jar)
mainFile.releaseType = "release"
mainFile.changelog = "${github_projectUrl}/releases/tag/${mod_version}"
mainFile.changelogType = "markdown"
mainFile.addGameVersion(minecraft_version)
mainFile.addModLoader("Fabric")
dependsOn(remapJar)
dependsOn(jar)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.resources.Identifier;
import net.pcal.fastback.common.mod.ClientHelper;
import net.pcal.fastback.common.mod.Mod;

Expand All @@ -33,14 +34,17 @@
*/
public class FabricClientInitializer implements ClientModInitializer {

private static final String MOD_ID = "fastback";

@Override
public void onInitializeClient() {
ClientLifecycleEvents.CLIENT_STARTED.register(
minecraftClient -> {
Mod.initializeForClient(new FabricLoaderHelper(), new ClientHelper(minecraftClient));
HudRenderCallback.EVENT.register((guiGraphics,deltaTracker)->{
Mod.mod().renderHud(guiGraphics);
});
HudElementRegistry.addLast(
Identifier.fromNamespaceAndPath(MOD_ID, "hud"),
(guiGraphics, deltaTracker) -> Mod.mod().renderHud(guiGraphics)
);
}
);
ServerLifecycleEvents.SERVER_STARTING.register(
Expand Down
7 changes: 4 additions & 3 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
],
"depends": {
"fabricloader": ">=${fabric_loader_version}",
"minecraft": ">=${minecraft_version}",
"java": ">=${java_version}"
"fabric-api": "*",
"fabric-permissions-api-v0": "*",
"minecraft": "26.1.x",
"java": ">=25"
},
"conflicts": {}
}

Loading
Loading