Skip to content

Commit

Permalink
Switch to using aw
Browse files Browse the repository at this point in the history
Signed-off-by: shedaniel <[email protected]>
  • Loading branch information
shedaniel committed Jun 3, 2021
1 parent 7a5a0e2 commit a419178
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 77 deletions.
63 changes: 17 additions & 46 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'idea'
id 'maven-publish'
id 'dev.architectury.loom' version '0.8.0-SNAPSHOT' apply false
id 'net.minecrell.licenser' version '0.4.1'
id 'org.cadixdev.licenser' version '0.6.0'
id "org.ajoberstar.grgit" version "3.1.1"
id 'com.matthewprenger.cursegradle' version "1.4.0"
}
Expand Down Expand Up @@ -32,7 +32,7 @@ def getBranch() {
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'dev.architectury.loom'
apply plugin: 'net.minecrell.licenser'
apply plugin: 'org.cadixdev.licenser'

group = "me.shedaniel.cloth.api"

Expand Down Expand Up @@ -73,38 +73,29 @@ allprojects {
dev
}

jar {
classifier = "dev"
}

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release.set 16
}

afterEvaluate {
remapJar {
input = file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar")
archiveName = "${archivesBaseName}-${version}.jar"
}

artifacts {
dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: jar
}
artifacts {
dev file: jar.archiveFile.get().asFile, type: "jar", builtBy: jar
}

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

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

license {
header rootProject.file('HEADER')
include '**/*.java'
}
license {
header rootProject.file('HEADER')
include '**/*.java'
}

afterEvaluate {
if (shouldGenerateData) {
task generateData(type: RunClientTask, dependsOn: downloadAssets) {
classpath = configurations.runtimeClasspath
Expand All @@ -130,21 +121,11 @@ subprojects {
datagenImplementation sourceSets.main.output
}

task remapMavenJar(type: Copy, dependsOn: remapJar) {
afterEvaluate {
from("${project.buildDir}/libs/$archivesBaseName-${version}.jar")
into("${project.buildDir}/libs/")
rename { String fn -> "$archivesBaseName-${version}-maven.jar" }
}
}

publishing {
publications {
create("${archivesBaseName}_mavenJava", MavenPublication) {
afterEvaluate {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(remapJar)
artifact(sourcesJar) {
builtBy remapSourcesJar
}
Expand All @@ -166,20 +147,10 @@ subprojects {
}
}

task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) {
afterEvaluate {
input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
archiveName = "${archivesBaseName}-${version}-maven.jar"
addNestedDependencies = false
}
}

publishing {
publications {
mavenJava(MavenPublication) {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(remapJar)
artifact(sourcesJar) {
builtBy remapSourcesJar
}
Expand Down
6 changes: 5 additions & 1 deletion cloth-client-events-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
archivesBaseName = "cloth-client-events-v0"
archivesBaseName = "cloth-client-events-v0"

loom {
accessWidener = file("src/main/resources/cloth-client-events-v0.accesswidener")
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ public abstract class MixinScreen implements ScreenHooks {

@Shadow @Final private List<Drawable> drawables;

@Shadow
protected abstract <T extends Element & Drawable & Selectable> T addDrawableChild(T drawableElement);

@Shadow
protected abstract <T extends Drawable> T addDrawable(T drawable);

@Shadow
protected abstract <T extends Element & Selectable> T addSelectableChild(T child);

@Override
public List<Selectable> cloth$getSelectables() {
return selectables;
Expand All @@ -89,17 +80,17 @@ public abstract class MixinScreen implements ScreenHooks {

@Override
public <T extends Element & Drawable & Selectable> T cloth$addDrawableChild(T drawableElement) {
return addDrawableChild(drawableElement);
return ((Screen) (Object) this).addDrawableChild(drawableElement);
}

@Override
public <T extends Drawable> T cloth$addDrawable(T drawable) {
return addDrawable(drawable);
return ((Screen) (Object) this).addDrawable(drawable);
}

@Override
public <T extends Element & Selectable> T cloth$addSelectableChild(T child) {
return addSelectableChild(child);
return ((Screen) (Object) this).addSelectableChild(child);
}

@Inject(method = "render", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessWidener v1 named
accessible method net/minecraft/client/gui/screen/Screen addDrawable (Lnet/minecraft/client/gui/Drawable;)Lnet/minecraft/client/gui/Drawable;
accessible method net/minecraft/client/gui/screen/Screen addDrawableChild (Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;
accessible method net/minecraft/client/gui/screen/Screen addSelectableChild (Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;
1 change: 1 addition & 0 deletions cloth-client-events-v0/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"depends": {
"fabric-api-base": "*"
},
"accessWidener": "cloth-client-events-v0.accesswidener",
"custom": {
"modmenu": {
"parent": "cloth-api",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@
package me.shedaniel.cloth.impl.utils;

import com.google.common.collect.Lists;
import me.shedaniel.cloth.api.utils.v1.Executor;
import me.shedaniel.cloth.api.utils.v1.ScissorsStack;
import me.shedaniel.math.Rectangle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.Window;
import org.apache.logging.log4j.LogManager;
Expand All @@ -49,22 +47,6 @@ public final class ScissorsStackImpl implements ScissorsStack {
private final Rectangle empty = new Rectangle();
private static final Logger LOGGER = LogManager.getFormatterLogger("cloth-scissors-api-v1");

static {
Executor.runIf(() -> FabricLoader.getInstance().isModLoaded("notenoughcrashes"), () -> () -> {
try {
Class.forName("fudge.notenoughcrashes.api.NotEnoughCrashesApi").getDeclaredMethod("onEveryCrash", Runnable.class).invoke(null, (Runnable) () -> {
try {
ScissorsStack.INSTANCE.popAll().applyStack();
} catch (Throwable t) {
LOGGER.error("[ClothConfig] Failed to clear scissors on game crash!", t);
}
});
} catch (Throwable throwable) {
throwable.printStackTrace();
}
});
}

@Override
public ScissorsStack applyScissors(Rectangle rectangle) {
if (rectangle.isEmpty()) {
Expand Down

0 comments on commit a419178

Please sign in to comment.