Add FoV options to KA and imassist (#214)

This commit is contained in:
Soda5601
2023-01-31 04:53:17 +08:00
committed by GitHub
parent e8905d671a
commit ad06a17a88
10 changed files with 122 additions and 41 deletions

View File

@@ -1,34 +0,0 @@
package anticope.rejects.mixin;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.block.entity.ChestBlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import anticope.rejects.modules.Rendering;
import meteordevelopment.meteorclient.systems.modules.Modules;
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.CallbackInfo;
@Mixin(ChestBlockEntityRenderer.class)
public class ChestBlockEntityRendererMixin {
@Shadow private boolean christmas;
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/client/model/ModelPart;Lnet/minecraft/client/model/ModelPart;Lnet/minecraft/client/model/ModelPart;FII)V", at = @At("HEAD"), cancellable = true)
public void render1(MatrixStack matrices, VertexConsumer vertices, ModelPart lid, ModelPart latch, ModelPart base, float openFactor, int light, int overlay, CallbackInfo ci) {
Rendering rendering = Modules.get().get(Rendering.class);
if (rendering != null)
this.christmas = rendering.chistmas();
}
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/client/model/ModelPart;Lnet/minecraft/client/model/ModelPart;Lnet/minecraft/client/model/ModelPart;FII)V", at = @At("RETURN"))
public void render2(MatrixStack matrices, VertexConsumer vertices, ModelPart lid, ModelPart latch, ModelPart base, float openFactor, int light, int overlay, CallbackInfo ci) {
Rendering rendering = Modules.get().get(Rendering.class);
if (rendering != null)
this.christmas = rendering.chistmas();
}
}

View File

@@ -0,0 +1,19 @@
package anticope.rejects.mixin;
import anticope.rejects.modules.Rendering;
import meteordevelopment.meteorclient.systems.modules.Modules;
import net.minecraft.client.render.TexturedRenderLayers;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(TexturedRenderLayers.class)
public class TexturedRenderLayersMixin {
@ModifyVariable(method = "getChestTexture(Lnet/minecraft/block/entity/BlockEntity;Lnet/minecraft/block/enums/ChestType;Z)Lnet/minecraft/client/util/SpriteIdentifier;", at = @At("LOAD"), name = "christmas")
private static boolean chrsitmas(boolean christmas) {
Rendering rendering = Modules.get().get(Rendering.class);
if (rendering != null && rendering.chistmas())
return true;
return christmas;
}
}

View File

@@ -12,13 +12,13 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Module.class)
@Mixin(value = Module.class, remap = false)
public class ModuleMixin {
@Mutable @Shadow(remap = false) public String name;
@Mutable @Shadow public String name;
@Mutable @Shadow(remap = false) public String title;
@Mutable @Shadow public String title;
@Inject(method = "<init>", at = @At("TAIL"), remap = false)
@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(Category category, String name, String description, CallbackInfo info) {
if (RejectsConfig.get().duplicateModuleNames) {
this.name = RejectsUtils.getModuleName(name);

View File

@@ -0,0 +1,39 @@
package anticope.rejects.mixin.meteor.modules;
import anticope.rejects.utils.RejectsUtils;
import meteordevelopment.meteorclient.settings.DoubleSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.combat.AimAssist;
import net.minecraft.entity.Entity;
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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(value = AimAssist.class, remap = false)
public class AimAssistMixin {
@Shadow @Final private SettingGroup sgGeneral;
private Setting<Double> fov;
@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
fov = sgGeneral.add(new DoubleSetting.Builder()
.name("fov")
.description("Will only aim entities in the fov.")
.defaultValue(360)
.min(0)
.max(360)
.build()
);
}
@Inject(method = "lambda$onTick$1", at = @At(value = "RETURN", ordinal = 5), cancellable = true)
private void onCheckEntity(Entity entity, CallbackInfoReturnable<Boolean> info) {
info.setReturnValue(RejectsUtils.inFov(entity, fov.get()));
}
}

View File

@@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public abstract class InventoryTweaksMixin implements IInventoryTweaks {
private Runnable callback;
@Inject(method = "lambda$steal$3", at = @At("RETURN"))
@Inject(method = "lambda$steal$4", at = @At("RETURN"))
private void afterSteal(ScreenHandler handler, CallbackInfo info) {
if (callback != null) {
callback.run();

View File

@@ -0,0 +1,41 @@
package anticope.rejects.mixin.meteor.modules;
import anticope.rejects.utils.RejectsUtils;
import meteordevelopment.meteorclient.settings.DoubleSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.combat.KillAura;
import net.minecraft.entity.Entity;
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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(value = KillAura.class, remap = false)
public class KillAuraMixin {
@Shadow
@Final
private SettingGroup sgGeneral;
private Setting<Double> fov;
@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
fov = sgGeneral.add(new DoubleSetting.Builder()
.name("fov")
.description("Will only aim entities in the fov.")
.defaultValue(360)
.min(0)
.max(360)
.build()
);
}
@Inject(method = "entityCheck", at = @At(value = "RETURN", ordinal = 14), cancellable = true)
private void onReturn(Entity entity, CallbackInfoReturnable<Boolean> info) {
info.setReturnValue(info.getReturnValueZ() && RejectsUtils.inFov(entity, fov.get()));
}
}

View File

@@ -5,9 +5,14 @@ import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.utils.PostInit;
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import java.util.Random;
import static meteordevelopment.meteorclient.MeteorClient.mc;
public class RejectsUtils {
@PostInit
@@ -40,4 +45,12 @@ public class RejectsUtils {
}
return sb.toString();
}
public static boolean inFov(Entity entity, double fov) {
float[] angle = PlayerUtils.calculateAngle(entity.getBoundingBox().getCenter());
double xDist = MathHelper.angleBetween(angle[0], mc.player.getYaw());
double yDist = MathHelper.angleBetween(angle[1], mc.player.getPitch());
double angleDistance = Math.hypot(xDist, yDist);
return angleDistance <= fov;
}
}

View File

@@ -13,6 +13,8 @@
"modules.FlightMixin",
"modules.NoRenderAccessor",
"modules.AutoSignMixin",
"modules.InventoryTweaksMixin"
"modules.InventoryTweaksMixin",
"modules.KillAuraMixin",
"modules.AimAssistMixin"
]
}

View File

@@ -3,7 +3,7 @@
"package": "anticope.rejects.mixin",
"compatibilityLevel": "JAVA_16",
"client": [
"ChestBlockEntityRendererMixin",
"TexturedRenderLayersMixin",
"ClientPlayNetworkHandlerMixin",
"ClientPlayerInteractionManagerMixin",
"CommandSuggestorMixin",