Search in sources :

Example 21 with SkinPart

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

the class ItemStackRenderHelper method renderSkinWithoutHelper.

public static void renderSkinWithoutHelper(ISkinPointer skinPointer, boolean doLodLoading) {
    Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
    if (skin == null) {
        return;
    }
    float scale = 1F / 16F;
    for (int i = 0; i < skin.getParts().size(); i++) {
        GL11.glPushMatrix();
        SkinPart skinPart = skin.getParts().get(i);
        IPoint3D offset = skinPart.getPartType().getOffset();
        GL11.glTranslated(offset.getX() * scale, (offset.getY() + 1) * scale, offset.getZ() * scale);
        SkinPartRenderer.INSTANCE.renderPart(skinPart, 0.0625F, skinPointer.getSkinDye(), null, doLodLoading);
        GL11.glPopMatrix();
    }
}
Also used : IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 22 with SkinPart

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

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

the class ModelSkinBow method render.

@Override
public void render(Entity entity, Skin armourData, boolean showSkinPaint, ISkinDye skinDye, byte[] extraColour, boolean itemRender, double distance, boolean doLodLoading) {
    if (armourData == null) {
        return;
    }
    ArrayList<SkinPart> parts = armourData.getParts();
    if (entity != null && entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        this.isSneak = player.isSneaking();
        this.isRiding = player.isRiding();
        this.isChild = player.isChild();
        this.heldItemRight = 0;
        if (player.getHeldItem() != null) {
            this.heldItemRight = 1;
        }
    }
    if (ClientProxy.isJrbaClientLoaded()) {
        this.isChild = false;
    }
    ApiRegistrar.INSTANCE.onRenderEquipment(entity, SkinTypeRegistry.skinBow);
    if (frame > parts.size() - 1) {
        frame = parts.size() - 1;
    }
    if (frame < 0 | frame > parts.size() - 1) {
        ModLogger.log("wow");
        return;
    }
    SkinPart part = parts.get(frame);
    GL11.glPushMatrix();
    if (isChild) {
        float f6 = 2.0F;
        GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6);
        GL11.glTranslatef(0.0F, 24.0F * SCALE, 0.0F);
    }
    ApiRegistrar.INSTANCE.onRenderEquipmentPart(entity, part.getPartType());
    renderRightArm(part, SCALE, skinDye, extraColour, distance, doLodLoading);
    GL11.glPopMatrix();
    GL11.glColor3f(1F, 1F, 1F);
    frame = 0;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 24 with SkinPart

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

the class GuiMiniArmourerBuildingModel method renderModels.

private void renderModels(int mouseX, int mouseY) {
    float scale = 0.0625F;
    GL11.glPushMatrix();
    GL11.glTranslatef(parent.width / 2, parent.height / 2, 500.0F);
    GL11.glScalef((float) (-zoom), (float) zoom, (float) zoom);
    GL11.glRotatef(180F, 0F, 1F, 0F);
    GL11.glRotatef(pitch, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(rotation, 0F, 1F, 0F);
    GL11.glTranslated(0, 1 * scale, 0);
    GL11.glScalef(-1, -1, 1);
    if (hoverCubeId != 0 && renderCubes != null) {
        int cubeId = (int) Math.ceil((double) hoverCubeId / 6);
        int cubeFace = cubeId * 6 - hoverCubeId;
        if (cubeId - 1 < renderCubes.size() & cubeId - 1 >= 0) {
            MiniCube tarCube = renderCubes.get(cubeId - 1);
            MiniCube newCube = new MiniCube(CubeRegistry.INSTANCE.getCubeFormId((byte) 0));
            ForgeDirection dir = GuiMiniArmourerHelper.getDirectionForCubeFace(cubeFace);
            newCube.setX((byte) (tarCube.getX() + dir.offsetX));
            newCube.setY((byte) (tarCube.getY() + dir.offsetY));
            newCube.setZ((byte) (tarCube.getZ() + dir.offsetZ));
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            IRenderBuffer buff = RenderBridge.INSTANCE;
            buff.startDrawingQuads();
            renderArmourBlock((byte) newCube.getX(), (byte) newCube.getY(), (byte) newCube.getZ(), newCube.getColour(), scale, true);
            buff.draw();
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }
    // Gui.drawRect(0, 0, parent.width, parent.height, 0xFF000000);
    drawBuildingCubes(false);
    GL11.glScalef(-1, -1, 1);
    RenderHelper.enableStandardItemLighting();
    mc.renderEngine.bindTexture(mc.thePlayer.getLocationSkin());
    if (skinPointer != null) {
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
        if (skin != null) {
            for (int i = 0; i < skin.getParts().size(); i++) {
                SkinPart part = skin.getParts().get(i);
                if (part.getPartType() == currentSkinPartType) {
                    SkinPartRenderer.INSTANCE.renderPart(part, scale, skinPointer.getSkinDye(), null, false);
                }
            }
        }
    }
    if (currentSkinPartType != null) {
        GL11.glTranslated(0, -currentSkinPartType.getBuildingSpace().getY() * scale, 0);
        currentSkinPartType.renderBuildingGuide(scale, true, false);
    // SkinRenderHelper.renderBuildingGrid(currentSkinPartType, scale);
    }
    /*
        if (currentSkinType != null) {
            SkinRenderHelper.renderBuildingGuide(currentSkinType, scale, true, false);
            SkinRenderHelper.renderBuildingGrid(currentSkinType, scale);
        }
        */
    GL11.glPopMatrix();
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) MiniCube(riskyken.armourersWorkshop.common.data.MiniCube) IRenderBuffer(riskyken.armourersWorkshop.client.render.IRenderBuffer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 25 with SkinPart

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

the class GuiMiniArmourerBuildingModel method renderFakeCubes.

private void renderFakeCubes(int mouseX, int mouseY) {
    ArrayList<SkinPart> skinParts = tileEntity.getSkinParts();
    for (int i = 0; i < skinParts.size(); i++) {
    /*
            if (skinParts.get(i).getPartType() == currentSkinPartType) {
                cubes = skinParts.get(i).getArmourData();
            }
            */
    }
    float scale = 0.0625F;
    GL11.glPushMatrix();
    GL11.glTranslatef(parent.width / 2, parent.height / 2, 500.0F);
    GL11.glScalef((float) (-zoom), (float) zoom, (float) zoom);
    GL11.glRotatef(180F, 0F, 1F, 0F);
    GL11.glRotatef(pitch, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(rotation, 0F, 1F, 0F);
    GL11.glTranslated(0, 1 * scale, 0);
    GL11.glScalef(-1, -1, 1);
    drawBuildingCubes(true);
    Color c = GuiMiniArmourerHelper.getColourAtPos(Mouse.getX(), Mouse.getY());
    hoverCubeId = GuiMiniArmourerHelper.getIdFromColour(c);
    if (Mouse.isButtonDown(0)) {
        if (!mouseLeftIsDown) {
            mouseLeftIsDown = true;
            mouseLeftDownId = hoverCubeId;
        }
    } else {
        if (mouseLeftIsDown) {
            mouseLeftIsDown = false;
            if (mouseLeftDownId != 0 & hoverCubeId == mouseLeftDownId) {
                int cubeId = (int) Math.ceil((double) mouseLeftDownId / 6);
                int cubeFace = cubeId * 6 - mouseLeftDownId;
                cubeClicked(cubeId, cubeFace, 0);
                mouseLeftDownId = 0;
            }
        }
    }
    if (Mouse.isButtonDown(1)) {
        if (!mouseRightIsDown) {
            mouseRightIsDown = true;
            mouseRightDownPosX = mouseX;
            mouseRightDownPosY = mouseY;
            mouseRightDownId = hoverCubeId;
        } else {
            rotation += lastMousePosX - mouseX;
            pitch -= lastMousePosY - mouseY;
        }
    } else {
        if (mouseRightIsDown) {
            mouseRightIsDown = false;
            if (mouseRightDownId != 0 & hoverCubeId == mouseRightDownId) {
                int cubeId = (int) Math.ceil((double) mouseRightDownId / 6);
                int cubeFace = cubeId * 6 - mouseRightDownId;
                cubeClicked(cubeId, cubeFace, 1);
                mouseRightDownId = 0;
            }
        }
    }
    GL11.glPopMatrix();
}
Also used : Color(java.awt.Color) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Aggregations

SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)26 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)10 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 ArrayList (java.util.ArrayList)5 IPoint3D (riskyken.armourersWorkshop.api.common.IPoint3D)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 ISkinPartType (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)3 SkinModelTexture (riskyken.armourersWorkshop.client.skin.SkinModelTexture)3 CubeMarkerData (riskyken.armourersWorkshop.common.skin.cubes.CubeMarkerData)3 Color (java.awt.Color)2 IOException (java.io.IOException)2 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)2 IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)2 IEntityEquipment (riskyken.armourersWorkshop.api.common.skin.IEntityEquipment)2 Rectangle3D (riskyken.armourersWorkshop.api.common.skin.Rectangle3D)2 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)2 SkinSaveException (riskyken.armourersWorkshop.common.exception.SkinSaveException)2 SkinCubeData (riskyken.armourersWorkshop.common.skin.data.SkinCubeData)2 SkinBlock (riskyken.armourersWorkshop.common.skin.type.block.SkinBlock)2 MovementType (riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType)2