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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
/*
* 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.mod;
import com.google.common.collect.Sets;
import kr.syeyoung.dungeonsguide.IDungeonGuide;
import kr.syeyoung.dungeonsguide.Main;
import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor;
import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter;
import kr.syeyoung.dungeonsguide.mod.commands.CommandDgDebug;
import kr.syeyoung.dungeonsguide.mod.commands.CommandDungeonsGuide;
import kr.syeyoung.dungeonsguide.mod.commands.CommandReparty;
import kr.syeyoung.dungeonsguide.mod.config.Config;
import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager;
import kr.syeyoung.dungeonsguide.mod.discord.rpc.RichPresenceManager;
import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonFacade;
import kr.syeyoung.dungeonsguide.mod.events.listener.FeatureListener;
import kr.syeyoung.dungeonsguide.mod.events.listener.PacketListener;
import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.mod.party.PartyManager;
import kr.syeyoung.dungeonsguide.mod.resources.DGTexturePack;
import kr.syeyoung.dungeonsguide.mod.utils.AhUtils;
import kr.syeyoung.dungeonsguide.mod.utils.BlockCache;
import kr.syeyoung.dungeonsguide.mod.utils.TimeScoreUtil;
import kr.syeyoung.dungeonsguide.mod.utils.TitleRender;
import kr.syeyoung.dungeonsguide.mod.utils.cursor.GLCursors;
import kr.syeyoung.dungeonsguide.mod.wsresource.StaticResourceCache;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.launchwrapper.LaunchClassLoader;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.ProgressManager;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
public class DungeonsGuide implements IDungeonGuide {
@Getter
private static boolean firstTimeUsingDG = false;
Logger logger = LogManager.getLogger("DungeonsGuide");
public boolean verbose = false;
private SkyblockStatus skyblockStatus;
@Getter
private CosmeticsManager cosmeticsManager;
@Getter
private DungeonFacade dungeonFacade;
@Getter
private BlockCache blockCache;
public DungeonsGuide(){
instance = this;
}
private static DungeonsGuide instance;
public static DungeonsGuide getDungeonsGuide() {
return instance;
}
@Getter
CommandReparty commandReparty;
public void init() {
ProgressManager.ProgressBar progressbar = ProgressManager.push("DungeonsGuide", 4);
MinecraftForge.EVENT_BUS.register(this);
progressbar.step("Registering Events & Commands");
skyblockStatus = new SkyblockStatus();
MinecraftForge.EVENT_BUS.register(skyblockStatus);
(new FeatureRegistry()).init();
new ChatTransmitter();
try {
Set<String> invalid = ReflectionHelper.getPrivateValue(LaunchClassLoader.class, (LaunchClassLoader) Main.class.getClassLoader(), "invalidClasses");
((LaunchClassLoader) Main.class.getClassLoader()).clearNegativeEntries(Sets.newHashSet("org.slf4j.LoggerFactory"));
invalid.clear();
} catch (Exception e) {
e.printStackTrace();
}
this.blockCache = new BlockCache();
this.dungeonFacade = new DungeonFacade();
dungeonFacade.init();
TitleRender.getInstance();
CommandDungeonsGuide commandDungeonsGuide = new CommandDungeonsGuide();
CommandDgDebug command = new CommandDgDebug();
ClientCommandHandler.instance.registerCommand(commandDungeonsGuide);
ClientCommandHandler.instance.registerCommand(command);
MinecraftForge.EVENT_BUS.register(command);
MinecraftForge.EVENT_BUS.register(commandDungeonsGuide);
commandReparty = new CommandReparty();
MinecraftForge.EVENT_BUS.register(commandReparty);
MinecraftForge.EVENT_BUS.register(new FeatureListener());
MinecraftForge.EVENT_BUS.register(new PacketListener());
MinecraftForge.EVENT_BUS.register(new Keybinds());
MinecraftForge.EVENT_BUS.register(PartyManager.INSTANCE);
MinecraftForge.EVENT_BUS.register(ChatProcessor.INSTANCE);
MinecraftForge.EVENT_BUS.register(StaticResourceCache.INSTANCE);
MinecraftForge.EVENT_BUS.register(new AhUtils());
progressbar.step("Opening connection");
cosmeticsManager = new CosmeticsManager();
MinecraftForge.EVENT_BUS.register(cosmeticsManager);
progressbar.step("Loading Config");
try {
Config.loadConfig(null);
} catch (IOException e) {
e.printStackTrace();
}
if (FeatureRegistry.ETC_REPARTY.isEnabled()) {
ClientCommandHandler.instance.registerCommand(commandReparty);
}
if (FeatureRegistry.DISCORD_DONOTUSE.isEnabled()) {
System.setProperty("dg.safe", "true");
}
MinecraftForge.EVENT_BUS.register(RichPresenceManager.INSTANCE);
TimeScoreUtil.init();
Main.finishUpProgressBar(progressbar);
ProgressManager.pop(progressbar);
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(resourceManager -> GLCursors.setupCursors());
}
private boolean showedStartUpGuide;
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent guiOpenEvent){
if(!showedStartUpGuide){
showedStartUpGuide = true;
if(isFirstTimeUsingDG()){
GuiScreen originalGUI = guiOpenEvent.gui;
guiOpenEvent.gui = new GuiScreen() {
final String welcomeText = "Thank you for installing §eDungeonsGuide§f, the most intelligent skyblock dungeon mod!\nThe gui for relocating GUI Elements and enabling or disabling features can be opened by typing §e/dg\nType §e/dg help §fto view full list of commands offered by dungeons guide!";
@Override
public void initGui() {
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
this.buttonList.add(new GuiButton(0, sr.getScaledWidth()/2-100,sr.getScaledHeight()-70 ,"Continue"));
}
@Override
protected void actionPerformed(GuiButton button) throws IOException {
super.actionPerformed(button);
if (button.id == 0) {
Minecraft.getMinecraft().displayGuiScreen(originalGUI);
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawBackground(1);
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
fontRenderer.drawString("§eWelcome To DungeonsGuide", (sr.getScaledWidth()-fontRenderer.getStringWidth("Welcome To DungeonsGuide"))/2,40,0xFFFF0000);
int tenth = sr.getScaledWidth() / 10;
Gui.drawRect(tenth, 70,sr.getScaledWidth()-tenth, sr.getScaledHeight()-80, 0xFF5B5B5B);
String[] split = welcomeText.split("\n");
for (int i = 0; i < split.length; i++) {
fontRenderer.drawString(split[i].replace("\t", " "), tenth + 2,i*fontRenderer.FONT_HEIGHT + 72, 0xFFFFFFFF);
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
};
}
}
}
public void preinit(){
File configFile = new File(Main.getConfigDir(), "config.json");
if (!configFile.exists()) {
Main.getConfigDir().mkdirs();
firstTimeUsingDG = true;
}
Config.f = configFile;
Minecraft.getMinecraft().getFramebuffer().enableStencil();
try {
List<IResourcePack> resourcePackList = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "aA", "field_110449_ao");
resourcePackList.add(new DGTexturePack());
Minecraft.getMinecraft().refreshResources();
} catch (Exception e) {
e.printStackTrace();
}
}
public SkyblockStatus getSkyblockStatus() {
return skyblockStatus;
}
}
|