Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Architectury (2.0) #311

Open
wants to merge 8 commits into
base: 1.20.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# gradle

.gradle/
/build/
fabric/build
common/build
forge/build
out/
classes/

Expand Down Expand Up @@ -31,3 +33,5 @@ bin/
# fabric

run/

.architectury-transformer/
122 changes: 46 additions & 76 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.3-SNAPSHOT" apply false
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
architectury {
minecraft = rootProject.minecraft_version
}

project.ext.lwjglVersion = "3.3.2"
project.ext.jomlVersion = "1.10.4"
Expand All @@ -17,87 +15,59 @@ project.ext.linuxNatives = "natives-linux"
project.ext.macosNatives = "natives-macos"
project.ext.macosArmNatives = "natives-macos-arm64"

dependencies {
include(implementation("org.lwjgl:lwjgl-vulkan:$lwjglVersion"))

include(implementation("org.lwjgl:lwjgl-vma:$lwjglVersion"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$winNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$linuxNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$macosArmNatives"))
subprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "dev.architectury.loom"
apply plugin: "maven-publish"

include(implementation("org.lwjgl:lwjgl-shaderc:$lwjglVersion"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$winNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$linuxNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$macosArmNatives"))
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

//MoltenVK
include(runtimeOnly("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$macosArmNatives"))
}

repositories {
// 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.
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
java {
withSourcesJar()
}

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}
loom {
silentMojangMappingsLicense()
}

processResources {
inputs.property "version", project.version
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings loom.officialMojangMappings()

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}

loom {
accessWidenerPath = file("src/main/resources/vulkanmod.accesswidener")
}
allprojects {
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

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()
repositories {
maven { url 'https://jitpack.io' }
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
}
}

jar {
/*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.
}
}
}*/
42 changes: 42 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
architectury {
common(rootProject.enabled_platforms.split(","))
}

loom {
accessWidenerPath = file("src/main/resources/vulkanmod.accesswidener")
}

dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// Remove the next line if you don't want to depend on the API

include(implementation("org.lwjgl:lwjgl-vulkan:$lwjglVersion"))
include(implementation("org.lwjgl:lwjgl-vma:$lwjglVersion"))
// include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$winNatives"))
// include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$linuxNatives"))

include(implementation("org.lwjgl:lwjgl-shaderc:$lwjglVersion"))
// include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$winNatives"))
// include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$linuxNatives"))

//MacOS
include(runtimeOnly("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$macosArmNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$macosArmNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$macosArmNatives"))

include(compileOnly("com.google.code.findbugs:jsr305:3.0.2"))
}

publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
from components.java
}
}
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
package net.vulkanmod;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.vulkanmod.config.Config;
import net.vulkanmod.config.VideoResolution;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.nio.file.Path;

public class Initializer implements ClientModInitializer {
public class Initializer {
public static final Logger LOGGER = LogManager.getLogger("VulkanMod");

private static String VERSION;
public static Config CONFIG;

@Override
public void onInitializeClient() {

VERSION = FabricLoader.getInstance()
.getModContainer("vulkanmod")
.get()
.getMetadata()
.getVersion().getFriendlyString();

public static Config CONFIG = loadConfig(VulkanModExpectPlatform.getConfigDirectory().resolve("vulkanmod_settings.json"));
public static final String MODID = "vulkanmod";
public static void onInitializeClient() {
VERSION = VulkanModExpectPlatform.getVersion();
LOGGER.info("== VulkanMod ==");

VideoResolution.init();

var configPath = FabricLoader.getInstance()
.getConfigDir()
.resolve("vulkanmod_settings.json");

CONFIG = loadConfig(configPath);

}

private static Config loadConfig(Path path) {
Expand All @@ -48,4 +30,4 @@ private static Config loadConfig(Path path) {
public static String getVersion() {
return VERSION;
}
}
}
19 changes: 19 additions & 0 deletions common/src/main/java/net/vulkanmod/VulkanModExpectPlatform.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.vulkanmod;

import dev.architectury.injectables.annotations.ExpectPlatform;

import java.nio.file.Path;

public class VulkanModExpectPlatform {

@ExpectPlatform
public static Path getConfigDirectory() {
// Just throw an error, the content should get replaced at runtime.
throw new AssertionError();
}

@ExpectPlatform
public static String getVersion() {
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.mojang.blaze3d.platform.Window;
import net.minecraft.client.*;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.contents.LiteralContents;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.vulkanmod.Initializer;
import net.vulkanmod.vulkan.Drawer;
import net.vulkanmod.vulkan.Renderer;

public class Options {
Expand Down Expand Up @@ -51,9 +48,7 @@ public static Option<?>[] getVideoOpts() {
new SwitchOption("VSync",
value -> {
minecraftOptions.enableVsync().set(value);
if (Minecraft.getInstance().getWindow() != null) {
Minecraft.getInstance().getWindow().updateVsync(value);
}
Minecraft.getInstance().getWindow().updateVsync(value);
},
() -> minecraftOptions.enableVsync().get()),
new CyclingOption<>("Gui Scale",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.platform.VideoMode;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWVidMode;

Expand Down Expand Up @@ -51,7 +52,8 @@ public int[] refreshRates() {
}

public static void init() {
RenderSystem.assertOnRenderThread();

RenderSystem.assertOnRenderThreadOrInit();
GLFW.glfwInit();
videoResolutions = populateVideoResolutions(GLFW.glfwGetPrimaryMonitor());
}
Expand Down
Loading