Skip to content

Commit

Permalink
Fix filled outline glow
Browse files Browse the repository at this point in the history
  • Loading branch information
Emirlol committed Nov 1, 2024
1 parent b43c951 commit c193e57
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/main/java/de/hysky/skyblocker/mixins/WorldRendererMixin.java
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
package de.hysky.skyblocker.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef;
import de.hysky.skyblocker.skyblock.dungeon.LividColor;
import de.hysky.skyblocker.skyblock.entity.MobBoundingBoxes;
import de.hysky.skyblocker.skyblock.entity.MobGlow;
import de.hysky.skyblocker.skyblock.slayers.features.SlayerEntitiesGlow;
import net.minecraft.client.render.DefaultFramebufferSet;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.ArmorStandEntity;
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.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(WorldRenderer.class)
public class WorldRendererMixin {
@Shadow
private DefaultFramebufferSet framebufferSet;

@ModifyExpressionValue(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z"))
private boolean skyblocker$shouldMobGlow(boolean original, @Local Entity entity, @Share("hasCustomGlow") LocalBooleanRef hasCustomGlow) {
boolean allowGlow = LividColor.allowGlow();
boolean shouldGlow = MobGlow.shouldMobGlow(entity);
hasCustomGlow.set(shouldGlow);
return allowGlow && original || shouldGlow;
private boolean skyblocker$shouldMobGlow1(boolean original, @Local Entity entity, @Share("hasCustomGlow") LocalBooleanRef hasCustomGlow) {
return shouldMobGlow(original, entity, hasCustomGlow);
}

@ModifyExpressionValue(method = "getEntitiesToRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z"))
private boolean skyblocker$shouldMobGlow2(boolean original, @Local Entity entity, @Share("hasCustomGlow") LocalBooleanRef hasCustomGlow) {
return shouldMobGlow(original, entity, hasCustomGlow);
}

@ModifyVariable(method = "renderEntities",
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z"), to = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OutlineVertexConsumerProvider;setColor(IIII)V")),
at = @At("STORE"), ordinal = 0
)
private int skyblocker$modifyGlowColor(int color, @Local Entity entity, @Share("hasCustomGlow") LocalBooleanRef hasCustomGlow) {
return hasCustomGlow.get() ? MobGlow.getGlowColor(entity) : color;
@WrapOperation(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I"))
private int skyblocker$modifyGlowColor(Entity instance, Operation<Integer> original, @Local Entity entity, @Share("hasCustomGlow") LocalBooleanRef hasCustomGlow) {
return hasCustomGlow.get() ? MobGlow.getGlowColor(entity) : original.call(instance);
}

@Inject(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderEntity(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V"))
Expand All @@ -52,4 +47,12 @@ public class WorldRendererMixin {
);
}
}

@Unique
private static boolean shouldMobGlow(boolean original, Entity entity, LocalBooleanRef hasCustomGlow) {
boolean allowGlow = LividColor.allowGlow();
boolean shouldGlow = MobGlow.shouldMobGlow(entity);
hasCustomGlow.set(shouldGlow);
return allowGlow && original || shouldGlow;
}
}

0 comments on commit c193e57

Please sign in to comment.