Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nimueller committed Jul 27, 2021
1 parent dab285a commit 768c21e
Show file tree
Hide file tree
Showing 42 changed files with 1,315 additions and 912 deletions.
139 changes: 38 additions & 101 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,134 +1,71 @@
import net.minecraftforge.gradle.common.util.MinecraftExtension
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter

val minecraftVersion: String by extra
val modVersion: String by extra
val forgeVersion: String by extra

buildscript {
repositories {
jcenter()
maven("https://files.minecraftforge.net/maven")
}
dependencies {
classpath("net.minecraftforge.gradle:ForgeGradle:3.+")
}
}

plugins {
java
`maven-publish`
id("net.minecraftforge.gradle")
}

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

val mainSourceSet: SourceSet = java.sourceSets.findByName("main")!!

fun DependencyHandlerScope.minecraft(): ExternalModuleDependency =
create(
group = "net.minecraftforge",
name = "forge",
version = "${minecraftVersion}-${forgeVersion}"
).apply { add("minecraft", this) }

group = "de.nekeras"
version = "${minecraftVersion}-${modVersion}"

java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}
version = "$minecraftVersion-$modVersion"

repositories {
mavenCentral()
}

dependencies {
minecraft()
minecraft(group = "net.minecraftforge", name = "forge", version = "$minecraftVersion-$forgeVersion")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

configure<MinecraftExtension> {
minecraft {
mappings("official", minecraftVersion)

runs {
"client" {
workingDirectory(project.file("run"))
val client by runs.creating {
workingDirectory(project.file("run"))

property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")

mods {
"borderless" {
source(mainSourceSet)
}
}
val borderless by mods.creating {
source(sourceSets.main.get())
}
}
}

tasks.withType<Jar> {
manifest {
attributes(
mapOf(
"Specification-Title" to project.name,
"Specification-Vendor" to "Nekeras",
"Specification-Version" to project.version,
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "Nekeras",
"Implementation-Timestamp" to DateTimeFormatter
.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ")
.withZone(ZoneId.systemDefault())
.format(Instant.now())
)
)
}
}

val forceModsTomlRefresh = tasks.register("forceModsTomlRefresh", Delete::class.java) {
delete(File(mainSourceSet.output.resourcesDir, "/META-INF/mods.toml"))
}.get()
val server by runs.creating {
workingDirectory(project.file("run"))

tasks.withType<ProcessResources> {
dependsOn(forceModsTomlRefresh)
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")

from(mainSourceSet.resources.srcDirs) {
include("META-INF/mods.toml")
expand(
mapOf(
"version" to project.version,
"forge_version_major" to forgeVersion.split(".")[0]
)
)
val borderless by mods.creating {
source(sourceSets.main.get())
}
}
}

tasks.withType<Javadoc> {
source(mainSourceSet.allJava)
tasks.processResources {
from(sourceSets.main.get().resources.srcDirs) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
include("META-INF/mods.toml")
expand("version" to project.version)
}
}

val sourcesJar = tasks.register("sourcesJar", Jar::class.java) {
classifier = "sources"
from(mainSourceSet.allJava)
}.get()

val javadocJar = tasks.register("javadocJar", Jar::class.java) {
classifier = "javadoc"
from(tasks.getByName("javadoc"))
}.get()

publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(sourcesJar)
artifact(javadocJar)
}
tasks.jar {
manifest {
attributes(
"Specification-Title" to project.name,
"Specification-Vendor" to "Nekeras",
"Specification-Version" to project.version,
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "Nekeras"
)
}
}

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
minecraftVersion=1.16.5
modVersion=1.1.1
modVersion=1.2.0
forgeVersion=36.0.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
2 changes: 0 additions & 2 deletions settings.gradle

This file was deleted.

14 changes: 14 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pluginManagement {
repositories {
maven("https://maven.minecraftforge.net")
}
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"net.minecraftforge.gradle" -> useModule("net.minecraftforge.gradle:ForgeGradle:5.1.+")
}
}
}
}

rootProject.name = "BorderlessWindow"
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package de.nekeras.borderless;

import de.nekeras.borderless.client.gui.ConfigScreen;
import de.nekeras.borderless.config.Config;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -16,52 +16,46 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.annotation.Nullable;
import javax.annotation.Nonnull;

/**
* The main Forge mod class.
*/
@Mod(Borderless.MOD_ID)
@Mod(BorderlessWindow.MOD_ID)
@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Bus.MOD)
public class Borderless {
public class BorderlessWindow {

/**
* The mod id of this Forge mod.
*/
public static final String MOD_ID = "borderless";
public static final String MOD_ID = "borderlesswindow";

private static final Logger log = LogManager.getLogger();

public Borderless() {
public BorderlessWindow() {
log.info("Creating mod instance");
ModLoadingContext context = ModLoadingContext.get();

// Client dist only, make sure server is always compatible with this mod
log.info("Enable server compatibility");
context.registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(
() -> FMLNetworkConstants.IGNORESERVERONLY,
(a, b) -> true));

// Register the config
log.info("Register client configuration");
context.registerConfig(ModConfig.Type.CLIENT, Config.CONFIG_SPEC);
}

@SuppressWarnings("deprecation")
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onClientSetup(@Nullable FMLClientSetupEvent event) {
public static void onClientSetup(@Nonnull FMLClientSetupEvent event) {
log.info("Initializing from client context");
ModLoadingContext context = ModLoadingContext.get();

// Config registration
context.registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY,
() -> (mc, modListScreen) -> new de.nekeras.borderless.config.gui.ConfigScreen(modListScreen));
log.info("Register client configuration screen");
context.registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () ->
(mc, modListScreen) -> new ConfigScreen(modListScreen));

log.info("Enqueue initialization work to main thread");
DeferredWorkQueue.runLater(FullscreenModeHolder::initMinecraft);
}

@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public void onConfigReload(ModConfig.Reloading event) {
de.nekeras.borderless.FullscreenModeHolder.setFullscreenMode(
de.nekeras.borderless.fullscreen.FullscreenMode.fromConfig());
event.enqueueWork(de.nekeras.borderless.client.FullscreenDisplayModeHolder::initMinecraft);
}
}
90 changes: 0 additions & 90 deletions src/main/java/de/nekeras/borderless/FullscreenModeHolder.java

This file was deleted.

Loading

0 comments on commit 768c21e

Please sign in to comment.