Skip to content

Commit

Permalink
1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Satxm committed Jul 16, 2024
1 parent 2919d37 commit 3be2eac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ neo_version = 21.0.95-beta
# Quilt Properties on https://lambdaurora.dev/tools/import_quilt.html
quilt_loader_version = 0.26.0-beta.1
qfapi_version = 11.0.0-alpha.3+0.100.7-1.21
# QSL on https://maven.quiltmc.org/repository/release/org/quiltmc/qsl/maven-metadata.xml
qsl_version = 10.0.0-alpha.1+1.21

# Mod Config
# Fabric
Expand Down
3 changes: 3 additions & 0 deletions quilt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ dependencies {
officialMojangMappings()
}
modImplementation "org.quiltmc:quilt-loader:${project.quilt_loader_version}"

modImplementation "org.quiltmc:qsl:${project.qsl_version}"

modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${qfapi_version}"
}

Expand Down
19 changes: 10 additions & 9 deletions quilt/src/main/java/io/github/satxm/mcwifipnp/MCWiFiPnP.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.satxm.mcwifipnp;

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.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractWidget;
Expand All @@ -28,8 +29,8 @@ public class MCWiFiPnP implements ModInitializer {

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

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

public static void afterScreenInit(Screen screen, Minecraft client, boolean i) {
public static void afterScreenInit(Minecraft client, Screen screen, int x, int y) {
if (screen instanceof PauseScreen) {
for (AbstractWidget button : screen.getButtons()) {
for (AbstractWidget button : Screens.getButtons(screen)) {
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;
screen.getButtons().remove(button);
screen.getButtons().add(newButton);
Screens.getButtons(screen).remove(button);
Screens.getButtons(screen).add(newButton);
}
}
}
Expand Down

0 comments on commit 3be2eac

Please sign in to comment.