Search in sources :

Example 1 with ModelTexture

use of com.tom.cpm.client.ModelTexture in project CustomPlayerModels by tom5454.

the class CapeFeatureRendererMixin method onRender.

@Inject(at = @At("HEAD"), method = "render" + "(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I" + "Lnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", cancellable = true)
public void onRender(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, AbstractClientPlayerEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, CallbackInfo cbi) {
    Player<?> pl = CustomPlayerModelsClient.INSTANCE.manager.getBoundPlayer();
    if (pl != null) {
        ModelDefinition def = pl.getModelDefinition();
        if (def != null && def.hasRoot(RootModelType.CAPE)) {
            ItemStack chestplate = entitylivingbaseIn.getEquippedStack(EquipmentSlot.CHEST);
            if (!entitylivingbaseIn.isInvisible() && entitylivingbaseIn.isPartVisible(PlayerModelPart.CAPE) && chestplate.getItem() != Items.ELYTRA) {
                Identifier defLoc = entitylivingbaseIn.getCapeTexture();
                if (defLoc == null)
                    defLoc = CustomPlayerModelsClient.DEFAULT_CAPE;
                ModelTexture mt = new ModelTexture(defLoc);
                CustomPlayerModelsClient.mc.getPlayerRenderManager().rebindModel(getContextModel());
                CustomPlayerModelsClient.mc.getPlayerRenderManager().bindSkin(getContextModel(), mt, TextureSheetType.CAPE);
                if (mt.getTexture() != null) {
                    VertexConsumer buffer = bufferIn.getBuffer(mt.getRenderType());
                    CustomPlayerModelsClient.renderCape(matrixStackIn, buffer, packedLightIn, entitylivingbaseIn, partialTicks, getContextModel(), def);
                }
            }
            cbi.cancel();
        }
    }
}
Also used : Identifier(net.minecraft.util.Identifier) ModelDefinition(com.tom.cpm.shared.definition.ModelDefinition) VertexConsumer(net.minecraft.client.render.VertexConsumer) ItemStack(net.minecraft.item.ItemStack) ModelTexture(com.tom.cpm.client.ModelTexture) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with ModelTexture

use of com.tom.cpm.client.ModelTexture in project CustomPlayerModels by tom5454.

the class SkullBlockEntityRendererMixin method onGetRenderTypeNoSkin.

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getEntityCutoutNoCull(" + "Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;"), method = "getRenderLayer(Lnet/minecraft/block/SkullBlock$SkullType;Lcom/mojang/authlib/GameProfile;)" + "Lnet/minecraft/client/render/RenderLayer;")
private static RenderLayer onGetRenderTypeNoSkin(Identifier resLoc, SkullBlock.SkullType skullType, GameProfile gameProfileIn) {
    if (RefHolder.CPM_MODELS == null)
        return RenderLayer.getEntityCutoutNoCull(resLoc);
    SkullBlockEntityModel model = RefHolder.CPM_MODELS.get(skullType);
    RefHolder.CPM_MODELS = null;
    ModelTexture mt = new ModelTexture(resLoc);
    CustomPlayerModelsClient.mc.getPlayerRenderManager().bindSkin(model, mt, TextureSheetType.SKIN);
    return mt.getRenderType();
}
Also used : SkullBlockEntityModel(net.minecraft.client.render.block.entity.SkullBlockEntityModel) ModelTexture(com.tom.cpm.client.ModelTexture) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 3 with ModelTexture

use of com.tom.cpm.client.ModelTexture in project CustomPlayerModels by tom5454.

the class CPMASMClientHooks method onGetEntityTexture.

public static ResourceLocation onGetEntityTexture(ResourceLocation rl, PlayerRenderer model) {
    ModelTexture tex = new ModelTexture(rl);
    ClientProxy.mc.getPlayerRenderManager().bindSkin(model.getModel(), tex, TextureSheetType.SKIN);
    return tex.getTexture();
}
Also used : ModelTexture(com.tom.cpm.client.ModelTexture)

Example 4 with ModelTexture

use of com.tom.cpm.client.ModelTexture in project CustomPlayerModels by tom5454.

the class CapeLayerMixin method onRender.

@Inject(at = @At("HEAD"), method = "render" + "(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I" + "Lnet/minecraft/client/player/AbstractClientPlayer;FFFFFF)V", cancellable = true)
public void onRender(PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn, AbstractClientPlayer entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, CallbackInfo cbi) {
    Player<?> pl = ClientProxy.INSTANCE.manager.getBoundPlayer();
    if (pl != null) {
        ModelDefinition def = pl.getModelDefinition();
        if (def != null && def.hasRoot(RootModelType.CAPE)) {
            ItemStack chestplate = entitylivingbaseIn.getItemBySlot(EquipmentSlot.CHEST);
            if (!entitylivingbaseIn.isInvisible() && entitylivingbaseIn.isModelPartShown(PlayerModelPart.CAPE) && chestplate.getItem() != Items.ELYTRA) {
                ResourceLocation defLoc = entitylivingbaseIn.getCloakTextureLocation();
                if (defLoc == null)
                    defLoc = ClientProxy.DEFAULT_CAPE;
                ModelTexture mt = new ModelTexture(defLoc);
                ClientProxy.mc.getPlayerRenderManager().rebindModel(getParentModel());
                ClientProxy.mc.getPlayerRenderManager().bindSkin(getParentModel(), mt, TextureSheetType.CAPE);
                if (mt.getTexture() != null) {
                    VertexConsumer buffer = bufferIn.getBuffer(mt.getRenderType());
                    ClientProxy.renderCape(matrixStackIn, buffer, packedLightIn, entitylivingbaseIn, partialTicks, getParentModel(), def);
                }
            }
            cbi.cancel();
        }
    }
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) ModelDefinition(com.tom.cpm.shared.definition.ModelDefinition) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) ItemStack(net.minecraft.world.item.ItemStack) ModelTexture(com.tom.cpm.client.ModelTexture) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with ModelTexture

use of com.tom.cpm.client.ModelTexture in project CustomPlayerModels by tom5454.

the class ElytraLayerMixin method onGetRenderTypeNoSkin.

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderType;armorCutoutNoCull(" + "Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/RenderType;", ordinal = 0), method = "render(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;I" + "Lnet/minecraft/entity/LivingEntity;FFFFFF)V")
private RenderType onGetRenderTypeNoSkin(ResourceLocation resLoc, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, LivingEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
    if (getParentModel() instanceof BipedModel) {
        ModelTexture mt = new ModelTexture(resLoc, PlayerRenderManager.armor);
        ClientProxy.mc.getPlayerRenderManager().bindSkin(elytraModel, mt, TextureSheetType.ELYTRA);
        return mt.getRenderType();
    }
    return RenderType.armorCutoutNoCull(resLoc);
}
Also used : BipedModel(net.minecraft.client.renderer.entity.model.BipedModel) ModelTexture(com.tom.cpm.client.ModelTexture) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

ModelTexture (com.tom.cpm.client.ModelTexture)16 Redirect (org.spongepowered.asm.mixin.injection.Redirect)11 ModelDefinition (com.tom.cpm.shared.definition.ModelDefinition)4 Inject (org.spongepowered.asm.mixin.injection.Inject)4 ItemStack (net.minecraft.item.ItemStack)3 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 SkullModelBase (net.minecraft.client.model.SkullModelBase)2 SkullBlockEntityModel (net.minecraft.client.render.block.entity.SkullBlockEntityModel)2 GenericHeadModel (net.minecraft.client.renderer.entity.model.GenericHeadModel)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)1 HumanoidModel (net.minecraft.client.model.HumanoidModel)1 VertexConsumer (net.minecraft.client.render.VertexConsumer)1 BipedEntityModel (net.minecraft.client.render.entity.model.BipedEntityModel)1 BipedModel (net.minecraft.client.renderer.entity.model.BipedModel)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 Identifier (net.minecraft.util.Identifier)1 ItemStack (net.minecraft.world.item.ItemStack)1