blob: 9ff92a20b4ce375c119dc4b20231865f526567af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package de.hysky.skyblocker.mixin;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
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(HandledScreens.Provider.class)
public interface HandledScreensMixin<T extends ScreenHandler, U extends Screen> {
//value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V"), cancellable = true
@Inject(method = "open", at = @At("HEAD"), cancellable = true)
default void skyblocker$open(Text name, ScreenHandlerType<T> type, MinecraftClient client, int id, CallbackInfo ci) {
if (!SkyblockerConfigManager.get().general.betterPartyFinder) return;
ClientPlayerEntity player = client.player;
if (player == null) return;
T screenHandler = type.create(id, player.getInventory());
if ((screenHandler instanceof GenericContainerScreenHandler containerScreenHandler) && PartyFinderScreen.possibleInventoryNames.contains(name.getString().toLowerCase())) {
//player.sendMessage(Text.of("LESSGOOOOO " + containerScreenHandler.getRows()));
client.player.currentScreenHandler = (containerScreenHandler);
if (client.currentScreen instanceof PartyFinderScreen screen) {
screen.updateHandler(containerScreenHandler, name);
} else {
client.setScreen(new PartyFinderScreen(containerScreenHandler, player.getInventory(), name));
}
ci.cancel();
}
}
}
|