Skip to content

Commit

Permalink
clean build more, add -Dfireblanket.saveAsDat
Browse files Browse the repository at this point in the history
argument allows mod to run on neoforge SP currently
  • Loading branch information
sisby-folk committed Aug 28, 2024
1 parent f7fd585 commit e8484e6
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 35 deletions.
26 changes: 15 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
alias libs.plugins.loom
}

version = "$project.baseVersion+$project.branch"
archivesBaseName = project.archivesName
version = "$baseVersion+$branch"
archivesBaseName = project.slug

repositories {
maven { url "https://api.modrinth.com/maven" }
Expand All @@ -23,6 +23,7 @@ dependencies {
mappings variantOf(libs.yarn) { classifier "v2" }
modImplementation libs.fl
modImplementation libs.fapi

modImplementation libs.sodium

modImplementation libs.nettyIoUringClasses
Expand All @@ -43,18 +44,20 @@ processResources {
modId : modId,
modName : modName,
modDescription: modDescription,
homepage : homepage,
issues : issues,
sources : sources,
homepage : "https://modrinth.com/mod/${slug}",
issues : "https://github.com/${user}/${slug}/issues",
sources : "https://github.com/${user}/${slug}",
license : license,
authors : authors.split(", ").join("\",\n \""),
contributors : contributors.split(", ").join("\",\n \""),
mc : libs.versions.mc.get(),
members : "${authors}. Contributions by ${contributors}",
mc : compatibleVersions.split(", ")[0],
fl : libs.versions.fl.get(),
fapi : libs.versions.fapi.get()
]
inputs.properties meta
filesMatching("fabric.mod.json") { expand meta }
inputs.properties(meta)
filesMatching("*.mod.json") { expand(meta) }
filesMatching("META-INF/*mods.toml") { expand(meta) }
}

tasks.withType(JavaCompile).configureEach {
Expand All @@ -63,7 +66,7 @@ tasks.withType(JavaCompile).configureEach {
}

loom {
accessWidenerPath = file("src/main/resources/fireblanket.aw")
accessWidenerPath = file("src/main/resources/fireblanket.accesswidener")
}

sourceSets {
Expand All @@ -77,12 +80,13 @@ sourceSets {

java {
withSourcesJar()
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
rename { "${it}_${archivesBaseName}" }
}

configurations.shade.resolve().each {
Expand Down
12 changes: 7 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ org.gradle.configureondemand=true
# Loom
fabric.loom.multiProjectOptimisation=true
# Mod Metadata
archivesName=fireblanket
group=net.modfest
user=ModFest
slug=fireblanket
modId=fireblanket
modName=Fireblanket
modDescription=Performance, bugfixes, and utilities for ModFest events.
authors=jaskarth, unascribed
contributors=Patbox, IThundxr
homepage=https://modrinth.com/mod/fireblanket
issues=https://github.com/modfest/fireblanket/issues
sources=https://github.com/modfest/fireblanket
license=AGPL-3.0-or-later
# Mod Version
baseVersion=0.5.4
baseVersion=0.5.5
# Branch Metadata
branch=1.21
tagBranch=1.21
compatibleVersions=1.21, 1.21.1
compatibleLoaders=fabric, quilt, neoforge
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement {
repositories {
maven { url 'https://maven.fabricmc.net/' }
maven { url "https://maven.fabricmc.net/" }
gradlePluginPortal()
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/modfest/fireblanket/FireblanketMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class FireblanketMixin implements IMixinConfigPlugin {
public static final boolean ALLOW_LAMBDAMAP_SAVING = Boolean.getBoolean("fireblanket.allowLambdaMapSaving");
private static final boolean DO_CHUNKSECTION_OPTO = Boolean.getBoolean("fireblanket.flattenChunkPalettes");
public static final boolean ALLOW_FOOTGUNS = Boolean.getBoolean("fireblanket.allowFootguns");
public static final boolean AVOID_ZTSD = Boolean.getBoolean("fireblanket.saveAsDat");

@Override
public void onLoad(String mixinPackage) {
Expand Down Expand Up @@ -116,6 +117,14 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return !ALLOW_FOOTGUNS;
}

if (mixinClassName.contains("footgun")) {
return !ALLOW_FOOTGUNS;
}

if (mixinClassName.contains("MixinRegionFile") || mixinClassName.contains("MixinPersistentState") || mixinClassName.contains("MixinLevelStorageSession")) {
return !AVOID_ZTSD;
}

// Conflicts with Krypton, which also lifts the limit
return !mixinClassName.contains("SplitterHandler") || !FabricLoader.getInstance().isModLoaded("krypton");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.modfest.fireblanket.mixin.zstd;

import com.github.luben.zstd.ZstdOutputStream;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIo;
import net.minecraft.world.PersistentState;
Expand All @@ -17,10 +19,8 @@

@Mixin(PersistentState.class)
public class MixinPersistentState {

@Redirect(at = @At(value = "INVOKE", target = "net/minecraft/nbt/NbtIo.writeCompressed(Lnet/minecraft/nbt/NbtCompound;Ljava/nio/file/Path;)V"),
method = "save")
public void fireblanket$writeZstd(NbtCompound nbt, Path vanilla) throws IOException {
@WrapOperation(at = @At(value = "INVOKE", target = "net/minecraft/nbt/NbtIo.writeCompressed(Lnet/minecraft/nbt/NbtCompound;Ljava/nio/file/Path;)V"), method = "save")
public void fireblanket$writeZstd(NbtCompound nbt, Path vanilla, Operation<Void> original) throws IOException {
String path = vanilla.toAbsolutePath().toString();
if (path.endsWith(".dat")) {
File zstd = new File(path.substring(0, path.length() - 4) + ".zat");
Expand All @@ -33,8 +33,7 @@ public class MixinPersistentState {
Files.deleteIfExists(vanilla);
} else {
// oookay, I dunno what you want. have fun.
NbtIo.writeCompressed(nbt, vanilla);
original.call(nbt, vanilla);
}
}

}
44 changes: 44 additions & 0 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
modLoader = "javafml"
loaderVersion = "[4,)"
license = "${license}"
issueTrackerURL = "${issues}"

[[mods]]
modId = "${modId}"
version = "${version}"
displayName = "${modName}"
description = '''${modDescription}'''
authors = "${members}"
displayURL = "${homepage}"
logoFile = "assets/${modId}/icon.png"

[properties]
"connector:placeholder" = true

[[dependencies.${ modId }]]
modId = "connector"
type = "required"
versionRange = "*"
ordering = "NONE"
side = "BOTH"

[[dependencies.${ modId }]]
modId = "neoforge"
type = "required"
versionRange = "*"
ordering = "NONE"
side = "BOTH"

[[dependencies.${ modId }]]
modId = "minecraft"
type = "required"
versionRange = "[${mc},)"
ordering = "NONE"
side = "BOTH"

[[dependencies.${ modId }]]
modId = "fabric_api"
type = "required"
versionRange = "[${fapi},)"
ordering = "NONE"
side = "BOTH"
20 changes: 10 additions & 10 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
"sources": "${sources}"
},
"license": "${license}",
"icon": "assets/fireblanket/icon.png",
"icon": "assets/${modId}/icon.png",
"accessWidener": "${modId}.accesswidener",
"mixins": [
"${modId}.mixins.json"
],
"depends": {
"minecraft": ">=${mc}",
"fabricloader": ">=${fl}",
"fabric-api": ">=${fapi}"
},
"entrypoints": {
"main": [
"net.modfest.fireblanket.Fireblanket"
],
"client": [
"net.modfest.fireblanket.FireblanketClient"
]
},
"mixins": [
"fireblanket.mixins.json"
],
"accessWidener": "fireblanket.aw",
"depends": {
"minecraft": ">=${mc}",
"fabricloader": ">=${fl}",
"fabric-api": ">=${fapi}"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
accessWidener v1 named
accessWidener v2 named

accessible class net/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk$RebuildTask
#accessible class net/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk$RebuildTask$RenderData
accessible class net/minecraft/server/world/ServerChunkManager$MainThreadExecutor

accessible method net/minecraft/server/world/ServerChunkLoadingManager entryIterator ()Ljava/lang/Iterable;
Expand Down

0 comments on commit e8484e6

Please sign in to comment.