Search in sources :

Example 11 with Skin

use of riskyken.armourersWorkshop.common.skin.data.Skin in project Armourers-Workshop by RiskyKen.

the class SkinModelRenderer method onRenderSpecialsPost.

@SubscribeEvent
public void onRenderSpecialsPost(RenderPlayerEvent.Specials.Post event) {
    if (ClientProxy.getSkinRenderType() != SkinRenderType.RENDER_EVENT) {
        return;
    }
    EntityPlayer player = event.entityPlayer;
    RenderPlayer render = event.renderer;
    if (player.getGameProfile() == null) {
        return;
    }
    PlayerPointer playerPointer = new PlayerPointer(player);
    if (!playerEquipmentMap.containsKey(playerPointer)) {
        return;
    }
    double distance = Minecraft.getMinecraft().thePlayer.getDistance(player.posX, player.posY, player.posZ);
    if (distance > ConfigHandlerClient.maxSkinRenderDistance) {
        return;
    }
    EquipmentWardrobeData ewd = ClientProxy.equipmentWardrobeHandler.getEquipmentWardrobeData(new PlayerPointer(player));
    byte[] extraColours = null;
    if (ewd != null) {
        Color skinColour = new Color(ewd.skinColour);
        Color hairColour = new Color(ewd.hairColour);
        extraColours = new byte[] { (byte) skinColour.getRed(), (byte) skinColour.getGreen(), (byte) skinColour.getBlue(), (byte) hairColour.getRed(), (byte) hairColour.getGreen(), (byte) hairColour.getBlue() };
    }
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    for (int slot = 0; slot < 4; slot++) {
        for (int skinIndex = 0; skinIndex < ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE; skinIndex++) {
            if (slot == SkinTypeRegistry.skinHead.getVanillaArmourSlotId()) {
                Skin data = getPlayerCustomArmour(player, SkinTypeRegistry.skinHead, skinIndex);
                ISkinDye dye = getPlayerDyeData(player, SkinTypeRegistry.skinHead, skinIndex);
                if (data != null) {
                    customHead.render(player, render.modelBipedMain, data, false, dye, extraColours, false, distance, true);
                }
            }
            if (slot == SkinTypeRegistry.skinChest.getVanillaArmourSlotId()) {
                Skin data = getPlayerCustomArmour(player, SkinTypeRegistry.skinChest, skinIndex);
                ISkinDye dye = getPlayerDyeData(player, SkinTypeRegistry.skinChest, skinIndex);
                if (data != null) {
                    customChest.render(player, render.modelBipedMain, data, false, dye, extraColours, false, distance, true);
                }
            }
            if (slot == SkinTypeRegistry.skinLegs.getVanillaArmourSlotId()) {
                Skin data = getPlayerCustomArmour(player, SkinTypeRegistry.skinLegs, skinIndex);
                ISkinDye dye = getPlayerDyeData(player, SkinTypeRegistry.skinLegs, skinIndex);
                if (data != null) {
                    customLegs.render(player, render.modelBipedMain, data, false, dye, extraColours, false, distance, true);
                }
            }
            if (slot == SkinTypeRegistry.skinSkirt.getVanillaArmourSlotId()) {
                Skin data = getPlayerCustomArmour(player, SkinTypeRegistry.skinSkirt, skinIndex);
                ISkinDye dye = getPlayerDyeData(player, SkinTypeRegistry.skinSkirt, skinIndex);
                if (data != null) {
                    customSkirt.render(player, render.modelBipedMain, data, false, dye, extraColours, false, distance, true);
                }
            }
            if (slot == SkinTypeRegistry.skinFeet.getVanillaArmourSlotId()) {
                Skin data = getPlayerCustomArmour(player, SkinTypeRegistry.skinFeet, skinIndex);
                ISkinDye dye = getPlayerDyeData(player, SkinTypeRegistry.skinFeet, skinIndex);
                if (data != null) {
                    customFeet.render(player, render.modelBipedMain, data, false, dye, extraColours, false, distance, true);
                }
            }
            if (slot == 0) {
                Skin data = getPlayerCustomArmour(player, SkinTypeRegistry.skinWings, skinIndex);
                ISkinDye dye = getPlayerDyeData(player, SkinTypeRegistry.skinWings, skinIndex);
                if (data != null) {
                    customWings.render(player, render.modelBipedMain, data, false, dye, extraColours, false, distance, true);
                }
            }
        }
    }
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) Color(java.awt.Color) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) AbstractModelSkin(riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin) RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 12 with Skin

use of riskyken.armourersWorkshop.common.skin.data.Skin in project Armourers-Workshop by RiskyKen.

the class SkinModelRenderer method renderEquipmentPartFromStack.

public boolean renderEquipmentPartFromStack(Entity entity, ItemStack stack, ModelBiped modelBiped, byte[] extraColours, double distance, boolean doLodLoading) {
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
    if (skinPointer == null) {
        return false;
    }
    Skin data = getCustomArmourItemData(skinPointer);
    return renderEquipmentPart(entity, modelBiped, data, skinPointer.getSkinDye(), extraColours, distance, doLodLoading);
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) AbstractModelSkin(riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)

Example 13 with Skin

use of riskyken.armourersWorkshop.common.skin.data.Skin in project Armourers-Workshop by RiskyKen.

the class RenderSkinnedArrow method doRender.

@Override
public void doRender(EntityArrow entityArrow, double x, double y, double z, float yaw, float partialTickTime) {
    if (entityArrow.shootingEntity != null && entityArrow.shootingEntity instanceof EntityClientPlayerMP) {
        EntityClientPlayerMP player = (EntityClientPlayerMP) entityArrow.shootingEntity;
        IEntityEquipment entityEquipment = equipmentModelRenderer.getPlayerCustomEquipmentData(player);
        if (entityEquipment != null && entityEquipment.haveEquipment(SkinTypeRegistry.skinBow, 0)) {
            ISkinPointer skinPointer = entityEquipment.getSkinPointer(SkinTypeRegistry.skinBow, 0);
            if (ClientSkinCache.INSTANCE.isSkinInCache(skinPointer)) {
                Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
                if (skin != null) {
                    SkinPart skinPart = skin.getPart("armourers:bow.arrow");
                    if (skinPart != null) {
                        ModRenderHelper.enableAlphaBlend();
                        renderArrowSkin(entityArrow, x, y, z, partialTickTime, skinPart, skinPointer.getSkinDye());
                        ModRenderHelper.disableAlphaBlend();
                        return;
                    }
                }
            } else {
                ClientSkinCache.INSTANCE.requestSkinFromServer(skinPointer);
            }
        }
    }
    super.doRender(entityArrow, x, y, z, yaw, partialTickTime);
}
Also used : EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) IEntityEquipment(riskyken.armourersWorkshop.api.common.skin.IEntityEquipment) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 14 with Skin

use of riskyken.armourersWorkshop.common.skin.data.Skin in project Armourers-Workshop by RiskyKen.

the class SkinnableEntityChickenRenderer method renderEquipmentType.

private void renderEquipmentType(EntityLivingBase entity, RendererLivingEntity renderer, ISkinType skinType, IEntityEquipment equipmentData) {
    if (equipmentData.haveEquipment(skinType, 0)) {
        ISkinPointer skinPointer = equipmentData.getSkinPointer(skinType, 0);
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
        if (skin == null) {
            return;
        }
        GL11.glEnable(GL11.GL_NORMALIZE);
        float scale = 1F / 16F;
        for (int i = 0; i < skin.getParts().size(); i++) {
            SkinPartRenderer.INSTANCE.renderPart(skin.getParts().get(i), scale, skinPointer.getSkinDye(), null, false);
        }
        GL11.glDisable(GL11.GL_NORMALIZE);
    }
}
Also used : Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)

Example 15 with Skin

use of riskyken.armourersWorkshop.common.skin.data.Skin in project Armourers-Workshop by RiskyKen.

the class PlayerTextureHandler method onRender.

@SubscribeEvent(priority = EventPriority.LOW)
public void onRender(RenderPlayerEvent.Pre event) {
    useTexturePainting = ClientProxy.useTexturePainting();
    if (!useTexturePainting) {
        return;
    }
    if (!(event.entityPlayer instanceof AbstractClientPlayer)) {
        return;
    }
    AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer;
    if (player instanceof MannequinFakePlayer) {
        return;
    }
    if (player.getGameProfile() == null) {
        return;
    }
    PlayerPointer playerPointer = new PlayerPointer(player);
    EquipmentWardrobeData ewd = ClientProxy.equipmentWardrobeHandler.getEquipmentWardrobeData(playerPointer);
    if (ewd == null) {
        return;
    }
    profiler.startSection("textureBuild");
    if (playerTextureMap.containsKey(playerPointer)) {
        EntityTextureInfo textureInfo = playerTextureMap.get(playerPointer);
        textureInfo.updateTexture(player.getLocationSkin());
        textureInfo.updateHairColour(ewd.hairColour);
        textureInfo.updateSkinColour(ewd.skinColour);
        Skin[] skins = new Skin[4 * ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE];
        for (int skinIndex = 0; skinIndex < ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE; skinIndex++) {
            skins[0 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerCustomArmour(player, SkinTypeRegistry.skinHead, skinIndex);
            skins[1 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerCustomArmour(player, SkinTypeRegistry.skinChest, skinIndex);
            skins[2 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerCustomArmour(player, SkinTypeRegistry.skinLegs, skinIndex);
            skins[3 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerCustomArmour(player, SkinTypeRegistry.skinFeet, skinIndex);
        }
        ISkinDye[] dyes = new ISkinDye[4 * ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE];
        for (int skinIndex = 0; skinIndex < ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE; skinIndex++) {
            dyes[0 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerDyeData(player, SkinTypeRegistry.skinHead, skinIndex);
            dyes[1 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerDyeData(player, SkinTypeRegistry.skinChest, skinIndex);
            dyes[2 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerDyeData(player, SkinTypeRegistry.skinLegs, skinIndex);
            dyes[3 + skinIndex * 4] = SkinModelRenderer.INSTANCE.getPlayerDyeData(player, SkinTypeRegistry.skinFeet, skinIndex);
        }
        textureInfo.updateSkins(skins);
        textureInfo.updateDyes(dyes);
        ResourceLocation replacmentTexture = textureInfo.preRender();
        player.func_152121_a(Type.SKIN, replacmentTexture);
    }
    profiler.endSection();
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) EntityTextureInfo(riskyken.armourersWorkshop.client.render.EntityTextureInfo) PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) ResourceLocation(net.minecraft.util.ResourceLocation) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

Skin (riskyken.armourersWorkshop.common.skin.data.Skin)69 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)19 ItemStack (net.minecraft.item.ItemStack)11 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)11 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)10 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)10 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)10 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 IOException (java.io.IOException)6 ISkinIdentifier (riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier)6 AbstractModelSkin (riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)6 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)6 Color (java.awt.Color)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 DataInputStream (java.io.DataInputStream)4 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)4 BakedSkin (riskyken.armourersWorkshop.client.model.bake.ModelBakery.BakedSkin)4 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 BufferedInputStream (java.io.BufferedInputStream)3 ArrayList (java.util.ArrayList)3