Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat committed May 3, 2024
1 parent 52eee5c commit 2f4d59a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public abstract class WorldRendererMixin {
@Shadow
private Framebuffer entityOutlinesFramebuffer;

@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 @@ -105,20 +107,19 @@ private void onRender(MatrixStack matrices, float tickDelta, long limitTime, boo

@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z"))
private boolean shouldMobGlow(boolean original, @Local Entity entity) {
ESP esp = Modules.get().get(ESP.class);
Color entityGlowColor = esp.getColor(entity);
if (entityGlowColor == null) return original;
return esp.isGlow() && !esp.shouldSkip(entity) || original;
if (!getESP().isGlow() || getESP().shouldSkip(entity)) return original;

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

@WrapOperation(method = "render", 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) {
ESP esp = Modules.get().get(ESP.class);
Color entityGlowColor = esp.getColor(entity.get());
if (esp.isGlow() && !esp.shouldSkip(entity.get()) && entityGlowColor != null) {
instance.setColor(entityGlowColor.r, entityGlowColor.g, entityGlowColor.b, entityGlowColor.a);
} else {
original.call(instance, red, green, blue, alpha);
if (!getESP().isGlow() || getESP().shouldSkip(entity.get())) original.call(instance, red, green, blue, alpha);
else {
Color color = getESP().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 Down Expand Up @@ -160,4 +161,13 @@ private static int getLightmapCoordinatesModifySkyLight(int sky) {
private static int getLightmapCoordinatesModifyBlockLight(int sky) {
return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.BLOCK), sky);
}

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

return esp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public String getInfoString() {
public boolean isShader() {
return isActive() && mode.get() == Mode.Shader;
}

public boolean isGlow() {
return isActive() && mode.get() == Mode.Glow;
}
Expand All @@ -360,6 +360,7 @@ public enum Mode {
_2D,
Shader,
Glow;

@Override
public String toString() {
return this == _2D ? "2D" : super.toString();
Expand Down

0 comments on commit 2f4d59a

Please sign in to comment.