Skip to content

Commit

Permalink
Merge pull request #16 from TexBlock/arch/1.19.3
Browse files Browse the repository at this point in the history
[1.19.3]Port to Architectury
  • Loading branch information
KrLite authored Aug 31, 2023
2 parents 4e0dab8 + b4c0ee6 commit 224e185
Show file tree
Hide file tree
Showing 24 changed files with 420 additions and 180 deletions.
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

47 changes: 13 additions & 34 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
# gradle

.gradle/
build/
out/
classes/

# eclipse

*.launch

# idea

.idea/
*.iml
*.ipr
run/
*.iws

# vscode

.settings/
.vscode/
out/
*.iml
.gradle/
output/
bin/
libs/

.classpath
.project

# macos

*.DS_Store

# fabric

run/

# java

hs_err_*.log
replay_*.log
*.hprof
*.jfr
.idea/
classes/
.metadata
.vscode
.settings
*.launch
103 changes: 48 additions & 55 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,57 +1,50 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
}

archivesBaseName = "${project.archives_base_name}-${project.minecraft_version}"
version = project.mod_version
group = project.maven_group

repositories {
maven { url 'https://api.modrinth.com/maven' }
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

compileOnly "maven.modrinth:splasher:${project.minecraft_version}-${project.splasher_version}"
}

processResources {
inputs.property "version", project.version

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

tasks.withType(JavaCompile).configureEach {
it.options.release = Integer.parseInt(sourceCompatibility)
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}

repositories {
}
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false
}

architectury {
minecraft = rootProject.minecraft_version
}

subprojects {
apply plugin: "dev.architectury.loom"

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
}
}

allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

archivesBaseName = rootProject.archives_base_name
version = "${rootProject.minecraft_version}-${rootProject.mod_version}"
group = rootProject.maven_group

repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
}

java {
withSourcesJar()
}
}
24 changes: 24 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
architectury {
common(rootProject.enabled_platforms.split(","))
}

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}"
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
}

publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
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.
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package net.krlite.bounced;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.krlite.splasher.Splasher;
import dev.architectury.platform.Platform;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.TitleScreen;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.atomic.AtomicBoolean;

public class Bounced implements ModInitializer {
public class Bounced {
public static final String NAME = "Bounced!", ID = "bounced";
public static final Logger LOGGER = LoggerFactory.getLogger(ID);
private static double primaryPos, secondaryPos;
Expand All @@ -23,29 +18,7 @@ public class Bounced implements ModInitializer {
private static final AtomicBoolean
shouldAnimate = new AtomicBoolean(true),
shouldJump = new AtomicBoolean(false);

@Override
public void onInitialize() {
boolean isSplasherLoaded = FabricLoader.getInstance().isModLoaded("splasher");

ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
if (screen instanceof TitleScreen) {
ScreenMouseEvents.beforeMouseClick(screen)
.register((currentScreen, mouseX, mouseY, button) -> {
double centerX = scaledWidth / 2.0, y = 30, width = 310, height = 44;
if (!isIntro()
&& mouseX >= centerX - width / 2 && mouseX <= centerX + width / 2
&& mouseY >= y && mouseY <= y + height
) {
if (!isSplasherLoaded || !Splasher.isMouseHovering(scaledWidth, mouseX, mouseY)) {
// Linkage with Splasher
push();
}
}
});
}
});
}
public static final boolean isSplasherLoaded = Platform.isModLoaded("splasher");

public static void update() {
if (isIntro()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
* This class is responsible for triggering the title animation before the title screen is rendered.
Expand Down
File renamed without changes.
File renamed without changes
80 changes: 80 additions & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}

architectury {
platformSetupLoomIde()
fabric()
}

project.archivesBaseName = rootProject.archivesBaseName + "-fabric"

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"

compileOnly "maven.modrinth:splasher:${project.minecraft_version}-${project.splasher_version}"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
}

processResources {
inputs.property "version", project.version

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

shadowJar {
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
archiveClassifier.set("dev-shadow")
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set(null)
}

jar {
archiveClassifier.set("dev")
}

sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}

publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
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.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.krlite.bounced.fabric;

import dev.architectury.event.EventResult;
import dev.architectury.event.events.client.ClientGuiEvent;
import dev.architectury.event.events.client.ClientScreenInputEvent;
import net.fabricmc.api.ClientModInitializer;
import net.krlite.bounced.Bounced;
import net.krlite.splasher.Splasher;
import net.minecraft.client.gui.screen.TitleScreen;

public class BouncedClientFabric implements ClientModInitializer {
@Override
public void onInitializeClient() {
ClientGuiEvent.INIT_POST.register((screen, screenAccess) -> {
if (screen instanceof TitleScreen) {
ClientScreenInputEvent.MOUSE_CLICKED_POST.register((client, currentScreen, mouseX, mouseY, button) -> {
double scaledWidth = screenAccess.getScreen().width;
double centerX = scaledWidth / 2.0, y = 30, width = 310, height = 44;
if (!Bounced.isIntro()
&& mouseX >= centerX - width / 2 && mouseX <= centerX + width / 2
&& mouseY >= y && mouseY <= y + height
) {

if (!Bounced.isSplasherLoaded || !Splasher.isMouseHovering(scaledWidth, mouseX, mouseY)) {
// Linkage with Splasher
Bounced.push();
}

}
return EventResult.pass();
});
}
});
}
}
Loading

0 comments on commit 224e185

Please sign in to comment.