Skip to content

various esp performance patches #5599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ else if ((Object) this instanceof LivingEntity) {
@Inject(method = "getTeamColorValue", at = @At("HEAD"), cancellable = true)
private void onGetTeamColorValue(CallbackInfoReturnable<Integer> info) {
if (PostProcessShaders.rendering) {
Color color = Modules.get().get(ESP.class).getColor((Entity) (Object) this);
Color color = ESP.getColor((Entity) (Object) this);
if (color != null) info.setReturnValue(color.getPacked());
}
}
Expand All @@ -161,8 +161,7 @@ private Block modifyVelocityMultiplierBlock(Block original) {
@ModifyReturnValue(method = "isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z", at = @At("RETURN"))
private boolean isInvisibleToCanceller(boolean original) {
if (!Utils.canUpdate()) return original;
ESP esp = Modules.get().get(ESP.class);
if (Modules.get().get(NoRender.class).noInvisibility() || esp.isActive() && !esp.shouldSkip((Entity) (Object) this)) return false;
if (Modules.get().get(NoRender.class).noInvisibility() || ESP.get().isActive() && !ESP.shouldSkip((Entity) (Object) this)) return false;
return original;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,10 @@ private void handleInputEventsInjectStopUsingItem(CallbackInfo info) {

@ModifyReturnValue(method = "hasOutline", at = @At("RETURN"))
private boolean hasOutlineModifyIsOutline(boolean original, Entity entity) {
ESP esp = Modules.get().get(ESP.class);
if (esp == null) return original;
if (!esp.isGlow() || esp.shouldSkip(entity)) return original;
if (ESP.get() == null) return original;
if (!ESP.isGlow() || ESP.shouldSkip(entity)) return original;

return esp.getColor(entity) != null || original;
return ESP.getColor(entity) != null || original;
}

// Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

@Mixin(WorldRenderer.class)
public abstract class WorldRendererMixin implements IWorldRenderer {
@Unique private ESP esp;

@Shadow
protected abstract void renderEntity(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers);

Expand Down Expand Up @@ -103,7 +101,7 @@ private void onRenderHead(ObjectAllocator allocator,
@Inject(method = "renderEntity", at = @At("HEAD"))
private void renderEntity(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo info) {
draw(entity, cameraX, cameraY, cameraZ, tickDelta, vertexConsumers, matrices, PostProcessShaders.CHAMS, Color.WHITE);
draw(entity, cameraX, cameraY, cameraZ, tickDelta, vertexConsumers, matrices, PostProcessShaders.ENTITY_OUTLINE, Modules.get().get(ESP.class).getColor(entity));
draw(entity, cameraX, cameraY, cameraZ, tickDelta, vertexConsumers, matrices, PostProcessShaders.ENTITY_OUTLINE, ESP.getColor(entity));
}

@Unique
Expand All @@ -127,9 +125,9 @@ private void onRender(CallbackInfo ci) {

@WrapOperation(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OutlineVertexConsumerProvider;setColor(IIII)V"))
private void setGlowColor(OutlineVertexConsumerProvider instance, int red, int green, int blue, int alpha, Operation<Void> original, @Local LocalRef<Entity> entity) {
if (!getESP().isGlow() || getESP().shouldSkip(entity.get())) original.call(instance, red, green, blue, alpha);
if (!ESP.isGlow() || ESP.shouldSkip(entity.get())) original.call(instance, red, green, blue, alpha);
else {
Color color = getESP().getColor(entity.get());
Color color = ESP.getColor(entity.get());

if (color == null) original.call(instance, red, green, blue, alpha);
else instance.setColor(color.r, color.g, color.b, color.a);
Expand All @@ -141,15 +139,6 @@ private void onResized(int width, int height, CallbackInfo info) {
PostProcessShaders.onResized(width, height);
}

@Unique
private ESP getESP() {
if (esp == null) {
esp = Modules.get().get(ESP.class);
}

return esp;
}

// IWorldRenderer

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import meteordevelopment.meteorclient.systems.friends.Friends;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
import meteordevelopment.meteorclient.utils.render.NametagUtils;
import meteordevelopment.meteorclient.utils.render.WireframeEntityRenderer;
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -31,6 +33,7 @@
import java.util.Set;

public class ESP extends Module {
private static ESP esp;
private final SettingGroup sgGeneral = settings.getDefaultGroup();
private final SettingGroup sgColors = settings.createGroup("Colors");

Expand Down Expand Up @@ -297,21 +300,35 @@ private boolean checkCorner(double x, double y, double z, Vector3d min, Vector3d

// Utils

public boolean shouldSkip(Entity entity) {
if (!entities.get().contains(entity.getType())) return true;
if (entity == mc.player && ignoreSelf.get()) return true;
if (entity == mc.cameraEntity && mc.options.getPerspective().isFirstPerson()) return true;
public static ESP get() {
if (esp == null) {
esp = Modules.get().get(ESP.class);
}

return esp;
}

public static boolean shouldSkip(Entity entity) {
ESP esp = get();

if (!esp.entities.get().contains(entity.getType())) return true;
if (entity == MinecraftClient.getInstance().player && esp.ignoreSelf.get()) return true;
if (entity == MinecraftClient.getInstance().cameraEntity
&& MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) return true;
return !EntityUtils.isInRenderDistance(entity);
}

public Color getColor(Entity entity) {
if (!entities.get().contains(entity.getType())) return null;
public static Color getColor(Entity entity) {
ESP esp = get();

if (!esp.isActive()) return null;
if (!esp.entities.get().contains(entity.getType())) return null;

double alpha = getFadeAlpha(entity);
double alpha = esp.getFadeAlpha(entity);
if (alpha == 0) return null;

Color color = getEntityTypeColor(entity);
return baseColor.set(color.r, color.g, color.b, (int) (color.a * alpha));
Color color = esp.getEntityTypeColor(entity);
return esp.baseColor.set(color.r, color.g, color.b, (int) (color.a * alpha));
}

private double getFadeAlpha(Entity entity) {
Expand Down Expand Up @@ -346,12 +363,14 @@ public String getInfoString() {
return Integer.toString(count);
}

public boolean isShader() {
return isActive() && mode.get() == Mode.Shader;
public static boolean isShader() {
ESP esp = get();
return esp.isActive() && esp.mode.get() == Mode.Shader;
}

public boolean isGlow() {
return isActive() && mode.get() == Mode.Glow;
public static boolean isGlow() {
ESP esp = get();
return esp.isActive() && esp.mode.get() == Mode.Glow;
}

public enum Mode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@

import meteordevelopment.meteorclient.renderer.MeshRenderer;
import meteordevelopment.meteorclient.renderer.MeteorRenderPipelines;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.ESP;
import net.minecraft.entity.Entity;

public class EntityOutlineShader extends EntityShader {
private static ESP esp;

public EntityOutlineShader() {
init(MeteorRenderPipelines.POST_OUTLINE);
}

@Override
protected boolean shouldDraw() {
if (esp == null) esp = Modules.get().get(ESP.class);
return esp.isShader();
return ESP.isShader();
}

@Override
public boolean shouldDraw(Entity entity) {
if (!shouldDraw()) return false;
return !esp.shouldSkip(entity);
return !ESP.shouldSkip(entity);
}

@Override
protected void setupPass(MeshRenderer renderer) {
ESP esp = ESP.get();
renderer.uniform("OutlineData", OutlineUniforms.write(
esp.outlineWidth.get(),
esp.fillOpacity.get().floatValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import com.mojang.blaze3d.systems.RenderSystem;
import meteordevelopment.meteorclient.mixininterface.IWorldRenderer;

import java.util.OptionalInt;

import static meteordevelopment.meteorclient.MeteorClient.mc;

public abstract class EntityShader extends PostProcessShader {
@Override
public boolean beginRender() {
if (super.beginRender()) {
RenderSystem.getDevice().createCommandEncoder().createRenderPass(() -> "Meteor EntityShader", framebuffer.getColorAttachmentView(), OptionalInt.of(0)).close();
RenderSystem.getDevice().createCommandEncoder().clearColorTexture(framebuffer.getColorAttachment(), 0);
return true;
}

Expand Down