mirror of
https://github.com/Lucaslah/No-Report-Button.git
synced 2026-02-02 11:11:04 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
299018c61b | ||
| eb45d0ff38 | |||
|
|
60e92a2488 | ||
| 5d8a53af6b | |||
|
|
f3ada3a332 | ||
|
|
fb50dfd833 | ||
|
|
ab4d22a186 |
@@ -5,4 +5,5 @@ Supports fabric 1.19.1+, forge support is coming soon!\
|
|||||||
The fabric api is not required.
|
The fabric api is not required.
|
||||||
|
|
||||||
## Links
|
## 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"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
// 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}"
|
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
||||||
|
|
||||||
includeModImplementation fabricApi.module("fabric-api-base", project.fabric_version)
|
includeModImplementation fabricApi.module("fabric-api-base", project.fabric_version)
|
||||||
|
includeModImplementation fabricApi.module("fabric-screen-api-v1", project.fabric_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ yarn_mappings=1.19.2+build.1
|
|||||||
loader_version=0.14.8
|
loader_version=0.14.8
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.0
|
mod_version = 1.2.0
|
||||||
maven_group = me.lucaslah
|
maven_group = me.lucaslah
|
||||||
archives_base_name = no-report-button
|
archives_base_name = no-report-button
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
package me.lucaslah.ncrb.mixin;
|
||||||
|
|
||||||
import me.lucaslah.ncrb.IScreen;
|
import net.fabricmc.fabric.api.client.screen.v1.Screens;
|
||||||
import net.minecraft.client.gui.Drawable;
|
import net.minecraft.client.gui.screen.GameMenuScreen;
|
||||||
import net.minecraft.client.gui.screen.*;
|
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.ButtonWidget;
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
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.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Mixin(GameMenuScreen.class)
|
@Mixin(GameMenuScreen.class)
|
||||||
public abstract class GameMenuScreenMixin extends Screen {
|
public abstract class GameMenuScreenMixin extends Screen {
|
||||||
|
|
||||||
@@ -21,29 +25,31 @@ 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);
|
||||||
|
|
||||||
ClickableWidget reportButton = null;
|
ClickableWidget reportButton = null;
|
||||||
boolean reportButtonFound = false;
|
boolean reportButtonFound = false;
|
||||||
|
|
||||||
for (Drawable drawable : ((IScreen) this).getButtons()) {
|
for (ClickableWidget button : buttons) {
|
||||||
if (!(drawable instanceof ClickableWidget)) continue;
|
if (button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) {
|
||||||
|
button.setWidth(-9999);
|
||||||
ClickableWidget button = (ClickableWidget) drawable;
|
reportButton = button;
|
||||||
|
reportButtonFound = true;
|
||||||
if (!button.getMessage().getString().equals(I18n.translate("menu.playerReporting"))) continue;
|
}
|
||||||
|
|
||||||
reportButton = button;
|
|
||||||
reportButtonFound = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reportButtonFound) {
|
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) -> {
|
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));
|
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": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.6",
|
"fabricloader": ">=0.14.6",
|
||||||
"minecraft": "~1.19",
|
"minecraft": "~1.19",
|
||||||
"java": ">=17"
|
"java": ">=17",
|
||||||
|
"fabric-screen-api-v1": ">=1.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
"mixins": [
|
"mixins": [
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"GameMenuScreenMixin",
|
"GameMenuScreenMixin"
|
||||||
"ScreenMixin"
|
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user