mirror of
https://github.com/Lucaslah/No-Report-Button.git
synced 2026-01-02 11:37:51 +00:00
fix: modmenu error
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package me.lucaslah.ncrb.mixin;
|
||||
|
||||
import me.lucaslah.ncrb.IScreen;
|
||||
import net.minecraft.client.gui.Drawable;
|
||||
import net.minecraft.client.gui.screen.*;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.Screens;
|
||||
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.resource.language.I18n;
|
||||
@@ -12,6 +13,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 +25,31 @@ 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);
|
||||
|
||||
ClickableWidget reportButton = null;
|
||||
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;
|
||||
for (ClickableWidget button : buttons) {
|
||||
if (button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) {
|
||||
button.setWidth(-9999);
|
||||
reportButton = button;
|
||||
reportButtonFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (reportButtonFound) {
|
||||
reportButton.visible = false;
|
||||
//reportButton.setWidth(-9999);
|
||||
//reportButton.setMessage(Text.of(""));
|
||||
//reportButton.active = false;
|
||||
|
||||
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.active = this.client.isIntegratedServerRunning() && !this.client.getServer().isRemote();
|
||||
assert this.client != null;
|
||||
openToLanButton.active = this.client.isIntegratedServerRunning() && !Objects.requireNonNull(this.client.getServer()).isRemote();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.6",
|
||||
"minecraft": "~1.19",
|
||||
"java": ">=17"
|
||||
"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