Search in sources :

Example 1 with MovementType

use of riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType in project Armourers-Workshop by RiskyKen.

the class GuiTabArmourerSkinSettings method initGui.

@Override
public void initGui(int xPos, int yPos, int width, int height) {
    super.initGui(xPos, yPos, width, height);
    String guiName = tileEntity.getInventoryName();
    buttonList.clear();
    SkinProperties skinProps = tileEntity.getSkinProps();
    checkBlockGlowing = new GuiCheckBox(15, 10, 20, GuiHelper.getLocalizedControlName(guiName, "glowing"), SkinProperties.PROP_BLOCK_GLOWING.getValue(skinProps));
    checkBlockLadder = new GuiCheckBox(15, 10, 35, GuiHelper.getLocalizedControlName(guiName, "ladder"), SkinProperties.PROP_BLOCK_LADDER.getValue(skinProps));
    checkBlockNoCollision = new GuiCheckBox(15, 10, 50, GuiHelper.getLocalizedControlName(guiName, "noCollision"), SkinProperties.PROP_BLOCK_NO_COLLISION.getValue(skinProps));
    checkBlockSeat = new GuiCheckBox(15, 10, 65, GuiHelper.getLocalizedControlName(guiName, "seat"), SkinProperties.PROP_BLOCK_SEAT.getValue(skinProps));
    checkBlockMultiblock = new GuiCheckBox(15, 10, 80, GuiHelper.getLocalizedControlName(guiName, "multiblock"), SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(skinProps));
    checkBlockBed = new GuiCheckBox(15, 22, 95, GuiHelper.getLocalizedControlName(guiName, "bed"), SkinProperties.PROP_BLOCK_BED.getValue(skinProps));
    checkBlockEnderInventory = new GuiCheckBox(15, 10, 110, GuiHelper.getLocalizedControlName(guiName, "enderInventory"), SkinProperties.PROP_BLOCK_ENDER_INVENTORY.getValue(skinProps));
    checkBlockInventory = new GuiCheckBox(15, 10, 125, GuiHelper.getLocalizedControlName(guiName, "inventory"), SkinProperties.PROP_BLOCK_INVENTORY.getValue(skinProps));
    if (!checkBlockMultiblock.isChecked()) {
        checkBlockBed.enabled = false;
        checkBlockBed.setIsChecked(false);
    } else {
        checkBlockBed.enabled = true;
    }
    // TODO remove to re-enable beds
    checkBlockBed.enabled = false;
    checkBlockEnderInventory.enabled = !checkBlockInventory.isChecked();
    checkBlockInventory.enabled = !checkBlockEnderInventory.isChecked();
    if (checkBlockInventory.isChecked()) {
        checkBlockEnderInventory.setIsChecked(false);
    }
    if (checkBlockEnderInventory.isChecked()) {
        checkBlockInventory.setIsChecked(false);
    }
    inventorySize = new GuiInventorySize(10, 158, 9, 6);
    inventorySize.setSrc(TEXTURE, 176, 0);
    inventorySize.setSelection(SkinProperties.PROP_BLOCK_INVENTORY_WIDTH.getValue(skinProps), SkinProperties.PROP_BLOCK_INVENTORY_HEIGHT.getValue(skinProps));
    sliderWingIdleSpeed = new GuiCustomSlider(15, 10, 45, 154, 10, "", "ms", 200D, 10000D, SkinProperties.PROP_WINGS_IDLE_SPEED.getValue(skinProps), false, true, this);
    sliderWingFlyingSpeed = new GuiCustomSlider(15, 10, 65, 154, 10, "", "ms", 200D, 10000D, SkinProperties.PROP_WINGS_FLYING_SPEED.getValue(skinProps), false, true, this);
    sliderWingMinAngle = new GuiCustomSlider(15, 10, 85, 154, 10, "", DEGREE, -180D, 180D, SkinProperties.PROP_WINGS_MIN_ANGLE.getValue(skinProps), false, true, this);
    sliderWingMaxAngle = new GuiCustomSlider(15, 10, 105, 154, 10, "", DEGREE, -180D, 180D, SkinProperties.PROP_WINGS_MAX_ANGLE.getValue(skinProps), false, true, this);
    sliderWingIdleSpeed.setFineTuneButtons(true);
    sliderWingFlyingSpeed.setFineTuneButtons(true);
    sliderWingMinAngle.setFineTuneButtons(true);
    sliderWingMaxAngle.setFineTuneButtons(true);
    checkArmourOverrideBodyPart = new GuiCheckBox(15, 10, 20, GuiHelper.getLocalizedControlName(guiName, "overrideBodyPart"), SkinProperties.PROP_ARMOUR_OVERRIDE.getValue(skinProps));
    checkArmourHideOverlay = new GuiCheckBox(15, 10, 35, GuiHelper.getLocalizedControlName(guiName, "hideOverlay"), SkinProperties.PROP_ARMOUR_HIDE_OVERLAY.getValue(skinProps));
    MovementType skinMovmentType = MovementType.valueOf(SkinProperties.PROP_WINGS_MOVMENT_TYPE.getValue(skinProps));
    dropDownList = new GuiDropDownList(0, 10, 125, 50, "", this);
    for (int i = 0; i < MovementType.values().length; i++) {
        MovementType movementType = MovementType.values()[i];
        String unlocalizedName = "movmentType." + LibModInfo.ID.toLowerCase() + ":" + movementType.name().toLowerCase();
        String localizedName = StatCollector.translateToLocal(unlocalizedName);
        dropDownList.addListItem(localizedName, movementType.name(), true);
        if (movementType == skinMovmentType) {
            dropDownList.setListSelectedIndex(i);
        }
    }
    buttonList.add(checkBlockGlowing);
    buttonList.add(checkBlockLadder);
    buttonList.add(checkBlockNoCollision);
    buttonList.add(checkBlockSeat);
    buttonList.add(checkBlockMultiblock);
    buttonList.add(checkBlockBed);
    buttonList.add(checkBlockInventory);
    buttonList.add(checkBlockEnderInventory);
    buttonList.add(inventorySize);
    buttonList.add(sliderWingIdleSpeed);
    buttonList.add(sliderWingFlyingSpeed);
    buttonList.add(sliderWingMinAngle);
    buttonList.add(sliderWingMaxAngle);
    buttonList.add(checkArmourOverrideBodyPart);
    buttonList.add(checkArmourHideOverlay);
    buttonList.add(dropDownList);
}
Also used : GuiDropDownList(riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList) GuiInventorySize(riskyken.armourersWorkshop.client.gui.controls.GuiInventorySize) GuiCustomSlider(riskyken.armourersWorkshop.client.gui.controls.GuiCustomSlider) GuiCheckBox(riskyken.armourersWorkshop.client.gui.controls.GuiCheckBox) SkinProperties(riskyken.armourersWorkshop.common.skin.data.SkinProperties) MovementType(riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType)

Example 2 with MovementType

use of riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType in project Armourers-Workshop by RiskyKen.

the class GuiTabArmourerSkinSettings method resetValues.

public void resetValues(SkinProperties skinProperties) {
    resetting = true;
    checkBlockGlowing.setIsChecked(SkinProperties.PROP_BLOCK_GLOWING.getValue(skinProperties));
    checkBlockLadder.setIsChecked(SkinProperties.PROP_BLOCK_LADDER.getValue(skinProperties));
    checkBlockNoCollision.setIsChecked(SkinProperties.PROP_BLOCK_NO_COLLISION.getValue(skinProperties));
    checkBlockSeat.setIsChecked(SkinProperties.PROP_BLOCK_SEAT.getValue(skinProperties));
    checkBlockMultiblock.setIsChecked(SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(skinProperties));
    checkBlockBed.setIsChecked(SkinProperties.PROP_BLOCK_BED.getValue(skinProperties));
    checkBlockInventory.setIsChecked(SkinProperties.PROP_BLOCK_INVENTORY.getValue(skinProperties));
    checkBlockEnderInventory.setIsChecked(SkinProperties.PROP_BLOCK_ENDER_INVENTORY.getValue(skinProperties));
    inventorySize.setSelection(SkinProperties.PROP_BLOCK_INVENTORY_WIDTH.getValue(skinProperties), SkinProperties.PROP_BLOCK_INVENTORY_HEIGHT.getValue(skinProperties));
    inventorySize.visible = checkBlockInventory.isChecked();
    sliderWingMinAngle.setValue(SkinProperties.PROP_WINGS_MIN_ANGLE.getValue(skinProperties));
    sliderWingMinAngle.updateSlider();
    sliderWingMaxAngle.setValue(SkinProperties.PROP_WINGS_MAX_ANGLE.getValue(skinProperties));
    sliderWingMaxAngle.updateSlider();
    sliderWingIdleSpeed.setValue(SkinProperties.PROP_WINGS_IDLE_SPEED.getValue(skinProperties));
    sliderWingIdleSpeed.updateSlider();
    sliderWingFlyingSpeed.setValue(SkinProperties.PROP_WINGS_FLYING_SPEED.getValue(skinProperties));
    sliderWingFlyingSpeed.updateSlider();
    checkArmourOverrideBodyPart.setIsChecked(SkinProperties.PROP_ARMOUR_OVERRIDE.getValue(skinProperties));
    checkArmourHideOverlay.setIsChecked(SkinProperties.PROP_ARMOUR_HIDE_OVERLAY.getValue(skinProperties));
    MovementType skinMovmentType = MovementType.valueOf(SkinProperties.PROP_WINGS_MOVMENT_TYPE.getValue(skinProperties));
    for (int i = 0; i < MovementType.values().length; i++) {
        MovementType movementType = MovementType.values()[i];
        if (movementType == skinMovmentType) {
            dropDownList.setListSelectedIndex(i);
        }
    }
    resetting = false;
}
Also used : MovementType(riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType)

Example 3 with MovementType

use of riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType in project Armourers-Workshop by RiskyKen.

the class SkinUtils method getFlapAngleForWings.

public static double getFlapAngleForWings(Entity entity, Skin skin) {
    double maxAngle = SkinProperties.PROP_WINGS_MAX_ANGLE.getValue(skin.getProperties());
    double minAngle = SkinProperties.PROP_WINGS_MIN_ANGLE.getValue(skin.getProperties());
    double idleSpeed = SkinProperties.PROP_WINGS_IDLE_SPEED.getValue(skin.getProperties());
    double flyingSpeed = SkinProperties.PROP_WINGS_FLYING_SPEED.getValue(skin.getProperties());
    MovementType movmentType = MovementType.valueOf(SkinProperties.PROP_WINGS_MOVMENT_TYPE.getValue(skin.getProperties()));
    double angle = 0;
    double flapTime = idleSpeed;
    if (entity != null) {
        if (entity.isAirBorne) {
            if (entity instanceof EntityPlayer) {
                if (((EntityPlayer) entity).capabilities.isFlying) {
                    flapTime = flyingSpeed;
                }
            } else {
                flapTime = flyingSpeed;
            }
        }
        angle = (((double) System.currentTimeMillis() + entity.getEntityId()) % flapTime);
        if (movmentType == MovementType.EASE) {
            angle = Math.sin(angle / flapTime * Math.PI * 2);
        }
        if (movmentType == MovementType.LINEAR) {
            angle = angle / flapTime;
        }
    }
    double fullAngle = maxAngle - minAngle;
    if (movmentType == MovementType.LINEAR) {
        return fullAngle * angle;
    }
    return -minAngle - fullAngle * ((angle + 1D) / 2);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) MovementType(riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType)

Example 4 with MovementType

use of riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType in project Armourers-Workshop by RiskyKen.

the class ModelSkinWings method render.

@Override
public void render(Entity entity, Skin skin, boolean showSkinPaint, ISkinDye skinDye, byte[] extraColour, boolean itemRender, double distance, boolean doLodLoading) {
    if (skin == null) {
        return;
    }
    ArrayList<SkinPart> parts = skin.getParts();
    if (entity != null && entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        this.isSneak = player.isSneaking();
        this.isRiding = player.isRiding();
        this.heldItemRight = 0;
        if (player.getHeldItem() != null) {
            this.heldItemRight = 1;
        }
    }
    if (ClientProxy.isJrbaClientLoaded()) {
        this.isChild = false;
    }
    ApiRegistrar.INSTANCE.onRenderEquipment(entity, SkinTypeRegistry.skinSword);
    for (int i = 0; i < parts.size(); i++) {
        SkinPart part = parts.get(i);
        GL11.glPushMatrix();
        GL11.glTranslated(0, 0, SCALE * 2);
        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());
        double angle = 45D;
        MovementType movmentType = MovementType.valueOf(SkinProperties.PROP_WINGS_MOVMENT_TYPE.getValue(skin.getProperties()));
        angle = SkinUtils.getFlapAngleForWings(entity, skin);
        if (isSneak) {
            GL11.glRotated(28F, 1F, 0, 0);
        }
        if (part.getPartType().getPartName().equals("leftWing")) {
            renderLeftWing(part, SCALE, skinDye, extraColour, distance, angle, doLodLoading, movmentType);
        }
        if (part.getPartType().getPartName().equals("rightWing")) {
            renderRightWing(part, SCALE, skinDye, extraColour, distance, -angle, doLodLoading, movmentType);
        }
        GL11.glPopMatrix();
    }
    GL11.glColor3f(1F, 1F, 1F);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart) MovementType(riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType)

Example 5 with MovementType

use of riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType 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)

Aggregations

MovementType (riskyken.armourersWorkshop.common.skin.type.wings.SkinWings.MovementType)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)2 Color (java.awt.Color)1 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 Point3D (riskyken.armourersWorkshop.api.common.skin.Point3D)1 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)1 GuiCheckBox (riskyken.armourersWorkshop.client.gui.controls.GuiCheckBox)1 GuiCustomSlider (riskyken.armourersWorkshop.client.gui.controls.GuiCustomSlider)1 GuiDropDownList (riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList)1 GuiInventorySize (riskyken.armourersWorkshop.client.gui.controls.GuiInventorySize)1 MannequinFakePlayer (riskyken.armourersWorkshop.client.render.MannequinFakePlayer)1 SkinModelRenderer (riskyken.armourersWorkshop.client.render.SkinModelRenderer)1 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)1 EquipmentWardrobeData (riskyken.armourersWorkshop.common.skin.EquipmentWardrobeData)1 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)1 SkinProperties (riskyken.armourersWorkshop.common.skin.data.SkinProperties)1