Skip to content

Commit

Permalink
Merge pull request #487 from viciscat/dungeons_party_gui
Browse files Browse the repository at this point in the history
Add a custom GUI for the Party Finder in dungeons
  • Loading branch information
kevinthegreat1 authored Jan 20, 2024
2 parents 8ccaa3b + f07dcf2 commit 2cf648b
Show file tree
Hide file tree
Showing 19 changed files with 1,796 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.hysky.skyblocker.debug.Debug;
import de.hysky.skyblocker.skyblock.*;
import de.hysky.skyblocker.skyblock.dungeon.*;
import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen;
import de.hysky.skyblocker.skyblock.dungeon.puzzle.CreeperBeams;
import de.hysky.skyblocker.skyblock.dungeon.puzzle.DungeonBlaze;
import de.hysky.skyblocker.skyblock.dungeon.puzzle.TicTacToe;
Expand Down Expand Up @@ -108,6 +109,7 @@ public void onInitializeClient() {
DungeonBlaze.init();
Waterboard.init();
DungeonScore.init();
PartyFinderScreen.initClass();
ChestValue.init();
FireFreezeStaffTimer.init();
GuardianHealth.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public static class General {
@SerialEntry
public boolean acceptReparty = true;

@SerialEntry
public boolean betterPartyFinder = true;

@SerialEntry
public boolean backpackPreviewWithoutShift = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.general.acceptReparty = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.betterPartyFinder"))
.binding(defaults.general.betterPartyFinder,
() -> config.general.betterPartyFinder,
newValue -> config.general.betterPartyFinder = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.backpackPreviewWithoutShift"))
.binding(defaults.general.backpackPreviewWithoutShift,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@

import com.mojang.authlib.GameProfile;

import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen;
import de.hysky.skyblocker.skyblock.item.HotbarSlotLock;
import de.hysky.skyblocker.skyblock.item.ItemProtection;
import de.hysky.skyblocker.skyblock.rift.HealingMelonIndicator;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.block.entity.SignBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ClientPlayerEntity.class)
public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity {
@Shadow @Final protected MinecraftClient client;

public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
super(world, profile);
}
Expand All @@ -33,4 +40,15 @@ public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
public void skyblocker$updateHealth(CallbackInfo ci) {
HealingMelonIndicator.updateHealth();
}

@Inject(method = "openEditSignScreen", at = @At("HEAD"), cancellable = true)
public void skyblocker$partyFinderRange(SignBlockEntity sign, boolean front, CallbackInfo callbackInfo) {
if (PartyFinderScreen.isInKuudraPartyFinder) return;
if (client.currentScreen instanceof PartyFinderScreen partyFinderScreen && !partyFinderScreen.isAborted()) {
if (sign.getText(front).getMessage(3, false).getString().toLowerCase().contains("level")) {
partyFinderScreen.updateSign(sign, front);
callbackInfo.cancel();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.hysky.skyblocker.mixin;

import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler;
Expand All @@ -20,11 +22,17 @@ protected GenericContainerScreenHandlerMixin(@Nullable ScreenHandlerType<?> type
public void setStackInSlot(int slot, int revision, ItemStack stack) {
super.setStackInSlot(slot, revision, stack);
SkyblockerMod.getInstance().containerSolverManager.markDirty();
if (MinecraftClient.getInstance().currentScreen instanceof PartyFinderScreen screen) {
screen.markDirty();
}
}

@Override
public void updateSlotStacks(int revision, List<ItemStack> stacks, ItemStack cursorStack) {
super.updateSlotStacks(revision, stacks, cursorStack);
SkyblockerMod.getInstance().containerSolverManager.markDirty();
if (MinecraftClient.getInstance().currentScreen instanceof PartyFinderScreen screen) {
screen.markDirty();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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.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 HandledScreenProviderMixin<T extends ScreenHandler> {
@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())) {
if (client.currentScreen != null) {
String lowerCase = client.currentScreen.getTitle().getString().toLowerCase();
if (lowerCase.contains("group builder")) return;
if (lowerCase.contains("select tier")) {
PartyFinderScreen.isInKuudraPartyFinder = true;
} else if (lowerCase.contains("catacombs")) {
PartyFinderScreen.isInKuudraPartyFinder = false;
}
}
if (PartyFinderScreen.isInKuudraPartyFinder) return;
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();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.hysky.skyblocker.mixin.accessor;

import com.mojang.authlib.GameProfile;
import net.minecraft.block.entity.SkullBlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;

@Mixin(SkullBlockEntity.class)
public interface SkullBlockEntityAccessor {
@Invoker
static CompletableFuture<Optional<GameProfile>> invokeFetchProfile(String name) {
throw new UnsupportedOperationException();
}
}
Loading

0 comments on commit 2cf648b

Please sign in to comment.