Add an option to change your UA (#244)

This commit is contained in:
Soda5601
2023-04-08 16:07:21 +08:00
committed by GitHub
parent 5ee9db0987
commit cc91428cb8
6 changed files with 34 additions and 41 deletions

View File

@@ -127,7 +127,8 @@
- Radar HUD - Radar HUD
## Config ## Config
- `Http Allowed` - Modify what http requests can be made with Meteor's http api - `Http Allowed` - Modify what HTTP requests can be made with Meteor's HTTP API
- `Http User Agent` - Modify the HTTP header of Meteor's HTTP API
- `Hidden Modules` - Hide modules from module gui. **requires restart when unhiding** - `Hidden Modules` - Hide modules from module gui. **requires restart when unhiding**
- `Load system fonts` - Disabling this for faster launch. You can put font into meteor-client/fonts folder. **requires restart to take effect** - `Load System Fonts` - Disabling this for faster launch. You can put font into meteor-client/fonts folder. **requires restart to take effect**
- `Duplicate module names` - Allow duplicate module names. Best for addon compatibility. - `Duplicate Module Names` - Allow duplicate module names. Enable it when you have one module overriding another.

View File

@@ -0,0 +1,18 @@
package anticope.rejects.mixin.meteor;
import anticope.rejects.utils.RejectsConfig;
import meteordevelopment.meteorclient.utils.network.Http;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.net.http.HttpRequest;
@Mixin(Http.Request.class)
public class HttpRequestMixin {
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/net/http/HttpRequest$Builder;header(Ljava/lang/String;Ljava/lang/String;)Ljava/net/http/HttpRequest$Builder;"))
private HttpRequest.Builder onAddUAHeader(HttpRequest.Builder builder, String userAgent, String value) {
if (RejectsConfig.get().httpUserAgent.isBlank()) return builder;
return builder.header("User-Agent", value);
}
}

View File

@@ -20,6 +20,14 @@ public class ConfigModifier {
.build() .build()
); );
public final Setting<String> httpUserAgent = sgRejects.add(new StringSetting.Builder()
.name("http-user-agent")
.description("Changes the HTTP user agent. Empty for none.")
.defaultValue(RejectsConfig.get().httpUserAgent)
.onChanged(v -> RejectsConfig.get().httpUserAgent = v)
.build()
);
public final Setting<List<Module>> hiddenModules = sgRejects.add(new ModuleListSetting.Builder() public final Setting<List<Module>> hiddenModules = sgRejects.add(new ModuleListSetting.Builder()
.name("hidden-modules") .name("hidden-modules")
.description("Which modules to hide.") .description("Which modules to hide.")

View File

@@ -26,6 +26,7 @@ public class RejectsConfig extends System<RejectsConfig> {
} }
public HttpAllowed httpAllowed = HttpAllowed.Everything; public HttpAllowed httpAllowed = HttpAllowed.Everything;
public String httpUserAgent = "Meteor Client";
public Set<String> hiddenModules = new HashSet<>(); public Set<String> hiddenModules = new HashSet<>();
public boolean loadSystemFonts = true; public boolean loadSystemFonts = true;
public boolean duplicateModuleNames = false; public boolean duplicateModuleNames = false;
@@ -66,6 +67,7 @@ public class RejectsConfig extends System<RejectsConfig> {
public NbtCompound toTag() { public NbtCompound toTag() {
NbtCompound tag = new NbtCompound(); NbtCompound tag = new NbtCompound();
tag.putString("httpAllowed", httpAllowed.toString()); tag.putString("httpAllowed", httpAllowed.toString());
tag.putString("httpUserAgent", httpUserAgent);
tag.putBoolean("loadSystemFonts", loadSystemFonts); tag.putBoolean("loadSystemFonts", loadSystemFonts);
tag.putBoolean("duplicateModuleNames", duplicateModuleNames); tag.putBoolean("duplicateModuleNames", duplicateModuleNames);
@@ -79,6 +81,7 @@ public class RejectsConfig extends System<RejectsConfig> {
@Override @Override
public RejectsConfig fromTag(NbtCompound tag) { public RejectsConfig fromTag(NbtCompound tag) {
httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed")); httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
httpUserAgent = tag.getString("httpUserAgent");
loadSystemFonts = tag.getBoolean("loadSystemFonts"); loadSystemFonts = tag.getBoolean("loadSystemFonts");
duplicateModuleNames = tag.getBoolean("duplicateModuleNames"); duplicateModuleNames = tag.getBoolean("duplicateModuleNames");

View File

@@ -1,38 +0,0 @@
package anticope.rejects.utils;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.utils.Utils;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.FluidState;
import net.minecraft.util.math.BlockPos;
import java.util.Optional;
public class TntDamage {
public static int calculate(BlockPos bp) {
if (!Utils.canUpdate()) return 0;
int score = 0;
for(int j = -5; j <= 5; ++j) {
for(int k = -5; k <= 5; ++k) {
for(int l = -5; l <= 5; ++l) {
BlockPos blockPos = new BlockPos(j, k, l);
BlockState blockState = MeteorClient.mc.world.getBlockState(blockPos);
FluidState fluidState = MeteorClient.mc.world.getFluidState(blockPos);
float h = 2.8F;
Optional<Float> optional = blockState.isAir() && fluidState.isEmpty() ? Optional.empty() : Optional.of(Math.max(blockState.getBlock().getBlastResistance(), fluidState.getBlastResistance()));;
if (optional.isPresent()) {
h -= (optional.get() + 0.3F) * 0.3F;
}
if (h > 0.0F) {
score++;
}
}
}
}
return score;
}
}

View File

@@ -11,6 +11,7 @@
"FontUtilsMixin", "FontUtilsMixin",
"GuiRendererAccessor", "GuiRendererAccessor",
"HttpMixin", "HttpMixin",
"HttpRequestMixin",
"ModuleMixin", "ModuleMixin",
"ModulesMixin", "ModulesMixin",
"WAccountMixin", "WAccountMixin",