Skip to content

Commit

Permalink
Merge Forge + Fabric Versions + Update to 1.4.1
Browse files Browse the repository at this point in the history
---

Minor Changes Forge side.
Update Fabric side to 1.4.0 Standard

Signed-off-by: AterAnimAvis <[email protected]>
  • Loading branch information
AterAnimAvis committed Nov 12, 2020
1 parent 5657e91 commit 4d91b13
Show file tree
Hide file tree
Showing 156 changed files with 3,153 additions and 335 deletions.
222 changes: 160 additions & 62 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
buildscript {
repositories {
maven(url = "https://files.minecraftforge.net/maven")
maven(url = "https://maven.fabricmc.net")
jcenter()
mavenCentral()
}
Expand All @@ -10,106 +11,203 @@ buildscript {
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = "3.+") {
isChanging = true
}
classpath(group = "fabric-loom", name = "fabric-loom.gradle.plugin", version = "0.5.+") {
isChanging = true
}
}
}

/*========================================================================================== Config -> Minecraft ==== */
/* ========================================================================================= Config -> Minecraft ==== */
val forgeVersion: String by extra
val mappingsChannel: String by extra
val mappingsVersion: String by extra
val minecraftVersion: String by extra
val yarnBuild: String by extra

/*================================================================================================ Config -> Mod ==== */
/* =============================================================================================== Config -> Mod ==== */
val modId: String by extra
val modVersion: String by extra
val modGroup: String by extra
val vendor: String by extra

/*========================================================================================= Config -> Run Config ==== */
/* ======================================================================================== Config -> Run Config ==== */
val level: String by extra
val markers: String by extra

/*======================================================================================= Config -> Dependencies ==== */
/* ====================================================================================== Config -> Dependencies ==== */
val fabricApiVersion: String by extra
val fabricLoaderVersion: String by extra
val log4jApiVersion: String by extra
val lwjglVersion: String by extra
val jetbrainsAnnotationVersion: String by extra

/*================================================================================== Config -> Test Dependencies ==== */
/* ================================================================================= Config -> Test Dependencies ==== */
val junitVersion: String by extra

/*====================================================================================================== Plugins ==== */
plugins {
`java-library`
}
subprojects {
/* ================================================================================================= Plugins ==== */
apply(plugin = "java")
apply(plugin = "java-library")

/* =================================================================================================== Setup ==== */

project.group = modGroup
project.version = "$minecraftVersion-$modVersion"

/* Java 8 Target + Parameter Names */
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.compilerArgs.add("-parameters")
}

/* Generate Package Infos */
apply(from = "$rootDir/utils.gradle.kts")

/* ============================================================================================ Dependencies ==== */

repositories {
jcenter()
mavenCentral()
}

dependencies {
/* JUnit 5 */
"testImplementation"(group = "org.junit.jupiter", name = "junit-jupiter", version = junitVersion)

/* Jetbrains Annotations */
"implementation"(group = "org.jetbrains", name = "annotations", version = jetbrainsAnnotationVersion)

apply(plugin = "net.minecraftforge.gradle")
if (project.name in listOf("forge", "fabric")) {
/* Common */
"implementation"(project(":common"))
} else {
/* Dependencies for Common */

/*========================================================================================= Minecraft Dependency ==== */
/* Logging */
"implementation"(group = "org.apache.logging.log4j", name = "log4j-api", version = log4jApiVersion)

/* Note: Due to the way kotlin gradle works we need to define the minecraft dependency before we configure Minecraft */
dependencies {
"minecraft"(group = "net.minecraftforge", name = "forge", version = "$minecraftVersion-$forgeVersion")
/* LWJGL / OpenGL */
"implementation"(group = "org.lwjgl", name = "lwjgl", version = lwjglVersion)
"implementation"(group = "org.lwjgl", name = "lwjgl-opengl", version = lwjglVersion)
}
}
}

/*==================================================================================================== Minecraft ==== */
/* ======================================================================================================= Forge ==== */

project(":forge") {
/* ================================================================================================= Plugins ==== */

apply(plugin = "net.minecraftforge.gradle")

/* ==================================================================================== Minecraft Dependency ==== */

/* Note: Due to the way kotlin gradle works we need to define the minecraft dependency before configuration */
dependencies {
"minecraft"(group = "net.minecraftforge", name = "forge", version = "$minecraftVersion-$forgeVersion")
}

/* =============================================================================================== Minecraft ==== */

minecraft {
mappingChannel = mappingsChannel
mappingVersion = mappingsVersion
minecraft {
mappingChannel = mappingsChannel
mappingVersion = mappingsVersion

runs {
config("client")
config("server")
runs {
config("client", project)
config("server", project)

// config("data") {
// args("--mod", modId, "--all", "--output", file("src/generated/resources/"))
// }
}
}
}

/*======================================================================================================== Setup ==== */
project.group = modGroup
project.version = "$minecraftVersion-$modVersion"
/* =================================================================================================== Setup ==== */

/* Java 8 Target + Parameter Names */
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.compilerArgs.add("-parameters")
}
tasks.whenTaskAdded {
if (name.startsWith("prepare")) {
dependsOn(":common:jar")
}
}

/* Finalize the jar by Reobf */
tasks.named<Jar>("jar") {
finalizedBy("reobfJar")
}
/* Finalize the jar by Reobf */
tasks.named<Jar>("jar") {
finalizedBy("reobfJar")
}

/* Manifest */
tasks.withType<Jar> {
manifest {
attributes(
"Specification-Title" to modId,
"Specification-Vendor" to vendor,
"Specification-Version" to modVersion,
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to vendor,
"Implementation-Timestamp" to Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
)
/* Manifest */
tasks.withType<Jar> {
manifest {
attributes(
"Specification-Title" to modId,
"Specification-Vendor" to vendor,
"Specification-Version" to modVersion,
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to vendor,
"Implementation-Timestamp" to Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
)
}
}
}

/* Generate Package Infos */
apply(from = "utils.gradle.kts")
/* ====================================================================================================== Fabric ==== */
project(":fabric") {
/* ================================================================================================= Plugins ==== */

apply(plugin = "fabric-loom")

/* =============================================================================================== Minecraft ==== */

dependencies {
/* Via https://modmuss50.me/fabric.html */
"minecraft"("com.mojang:minecraft:1.16.3") //group = "com.mojang", name = "minecraft", version = "1.16.4")
"mappings"(group = "net.fabricmc", name = "yarn", version = "$minecraftVersion+build.$yarnBuild", classifier = "v2")

"modImplementation"(group = "net.fabricmc", name = "fabric-loader", version = fabricLoaderVersion)
"modImplementation"(group = "net.fabricmc.fabric-api", name = "fabric-api", version = fabricApiVersion)
}

/* ======================================================================================= Include Resources ==== */

//TODO: FIX + REMOVE HACK
if (gradle.startParameter.taskNames.filter { it.startsWith("run") }.any()) {
println("Detected Fabric Run + Adding Resources")
val sourceSet = project.the<JavaPluginConvention>().sourceSets["main"]
val commonSourceSet = project(":common").the<JavaPluginConvention>().sourceSets["main"]
sourceSet.resources.srcDirs(commonSourceSet.resources.srcDirs)
}

/* =================================================================================================== Setup ==== */

/* Finalize the jar by Reobf */
tasks.named<Jar>("jar") {
finalizedBy("remapJar")
}

/*================================================================================================= Dependencies ==== */
/* Expand version in fabric.mod.json */
tasks.getByName<ProcessResources>("processResources") {
inputs.property("version", project.version)

dependencies {
/* JUnit 5 */
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter", version = junitVersion)
val sourceSet = project.the<JavaPluginConvention>().sourceSets["main"]

from(sourceSet.resources.srcDirs) {
include("fabric.mod.json")
expand("version" to project.version)
}

from(sourceSet.resources.srcDirs) {
exclude("fabric.mod.json")
}
}

/* Jetbrains Annotations */
implementation(group = "org.jetbrains", name = "annotations", version = jetbrainsAnnotationVersion)
}

/*==================================================================================================== Utilities ==== */
apply(from = "$rootDir/merge.gradle.kts")

/* =================================================================================================== Utilities ==== */

typealias Date = java.util.Date
typealias SimpleDateFormat = java.text.SimpleDateFormat
Expand All @@ -121,21 +219,21 @@ typealias UserDevExtension = net.minecraftforge.gradle.userdev.UserDevExtension

typealias RunConfiguration = RunConfig.() -> Unit

fun minecraft(configuration: UserDevExtension.() -> Unit) =
configuration(extensions.getByName("minecraft") as UserDevExtension)
fun Project.minecraft(configuration: UserDevExtension.() -> Unit) =
configuration(this.extensions.getByName("minecraft") as UserDevExtension)

fun NamedDomainObjectContainerScope<RunConfig>.config(name: String, additionalConfiguration: RunConfiguration = {}) {
fun NamedDomainObjectContainerScope<RunConfig>.config(name: String, project: Project, additionalConfiguration: RunConfiguration = {}) {
val runDirectory = project.file("run")
val sourceSet = the<JavaPluginConvention>().sourceSets["main"]
val sourceSet = project.the<JavaPluginConvention>().sourceSets["main"]
val commonSourceSet = project(":common").the<JavaPluginConvention>().sourceSets["main"]

create(name) {
workingDirectory(runDirectory)
property("forge.logging.markers", markers)
property("forge.logging.console.level", level)
environment("MOD_VERSION", modVersion)

additionalConfiguration(this)

mods { create(modId) { source(sourceSet) } }
mods { create(modId) { sources(sourceSet, commonSourceSet) } }
}
}
15 changes: 15 additions & 0 deletions common/src/main/java/com/unascribed/blockrenderer/Reference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.unascribed.blockrenderer;

import com.unascribed.blockrenderer.varia.VersionUtilities;

import java.util.Objects;

public interface Reference {

String ID = "block_renderer";
String NAME = "BlockRenderer";
String VERSION = VersionUtilities.getSpecificationVersion(Reference.class).orElse("DEVELOPMENT");

boolean DEVELOPMENT = Objects.equals(VERSION, "DEVELOPMENT");

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.unascribed.blockrenderer.client.render;
package com.unascribed.blockrenderer.render;

import com.unascribed.blockrenderer.client.render.request.lambda.ImageHandler;
import com.unascribed.blockrenderer.render.request.lambda.ImageHandler;

public interface IAnimatedRenderer<S, T> extends IRenderer<S, T> {

@Override
default void render(T instance, ImageHandler<T> consumer) {
render(instance, consumer, 0L);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.unascribed.blockrenderer.client.render;
package com.unascribed.blockrenderer.render;

import com.unascribed.blockrenderer.client.render.request.lambda.ImageHandler;
import com.unascribed.blockrenderer.render.request.lambda.ImageHandler;

public interface IRenderer<S, T> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.unascribed.blockrenderer.client.render;
package com.unascribed.blockrenderer.render;

public interface IRequest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.unascribed.blockrenderer.client.render.request.lambda;
package com.unascribed.blockrenderer.render.request.lambda;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@NonnullDefault
package com.unascribed.blockrenderer.render.request.lambda;

import org.lwjgl.system.NonnullDefault;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.unascribed.blockrenderer.client.varia;
package com.unascribed.blockrenderer.varia;

import com.unascribed.blockrenderer.client.varia.logging.Log;
import com.unascribed.blockrenderer.client.varia.logging.Markers;
import com.unascribed.blockrenderer.varia.logging.Log;
import com.unascribed.blockrenderer.varia.logging.Markers;
import org.jetbrains.annotations.Nullable;

import javax.imageio.ImageIO;
Expand All @@ -13,10 +13,9 @@ public interface Files {

File DEFAULT_FOLDER = new File("renders");

@SuppressWarnings("UnstableApiUsage")
static File getFile(File folder, String filename, String type) throws IOException {
File file = new File(folder, filename + "." + type);
com.google.common.io.Files.createParentDirs(file);
createParentDirs(file);

for (int i = 1; file.exists(); i++)
file = new File(folder, filename + "_" + i + "." + type);
Expand Down Expand Up @@ -48,6 +47,14 @@ static <T> T wrap(String message, IOSupplier<T> supplier) {
return null;
}

static void createParentDirs(File file) throws IOException {
File parent = file.getCanonicalFile().getParentFile();
if (parent == null) return;
//noinspection ResultOfMethodCallIgnored
parent.mkdirs();
if (!parent.isDirectory()) throw new IOException("Unable to create parent directories of " + file);
}

@FunctionalInterface
interface IOSupplier<T> {
T get() throws IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.unascribed.blockrenderer.client.varia;
package com.unascribed.blockrenderer.varia;

import com.unascribed.blockrenderer.client.varia.rendering.TileRenderer;
import com.unascribed.blockrenderer.varia.rendering.TileRenderer;

import java.awt.*;
import java.awt.geom.AffineTransform;
Expand Down
Loading

0 comments on commit 4d91b13

Please sign in to comment.