aboutsummaryrefslogblamecommitdiff
path: root/src/main/java/org/chrisoft/trashyaddon/mixin/EntityMixin.java
blob: 39f6bb6fa4571663793f64e724f870df2a603300 (plain) (tree)
























                                                                                        
package org.chrisoft.trashyaddon.mixin;

import com.mojang.logging.LogUtils;
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.render.postprocess.PostProcessShaders;
import net.minecraft.entity.Entity;
import org.chrisoft.trashyaddon.commands.EntityHighlightCommand;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = Entity.class, priority = 1001)
public abstract class EntityMixin {
    @Inject(method = "getTeamColorValue", at = @At("HEAD"), cancellable = true)
    private void onGetTeamColorValue(CallbackInfoReturnable<Integer> info) {
        if (PostProcessShaders.rendering) {
            Color color = EntityHighlightCommand.getEntityColor((Entity) (Object) this);
            if (color != null) {
                info.setReturnValue(color.getPacked());
                info.cancel();
            }
        }
    }
}