Skip to content

Commit

Permalink
Merge branch 'multi-version' of https://github.com/Polyfrost/OneConfi…
Browse files Browse the repository at this point in the history
…gExampleMod into multi-version
  • Loading branch information
Deftu committed Jan 2, 2025
2 parents 3174026 + 00f8d82 commit 39b703e
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 126 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 10

- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: temurin

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,4 @@ Example mod implementing OneConfig.
- **Remove the license named "LICENSE-TEMPLATE" and choose a new one.**
- Refactor the template (specifically, the modid, version and name in the gradle.properties and most of the class names)
to a different name.
- Have fun modding! :D

## Need to update to a newer commit of this template?

Check out these update guides:
- [Updating to commit `fd8e095`](update-to-fd8e095.md) (most recent update)
- [Updating to commit `301a6ca`](update-to-301a6ca.md)
- Have fun modding! :D
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@file:Suppress("UnstableApiUsage", "PropertyName")

import dev.deftu.gradle.utils.GameSide
import dev.deftu.gradle.utils.MinecraftVersion

plugins {
java
Expand All @@ -17,8 +16,8 @@ plugins {

toolkitLoomHelper {
useOneConfig {
version = "1.0.0-alpha.47"
loaderVersion = "1.1.0-alpha.34"
version = "1.0.0-alpha.49"
loaderVersion = "1.1.0-alpha.35"

usePolyMixin = true
polyMixinVersion = "0.8.4+build.2"
Expand All @@ -29,6 +28,8 @@ toolkitLoomHelper {
+module
}
}
useDevAuth("1.2.1")
useMixinExtras("0.4.1")

// Turns off the server-side run configs, as we're building a client-sided mod.
disableRunConfigs(GameSide.SERVER)
Expand All @@ -45,7 +46,7 @@ toolkitLoomHelper {
}

dependencies {
// Add Fabric Language Kotlin and (Legacy) Fabric API as dependencies (these are both optional but are particularly useful).
// Add (Legacy) Fabric API as dependencies (these are both optional but are particularly useful).
if (mcData.isFabric) {
if (mcData.isLegacyFabric) {
// 1.8.9 - 1.13
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ mod.id=examplemod
# Sets the version of your mod. Make sure to update this when you make changes according to the SemVer specification.
mod.version=1.0.0
# Sets the Maven group ID of your mod. This is effectively unused but is good practice to set regardless.
mod.group=com.example
mod.group=org.polyfrost
2 changes: 2 additions & 0 deletions root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ preprocess {
}
}
}

strictExtraMappings.set(true)
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rootProject.buildFileName = "root.gradle.kts"
// Adds all of our build target versions to the classpath if we need to add version-specific code.
// Update this list if you want to remove/add a version and/or mod loader.
// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc)
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` AND `build.gradle.kts` FILES WITH THE NEW VERSION(S).
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` FILE WITH THE NEW VERSION(S).
listOf(
"1.8.9-forge",
"1.8.9-fabric",
Expand Down
24 changes: 18 additions & 6 deletions src/main/java/org/polyfrost/example/ExampleEntrypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
//$$ import org.polyfrost.example.ExampleConstants;
//$$
//#if MC >= 1.16.5
//$$ @Mod(ModTemplateConstants.ID)
//$$ @Mod(ExampleConstants.ID)
//#else
//$$ @Mod(modid = ExampleConstants.ID, version = ExampleConstants.VERSION)
//#endif
Expand Down Expand Up @@ -86,7 +86,13 @@ public void onInitializeClient(
//#endif
) {
//#if FORGE && MC <= 1.12.2
//$$ if (!event.side.isClient) {
//$$ if (!event
//#if MC <= 1.8.9
//$$ .side.isClient
//#else
//$$ .getSide().isClient()
//#endif
//$$ ) {
//$$ return;
//$$ }
//#endif
Expand All @@ -109,7 +115,13 @@ public void onInitializeServer(
//#endif
) {
//#if FORGE && MC <= 1.12.2
//$$ if (!event.side.isServer) {
//$$ if (!event.
//#if MC <= 1.8.9
//$$ side.isServer
//#else
//$$ getSide().isServer()
//#endif
//$$ ) {
//$$ return;
//$$ }
//#endif
Expand All @@ -119,9 +131,9 @@ public void onInitializeServer(

//#if FORGE-LIKE && MC >= 1.16.5
//$$ private void setupForgeEvents(IEventBus modEventBus) {
//$$ modEventBus.addListener(this::onInitialize)
//$$ modEventBus.addListener(this::onInitializeClient)
//$$ modEventBus.addListener(this::onInitializeServer)
//$$ modEventBus.addListener(this::onInitialize);
//$$ modEventBus.addListener(this::onInitializeClient);
//$$ modEventBus.addListener(this::onInitializeServer);
//$$ }
//#endif

Expand Down
10 changes: 1 addition & 9 deletions src/main/java/org/polyfrost/example/client/ExampleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@ public class ExampleClient {

public static final ExampleClient INSTANCE = new ExampleClient();

private ExampleConfig config;

public void initialize() {
System.out.println("Initializing Example Client");

config = new ExampleConfig();
ExampleConfig.INSTANCE.preload();
CommandManager.registerCommand(new ExampleCommand());
}

public ExampleConfig getConfig() {
return config;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ExampleCommand {

@Command
private void main() {
ScreensKt.openUI(ExampleClient.INSTANCE.getConfig());
ScreensKt.openUI(ExampleConfig.INSTANCE);
}

}
2 changes: 2 additions & 0 deletions src/main/java/org/polyfrost/example/client/ExampleConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class ExampleConfig extends Config {
)
public static int exampleDropdown = 1; // Default option (in this case "Option 2")

public static final ExampleConfig INSTANCE = new ExampleConfig(); // The instance of the Config.

public ExampleConfig() {
super(ExampleConstants.ID + ".json", ExampleConstants.NAME, Category.OTHER); // TODO: Change your category here.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Mixin(Minecraft.class)
public class MixinMinecraft_Example {

@Inject(method = "startGame", at = @At(value = "HEAD"))
@Inject(method = "<init>", at = @At(value = "RETURN"))
private void examplemod$onStartGame(CallbackInfo ci) {
System.out.println("This is a message from the example mod!");
}
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/org/polyfrost/oneconfig/test/TestMod_Test.java

This file was deleted.

10 changes: 3 additions & 7 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@
"name": "${mod_name}",
"description": "${mod_description}",
"authors": [
"Polyfrost"
"Your Name"
],
"environment": "*",
"entrypoints": {
"main": [
{
"adapter": "kotlin",
"value": "org.polyfrost.example.ExampleEntrypoint"
}
],
"client": [
{
"adapter": "kotlin",
"value": "org.polyfrost.example.ExampleEntrypoint"
}
],
"server": [
{
"adapter": "kotlin",
"value": "org.polyfrost.example.ExampleEntrypoint"
}
]
Expand All @@ -33,7 +30,6 @@
],
"depends": {
"minecraft": "~${minor_mc_version}",
"fabricloader": ">=0.15.11",
"fabric-language-kotlin": "*"
"fabricloader": ">=0.15.11"
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mixins.examplemod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compatibilityLevel": "${java_version}",
"minVersion": "0.7",
"minVersion": "0.8",
"package": "org.polyfrost.example.client.mixin",
"refmap": "mixins.${mod_id}.refmap.json",
"injectors": {
Expand Down
51 changes: 0 additions & 51 deletions update-to-301a6ca.md

This file was deleted.

21 changes: 0 additions & 21 deletions update-to-fd8e095.md

This file was deleted.

0 comments on commit 39b703e

Please sign in to comment.