mirror of
https://github.com/Lucaslah/No-Report-Button.git
synced 2026-01-07 22:17:53 +00:00
Setup Project
This commit is contained in:
9
src/main/java/me/lucaslah/ncrb/IScreen.java
Normal file
9
src/main/java/me/lucaslah/ncrb/IScreen.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package me.lucaslah.ncrb;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.Drawable;
|
||||
|
||||
public interface IScreen {
|
||||
public List<Drawable> getButtons();
|
||||
}
|
||||
10
src/main/java/me/lucaslah/ncrb/NoReportButton.java
Normal file
10
src/main/java/me/lucaslah/ncrb/NoReportButton.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package me.lucaslah.ncrb;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
public class NoReportButton implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package me.lucaslah.ncrb.mixin;
|
||||
|
||||
import me.lucaslah.ncrb.IScreen;
|
||||
import net.minecraft.client.gui.Drawable;
|
||||
import net.minecraft.client.gui.screen.*;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(GameMenuScreen.class)
|
||||
public abstract class GameMenuScreenMixin extends Screen {
|
||||
|
||||
protected GameMenuScreenMixin(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "initWidgets()V", at = @At(value = "RETURN"))
|
||||
public void initWidgets(CallbackInfo ci) {
|
||||
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;
|
||||
}
|
||||
|
||||
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) -> {
|
||||
this.client.setScreen(new OpenToLanScreen(this));
|
||||
}));
|
||||
|
||||
openToLanButton.active = this.client.isIntegratedServerRunning() && !this.client.getServer().isRemote();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
src/main/java/me/lucaslah/ncrb/mixin/ScreenMixin.java
Normal file
23
src/main/java/me/lucaslah/ncrb/mixin/ScreenMixin.java
Normal file
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user