mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
Allow armor to render with translucency
This commit is contained in:
parent
24a8afc508
commit
ca728ded81
3 changed files with 39 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
import com.minelittlepony.api.model.ModelWrapper;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.model.armour.*;
|
||||
import com.minelittlepony.client.render.ArmorRenderLayers;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
|
||||
|
@ -95,7 +96,7 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -103,9 +104,8 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
|
|||
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(trim.getPattern().value().decal()), true, glint)
|
||||
);
|
||||
return sprite.getTextureSpecificVertexConsumer(ItemRenderer.getDirectItemGlintConsumer(provider, renderLayer, true, glint));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue