Skip to content

Commit

Permalink
Update to 1.20.1, temporarily drop Lectern support
Browse files Browse the repository at this point in the history
  • Loading branch information
waffle-stomper committed Mar 27, 2024
1 parent 0b6dfb6 commit 21b5a71
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 140 deletions.
107 changes: 38 additions & 69 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -77,66 +75,36 @@ 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
}
}
}

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
}
}
}
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/wafflestomper/ghostwriter/Ghostwriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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<String> pagesAsList() {
ItemStack book = this.menu.getBook();
List<String> 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;
}

Expand Down Expand Up @@ -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();
}


Expand Down
18 changes: 5 additions & 13 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
# Don't forget to do a gradle refresh after updating this

# Signatures can be found in <project dir>/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:<version>


# TODO: Restrict these once the mod is working
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
# public net.minecraft.client.gui.components.AbstractWidget f_93625_ # alpha

public net.minecraft.world.inventory.LecternMenu f_39820_ # lecternData
43 changes: 0 additions & 43 deletions srg_to_access_transformer.py

This file was deleted.

4 changes: 4 additions & 0 deletions update.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
},
Expand Down

0 comments on commit 21b5a71

Please sign in to comment.