Search in sources :

Example 1 with EquipmentWardrobeData

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

the class GuiTabWardrobeColourSettings method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button == selectSkinButton) {
        selectingSkinColour = true;
    }
    if (button == selectHairButton) {
        selectingHairColour = true;
    }
    if (button == autoSkinButton) {
        int newSkinColour = equipmentWardrobeData.autoColourSkin((AbstractClientPlayer) this.entityPlayer);
        EquipmentWardrobeData ewd = new EquipmentWardrobeData(this.equipmentWardrobeData);
        ewd.skinColour = newSkinColour;
        PacketHandler.networkWrapper.sendToServer(new MessageClientSkinWardrobeUpdate(ewd));
    }
    if (button == autoHairButton) {
        int newHairColour = equipmentWardrobeData.autoColourHair((AbstractClientPlayer) this.entityPlayer);
        EquipmentWardrobeData ewd = new EquipmentWardrobeData(this.equipmentWardrobeData);
        ewd.hairColour = newHairColour;
        PacketHandler.networkWrapper.sendToServer(new MessageClientSkinWardrobeUpdate(ewd));
    }
}
Also used : MessageClientSkinWardrobeUpdate(riskyken.armourersWorkshop.common.network.messages.client.MessageClientSkinWardrobeUpdate) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)

Example 2 with EquipmentWardrobeData

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

the class SkinModelRenderer method onRender.

@SubscribeEvent
public void onRender(RenderPlayerEvent.Pre event) {
    EntityPlayer player = event.entityPlayer;
    targetPlayer = player;
    if (ClientProxy.getSkinRenderType() == SkinRenderType.MODEL_ATTACHMENT) {
        attachModelsToBiped(event.renderer.modelBipedMain, event.renderer);
    }
    if (player.getGameProfile() == null) {
        return;
    }
    PlayerPointer playerPointer = new PlayerPointer(player);
    // A proper lady should not swing her legs around!
    if (isPlayerWearingSkirt(playerPointer)) {
        EquipmentWardrobeData ewd = ClientProxy.equipmentWardrobeHandler.getEquipmentWardrobeData(playerPointer);
        if (ewd != null && ewd.limitLimbs) {
            if (player.limbSwingAmount > 0.25F) {
                player.limbSwingAmount = 0.25F;
                player.prevLimbSwingAmount = 0.25F;
            }
        }
    }
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with EquipmentWardrobeData

use of riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData 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 4 with EquipmentWardrobeData

use of riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData 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 5 with EquipmentWardrobeData

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

the class PlayerTextureHandler method onRender.

@SubscribeEvent(priority = EventPriority.HIGH)
public void onRender(RenderPlayerEvent.Post event) {
    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("textureReset");
    if (playerTextureMap.containsKey(playerPointer)) {
        EntityTextureInfo textureInfo = playerTextureMap.get(playerPointer);
        ResourceLocation replacmentTexture = textureInfo.postRender();
        player.func_152121_a(Type.SKIN, replacmentTexture);
    } else {
        playerTextureMap.put(playerPointer, new EntityTextureInfo());
    }
    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) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

EquipmentWardrobeData (riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)14 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)11 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)5 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)3 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)3 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 Color (java.awt.Color)2 RenderPlayer (net.minecraft.client.renderer.entity.RenderPlayer)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 FakePlayer (net.minecraftforge.common.util.FakePlayer)2 EntityTextureInfo (riskyken.armourersWorkshop.client.render.EntityTextureInfo)2 MessageClientSkinWardrobeUpdate (riskyken.armourersWorkshop.common.network.messages.client.MessageClientSkinWardrobeUpdate)2 WrongUsageException (net.minecraft.command.WrongUsageException)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemStack (net.minecraft.item.ItemStack)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 Point3D (riskyken.armourersWorkshop.api.common.skin.Point3D)1