mirror of
https://github.com/Lucaslah/No-Report-Button.git
synced 2026-01-09 20:47:52 +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
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.19.2
|
minecraft_version=1.19.3
|
||||||
yarn_mappings=1.19.2+build.1
|
yarn_mappings=1.19.3+build.1
|
||||||
loader_version=0.14.8
|
loader_version=0.14.11
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.2.1
|
mod_version = 1.3.0
|
||||||
maven_group = me.lucaslah
|
maven_group = me.lucaslah
|
||||||
archives_base_name = no-report-button
|
archives_base_name = no-report-button
|
||||||
|
|
||||||
# Dependencies
|
# 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;
|
package me.lucaslah.ncrb.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.screen.GameMenuScreen;
|
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.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
|
import net.minecraft.client.gui.widget.GridWidget;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -25,28 +26,41 @@ public abstract class GameMenuScreenMixin extends Screen {
|
|||||||
|
|
||||||
@Inject(method = "initWidgets()V", at = @At(value = "RETURN"))
|
@Inject(method = "initWidgets()V", at = @At(value = "RETURN"))
|
||||||
public void initWidgets(CallbackInfo ci) {
|
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;
|
boolean reportButtonFound = false;
|
||||||
|
|
||||||
for (ClickableWidget button : buttons) {
|
if (buttons != null) {
|
||||||
if (button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) {
|
for (Element element : buttons) {
|
||||||
button.setWidth(-9999);
|
if (element instanceof ClickableWidget button) {
|
||||||
button.active = false;
|
if (button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) {
|
||||||
reportButton = button;
|
button.visible = false;
|
||||||
reportButtonFound = true;
|
button.active = false;
|
||||||
|
reportButtonFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reportButtonFound) {
|
if (reportButtonFound) {
|
||||||
ButtonWidget openToLanButton = this.addDrawableChild(new ButtonWidget(this.width / 2 + 4, this.height / 4 + 96 + -16, 98, 20, Text.translatable("menu.shareToLan"), (button) -> {
|
OpenToLanButton openToLanButton = new OpenToLanButton(this,this.width / 2 + 4, this.height / 4 + 96 + -16, 98, 20, Text.translatable("menu.shareToLan"));
|
||||||
assert this.client != null;
|
|
||||||
this.client.setScreen(new OpenToLanScreen(this));
|
|
||||||
}));
|
|
||||||
|
|
||||||
assert this.client != null;
|
if (this.client != null) {
|
||||||
openToLanButton.active = this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote();
|
openToLanButton.active = this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote();
|
||||||
|
}
|
||||||
|
|
||||||
|
widgets.add(openToLanButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.6",
|
"fabricloader": ">=0.14.6",
|
||||||
"minecraft": "~1.19",
|
"minecraft": ">=1.19.3",
|
||||||
"java": ">=17",
|
"java": ">=17",
|
||||||
"fabric-screen-api-v1": ">=1.0.4"
|
"fabric-screen-api-v1": ">=1.0.4"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user