Add an option to change your UA (#244)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,14 @@ public class ConfigModifier {
|
||||
.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()
|
||||
.name("hidden-modules")
|
||||
.description("Which modules to hide.")
|
||||
|
||||
@@ -26,6 +26,7 @@ public class RejectsConfig extends System<RejectsConfig> {
|
||||
}
|
||||
|
||||
public HttpAllowed httpAllowed = HttpAllowed.Everything;
|
||||
public String httpUserAgent = "Meteor Client";
|
||||
public Set<String> hiddenModules = new HashSet<>();
|
||||
public boolean loadSystemFonts = true;
|
||||
public boolean duplicateModuleNames = false;
|
||||
@@ -66,6 +67,7 @@ public class RejectsConfig extends System<RejectsConfig> {
|
||||
public NbtCompound toTag() {
|
||||
NbtCompound tag = new NbtCompound();
|
||||
tag.putString("httpAllowed", httpAllowed.toString());
|
||||
tag.putString("httpUserAgent", httpUserAgent);
|
||||
tag.putBoolean("loadSystemFonts", loadSystemFonts);
|
||||
tag.putBoolean("duplicateModuleNames", duplicateModuleNames);
|
||||
|
||||
@@ -79,6 +81,7 @@ public class RejectsConfig extends System<RejectsConfig> {
|
||||
@Override
|
||||
public RejectsConfig fromTag(NbtCompound tag) {
|
||||
httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
|
||||
httpUserAgent = tag.getString("httpUserAgent");
|
||||
loadSystemFonts = tag.getBoolean("loadSystemFonts");
|
||||
duplicateModuleNames = tag.getBoolean("duplicateModuleNames");
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
"FontUtilsMixin",
|
||||
"GuiRendererAccessor",
|
||||
"HttpMixin",
|
||||
"HttpRequestMixin",
|
||||
"ModuleMixin",
|
||||
"ModulesMixin",
|
||||
"WAccountMixin",
|
||||
|
||||
Reference in New Issue
Block a user