added a way to hide modules from gui

This commit is contained in:
C10udburst
2021-08-30 11:07:05 +02:00
parent 15d3dea949
commit b08e0ae3a5
5 changed files with 105 additions and 4 deletions

View File

@@ -23,7 +23,7 @@ An addon to Meteor Client that adds modules and commands that were too useless t
- Put it in your `.minecraft/mods` folder where you have installed Meteor. - Put it in your `.minecraft/mods` folder where you have installed Meteor.
# Features # Features
### Modules ## Modules
- AntiBot (Removed from Meteor in [166fc](https://github.com/MeteorDevelopment/meteor-client/commit/166fccc73e53de6cfdbe41ea58dc593a2f5011f6#diff-05896d5a7f735a14ee8da5d12fbd24585862ca68efdf32b9401b3f4329d17c73)) - AntiBot (Removed from Meteor in [166fc](https://github.com/MeteorDevelopment/meteor-client/commit/166fccc73e53de6cfdbe41ea58dc593a2f5011f6#diff-05896d5a7f735a14ee8da5d12fbd24585862ca68efdf32b9401b3f4329d17c73))
- AntiSpawnpoint - AntiSpawnpoint
- AntiVanish - AntiVanish
@@ -55,7 +55,7 @@ An addon to Meteor Client that adds modules and commands that were too useless t
- SkeletonESP (Ported from [JexClient](https://github.com/DustinRepo/JexClient-main/blob/main/src/main/java/me/dustin/jex/feature/mod/impl/render/Skeletons.java)) - SkeletonESP (Ported from [JexClient](https://github.com/DustinRepo/JexClient-main/blob/main/src/main/java/me/dustin/jex/feature/mod/impl/render/Skeletons.java))
- SoundLocator - SoundLocator
**Modifications** ### Modifications
- NoRender - NoRender
- `noCommandSuggestions` (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/1347)) - `noCommandSuggestions` (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/1347))
- Flight - Flight
@@ -70,7 +70,7 @@ An addon to Meteor Client that adds modules and commands that were too useless t
- `.teleport` - `.teleport`
- `.terrain-export` (Ported from [BleachHack](https://github.com/BleachDrinker420/BleachHack/blob/master/BleachHack-Fabric-1.17/src/main/java/bleach/hack/command/commands/CmdTerrain.java)) - `.terrain-export` (Ported from [BleachHack](https://github.com/BleachDrinker420/BleachHack/blob/master/BleachHack-Fabric-1.17/src/main/java/bleach/hack/command/commands/CmdTerrain.java))
**Modifications** ### Modifications
- `.server` - `.server`
- `ports` (Ported from [Cornos](https://github.com/cornos/Cornos/blob/master/src/main/java/me/zeroX150/cornos/features/command/impl/Scan.java)) - `ports` (Ported from [Cornos](https://github.com/cornos/Cornos/blob/master/src/main/java/me/zeroX150/cornos/features/command/impl/Scan.java))
- `.locate` - `.locate`
@@ -84,3 +84,7 @@ An addon to Meteor Client that adds modules and commands that were too useless t
## HUD ## HUD
- Apple, Exp & Crystal HUD (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/757)) - Apple, Exp & Crystal HUD (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/757))
- CPS HUD (Ported from [AuroraKeystrokes](https://github.com/LambdAurora/AuroraKeystrokes/tree/1.16/src/main/java/me/lambdaurora/keystrokes)) - CPS HUD (Ported from [AuroraKeystrokes](https://github.com/LambdAurora/AuroraKeystrokes/tree/1.16/src/main/java/me/lambdaurora/keystrokes))
## Config
- `Http Allowed` - modify what http requests can be made with Meteor's http api
- `Hidden Modules` - hide modules from module gui. **requires restart when unhiding**

View File

@@ -3,7 +3,15 @@ package cloudburst.rejects.mixin.meteor;
import cloudburst.rejects.utils.RejectsConfig; import cloudburst.rejects.utils.RejectsConfig;
import meteordevelopment.meteorclient.gui.tabs.builtin.ConfigTab; import meteordevelopment.meteorclient.gui.tabs.builtin.ConfigTab;
import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Module;
import java.util.Arrays;
import java.util.List;
import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ConfigTab.class) @Mixin(ConfigTab.class)
public class ConfigTabMixin { public class ConfigTabMixin {
@@ -20,4 +28,19 @@ public class ConfigTabMixin {
.onChanged(v -> RejectsConfig.get().httpAllowed = v) .onChanged(v -> RejectsConfig.get().httpAllowed = v)
.build() .build()
); );
private final Setting<List<Module>> hiddenModules = sgRejects.add(new ModuleListSetting.Builder()
.name("hidden-modules")
.description("Which modules to hide.")
.defaultValue(Arrays.asList())
.defaultValue(RejectsConfig.get().getHiddenModules())
.onChanged(v -> RejectsConfig.get().setHiddenModules(v))
.build()
);
// No idea why CallbackInfoReturnable, but fabric crashes otherwise lol
@Inject(method = "createScreen", at=@At("HEAD"), remap = false)
private void onCreateScreen(CallbackInfoReturnable<?> cir) {
hiddenModules.set(RejectsConfig.get().getHiddenModules());
}
} }

View File

@@ -0,0 +1,36 @@
package cloudburst.rejects.mixin.meteor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import cloudburst.rejects.utils.RejectsConfig;
import meteordevelopment.meteorclient.systems.modules.Category;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
@Mixin(Modules.class)
public class ModulesMixin {
@Shadow
@Final
private Map<Category, List<Module>> groups;
@Inject(method = "getGroup", at=@At("HEAD"), cancellable = true, remap = false)
private void onGetGroup(Category category, CallbackInfoReturnable<List<Module>> cir) {
Set<String> hiddenModules = RejectsConfig.get().hiddenModules;
if (hiddenModules.isEmpty()) return;
List<Module> foundModules = groups.computeIfAbsent(category, category1 -> new ArrayList<>());
foundModules.removeIf(m -> hiddenModules.contains(m.name));
cir.setReturnValue(foundModules);
}
}

View File

@@ -1,8 +1,20 @@
package cloudburst.rejects.utils; package cloudburst.rejects.utils;
import meteordevelopment.meteorclient.systems.System; import meteordevelopment.meteorclient.systems.System;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.MeteorClient;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtString;
public class RejectsConfig extends System<RejectsConfig> { public class RejectsConfig extends System<RejectsConfig> {
private static final RejectsConfig INSTANCE = new RejectsConfig(); private static final RejectsConfig INSTANCE = new RejectsConfig();
@@ -15,6 +27,7 @@ public class RejectsConfig extends System<RejectsConfig> {
} }
public HttpAllowed httpAllowed = HttpAllowed.Everything; public HttpAllowed httpAllowed = HttpAllowed.Everything;
public Set<String> hiddenModules = new HashSet<String>();
public RejectsConfig() { public RejectsConfig() {
super("rejects-config"); super("rejects-config");
@@ -26,16 +39,40 @@ public class RejectsConfig extends System<RejectsConfig> {
return INSTANCE; return INSTANCE;
} }
public void setHiddenModules(List<Module> newList) {
for (Module module : newList) {
if (module.isActive()) module.toggle();
hiddenModules.add(module.name);
}
}
public List<Module> getHiddenModules() {
Modules modules = Modules.get();
if (modules == null) return Arrays.asList();
return hiddenModules.stream().map(modules::get).collect(Collectors.toList());
}
@Override @Override
public NbtCompound toTag() { public NbtCompound toTag() {
NbtCompound tag = new NbtCompound(); NbtCompound tag = new NbtCompound();
tag.putString("httpAllowed", httpAllowed.toString()); tag.putString("httpAllowed", httpAllowed.toString());
NbtList modulesTag = new NbtList();
for (String module : hiddenModules) modulesTag.add(NbtString.of(module));
tag.put("hiddenModules", modulesTag);
return tag; return tag;
} }
@Override @Override
public RejectsConfig fromTag(NbtCompound tag) { public RejectsConfig fromTag(NbtCompound tag) {
httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed")); httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
NbtList valueTag = tag.getList("hiddenModules", 8);
for (NbtElement tagI : valueTag) {
hiddenModules.add(tagI.asString());
}
return this; return this;
} }
} }

View File

@@ -8,6 +8,7 @@
"CommandsMixin", "CommandsMixin",
"ConfigTabMixin", "ConfigTabMixin",
"GuiRendererAccessor", "GuiRendererAccessor",
"HttpMixin" "HttpMixin",
"ModulesMixin"
] ]
} }