Compare commits

...
5 Commits
Author SHA1 Message Date
Martin Robertz 089d2fc3c2 Merge pull request #29 from GTNewHorizons/fix/magnet_npe_and_updates
Fix/magnet npe and updates
2023-07-30 17:43:57 +02:00
Firenoo 7a907225d6 Update dependencies 2023-07-30 08:25:27 -07:00
Firenoo bcd6fbbdf5 Update buildscript 2023-07-30 08:23:44 -07:00
Firenoo 9188911cce WCTGuiHandler: clean up some old code w/ Java 17 syntax 2023-07-30 08:23:38 -07:00
Firenoo 44d039a517 Fix NPE when magnet card is used w/o WCT in inventory 2023-07-30 08:22:54 -07:00
6 changed files with 210 additions and 135 deletions

No files matched your search

+144 -63
View File
@@ -1,4 +1,4 @@
//version: 1684218858 //version: 1690657483
/* /*
DO NOT CHANGE THIS FILE! DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available. Also, you may replace this file at any time if there is an update available.
@@ -69,7 +69,7 @@ plugins {
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
id 'com.modrinth.minotaur' version '2.+' apply false id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.14' id 'com.gtnewhorizons.retrofuturagradle' version '1.3.21'
} }
print("You might want to check out './gradlew :faq' if your build fails.\n") print("You might want to check out './gradlew :faq' if your build fails.\n")
@@ -115,6 +115,8 @@ propertyDefaultIfUnset("usesMixinDebug", project.usesMixins)
propertyDefaultIfUnset("forceEnableMixins", false) propertyDefaultIfUnset("forceEnableMixins", false)
propertyDefaultIfUnset("channel", "stable") propertyDefaultIfUnset("channel", "stable")
propertyDefaultIfUnset("mappingsVersion", "12") propertyDefaultIfUnset("mappingsVersion", "12")
propertyDefaultIfUnset("usesMavenPublishing", true)
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
propertyDefaultIfUnset("modrinthProjectId", "") propertyDefaultIfUnset("modrinthProjectId", "")
propertyDefaultIfUnset("modrinthRelations", "") propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "") propertyDefaultIfUnset("curseForgeProjectId", "")
@@ -357,7 +359,27 @@ catch (Exception ignored) {
String identifiedVersion String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null String versionOverride = System.getenv("VERSION") ?: null
try { try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride // Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty
if (versionOverride == null) {
def gitDetails = versionDetails()
def isDirty = gitVersion().endsWith(".dirty") // No public API for this, isCleanTag has a different meaning
String branchName = gitDetails.branchName ?: (System.getenv('GIT_BRANCH') ?: 'git')
if (branchName.startsWith('origin/')) {
branchName = branchName.minus('origin/')
}
branchName = branchName.replaceAll("[^a-zA-Z0-9-]+", "-") // sanitize branch names for semver
identifiedVersion = gitDetails.lastTag ?: '${gitDetails.gitHash}'
if (gitDetails.commitDistance > 0) {
identifiedVersion += "-${branchName}.${gitDetails.commitDistance}+${gitDetails.gitHash}"
if (isDirty) {
identifiedVersion += "-dirty"
}
} else if (isDirty) {
identifiedVersion += "-${branchName}+${gitDetails.gitHash}-dirty"
}
} else {
identifiedVersion = versionOverride
}
} }
catch (Exception ignored) { catch (Exception ignored) {
out.style(Style.Failure).text( out.style(Style.Failure).text(
@@ -379,9 +401,13 @@ if (identifiedVersion == versionOverride) {
group = "com.github.GTNewHorizons" group = "com.github.GTNewHorizons"
if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) { if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName base {
archivesName = customArchiveBaseName
}
} else { } else {
archivesBaseName = modId base {
archivesName = modId
}
} }
@@ -465,10 +491,19 @@ sourceSets {
} }
} }
if (file('addon.gradle').exists()) { if (file('addon.gradle.kts').exists()) {
apply from: 'addon.gradle.kts'
} else if (file('addon.gradle').exists()) {
apply from: 'addon.gradle' apply from: 'addon.gradle'
} }
// File for local tweaks not commited to Git
if (file('addon.local.gradle.kts').exists()) {
apply from: 'addon.local.gradle.kts'
} else if (file('addon.local.gradle').exists()) {
apply from: 'addon.local.gradle'
}
// Allow unsafe repos but warn // Allow unsafe repos but warn
repositories.configureEach { repo -> repositories.configureEach { repo ->
if (repo instanceof org.gradle.api.artifacts.repositories.UrlArtifactRepository) { if (repo instanceof org.gradle.api.artifacts.repositories.UrlArtifactRepository) {
@@ -479,7 +514,14 @@ repositories.configureEach { repo ->
} }
} }
apply from: 'repositories.gradle' if (file('repositories.gradle.kts').exists()) {
apply from: 'repositories.gradle.kts'
} else if (file('repositories.gradle').exists()) {
apply from: 'repositories.gradle'
} else {
logger.error("Neither repositories.gradle.kts nor repositories.gradle was found, make sure you extracted the full ExampleMod template.")
throw new RuntimeException("Missing repositories.gradle[.kts]")
}
configurations { configurations {
runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable) runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
@@ -537,13 +579,28 @@ repositories {
} }
} }
if (includeWellKnownRepositories.toBoolean()) { if (includeWellKnownRepositories.toBoolean()) {
maven { exclusiveContent {
name "CurseMaven" forRepository {
url "https://cursemaven.com" maven {
content { name "CurseMaven"
url "https://cursemaven.com"
}
}
filter {
includeGroup "curse.maven" includeGroup "curse.maven"
} }
} }
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
maven { maven {
name = "ic2" name = "ic2"
url = "https://maven.ic2.player.to/" url = "https://maven.ic2.player.to/"
@@ -585,7 +642,7 @@ dependencies {
} }
} }
if (usesMixins.toBoolean()) { if (usesMixins.toBoolean()) {
implementation(mixinProviderSpec) implementation(modUtils.enableMixins(mixinProviderSpec))
} else if (forceEnableMixins.toBoolean()) { } else if (forceEnableMixins.toBoolean()) {
runtimeOnlyNonPublishable(mixinProviderSpec) runtimeOnlyNonPublishable(mixinProviderSpec)
} }
@@ -611,12 +668,34 @@ configurations.all {
} }
} }
apply from: 'dependencies.gradle' dependencies {
constraints {
def minGtnhLibVersion = "0.0.13"
implementation("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
}
runtimeOnly("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
}
devOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
}
runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
}
}
}
if (file('dependencies.gradle.kts').exists()) {
apply from: 'dependencies.gradle.kts'
} else if (file('dependencies.gradle').exists()) {
apply from: 'dependencies.gradle'
} else {
logger.error("Neither dependencies.gradle.kts nor dependencies.gradle was found, make sure you extracted the full ExampleMod template.")
throw new RuntimeException("Missing dependencies.gradle[.kts]")
}
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json' def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
def mixinTmpDir = buildDir.path + File.separator + 'tmp' + File.separator + 'mixins'
def refMap = "${mixinTmpDir}" + File.separator + mixingConfigRefMap
def mixinSrg = "${mixinTmpDir}" + File.separator + "mixins.srg"
tasks.register('generateAssets') { tasks.register('generateAssets') {
group = "GTNH Buildscript" group = "GTNH Buildscript"
@@ -648,46 +727,17 @@ tasks.register('generateAssets') {
} }
if (usesMixins.toBoolean()) { if (usesMixins.toBoolean()) {
tasks.named("reobfJar", ReobfuscatedJar).configure {
extraSrgFiles.from(mixinSrg)
}
tasks.named("processResources").configure { tasks.named("processResources").configure {
dependsOn("generateAssets") dependsOn("generateAssets")
} }
tasks.named("compileJava", JavaCompile).configure { tasks.named("compileJava", JavaCompile).configure {
doFirst {
new File(mixinTmpDir).mkdirs()
}
options.compilerArgs += [ options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
"-XDenableSunApiLintControl", "-XDenableSunApiLintControl",
"-XDignore.symbol.file" "-XDignore.symbol.file"
] ]
} }
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
kapt {
correctErrorTypes = true
javacOptions {
option("-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}")
option("-AoutSrgFile=$mixinSrg")
option("-AoutRefMapFile=$refMap")
}
}
tasks.configureEach { task ->
if (task.name == "kaptKotlin") {
task.doFirst {
new File(mixinTmpDir).mkdirs()
}
}
}
}
} }
tasks.named("processResources", ProcessResources).configure { tasks.named("processResources", ProcessResources).configure {
@@ -705,7 +755,6 @@ tasks.named("processResources", ProcessResources).configure {
} }
if (usesMixins.toBoolean()) { if (usesMixins.toBoolean()) {
from refMap
dependsOn("compileJava", "compileScala") dependsOn("compileJava", "compileScala")
} }
} }
@@ -724,16 +773,16 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
} }
dependencies { dependencies {
def lwjgl3ifyVersion = '1.3.5' def lwjgl3ifyVersion = '1.4.0'
def asmVersion = '9.4' def asmVersion = '9.4'
if (modId != 'lwjgl3ify') { if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}") java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
} }
if (modId != 'hodgepodge') { if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.13') java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.19')
} }
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false} java17PatchDependencies('net.minecraft:launchwrapper:1.17.1') {transitive = false}
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}") java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}") java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}") java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
@@ -979,6 +1028,9 @@ idea {
} }
} }
runConfigurations { runConfigurations {
"0. Build and Test"(Gradle) {
taskNames = ["build"]
}
"1. Run Client"(Gradle) { "1. Run Client"(Gradle) {
taskNames = ["runClient"] taskNames = ["runClient"]
} }
@@ -1098,6 +1150,11 @@ tasks.named("processIdeaSettings").configure {
dependsOn("injectTags") dependsOn("injectTags")
} }
tasks.named("ideVirtualMainClasses").configure {
// Make IntelliJ "Build project" build the mod jars
dependsOn("jar", "reobfJar", "spotlessCheck")
}
// workaround variable hiding in pom processing // workaround variable hiding in pom processing
def projectConfigs = project.configurations def projectConfigs = project.configurations
@@ -1118,12 +1175,14 @@ publishing {
} }
repositories { repositories {
maven { if (usesMavenPublishing.toBoolean()) {
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases" maven {
allowInsecureProtocol = true url = mavenPublishUrl
credentials { allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
username = System.getenv("MAVEN_USER") ?: "NONE" credentials {
password = System.getenv("MAVEN_PASSWORD") ?: "NONE" username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
} }
} }
} }
@@ -1238,7 +1297,7 @@ def addCurseForgeRelation(String type, String name) {
// Updating // Updating
def buildscriptGradleVersion = "8.1.1" def buildscriptGradleVersion = "8.2.1"
tasks.named('wrapper', Wrapper).configure { tasks.named('wrapper', Wrapper).configure {
gradleVersion = buildscriptGradleVersion gradleVersion = buildscriptGradleVersion
@@ -1276,12 +1335,14 @@ tasks.register('faq') {
description = 'Prints frequently asked questions about building a project' description = 'Prints frequently asked questions about building a project'
doLast { doLast {
print("If your build fails to fetch dependencies, they might have been deleted and replaced by newer " + print("If your build fails to fetch dependencies, run './gradlew updateDependencies'. " +
"versions.\nCheck if the versions you try to fetch are still on the distributing sites.\n" + "Or you can manually check if the versions are still on the distributing sites - " +
"The links can be found in repositories.gradle and build.gradle:repositories, " + "the links can be found in repositories.gradle and build.gradle:repositories, " +
"not build.gradle:buildscript.repositories - this one is for gradle plugin metadata.\n\n" + "but not build.gradle:buildscript.repositories - those ones are for gradle plugin metadata.\n\n" +
"If your build fails to recognize the syntax of new Java versions, enable Jabel in your " + "If your build fails to recognize the syntax of new Java versions, enable Jabel in your " +
"gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties.") "gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties. " +
"However, keep in mind that Jabel enables only syntax features, but not APIs that were introduced in " +
"Java 9 or later.")
} }
} }
@@ -1342,8 +1403,14 @@ boolean isNewBuildScriptVersionAvailable() {
String currentBuildScript = getFile("build.gradle").getText() String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript) String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText() String availableBuildScriptHash
String availableBuildScriptHash = getVersionHash(availableBuildScript) try {
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
availableBuildScriptHash = getVersionHash(availableBuildScript)
} catch (IOException e) {
logger.warn("Could not check for buildscript update availability: {}", e.message)
return false
}
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate return !isUpToDate
@@ -1508,3 +1575,17 @@ def getSecondaryArtifacts() {
if (apiPackage) secondaryArtifacts += [apiJar] if (apiPackage) secondaryArtifacts += [apiJar]
return secondaryArtifacts return secondaryArtifacts
} }
// For easier scripting of things that require variables defined earlier in the buildscript
if (file('addon.late.gradle.kts').exists()) {
apply from: 'addon.late.gradle.kts'
} else if (file('addon.late.gradle').exists()) {
apply from: 'addon.late.gradle'
}
// File for local tweaks not commited to Git
if (file('addon.late.local.gradle.kts').exists()) {
apply from: 'addon.late.local.gradle.kts'
} else if (file('addon.late.local.gradle').exists()) {
apply from: 'addon.late.local.gradle'
}
+5 -5
View File
@@ -1,10 +1,10 @@
// Add your dependencies here // Add your dependencies here
dependencies { dependencies {
api("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-216-GTNH:dev") implementation("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-243-GTNH:dev")
api("com.github.GTNewHorizons:Baubles:1.0.1.14:dev") implementation("com.github.GTNewHorizons:Baubles:1.0.1.16:dev")
api("curse.maven:cofh-core-69162:2388751") implementation("curse.maven:cofh-core-69162:2388751")
api("com.github.GTNewHorizons:NotEnoughItems:2.3.51-GTNH:dev") implementation("com.github.GTNewHorizons:NotEnoughItems:2.3.79-GTNH:dev")
compileOnly("com.github.GTNewHorizons:MouseTweaks:2.4.8-GTNH:dev") { transitive = false } compileOnly("com.github.GTNewHorizons:MouseTweaks:2.4.8-GTNH:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:EnderIO:2.4.17:dev") { transitive = false } compileOnly("com.github.GTNewHorizons:EnderIO:2.4.24:dev") { transitive = false }
} }
+4
View File
@@ -21,6 +21,10 @@ forgeVersion = 10.13.4.1614
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty # Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer developmentEnvironmentUserName = Developer
# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true
# Define a source file of your project with: # Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION"; # public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's # The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
@@ -30,70 +30,61 @@ public class WCTGuiHandler implements IGuiHandler {
@Override @Override
public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) { public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless()
.getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory));
if (wh != null) {
final WirelessTerminalGuiObject obj = new WirelessTerminalGuiObject(
wh,
RandomUtils.getWirelessTerm(player.inventory),
player,
world,
x,
y,
z);
if (obj != null) {
final IPortableCell terminal = obj;
if (guiId == Reference.GUI_WCT) {
return updateGui(
new ContainerWirelessCraftingTerminal(player, player.inventory),
world,
x,
y,
z,
ForgeDirection.UNKNOWN,
obj);
}
if (guiId == Reference.GUI_CRAFTING_STATUS) {
return updateGui(
new ContainerCraftingStatus(player.inventory, terminal),
world,
x,
y,
z,
ForgeDirection.UNKNOWN,
obj);
}
if (guiId == Reference.GUI_CRAFT_AMOUNT) {
return updateGui(
new ContainerCraftAmount(player, terminal),
world,
x,
y,
z,
ForgeDirection.UNKNOWN,
obj);
}
if (guiId == Reference.GUI_CRAFT_CONFIRM) {
return updateGui(
new ContainerCraftConfirm(player, terminal),
world,
x,
y,
z,
ForgeDirection.UNKNOWN,
obj);
}
}
}
if (guiId == Reference.GUI_MAGNET) { if (guiId == Reference.GUI_MAGNET) {
return new ContainerMagnet(player, player.inventory); return new ContainerMagnet(player, player.inventory);
} }
return null; final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless()
.getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory));
if (wh == null) {
return null;
}
final WirelessTerminalGuiObject term = new WirelessTerminalGuiObject(
wh,
RandomUtils.getWirelessTerm(player.inventory),
player,
world,
x,
y,
z);
return switch (guiId) {
case Reference.GUI_WCT -> updateGui(
new ContainerWirelessCraftingTerminal(player, player.inventory),
world,
x,
y,
z,
ForgeDirection.UNKNOWN,
term);
case Reference.GUI_CRAFTING_STATUS -> updateGui(
new ContainerCraftingStatus(player.inventory, term),
world,
x,
y,
z,
ForgeDirection.UNKNOWN,
term);
case Reference.GUI_CRAFT_AMOUNT -> updateGui(
new ContainerCraftAmount(player, term),
world,
x,
y,
z,
ForgeDirection.UNKNOWN,
term);
case Reference.GUI_CRAFT_CONFIRM -> updateGui(
new ContainerCraftConfirm(player, term),
world,
x,
y,
z,
ForgeDirection.UNKNOWN,
term);
default -> null;
};
} }
@Override @Override
@@ -219,7 +219,7 @@ public class ItemWirelessCraftingTerminal extends AERootPoweredItem
@Override @Override
public boolean canHandle(final ItemStack is) { public boolean canHandle(final ItemStack is) {
return is.getItem() instanceof IWirelessCraftingTerminalItem; return is != null && is.getItem() instanceof IWirelessCraftingTerminalItem;
} }
@Override @Override
@@ -22,10 +22,9 @@ public class Reference {
public static boolean WCT_HASCHECKEDVERSION = false; public static boolean WCT_HASCHECKEDVERSION = false;
// Gui IDs // Gui IDs
private static int ae2wctGuiIndex = 0; public static final int GUI_WCT = 0;
public static final int GUI_WCT = ++ae2wctGuiIndex; public static final int GUI_CRAFTING_STATUS = 1;
public static final int GUI_CRAFTING_STATUS = ++ae2wctGuiIndex; public static final int GUI_CRAFT_AMOUNT = 2;
public static final int GUI_CRAFT_AMOUNT = ++ae2wctGuiIndex; public static final int GUI_CRAFT_CONFIRM = 3;
public static final int GUI_CRAFT_CONFIRM = ++ae2wctGuiIndex; public static final int GUI_MAGNET = 4;
public static final int GUI_MAGNET = ++ae2wctGuiIndex;
} }