Search in sources :

Example 21 with PlayerPointer

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

the class EquipmentWardrobeHandler method onRender.

@SubscribeEvent
public void onRender(RenderPlayerEvent.Pre event) {
    EntityPlayer player = event.entityPlayer;
    if (player instanceof MannequinFakePlayer) {
        return;
    }
    if (player.getGameProfile() == null) {
        return;
    }
    if (player instanceof FakePlayer) {
        return;
    }
    // Hide the head overlay if the player has turned it off.
    PlayerPointer playerPointer = new PlayerPointer(player);
    RenderPlayer renderer = event.renderer;
    if (equipmentWardrobeMap.containsKey(playerPointer)) {
        EquipmentWardrobeData ewd = equipmentWardrobeMap.get(playerPointer);
        renderer.modelBipedMain.bipedHeadwear.isHidden = ewd.headOverlay;
        if (!ewd.headOverlay) {
            if (SkinModelRenderer.INSTANCE.playerHasCustomHead(player)) {
                renderer.modelBipedMain.bipedHeadwear.isHidden = true;
            }
        }
    }
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RenderPlayer(net.minecraft.client.renderer.entity.RenderPlayer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) FakePlayer(net.minecraftforge.common.util.FakePlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 22 with PlayerPointer

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

the class ModelRendererAttachment method render.

@Override
public void render(float scale) {
    if (ClientProxy.getSkinRenderType() != SkinRenderType.MODEL_ATTACHMENT) {
        return;
    }
    mc.mcProfiler.startSection("armourers player render");
    SkinModelRenderer modelRenderer = SkinModelRenderer.INSTANCE;
    EntityPlayer player = modelRenderer.targetPlayer;
    if (player == null) {
        mc.mcProfiler.endSection();
        return;
    }
    if (player instanceof MannequinFakePlayer) {
        mc.mcProfiler.endSection();
        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() };
    }
    for (int skinIndex = 0; skinIndex < ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE; skinIndex++) {
        Skin data = modelRenderer.getPlayerCustomArmour(player, skinType, skinIndex);
        if (data == null) {
            continue;
        }
        ISkinDye skinDye = modelRenderer.getPlayerDyeData(player, skinType, skinIndex);
        MovementType movmentType = MovementType.valueOf(SkinProperties.PROP_WINGS_MOVMENT_TYPE.getValue(data.getProperties()));
        int size = data.getParts().size();
        for (int i = 0; i < size; i++) {
            SkinPart partData = data.getParts().get(i);
            if (partData.getPartType() == skinPart) {
                GL11.glPushMatrix();
                if (skinType == SkinTypeRegistry.skinLegs && skinPart.getRegistryName().equals("armourers:legs.skirt")) {
                    GL11.glTranslatef(0, 12 * scale, 0);
                    if (player.isSneaking()) {
                        GL11.glRotatef(-30, 1, 0, 0);
                        GL11.glTranslatef(0, -1.25F * scale, -2F * scale);
                    }
                    if (player.isRiding()) {
                        GL11.glRotated(-70, 1F, 0F, 0F);
                    }
                }
                if (skinType == SkinTypeRegistry.skinWings) {
                    GL11.glTranslated(0, 0, scale * 2);
                    double angle = SkinUtils.getFlapAngleForWings(player, data);
                    Point3D point = new Point3D(0, 0, 0);
                    ForgeDirection axis = ForgeDirection.DOWN;
                    if (partData.getMarkerCount() > 0) {
                        point = partData.getMarker(0);
                        axis = partData.getMarkerSide(0);
                    }
                    GL11.glTranslated(scale * 0.5F, scale * 0.5F, scale * 0.5F);
                    GL11.glTranslated(scale * point.getX(), scale * point.getY(), scale * point.getZ());
                    if (skinPart.getRegistryName().equals("armourers:wings.rightWing")) {
                        angle = -angle;
                    }
                    switch(axis) {
                        case UP:
                            GL11.glRotated(angle, 0, 1, 0);
                            break;
                        case DOWN:
                            GL11.glRotated(angle, 0, -1, 0);
                            break;
                        case SOUTH:
                            GL11.glRotated(angle, 0, 0, -1);
                            break;
                        case NORTH:
                            GL11.glRotated(angle, 0, 0, 1);
                            break;
                        case EAST:
                            GL11.glRotated(angle, 1, 0, 0);
                            break;
                        case WEST:
                            GL11.glRotated(angle, -1, 0, 0);
                            break;
                        case UNKNOWN:
                            break;
                    }
                    GL11.glTranslated(scale * -point.getX(), scale * -point.getY(), scale * -point.getZ());
                    GL11.glTranslated(scale * -0.5F, scale * -0.5F, scale * -0.5F);
                }
                GL11.glEnable(GL11.GL_CULL_FACE);
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                GL11.glEnable(GL11.GL_BLEND);
                SkinPartRenderer.INSTANCE.renderPart(partData, scale, skinDye, extraColours, distance, true);
                GL11.glDisable(GL11.GL_CULL_FACE);
                GL11.glPopMatrix();
                break;
            }
        }
    }
    if (ClientProxy.useSafeTextureRender()) {
        if (player instanceof AbstractClientPlayer) {
            AbstractClientPlayer clientPlayer = (AbstractClientPlayer) player;
            Minecraft.getMinecraft().renderEngine.bindTexture(clientPlayer.getLocationSkin());
        }
    }
    mc.mcProfiler.endSection();
}
Also used : SkinModelRenderer(riskyken.armourersWorkshop.client.render.SkinModelRenderer) PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) Color(java.awt.Color) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart) MovementType(riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType) AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) MannequinFakePlayer(riskyken.armourersWorkshop.client.render.MannequinFakePlayer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData) Point3D(riskyken.armourersWorkshop.api.common.skin.Point3D) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin)

Example 23 with PlayerPointer

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

the class MessageServerSkinInfoUpdate method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    this.playerPointer = new PlayerPointer(buf);
    this.equipmentData = EntityEquipmentData.readFromByteBuf(buf);
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer)

Example 24 with PlayerPointer

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

the class GuiTabWardrobeColourSettings method drawBackgroundLayer.

@Override
public void drawBackgroundLayer(float partialTickTime, int mouseX, int mouseY) {
    GL11.glColor4f(1, 1, 1, 1);
    // Top half of GUI. (active tab)
    this.drawTexturedModalRect(this.x, this.y, 0, 0, 236, 151);
    // Bottom half of GUI. (player inventory)
    this.drawTexturedModalRect(this.x + 29, this.y + 151, 29, 151, 178, 89);
    PlayerPointer playerPointer = new PlayerPointer(entityPlayer);
    EquipmentWardrobeData newEwd = equipmentWardrobeData = ClientProxy.equipmentWardrobeHandler.getEquipmentWardrobeData(playerPointer);
    if (newEwd != null) {
        equipmentWardrobeData = newEwd;
    }
    float skinR = (float) skinColour.getRed() / 255;
    float skinG = (float) skinColour.getGreen() / 255;
    float skinB = (float) skinColour.getBlue() / 255;
    // Skin colour display
    this.drawTexturedModalRect(this.x + 68, this.y + 30, 242, 180, 14, 14);
    GL11.glColor4f(skinR, skinG, skinB, 1F);
    this.drawTexturedModalRect(this.x + 69, this.y + 31, 243, 181, 12, 12);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    float hairR = (float) hairColour.getRed() / 255;
    float hairG = (float) hairColour.getGreen() / 255;
    float hairB = (float) hairColour.getBlue() / 255;
    // Hair colour display
    this.drawTexturedModalRect(this.x + 68, this.y + 82, 242, 180, 14, 14);
    GL11.glColor4f(hairR, hairG, hairB, 1F);
    this.drawTexturedModalRect(this.x + 69, this.y + 83, 243, 181, 12, 12);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) EquipmentWardrobeData(riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)

Aggregations

PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)24 EquipmentWardrobeData (riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)11 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)8 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)6 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)4 EntityEquipmentData (riskyken.armourersWorkshop.common.skin.EntityEquipmentData)4 RenderPlayer (net.minecraft.client.renderer.entity.RenderPlayer)3 ItemStack (net.minecraft.item.ItemStack)3 FakePlayer (net.minecraftforge.common.util.FakePlayer)3 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)3 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 Color (java.awt.Color)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)2 EntityTextureInfo (riskyken.armourersWorkshop.client.render.EntityTextureInfo)2 MessageServerSkinInfoUpdate (riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinInfoUpdate)2 MessageServerSkinWardrobeUpdate (riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinWardrobeUpdate)2