1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package org.chrisoft.trashyaddon.mixin;
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.render.postprocess.PostProcessShaders;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import meteordevelopment.meteorclient.utils.render.postprocess.EntityShader;
import org.chrisoft.trashyaddon.commands.EntityHighlightCommand;
import org.chrisoft.trashyaddon.misc.AddonPostProcessingShaders;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = WorldRenderer.class, priority = 999)
public abstract class WorldRendererMixin {
@Shadow
private Framebuffer entityOutlinesFramebuffer;
@Shadow
protected abstract void renderEntity(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers);
@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) {
for (EntityShader es : AddonPostProcessingShaders.entityShaders) {
drawShaded(entity, cameraX, cameraY, cameraZ, tickDelta, vertexConsumers, matrices, es, EntityHighlightCommand.getEntityColor(entity));
}
}
@Unique
private void drawShaded(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, VertexConsumerProvider vertexConsumers, MatrixStack matrices, EntityShader shader, Color color) {
if (shader.shouldDraw(entity) && !PostProcessShaders.isCustom(vertexConsumers) && color != null) {
Framebuffer prevBuffer = this.entityOutlinesFramebuffer;
this.entityOutlinesFramebuffer = shader.framebuffer;
PostProcessShaders.rendering = true;
shader.vertexConsumerProvider.setColor(color.r, color.g, color.b, color.a);
renderEntity(entity, cameraX, cameraY, cameraZ, tickDelta, matrices, shader.vertexConsumerProvider);
PostProcessShaders.rendering = false;
this.entityOutlinesFramebuffer = prevBuffer;
}
}
}
|