function init(hero) {
    hero.setName("Omnitrix");
    hero.setTier(10);
    
    hero.setChestplate("Watch");

    hero.addPowers("omnitrixfull:dna_alteration");
	
	//Fiskheroes Keys
    hero.addKeyBind("AIM", "Aim", 1);
    hero.addKeyBind("INTANGIBILITY", "Intangibility", 2);
    hero.addKeyBind("SIZE_MANIPULATION", "Size Manipulation", 2);
    hero.addKeyBind("GROUND_SMASH", "Ground Smash", 1);
    hero.addKeyBind("CHARGE_ICE", "Charge Shards", 1);
    hero.addKeyBind("SHADOWFORM", "Liquid Form", 2);
    hero.addKeyBind("EARTHQUAKE", "key.earthquake", 2);
    hero.addKeyBind("INVISIBILITY", "Invisibility", 4);    
    hero.addKeyBind("HEAT_VISION", "Shoot", 1);    
    hero.addKeyBind("ENERGY_PROJECTION", "Shoot", 1);
    hero.addKeyBind("CHARGED_BEAM", "Shoot", 1);
    hero.addKeyBind("SHOOT_SPIKES", "Shoot Spikes", 2);
    hero.addKeyBind("SUPER_SPEED", "Super Speed", 1);
    hero.addKeyBind("TELEPORT", "Teleport", 4);
    hero.addKeyBind("SHIELD", "Shield", 2);
    hero.addKeyBind("BLADE", "Blade", 2);
    hero.addKeyBind("SONIC_WAVES", "Sonic Scream", 1);
    hero.addKeyBind("TELEKINESIS", "key.shadowChain", 3);
    hero.addKeyBind("SLOW_MOTION", "Slomo", 2);
    hero.addKeyBind("HOVER", "Hover", 4);
    hero.addKeyBind("SPELL_MENU", "Secondary Abilities", 2);
    hero.addKeyBind("TENTACLE_JAB", "key.tentacleJab", 1);
    hero.addKeyBind("TENTACLE_GRAB", "key.tentacleGrab", 2);
    hero.addKeyBind("TENTACLE_STRIKE", "key.tentacleStrike", 4);
    hero.addKeyBind("TENTACLES", "key.tentacles", 3);
    
    // Omnitrix Controls
    
    hero.addKeyBindFunc("func_ACTIVATE_OMNITRIX", activateOmnitrixKey, "Activate Omnitrix", 3);
    hero.addKeyBindFunc("func_CHANGE_ALIEN_FORM", changeAlienFormKey, "Change Alien Form", 5);
  
    hero.addKeyBindFunc("func_PREV_PLAYLIST", prevPlaylistKey, "Prev. Playlist", 1);
    hero.addKeyBindFunc("func_PREV_ALIEN", prevAlienKey, "Prev. Alien", 2);
    hero.addKeyBindFunc("func_NEXT_ALIEN", nextAlienKey, "Next Alien", 4);
    hero.addKeyBindFunc("func_NEXT_PLAYLIST", nextPlaylistKey, "Next Playlist", 5);     
    hero.addKeyBindFunc("func_REVERT", revertKey, "Revert", 5);      
    hero.addKeyBindFunc("func_CLOSE", closeKey, "Close", 3);
	hero.addKeyBindFunc("func_LOCKED1", lockedKey, "\u00A74Playlist 1 Currently Unavailable", 3);
	hero.addKeyBindFunc("func_LOCKED2", lockedKey, "\u00A74Playlist 2 Currently Unavailable", 3);
	hero.addKeyBindFunc("func_LOCKED3", lockedKey, "\u00A74Playlist 3 Currently Unavailable", 3);
	
	// Recalibration
    hero.addKeyBindFunc("func_RECALIBRATE", recalibrateKey, "Enter Recalibration Mode", 5);
    hero.addKeyBindFunc("func_FINISH_RECALIBRATE", recalibratedKey, "Finish Recalibration Mode", 2);

    // Settings Menu
    hero.addKeyBindFunc("func_MENU", settingsKey, "Settings", 5);     
    hero.addKeyBindFunc("func_DISPLAY", displayKey, "Display Options", 2);   
    hero.addKeyBindFunc("func_CLOSE_MENU", closeMenuKey, "Close Menu", 1);        
    
    // Advanced Settings
    hero.addKeyBindFunc("func_MASTER_CONTROL", mastercontrolKey, "Toggle Master Control", 1);
    
    // Confirm Alien
    // Playlist 1
    hero.addKeyBindFunc("func_HEATBLAST", heatblastKey, "Playlist 1 - \u00A7lHeatblast\u00A7r (1/10)", 3);  
    hero.addKeyBindFunc("func_WILDMUTT", wildmuttKey, "Playlist 1 - \u00A7lWildmutt\u00A7r (2/10)", 3);
    hero.addKeyBindFunc("func_DIAMONDHEAD", diamondheadKey, "Playlist 1 - \u00A7lDiamondhead\u00A7r (3/10)", 3);  
    hero.addKeyBindFunc("func_XLR8", xlr8Key, "Playlist 1 - \u00A7lXLR8\u00A7r (4/10)", 3);  
    hero.addKeyBindFunc("func_GREY_MATTER", greymatterKey, "Playlist 1 - \u00A7lGrey Matter\u00A7r (5/10)", 3);
    hero.addKeyBindFunc("func_FOUR_ARMS", fourarmsKey, "Playlist 1 - \u00A7lFour Arms\u00A7r (6/10)", 3);
    hero.addKeyBindFunc("func_STINKFLY", stinkflyKey, "Playlist 1 - \u00A7lStinkfly\u00A7r (7/10)", 3);
    hero.addKeyBindFunc("func_RIP_JAWS", ripjawsKey, "Playlist 1 - \u00A7lRip Jaws\u00A7r (8/10)", 3);
    hero.addKeyBindFunc("func_UPGRADE", upgradeKey, "Playlist 1 - \u00A7lUpgrade\u00A7r (9/10)", 3);
    hero.addKeyBindFunc("func_GHOSTFREAK", ghostfreakKey, "Playlist 1 - \u00A7lGhostfreak\u00A7r (10/10)", 3);              
    // Playlist 2
    hero.addKeyBindFunc("func_CANNONBOLT", cannonboltKey, "Playlist 2 - Cannonbolt", 3);
    hero.addKeyBindFunc("func_WILDVINE", wildvineKey, "Playlist 2 - Wildvine", 3);   
	hero.addKeyBindFunc("func_BLITZWOLFER", blitzwolferKey, "Playlist 2 - Blitzwolfer", 3);
	hero.addKeyBindFunc("func_SNARE-OH", snareohKey, "Playlist 2 - Snare-Oh", 3);
	hero.addKeyBindFunc("func_FRANKENSTRIKE", frankenstrikeKey, "Playlist 2 - Frankenstrike", 3);
	hero.addKeyBindFunc("func_UPCHUCK", upchuckKey, "Playlist 2 - Upchuck", 3);
	hero.addKeyBindFunc("func_DITTO", dittoKey, "Playlist 2 - Ditto", 3);
	hero.addKeyBindFunc("func_EYEGUY", eyeguyKey, "Playlist 2 - Eye Guy", 3);
	hero.addKeyBindFunc("func_WAYBIG", waybigKey, "Playlist 2 - Way Big", 3);
	hero.addKeyBindFunc("func_ARCTIGUANA", arctiguanaKey, "Playlist 2 - Arctiguana", 3);
    // Playlist 3
    hero.addKeyBindFunc("func_SWAMPFIRE", swampfireKey, "Playlist 3 - Swampfire", 3);    
    hero.addKeyBindFunc("func_ECHOECHO", echoechoKey, "Playlist 3 - Echo Echo", 3);   
    hero.addKeyBindFunc("func_HUMUNGOUSAUR", humungousaurKey, "Playlist 3 - Humungousaur", 3);   
    hero.addKeyBindFunc("func_JETRAY", jetrayKey, "Playlist 3 - Jetray", 3);   
    hero.addKeyBindFunc("func_BIGCHILL", bigchillKey, "Playlist 3 - Big Chill", 3);      
    hero.addKeyBindFunc("func_CHROMASTONE", chromastoneKey, "Playlist 3 - Chromastone", 3);     
    hero.addKeyBindFunc("func_BRAINSTORM", brainstormKey, "Playlist 3 - Brainstorm", 3);   
    hero.addKeyBindFunc("func_SPIDERMONKEY", spidermonkeyKey, "Playlist 3 - Spidermonkey", 3);   
    hero.addKeyBindFunc("func_GOOP", goopKey, "Playlist 3 - Goop", 3);   
    hero.addKeyBindFunc("func_ALIENX", alienxKey, "Playlist 3 - Alien X", 3);   
	
	//Sound key
	
	//Alien Damage Profiles
    hero.addDamageProfile("HEATBLAST", {
        "types": {
            "BLUNT": 1.0,
            "FIRE": 0.6
        },
        "properties": {
            "HEAT_TRANSFER": 40,
            "IGNITE": 3
        }
    });
    hero.addDamageProfile("HEATBLAST_SICK", {
        "types": {
            "BLUNT": 1.0,
            "COLD": 0.4
        }
    });
    hero.addDamageProfile("DIAMONDHEAD", {
        "types": {
            "BLUNT": 1.0,
            "SHARP": 0.2
        }
    });
    hero.addDamageProfile("DIAMONDHEAD_BLADE", {
        "types": {
            "SHARP": 1.0
        }
    });
    hero.addDamageProfile("XLR8", {
        "types": {
            "BLUNT": 1.0,
            "SHARP": 0.55
        },
        "properties": {
            "HIT_COOLDOWN": 5
        }
    });

    hero.addKeyBindFunc("func_UPGRADE_TECH_SCAN", upgrade_tech_scanKey, "Scan Tech", 3);
    hero.addKeyBindFunc("func_GALVAN_TECH", galvan_techKey, "Suit Up", 3);	
    hero.addKeyBindFunc("func_QR", qrKey, "Travel to QR", 3);	
    
    hero.setHasProperty(hasProperty);
    hero.setHasPermission(hasPermission);
    hero.setRuleValueModifier(ruleModifier);

    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setTierOverride(getTierOverride);
    hero.setDamageProfile(getDamageProfile);

    hero.supplyFunction("canAim", canAim);
    hero.setAttributeProfile(getAttributeProfile);


// Playlist 1 Profiles
    hero.addAttributeProfile("PYRONITE", pyroniteProfile); // Heatblast
    hero.addAttributeProfile("KINECELERAN", kineceleranProfile); // XLR8
    hero.addAttributeProfile("KINECELERANMASKED", kineceleranMaskedProfile); // XLR8
    hero.addAttributeProfile("PISCCISSVOLANN", pisccissvolannProfile); // Ripjaws - Land
    hero.addAttributeProfile("PISCCISSVOLANNWATER", pisccissvolannwaterProfile); // Ripjaws - Water
    hero.addAttributeProfile("TETRAMAND", tetramandProfile); // Four Arms
    hero.addAttributeProfile("LEPIDOPTERRAN", lepidopterranProfile); // Stinkfly
    hero.addAttributeProfile("GALVAN", galvanProfile); // Grey Matter
    hero.addAttributeProfile("GALVANATOM", galvanAtomProfile); // Grey Matter A.T.O.M.
    hero.addAttributeProfile("GCOLDGUN", galvanColdGunProfile); // Grey Matter Cold Gun
    hero.addAttributeProfile("GALVANTECH", galvanTransformProfile); // Grey Matter Transforming
    hero.addAttributeProfile("PETROSAPIEN", petrosapienProfile); // Diamondhead
    hero.addAttributeProfile("PETROSAPIENDAGGER", petrosapiendaggerProfile); // Diamondhead daggers
    hero.addAttributeProfile("GALVANICMECHAMORPH", galvanicmechamorphProfile); // Upgrade
    hero.addAttributeProfile("GALVANICMECHAMORPHTECH", galvanicmechamorphTechProfile); // Upgrade
    hero.addAttributeProfile("ECTONURITE", ectonuriteProfile); // Ghostfreak
    hero.addAttributeProfile("VULPIMANCER", vulpimancerProfile); // Wildmutt

    hero.setDefaultScale(defaultScale);
	
	hero.addSoundEvent("PUNCH", ["omnitrixfull:wildmutt_scream", "omnitrixfull:fa_punch"]);
	hero.addSoundEvent("MASK_OPEN", "omnitrixfull:xlr8_mask");
	hero.addSoundEvent("MASK_CLOSE", "omnitrixfull:xlr8_mask");
	hero.addSoundEvent("STEP", ["omnitrixfull:xlr8_speeding", "omnitrixfull:gm_tank_sprint", "omnitrixfull:gm_tank_sprinting", "omnitrixfull:gm_tank_treads"]);
	hero.addSoundEvent("JUMP", "omnitrixfull:gm_tank_jump");
}

function isKeyBindEnabled(entity, keyBind) {
    var alien = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
	var nbt = (omnitrix.nbt());
    
    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
    var playlist1 = (!recalibrated || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol);
    var ActiveMode = (omnitrix.nbt().getString('ActiveMode'));
    var SelectedAlien = omnitrix.nbt().getFloat('SelectedAlien');
    var Settings = (omnitrix.nbt().getString("Settings"));
	var block = entity.world().getBlock(entity.pos().add(0, -1, 0));
    var Used = nbt.getBoolean("Used");
    var uuid = nbt.getString("userUUID");
    var playerUUID = entity.getUUID();
 
if (omnitrix.nbt().getString('CurrentAlien') != null && entity.getData('omnitrixfull:dyn/omni_transform') && !entity.getData('omnitrixfull:dyn/settings') && ActiveMode == 'Alien Form' && ActiveMode != 'SemiActive') {
    switch (keyBind) {
        case "func_CHANGE_ALIEN_FORM":
            return (mastercontrol || recalibrated) && !entity.isSneaking();
        case "func_REVERT":
            return (mastercontrol || recalibrated) && entity.isSneaking();
	}
    if (playlist1 == true) {
        if (alien == "Heatblast") {
		return pyroniteKeys(entity, keyBind);
        }
         else if (alien == "Four Arms") {
             return tetramandKeys(entity, keyBind);
        }
         else if (alien == "Stinkfly") {
            return lepidopterranKeys(entity, keyBind);
        }
        else if (alien == "Wildmutt") {
            return vulpimancerKeys(entity, keyBind);
        }
        else if (alien == "Diamondhead") {
            return petrosapienKeys(entity, keyBind);
        }
        else if (alien == "Ghostfreak") {
            return ectonuriteKeys(entity, keyBind);
        }
        else if (alien == "Grey Matter") {
            return galvanKeys(entity, keyBind);
        }
        else if (alien == "Upgrade") {
            return galvanicmechamorphKeys(entity, keyBind);
        }
        else if (alien == "Ripjaws") {
            return pisccissvolannKeys(entity, keyBind);
        }
        else if (alien == "XLR8") {
            return kineceleranKeys(entity, keyBind);
        }
    }
    if (playlist2 == true) {
        if (alien == "Ditto") {
            return splixsonKeys(entity, keyBind);
        }
        else if (alien == "Blitzwolfer") {
            return loboanKeys(entity, keyBind);
        }
        else if (alien == "Wildvine") {
            return flouranaKeys(entity, keyBind);
        }
        else if (alien == "Way Big") {
            return tokustarKeys(entity, keyBind);
        }
        else if (alien == "Snare-Oh") {
            return thepkhufanKeys(entity, keyBind);
        }
        else if (alien == "Frankenstrike") {
            return transylianKeys(entity, keyBind);
        }
        else if (alien == "Cannonbolt") {
            return arburianpelarotaKeys(entity, keyBind);
        }
    }   
    if (playlist3 == true) { 
        if (alien == "Swampfire") {
            return methanosianKeys(entity, keyBind);
        }
        else if (alien == "Humungousaur") {
            return vaxasaurianKeys(entity, keyBind);
        }
        else if (alien == "Echo Echo") {
            return sonarosianKeys(entity, keyBind);
        }
        else if (alien == "Goop") {
            return polymorphKeys(entity, keyBind);
        }
        else if (alien == "Big Chill") {
            return necrofriggianKeys(entity, keyBind);
        }
        else if (alien == "Alien X") {
            return celestialsapienKeys(entity, keyBind);
        }
        else if (alien == "Jetray") {
            return aerophibianKeys(entity, keyBind);
        }
        else if (alien == "Chromastone") {
            return crystalsapienKeys(entity, keyBind);
        }
        else if (alien == "Spidermonkey") {
            return arachnichimpKeys(entity, keyBind);
        }
        else if (alien == "Brainstorm") {
          return cerebrocrustaceanKeys(entity, keyBind);
        }
    }
}

    switch (keyBind) {
    case "func_ACTIVATE_OMNITRIX":
        return (!Used || uuid == playerUUID) && ((entity.getData('omnitrixfull:dyn/settings_timer') == 0 && entity.getData('omnitrixfull:dyn/omni_transform_cooldown') == 0 && entity.getData('omnitrixfull:dyn/omni_transform_timer') == 0 && !recalibrating) && !(entity.getEquipmentInSlot(3).damage() == 1024 && playlist2 && !recalibrated && !mastercontrol));
	case "func_MENU":
		return (entity.getData('omnitrixfull:dyn/settings_timer') == 0 && entity.getData('omnitrixfull:dyn/omni_transform_timer') == 0 && !recalibrating && nbt.getBoolean("Used") && (recalibrated || mastercontrol || playlist2)) && !(entity.getEquipmentInSlot(3).damage() == 1024 && playlist2 && !recalibrated && !mastercontrol);
	case "func_FINISH_RECALIBRATE":
		return recalibrating && entity.getData('omnitrixfull:dyn/omni_transform_timer') == 0;
//	  case "func_RECALIBRATE":
//		  return entity.getEquipmentInSlot(3).damage() == 1024 && playlist2 && !recalibrated && !mastercontrol && !recalibrating;
//    case "func_MASTER_CONTROL":
//        return block == "fiskheroes:tutridium_block";
            
    }
	if (Settings) {
          return settingsKeys(entity, keyBind);
    }
	
    if (ActiveMode == ("Active") || ActiveMode == ("SemiActive"))  {
          return omnitrixKeys(entity, keyBind);
    }

return false;
}

function canAim(entity) {
    var alien = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
	var nbt = (omnitrix.nbt());

    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
	var display = omnitrix.nbt().getString('ActiveMode') == "Display";
    var playlist1 = (!recalibrated || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol || recalibrated);
    
    if (playlist1 == true) {
        if (alien == "Heatblast") {
			return entity.getHeldItem().isEmpty() && !entity.getData("fiskheroes:jetpacking");;
        }
        else if (alien == "Grey Matter") {
            return entity.getData("fiskheroes:scale") == 1 && (entity.getHeldItem().name() == "fiskheroes:rip_hunters_gun" || entity.getHeldItem().name() == "fiskheroes:heat_gun" || entity.getHeldItem().name() == "fiskheroes:chronos_rifle" || entity.getHeldItem().name() == "fiskheroes:cold_gun");
        }
    } 
    return false;
}

function isModifierEnabled(entity, modifier) {
    var alien = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
    
    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
	var display = omnitrix.nbt().getString('ActiveMode') == "Display";
    var playlist1 = (!recalibrated || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol || recalibrated);

    switch (modifier.name()) {
    case "fiskheroes:transformation":
        return true;
    }
	
    switch (modifier.id()) {
    case "settings_cooldown":
        return true;
    case "tech_cooldown":
        return true;
    case "tech_upgrade_cooldown":
        return true;
    case "cooldown_1":
        return true;
    case "cooldown_2":
        return true;
    case "cooldown_3":
        return true;
    case "cooldown_4":
        return true;
    case "cooldown_5":
        return true;
    case "cooldown_6":
        return true;
    case "omni_transform_cooldown_default":
        return true;
    case "omni_transform_cooldown_mastercontrol":
        return (mastercontrol && !display);
    case "omni_transform_cooldown_recalibrating":
        return (recalibrating && entity.getData('omnitrixfull:dyn/omni_transform') || (recalibrating && !entity.getData('omnitrixfull:dyn/omni_transform')) );
    case "omni_transform_cooldown_changing_recalibrated":
        return (recalibrated && omnitrix.nbt().getString('ActiveMode') == "SemiActive");
    case "omni_transform_cooldown_animations":
        return ((display && entity.getData('omnitrixfull:dyn/omni_transform') && mastercontrol) || display);
    }
	
    if (playlist1 == true) {
        if (alien == "Heatblast") {
			return pyroniteModifier(entity, modifier);
        }
         else if (alien == "Four Arms") {
            return tetramandModifier(entity, modifier);
        }
        else if (alien == "Stinkfly") {
            return lepidopterranModifier(entity, modifier);
        }
        else if (alien == "Wildmutt") {
            return vulpimancerModifier(entity, modifier);
        }
        else if (alien == "Diamondhead") {
            return petrosapienModifier(entity, modifier);
        }
        else if (alien == "Ghostfreak") {
            return ectonuriteModifier(entity, modifier);
        }
        else if (alien == "Grey Matter") {
            return galvanModifier(entity, modifier);
        }
        else if (alien == "Upgrade") {
            return galvanicmechamorphModifier(entity, modifier);
        }
        else if (alien == "Ripjaws") {
            return pisccissvolannModifier(entity, modifier);
        }
        else if (alien == "XLR8") {
            return kineceleranModifier(entity, modifier);
        }
    }  
    if (playlist2 == true) {
        if (alien == "Ditto") {
            return splixsonModifier(entity, modifier);
        }
        else if (alien == "Blitzwolfer") {
            return loboanModifier(entity, modifier);
        }
        else if (alien == "Wildvine") {
            return flouranaModifier(entity, modifier);
        }
        else if (alien == "Way Big") {
            return tokustarModifier(entity, modifier);
        }
        else if (alien == "Snare-Oh") {
            return thepkhufanModifier(entity, modifier);
        }
        else if (alien == "Frankenstrike") {
            return transylianModifier(entity, modifier);
        }
        else if (alien == "Cannonbolt") {
            return arburianpelarotaModifier(entity, modifier);
        }
    }   
    if (playlist3 == true) { 
        if (alien == "Swampfire") {
            return methanosianModifier(entity, modifier);
        }
        else if (alien == "Humungousaur") {
            return vaxasaurianModifier(entity, modifier);
        }
        else if (alien == "Echo Echo") {
            return sonarosianModifier(entity, modifier);
        }
        else if (alien == "Goop") {
            return polymorphModifier(entity, modifier);
        }
        else if (alien == "Big Chill") {
            return necrofriggianModifier(entity, modifier);
        }
        else if (alien == "Alien X") {
            return celestialsapienModifier(entity, modifier);
        }
        else if (alien == "Jetray") {
            return aerophibianModifier(entity, modifier);
        }
        else if (alien == "Chromastone") {
            return crystalsapienModifier(entity, modifier);
        }
        else if (alien == "Spidermonkey") {
            return arachnichimpModifier(entity, modifier);
        }
        else if (alien == "Brainstorm") {
          return cerebrocrustaceanModifier(entity, modifier);
        }
    }
	
return false;
}



// Omnitrix Control Keys
function activateOmnitrixKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();
    var SelectedAlien = nbt.getFloat("SelectedAlien");
    var Used = nbt.getBoolean("Used");
    var recalibrating = (item.nbt().getBoolean("Recalibrating"));
    var recalibrated = (item.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (item.nbt().getBoolean("MasterControl") && !recalibrating);
    var display = nbt.getCompoundTag("display");
    var lore = manager.newTagList();
	
	player.playSound("omnitrixfull:omnitrix.activation", 1.0, 1.0);

    manager.removeTag(nbt, "Tech");
    manager.removeTag(nbt, "QR");
    manager.setData(player, 'omnitrixfull:dyn/tech', false);
  
  if (player.getData('omnitrixfull:dyn/omni_transform') == false) {
    manager.removeTag(nbt, 'CurrentAlien');
  }
    manager.setString(nbt, "ActiveMode", 'Active');
    manager.removeTag(nbt, "Settings");
  
  if (!Used) {
   manager.setFloat(nbt, "SelectedAlien", 1);
   manager.setFloat(nbt, "ActivePlaylist", 1);
   manager.setBoolean(nbt, "Used", true);
   manager.setString(nbt, "Display", "Prototype");
   manager.setString(nbt, "userUUID", player.getUUID());
   manager.setString (nbt, "userName", player.getName());
 
   var name = nbt.getString("userName");
   
   manager.setCompoundTag(nbt, "display", display);
   manager.setString(display, "Name", "The Omnitrix Prototype");
   manager.appendString(lore, name + "'s Omnitrix");
   manager.setTagList(display, "Lore", lore);
 }
	
  if (nbt.getString("userUUID") == player.getUUID() && nbt.getString("userName") != player.getName()) {
   manager.setString (nbt, "userName", player.getName());
 
   var name = nbt.getString("userName");
   
   manager.setCompoundTag(nbt, "display", display);
   manager.appendString(lore, name + "'s Omnitrix");
   manager.setTagList(display, "Lore", lore);
 }
 
    if (nbt.getString("Display") == "Prototype") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix");
    }
    if (nbt.getString("Display") == "Recalibrated") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_af");
    }
    if (nbt.getString("Display") == "Official") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_official");
    }
    if (nbt.getString("Display") == "Recalibrated") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_af");
    }
    if (nbt.getString("Display") == "5YL") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_5yl");
    }
    if (nbt.getString("Display") == "10k") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_10k");
    }
	
    return true;
}

function changeAlienFormKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();

    manager.setString(nbt, "ActiveMode", 'SemiActive');
    manager.setData(player, 'omnitrixfull:dyn/settings', true);
    manager.removeTag(nbt, "Tech");
    manager.removeTag(nbt, "QR");
    manager.setData(player, 'omnitrixfull:dyn/tech', false);

    return true;
}

function closeKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();
    var ActiveMode = (nbt.getString('ActiveMode'));
	
    manager.removeTag(nbt, "Tech");
    manager.removeTag(nbt, "QR");
    manager.setData(player, 'omnitrixfull:dyn/tech', false);
    
 if (ActiveMode == "Active") {
	manager.setString(nbt, "ActiveMode", "Deactivated");
	manager.setData(player, 'omnitrixfull:dyn/settings', false);
	}
 if (ActiveMode == "SemiActive" ) {
	manager.setString(nbt, "ActiveMode", "Alien Form");
	manager.setData(player, 'omnitrixfull:dyn/settings', false);
	}
	
    return true;
}

function revertKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();
	
    manager.removeTag(nbt, "Tech");
    manager.removeTag(nbt, "QR");
    manager.setData(player, 'omnitrixfull:dyn/tech', false);

	manager.setData(player, 'omnitrixfull:dyn/omni_transform', false);
	
    return true;
}

function nextAlienKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();
    var SelectedAlien = nbt.getFloat("SelectedAlien");
	
	player.playSound("omnitrixfull:omnitrix.alien_cycle", 1.0, 1.0);
    
    manager.setFloat(nbt, "SelectedAlien", SelectedAlien == 10 ? 1 : SelectedAlien + 1);
    manager.setData(player, 'omnitrixfull:dyn/settings', true);
    
    return true;
}

function prevAlienKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();
    var SelectedAlien = nbt.getFloat('SelectedAlien');
    
	player.playSound("omnitrixfull:omnitrix.alien_cycle", 1.0, 1.0);

    manager.setFloat(nbt, "SelectedAlien", SelectedAlien == 1 ? 10 : SelectedAlien - 1);
    manager.setData(player, 'omnitrixfull:dyn/settings', true);
    
    return true;
}

function prevPlaylistKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();
    var activePlaylist = nbt.getFloat('ActivePlaylist');

    manager.setFloat(nbt, "ActivePlaylist", activePlaylist == 1 ? 8 : activePlaylist - 1);
    manager.setData(player, 'omnitrixfull:dyn/settings', true);
    
    return true;
}

function nextPlaylistKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();
    var activePlaylist = nbt.getFloat('ActivePlaylist');
  
    manager.setFloat(nbt, "ActivePlaylist", activePlaylist == 8 ? 1 : activePlaylist + 1);
    manager.setData(player, 'omnitrixfull:dyn/settings', true);
    
    return true;
}

function omnitrixKeys(entity, keyBind) {
    var item = entity.getEquipmentInSlot(3);
    var nbt = item.nbt();
    var activePlaylist = nbt.getFloat('ActivePlaylist');
    var SelectedAlien = nbt.getFloat('SelectedAlien');
    var recalibrating = (item.nbt().getBoolean("Recalibrating"));
    var recalibrated = (item.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (item.nbt().getBoolean("MasterControl") && !recalibrating);
    var ActiveMode = (nbt.getString('ActiveMode'));
    var playlist1 = (!item.nbt().getBoolean("Recalibrated") || item.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (item.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (item.nbt().getBoolean("Playlist3") || mastercontrol);
    
    
   if ((entity.getData('omnitrixfull:dyn/settings_timer') == 1 && !entity.getData('omnitrixfull:dyn/omni_transform') && ActiveMode == "Active") || (entity.getData('omnitrixfull:dyn/omni_transform') && ActiveMode == "SemiActive")) {
    switch (keyBind) {
        case "func_PREV_PLAYLIST":
                return playlist2 || mastercontrol || !recalibrated && playlist2;
        case "func_PREV_ALIEN":
                return true;
        case "func_NEXT_ALIEN":
                return true;
        case "func_NEXT_PLAYLIST":
                return playlist2 || mastercontrol || !recalibrated && playlist2;
        case "func_CLOSE":
                return entity.isSneaking();
    }
    if (!entity.isSneaking()) {
    if (activePlaylist == 1) {
	 if (playlist1) {
      if (SelectedAlien == 1) {
        switch (keyBind) {
          case "func_HEATBLAST":
            return true;
        }
      }
      if (SelectedAlien == 2) {
        switch (keyBind) {
          case "func_WILDMUTT":
            return true;
        }
      }
      if (SelectedAlien == 3) {
        switch (keyBind) {
          case "func_DIAMONDHEAD":
            return true;
        }
      }
      if (SelectedAlien == 4) {
        switch (keyBind) {
          case "func_XLR8":
            return true;
        }
      }
      if (SelectedAlien == 5) {
        switch (keyBind) {
          case "func_GREY_MATTER":
            return true;
        }
      }
      if (SelectedAlien == 6) {
        switch (keyBind) {
          case "func_FOUR_ARMS":
            return true;
        }
      }
      if (SelectedAlien == 7) {
        switch (keyBind) {
          case "func_STINKFLY":
            return true;
        }
      }
      if (SelectedAlien == 8) {
        switch (keyBind) {
          case "func_RIP_JAWS":
            return true;
        }
      }
      if (SelectedAlien == 9) {
        switch (keyBind) {
          case "func_UPGRADE":
            return true;
        }
      }
      if (SelectedAlien == 10) {
        switch (keyBind) {
          case "func_GHOSTFREAK":
            return true;
        }
      }
	 }
	 if (!(playlist1)) {
        switch (keyBind) {
          case "func_LOCKED1":
            return true;
	  }
	 }
    }
    if (activePlaylist == 2) {
	 if (playlist2) {
      if (SelectedAlien == 1) {
        switch (keyBind) {
          case "func_CANNONBOLT":
            return true;
        }
      }
      if (SelectedAlien == 2) {
        switch (keyBind) {
          case "func_WILDVINE":
            return true;
        }
      }
	  if (SelectedAlien == 3) {
        switch (keyBind) {
          case "func_BLITZWOLFER":
            return true;
        }
	  }	
	  if (SelectedAlien == 4) {
        switch (keyBind) {
          case "func_SNARE-OH":
            return true;
        }
      }
	  if (SelectedAlien == 5) {
        switch (keyBind) {
          case "func_FRANKENSTRIKE":
            return true;
        }
	  }
	  if (SelectedAlien == 6) {
        switch (keyBind) {
          case "func_UPCHUCK":
            return true;
        }
	  }
	  if (SelectedAlien == 7) {
        switch (keyBind) {
          case "func_DITTO":
            return true;
        }
	  }
	  if (SelectedAlien == 8) {
        switch (keyBind) {
          case "func_EYEGUY":
            return true;
        }
	  }
	  if (SelectedAlien == 9) {
        switch (keyBind) {
          case "func_WAYBIG":
            return true;
        }
	  }
	  if (SelectedAlien == 10) {
        switch (keyBind) {
          case "func_ARCTIGUANA":
            return true;
        }
	  }
	 }
	 if (!(playlist2)) {
        switch (keyBind) {
          case "func_LOCKED2":
            return true;
	  }
	 }
    }
    if (activePlaylist == 3) {
	 if (playlist3) {
      if (SelectedAlien == 1) {
        switch (keyBind) {
          case "func_SWAMPFIRE":
            return true;
        }
      }
	  if (SelectedAlien == 2) {
        switch (keyBind) {
          case "func_ECHOECHO":
            return true;
        }
	  }
      if (SelectedAlien == 3) {
        switch (keyBind) {
          case "func_HUMUNGOUSAUR":
            return true;
        }
      }
      if (SelectedAlien == 4) {
        switch (keyBind) {
          case "func_JETRAY":
            return true;
        }
      }
	  if (SelectedAlien == 5) {
        switch (keyBind) {
          case "func_BIGCHILL":
            return true;
        }
	  }
	  if (SelectedAlien == 6) {
        switch (keyBind) {
          case "func_CHROMASTONE":
            return true;
        }
	  }
	  if (SelectedAlien == 7) {
        switch (keyBind) {
          case "func_BRAINSTORM":
            return true;
        }
	  }
	  if (SelectedAlien == 8) {
        switch (keyBind) {
          case "func_SPIDERMONKEY":
            return true;
        }
	  }
	  if (SelectedAlien == 9) {
        switch (keyBind) {
          case "func_GOOP":
            return true;
        }
	  }
	  if (SelectedAlien == 10) {
        switch (keyBind) {
          case "func_ALIENX":
            return true;
        }
	   }
	  }
	 if (!(playlist3)) {
        switch (keyBind) {
          case "func_LOCKED3":
            return true;
	  }
	 }
    }
    }
    }
  return false;
}

// Recalibration

function recalibratedKey(player, manager) {
        var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();
  var display = nbt.getCompoundTag("display");
    var lore = manager.newTagList();
    
    
      manager.appendString(lore, "\u00A72Recalibrated");
      manager.setTagList(display, "Lore", lore);
	  
      manager.setFloat(nbt, "ActivePlaylist", 3);
      manager.setFloat(nbt, "SelectedAlien", 1);
	  
	  manager.setBoolean(nbt, "Playlist1", false);
 	  manager.setBoolean(nbt, "Playlist2", false);
	  manager.setBoolean(nbt, "Playlist3", true);
      manager.setString(nbt, "Display", "Recalibrated");
	  
	  manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_af");

  manager.setBoolean(nbt, "Recalibrated", true);
  manager.setBoolean(nbt, "Recalibrating", false);
    return true;
}

function recalibrateKey(player, manager) {
        var item = player.getEquipmentInSlot(3);
        setRecalibrationMode(item, manager, !isRecalibrating(item));

	manager.removeTag(item.nbt(), "Settings"); 
	manager.removeTag(item.nbt(), "ActiveMode"); 
    manager.removeTag(item.nbt(), 'CurrentAlien'); 	

	manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
	manager.setData(player, 'omnitrixfull:dyn/settings', false);
    return true;
}

function setRecalibrationMode(item, manager, enabled) {
  var nbt = item.nbt();
  var display = nbt.getCompoundTag("display");

  if (enabled) {
    var lore = manager.newTagList();
    manager.appendString(lore, "\u00A71Recalibrating...");
    manager.setTagList(display, "Lore", lore);
  manager.setBoolean(nbt, "MasterControl", false);
  manager.setBoolean(nbt, "Unbreakable", false);
  
  
  }
  else {
    manager.removeTag(display, "Lore");
  }

  manager.setCompoundTag(nbt, "display", display);
  manager.setBoolean(nbt, "Recalibrating", enabled);
}

function isRecalibrating(item) {
  return item.nbt().getBoolean("Recalibrating");
}

//Junk?

function upgrade_tech_scanKey(player, manager) {
        var omnitrix = player.getEquipmentInSlot(3);
        var item = player.getHeldItem();
      	var nbt = omnitrix.nbt();

    if (item.name() == "minecraft:minecart" && player.getData('omnitrixfull:dyn/upgrade_timer') == 0) {
            manager.setString(nbt, "Tech", "Minecart");
    }
    if ((item.name() == "fiskheroes:superhero_helmet" || item.name() == "fiskheroes:superhero_chestplate" || item.name() == "fiskheroes:superhero_leggings" || item.name() == "fiskheroes:superhero_boots") && item.nbt().getString("HeroType") == "fiskheroes:mysterio" && player.getData('omnitrixfull:dyn/upgrade_timer') == 0) {
            manager.setString(nbt, "Tech", "Mysterio");
    }

    return true;
}

function galvan_techKey(player, manager) {
        var omnitrix = player.getEquipmentInSlot(3);
        var item = player.getHeldItem();
      	var nbt = omnitrix.nbt();

    if (item.name() == "fiskheroes:mini_atom_suit" && player.getData('omnitrixfull:dyn/tech_timer') == 0) {
            manager.setString(nbt, "Tech", "ATOM");
    }
    if (item.name() == "fiskheroes:cold_gun" && player.getData('omnitrixfull:dyn/tech_timer') == 0) {
            manager.setString(nbt, "Tech", "ColdGun");
    }

    return true;
}

function qrKey(player, manager) {
      	var nbt = player.getEquipmentInSlot(3).nbt();
	
	manager.setBoolean(nbt, "QR", true);
	
	
    return true;
}

function nullKey(player, manager) {
  return false;
}

function lockedKey(item) {
  return false;
}

// Alien Confirmation Group

function transformKey(player, manager) {
    var item = player.getEquipmentInSlot(3);
    var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Alien Form");
    return true;
}
// Playlist 1

function genericAlienKey(player, manager, alien) {
    var item = player.getEquipmentInSlot(3);
	var nbt = item.nbt();
	
player.playSound("omnitrixfull:omnitrix.transformation", 1.0, 1.0);

manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", alien);
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
	
    return transformKey(player, manager);
}

function heatblastKey(player, manager) {
	return genericAlienKey(player, manager, "Heatblast");
}
function xlr8Key(player, manager) {
	return genericAlienKey(player, manager, "XLR8");
}
function diamondheadKey(player, manager) {
	return genericAlienKey(player, manager, "Diamondhead");
}
function ghostfreakKey(player, manager) {
	return genericAlienKey(player, manager, "Ghostfreak");
}
function wildmuttKey(player, manager) {
	return genericAlienKey(player, manager, "Wildmutt");
}
function upgradeKey(player, manager) {
	return genericAlienKey(player, manager, "Upgrade");
}
function ripjawsKey(player, manager) {
	return genericAlienKey(player, manager, "Ripjaws");
}
function greymatterKey(player, manager) {
	return genericAlienKey(player, manager, "Grey Matter");
}
function fourarmsKey(player, manager) {
	return genericAlienKey(player, manager, "Four Arms");
}
function stinkflyKey(player, manager) {
	return genericAlienKey(player, manager, "Stinkfly");
}
// Playlist 2
function cannonboltKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Cannonbolt");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function wildvineKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Wildvine");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function upchuckKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Upchuck");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function eyeguyKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Eye Guy");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function blitzwolferKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Blitzwolfer");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function snareohKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Snare-Oh");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function frankenstrikeKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Frankenstrike");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function waybigKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Way Big");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function dittoKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Ditto");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function arctiguanaKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Arctiguana");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
// Playlist 3
function swampfireKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Swampfire");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function humungousaurKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Humungousaur");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function bigchillKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Big Chill");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function echoechoKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Echo Echo");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function jetrayKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Jetray");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function chromastoneKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Chromastone");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function brainstormKey(player, manager) {
   var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Brainstorm");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function goopKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Goop");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function spidermonkeyKey(player, manager) {
  var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Spidermonkey");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}
function alienxKey(player, manager) {
   var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "ActiveMode", "Deactivated");
manager.setBoolean(nbt, "transforming", true);
manager.setString(nbt, "CurrentAlien", "Alien X");
manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
manager.setData(player, 'omnitrixfull:dyn/settings', false);
manager.setBoolean(nbt, "transforming", false);
    return transformKey(player, manager);
}


// Settings Segment
function settingsKey(player, manager) {
        var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();
  
    manager.removeTag(nbt, "Tech");
  
    if (nbt.getString("Display") == "Prototype") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix");
    }
    if (nbt.getString("Display") == "Recalibrated") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_af");
    }
    if (nbt.getString("Display") == "Official") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_official");
    }
    if (nbt.getString("Display") == "Recalibrated") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_af");
    }
    if (nbt.getString("Display") == "5YL") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_5yl");
    }
    if (nbt.getString("Display") == "10k") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_10k");
    }

  manager.setString(nbt, "Settings", "Menu");
  manager.removeTag(nbt, "CurrentAlien");  
    manager.setData(player, 'omnitrixfull:dyn/settings', true);
    return true;
}
function closeMenuKey(player, manager) {
        var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();
	
    if (nbt.getString("Display") == "Prototype") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix");
    }
    if (nbt.getString("Display") == "Recalibrated") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_af");
    }
    if (nbt.getString("Display") == "Official") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_official");
    }
    if (nbt.getString("Display") == "Recalibrated") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_af");
    }
    if (nbt.getString("Display") == "5YL") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_5yl");
    }
    if (nbt.getString("Display") == "10k") {
			manager.setString(nbt, "HeroType", "omnitrixfull:omnitrix_10k");
    }
			
  manager.removeTag(nbt, "Settings");
    manager.setData(player, 'omnitrixfull:dyn/settings', false);
    return true;
}

function displayKey(player, manager) {
        var omnitrix = player.getEquipmentInSlot(3);
      	var nbt = omnitrix.nbt();
		
	manager.setData(player, 'omnitrixfull:dyn/omni_transform', false);
    manager.setData(player, 'omnitrixfull:dyn/omni_transform', true);
	manager.setString(nbt, "ActiveMode", "Display");
	manager.setString(nbt, "Settings", "Menu");

    if (nbt.getString("Display") == "Prototype") {
            manager.setString(nbt, "Display", "Recalibrated");
    }
    else if (nbt.getString("Display") == "Recalibrated") {
            manager.setString(nbt, "Display", "Official");
    }
    else if (nbt.getString("Display") == "Official") {
            manager.setString(nbt, "Display", "5YL");
    }
    else if (nbt.getString("Display") == "5YL") {
            manager.setString(nbt, "Display", "10k");
    }
    else if (nbt.getString("Display") == "10k") {
            manager.setString(nbt, "Display", "Prototype");
    }

    return true;
}

function backKey(player, manager) {
        var item = player.getEquipmentInSlot(3);
  var nbt = item.nbt();

  manager.setString(nbt, "Settings", "Menu");
    manager.setData(player, 'omnitrixfull:dyn/settings', true);
    return true;
}

// Master Control Functions
function mastercontrolKey(player, manager) {
        var item = player.getEquipmentInSlot(3);
        setMasterControl(item, manager, !isMasterControl(item));
    return true;
}

function setMasterControl(item, manager, enabled) {
  var nbt = item.nbt();
  var display = nbt.getCompoundTag("display");
    var lore = manager.newTagList();
    var recalibrated = nbt.getBoolean("Recalibrated");

  if (enabled) {
    manager.appendString(lore, "\u00A7aMaster Control Enabled");
    manager.setTagList(display, "Lore", lore);
   }
  else {
    manager.removeTag(display, "Lore");
  }

  manager.setCompoundTag(nbt, "display", display);
  manager.setBoolean(nbt, "MasterControl", enabled);
  manager.setBoolean(nbt, "Unbreakable", enabled);
}

function isMasterControl(item) {
  return item.nbt().getBoolean("MasterControl");
}

// Settings Keys Management

function settingsKeys(entity, keyBind) {
    var item = entity.getEquipmentInSlot(3);
    var nbt = item.nbt();
    var block = entity.world().getBlock(entity.pos().add(0, -1, 0));
    var Settings = nbt.getString("Settings");
    var recalibrating = (nbt.getBoolean("Recalibrating"));
    var recalibrated = (nbt.getBoolean("Recalibrated"));
    var mastercontrol = (nbt.getBoolean("MasterControl") && !recalibrating);
    
    if (entity.getData('omnitrixfull:dyn/settings_timer') == 1) {
      if (Settings == 'Menu') {
    switch (keyBind) {
		case "func_DISPLAY":
				return mastercontrol;
        case "func_CLOSE_MENU":
                return entity.getData('omnitrixfull:dyn/omni_transform_timer') == 0 && !recalibrating;
    }
    }
    }
  return false;
}


//Playlist 1
// Pyronite Bulk

function pyroniteProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 6.5, 0);
    profile.addAttribute("JUMP_HEIGHT", 1.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 0.65, 1);
    profile.addAttribute("SPRINT_SPEED", 0.15, 1);
}
function pyroniteKeys(entity, keyBind) {
    switch (keyBind) {
        case "HEAT_VISION":
            return !entity.hasPotionEffect(18);
    }
  return false;
}
function pyroniteModifier(entity, modifier) {
    switch (modifier.id()) {
        case "heatblast_propelled_flight":
                return !entity.hasPotionEffect(18);
        case "heatblast_fireball":
				return !entity.isInWater() && !entity.hasPotionEffect(18);
        case "heatblast_heat_vision":
				return !entity.hasPotionEffect(18) && (entity.getData("omnitrixfull:dyn/cooldown_6") == 0 || (entity.getData("omnitrixfull:dyn/cooldown_6") < 1 && entity.getData('fiskheroes:heat_vision')));
        case "heatblast_frost_walking":
				return entity.hasPotionEffect(18);
        case "heatblast_cryoball":
				return entity.hasPotionEffect(18);
		}
		
  return (modifier.id().startsWith("heatblast")) == true;
}
function pyroniteRules(entity, rule) {
return null;
}

// Tetramand Bulk
function tetramandProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 10.5, 0);
    profile.addAttribute("WEAPON_DAMAGE", -1.5, 0);
    profile.addAttribute("JUMP_HEIGHT", 2.5, 0);
    profile.addAttribute("FALL_RESISTANCE", 0.75, 1);
    profile.addAttribute("SPRINT_SPEED", 0.55, 1);
	profile.addAttribute("KNOCKBACK", 1, 0);
	profile.addAttribute("STEP_HEIGHT", 0.5, 0);
    profile.addAttribute("MAX_HEALTH", 2, 0);
}
function tetramandKeys(entity, keyBind) {
    switch (keyBind) {
        case "GROUND_SMASH":
                return true;
        case "EARTHQUAKE":
                return true;
    }
  return false;
}
function tetramandModifier(entity, modifier) {		
  return (modifier.id().startsWith("fourarms")) == true;
}
function tetramandRules(entity, rule) {
return null;
}
// Vulpimancer Bulk
function vulpimancerProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 5.5, 0);
    profile.addAttribute("JUMP_HEIGHT", 2.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 0.65, 1);
    profile.addAttribute("SPRINT_SPEED", 0.65, 1);
    profile.addAttribute("MAX_HEALTH", -2, 0);
}
function vulpimancerKeys(entity, keyBind) {
  return false;
}
function vulpimancerModifier(entity, modifier) {
    switch (modifier.id()) {
        case "wildmutt_potion_immunity":
                return !entity.hasPotionEffect(18);
		}
		
  return (modifier.id().startsWith("wildmutt")) == true;
}
function vulpimancerRules(entity, rule) {
return null;
}


// Lepidopterran Bulk
function lepidopterranProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 2.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 4.0, 0);
	profile.addAttribute("IMPACT_DAMAGE", 0.55, 1);
}
function lepidopterranKeys(entity, keyBind) {
    switch (keyBind) {
        case "ENERGY_PROJECTION":
            return true;
    }
  return false;
}
function lepidopterranModifier(entity, modifier) {
		
    switch (modifier.id()) {
        case "stinkfly_gliding":
                return !entity.isInWater();
        case "stinkfly_energy_projection":
                return (entity.getData("omnitrixfull:dyn/cooldown_6") == 0 || (entity.getData("omnitrixfull:dyn/cooldown_6") < 1 && entity.getData('fiskheroes:energy_projection')));
		}
		
  return (modifier.id().startsWith("stinkfly")) == true;
}
function lepidopterranRules(entity, rule) {
return null;
}

// Petrosapien Bulk
function petrosapienProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 9.0, 0);
    profile.addAttribute("WEAPON_DAMAGE", -1.0, 0);
    profile.addAttribute("JUMP_HEIGHT", 0.5, 0);
    profile.addAttribute("FALL_RESISTANCE", 9.5, 0);
    profile.addAttribute("SPRINT_SPEED", 0.1, 1);
    profile.addAttribute("MAX_HEALTH", 2, 0);
}
function petrosapiendaggerProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 10.5, 0);
    profile.addAttribute("JUMP_HEIGHT", 0.5, 0);
    profile.addAttribute("FALL_RESISTANCE", 9.5, 0);
    profile.addAttribute("SPRINT_SPEED", 0.1, 1);
    profile.addAttribute("MAX_HEALTH", 2, 0);
}
function petrosapienKeys(entity, keyBind) {
    switch (keyBind) {
        case "CHARGE_ICE":
            return !entity.getData("fiskheroes:shield");
        case "SHIELD":
            return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:cryo_charge") == 1 || entity.getData("fiskheroes:shield");
    }
  return false;
}
function petrosapienModifier(entity, modifier) {
		
    switch (modifier.id()) {
        case "diamondhead_shield":
                return entity.getData("fiskheroes:cryo_charge") > 0;
        case "diamondhead_damage_bonus":
                return entity.getData("fiskheroes:shield");
        case "diamondhead_healing_factor":
                return !entity.getData("fiskheroes:shield_blocking");
        case "diamondhead_healing_factor_shield_blocking":
                return entity.getData("fiskheroes:shield_blocking");
		}
		
		
  return (modifier.id().startsWith("diamondhead")) == true;
}
function petrosapienRules(entity, rule) {
    switch (rule.name()) {
        case "fiskheroes:dmg_icefistbonus":
            return rule.value() * 0;
    }
return null;
}

// Galvan Bulk
function galvanProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", -1.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 1.5, 0);
    profile.addAttribute("SPRINT_SPEED", 0.05, 1);
    profile.addAttribute("MAX_HEALTH", -14, 0);
}
function galvanTransformProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", -1.0, 0);
    profile.addAttribute("JUMP_HEIGHT", -1.0, 1);
    profile.addAttribute("BASE_SPEED", -1.0, 1);
    profile.addAttribute("SPRINT_SPEED", -1.0, 1);
}
function galvanAtomProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 7.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 7.0, 0);
    profile.addAttribute("SPRINT_SPEED", 0.15, 1);
}
function galvanColdGunProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", -10.0, 0);
    profile.addAttribute("BASE_SPEED", -1.0, 1);
    profile.addAttribute("SPRINT_SPEED", 0.6, 1);
}
function galvanKeys(entity, keyBind) {
    switch (keyBind) {
        case "func_GALVAN_TECH":
            return entity.getData('fiskheroes:scale') > 0.0625 && ((entity.getData("omnitrixfull:dyn/tech_timer") == 0 && (entity.getHeldItem().name() == 'fiskheroes:mini_atom_suit' || entity.getHeldItem().name() == 'fiskheroes:cold_gun')) || (entity.getData("omnitrixfull:dyn/tech_timer") == 1 && (entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ColdGun" || entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM")));
        case "func_QR":
            return entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM" && entity.getData('fiskheroes:scale') == 0.0625;
        case "HOVER":
            return entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM";
        case "SIZE_MANIPULATION":
            return entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM";
		case "AIM":
			return entity.getData("fiskheroes:scale") == 1 && (entity.getHeldItem().name() == "fiskheroes:rip_hunters_gun" || entity.getHeldItem().name() == "fiskheroes:heat_gun" || entity.getHeldItem().name() == "fiskheroes:chronos_rifle" || entity.getHeldItem().name() == "fiskheroes:cold_gun");
    }
  return false;
}
function galvanModifier(entity, modifier) {
    switch (modifier.id()) {
        case "atom_size_manipulation":
                return entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM";
        case "atom_propelled_flight":
                return entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM";
        case "atom_hover":
                return entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM";
        case "coldgun_greymatter_cryoball":
                return !entity.isSneaking() && entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ColdGun";
		}
		
		
  return (modifier.id().startsWith("greymatter")) == true;

}
function galvanRules(entity, rule) {

	switch (rule.name()) {
		case "fiskheroes:ticks_qrtimer":
			return entity.getEquipmentInSlot(3).nbt().getBoolean("QR") == true ? 1 : -1;
	}
return null;
}

// Kineceleran Bulk
function kineceleranProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 4.5, 0);
    profile.addAttribute("WEAPON_DAMAGE", 1.0, 0);
    profile.addAttribute("JUMP_HEIGHT", 1.5, 0);
    profile.addAttribute("FALL_RESISTANCE", 5.5, 0);
    profile.addAttribute("SPRINT_SPEED", 0.6, 1);
    profile.addAttribute("BASE_SPEED_LEVELS", 4.0, 0);
    profile.addAttribute("MAX_HEALTH", -4, 0);
}
function kineceleranMaskedProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 4.5, 0);
    profile.addAttribute("WEAPON_DAMAGE", 1.0, 0);
    profile.addAttribute("JUMP_HEIGHT", 1.5, 0);
    profile.addAttribute("FALL_RESISTANCE", 5.5, 0);
    profile.addAttribute("SPRINT_SPEED", 0.6, 1);
    profile.addAttribute("BASE_SPEED_LEVELS", 6.0, 0);
    profile.addAttribute("MAX_HEALTH", -4, 0);
}
function kineceleranKeys(entity, keyBind) {
    switch (keyBind) {
        case "SUPER_SPEED":
            return true;
        case "SLOW_MOTION":
            return true;
    }
  return false;
}
function kineceleranModifier(entity, modifier) {
  return (modifier.id().startsWith("xlr8")) == true;
}
function kineceleranRules(entity, rule) {
    switch (rule.name()) {
        case "fiskheroes:ticks_qrtimer":
            return -1;
    }
    return null;
}

// Piscciss Volann Bulk
function pisccissvolannProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 1.5, 0);
    profile.addAttribute("FALL_RESISTANCE", 2.0, 0);
    profile.addAttribute("MAX_HEALTH", -14, 0);
}
function pisccissvolannwaterProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 7.5, 0);
    profile.addAttribute("JUMP_HEIGHT", 1.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 4.0, 0);
    profile.addAttribute("SPRINT_SPEED", 0.2, 1);
	profile.addAttribute("IMPACT_DAMAGE", 0.4, 1);
}
function pisccissvolannKeys(entity, keyBind) {
  return false;
}
function pisccissvolannModifier(entity, modifier) {
    switch (modifier.id()) {
        case "ripjaws_gliding":
                return entity.isInWater();
        case "ripjaws_fire_weakness":
                return !entity.isInWater();
		}
		
		
  return (modifier.id().startsWith("ripjaws")) == true;
}
function pisccissvolannRules(entity, rule) {
return null;
}

// Galvanic Mechamorph Bulk

function galvanicmechamorphProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 5.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 1.0, 1);
	profile.addAttribute("KNOCKBACK", 1, 0);
}
function galvanicmechamorphTechProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", -10.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 1.0, 1);
    profile.addAttribute("SPRINT_SPEED", 0.6, 1);
}
function galvanicmechamorphKeys(entity, keyBind) {
    var item = entity.getHeldItem();
		
    switch (keyBind) {
        case "SHADOWFORM":
            return entity.getData("omnitrixfull:dyn/upgrade_timer") == 0;
        case "CHARGED_BEAM":
            return entity.getData("omnitrixfull:dyn/upgrade_timer") == 0 || (entity.getData("omnitrixfull:dyn/upgrade_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "Mysterio");
        case "HOVER":
            return entity.getData("omnitrixfull:dyn/upgrade_timer") == 1 && (entity.getEquipmentInSlot(3).nbt().getString("Tech") == "Mysterio");
        case "func_UPGRADE_TECH_SCAN":
            return (((item.name() == "fiskheroes:superhero_helmet" || item.name() == "fiskheroes:superhero_chestplate" || item.name() == "fiskheroes:superhero_leggings" || item.name() == "fiskheroes:superhero_boots") && item.nbt().getString("HeroType") == "fiskheroes:mysterio")
			|| item.name() == "minecraft:minecart"
			|| entity.getData("omnitrixfull:dyn/upgrade_timer") == 1);
            
    }
  return false;
}

function galvanicmechamorphModifier(entity, modifier) {
    switch (modifier.id()) {
        case "mupgrade_gliding":
                return entity.getData("omnitrixfull:dyn/upgrade_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "Minecart";
        case "mupgrade_hover":
                return entity.getData("omnitrixfull:dyn/upgrade_timer") == 1 && (entity.getEquipmentInSlot(3).nbt().getString("Tech") == "Mysterio");
        case "mupgrade_flight":
                return entity.getData("omnitrixfull:dyn/upgrade_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "Mysterio";
        case "upgrade_charged_beam":
                return entity.getData("omnitrixfull:dyn/upgrade_timer") == 0;
        case "upgrade_charged_beam_mysterio":
                return (entity.getData("omnitrixfull:dyn/upgrade_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "Mysterio");
        case "tech_upgrade":
                return true;
        case "tech":
                return false;
		}
		
		
  return (modifier.id().startsWith("upgrade")) == true;
}
function galvanicmechamorphRules(entity, rule) {
return null;
}

// Ectonurite Bulk

function ectonuriteProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 5.0, 0);
    profile.addAttribute("SPRINT_SPEED", 0.1, 1);
}
function ectonuriteKeys(entity, keyBind) {
    switch (keyBind) {
        case "INTANGIBILITY":
            return true;
        case "INVISIBILITY":
            return true;
        case "TENTACLE_JAB":
            return true;
        case "TENTACLES":
            return true;
    }
  return false;
}
function ectonuriteModifier(entity, modifier) {
    switch (modifier.id()) {
        case "ghostfreak_tentacles":
                return !entity.getData("fiskheroes:intangible") && !entity.getData("fiskheroes:invisible") && entity.isOnGround();
		}
		
  return (modifier.id().startsWith("ghostfreak")) == true;
}
function ectonuriteRules(entity, rule) {
return null;
}

function getAttributeProfile(entity) {
    var alien = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
    
    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
    var playlist1 = (!recalibrated || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol) || recalibrated;
    
    
    if (playlist1 == true) {
        if (alien == 'Heatblast') {
			return "PYRONITE";
        }
        if (alien == 'Four Arms') {
            return "TETRAMAND";
        }
        if (alien == 'Stinkfly') {
            return "LEPIDOPTERRAN";
        }
        if (alien == 'Wildmutt') {
            return "VULPIMANCER";
        }
        if (alien == 'Diamondhead') {
            if (entity.getData("fiskheroes:shield")) {
                return "PETROSAPIENDAGGER";
            }
            if (!entity.getData("fiskheroes:shield")) {
                return "PETROSAPIEN";
            }
        }
        if (alien == 'Ghostfreak') {
            return "ECTONURITE";
        }
        if (alien == 'Grey Matter') {
            if (entity.getData("omnitrixfull:dyn/tech") && entity.getData("omnitrixfull:dyn/tech_timer") < 1) {
                return "GALVANTECH";
            }
            if (entity.getData("omnitrixfull:dyn/tech") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM") {
                return "GALVANATOM";
            }
            if (entity.getData("omnitrixfull:dyn/tech") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ColdGun") {
                return "GCOLDGUN";
            }
            if (!entity.getData("omnitrixfull:dyn/tech")) {
                return "GALVAN";
            }
        }
        if (alien == 'Upgrade') {
            if (entity.getData("omnitrixfull:dyn/upgrade_timer") > 0) {
                return "GALVANICMECHAMORPHTECH";
            }
            if (entity.getData("omnitrixfull:dyn/upgrade_timer") == 0) {
                return "GALVANICMECHAMORPH";
            }
        }
        if (alien == 'Ripjaws') {
            if (entity.isInWater()) {
                return "PISCCISSVOLANNWATER";
            }
            if (!entity.isInWater()) {
                return "PISCCISSVOLANN";
            }
        }
        if (alien == 'XLR8') {
			if (!entity.getData("fiskheroes:mask_open_timer")){
            return "KINECELERAN";
			}
			if (entity.getData("fiskheroes:mask_open_timer")){
            return "KINECELERANMASKED";
			}
        }
    } 
    return null;
}

function getTierOverride(entity) {
    var alien = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
    
    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
    var playlist1 = (!recalibrated || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol) || recalibrated;

    
    if (playlist1 == true) {
        if (alien == 'Heatblast') {
			return 6;
        }
        if (alien == 'Four Arms') {
            return 8;
            }
        if (alien == 'Stinkfly') {
                return 4;
            }
        if (alien == 'Wildmutt') {
            return 6;
        }
        if (alien == 'Diamondhead') {
            return 8;
        }
        if (alien == 'Ghostfreak') {
            return 5;
        }
        if (alien == 'Grey Matter') {
			if (!entity.getData("omnitrixfull:dyn/tech_timer") == 1) {
				return 0;
			}
			if (entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ATOM") {
				return 6;
			}
        }
        if (alien == 'Upgrade') {
            return 6;
        }
        if (alien == 'Ripjaws') {
            if (entity.isInWater()) {
                return 5;
            }
            if (!entity.isInWater()) {
                return 2;
            }
        }
        if (alien == 'XLR8') {
            return 4;
        }
    }  
return 0;    
    

}

function getDamageProfile(entity) {
    var alien = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
    
    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
    var playlist1 = (!recalibrated || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol) || recalibrated;

    
    if (playlist1 == true) {
        if (alien == 'Heatblast') {
			if (!entity.hasPotionEffect(18)){
				return "HEATBLAST";
			}
			else {
				return "HEATBLAST_SICK";
			}
        }
        if (alien == 'Diamondhead') {
			if (entity.getData('fiskheroes:blade')) {
				return "DIAMONDHEAD_BLADE";
			}
			else {
				return "DIAMONDHEAD";		
			}
		}
        if (alien == 'XLR8') {
            return "XLR8";
        }
    }  
return null;    
    

}

function ruleModifier(entity, rule) {
    var disguise = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
    
    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
    var playlist1 = (!omnitrix.nbt().getBoolean("Recalibrated") || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol);
    var playlist4 = (omnitrix.nbt().getBoolean("Playlist4") || mastercontrol);
    var playlist5 = (omnitrix.nbt().getBoolean("Playlist5") || mastercontrol);
    var playlist6 = (omnitrix.nbt().getBoolean("Playlist6") || mastercontrol);
    var playlist7 = (omnitrix.nbt().getBoolean("Playlist7") || mastercontrol);
    var playlist4317 = (omnitrix.nbt().getBoolean("Playlist4317") || mastercontrol);
    
    if (playlist1 == true) {
        if (disguise == 'Heatblast') {
			return pyroniteRules(entity, rule);
        }
        if (disguise == 'Four Arms' || disguise == 'Tetramand') {
            return tetramandRules(entity, rule);
            }
        if (disguise == 'Lepidopterran' || disguise == 'Stinkfly') {
            return lepidopterranRules(entity, rule);
                }
        if (disguise == 'Vulpimancer' || disguise == 'Wildmutt') {
            return vulpimancerRules(entity, rule);
        }
        if (disguise == 'Petrosapien' || disguise == 'Diamondhead') {
            return petrosapienRules(entity, rule);
        }
        if (disguise == 'Ectonurite' || disguise == 'Ghostfreak') {
            return ectonuriteRules(entity, rule);
        }
        if (disguise == 'Galvan' || disguise == 'Grey Matter') {
            return galvanRules(entity, rule);
        }
        if (disguise == 'Galvanic Mechamorph' || disguise == 'Upgrade') {
            return galvanicmechamorphRules(entity, rule);
        }
        if (disguise == 'Piscciss Volann' || disguise == 'Ripjaws') {
            return pisccissvolannRules(entity, rule);
        }
        if (disguise == 'Kineceleran' || disguise == 'XLR8') {
            return kineceleranRules(entity, rule);
        }
    } 
    if (playlist2 == true) {
        if (disguise == 'Splixson' || disguise == 'Ditto') {
            return splixsonRules(entity, rule);
        }
        else if (disguise == 'Loboan' || disguise == 'Blitzwolfer') {
            return loboanRules(entity, rule);
        }
        else if (disguise == 'Flourana' || disguise == 'Wildvine') {
            return flouranaRules(entity, rule);
        }
        else if (disguise == 'Tokustar' || disguise == 'Way Big') {
            return tokustarRules(entity, rule);
        }
        else if (disguise == 'Thep Khufan' || disguise == 'Snare-Oh') {
            return thepkhufanRules(entity, rule);
        }
        else if (disguise == 'Transylian' || disguise == 'Frankenstrike') {
            return transylianRules(entity, rule);
        }
    }
    if (playlist3 == true) { 
        if (disguise == 'Methanosian' || disguise == 'Swampfire') {
            return methanosianRules(entity, rule);
        }
        else if (disguise == 'Vaxasaurian' || disguise == 'Humungousaur') {
            return vaxasaurianRules(entity, rule);
        }
        else if (disguise == 'Sonarosian' || disguise == 'Echo Echo') {
            return sonarosianRules(entity, rule);
        }
        else if (disguise == 'Polymorph' || disguise == 'Goop') {
            return polymorphRules(entity, rule);
        }
        else if (disguise == 'Necrofriggian' || disguise == 'Big Chill') {
            return necrofriggianRules(entity, rule);
        }
        else if (disguise == 'Celestialsapien' || disguise == 'Alien X') {
            return celestialsapienRules(entity, rule);
        }
        else if (disguise == 'Aerophibian' || disguise == 'Jetray') {
            return aerophibianRules(entity, rule);
        }
        else if (disguise == 'Crystalsapien' || disguise == 'Chromastone') {
            return crystalsapienRules(entity, rule);
        }
        else if (disguise == 'Arachnichimp' || disguise == 'Spidermonkey') {
            return arachnichimpRules(entity, rule);
        }
        else if (disguise == 'Cerebrocrustacean' || disguise == 'Brainstorm') {
          return cerebrocrustaceanRules(entity, rule);
        }
    }
     return null;
}


function defaultScale(entity) {
    var disguise = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
    
    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
    var playlist1 = (!omnitrix.nbt().getBoolean("Recalibrated") || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol);
    var playlist4 = (omnitrix.nbt().getBoolean("Playlist4") || mastercontrol);
    var playlist5 = (omnitrix.nbt().getBoolean("Playlist5") || mastercontrol);
    var playlist6 = (omnitrix.nbt().getBoolean("Playlist6") || mastercontrol);
    var playlist7 = (omnitrix.nbt().getBoolean("Playlist7") || mastercontrol);
    var playlist4317 = (omnitrix.nbt().getBoolean("Playlist4317") || mastercontrol);
    
    
    if (playlist1 == true) {
        if (disguise == 'Heatblast') {
    return 1.0;
        }
         else if (disguise == 'Four Arms' || disguise == 'Tetramand') {
                return 2;
            }
		else if (disguise == 'Lepidopterran' || disguise == 'Stinkfly') {
            return 1.0;
                }
        else if (disguise == 'Vulpimancer' || disguise == 'Wildmutt') {
            return 1.3;
        }
        else if (disguise == 'Petrosapien' || disguise == 'Diamondhead') {
            return 1.2;
        }
        else if (disguise == 'Ectonurite' || disguise == 'Ghostfreak') {
            return 1.0;
        }
        else if (disguise == 'Galvan' || disguise == 'Grey Matter') {
			if (entity.getData("omnitrixfull:dyn/tech_timer") == 1 && entity.getEquipmentInSlot(3).nbt().getString("Tech") == "ColdGun"){
				return 0.2;
			}
            return 0.08;
        }
        else if (disguise == 'Galvanic Mechamorph' || disguise == 'Upgrade') {
            return 1.2;
        }
        else if (disguise == 'Piscciss Volann' || disguise == 'Ripjaws') {
            return 1.1;
        }
        else if (disguise == 'Kineceleran' || disguise == 'XLR8') {
            return 0.8;
        }
    }
  
  return 1;
}

function hasProperty(entity, property) {
    var disguise = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
    
    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
    var playlist1 = (!omnitrix.nbt().getBoolean("Recalibrated") || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol);
    var playlist4 = (omnitrix.nbt().getBoolean("Playlist4") || mastercontrol);
    var playlist5 = (omnitrix.nbt().getBoolean("Playlist5") || mastercontrol);
    var playlist6 = (omnitrix.nbt().getBoolean("Playlist6") || mastercontrol);
    var playlist7 = (omnitrix.nbt().getBoolean("Playlist7") || mastercontrol);
    var playlist4317 = (omnitrix.nbt().getBoolean("Playlist4317") || mastercontrol);
    
    
    if (playlist1 == true) {
        if (disguise == 'Heatblast') {
    return false;
        }
        else if (disguise == 'Four Arms' || disguise == 'Tetramand') {
                return false;
            }
        else if (disguise == 'Lepidopterran' || disguise == 'Stinkfly') {
            return false;
            }
        else if (disguise == 'Vulpimancer' || disguise == 'Wildmutt') {
            return false;
        }
        else if (disguise == 'Petrosapien' || disguise == 'Diamondhead') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Ectonurite' || disguise == 'Ghostfreak') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Galvan' || disguise == 'Grey Matter') {
            if (property == "BREATHE_SPACE") {
				return entity.getData("fiskheroes:mask_open");
			}
			return property == "MASK_TOGGLE";
        }
        else if (disguise == 'Galvanic Mechamorph' || disguise == 'Upgrade') {
            return property == "MASK_TOGGLE" || property == "BREATHE_SPACE";
        }
        else if (disguise == 'Piscciss Volann' || disguise == 'Ripjaws') {
            return false;
        }
        else if (disguise == 'Kineceleran' || disguise == 'XLR8') {
            return property == "MASK_TOGGLE";
        }
    }        
    if (playlist2 == true) {
        if (disguise == 'Splixson' || disguise == 'Ditto') {
            return false;
        }
        else if (disguise == 'Loboan' || disguise == 'Blitzwolfer') {
            return false;
        }
        else if (disguise == 'Flourana' || disguise == 'Wildvine') {
            return false;
        }
        else if (disguise == 'Tokustar' || disguise == 'Way Big') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Thep Khufan' || disguise == 'Snare-Oh') {
            return false;
        }
        else if (disguise == 'Transylian' || disguise == 'Frankenstrike') {
            return property == "BREATHE_SPACE";
        }
		else if (disguise == 'Opticoid' || disguise == 'Eye Guy') {
            return property == "MASK_TOGGLE";
        }
    } 
    if (playlist3 == true) { 
        if (disguise == 'Methanosian' || disguise == 'Swampfire') {
            return property == "MASK_TOGGLE";
        }
        else if (disguise == 'Vaxasaurian' || disguise == 'Humungousaur') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Sonarosian' || disguise == 'Echo Echo') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Polymorph' || disguise == 'Goop') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Necrofriggian' || disguise == 'Big Chill') {
            return property == "MASK_TOGGLE" || property == "BREATHE_SPACE";
        }
        else if (disguise == 'Celestialsapien' || disguise == 'Alien X') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Aerophibian' || disguise == 'Jetray') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Crystalsapien' || disguise == 'Chromastone') {
            return property == "BREATHE_SPACE";
        }
        else if (disguise == 'Arachnichimp' || disguise == 'Spidermonkey') {
            return false;
        }
        else if (disguise == 'Cerebrocrustacean' || disguise == 'Brainstorm') {
          return false;
        }
    }
  return false;
}

function hasPermission(entity, permission) {
    var alien = entity.getData('omnitrixfull:dyn/omni_transform') && entity.getEquipmentInSlot(3).nbt().getString('CurrentAlien');
    var omnitrix = (entity.getEquipmentInSlot(3));
	var nbt = (omnitrix.nbt());

    var recalibrating = (omnitrix.nbt().getBoolean("Recalibrating"));
    var recalibrated = (omnitrix.nbt().getBoolean("Recalibrated"));
    var mastercontrol = (omnitrix.nbt().getBoolean("MasterControl") && !recalibrating);
	var display = omnitrix.nbt().getString('ActiveMode') == "Display";
    var playlist1 = (!recalibrated || omnitrix.nbt().getBoolean("Playlist1") || mastercontrol);
    var playlist2 = (omnitrix.nbt().getBoolean("Playlist2") || mastercontrol);
    var playlist3 = (omnitrix.nbt().getBoolean("Playlist3") || mastercontrol || recalibrated);
    
    if (playlist1 == true) {
        if (alien == "Grey Matter") {
			if (permission == "USE_COLD_GUN" || permission == "USE_RIPS_GUN" || permission == "USE_CHRONOS_RIFLE" || permission == "USE_HEAT_GUN") {
            return entity.getData("fiskheroes:scale") == 1 && (entity.getHeldItem().name() == "fiskheroes:rip_hunters_gun" || entity.getHeldItem().name() == "fiskheroes:heat_gun" || entity.getHeldItem().name() == "fiskheroes:chronos_rifle" || entity.getHeldItem().name() == "fiskheroes:cold_gun");
			}
		}
    } 
    return false;
	
    return permission == "USE_COLD_GUN" || permission == "USE_RIPS_GUN" || permission == "USE_CHRONOS_RIFLE" || permission == "USE_HEAT_GUN";
}
