mirror of
https://github.com/Lucaslah/No-Report-Button.git
synced 2026-01-02 19:47:51 +00:00
update to 1.19.3
note: this version only supports 1.19.3, not older versions.
This commit is contained in:
@@ -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.2.1
|
||||
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
|
||||
|
||||
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,11 +1,12 @@
|
||||
package me.lucaslah.ncrb.mixin;
|
||||
|
||||
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.OpenToLanScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
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;
|
||||
@@ -25,28 +26,41 @@ public abstract class GameMenuScreenMixin extends Screen {
|
||||
|
||||
@Inject(method = "initWidgets()V", at = @At(value = "RETURN"))
|
||||
public void initWidgets(CallbackInfo ci) {
|
||||
final List<ClickableWidget> buttons = Screens.getButtons(this);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClickableWidget reportButton = null;
|
||||
boolean reportButtonFound = false;
|
||||
|
||||
for (ClickableWidget button : buttons) {
|
||||
if (button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) {
|
||||
button.setWidth(-9999);
|
||||
button.active = false;
|
||||
reportButton = button;
|
||||
reportButtonFound = true;
|
||||
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) {
|
||||
ButtonWidget openToLanButton = this.addDrawableChild(new ButtonWidget(this.width / 2 + 4, this.height / 4 + 96 + -16, 98, 20, Text.translatable("menu.shareToLan"), (button) -> {
|
||||
assert this.client != null;
|
||||
this.client.setScreen(new OpenToLanScreen(this));
|
||||
}));
|
||||
OpenToLanButton openToLanButton = new OpenToLanButton(this,this.width / 2 + 4, this.height / 4 + 96 + -16, 98, 20, Text.translatable("menu.shareToLan"));
|
||||
|
||||
assert this.client != null;
|
||||
openToLanButton.active = this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote();
|
||||
if (this.client != null) {
|
||||
openToLanButton.active = this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote();
|
||||
}
|
||||
|
||||
widgets.add(openToLanButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.6",
|
||||
"minecraft": "~1.19",
|
||||
"minecraft": ">=1.19.3",
|
||||
"java": ">=17",
|
||||
"fabric-screen-api-v1": ">=1.0.4"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user