Search in sources :

Example 1 with GearElytraItem

use of net.silentchaos512.gear.item.gear.GearElytraItem in project Silent-Gear by SilentChaos512.

the class GearElytraLayer method render.

@Override
public void render(@Nonnull PoseStack matrixStackIn, @Nonnull MultiBufferSource bufferIn, int packedLightIn, T entityIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
    ItemStack stack = entityIn.getItemBySlot(EquipmentSlot.CHEST);
    if (stack.getItem() instanceof GearElytraItem) {
        ResourceLocation resourcelocation;
        if (entityIn instanceof AbstractClientPlayer) {
            AbstractClientPlayer abstractclientplayerentity = (AbstractClientPlayer) entityIn;
            boolean hasElytra = abstractclientplayerentity.isElytraLoaded() && abstractclientplayerentity.getElytraTextureLocation() != null;
            boolean hasCape = abstractclientplayerentity.isCapeLoaded() && abstractclientplayerentity.getCloakTextureLocation() != null && abstractclientplayerentity.isModelPartShown(PlayerModelPart.CAPE);
            if (hasElytra) {
                resourcelocation = abstractclientplayerentity.getElytraTextureLocation();
            } else if (hasCape) {
                resourcelocation = abstractclientplayerentity.getCloakTextureLocation();
            } else {
                resourcelocation = TEXTURE;
            }
        } else {
            resourcelocation = TEXTURE;
        }
        matrixStackIn.pushPose();
        matrixStackIn.translate(0.0D, 0.0D, 0.125D);
        this.getParentModel().copyPropertiesTo(this.modelElytra);
        this.modelElytra.setupAnim(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
        VertexConsumer ivertexbuilder = ItemRenderer.getArmorFoilBuffer(bufferIn, this.modelElytra.renderType(resourcelocation), false, stack.isEnchanted());
        Color color = new Color(GearClientHelper.getColor(stack, PartType.MAIN));
        this.modelElytra.renderToBuffer(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
        matrixStackIn.popPose();
    }
}
Also used : AbstractClientPlayer(net.minecraft.client.player.AbstractClientPlayer) ResourceLocation(net.minecraft.resources.ResourceLocation) Color(net.silentchaos512.utils.Color) GearElytraItem(net.silentchaos512.gear.item.gear.GearElytraItem) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)1 AbstractClientPlayer (net.minecraft.client.player.AbstractClientPlayer)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 ItemStack (net.minecraft.world.item.ItemStack)1 GearElytraItem (net.silentchaos512.gear.item.gear.GearElytraItem)1 Color (net.silentchaos512.utils.Color)1