Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.isxander.debugify.client.mixins.basic.mc197260;

import com.mojang.datafixers.util.Pair;
import dev.isxander.debugify.fixes.BugFix;
import dev.isxander.debugify.fixes.FixCategory;
import net.minecraft.client.Minecraft;
Expand All @@ -9,8 +8,6 @@
import net.minecraft.client.renderer.entity.state.ArmorStandRenderState;
import org.spongepowered.asm.mixin.Mixin;

import java.util.Comparator;
import java.util.stream.IntStream;
import net.minecraft.client.model.ArmorStandArmorModel;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.entity.ArmorStandRenderer;
Expand Down Expand Up @@ -39,13 +36,14 @@ protected ArmorStandRendererMixin(EntityRendererProvider.Context context) {
BlockPos mainPos = BlockPos.containing(livingEntity.x, livingEntity.y, livingEntity.z);
ClientLevel level = Minecraft.getInstance().level;

livingEntity.lightCoords = IntStream.of(-1, 0, 2, 3)
.mapToObj(operand -> {
BlockPos pos = mainPos.offset(0, operand, 0);
return Pair.of(level.getBrightness(LightLayer.BLOCK, pos), pos);
})
.max(Comparator.comparingInt(Pair::getFirst))
.map(p -> LightTexture.pack(p.getFirst(), level.getBrightness(LightLayer.SKY, p.getSecond())))
.orElse(livingEntity.lightCoords);
int maxSkyLight = 0;
int maxBlockLight = 0;
for (int offset : new int[] { -1, 0, 2, 3 }) {
BlockPos pos = mainPos.offset(0, offset, 0);
maxSkyLight = Math.max(maxSkyLight, level.getBrightness(LightLayer.SKY, pos));
maxBlockLight = Math.max(maxBlockLight, level.getBrightness(LightLayer.BLOCK, pos));
}

livingEntity.lightCoords = LightTexture.pack(maxBlockLight, maxSkyLight);
}
}