mirror of
https://github.com/Lucaslah/No-Report-Button.git
synced 2026-01-12 08:57:52 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1fa8e47900 | |||
| bb3254389c | |||
| de212d0b6d | |||
|
|
299018c61b | ||
| eb45d0ff38 | |||
|
|
60e92a2488 | ||
| 5d8a53af6b | |||
|
|
f3ada3a332 | ||
|
|
fb50dfd833 | ||
|
|
ab4d22a186 |
@@ -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"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
28
src/main/java/me/lucaslah/ncrb/OpenToLanButton.java
Normal file
28
src/main/java/me/lucaslah/ncrb/OpenToLanButton.java
Normal 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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"GameMenuScreenMixin",
|
||||
"ScreenMixin"
|
||||
"GameMenuScreenMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user