mirror of
https://github.com/Lucaslah/No-Report-Button.git
synced 2026-01-12 08:57:52 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -5,4 +5,5 @@ Supports fabric 1.19.1+, forge support is coming soon!\
|
||||
The fabric api is not required.
|
||||
|
||||
## 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 {
|
||||
|
||||
@@ -8,7 +8,7 @@ yarn_mappings=1.19.2+build.1
|
||||
loader_version=0.14.8
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.0
|
||||
mod_version = 1.2.1
|
||||
maven_group = me.lucaslah
|
||||
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;
|
||||
|
||||
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,28 @@ 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);
|
||||
button.active = false;
|
||||
reportButton = button;
|
||||
reportButtonFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (reportButtonFound) {
|
||||
reportButton.visible = 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