Search in sources :

Example 1 with PlayerTexture

use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.

the class GuiTabArmourerDisplaySettings method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button.id == 8) {
        String username = textUserSkin.getText().trim();
        PacketHandler.networkWrapper.sendToServer(new MessageClientGuiSetSkin(new PlayerTexture(username, TextureType.values()[textureTypeList.getListSelectedIndex()])));
    } else {
        PacketHandler.networkWrapper.sendToServer(new MessageClientGuiButton((byte) button.id));
    }
}
Also used : PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture) MessageClientGuiSetSkin(riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiSetSkin) MessageClientGuiButton(riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiButton)

Example 2 with PlayerTexture

use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.

the class GuiMannequinTabSkinHair method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button == selectSkinButton) {
        selectingSkinColour = true;
    }
    if (button == autoSkinButton) {
        PlayerTexture playerTexture = MannequinTextureHelper.getMannequinTexture(tileEntity);
        skinColour = autoColourSkin(playerTexture.getResourceLocation());
        ((GuiMannequin) parent).tabOffset.sendData();
    }
    if (button == selectHairButton) {
        selectingHairColour = true;
    }
    if (button == autoHairButton) {
        PlayerTexture playerTexture = MannequinTextureHelper.getMannequinTexture(tileEntity);
        hairColour = autoColourHair(playerTexture.getResourceLocation());
        ((GuiMannequin) parent).tabOffset.sendData();
    }
}
Also used : PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture)

Example 3 with PlayerTexture

use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.

the class RenderItemMannequin method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();
    GL11.glScalef(-1, -1, 1);
    GL11.glTranslatef(0, -0.5F, 0);
    float headPitch = 0F;
    float headTilt = 0F;
    float limbWobble = 0F;
    switch(type) {
        case EQUIPPED_FIRST_PERSON:
            GL11.glTranslatef(-0.6F, -0.5F, 0.6F);
            GL11.glRotatef(-60, 0, 1, 0);
            headPitch = -40F;
            headTilt = -10F;
            if (data.length >= 2) {
                if (data[1] instanceof AbstractClientPlayer & data[0] instanceof RenderBlocks) {
                    RenderBlocks renderBlocks = (RenderBlocks) data[0];
                    AbstractClientPlayer player = (AbstractClientPlayer) data[1];
                    World world = player.worldObj;
                    float partialTickTime = ModClientFMLEventHandler.renderTickTime;
                    float pitchTime = (world.getTotalWorldTime() % 10L) + partialTickTime;
                    float tiltTime = (world.getTotalWorldTime() % 8L) + partialTickTime;
                    float limbTime = (world.getTotalWorldTime() % 6L) + partialTickTime;
                    pitchTime = (pitchTime / 5) - 1;
                    tiltTime = (tiltTime / 4) - 1;
                    limbTime = (limbTime / 3) - 1;
                    float lastDistance = player.distanceWalkedModified - player.prevDistanceWalkedModified;
                    headTilt += Math.sin(tiltTime * Math.PI) * 80F * lastDistance;
                    headPitch += Math.sin(pitchTime * Math.PI) * 40F * lastDistance;
                    limbWobble += Math.sin(limbTime * Math.PI) * lastDistance / 10F;
                }
            }
            break;
        case ENTITY:
            GL11.glScalef(1.4F, 1.4F, 1.4F);
            GL11.glTranslatef(0, -0.8F, 0);
            break;
        case EQUIPPED:
            GL11.glScalef(1.2F, 1.2F, 1.2F);
            GL11.glTranslatef(-0.6F, -0.5F, 0.6F);
            GL11.glRotatef(-60, 0, 1, 0);
            break;
        case INVENTORY:
            GL11.glTranslatef(0, 0.1F, 0);
            GL11.glScalef(0.9F, 0.9F, 0.9F);
            GL11.glRotatef(180, 0, 1, 0);
            break;
        default:
            break;
    }
    PlayerTexture playerTexture = MannequinTextureHelper.getMannequinTexture(item);
    Minecraft.getMinecraft().renderEngine.bindTexture(playerTexture.getResourceLocation());
    if (item.getItem() == Item.getItemFromBlock(ModBlocks.doll)) {
        float dollScale = 0.5F;
        GL11.glScalef(dollScale, dollScale, dollScale);
    }
    float scale = 0.0625F;
    GL11.glColor3f(1F, 1F, 1F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    if (playerTexture.isSlimModel()) {
        modelAlex.render(null, 0, limbWobble, 0, headPitch, headTilt, scale, true);
    } else {
        modelSteve.render(null, 0, limbWobble, 0, headPitch, headTilt, scale, true);
    }
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) RenderBlocks(net.minecraft.client.renderer.RenderBlocks) PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture) World(net.minecraft.world.World)

Example 4 with PlayerTexture

use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.

the class MannequinTextureHelper method getMannequinTexture.

public static PlayerTexture getMannequinTexture(ItemStack itemStack) {
    PlayerTexture playerTexture = NO_TEXTURE;
    GameProfile gameProfile = null;
    String imageUrl = null;
    if (itemStack.hasTagCompound()) {
        NBTTagCompound compound = itemStack.getTagCompound();
        if (compound.hasKey(TAG_OWNER, Constants.NBT.TAG_COMPOUND)) {
            gameProfile = NBTUtil.func_152459_a(compound.getCompoundTag(TAG_OWNER));
        }
        if (compound.hasKey(TAG_IMAGE_URL, Constants.NBT.TAG_STRING)) {
            imageUrl = compound.getString(TAG_IMAGE_URL);
        }
    }
    if (gameProfile != null) {
        playerTexture = getMannequinTexture(gameProfile.getName(), TextureType.USER);
    }
    if (!StringUtils.isNullOrEmpty(imageUrl)) {
        playerTexture = getMannequinTexture(imageUrl, TextureType.URL);
    }
    return playerTexture;
}
Also used : PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture) GameProfile(com.mojang.authlib.GameProfile) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 5 with PlayerTexture

use of riskyken.armourersWorkshop.client.texture.PlayerTexture in project Armourers-Workshop by RiskyKen.

the class MannequinTextureHelper method getMannequinTexture.

public static PlayerTexture getMannequinTexture(TileEntityMannequin tileEntity) {
    PlayerTexture playerTexture = NO_TEXTURE;
    if (tileEntity.getGameProfile() != null && tileEntity.getTextureType() == TextureType.USER) {
        String name = tileEntity.getGameProfile().getName();
        playerTexture = getMannequinTexture(name, TextureType.USER);
    }
    if (!StringUtils.isNullOrEmpty(tileEntity.getImageUrl()) && tileEntity.getTextureType() == TextureType.URL) {
        playerTexture = getMannequinTexture(tileEntity.getImageUrl(), TextureType.URL);
    }
    return playerTexture;
}
Also used : PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture)

Aggregations

PlayerTexture (riskyken.armourersWorkshop.client.texture.PlayerTexture)12 GameProfile (com.mojang.authlib.GameProfile)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 TileEntityArmourer (riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer)2 Point (java.awt.Point)1 BufferedImage (java.awt.image.BufferedImage)1 Minecraft (net.minecraft.client.Minecraft)1 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)1 RenderBlocks (net.minecraft.client.renderer.RenderBlocks)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 World (net.minecraft.world.World)1 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)1 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)1 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)1 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)1 GuiMannequin (riskyken.armourersWorkshop.client.gui.mannequin.GuiMannequin)1 GuiMannequinTabSkinHair (riskyken.armourersWorkshop.client.gui.mannequin.GuiMannequinTabSkinHair)1