Search in sources :

Example 1 with CKinetics

use of com.simibubi.create.foundation.config.CKinetics in project Create by Creators-of-Create.

the class IAirCurrentSource method getMaxDistance.

default float getMaxDistance() {
    float speed = Math.abs(this.getSpeed());
    CKinetics config = AllConfigs.SERVER.kinetics;
    float distanceFactor = Math.min(speed / config.fanRotationArgmax.get(), 1);
    float pushDistance = Mth.lerp(distanceFactor, 3, config.fanPushDistance.get());
    float pullDistance = Mth.lerp(distanceFactor, 3f, config.fanPullDistance.get());
    return this.getSpeed() > 0 ? pushDistance : pullDistance;
}
Also used : CKinetics(com.simibubi.create.foundation.config.CKinetics)

Example 2 with CKinetics

use of com.simibubi.create.foundation.config.CKinetics in project Create by Creators-of-Create.

the class ItemDescription method getKineticStats.

public static List<Component> getKineticStats(Block block) {
    List<Component> list = new ArrayList<>();
    CKinetics config = AllConfigs.SERVER.kinetics;
    Component rpmUnit = Lang.translate("generic.unit.rpm");
    boolean hasGoggles = AllItems.GOGGLES.isIn(Minecraft.getInstance().player.getItemBySlot(EquipmentSlot.HEAD));
    SpeedLevel minimumRequiredSpeedLevel;
    boolean showStressImpact;
    if (!(block instanceof IRotate)) {
        minimumRequiredSpeedLevel = SpeedLevel.NONE;
        showStressImpact = true;
    } else {
        minimumRequiredSpeedLevel = ((IRotate) block).getMinimumRequiredSpeedLevel();
        showStressImpact = !((IRotate) block).hideStressImpact();
    }
    boolean hasSpeedRequirement = minimumRequiredSpeedLevel != SpeedLevel.NONE;
    boolean hasStressImpact = StressImpact.isEnabled() && showStressImpact && BlockStressValues.getImpact(block) > 0;
    boolean hasStressCapacity = StressImpact.isEnabled() && BlockStressValues.hasCapacity(block);
    if (hasSpeedRequirement) {
        List<Component> speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high");
        int index = minimumRequiredSpeedLevel.ordinal();
        MutableComponent level = new TextComponent(makeProgressBar(3, index)).withStyle(minimumRequiredSpeedLevel.getTextColor());
        if (hasGoggles)
            level.append(String.valueOf(minimumRequiredSpeedLevel.getSpeedValue())).append(rpmUnit).append("+");
        else
            level.append(speedLevels.get(index));
        list.add(Lang.translate("tooltip.speedRequirement").withStyle(GRAY));
        list.add(level);
    }
    if (hasStressImpact) {
        List<Component> stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high");
        double impact = BlockStressValues.getImpact(block);
        StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH : (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
        int index = impactId.ordinal();
        MutableComponent level = new TextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor());
        if (hasGoggles)
            level.append(impact + "x ").append(rpmUnit);
        else
            level.append(stressLevels.get(index));
        list.add(Lang.translate("tooltip.stressImpact").withStyle(GRAY));
        list.add(level);
    }
    if (hasStressCapacity) {
        List<Component> stressCapacityLevels = Lang.translatedOptions("tooltip.capacityProvided", "low", "medium", "high");
        double capacity = BlockStressValues.getCapacity(block);
        StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW : (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH);
        int index = StressImpact.values().length - 2 - impactId.ordinal();
        MutableComponent level = new TextComponent(makeProgressBar(3, index)).withStyle(impactId.getAbsoluteColor());
        if (hasGoggles)
            level.append(capacity + "x ").append(rpmUnit);
        else
            level.append(stressCapacityLevels.get(index));
        // if (!isEngine && ((IRotate) block).showCapacityWithAnnotation())
        // level +=
        // " " + DARK_GRAY + TextFormatting.ITALIC + Lang.translate("tooltip.capacityProvided.asGenerator");
        list.add(Lang.translate("tooltip.capacityProvided").withStyle(GRAY));
        list.add(level);
        MutableComponent genSpeed = generatorSpeed(block, rpmUnit);
        if (!genSpeed.getString().isEmpty())
            list.add(new TextComponent(" ").append(genSpeed).withStyle(DARK_GRAY));
    }
    // add(linesOnShift, "");
    return list;
}
Also used : TooltipHelper.cutStringTextComponent(com.simibubi.create.foundation.item.TooltipHelper.cutStringTextComponent) TooltipHelper.cutTextComponent(com.simibubi.create.foundation.item.TooltipHelper.cutTextComponent) TextComponent(net.minecraft.network.chat.TextComponent) SpeedLevel(com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel) IRotate(com.simibubi.create.content.contraptions.base.IRotate) MutableComponent(net.minecraft.network.chat.MutableComponent) CKinetics(com.simibubi.create.foundation.config.CKinetics) ArrayList(java.util.ArrayList) TooltipHelper.cutStringTextComponent(com.simibubi.create.foundation.item.TooltipHelper.cutStringTextComponent) TooltipHelper.cutTextComponent(com.simibubi.create.foundation.item.TooltipHelper.cutTextComponent) MutableComponent(net.minecraft.network.chat.MutableComponent) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent) StressImpact(com.simibubi.create.content.contraptions.base.IRotate.StressImpact)

Aggregations

CKinetics (com.simibubi.create.foundation.config.CKinetics)2 IRotate (com.simibubi.create.content.contraptions.base.IRotate)1 SpeedLevel (com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel)1 StressImpact (com.simibubi.create.content.contraptions.base.IRotate.StressImpact)1 TooltipHelper.cutStringTextComponent (com.simibubi.create.foundation.item.TooltipHelper.cutStringTextComponent)1 TooltipHelper.cutTextComponent (com.simibubi.create.foundation.item.TooltipHelper.cutTextComponent)1 ArrayList (java.util.ArrayList)1 Component (net.minecraft.network.chat.Component)1 MutableComponent (net.minecraft.network.chat.MutableComponent)1 TextComponent (net.minecraft.network.chat.TextComponent)1