fix: mod menu mods button offset

- fixes #5
- bump version to 1.3.1
- update button logic that replaces the report button to fix mod menu issue
- rename mixins.json to noreportbutton.mixins.json
- updated package from ncrb to nrb
- minor cleanup
This commit is contained in:
2023-01-04 09:34:56 -05:00
parent 64397c5497
commit 256ed10cfe
7 changed files with 13 additions and 90 deletions

View File

@@ -10,13 +10,7 @@ archivesBaseName = project.archives_base_name
version = project.mod_version version = project.mod_version
group = project.maven_group group = project.maven_group
repositories { repositories {}
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}
configurations { configurations {
includeModImplementation includeModImplementation
@@ -35,15 +29,6 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
includeModImplementation fabricApi.module("fabric-api-base", project.fabric_version) includeModImplementation fabricApi.module("fabric-api-base", project.fabric_version)
includeModImplementation fabricApi.module("fabric-screen-api-v1", project.fabric_version) includeModImplementation fabricApi.module("fabric-screen-api-v1", project.fabric_version)
} }
@@ -57,14 +42,10 @@ processResources {
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17 it.options.release = 17
} }
java { java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar() withSourcesJar()
} }
@@ -73,20 +54,3 @@ jar {
rename { "${it}_${project.archivesBaseName}"} rename { "${it}_${project.archivesBaseName}"}
} }
} }
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
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.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

View File

@@ -8,7 +8,7 @@ yarn_mappings=1.19.3+build.1
loader_version=0.14.11 loader_version=0.14.11
# Mod Properties # Mod Properties
mod_version = 1.3.0 mod_version = 1.3.1
maven_group = me.lucaslah maven_group = me.lucaslah
archives_base_name = no-report-button archives_base_name = no-report-button

View File

@@ -1,28 +0,0 @@
package me.lucaslah.ncrb;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.OpenToLanScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.PressableWidget;
import net.minecraft.text.Text;
public class OpenToLanButton extends PressableWidget {
private final Screen screen;
public OpenToLanButton(Screen screen, int i, int j, int k, int l, Text text) {
super(i, j, k, l, text);
this.screen = screen;
}
@Override
public void onPress() {
MinecraftClient client = MinecraftClient.getInstance();
assert client != null;
client.setScreen(new OpenToLanScreen(screen));
}
@Override
protected void appendClickableNarrations(NarrationMessageBuilder builder) {
}
}

View File

@@ -1,10 +1,8 @@
package me.lucaslah.ncrb; package me.lucaslah.nrb;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
public class NoReportButton implements ModInitializer { public class NoReportButton implements ModInitializer {
@Override @Override
public void onInitialize() { public void onInitialize() {}
// Do nothing
}
} }

View File

@@ -1,6 +1,5 @@
package me.lucaslah.ncrb.mixin; package me.lucaslah.nrb.mixin;
import me.lucaslah.ncrb.OpenToLanButton;
import net.fabricmc.fabric.api.client.screen.v1.Screens; import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.minecraft.client.gui.Element; import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.GameMenuScreen;
@@ -39,28 +38,18 @@ public abstract class GameMenuScreenMixin extends Screen {
} }
} }
boolean reportButtonFound = false;
if (buttons != null) { if (buttons != null) {
for (Element element : buttons) { for (Element element : buttons) {
if (element instanceof ClickableWidget button) { if (element instanceof ClickableWidget button) {
if (button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) { if (button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) {
button.visible = false; if (this.client != null) {
button.active = false; button.active = this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote();
reportButtonFound = true; }
button.setMessage(Text.translatable("menu.shareToLan"));
} }
} }
} }
} }
if (reportButtonFound) {
OpenToLanButton openToLanButton = new OpenToLanButton(this,this.width / 2 + 4, this.height / 4 + 96 + -16, 98, 20, Text.translatable("menu.shareToLan"));
if (this.client != null) {
openToLanButton.active = this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote();
}
widgets.add(openToLanButton);
}
} }
} }

View File

@@ -19,11 +19,11 @@
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"main": [ "main": [
"me.lucaslah.ncrb.NoReportButton" "me.lucaslah.nrb.NoReportButton"
] ]
}, },
"mixins": [ "mixins": [
"mixins.json" "noreportbutton.mixins.json"
], ],
"depends": { "depends": {

View File

@@ -1,7 +1,7 @@
{ {
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "me.lucaslah.ncrb.mixin", "package": "me.lucaslah.nrb.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"mixins": [ "mixins": [
], ],