Skip to content

Commit d7536c0

Browse files
committed
Add Hypixel mod API support; improve safety checks for game modes
1 parent 35e96a1 commit d7536c0

File tree

6 files changed

+51
-19
lines changed

6 files changed

+51
-19
lines changed

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ repositories {
2626
maven {
2727
url 'https://maven.wispforest.io/releases/'
2828
}
29+
maven {
30+
url 'https://repo.hypixel.net/repository/Hypixel/'
31+
}
2932
}
3033

3134
dependencies {
@@ -41,6 +44,9 @@ dependencies {
4144
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
4245
modImplementation "io.wispforest:owo-lib:${project.owo_version}"
4346

47+
modImplementation 'net.hypixel:mod-api:1.0.1'
48+
include 'net.hypixel:mod-api:1.0.1'
49+
4450
implementation 'com.google.code.gson:gson:2.10.1'
4551
}
4652

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx1G
44
# check these on https://modmuss50.me/fabric.html
55
minecraft_version=1.21.5
66
yarn_mappings=1.21.5+build.1
7-
loader_version=0.16.14
7+
loader_version=0.17.1
88
# Mod Properties
99
mod_version=2.0.0+1.21.5
10-
maven_group=com.github
10+
maven_group=com.github.kd_gaming1
1111
archives_base_name=scaleme
1212
# Dependencies
1313
# check this on https://modmuss50.me/fabric.html
14-
fabric_version=0.127.1+1.21.5
14+
fabric_version=0.128.1+1.21.5
1515
midnightlib_version = 1.7.3+1.21.4-fabric
1616
modmenu_version = 14.0.0-rc.2
1717
owo_version=0.12.21+1.21.5

src/main/java/com/github/kd_gaming1/scaleme/client/util/HypixelDetector.java

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,54 @@
88

99
public class HypixelDetector {
1010

11+
public static String currentMode = null;
12+
public static String currentMap = null;
13+
public static String currentServerName = null;
14+
public static String serverType = null;
15+
1116
public static boolean isSafeGameMode() {
1217
MinecraftClient client = MinecraftClient.getInstance();
1318

1419
// Check if on Hypixel using server brand
15-
if (client.getNetworkHandler() == null) return true; // Not on a server, safe
20+
if (client.getNetworkHandler() == null) return false; // Not on a server, safe
1621
String brand = client.getNetworkHandler().getBrand();
17-
if (brand == null || !brand.toLowerCase().contains("hypixel")) return true; // Not Hypixel, safe
22+
if (brand == null || !brand.toLowerCase().contains("hypixel")) return false; // Not Hypixel, safe
1823

1924
// Get scoreboard title
20-
if (client.world == null) return true; // Safe default for Hypixel
25+
if (client.world == null) return false; // Safe default for Hypixel
2126
Scoreboard scoreboard = client.world.getScoreboard();
22-
if (scoreboard == null) return true; // Safe default for Hypixel
27+
if (scoreboard == null) return false; // Safe default for Hypixel
2328

2429
ScoreboardObjective objective = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.SIDEBAR);
25-
if (objective == null) return true; // Safe default for Hypixel
30+
if (objective == null) return false; // Safe default for Hypixel
2631

2732
Text scoreboardTitle = objective.getDisplayName();
2833
String title = stripColors(scoreboardTitle.getString()).toUpperCase();
2934

3035
// Return true if in safe modes
31-
return title.startsWith("SKYBLOCK") ||
32-
title.startsWith("LOBBY") ||
33-
title.startsWith("LIMBO") ||
34-
title.startsWith("HOUSING") ||
35-
title.startsWith("PROTOTYPE");
36+
return !title.startsWith("SKYBLOCK") &&
37+
!title.startsWith("LOBBY") &&
38+
!title.startsWith("LIMBO") &&
39+
!title.startsWith("HOUSING") &&
40+
!title.startsWith("PROTOTYPE");
41+
}
42+
43+
/**
44+
* Checks if the player is in a Hypixel dungeon or catacombs.
45+
* This method uses the current mode, map, and server name to determine if the player is in dungeons.
46+
*
47+
* @return true if the player is in dungeons, false otherwise.
48+
*/
49+
public static boolean isInDungeons() {
50+
if (!"SKYBLOCK".equalsIgnoreCase(serverType)) return true;
51+
52+
String mode = currentMode != null ? currentMode.toLowerCase() : "";
53+
String map = currentMap != null ? currentMap.toLowerCase() : "";
54+
String server = currentServerName != null ? currentServerName.toLowerCase() : "";
55+
56+
return !mode.contains("dungeon") && !mode.contains("catacombs")
57+
&& !map.contains("dungeon") && !map.contains("catacombs") && !map.contains("floor")
58+
&& !server.contains("dungeon") && !server.contains("catacombs");
3659
}
3760

3861
private static String stripColors(String text) {

src/main/java/com/github/kd_gaming1/scaleme/client/util/PlayerPresetManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static void tick() {
7575

7676
/** Returns the current scale for a player. O(1) lookup. */
7777
public static float getCurrentScale(UUID playerUUID) {
78-
if (!HypixelDetector.isSafeGameMode()) return 1.0f; // Disable scaling if not safe game mode
78+
if (HypixelDetector.isSafeGameMode()) return 1.0f; // Disable scaling if not safe game mode
7979
if (playerUUID == null) return 1.0f;
8080

8181
Float cached = currentScales.get(playerUUID);

src/main/java/com/github/kd_gaming1/scaleme/client/util/ScaleManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public static float getCurrentScale(UUID playerUUID) {
3333

3434
/** Returns NPC scale with safety check including dungeons detection. */
3535
public static float getNpcScale() {
36-
// Disable NPC scaling in competitive modes AND dungeons
37-
36+
// Only apply scaling when it's safe (not in competitive modes or dungeons)
37+
if (HypixelDetector.isSafeGameMode() && HypixelDetector.isInDungeons()) return 1.0f;
3838
return ScaleMeConfig.npcPlayerScale;
3939
}
4040

4141
/** Returns Villager NPC scale with safety check including dungeons detection. */
4242
public static float getVillagerNpcScale() {
43-
// Disable Villager NPC scaling in competitive modes AND dungeons
44-
43+
// Only apply scaling when it's safe (not in competitive modes or dungeons)
44+
if (HypixelDetector.isSafeGameMode() && HypixelDetector.isInDungeons()) return 1.0f;
4545
return ScaleMeConfig.villagerNpcScale;
4646
}
4747
}

src/main/resources/fabric.mod.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"description": "Client-side player model scaling for Minecraft",
77
"authors": ["Kd_Gaming1"],
88
"contact": {},
9-
"license": "All-Rights-Reserved",
9+
"license": "PolyForm Shield License 1.0.0",
1010
"icon": "assets/scaleme/icon.png",
1111
"environment": "client",
1212
"entrypoints": {
@@ -26,5 +26,8 @@
2626
"minecraft": "${minecraft_version}",
2727
"midnightlib": ">=1.6.0",
2828
"owo": ">=${owo_version}"
29+
},
30+
"suggests": {
31+
"hypixel-mod-api": "*"
2932
}
3033
}

0 commit comments

Comments
 (0)