Volver al índice

src/main/java/ar/com/companeros/client/CompanionRenderer.java

package ar.com.companeros.client;

import ar.com.companeros.Companion;
import ar.com.companeros.Companeros;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.HumanoidMobRenderer;
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

/** Modelo humano con textura incluida en Minecraft; no necesita descargas ni librerías. */
public final class CompanionRenderer extends HumanoidMobRenderer<Companion, HumanoidModel<Companion>> {
    private static final ResourceLocation STEVE = new ResourceLocation("minecraft", "textures/entity/player/wide/steve.png");
    public CompanionRenderer(EntityRendererProvider.Context context) {
        super(context, new HumanoidModel<>(context.bakeLayer(ModelLayers.PLAYER)), .5F);
        addLayer(new HumanoidArmorLayer<>(this,
            new HumanoidModel<>(context.bakeLayer(ModelLayers.PLAYER_INNER_ARMOR)),
            new HumanoidModel<>(context.bakeLayer(ModelLayers.PLAYER_OUTER_ARMOR)), context.getModelManager()));
    }
    @Override public ResourceLocation getTextureLocation(Companion entity) { return STEVE; }

    @Mod.EventBusSubscriber(modid = Companeros.ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
    public static final class Registration {
        @SubscribeEvent public static void renderers(EntityRenderersEvent.RegisterRenderers event) {
            event.registerEntityRenderer(Companeros.COMPANION.get(), CompanionRenderer::new);
        }
    }
}