Skip to content

Commit

Permalink
Update to babric 1.4.2, use biny, remove test mod container
Browse files Browse the repository at this point in the history
  • Loading branch information
calmilamsy committed Apr 8, 2024
1 parent 6f7077f commit 2e95f78
Show file tree
Hide file tree
Showing 24 changed files with 292 additions and 442 deletions.
154 changes: 93 additions & 61 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
buildscript {
repositories {
maven {
name = "Fabric"
url = "https://maven.fabricmc.net/"
}
mavenCentral()
jcenter()
maven {
name = "Jitpack"
url 'https://jitpack.io/'
}
}
dependencies {
classpath 'com.github.Chocohead:Fabric-Loom:0d0261a'
}
plugins {
id 'babric-loom' version '1.4.2'
id 'maven-publish'
}

apply plugin: "fabric-loom"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

Expand All @@ -26,68 +11,115 @@ version = project.mod_version
group = project.maven_group

repositories {
maven {
name = "Jitpack"
url "https://jitpack.io/"
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.

// Used for the fabric toolchain in this project.
maven {
name = 'Babric'
url = 'https://maven.glass-launcher.net/babric'
}
// Used for mappings.
maven {
name = 'Glass Releases'
url = 'https://maven.glass-launcher.net/releases'
}
// Used for StationAPI and HowManyItems.
maven {
name = 'Glass Snapshots'
url = 'https://maven.glass-launcher.net/snapshots'
}
// Used for a StationAPI dependency.
maven {
name = 'Froge'
url 'https://maven.minecraftforge.net/'
}
// Used for projects that do not have a maven repository, but do have a GitHub repository with working build scripts.
maven {
name = 'Jitpack'
url = 'https://jitpack.io'
}
// Used for another StationAPI dependency
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
mavenCentral()
}

minecraft {
loom {
mixin {
useLegacyMixinAp = true
}
gluedMinecraftJar()
customMinecraftManifest.set("https://babric.github.io/manifest-polyfill/${minecraft_version}.json")
intermediaryUrl.set("https://maven.glass-launcher.net/babric/babric/intermediary/%1\$s/intermediary-%1\$s-v2.jar")
}

dependencies {
// fabric loader requires log4j, guava, and gson
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8.1'
annotationProcessor group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8.1'
annotationProcessor group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8.1'
implementation 'com.google.guava:guava:28.0-jre'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'

// mixin and fabric loader need asm 9
implementation 'org.ow2.asm:asm:9.0'
implementation 'org.ow2.asm:asm-analysis:9.0'
implementation 'org.ow2.asm:asm-commons:9.0'
implementation 'org.ow2.asm:asm-tree:9.0'
implementation 'org.ow2.asm:asm-util:9.0'

// adds some useful annotations for miscellaneous uses. does not add any dependencies, though people without the lib will be missing some useful context hints.
compile 'org.jetbrains:annotations:16.0.2'

//to change the versions see the gradle.properties file
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.glasslauncher:biny:${project.yarn_mappings}:v2"
modImplementation "babric:fabric-loader:${project.loader_version}"
implementation 'org.apache.logging.log4j:log4j-slf4j18-impl:2.17.2'

mappings loom.fromCommit("calmilamsy/BIN-Mappings", "${project.yarn_mappings}") {spec ->
spec.version = "b1.7.3-${project.yarn_mappings}"
}
implementation 'com.google.guava:guava:28.0-jre'
implementation 'com.google.code.gson:gson:2.8.6'

modImplementation "com.github.minecraft-cursed-legacy:cursed-fabric-loader:${project.loader_version}"
// adds some useful annotations for miscellaneous uses. does not add any dependencies, though people without the lib will be missing some useful context hints.
implementation 'org.jetbrains:annotations:24.0.0'
}

processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
// Loom also requires J17.
it.options.release = 17
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
java {
// 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.
withSourcesJar()
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
11 changes: 5 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Disables gradle's buggy (in minecraft's case) daemon.
# Also makes builds more reliable and less likely to randomly fail.
org.gradle.daemon=false

mod_version=1.8.5-beta.2
maven_group=io.github.prospector
mod_version=1.8.5-beta.4
maven_group=net.glasslauncher.mods
archives_base_name=modmenu

yarn_mappings=df0e26c
minecraft_version=b1.7.3
loader_version=1.0.0
yarn_mappings=b1.7.3+cbcfb39
loader_version=0.14.24-babric.1
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sun Nov 11 14:39:10 PST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStorePath=wrapper/dists
14 changes: 14 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Babric'
url = 'https://maven.glass-launcher.net/babric'
}
mavenCentral()
gradlePluginPortal()
}
}
14 changes: 7 additions & 7 deletions src/main/java/io/github/prospector/modmenu/ModMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import net.fabricmc.loader.api.metadata.CustomValue;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.ScreenBase;
import net.minecraft.client.gui.screen.menu.Options;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen;

import java.text.NumberFormat;
import java.util.*;
Expand All @@ -30,15 +30,15 @@ public class ModMenu implements ClientModInitializer {
public static final Set<String> CLIENTSIDE_MODS = new HashSet<>();
public static final Set<String> PATCHWORK_FORGE_MODS = new HashSet<>();
public static final LinkedListMultimap<ModContainer, ModContainer> PARENT_MAP = LinkedListMultimap.create();
private static ImmutableMap<String, Function<ScreenBase, ? extends ScreenBase>> configScreenFactories = ImmutableMap.of();
private static ImmutableMap<String, Function<Screen, ? extends Screen>> configScreenFactories = ImmutableMap.of();
private static int libraryCount = 0;

public static boolean hasConfigScreenFactory(String modid) {
return configScreenFactories.containsKey(modid);
}

public static ScreenBase getConfigScreen(String modid, ScreenBase menuScreen) {
Function<ScreenBase, ? extends ScreenBase> factory = configScreenFactories.get(modid);
public static Screen getConfigScreen(String modid, Screen menuScreen) {
Function<Screen, ? extends Screen> factory = configScreenFactories.get(modid);
return factory != null ? factory.apply(menuScreen) : null;
}

Expand All @@ -64,9 +64,9 @@ public static void addLibraryMod(String modid) {
@Override
public void onInitializeClient() {
ModMenuConfigManager.initializeConfig();
ImmutableMap.Builder<String, Function<ScreenBase, ? extends ScreenBase>> factories = ImmutableMap.builder();
ImmutableMap.Builder<String, Function<Screen, ? extends Screen>> factories = ImmutableMap.builder();
FabricLoader.getInstance().getEntrypoints("modmenu", ModMenuApi.class).forEach(api -> factories.put(api.getModId(), api.getConfigScreenFactory()));
factories.put("minecraft", (screenBase -> new Options(screenBase, ((Minecraft) FabricLoader.getInstance().getGameInstance()).options)));
factories.put("minecraft", (screenBase -> new OptionsScreen(screenBase, ((Minecraft) FabricLoader.getInstance().getGameInstance()).options)));
configScreenFactories = factories.build();
Collection<ModContainer> mods = FabricLoader.getInstance().getAllMods();
HardcodedUtil.initializeHardcodings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.client.gui.screen.ScreenBase;
import net.minecraft.client.gui.screen.Screen;

public interface ModMenuApi {
/**
* Replaced with {@link ModMenuApi#getConfigScreen(ScreenBase)}, with
* Replaced with {@link ModMenuApi#getConfigScreen(Screen)}, with
* the ModMenuApi implemented onto a class that is added as an
* entry point to your fabric mod metadata.
*
Expand All @@ -34,7 +34,7 @@ static void addConfigOverride(String modid, Runnable action) {
* @deprecated Will be removed in 1.15 snapshots.
*/
@Deprecated
default Optional<Supplier<ScreenBase>> getConfigScreen(ScreenBase screen) {
default Optional<Supplier<Screen>> getConfigScreen(Screen screen) {
return Optional.empty();
}

Expand All @@ -45,7 +45,7 @@ default Optional<Supplier<ScreenBase>> getConfigScreen(ScreenBase screen) {
*
* @return A factory function for constructing config screen instances.
*/
default Function<ScreenBase, ? extends ScreenBase> getConfigScreenFactory() {
default Function<Screen, ? extends Screen> getConfigScreenFactory() {
return screen -> getConfigScreen(screen).map(Supplier::get).orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.github.prospector.modmenu.util.HardcodedUtil;
import io.github.prospector.modmenu.util.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.render.TextRenderer;
import net.minecraft.client.font.TextRenderer;

public class DescriptionListWidget extends EntryListWidget<DescriptionListWidget.DescriptionEntry> {

Expand Down Expand Up @@ -68,7 +68,7 @@ public DescriptionEntry(String text) {

@Override
public void render(int index, int y, int x, int itemWidth, int itemHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
textRenderer.drawTextWithShadow(text, x, y, 0xAAAAAA);
textRenderer.drawWithShadow(text, x, y, 0xAAAAAA);
}
}

Expand Down
Loading

0 comments on commit 2e95f78

Please sign in to comment.