-
-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathEntityRendererMixin.java
More file actions
91 lines (81 loc) · 4.15 KB
/
Copy pathEntityRendererMixin.java
File metadata and controls
91 lines (81 loc) · 4.15 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package de.hysky.skyblocker.mixins;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Local;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.config.configs.SlayersConfig;
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.SlayerManager;
import de.hysky.skyblocker.skyblock.teleport.PredictiveSmoothAOTE;
import de.hysky.skyblocker.skyblock.teleport.ResponsiveSmoothAOTE;
import de.hysky.skyblocker.utils.Boxes;
import de.hysky.skyblocker.utils.ColorUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.state.EntityRenderState;
import net.minecraft.network.chat.Component;
import net.minecraft.util.ARGB;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.jspecify.annotations.Nullable;
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.CallbackInfo;
@Mixin(EntityRenderer.class)
public class EntityRendererMixin {
@Inject(method = "extractRenderState", at = @At("TAIL"))
private void skyblocker$customGlow(CallbackInfo ci, @Local(name = "entity") Entity entity, @Local(name = "state") EntityRenderState state) {
boolean allowGlowInLivid = LividColor.allowGlow();
boolean customGlow = MobGlow.hasOrComputeMobGlow(entity);
boolean allowGlow = allowGlowInLivid && state.appearsGlowing() || customGlow;
if (allowGlow && customGlow) {
// Only use custom colour flag if the entity has no vanilla glow (so we can change Hypixel's glow colours without changing the glow's visibility)
// NB: Custom glow needs to be separate to avoid weird rendering bugs.
if (!entity.isCurrentlyGlowing()) {
state.setData(MobGlow.ENTITY_CUSTOM_GLOW_COLOUR, ARGB.opaque(MobGlow.getMobGlow(entity)));
} else {
state.outlineColor = ARGB.opaque(MobGlow.getMobGlow(entity));
}
} else if (!allowGlow) {
state.outlineColor = EntityRenderState.NO_OUTLINE;
}
}
// This is meant to be separate from the previous injection for organizational purposes.
@Inject(method = "extractRenderState", at = @At(value = "TAIL"))
private void skyblocker$mobBoundingBox(CallbackInfo ci, @Local(name = "entity") Entity entity, @Local(name = "partialTicks") float partialTicks) {
if (MobBoundingBoxes.shouldDrawMobBoundingBox(entity)) {
MobBoundingBoxes.submitBox2BeRendered(Boxes.lerpEntityBoundingBox(entity, partialTicks), MobBoundingBoxes.getBoxColor(entity));
return;
}
if (SlayerManager.shouldGlow(entity, SlayersConfig.HighlightSlayerEntities.HITBOX)) {
float[] color = ColorUtils.getFloatComponents(SkyblockerConfigManager.get().slayers.highlightColor.getRGB());
MobBoundingBoxes.submitBox2BeRendered(Boxes.lerpEntityBoundingBox(entity, partialTicks), color);
}
}
// This is meant to be separate from the previous injection for organizational purposes.
@Inject(method = "extractRenderState", at = @At(value = "TAIL"))
private void skyblocker$movePlayerRenderPos(CallbackInfo ci, @Local(name = "entity") Entity entity, @Local(name = "state") EntityRenderState state, @Local(name = "partialTicks") float partialTicks) {
Minecraft client = Minecraft.getInstance();
if (entity == client.player && !client.options.getCameraType().isFirstPerson()) {
Vec3 pos;
if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.predictive) {
pos = PredictiveSmoothAOTE.getInterpolatedPlayerPos();
} else {
pos = ResponsiveSmoothAOTE.getInterpolatedPlayerPos(partialTicks);
}
if (pos != null)
{
state.x = pos.x;
state.y = pos.y;
state.z = pos.z;
}
}
}
@ModifyReturnValue(method = "getNameTag", at = @At("RETURN"))
private <T extends Entity> @Nullable Component skyblocker$applyCustomName(@Nullable Component original, T entity) {
Component customName = entity.skyblocker$getCustomName();
return customName != null ? customName : original;
}
}