Search in sources :

Example 1 with AbilityNaturalArmour

use of com.lying.variousoddities.species.abilities.AbilityNaturalArmour in project VariousOddities by Lyinginbedmon.

the class ScreenCharacterSheet method init.

public void init(Minecraft minecraft, int width, int height) {
    super.init(minecraft, width, height);
    this.buttons.clear();
    PlayerEntity player = Minecraft.getInstance().player;
    Types types = EnumCreatureType.getTypes(player);
    this.typesHeader = types.toHeader();
    this.health = types.getPlayerHealth();
    this.armour = 0D;
    List<Ability> passives = Lists.newArrayList();
    List<Ability> actives = Lists.newArrayList();
    for (Ability ability : AbilityRegistry.getCreatureAbilities(player).values()) {
        if (ability.getRegistryName().equals(AbilityNaturalArmour.REGISTRY_NAME))
            armour += ((AbilityNaturalArmour) ability).amount();
        if (ability.getRegistryName().equals(AbilityModifierCon.REGISTRY_NAME))
            health += ((AbilityModifier) ability).amount();
        if (ability.passive())
            passives.add(ability);
        else
            actives.add(ability);
    }
    ;
    this.isDoubleList = !actives.isEmpty();
    int listWidth = Math.max((int) (this.width * (actives.isEmpty() ? 0.6D : 0.3D)), 200);
    int listSep = (ACTION_ICON_SIZE + ACTION_ICON_SEP * 2) / 2;
    this.listPassives = new AbilityList(minecraft, isDoubleList ? (this.width / 2) + listSep : (this.width - listWidth) / 2, listWidth, this.height, 20);
    if (!passives.isEmpty()) {
        passives.sort(ScreenSelectSpecies.ABILITY_SORT);
        this.listPassives.addAbilities(passives);
        this.children.add(this.listPassives);
    }
    this.listActives = new AbilityList(minecraft, (this.width / 2) - listWidth - listSep, listWidth, this.height, 20);
    if (this.isDoubleList) {
        actives.sort(ScreenSelectSpecies.ABILITY_SORT);
        this.listActives.addAbilities(actives);
        this.children.add(this.listActives);
    }
}
Also used : Ability(com.lying.variousoddities.species.abilities.Ability) Types(com.lying.variousoddities.species.types.Types) AbilityModifier(com.lying.variousoddities.species.abilities.AbilityModifier) AbilityNaturalArmour(com.lying.variousoddities.species.abilities.AbilityNaturalArmour) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

Ability (com.lying.variousoddities.species.abilities.Ability)1 AbilityModifier (com.lying.variousoddities.species.abilities.AbilityModifier)1 AbilityNaturalArmour (com.lying.variousoddities.species.abilities.AbilityNaturalArmour)1 Types (com.lying.variousoddities.species.types.Types)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1