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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/*
* Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
* Copyright (C) 2021 cyoung06
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package kr.syeyoung.dungeonsguide.features.impl.boss.terminal;
import kr.syeyoung.dungeonsguide.features.SimpleFeature;
import kr.syeyoung.dungeonsguide.features.listener.*;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.Slot;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import org.lwjgl.input.Mouse;
import java.util.ArrayList;
import java.util.List;
public class FeatureTerminalSolvers extends SimpleFeature implements GuiOpenListener, TickListener, GuiPostRenderListener, GuiClickListener, TooltipListener {
public FeatureTerminalSolvers() {
super("Solver.Floor 7+.Bossfight","F7 GUI Terminal Solver", "Solve f7 gui terminals. (color, startswith, order, navigate, correct panes)", "bossfight.terminals");
}
public static final List<TerminalSolutionProvider> solutionProviders = new ArrayList<TerminalSolutionProvider>();
static {
solutionProviders.add(new WhatStartsWithSolutionProvider());
solutionProviders.add(new SelectAllColorSolutionProivider());
solutionProviders.add(new SelectInOrderSolutionProvider());
solutionProviders.add(new NavigateMazeSolutionProvider());
solutionProviders.add(new CorrectThePaneSolutionProvider());
}
private TerminalSolutionProvider solutionProvider;
private TerminalSolution solution;
private final List<Slot> clicked = new ArrayList<Slot>();
@Override
public void onGuiOpen(GuiOpenEvent event) {
if (!isEnabled()) return;
solution = null;
solutionProvider = null;
clicked.clear();
if (event.gui instanceof GuiChest) {
ContainerChest cc = (ContainerChest) ((GuiChest) event.gui).inventorySlots;
for (TerminalSolutionProvider solutionProvider : solutionProviders) {
if (solutionProvider.isApplicable(cc)) {
solution = solutionProvider.provideSolution(cc, clicked);
this.solutionProvider = solutionProvider;
}
}
}
}
@Override
public void onTick() {
if (!isEnabled()) return;
if (solutionProvider == null) return;
if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
solution = null;
solutionProvider = null;
clicked.clear();
return;
}
ContainerChest cc = (ContainerChest) ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots;
solution = solutionProvider.provideSolution(cc, clicked);
}
@Override
public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) {
if (!isEnabled()) return;
if (solutionProvider == null) return;
if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
solution = null;
solutionProvider = null;
clicked.clear();
return;
}
if (solution != null) {
int i = 222;
int j = i - 108;
int ySize = j + (((ContainerChest)(((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots)).getLowerChestInventory().getSizeInventory() / 9) * 18;
int left = (rendered.gui.width - 176) / 2;
int top = (rendered.gui.height - ySize ) / 2;
GlStateManager.pushMatrix();
GlStateManager.disableDepth();
GlStateManager.disableLighting();
GlStateManager.colorMask(true, true, true, false);
GlStateManager.translate(left, top, 0);
if (solution.getCurrSlots() != null) {
for (Slot currSlot : solution.getCurrSlots()) {
int x = currSlot.xDisplayPosition;
int y = currSlot.yDisplayPosition;
Gui.drawRect(x, y, x + 16, y + 16, 0x7700FFFF);
}
}
if (solution.getNextSlots() != null) {
for (Slot nextSlot : solution.getNextSlots()) {
int x = nextSlot.xDisplayPosition;
int y = nextSlot.yDisplayPosition;
Gui.drawRect(x, y, x + 16, y + 16, 0x77FFFF00);
}
}
GlStateManager.colorMask(true, true, true, true);
GlStateManager.popMatrix();
}
GlStateManager.enableBlend();
GlStateManager.enableLighting();
}
@Override
public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) {
if (!isEnabled()) return;
if (Mouse.getEventButton() == -1) return;
if (solutionProvider == null) return;
if (solution == null) return;
if (solution.getCurrSlots() == null) {
return;
}
Slot s = ((GuiChest) Minecraft.getMinecraft().currentScreen).getSlotUnderMouse();
if (solution.getCurrSlots().contains(s)) {
clicked.add(s);
return;
}
}
@Override
public void onTooltip(ItemTooltipEvent event) {
if (!isEnabled()) return;
if (solutionProvider == null) return;
event.toolTip.clear();
}
}
|