Skip to content

Commit 2ae5015

Browse files
committed
Connor changed some things.
1 parent 35bbae4 commit 2ae5015

File tree

12 files changed

+168
-133
lines changed

12 files changed

+168
-133
lines changed

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,20 @@ dependencies {
7474

7575
compileOnly('cc.polyfrost:oneconfig-1.8.9-forge:0.2.1-alpha184')
7676
include('cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+')
77+
include('org.polyfrost:polyui:1.1.+')
7778
include('org.reflections:reflections:0.10.2')
7879
include('org.json:json:20231013')
7980
include('org.slick2d:slick2d-core:1.0.2') {
8081
exclude module: 'lwjgl'
8182
}
8283
include('com.neovisionaries:nv-websocket-client:2.14')
83-
include('net.hypixel:mod-api:0.3.1')
84+
include('net.hypixel:mod-api:0.4.0')
8485
include("org.bitbucket.cowwoc:diff-match-patch:1.2")
8586

87+
compileOnly("cc.polyfrost:lwjgl-legacy:1.0.0-alpha26") {
88+
transitive = false
89+
}
90+
8691
compileOnly('org.spongepowered:mixin:0.7.+')
8792
}
8893

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cc.polyfrost.oneconfig.internal.gui;
22

3-
import cc.polyfrost.oneconfig.libs.universal.UScreen;
3+
import net.minecraft.client.gui.GuiScreen;
44

5-
public class HudGui extends UScreen {
5+
public class HudGui extends GuiScreen {
66
}

src/dummy/java/cc/polyfrost/oneconfig/libs/universal/UScreen.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/java/llc/redstone/hysentials/Hysentials.java

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
import llc.redstone.hysentials.cosmetics.wings.tdarth.TdarthCosmetic;
2222
import llc.redstone.hysentials.guis.container.containers.club.ClubDashboardHandler;
2323
import llc.redstone.hysentials.guis.container.ContainerHandler;
24+
import llc.redstone.hysentials.guis.polyui.LwjglManagerImpl;
2425
import llc.redstone.hysentials.handlers.chat.modules.misc.Limit256;
2526
import llc.redstone.hysentials.handlers.guis.GuiScreenPost;
2627
import llc.redstone.hysentials.handlers.guis.OneConfigHudClickHandler;
2728
import llc.redstone.hysentials.handlers.htsl.*;
29+
import llc.redstone.hysentials.polyui.ui.VisitHouseScreen;
2830
import llc.redstone.hysentials.util.LocrawUtil;
2931
import llc.redstone.hysentials.handlers.misc.HousingJoinHandler;
3032
import llc.redstone.hysentials.handlers.misc.PacketRecievedHandler;
@@ -53,6 +55,7 @@
5355
import llc.redstone.hysentials.cosmetics.cubit.CubitCompanion;
5456
import llc.redstone.hysentials.websocket.Socket;
5557
import net.hypixel.modapi.HypixelModAPI;
58+
import net.hypixel.modapi.packet.impl.clientbound.event.ClientboundLocationPacket;
5659
import net.minecraft.client.Minecraft;
5760
import net.minecraft.client.gui.FontRenderer;
5861
import net.minecraft.client.gui.GuiMainMenu;
@@ -74,14 +77,15 @@
7477
import org.apache.logging.log4j.Logger;
7578
import org.json.JSONArray;
7679
import org.json.JSONObject;
80+
import org.polyfrost.polyui.PolyUI;
81+
import org.polyfrost.polyui.component.Drawable;
82+
import org.polyfrost.polyui.input.Translator;
7783

7884
import javax.net.ssl.HttpsURLConnection;
7985
import javax.net.ssl.SSLContext;
8086
import java.io.*;
81-
import java.lang.reflect.Field;
8287
import java.net.HttpURLConnection;
8388
import java.net.URL;
84-
import java.nio.charset.Charset;
8589
import java.nio.charset.StandardCharsets;
8690
import java.util.ArrayList;
8791
import java.util.List;
@@ -154,22 +158,23 @@ public void init(FMLInitializationEvent event) {
154158
registerImages();
155159
config = new HysentialsConfig();
156160
updateAndAdd();
161+
157162
File file = new File(modDir, "./config/hysentials");
158163
if (!file.exists() && !file.mkdirs()) {
159164
throw new RuntimeException("Failed to create config directory! Please report this to sinender on Discord");
160165
}
161166
sbBoxes = new SBBJsonData("./config/hysentials/lines.json", new JSONObject().put("lines", new JSONArray()));
162167
macroJson = new MacroWheelData.MacroJson();
163168

164-
try {
165-
System.setProperty("file.encoding", "UTF-8");
166-
Field charset = Charset.class.getDeclaredField("defaultCharset");
167-
charset.setAccessible(true);
168-
charset.set(null, null);
169-
} catch (Exception e) {
170-
e.printStackTrace();
171-
}
172-
169+
// try {
170+
// System.setProperty("file.encoding", "UTF-8");
171+
// Field charset = Charset.class.getDeclaredField("defaultCharset");
172+
// charset.setAccessible(true);
173+
// charset.set(null, null);
174+
// } catch (Exception e) {
175+
// e.printStackTrace();
176+
// }
177+
//
173178
try {
174179
SSLStore store = new SSLStore();
175180
store.load("/ssl/hysentials.der");
@@ -246,6 +251,9 @@ public void postInit(FMLPostInitializationEvent event) {
246251
Minecraft.getMinecraft().fontRendererObj = imageIconRenderer;
247252
}
248253

254+
preload();
255+
preloadScreens();
256+
249257
registerHandlers();
250258

251259
MinecraftForge.EVENT_BUS.post(new HysentialsLoadedEvent());
@@ -259,6 +267,10 @@ public void postInit(FMLPostInitializationEvent event) {
259267
}
260268
}
261269

270+
private void preloadScreens() {
271+
new VisitHouseScreen().create("Sin_ender");
272+
}
273+
262274
@Mod.EventHandler
263275
public void finishedStarting(FMLLoadCompleteEvent event) {
264276
this.loadedCall = true;
@@ -451,6 +463,7 @@ private void registerHandlers() {
451463

452464
EventManager.INSTANCE.register(new BwRanks());
453465

466+
HypixelModAPI.getInstance().subscribeToEventPacket(ClientboundLocationPacket.class);
454467
HypixelModAPI.getInstance().registerHandler(hypixelModAPI = new ModAPIHandler());
455468

456469
// Runtime.getRuntime().addShutdownHook(new Thread(() -> {
@@ -524,6 +537,26 @@ public static InputStream post(String url, JSONObject json) throws IOException {
524537
return connection.getInputStream();
525538
}
526539

540+
/**
541+
* Ensure that key PolyUI classes are loaded to prevent lag-spikes when loading PolyUI for the first time.
542+
*/
543+
private static void preload() {
544+
long t1 = System.nanoTime();
545+
try {
546+
Class.forName(PolyUI.class.getName());
547+
Class.forName(Drawable.class.getName());
548+
Class.forName(Translator.class.getName());
549+
550+
LwjglManagerImpl.INSTANCE = new LwjglManagerImpl();
551+
LwjglManagerImpl.INSTANCE.getRenderer();
552+
} catch (Exception e) {
553+
throw new IllegalStateException("Failed to preload necessary PolyUI classes", e);
554+
} catch (Throwable e) {
555+
throw new RuntimeException(e);
556+
}
557+
System.out.printf("PolyUI preload took %sms", (System.nanoTime() - t1) / 1_000_000.0);
558+
}
559+
527560
public boolean isApec() {
528561
return isApec && Minecraft.getMinecraft().ingameGUI instanceof ApecGuiIngameForge;
529562
}

src/main/java/llc/redstone/hysentials/command/HysentialsCommand.java

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import llc.redstone.hysentials.guis.misc.HysentialsLevel;
1111
import llc.redstone.hysentials.guis.quest.QuestMainGui;
1212
import llc.redstone.hysentials.handlers.imageicons.ImageIcon;
13+
import llc.redstone.hysentials.polyui.ui.VisitHouseScreen;
1314
import llc.redstone.hysentials.util.LocrawUtil;
1415
import llc.redstone.hysentials.handlers.npc.NPC;
1516
import llc.redstone.hysentials.htsl.compiler.CompileKt;
@@ -27,7 +28,10 @@
2728
import com.mojang.authlib.properties.PropertyMap;
2829
import net.hypixel.data.type.GameType;
2930
import net.hypixel.data.type.ServerType;
31+
import net.hypixel.modapi.HypixelModAPI;
32+
import net.hypixel.modapi.handler.ClientboundPacketHandler;
3033
import net.hypixel.modapi.packet.impl.clientbound.ClientboundLocationPacket;
34+
import net.hypixel.modapi.packet.impl.clientbound.event.ClientboundLocationPacket;
3135
import net.minecraft.client.Minecraft;
3236
import net.minecraft.command.CommandBase;
3337
import net.minecraft.command.CommandException;
@@ -301,29 +305,17 @@ private static void handleTest(String command, String args) {
301305
break;
302306
}
303307

304-
case "hypixel": {
305-
UChat.chat("Sending Hypixel mod API requests...");
306-
for (HypixelPacketType type : HypixelPacketType.values()) {
307-
Hysentials.getModAPI().sendPacket(type, (packet) -> {
308-
UChat.chat("§aReceived packet: " + packet.toString());
309-
});
310-
}
311-
break;
312-
}
313308
case "locraw": {
314309
LocrawInfo info = LocrawUtil.INSTANCE.getLocrawInfo();
315310
if (info != null) {
316311
UChat.chat("§aLocraw Info:");
317-
UChat.chat("&7Environment: &a" + info.getEnvironment());
318-
UChat.chat("&7ProxyName: &a" + info.getProxyName());
319312
UChat.chat("&7ServerName: &a" + info.getServerName());
320313
UChat.chat("&7GameType: &a" + info.getGameType());
321314
UChat.chat("&7LobbyName: &a" + info.getLobbyName());
322315
UChat.chat("&7ModeName: &a" + info.getGameMode());
323316
UChat.chat("&7MapName: &a" + info.getMapName());
324317
} else {
325318
UChat.chat("§cLocraw Info is null!");
326-
LocrawUtil.INSTANCE.sendLocraw();
327319
}
328320
break;
329321
}
@@ -354,33 +346,40 @@ private static void handleTest(String command, String args) {
354346

355347
case "plus": {
356348
UChat.chat("Sending Location Request...");
357-
Hysentials.getModAPI().sendPacket(HypixelPacketType.LOCATION, (p) -> {
358-
double x = 0;
359-
double y = 0;
360-
double z = 0;
361-
float yaw = 0;
362-
ClientboundLocationPacket packet = (ClientboundLocationPacket) p;
363-
if (!packet.getServerType().isPresent()) return;
364-
ServerType serverType = packet.getServerType().get();
365-
if (!(serverType instanceof GameType)) return;
366-
GameType gameType = (GameType) serverType;
367-
switch (gameType) {
368-
case HOUSING: {
369-
x = -16;
370-
y = 65;
371-
z = 30;
372-
yaw = 320f;
373-
break;
349+
HypixelModAPI.getInstance().registerHandler(new ClientboundPacketHandler() {
350+
@Override
351+
public void onLocationEvent(ClientboundLocationPacket packet) {
352+
double x = 0;
353+
double y = 0;
354+
double z = 0;
355+
float yaw = 0;
356+
if (!packet.getServerType().isPresent()) return;
357+
ServerType serverType = packet.getServerType().get();
358+
if (!(serverType instanceof GameType)) return;
359+
GameType gameType = (GameType) serverType;
360+
switch (gameType) {
361+
case HOUSING: {
362+
x = -16;
363+
y = 65;
364+
z = 30;
365+
yaw = 320f;
366+
break;
367+
}
374368
}
375-
}
376369

377-
PlusStandEntity entity = new PlusStandEntity(Minecraft.getMinecraft().theWorld);
378-
entity.setPositionAndRotation(x, y, z, yaw, 0);
379-
Minecraft.getMinecraft().theWorld.spawnEntityInWorld(entity);
370+
PlusStandEntity entity = new PlusStandEntity(Minecraft.getMinecraft().theWorld);
371+
entity.setPositionAndRotation(x, y, z, yaw, 0);
372+
Minecraft.getMinecraft().theWorld.spawnEntityInWorld(entity);
373+
}
380374
});
381375
break;
382376
}
383377

378+
case "house": {
379+
VisitHouseScreen.INSTANCE.open();
380+
break;
381+
}
382+
384383
case "doorbell": {
385384
Socket.CLIENT.sendText(
386385
new Request(

src/main/java/llc/redstone/hysentials/handlers/redworks/BwRanksUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,14 @@ public static String getReplace(String prefix, String name, UUID uuid) {
208208
}
209209

210210
public static boolean futuristicRanks(Boolean tab) {
211-
if (tab == null) {
212-
return Hysentials.INSTANCE.getConfig().formattingConfig.enabled && FormattingConfig.futuristicRanks;
211+
try {
212+
if (tab == null) {
213+
return Hysentials.INSTANCE.getConfig().formattingConfig.enabled && FormattingConfig.futuristicRanks;
214+
}
215+
return Hysentials.INSTANCE.getConfig().formattingConfig.enabled && FormattingConfig.futuristicRanks && (tab ? FormattingConfig.fancyRankInTab : FormattingConfig.fancyRankInChat);
216+
} catch (Exception e) {
217+
return false;
213218
}
214-
return Hysentials.INSTANCE.getConfig().formattingConfig.enabled && FormattingConfig.futuristicRanks && (tab ? FormattingConfig.fancyRankInTab : FormattingConfig.fancyRankInChat);
215219
}
216220

217221
public static String getPlus(UUID id) {
Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,80 @@
11
package llc.redstone.hysentials.mixin;
22

3+
import llc.redstone.hysentials.handlers.redworks.BwRanksUtils;
34
import net.minecraft.client.Minecraft;
45
import net.minecraft.client.gui.FontRenderer;
6+
import net.minecraft.client.network.NetworkPlayerInfo;
7+
import net.minecraft.client.renderer.GlStateManager;
8+
import net.minecraft.client.renderer.Tessellator;
9+
import net.minecraft.client.renderer.WorldRenderer;
510
import net.minecraft.client.renderer.entity.Render;
611
import net.minecraft.client.renderer.entity.RenderManager;
12+
import net.minecraft.client.renderer.entity.RendererLivingEntity;
13+
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
714
import net.minecraft.entity.Entity;
15+
import net.minecraft.entity.EntityLivingBase;
16+
import net.minecraft.entity.player.EntityPlayer;
17+
import net.minecraft.util.IChatComponent;
18+
import org.lwjgl.opengl.GL11;
819
import org.spongepowered.asm.mixin.Final;
920
import org.spongepowered.asm.mixin.Mixin;
21+
import org.spongepowered.asm.mixin.Overwrite;
1022
import org.spongepowered.asm.mixin.Shadow;
1123
import org.spongepowered.asm.mixin.injection.At;
1224
import org.spongepowered.asm.mixin.injection.Redirect;
1325

14-
@Mixin(value = Render.class, priority = 1001)
26+
@Mixin(value = Render.class, priority = Integer.MIN_VALUE)
1527
public abstract class RenderMixin<T extends Entity> {
1628
@Final
1729
@Shadow
1830
protected RenderManager renderManager;
1931

20-
@Redirect(method = "renderLivingLabel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/Render;getFontRendererFromRenderManager()Lnet/minecraft/client/gui/FontRenderer;"))
21-
public FontRenderer drawString(Render instance) {
22-
return Minecraft.getMinecraft().fontRendererObj;
32+
/**
33+
* @author
34+
* @reason
35+
*/
36+
@Overwrite
37+
protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance) {
38+
double d = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer);
39+
if (!(d > (double)(maxDistance * maxDistance))) {
40+
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
41+
float f = 1.6F;
42+
float g = 0.016666668F * f;
43+
GlStateManager.pushMatrix();
44+
GlStateManager.translate((float)x + 0.0F, (float)y + entityIn.height + 0.5F, (float)z);
45+
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
46+
GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
47+
GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
48+
GlStateManager.scale(-g, -g, g);
49+
GlStateManager.disableLighting();
50+
GlStateManager.depthMask(false);
51+
GlStateManager.disableDepth();
52+
GlStateManager.enableBlend();
53+
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
54+
Tessellator tessellator = Tessellator.getInstance();
55+
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
56+
int i = 0;
57+
if (str.equals("deadmau5")) {
58+
i = -10;
59+
}
60+
61+
int j = fontRenderer.getStringWidth(str) / 2;
62+
GlStateManager.disableTexture2D();
63+
worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
64+
worldRenderer.pos((double)(-j - 1), (double)(-1 + i), 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
65+
worldRenderer.pos((double)(-j - 1), (double)(8 + i), 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
66+
worldRenderer.pos((double)(j + 1), (double)(8 + i), 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
67+
worldRenderer.pos((double)(j + 1), (double)(-1 + i), 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
68+
tessellator.draw();
69+
GlStateManager.enableTexture2D();
70+
fontRenderer.drawString(str, -fontRenderer.getStringWidth(str) / 2, i, 553648127);
71+
GlStateManager.enableDepth();
72+
GlStateManager.depthMask(true);
73+
fontRenderer.drawString(str, -fontRenderer.getStringWidth(str) / 2, i, -1);
74+
GlStateManager.enableLighting();
75+
GlStateManager.disableBlend();
76+
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
77+
GlStateManager.popMatrix();
78+
}
2379
}
2480
}

src/main/java/llc/redstone/hysentials/util/HypixelPacketType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package llc.redstone.hysentials.util;
22

33
import net.hypixel.modapi.packet.HypixelPacket;
4-
import net.hypixel.modapi.packet.impl.clientbound.ClientboundLocationPacket;
54
import net.hypixel.modapi.packet.impl.clientbound.ClientboundPartyInfoPacket;
65
import net.hypixel.modapi.packet.impl.clientbound.ClientboundPingPacket;
76
import net.hypixel.modapi.packet.impl.clientbound.ClientboundPlayerInfoPacket;
7+
import net.hypixel.modapi.packet.impl.clientbound.event.ClientboundLocationPacket;
88
import net.hypixel.modapi.serializer.PacketSerializer;
99
import org.jetbrains.annotations.Nullable;
1010

0 commit comments

Comments
 (0)