Skip to content

Commit

Permalink
1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Satxm committed Jul 16, 2024
1 parent e8e6994 commit 2919d37
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions quilt/src/main/java/io/github/satxm/mcwifipnp/MCWiFiPnP.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.satxm.mcwifipnp;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.command.api.CommandRegistrationCallback;
import org.quiltmc.qsl.lifecycle.api.event.ServerLifecycleEvents;
import org.quiltmc.qsl.screen.api.client.ScreenEvents;

import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
Expand All @@ -27,9 +27,9 @@ public class MCWiFiPnP implements ModInitializer {
public static final String MODID = "mcwifipnp";

@Override
public void onInitialize() {
ServerLifecycleEvents.SERVER_STARTING.register(this::onServerLoad);
ServerLifecycleEvents.SERVER_STOPPING.register(this::onServerStop);
public void onInitialize(ModContainer mod) {
ServerLifecycleEvents.STARTING.register(this::onServerLoad);
ServerLifecycleEvents.STOPPING.register(this::onServerStop);
ScreenEvents.AFTER_INIT.register(MCWiFiPnP::afterScreenInit);

CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
Expand All @@ -42,16 +42,16 @@ public void onInitialize() {
});
}

public static void afterScreenInit(Minecraft client, Screen screen, int x, int y) {
public static void afterScreenInit(Screen screen, Minecraft client, boolean i) {
if (screen instanceof PauseScreen) {
for (AbstractWidget button : Screens.getButtons(screen)) {
for (AbstractWidget button : screen.getButtons()) {
if (button.getMessage().equals(Component.translatable("menu.shareToLan"))) {
Button newButton = Button.builder(Component.translatable("menu.shareToLan"), $ -> {
client.setScreen(new ShareToLanScreenNew(screen));
}).bounds(button.getX(), button.getY(), button.getWidth(), button.getHeight()).build();
newButton.active = button.active;
Screens.getButtons(screen).remove(button);
Screens.getButtons(screen).add(newButton);
screen.getButtons().remove(button);
screen.getButtons().add(newButton);
}
}
}
Expand Down

0 comments on commit 2919d37

Please sign in to comment.