Skip to content

Commit

Permalink
Fixed Reset Command, and added ServerScraper module.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Nov 3, 2024
1 parent 52cdbbe commit c91c63c
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/main/java/dev/heliosclient/command/commands/Reset.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import dev.heliosclient.HeliosClient;
import dev.heliosclient.command.Command;
import dev.heliosclient.managers.ModuleManager;
import dev.heliosclient.util.ChatUtils;
import net.minecraft.command.CommandSource;

Expand All @@ -14,6 +15,7 @@ public Reset() {
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
ModuleManager.init();
HeliosClient.CONFIG.writeDefaultModuleConfig();

ChatUtils.sendHeliosMsg("Reset config.");
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/dev/heliosclient/managers/ColorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ private ColorManager() {
.setEndGradient(this::getPrimaryGradientEnd)
.register();



registerStaticGradient("Sunrise", new Color(255, 94, 77), new Color(255, 165, 0));
registerStaticGradient("Ocean", new Color(0, 105, 148), new Color(0, 168, 255));
registerStaticGradient("Forest", new Color(34, 139, 34), new Color(107, 142, 35));
Expand Down Expand Up @@ -163,28 +161,24 @@ public int clickGuiPaneText() {
return clickGuiPaneText;
}
}

@SuppressWarnings("all")
@SubscribeEvent
public void onTick(TickEvent.CLIENT e) {
if (HeliosClient.CLICKGUI == null) return;
ColorManager.SYNC_ACCENT = HeliosClient.CLICKGUI.syncAccentColor.value;


Tooltip.tooltip.mode = HeliosClient.CLICKGUI.TooltipMode.value;
Tooltip.tooltip.fixedPos = HeliosClient.CLICKGUI.TooltipPos.value;

//Sync accent color with the rest of the client.
//Hud color is synced in HUDModule.java
if (SYNC_ACCENT) {
updateClickGuiSecondary(HeliosClient.CLICKGUI.AccentColor.getColor(), HeliosClient.CLICKGUI.AccentColor.isRainbow());

updatePrimaryGradients(HeliosClient.CLICKGUI.AccentColor.getColor(), HeliosClient.CLICKGUI.AccentColor.getColor());
return;
}



//hey blackbox, fix this bloated code please

GUI gui = (ModuleManager.get(GUI.class));

Expand All @@ -196,7 +190,6 @@ public void onTick(TickEvent.CLIENT e) {
updatePrimaryGradients(gui.gradientType.get().getStartGradient(), gui.gradientType.get().getEndGradient());
}


updateClickGuiSecondary(HeliosClient.CLICKGUI.AccentColor.getColor(), HeliosClient.CLICKGUI.AccentColor.isRainbow());

this.defaultTextColor = HeliosClient.CLICKGUI.TextColor.getColor().getRGB();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/heliosclient/managers/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static void init() {
new AutoNametag(),
new BetterPortals(),
new LiquidInteract(),
new ServerScraper(),
new Painter(),
new SignTweaks(),
new Collisions(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ public ChatHighlight() {

addSettingGroup(sgGeneral);
addQuickSettings(sgGeneral.getSettings());

//Test
// this.highlightList.add("ElBe_Gaming");
// this.highlightList.add("tanishisherewith");
}

public void checkForHighlights() {
Expand Down Expand Up @@ -112,7 +108,7 @@ public void checkForHighlights() {


//Priority low for chat tweaks to append first.
@SubscribeEvent
@SubscribeEvent(priority = SubscribeEvent.Priority.LOW)
public void onChatMessageEvent(ChatMessageEvent event) {
event.setCanceled(true);

Expand Down Expand Up @@ -165,8 +161,7 @@ public void onChatMessageEvent(ChatMessageEvent event) {
// The message has been edited; we should change the text.
messageEdited = true;
}
} catch (PatternSyntaxException ignored) {
}
} catch (PatternSyntaxException ignored) {}
}
}

Expand All @@ -175,7 +170,6 @@ public void onChatMessageEvent(ChatMessageEvent event) {
}
}


private String applyCaseCheck(String input) {
if (checkCase.getOption() != CaseCheck.NONE) {
return ((CaseCheck) checkCase.getOption()).getString(input);
Expand Down
108 changes: 108 additions & 0 deletions src/main/java/dev/heliosclient/module/modules/world/ServerScraper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package dev.heliosclient.module.modules.world;

import dev.heliosclient.event.SubscribeEvent;
import dev.heliosclient.event.events.player.PacketEvent;
import dev.heliosclient.event.events.player.PlayerJoinEvent;
import dev.heliosclient.module.Categories;
import dev.heliosclient.module.Module_;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.Vec3d;

public class ServerScraper extends Module_ {
public ServerScraper() {
super("ServerScraper", "Gathers information about the server and world on join.", Categories.WORLD);
}

@SubscribeEvent
public void onPacketSend(PacketEvent.SEND event) {
if (event.getPacket() instanceof ResourcePackSendS2CPacket rsPack) {
MutableText text = Text.literal("ResourcePack URL:")
.formatted(Formatting.BOLD, Formatting.BLUE)
.append(Text.literal(" " + rsPack.url())
.formatted(Formatting.ITALIC, Formatting.GOLD)
);

mc.inGameHud.getChatHud().addMessage(text);
}
}
@SubscribeEvent
public void onPlayerJoin(PlayerJoinEvent event) {
// Get the current world
ClientWorld world = mc.world;

if (world != null) {
// Gather world information
long worldAge = world.getTime();
long dayTime = world.getTimeOfDay();
boolean isDay = dayTime >= 0 && dayTime < 12000; // Daytime is between 0 and 12000 ticks

// Gather player and entity information
int playerCount = world.getPlayers().size();

// Gather world border information
double worldBorderSize = world.getWorldBorder().getSize();
Vec3d worldBorderCenter = new Vec3d(world.getWorldBorder().getCenterX(),0, world.getWorldBorder().getCenterZ());

// Gather biome information
String biomeName = world.getBiome(mc.player.getBlockPos()).value().toString();
MutableText separator = Text.of("=======================================================").copy().formatted(Formatting.DARK_GREEN);
mc.inGameHud.getChatHud().addMessage(separator);

// Constructing the information message
MutableText worldInfoMessage = Text.literal("World Info:")
.formatted(Formatting.BOLD, Formatting.GREEN)
.append(Text.literal("\nWorld Age: ").formatted(Formatting.WHITE).append(Text.literal(worldAge + " ticks").formatted(Formatting.YELLOW)))
.append(Text.literal("\nDay Time: ").formatted(Formatting.WHITE).append(Text.literal(dayTime + " ticks").formatted(Formatting.YELLOW)))
.append(Text.literal("\nDay Count: ").formatted(Formatting.WHITE).append(Text.literal(String.valueOf(Math.floor(mc.world.getTime() / 24000))).formatted(Formatting.YELLOW)))
.append(Text.literal("\nIs Day: ").formatted(Formatting.WHITE).append(Text.literal(isDay ? "Yes" : "No").formatted(isDay ? Formatting.GREEN : Formatting.RED)))
.append(Text.literal("\nPlayer Count: ").formatted(Formatting.WHITE).append(Text.literal(playerCount + "").formatted(Formatting.YELLOW)))
.append(Text.literal("\nWorld Border Size: ").formatted(Formatting.WHITE).append(Text.literal(worldBorderSize + " blocks").formatted(Formatting.YELLOW)))
.append(Text.literal("\nWorld Border Center: ").formatted(Formatting.WHITE).append(Text.literal(worldBorderCenter.toString()).formatted(Formatting.YELLOW)))
.append(Text.literal("\nDifficulty: ").formatted(Formatting.WHITE).append(Text.literal(mc.world.getDifficulty().name()).formatted(Formatting.YELLOW)))
.append(Text.literal("\nPermissionLevel: ").formatted(Formatting.WHITE).append(Text.literal(String.valueOf(mc.player.getPermissionLevel())).formatted(Formatting.YELLOW)))
.append(Text.literal("\nCurrent Biome: ").formatted(Formatting.WHITE).append(Text.literal(biomeName).formatted(Formatting.YELLOW)))
.append(Text.literal("\nWorld Spawn Pos: ").formatted(Formatting.WHITE).append(Text.literal(mc.world.getSpawnPos().toString()).formatted(Formatting.YELLOW)));

// Display the message in chat
mc.inGameHud.getChatHud().addMessage(worldInfoMessage);
mc.inGameHud.getChatHud().addMessage(Text.of("------------------------------------------------------"));


ServerInfo info = mc.getCurrentServerEntry();
if(info != null) {
String serverName = info.name;
String serverVersion = info.version.getString();
String serverProtocolVersion = String.valueOf(info.protocolVersion);
String motd = info.label.getString();
String serverAddress = info.address;
String online = String.valueOf(info.online);
boolean hasSecureChat = info.isSecureChatEnforced();
boolean texturePackRequired = info.getResourcePackPolicy() == ServerInfo.ResourcePackPolicy.ENABLED;

// Constructing the server information message
MutableText serverInfoMessage = Text.literal("Server Info:")
.formatted(Formatting.BOLD, Formatting.BLUE)
.append(Text.literal("\nName: ").formatted(Formatting.WHITE).append(Text.literal(serverName).formatted(Formatting.YELLOW)))
.append(Text.literal("\nServer Address: ").formatted(Formatting.WHITE).append(Text.literal(serverAddress).formatted(Formatting.YELLOW)))
.append(Text.literal("\nVersion: ").formatted(Formatting.WHITE).append(Text.literal(serverVersion).formatted(Formatting.YELLOW)))
.append(Text.literal("\nProtocol Version: ").formatted(Formatting.WHITE).append(Text.literal(serverProtocolVersion).formatted(Formatting.YELLOW)))
.append(Text.literal("\nMOTD: ").formatted(Formatting.WHITE).append(Text.literal(motd).formatted(Formatting.YELLOW)))
.append(Text.literal("\nOnline: ").formatted(Formatting.WHITE).append(Text.literal(online).formatted(Formatting.YELLOW)))
.append(Text.literal("\nTexture Pack Required: ").formatted(Formatting.WHITE).append(Text.literal(texturePackRequired ? "Yes" : "No").formatted(texturePackRequired ? Formatting.GREEN : Formatting.RED)))
.append(Text.literal("\nTexture Pack Policy: ").formatted(Formatting.WHITE).append(Text.literal(info.getResourcePackPolicy().name()).formatted(Formatting.YELLOW)))
.append(Text.literal("\nIs Chat Secure: ").formatted(Formatting.WHITE).append(Text.literal(hasSecureChat ? "Yes" : "No").formatted(hasSecureChat ? Formatting.GREEN : Formatting.RED)))
.append(Text.literal("\nServer Type: ").formatted(Formatting.WHITE).append(Text.literal(info.getServerType().name()).formatted(Formatting.YELLOW)));

// Display the server info message in chat
mc.inGameHud.getChatHud().addMessage(serverInfoMessage);
}

mc.inGameHud.getChatHud().addMessage(separator);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public boolean checkIfEmpty(String fileName) {
public boolean save() {
return currentConfig != null && currentConfig.save();
}

public void loadCurrent() {
if (currentConfig != null) {
currentConfig.load();
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/heliosclient.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPa
accessible method net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler getType ()Lnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractType;

accessible method net/minecraft/client/render/Camera setPos (DDD)V
accessible method net/minecraft/client/render/Camera setRotation (FF)V
accessible method net/minecraft/client/render/Camera setRotation (FF)V

accessible method net/minecraft/client/network/ClientPlayerEntity getPermissionLevel ()I

0 comments on commit c91c63c

Please sign in to comment.