Skip to content

Commit

Permalink
update PGT and relocate to org.polyfrost
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Nov 22, 2023
1 parent 2a85a94 commit 4cad995
Show file tree
Hide file tree
Showing 38 changed files with 219 additions and 179 deletions.
178 changes: 107 additions & 71 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,124 +1,156 @@
@file:Suppress("UnstableApiUsage", "PropertyName")

import org.polyfrost.gradle.util.noServerRunConfigs
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import cc.polyfrost.gradle.util.noServerRunConfigs

// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit
// which we use to prepare the environment.
plugins {
id("cc.polyfrost.multi-version")
id("cc.polyfrost.defaults.repo")
id("cc.polyfrost.defaults.java")
id("cc.polyfrost.defaults.loom")
kotlin("jvm")
id("org.polyfrost.multi-version")
id("org.polyfrost.defaults.repo")
id("org.polyfrost.defaults.java")
id("org.polyfrost.defaults.loom")
id("com.github.johnrengelman.shadow")
id("net.kyori.blossom") version "1.3.0"
id("net.kyori.blossom") version "1.3.1"
id("signing")
java
}

// Gets the mod name, version and id from the `gradle.properties` file.
val mod_name: String by project
val mod_version: String by project
val mod_id: String by project
val mod_archives_name: String by project

// Sets up the variables for when we preprocess to other Minecraft versions.
preprocess {
vars.put("MODERN", if (project.platform.mcMinor >= 16) 1 else 0)
}

// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`.
blossom {
replaceToken("@VER@", mod_version)
replaceToken("@NAME@", mod_name)
replaceToken("@ID@", mod_id)
}

// Sets the mod version to the one specified in `gradle.properties`. Make sure to change this following semver!
version = mod_version
group = "cc.polyfrost"
// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username.
// e.g. com.github.<your username> or com.<your domain>
group = "org.polyfrost"

// Sets the name of the output jar (the one you put in your mods folder and send to other people)
// It outputs all versions of the mod into the `build` directory.
base {
archivesName.set("$mod_name ($platform)")
archivesName.set("$mod_archives_name-$platform")
}

// Configures the Polyfrost Loom, our plugin fork to easily set up the programming environment.
loom {
// Removes the server configs from IntelliJ IDEA, leaving only client runs.
// If you're developing a server-side mod, you can remove this line.
noServerRunConfigs()

// Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org)
if (project.platform.isLegacyForge) {
launchConfigs.named("client") {
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
property("fml.coreMods.load", "cc.polyfrost.overflowanimations.ModDetectorPlugin")
property("mixin.debug.export", "true")
runConfigs {
"client" {
programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
property("fml.coreMods.load", "org.polyfrost.overflowanimations.ModDetectorPlugin")
property("mixin.debug.export", "true")
}
}
}
// Configures the mixins if we are building for forge, useful for when we are dealing with cross-platform projects.
if (project.platform.isForge) {
forge {
mixinConfig("mixins.${mod_id}.json")
}
}
// Configures the name of the mixin "refmap" using an experimental loom api.
mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json")
}

// Creates the shade/shadow configuration, so we can include libraries inside our mod, rather than having to add them separately.
val shade: Configuration by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}

// Configures the output directory for when building from the `src/resources` directory.
sourceSets {
main {
output.setResourcesDir(java.classesDirectory)
}
}

// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod.
repositories {
maven("https://repo.polyfrost.cc/releases")
maven("https://repo.polyfrost.org/releases")
}

// Configures the libraries/dependencies for your mod.
dependencies {
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.0-alpha+")
// Adds the OneConfig library, so we can develop with it.
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.1-alpha+")

modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.1.2")

// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
if (platform.isLegacyForge) {
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
}
}

tasks.processResources {
inputs.property("id", mod_id)
inputs.property("name", mod_name)
val java = if (project.platform.mcMinor >= 18) {
17
} else {
if (project.platform.mcMinor == 17) 16 else 8
}
val compatLevel = "JAVA_${java}"
inputs.property("java", java)
inputs.property("java_level", compatLevel)
inputs.property("version", mod_version)
inputs.property("mcVersionStr", project.platform.mcVersionStr)
filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) {
expand(
mapOf(
"id" to mod_id,
"name" to mod_name,
"java" to java,
"java_level" to compatLevel,
"version" to mod_version,
"mcVersionStr" to project.platform.mcVersionStr
tasks {
// Processes the `src/resources/mcmod.info or fabric.mod.json` and replaces
// the mod id, name and version with the ones in `gradle.properties`
processResources {
inputs.property("id", mod_id)
inputs.property("name", mod_name)
val java = if (project.platform.mcMinor >= 18) {
17 // If we are playing on version 1.18, set the java version to 17
} else {
// Else if we are playing on version 1.17, use java 16.
if (project.platform.mcMinor == 17)
16
else
8 // For all previous versions, we **need** java 8 (for Forge support).
}
val compatLevel = "JAVA_${java}"
inputs.property("java", java)
inputs.property("java_level", compatLevel)
inputs.property("version", mod_version)
inputs.property("mcVersionStr", project.platform.mcVersionStr)
filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) {
expand(
mapOf(
"id" to mod_id,
"name" to mod_name,
"java" to java,
"java_level" to compatLevel,
"version" to mod_version,
"mcVersionStr" to project.platform.mcVersionStr
)
)
)
}
filesMatching("fabric.mod.json") {
expand(
mapOf(
"id" to mod_id,
"name" to mod_name,
"java" to java,
"java_level" to compatLevel,
"version" to mod_version,
"mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x"
}
filesMatching("fabric.mod.json") {
expand(
mapOf(
"id" to mod_id,
"name" to mod_name,
"java" to java,
"java_level" to compatLevel,
"version" to mod_version,
"mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x"
)
)
)
}
}

afterEvaluate {
if (rootProject.file("LICENSE-TEMPLATE").exists()) {
logger.error("-------------------------------------------------------")
logger.error("PLEASE REPLACE THE `LICENSE-TEMPLATE` FILE WITH YOUR OWN LICENSE")
logger.error("-------------------------------------------------------")
}
}
}

tasks {
// Configures the resources to include if we are building for forge or fabric.
withType(Jar::class.java) {
if (project.platform.isFabric) {
exclude("mcmod.info", "mods.toml")
Expand All @@ -131,27 +163,31 @@ tasks {
}
}
}

// Configures our shadow/shade configuration, so we can
// include some dependencies within our mod jar file.
named<ShadowJar>("shadowJar") {
archiveClassifier.set("dev")
archiveClassifier.set("dev") // TODO: machete gets confused by the `dev` prefix.
configurations = listOf(shade)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

remapJar {
input.set(shadowJar.get().archiveFile)
inputFile.set(shadowJar.get().archiveFile)
archiveClassifier.set("")
}

jar {
manifest {
attributes(
mapOf(
"ModSide" to "CLIENT",
"ForceLoadAsMod" to true,
"FMLCorePluginContainsFMLMod" to "Yes, yes it does",
"FMLCorePlugin" to "cc.polyfrost.overflowanimations.ModDetectorPlugin",
"TweakOrder" to "0",
"MixinConfigs" to "mixins.${mod_id}.json",
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
)
// Sets the jar manifest attributes.
if (platform.isLegacyForge) {
manifest.attributes += mapOf(
"ModSide" to "CLIENT", // We aren't developing a server-side mod, so this is fine.
"ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so.
"FMLCorePluginContainsFMLMod" to "Yes, yes it does",
"FMLCorePlugin" to "org.polyfrost.overflowanimations.ModDetectorPlugin",
"TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible.
"MixinConfigs" to "mixins.${mod_id}.json", // We want to use our mixin configuration, so we specify it here.
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper.
)
}
dependsOn(shadowJar)
Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
mod_name = OverflowAnimations
mod_id = overflowanimations
mod_version = 2.0.1-beta7alpha69

polyfrost.defaults.loom=0
mod_version = 2.0.0
mod_archives_name=OverflowAnimations

# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
polyfrost.defaults.loom=1
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureoncommand=true
org.gradle.parallel.threads=4
org.gradle.jvmargs=-Xmx2G
org.gradle.jvmargs=-Xmx2G
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions root.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("jvm") version "1.6.21" apply false
id("cc.polyfrost.multi-version.root")
kotlin("jvm") version "1.8.22" apply false
id("org.polyfrost.multi-version.root")
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
}

Expand Down
11 changes: 8 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
@file:Suppress("PropertyName")

pluginManagement {
repositories {
gradlePluginPortal()
maven("https://repo.polyfrost.cc/releases")
mavenCentral()
maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit
}
plugins {
val egtVersion = "0.1.28"
id("cc.polyfrost.multi-version.root") version egtVersion
val pgtVersion = "0.2.9" // Sets the default versions for Polyfrost Gradle Toolkit
id("org.polyfrost.multi-version.root") version pgtVersion
}
}

val mod_name: String by settings

// Configures the root project Gradle name based on the value in `gradle.properties`
rootProject.name = mod_name
rootProject.buildFileName = "root.gradle.kts"

// Adds all of our build target versions to the classpath if we need to add version-specific code.
listOf(
"1.8.9-forge"
).forEach { version ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.polyfrost.overflowanimations;
package org.polyfrost.overflowanimations;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cc.polyfrost.overflowanimations;
package org.polyfrost.overflowanimations;

import cc.polyfrost.oneconfig.utils.commands.CommandManager;
import cc.polyfrost.overflowanimations.command.OldAnimationsCommand;
import cc.polyfrost.overflowanimations.config.OldAnimationsSettings;
import org.polyfrost.overflowanimations.command.OldAnimationsCommand;
import org.polyfrost.overflowanimations.config.OldAnimationsSettings;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
Expand All @@ -15,7 +15,7 @@ public class OverflowAnimations {

@EventHandler
public void init(FMLInitializationEvent event) {
OldAnimationsSettings.INSTANCE.preLoad();
OldAnimationsSettings.INSTANCE.preload();
CommandManager.INSTANCE.registerCommand(new OldAnimationsCommand());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cc.polyfrost.overflowanimations.command;
package org.polyfrost.overflowanimations.command;

import cc.polyfrost.oneconfig.utils.commands.annotations.Command;
import cc.polyfrost.oneconfig.utils.commands.annotations.Main;
import cc.polyfrost.overflowanimations.config.OldAnimationsSettings;
import org.polyfrost.overflowanimations.config.OldAnimationsSettings;

@Command(value = "overflowanimations", aliases = {"oam", "oldanimations", "animations"}, description = "Overflow Animations")
public class OldAnimationsCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package cc.polyfrost.overflowanimations.config;
package org.polyfrost.overflowanimations.config;

import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.annotations.Checkbox;
import cc.polyfrost.oneconfig.config.annotations.Dropdown;
import cc.polyfrost.oneconfig.config.annotations.Exclude;
import cc.polyfrost.oneconfig.config.annotations.Switch;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator;
import cc.polyfrost.oneconfig.config.migration.VigilanceName;
import cc.polyfrost.overflowanimations.OverflowAnimations;
import org.polyfrost.overflowanimations.OverflowAnimations;

@SuppressWarnings("unused")
public class OldAnimationsSettings extends Config {
Expand Down Expand Up @@ -92,7 +93,8 @@ public class OldAnimationsSettings extends Config {
@Switch(name = "1.15+ Armor Enchantment Glint", description = "Back-ports the 1.15 armor glint rendering.", subcategory = "Modern Features")
public static boolean enchantmentGlintNew = false;

@Switch(name = "1.15+ Item Throwing Animation", description = "Back-ports the 1.15 item throwing animation while dropping items or throwing projectiles.", subcategory = "Modern Features")
//@Switch(name = "1.15+ Item Throwing Animation", description = "Back-ports the 1.15 item throwing animation while dropping items or throwing projectiles.", subcategory = "Modern Features")
@Exclude
public static boolean itemThrow = false;

@Switch(name = "Miss Penalty Swing Animation", description = "This option is purely visual. During the miss penalty, the player's arm will still swing and show particles.",subcategory = "Fixes")
Expand Down Expand Up @@ -147,8 +149,4 @@ public OldAnimationsSettings() {
addDependency("fixRod", "itemTransformations");
addDependency("entityTransforms", "thirdTransformations");
}

public void preLoad() {
// does nothing, used to call static initializers
}
}
Loading

0 comments on commit 4cad995

Please sign in to comment.