Search in sources :

Example 1 with ISkinDye

use of riskyken.armourersWorkshop.api.common.skin.data.ISkinDye 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 2 with ISkinDye

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

the class SkinModelRenderer method getPlayerDyeData.

public ISkinDye getPlayerDyeData(Entity entity, ISkinType skinType, int slotIndex) {
    if (!(entity instanceof AbstractClientPlayer)) {
        return null;
    }
    AbstractClientPlayer player = (AbstractClientPlayer) entity;
    EntityEquipmentData equipmentData = playerEquipmentMap.get(new PlayerPointer(player));
    // Look for skinned armourer.
    if (skinType.getVanillaArmourSlotId() >= 0 && skinType.getVanillaArmourSlotId() < 4 && slotIndex == 0) {
        int slot = 3 - skinType.getVanillaArmourSlotId();
        ItemStack armourStack = player.getCurrentArmor(slot);
        if (SkinNBTHelper.stackHasSkinData(armourStack)) {
            SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(armourStack);
            return sp.getSkinDye();
        }
    }
    // No skinned armour found checking the equipment wardrobe.
    if (equipmentData == null) {
        return null;
    }
    if (!equipmentData.haveEquipment(skinType, slotIndex)) {
        return null;
    }
    ISkinDye skinDye = equipmentData.getSkinPointer(skinType, slotIndex).getSkinDye();
    return skinDye;
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) EntityEquipmentData(riskyken.armourersWorkshop.common.skin.EntityEquipmentData) PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ISkinDye

use of riskyken.armourersWorkshop.api.common.skin.data.ISkinDye 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)

Example 4 with ISkinDye

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

the class RenderBlockMannequin method renderTileEntityAt.

public void renderTileEntityAt(TileEntityMannequin te, double x, double y, double z, float partialTickTime) {
    mc.mcProfiler.startSection("armourersMannequin");
    mc.mcProfiler.startSection("holidayCheck");
    isHalloweenSeason = HolidayHelper.halloween_season.isHolidayActive();
    isHalloween = HolidayHelper.halloween.isHolidayActive();
    MannequinFakePlayer fakePlayer = te.getFakePlayer();
    mc.mcProfiler.endStartSection("move");
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    ModRenderHelper.disableAlphaBlend();
    int rotaion = te.getRotation();
    GL11.glTranslated(x + 0.5D + te.getOffsetX(), y + 1.0D + te.getOffsetY(), z + 0.5D + te.getOffsetZ());
    BipedRotations rots = te.getBipedRotations();
    GL11.glRotated(Math.toDegrees(rots.chest.rotationX), 1F, 0F, 0F);
    GL11.glRotated(Math.toDegrees(rots.chest.rotationY), 0F, 1F, 0F);
    GL11.glRotated(Math.toDegrees(rots.chest.rotationZ), 0F, 0F, 1F);
    GL11.glTranslated(0, 0.5D, 0);
    GL11.glScalef(SCALE * 15, SCALE * 15, SCALE * 15);
    GL11.glTranslated(0, SCALE * -1.6F, 0);
    GL11.glScalef(-1, -1, 1);
    GL11.glRotatef(rotaion * 22.5F, 0, 1, 0);
    if (te.getIsDoll()) {
        float dollScale = 0.5F;
        GL11.glScalef(dollScale, dollScale, dollScale);
        GL11.glTranslatef(0, SCALE * 24, 0);
    }
    mc.mcProfiler.endStartSection("getTexture");
    ResourceLocation rl;
    boolean slimModel = false;
    boolean download;
    PlayerTexture playerTexture = MannequinTextureHelper.getMannequinTexture(te);
    rl = playerTexture.getResourceLocation();
    slimModel = playerTexture.isSlimModel();
    download = playerTexture.isDownloaded();
    ModelMannequin model = modelSteve;
    if (slimModel) {
        model = modelAlex;
    }
    mc.mcProfiler.endStartSection("fakePlayer");
    if (mannequinFakePlayer == null) {
        mannequinFakePlayer = new MannequinFakePlayer(te.getWorldObj(), new GameProfile(null, "[Mannequin]"));
        mannequinFakePlayer.posX = x;
        mannequinFakePlayer.posY = y;
        mannequinFakePlayer.posZ = z;
        mannequinFakePlayer.prevPosX = x;
        mannequinFakePlayer.prevPosY = y;
        mannequinFakePlayer.prevPosZ = z;
    }
    if (te.getGameProfile() != null) {
        if (te.getWorldObj() != null & fakePlayer != null) {
            fakePlayer.setEntityId(te.xCoord * 31 * -te.zCoord);
            fakePlayer.isAirBorne = te.isFlying();
            fakePlayer.capabilities.isFlying = te.isFlying();
        }
    } else {
        mannequinFakePlayer.setEntityId(te.xCoord * 31 * -te.zCoord);
        mannequinFakePlayer.isAirBorne = te.isFlying();
        mannequinFakePlayer.capabilities.isFlying = te.isFlying();
    }
    if (fakePlayer != null) {
        fakePlayer.setEntityId(te.xCoord * 31 * -te.zCoord);
        fakePlayer.isAirBorne = te.isFlying();
        fakePlayer.capabilities.isFlying = te.isFlying();
    }
    if (te.getBipedRotations() != null) {
        te.getBipedRotations().applyRotationsToBiped(model);
        te.getBipedRotations().applyRotationsToBiped(renderPlayer.modelArmor);
        te.getBipedRotations().applyRotationsToBiped(renderPlayer.modelArmorChestplate);
    }
    ApiRegistrar.INSTANCE.onRenderMannequin(te, te.getGameProfile());
    model.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F);
    model.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F);
    model.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F);
    model.bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F);
    model.bipedRightLeg.setRotationPoint(-1.9F, 12.0F, 0.0F);
    model.bipedLeftLeg.setRotationPoint(1.9F, 12.0F, 0.0F);
    rots.applyRotationsToBiped(model);
    model.bipedBody.rotateAngleX = 0;
    model.bipedBody.rotateAngleY = 0;
    model.bipedBody.rotateAngleZ = 0;
    if (isHalloween) {
        double dX = -x - 0.5F;
        double dY = -y - 1.72F;
        double dZ = -z - 0.5F;
        double yaw = Math.atan2(dZ, dX);
        double pitch = Math.atan2(Math.sqrt(dZ * dZ + dX * dX), dY) + Math.PI;
        yaw -= Math.toRadians(rotaion * 22.5F - 90F);
        pitch += Math.PI / 2D;
        model.bipedHead.rotateAngleX = (float) (pitch);
        model.bipedHead.rotateAngleY = (float) (yaw);
        model.bipedHeadwear.rotateAngleX = model.bipedHead.rotateAngleX;
        model.bipedHeadwear.rotateAngleY = model.bipedHead.rotateAngleY;
    }
    mc.mcProfiler.endStartSection("textureBuild");
    if (te.haveSkinsUpdated()) {
        te.sp = getSkinPointers(te);
    }
    if (te.sp != null) {
        ISkinPointer[] sp = te.sp;
        Skin[] skins = new Skin[sp.length];
        ISkinDye[] dyes = new ISkinDye[sp.length];
        boolean hasPaintedSkin = false;
        for (int i = 0; i < sp.length; i++) {
            if (sp[i] != null) {
                skins[i] = ClientSkinCache.INSTANCE.getSkin(sp[i]);
                dyes[i] = sp[i].getSkinDye();
                if (skins[i] != null) {
                    if (skins[i].hasPaintData() | SkinProperties.PROP_ARMOUR_OVERRIDE.getValue(skins[i].getProperties())) {
                        hasPaintedSkin = true;
                    }
                }
            }
        }
        if (hasPaintedSkin) {
            if (te.skinTexture == null) {
                te.skinTexture = new EntityTextureInfo();
            }
            te.skinTexture.updateTexture(rl);
            te.skinTexture.updateSkinColour(te.getSkinColour());
            te.skinTexture.updateHairColour(te.getHairColour());
            te.skinTexture.updateSkins(skins);
            te.skinTexture.updateDyes(dyes);
            if (te.skinTexture.getNeedsUpdate()) {
                if (lastTextureBuild + 200L < System.currentTimeMillis()) {
                    lastTextureBuild = System.currentTimeMillis();
                    rl = te.skinTexture.preRender();
                }
            } else {
                rl = te.skinTexture.preRender();
            }
        }
    }
    mc.mcProfiler.endStartSection("textureBind");
    bindTexture(rl);
    mc.mcProfiler.endStartSection("selectModelRender");
    te.getBipedRotations().hasCustomHead = hasCustomHead(te);
    boolean selectingColour = false;
    GuiMannequinTabSkinHair tabSkinHair = null;
    if (mc.currentScreen instanceof GuiMannequin) {
        GuiMannequin screen = (GuiMannequin) mc.currentScreen;
        if (screen.tileEntity == te) {
            tabSkinHair = screen.tabSkinAndHair;
            if (tabSkinHair.selectingSkinColour | tabSkinHair.selectingHairColour) {
                selectingColour = true;
            }
        }
    }
    if (selectingColour) {
        GL11.glDisable(GL11.GL_LIGHTING);
        if (te.isVisible() & !(te.getGameProfile() != null && te.getGameProfile().getName().equalsIgnoreCase("null"))) {
            renderModel(te, model, fakePlayer);
        }
        tabSkinHair.hoverColour = getColourAtPos(Mouse.getX(), Mouse.getY());
        GL11.glEnable(GL11.GL_LIGHTING);
    }
    mc.mcProfiler.endStartSection("modelRender");
    if (te.isVisible() & !(te.getGameProfile() != null && te.getGameProfile().getName().equalsIgnoreCase("null"))) {
        long time = System.currentTimeMillis();
        int fadeTime = 1000;
        int fade = (int) (time - playerTexture.getDownloadTime());
        if (playerTexture.isDownloaded() & fade < fadeTime) {
            bindTexture(AbstractClientPlayer.locationStevePng);
            renderModel(te, model, fakePlayer);
            bindTexture(rl);
            ModRenderHelper.enableAlphaBlend();
            GL11.glColor4f(1, 1, 1, fade / 1000F);
            GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
            GL11.glPolygonOffset(-3F, -3F);
            renderModel(te, model, fakePlayer);
            GL11.glPolygonOffset(0F, 0F);
            GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
            ModRenderHelper.disableAlphaBlend();
            GL11.glColor4f(1, 1, 1, 1);
        } else {
            renderModel(te, model, fakePlayer);
        }
    }
    mc.mcProfiler.endStartSection("earRender");
    if (te.getGameProfile() != null && te.getGameProfile().getName().equals("deadmau5")) {
        GL11.glPushMatrix();
        GL11.glRotated(Math.toDegrees(model.bipedHead.rotateAngleZ), 0, 0, 1);
        GL11.glRotated(Math.toDegrees(model.bipedHead.rotateAngleY), 0, 1, 0);
        GL11.glRotated(Math.toDegrees(model.bipedHead.rotateAngleX), 1, 0, 0);
        GL11.glTranslated(-5.5F * SCALE, 0, 0);
        GL11.glTranslated(0, -6.5F * SCALE, 0);
        model.bipedEars.render(SCALE);
        GL11.glTranslated(11F * SCALE, 0, 0);
        model.bipedEars.render(SCALE);
        GL11.glPopMatrix();
    }
    mc.mcProfiler.endStartSection("magicCircle");
    // Magic circle.
    if (te.isRenderExtras() & te.isVisible()) {
        Contributor contributor = Contributors.INSTANCE.getContributor(te.getGameProfile());
        if (contributor != null) {
            int offset = te.xCoord * te.yCoord * te.zCoord;
            renderMagicCircle(contributor.r, contributor.g, contributor.b, partialTickTime, offset, te.getBipedRotations().isChild);
        }
    }
    // Render items.
    mc.mcProfiler.endStartSection("equippedItems");
    double distance = Minecraft.getMinecraft().thePlayer.getDistance(te.xCoord + 0.5F, te.yCoord + 0.5F, te.zCoord + 0.5F);
    if (distance <= ConfigHandlerClient.mannequinMaxEquipmentRenderDistance) {
        renderEquippedItems(te, fakePlayer, model, distance);
    }
    mc.mcProfiler.endStartSection("reset");
    model.bipedLeftLeg.rotateAngleZ = 0F;
    model.bipedRightLeg.rotateAngleZ = 0F;
    model.bipedHead.rotateAngleZ = 0F;
    model.bipedHeadwear.rotateAngleZ = 0F;
    renderPlayer.modelArmor.bipedLeftLeg.rotateAngleZ = 0F;
    renderPlayer.modelArmor.bipedRightLeg.rotateAngleZ = 0F;
    renderPlayer.modelArmor.bipedHead.rotateAngleZ = 0F;
    renderPlayer.modelArmor.bipedHeadwear.rotateAngleZ = 0F;
    renderPlayer.modelArmorChestplate.bipedLeftLeg.rotateAngleZ = 0F;
    renderPlayer.modelArmorChestplate.bipedRightLeg.rotateAngleZ = 0F;
    renderPlayer.modelArmorChestplate.bipedHead.rotateAngleZ = 0F;
    renderPlayer.modelArmorChestplate.bipedHeadwear.rotateAngleZ = 0F;
    mc.mcProfiler.endStartSection("pop");
    GL11.glPopAttrib();
    GL11.glPopAttrib();
    GL11.glPopMatrix();
    mc.mcProfiler.endSection();
    mc.mcProfiler.endSection();
}
Also used : EntityTextureInfo(riskyken.armourersWorkshop.client.render.EntityTextureInfo) BipedRotations(riskyken.armourersWorkshop.common.data.BipedRotations) PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) GuiMannequin(riskyken.armourersWorkshop.client.gui.mannequin.GuiMannequin) Contributor(riskyken.armourersWorkshop.common.Contributors.Contributor) GuiMannequinTabSkinHair(riskyken.armourersWorkshop.client.gui.mannequin.GuiMannequinTabSkinHair) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) GameProfile(com.mojang.authlib.GameProfile) ResourceLocation(net.minecraft.util.ResourceLocation) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) ModelMannequin(riskyken.armourersWorkshop.client.model.ModelMannequin)

Example 5 with ISkinDye

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

the class SkinModelTexture method createTextureForColours.

public void createTextureForColours(Skin skin, SkinTextureKey cmk) {
    for (int ix = 0; ix < SkinTexture.TEXTURE_WIDTH; ix++) {
        for (int iy = 0; iy < SkinTexture.TEXTURE_HEIGHT; iy++) {
            int paintColour = skin.getPaintData()[ix + (iy * SkinTexture.TEXTURE_WIDTH)];
            int paintType = BitwiseUtils.getUByteFromInt(paintColour, 0);
            if (cmk != null) {
                if (paintType == 255) {
                    texture.setRGB(ix, iy, BitwiseUtils.setUByteToInt(paintColour, 0, 255));
                }
                if (paintType == 254) {
                    byte[] hairColour = cmk.getExtraColours();
                    int colour = dyeColour(new byte[] { hairColour[3], hairColour[4], hairColour[5] }, paintColour, 9, skin, cmk);
                    texture.setRGB(ix, iy, BitwiseUtils.setUByteToInt(colour, 0, 255));
                }
                if (paintType == 253) {
                    byte[] skinColour = cmk.getExtraColours();
                    int colour = dyeColour(new byte[] { skinColour[0], skinColour[1], skinColour[2] }, paintColour, 8, skin, cmk);
                    texture.setRGB(ix, iy, BitwiseUtils.setUByteToInt(colour, 0, 255));
                }
                if (paintType >= 1 & paintType <= 8) {
                    ISkinDye skinDye = cmk.getSkinDye();
                    int dyeNumber = paintType - 1;
                    if (skinDye.haveDyeInSlot(dyeNumber)) {
                        byte[] dye = skinDye.getDyeColour(dyeNumber);
                        if ((dye[3] & 0xFF) != 0) {
                            int colour = dyeColour(dye, paintColour, dyeNumber, skin, cmk);
                            texture.setRGB(ix, iy, colour);
                        }
                    } else {
                        texture.setRGB(ix, iy, BitwiseUtils.setUByteToInt(paintColour, 0, 255));
                    }
                }
            } else {
                if (paintType == 255) {
                    texture.setRGB(ix, iy, BitwiseUtils.setUByteToInt(paintColour, 0, 255));
                }
                if (paintType >= 1 & paintType <= 8) {
                    texture.setRGB(ix, iy, BitwiseUtils.setUByteToInt(paintColour, 0, 255));
                }
            }
        }
    }
}
Also used : ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)

Aggregations

ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)13 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)8 ItemStack (net.minecraft.item.ItemStack)6 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)4 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)4 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)3 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)3 EquipmentWardrobeData (riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 Color (java.awt.Color)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 Item (net.minecraft.item.Item)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)2 EntityTextureInfo (riskyken.armourersWorkshop.client.render.EntityTextureInfo)2 GameProfile (com.mojang.authlib.GameProfile)1 RenderPlayer (net.minecraft.client.renderer.entity.RenderPlayer)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 Point3D (riskyken.armourersWorkshop.api.common.skin.Point3D)1 GuiMannequin (riskyken.armourersWorkshop.client.gui.mannequin.GuiMannequin)1