10 Commits

Author SHA1 Message Date
1fa8e47900 add note to readme 2022-12-10 12:17:01 -05:00
bb3254389c update to 1.19.3
note: this version only supports 1.19.3, not older versions.
2022-12-10 12:13:12 -05:00
de212d0b6d fix: report button could still be interacted with
- fixes #3
2022-10-07 13:36:18 -04:00
Lucas Petrino
299018c61b bump version to 1.2.0 2022-08-24 17:50:14 -04:00
eb45d0ff38 Merge pull request #2 from Lucaslah/version-2.0
fix: modmenu error
2022-08-24 17:47:24 -04:00
Lucas Petrino
60e92a2488 fix: modmenu error 2022-08-24 17:45:36 -04:00
5d8a53af6b fix: line break 2022-08-12 11:10:32 -04:00
lucaslah
f3ada3a332 fix: new line between links 2022-08-12 15:10:01 +00:00
lucaslah
fb50dfd833 docs: add modrinth link 2022-08-12 15:08:55 +00:00
lucaslah
ab4d22a186 chore: bump version to 1.1.0 2022-08-12 14:21:01 +00:00
10 changed files with 83 additions and 64 deletions

View File

@@ -26,7 +26,8 @@
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vscjava.vscode-java-pack"
"vscjava.vscode-java-pack",
"vscjava.vscode-gradle"
]
}
},

View File

@@ -1,8 +1,11 @@
# No Report Button
Removes the chat report button from the game menu screen
Supports fabric 1.19.1+, forge support is coming soon!\
Supports fabric 1.19.3+, forge support is coming soon!\
The fabric api is not required.
For minecraft versions 1.19.2 or older use NRB v1.2.1, the latest version only supports 1.19.3+.
## Links
Curseforge: https://www.curseforge.com/minecraft/mc-mods/no-report-button
Curseforge: https://www.curseforge.com/minecraft/mc-mods/no-report-button<br>
Modrinth: https://modrinth.com/mod/nrb

View File

@@ -35,6 +35,7 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
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}"
@@ -44,6 +45,7 @@ dependencies {
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
includeModImplementation fabricApi.module("fabric-api-base", project.fabric_version)
includeModImplementation fabricApi.module("fabric-screen-api-v1", project.fabric_version)
}
processResources {

View File

@@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.1
loader_version=0.14.8
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.1
loader_version=0.14.11
# Mod Properties
mod_version = 1.0.0
mod_version = 1.3.0
maven_group = me.lucaslah
archives_base_name = no-report-button
# Dependencies
fabric_version=0.58.6+1.19.2
fabric_version=0.68.1+1.19.3

View File

@@ -1,9 +0,0 @@
package me.lucaslah.ncrb;
import java.util.List;
import net.minecraft.client.gui.Drawable;
public interface IScreen {
public List<Drawable> getButtons();
}

View File

@@ -0,0 +1,28 @@
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,12 @@
package me.lucaslah.ncrb.mixin;
import me.lucaslah.ncrb.IScreen;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.*;
import net.minecraft.client.gui.widget.ButtonWidget;
import me.lucaslah.ncrb.OpenToLanButton;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
@@ -12,6 +14,9 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
import java.util.Objects;
@Mixin(GameMenuScreen.class)
public abstract class GameMenuScreenMixin extends Screen {
@@ -21,29 +26,41 @@ public abstract class GameMenuScreenMixin extends Screen {
@Inject(method = "initWidgets()V", at = @At(value = "RETURN"))
public void initWidgets(CallbackInfo ci) {
ClickableWidget reportButton = null;
final List<ClickableWidget> widgets = Screens.getButtons(this);
List<? extends Element> buttons = null;
for (ClickableWidget clickableWidget : widgets) {
if (clickableWidget instanceof GridWidget widget) {
List<? extends Element> children = widget.children();
if (children != null) {
buttons = children;
}
}
}
boolean reportButtonFound = false;
for (Drawable drawable : ((IScreen) this).getButtons()) {
if (!(drawable instanceof ClickableWidget)) continue;
ClickableWidget button = (ClickableWidget) drawable;
if (!button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) continue;
reportButton = button;
reportButtonFound = true;
break;
if (buttons != null) {
for (Element element : buttons) {
if (element instanceof ClickableWidget button) {
if (button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) {
button.visible = false;
button.active = false;
reportButtonFound = true;
}
}
}
}
if (reportButtonFound) {
reportButton.visible = false;
OpenToLanButton openToLanButton = new OpenToLanButton(this,this.width / 2 + 4, this.height / 4 + 96 + -16, 98, 20, Text.translatable("menu.shareToLan"));
ButtonWidget openToLanButton = this.addDrawableChild(new ButtonWidget(this.width / 2 + 4, this.height / 4 + 96 + -16, 98, 20, Text.translatable("menu.shareToLan"), (button) -> {
this.client.setScreen(new OpenToLanScreen(this));
}));
if (this.client != null) {
openToLanButton.active = this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote();
}
openToLanButton.active = this.client.isIntegratedServerRunning() && !this.client.getServer().isRemote();
widgets.add(openToLanButton);
}
}
}

View File

@@ -1,23 +0,0 @@
package me.lucaslah.ncrb.mixin;
import me.lucaslah.ncrb.IScreen;
import net.minecraft.client.gui.AbstractParentElement;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.List;
@Mixin(Screen.class)
public abstract class ScreenMixin extends AbstractParentElement implements Drawable, IScreen {
@Shadow
@Final
private List<Drawable> drawables;
@Override
public List<Drawable> getButtons() {
return drawables;
}
}

View File

@@ -28,7 +28,8 @@
"depends": {
"fabricloader": ">=0.14.6",
"minecraft": "~1.19",
"java": ">=17"
"minecraft": ">=1.19.3",
"java": ">=17",
"fabric-screen-api-v1": ">=1.0.4"
}
}

View File

@@ -6,8 +6,7 @@
"mixins": [
],
"client": [
"GameMenuScreenMixin",
"ScreenMixin"
"GameMenuScreenMixin"
],
"injectors": {
"defaultRequire": 1