feat: bring back mods button!

kinda broken and jank but hey it works for now;
This commit is contained in:
əlemi 2023-02-16 02:40:15 +01:00
parent b5d76e3494
commit f85188f310
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 32 additions and 2 deletions

View file

@ -2,10 +2,14 @@ package ftbsc.bscv;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.IngameMenuScreen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands; import net.minecraft.command.Commands;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent;
@ -137,6 +141,30 @@ public class BoSCoVicino implements ICommons {
} }
} }
@SubscribeEvent
public void onPauseMenu(InitGuiEvent.Post event) {
if (event.getGui() instanceof IngameMenuScreen) { // TODO de-jank this, maybe by extending IngameMenuScreen
IngameMenuScreen screen = (IngameMenuScreen) event.getGui();
screen.buttons.remove(3);
screen.buttons.remove(3);
screen.children.remove(3);
screen.children.remove(3);
Button mods_btn = new Button(
screen.width / 2 + 4,
screen.height / 4 + 72 + -16, 98, 20,
new TranslationTextComponent("fml.menu.mods"),
cb -> {
MC.setScreen(new net.minecraftforge.fml.client.gui.screen.ModListScreen(screen));
}
);
// need to add it twice for it to work once...
screen.buttons.add(3, mods_btn);
screen.buttons.add(3, mods_btn);
screen.children.add(3, mods_btn);
screen.children.add(3, mods_btn);
}
}
@SubscribeEvent @SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) { public void onWorldLoad(WorldEvent.Load event) {
// TEMPORARY! add command to regenerate suggestions // TEMPORARY! add command to regenerate suggestions

View file

@ -1,2 +1,4 @@
public net.minecraft.client.network.play.NetworkPlayerInfo field_178866_b public net.minecraft.client.gui.screen.Screen field_230710_m_ # buttons
public net.minecraft.network.play.client.CPlayerPacket field_149474_g public net.minecraft.client.gui.screen.Screen field_230705_e_ # children
public net.minecraft.client.network.play.NetworkPlayerInfo field_178866_b # gameMode
public net.minecraft.network.play.client.CPlayerPacket field_149474_g # onGround