blob: 3c3dbd52880bf18c2f1dacac9ba0d5e7c892fad6 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package de.hysky.skyblocker.mixins;
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen;
import de.hysky.skyblocker.skyblock.item.SkyblockInventoryScreen;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import java.util.List;
@Mixin(GenericContainerScreenHandler.class)
public abstract class GenericContainerScreenHandlerMixin extends ScreenHandler {
protected GenericContainerScreenHandlerMixin(@Nullable ScreenHandlerType<?> type, int syncId) {
super(type, syncId);
}
@Override
public void setStackInSlot(int slot, int revision, ItemStack stack) {
super.setStackInSlot(slot, revision, stack);
SkyblockerMod.getInstance().containerSolverManager.markDirty();
Screen currentScreen = MinecraftClient.getInstance().currentScreen;
switch (currentScreen) {
case PartyFinderScreen screen -> screen.markDirty();
case GenericContainerScreen screen when screen.getTitle().getString().toLowerCase().contains("equipment") -> {
int line = slot/9;
if (line > 0 && line < 5 && slot % 9 == 1) {
boolean empty = stack.getName().getString().trim().toLowerCase().startsWith("empty");
if (Utils.isInTheRift())
SkyblockInventoryScreen.equipment_rift[line - 1] = empty ? ItemStack.EMPTY : stack;
else
SkyblockInventoryScreen.equipment[line - 1] = empty ? ItemStack.EMPTY : stack;
}
}
case null, default -> {}
}
}
@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();
}
}
}
|