From 21b5a71358b50d53385471d8814e5a4d320f0e74 Mon Sep 17 00:00:00 2001 From: waffle-stomper <5958168+waffle-stomper@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:25:11 +1000 Subject: [PATCH] Update to 1.20.1, temporarily drop Lectern support --- build.gradle | 107 +++++++----------- gradle.properties | 14 +-- .../ghostwriter/Ghostwriter.java | 3 +- .../gui/screen/GhostwriterLecternScreen.java | 26 +++-- .../resources/META-INF/accesstransformer.cfg | 18 +-- srg_to_access_transformer.py | 43 ------- update.json | 4 + 7 files changed, 75 insertions(+), 140 deletions(-) delete mode 100644 srg_to_access_transformer.py diff --git a/build.gradle b/build.gradle index 3b1c441..3f7c72f 100644 --- a/build.gradle +++ b/build.gradle @@ -32,12 +32,9 @@ minecraft { // Simply re-run your setup task after changing the mappings to update your workspace. mappings channel: mapping_channel, version: mapping_version - // When true, this property will have all Eclipse run configurations run the "prepareX" task for the given run configuration before launching the game. + // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. // In most cases, it is not necessary to enable. // enableEclipsePrepareRuns = true - - // When true, this property will have all IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. - // In most cases, it is not necessary to enable. // enableIdeaPrepareRuns = true // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game. @@ -62,7 +59,8 @@ minecraft { // Default run configurations. // These can be tweaked, removed, or duplicated as needed. runs { - client { + // applies to all the run configs below + configureEach { workingDirectory project.file('run') // Recommended logging data for a userdev environment @@ -77,9 +75,6 @@ minecraft { // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - property 'forge.enabledGameTestNamespaces', mod_id - mods { "${mod_id}" { source sourceSets.main @@ -87,56 +82,29 @@ minecraft { } } - server { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - - property 'forge.logging.console.level', 'debug' - + client { + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id + } - mods { - "${mod_id}" { - source sourceSets.main - } - } + server { + property 'forge.enabledGameTestNamespaces', mod_id + args '--nogui' } // This run config launches GameTestServer and runs all registered gametests, then exits. // By default, the server will crash when no gametests are provided. // The gametest system is also enabled by default for other run configs under the /test command. gameTestServer { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - - property 'forge.logging.console.level', 'debug' - property 'forge.enabledGameTestNamespaces', mod_id - - mods { - "${mod_id}" { - source sourceSets.main - } - } } data { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - - property 'forge.logging.console.level', 'debug' + // example of overriding the workingDirectory set in configureEach above + workingDirectory project.file('run-data') // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - - mods { - "${mod_id}" { - source sourceSets.main - } - } } } } @@ -183,47 +151,48 @@ dependencies { // A missing property will result in an error. Properties are expanded using ${} Groovy notation. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html -def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta'] -def replaceProperties = [ - minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, - forge_version: forge_version, forge_version_range: forge_version_range, - loader_version_range: loader_version_range, - mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, - mod_authors: mod_authors, mod_description: mod_description -] -processResources { +tasks.named('processResources', ProcessResources).configure { + var replaceProperties = [ + minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, + forge_version: forge_version, forge_version_range: forge_version_range, + loader_version_range: loader_version_range, + mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, + mod_authors: mod_authors, mod_description: mod_description, + ] inputs.properties replaceProperties - replaceProperties.put 'project', project - filesMatching(resourceTargets) { - expand replaceProperties + filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { + expand replaceProperties + [project: project] } } // Example for how to get properties into the manifest for reading at runtime. -jar { +tasks.named('jar', Jar).configure { manifest { attributes([ - "Specification-Title" : mod_id, - "Specification-Vendor" : mod_authors, - "Specification-Version" : "1", // We are version 1 of ourselves - "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : mod_authors, - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + 'Specification-Title' : mod_id, + 'Specification-Vendor' : mod_authors, + 'Specification-Version' : '1', // We are version 1 of ourselves + 'Implementation-Title' : project.name, + 'Implementation-Version' : project.jar.archiveVersion, + 'Implementation-Vendor' : mod_authors, + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } + + // This is the preferred method to reobfuscate your jar file + finalizedBy 'reobfJar' } -// Example configuration to allow publishing using the maven-publish plugin -// This is the preferred method to reobfuscate your jar file -jar.finalizedBy('reobfJar') -// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing -// publish.dependsOn('reobfJar') +// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing: +// tasks.named('publish').configure { +// dependsOn 'reobfJar' +// } +// Example configuration to allow publishing using the maven-publish plugin publishing { publications { - mavenJava(MavenPublication) { + register('mavenJava', MavenPublication) { artifact jar } } diff --git a/gradle.properties b/gradle.properties index fe299ca..3bcbd25 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,17 +7,17 @@ org.gradle.daemon=false ## Environment Properties # The Minecraft version must agree with the Forge version to get a valid artifact -minecraft_version=1.20 +minecraft_version=1.20.1 # The Minecraft version range can use any release version of Minecraft as bounds. # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # as they do not follow standard versioning conventions. -minecraft_version_range=[1.20,1.21) +minecraft_version_range=[1.20.1,1.21) # The Forge version must agree with the Minecraft version to get a valid artifact -forge_version=46.0.14 +forge_version=47.1.0 # The Forge version range can use any version of Forge as bounds or match the loader version range -forge_version_range=[46,) +forge_version_range=[47,) # The loader version range can only use the major version of Forge/FML as bounds -loader_version_range=[46,) +loader_version_range=[47,) # The mapping channel to use for mappings. # The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. # Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. @@ -35,7 +35,7 @@ loader_version_range=[46,) mapping_channel=official # The mapping version to query from the mapping channel. # This must match the format required by the mapping channel. -mapping_version=1.20 +mapping_version=1.20.1 ## Mod Properties @@ -48,7 +48,7 @@ mod_name=Ghostwriter # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GNU GPL v3.0 # The mod version. See https://semver.org/ -mod_version=2.4.5 +mod_version=2.4.6 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/wafflestomper/ghostwriter/Ghostwriter.java b/src/main/java/wafflestomper/ghostwriter/Ghostwriter.java index ccec11f..d7b5b91 100644 --- a/src/main/java/wafflestomper/ghostwriter/Ghostwriter.java +++ b/src/main/java/wafflestomper/ghostwriter/Ghostwriter.java @@ -120,7 +120,8 @@ public void guiOpen(Opening event) { return; } else if (eventGui instanceof LecternScreen) { LOG.info("Aborting early GUI replacement (target is a lectern). Setting lectern swap flag"); - lecternArmed = true; + LOG.warn("Lectern support has temporarily been disabled until I have more time to debug it."); + //lecternArmed = true; return; } diff --git a/src/main/java/wafflestomper/ghostwriter/gui/screen/GhostwriterLecternScreen.java b/src/main/java/wafflestomper/ghostwriter/gui/screen/GhostwriterLecternScreen.java index 2edf693..964693b 100644 --- a/src/main/java/wafflestomper/ghostwriter/gui/screen/GhostwriterLecternScreen.java +++ b/src/main/java/wafflestomper/ghostwriter/gui/screen/GhostwriterLecternScreen.java @@ -10,6 +10,7 @@ import wafflestomper.ghostwriter.utilities.BookUtilities; import wafflestomper.ghostwriter.gui.GhostLayer; import wafflestomper.ghostwriter.gui.IGhostBook; +import wafflestomper.ghostwriter.utilities.Printer; import java.util.ArrayList; import java.util.List; @@ -18,6 +19,7 @@ public class GhostwriterLecternScreen extends LecternScreen implements IGhostBoo private final GhostLayer ghostLayer; private final LecternMenu lecternContainer; + private final Printer printer; public GhostwriterLecternScreen(ItemStack currStack, LecternMenu lecternContainer, Inventory playerInventory) { @@ -27,21 +29,26 @@ public GhostwriterLecternScreen(ItemStack currStack, LecternMenu lecternContaine this.ghostLayer = new GhostLayer(this, this, false); this.lecternContainer = lecternContainer; this.ghostLayer.extractTitleAuthor(currStack); + this.printer = new Printer(); + this.printer.gamePrint("WARNING! LECTERNS ARE NOT CURRENTLY SUPPORTED!!"); } - @Override // From ReadBookScreen - public void updateButtonVisibility() { + @Override // From LecternScreen + public void createMenuControls() { this.ghostLayer.updateButtons(); - } + } // TODO: Is this the correct override? @Override // From IGhostBook public List pagesAsList() { + ItemStack book = this.menu.getBook(); List pages = new ArrayList<>(); - for (int i = 0; i < this.getNumPages(); i++) { - pages.add(BookUtilities.deJSONify(this.bookAccess.getPage(i).getString())); - } + this.printer.gamePrint("WARNING! DEV VERSION - CAN'T GET PAGES!"); + // TODO: FIX AND ENABLE THIS BEFORE RELEASE +// for (int i = 0; i < this.lecternContainer.lecternData.getCount(); i++) { +// pages.add(BookUtilities.deJSONify(this.lecternContainer.lecternData.get(i).getString())); +// } return pages; } @@ -69,13 +76,18 @@ public int getBookPageCount() { @Override // From IGhostBook public void updateVanillaButtons() { + // TODO: This is causing a crash when opening a book because forwardButton is null on the lectern super.updateButtonVisibility(); } @Override // From IGhostBook public String getPageText(int pageNum) { - return this.bookAccess.getPage(pageNum).getString(); + + this.printer.gamePrint("WARNING! DEV VERSION - CAN'T GET PAGE TEXT!"); + // TODO: REMOVE THIS TEMPORARY WORKAROUND ONCE YOU FIGURE OUT HOW TO GET PAGES! + return ""; + //return this.lecternContainer.lecternData.get(pageNum).getString(); } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index c6c8d05..06e5938 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,17 +1,6 @@ # Don't forget to do a gradle refresh after updating this -# Signatures can be found in /build/createSrgToMcp/output.srg -# They'll need some massaging, but at least you don't have to write them from scratch - -# Regex find and replace for fields -# FD: (net.+)/(.+) .+/(.+) -# public $1 $2 # $3 -# Then swap all of the forward slashes for dots - -# Regex find and replace for methods -# MD: (net.+)/(.+) (.+) net.+/(.+) .+ -# public $1 $2$3 # $4 -# Then swap the forward slashes in the method path for dots but leave the slashes in the argument/return descriptions +# Signatures can be found in External Libraries > net.minecraft:mappings_official.zip: # TODO: Restrict these once the mod is working @@ -241,6 +230,7 @@ public net.minecraft.client.gui.screens.inventory.LecternScreen$1 m_142153_(Lnet public net.minecraft.client.gui.screens.inventory.LecternScreen$1 m_7934_(Lnet/minecraft/world/inventory/AbstractContainerMenu;ILnet/minecraft/world/item/ItemStack;)V # slotChanged() + public net.minecraft.client.gui.screens.Screen f_169365_ # lastNarratable public net.minecraft.client.gui.screens.Screen f_169366_ # EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE public net.minecraft.client.gui.screens.Screen f_169367_ # USAGE_NARRATION @@ -282,4 +272,6 @@ public net.minecraft.client.gui.components.AbstractWidget f_93621_ # y # public net.minecraft.client.gui.components.AbstractWidget f_93622_ # isHovered # public net.minecraft.client.gui.components.AbstractWidget f_93623_ # active # public net.minecraft.client.gui.components.AbstractWidget f_93624_ # visible -# public net.minecraft.client.gui.components.AbstractWidget f_93625_ # alpha \ No newline at end of file +# public net.minecraft.client.gui.components.AbstractWidget f_93625_ # alpha + +public net.minecraft.world.inventory.LecternMenu f_39820_ # lecternData \ No newline at end of file diff --git a/srg_to_access_transformer.py b/srg_to_access_transformer.py deleted file mode 100644 index d6437ee..0000000 --- a/srg_to_access_transformer.py +++ /dev/null @@ -1,43 +0,0 @@ -# Converts output.srg to accessTransformer format - -from typing import List -import re - -FIELD_PATTERN = re.compile("FD: (?P.+)/(?P.+) .+/(?P.+)") -METHOD_PATTERN = re.compile("MD: (?P.+)/(?P.+) (?P.+) .+/(?P.+) .+") - -def convert_line(line_in: str, level: str = "public", remove_final: bool = False) -> str: - line_in = line_in.strip() - if line_in.startswith("FD"): - # Field line - match = re.match(FIELD_PATTERN, line_in) - dot_path = match.group("slash_path").replace("/", ".") - srg_name = match.group("srg_name") - mcp_name = match.group("mcp_name") - return "{} {} {} # {}\n".format(level, dot_path, srg_name, mcp_name) - elif line_in.startswith("MD"): - match = re.match(METHOD_PATTERN, line_in) - dot_path = match.group("slash_path").replace("/", ".") - srg_name = match.group("srg_name") - descriptor = match.group("descriptor") - mcp_name = match.group("mcp_name") - disabler = "# " if "<" in srg_name else "" - final_mod = "-f" if remove_final else "" - return "{}{}{} {} {}{} # {}()\n".format(disabler, level, final_mod, dot_path, srg_name, descriptor, mcp_name) - else: - return "# {}\n".format(line_in) - - -if __name__ == "__main__": - output_lines: List[str] = list() - with open("build/createSrgToMcp/output.srg", "r") as f: - for i, line in enumerate(f.readlines()): - if (i+1)%1000 == 0: - print("Working on line {}".format(i+1)) - output_lines.append(convert_line(line)) - - print("Writing output...") - with open("access_transformer_lines.txt", "w") as f: - f.writelines(output_lines) - - print("Done") diff --git a/update.json b/update.json index f66add8..69887d2 100644 --- a/update.json +++ b/update.json @@ -1,6 +1,7 @@ { "homepage": "https://github.com/waffle-stomper/Ghostwriter/releases", "promos":{ + "1.20.1-recommended": "2.4.6", "1.20-recommended": "2.4.5", "1.19.4-recommended": "2.4.4", "1.19.3-recommended": "2.4.3", @@ -25,6 +26,9 @@ "1.11-recommended": "1.8.7", "1.10-recommended": "1.8.5" }, + "1.20.1": { + "2.4.6": "Update to 1.20.1. Lectern support temporarily disabled" + }, "1.20": { "2.4.5": "Update to 1.20" },