Allow armor to render with translucency

This commit is contained in:
Sollace 2023-09-27 12:11:20 +01:00
parent f8b21e78ba
commit 24e220bb29
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 38 additions and 7 deletions

View file

@ -0,0 +1,33 @@
package com.minelittlepony.client.render;
import net.minecraft.client.render.*;
import net.minecraft.client.render.RenderLayer.MultiPhaseParameters;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import java.util.function.BiFunction;
public class ArmorRenderLayers extends RenderPhase {
private ArmorRenderLayers() {
super(null, null, null);
}
private static final BiFunction<Identifier, Boolean, RenderLayer> ARMOR_TRANSLUCENT_NO_CULL = Util.memoize((texture, decal) -> {
return RenderLayer.of(decal ? "armor_decal_translucent_no_cull" : "armor_translucent_no_cull",
VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, VertexFormat.DrawMode.QUADS, 256, true, false, MultiPhaseParameters.builder()
.program(ARMOR_CUTOUT_NO_CULL_PROGRAM)
.texture(new RenderPhase.Texture(texture, false, false))
.transparency(TRANSLUCENT_TRANSPARENCY)
.cull(DISABLE_CULLING)
.lightmap(ENABLE_LIGHTMAP)
.overlay(ENABLE_OVERLAY_COLOR)
.layering(VIEW_OFFSET_Z_LAYERING)
.depthTest(decal ? EQUAL_DEPTH_TEST : LEQUAL_DEPTH_TEST)
.build(true)
);
});
public static RenderLayer getArmorTranslucentNoCull(Identifier texture, boolean decal) {
return ARMOR_TRANSLUCENT_NO_CULL.apply(texture, decal);
}
}

View file

@ -16,8 +16,8 @@ import java.util.function.BiFunction;
import java.util.function.Supplier;
public abstract class MagicGlow extends RenderPhase {
private MagicGlow(String name, Runnable beginAction, Runnable endAction) {
super(name, beginAction, endAction);
private MagicGlow() {
super(null, null, null);
}
private static final Supplier<RenderLayer> MAGIC = Suppliers.memoize(() -> {
@ -54,7 +54,6 @@ public abstract class MagicGlow extends RenderPhase {
}
private static class Colored extends Texture {
private final float red;
private final float green;
private final float blue;

View file

@ -97,7 +97,7 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & IP
}
private static VertexConsumer getArmorConsumer(VertexConsumerProvider provider, Identifier texture, boolean glint) {
return ItemRenderer.getArmorGlintConsumer(provider, RenderLayer.getArmorCutoutNoCull(texture), false, glint);
return ItemRenderer.getArmorGlintConsumer(provider, ArmorRenderLayers.getArmorTranslucentNoCull(texture, false), false, glint);
}
private static VertexConsumer getTrimConsumer(VertexConsumerProvider provider, ArmorMaterial material, ArmorTrim trim, ArmourLayer layer, boolean glint) {
@ -105,9 +105,8 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & IP
Sprite sprite = armorTrimsAtlas.getSprite(
layer == ArmourLayer.INNER ? trim.getLeggingsModelId(material) : trim.getGenericModelId(material)
);
RenderLayer renderLayer = ArmorRenderLayers.getArmorTranslucentNoCull(TexturedRenderLayers.ARMOR_TRIMS_ATLAS_TEXTURE, trim.getPattern().value().decal());
return sprite.getTextureSpecificVertexConsumer(
ItemRenderer.getDirectItemGlintConsumer(provider, TexturedRenderLayers.getArmorTrims(), true, glint)
);
return sprite.getTextureSpecificVertexConsumer(ItemRenderer.getDirectItemGlintConsumer(provider, renderLayer, true, glint));
}
}