[Mod Compatibility] Allurement prevents any changes to HorseArmorLayer RenderType from other mods
mortuusars opened this issue ยท 2 comments
In your mixin:
@Mixin(HorseArmorLayer.class)
public class HorseArmorLayerMixin {
@ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/renderer/MultiBufferSource;getBuffer(Lnet/minecraft/client/renderer/RenderType;)Lcom/mojang/blaze3d/vertex/VertexConsumer;", shift = At.Shift.AFTER))
private VertexConsumer render(VertexConsumer builderIn, PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn, Horse entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
ItemStack stack = entity.getBodyArmorItem();
AllurementUtil.setColorRuneTarget(stack);
AnimalArmorItem armorItem = (AnimalArmorItem) stack.getItem();
return ItemRenderer.getFoilBufferDirect(bufferIn, RenderType.entityCutoutNoCull(armorItem.getTexture()), false, stack.hasFoil());
}
}you're always modifying VertexBuffer which overrides any changes to RenderType applied by other mods in this method, even if horse armor is not enchanted.
Specifically it overrides my mod's (Horseman) translucent RenderType changes, because I apply it directly to RenderType and not VertexBuffer:
@WrapOperation(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/animal/horse/Horse;FFFFFF)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderType;entityCutoutNoCull(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/RenderType;"))
RenderType makeRenderLayerTranslucent(ResourceLocation location, Operation<RenderType> original, @Local(argsOnly = true) Horse horse, @Share("alpha") LocalFloatRef alpha) {
float a = HorseRenderUtils.getAlpha(horse);
alpha.set(a);
if (a < 1.0) {
return RenderType.entityTranslucent(location);
}
return original.call(location);
}Here's the issue that happens from it: mortuusars/Horseman#22
It would be nice for it to work at least some of the time, if full compatibility is not possible.
I think it may work properly if you change your mixin to WrapOperation(it should chain when multiple mods do it, IIRC) and then I can conditionally return RenderType#glintTranslucent if your mod is present.
Good call! The latest commit addresses the issue without you having to do anything conditionally - since ItemRenderer#getFoilBufferDirect takes a RenderType as a parameter I can use the one passed, which is modified by you. Based on my testing looks like it now works as intended, maintaining both the transparency and glint when the two mods are combined!