import { ActionFormData, ModalFormData } from "@minecraft/server-ui";
import { world, ItemStack, MinecraftItemTypes } from "@minecraft/server";

class put_id_command_ui{
  constructor(player, entity){
    this.player = player;
    this.entity = entity;

    this.title="";
    this.type_id= "";
    this.command="";
    this.put="";
    this.ui_close=function(player,entity){};
    this.ui_open =function(player,entity){};
    //this.show(this.player);
  }
  get inventory_hand(){
    this.ui_close=function(player,entity){
      new gc_ui(player, entity).inventory;
    };
    this.type_id= "hand";
    this.command="replaceitem entity @s slot.weapon.mainhand 0 ";
    this.show(this.player);
  }
  get inventory_head(){
    this.ui_close=function(player,entity){
      new gc_ui(player, entity).inventory;
    };
    this.type_id= "head";
    this.command="replaceitem entity @s slot.armor.head 0";
    this.show(this.player);
  }
  get inventory_chest(){
    this.ui_close=function(player,entity){
      new gc_ui(player, entity).inventory;
    };
    this.type_id= "chestplate";
    this.command="replaceitem entity @s slot.armor.chest 0";
    this.show(this.player);
  }
  get inventory_legs(){
    this.ui_close=function(player,entity){
      new gc_ui(player, entity).inventory;
    };
    this.type_id= "legs";
    this.command="replaceitem entity @s slot.armor.legs 0";
    this.show(this.player);
  }
  get inventory_feet(){
    this.ui_close=function(player,entity){
      new gc_ui(player, entity).inventory;
    };
    this.type_id= "feet";
    this.command="replaceitem entity @s slot.armor.feet 0";
    this.show(this.player);
  }
  
  show(player){
    let ui = new ModalFormData();
    ui.title(this.title);
    ui.textField("id:", 'minecraft:air');
    
    ui.show(player).then((response) => {
      const [id] = response.formValues;
      Tag(this.entity, `${this.type_id}__${id}`);
      this.ui_close( this.player, this.entity );
      this.entity.runCommandAsync(`${this.command} ${id||"air"}`);
    });
  }
}
class put_ui{
  constructor(player, entity){
    this.player = player;
    this.entity = entity;

    this.title="";
    this.name_field="";
    this.example_field="";
	this.f_put= function(player, entity, put){}
    this.ui_close=function(player,entity){};
    this.ui_open =function(player,entity){};
    //this.show(this.player);
  }
  get name_edit(){
    this.ui_close=function(player,entity){
      new gc_ui(player, entity).customize_appearance;
    };
    this.name_field="name:";
    this.example_field="NPC";
	this.f_put= function(player, entity, put){
		entity.nameTag = put
	}
	
    this.show(this.player); 
  }
  get animation(){
    this.ui_close=function(player,entity){
      new gc_ui(player, entity).customize_appearance;
    };
    this.name_field="animation:";
    this.example_field="animation.null";
	this.f_put= function(player, entity, put){
		entity.runCommandAsync (`playanimation @s "${put||"animation.null"}" "${put||"animation.null"}" 0`)
	}
	
    this.show(this.player); 
  }
  
  show(player){
    let ui = new ModalFormData();
    ui.title(this.title);
    ui.textField( this.name_field, this.example_field);
    
    ui.show(player).then((response) => {
      const [id] = response.formValues;
      this.ui_close( this.player, this.entity );
      this.f_put( this.player, this.entity, id );
    });
  }
}


class gc_ui {
  constructor(player, entity){
	this.entityName= entity.nameTag
    this.tags= entity.getTags();
    this.classic_skin_id_icon = [
      "minecraft/classic_skin/steve/icon",
      "minecraft/classic_skin/alex/icon",
  
      "gabriielcraft/classic_skin/skin_1/icon",
      "gabriielcraft/classic_skin/skin_2/icon",
      "gabriielcraft/classic_skin/skin_3/icon",
      "gabriielcraft/classic_skin/skin_4/icon",
      "gabriielcraft/classic_skin/skin_5/icon",
      "gabriielcraft/classic_skin/skin_6/icon",
      "gabriielcraft/classic_skin/skin_7/icon",
      "gabriielcraft/classic_skin/skin_8/icon",
      "gabriielcraft/classic_skin/skin_9/icon",
      "gabriielcraft/classic_skin/skin_10/icon",
      "gabriielcraft/classic_skin/skin_11/icon",
      "gabriielcraft/classic_skin/skin_12/icon",
      "gabriielcraft/classic_skin/skin_13/icon",
      "gabriielcraft/classic_skin/skin_14/icon",
      "gabriielcraft/classic_skin/skin_15/icon",
      "gabriielcraft/classic_skin/skin_16/icon",
      "gabriielcraft/classic_skin/skin_17/icon",
      "gabriielcraft/classic_skin/skin_18/icon",
      "gabriielcraft/classic_skin/skin_19/icon",
      "gabriielcraft/classic_skin/skin_20/icon"
  ];
    for(let i=1;i<1001;i++){
  	  this.classic_skin_id_icon.push(`custom/classic_skin/skin_${i}/skin`)
    }
    this.player = player;
    this.entity = entity;
    this.buttons=[];
    this.event = function(entity){
      let tags= entity.getTags(), events= '"null":0';
      for(let i=0;i<tags.length;i++){
        let tag= tags[i].split("__");
        events= `${events}, "${tag[0]}":"${tag[1]}"`;
      }
      events= JSON.parse(`{${events}}`);
      return events;
    }(entity);
    
    this.title="";
    this.body="";
    this.ui_close=function(player,entity){};
    this.ui_open =function(player,entity){};
  //this.button("name", "img", function(player,entity){} )
  //this.show(this.player);
  }
  button(nome, img, js){ this.buttons.push({"nome":nome, "img":img, "js":js}); }
  show(player){
    let ui = new ActionFormData();
    ui.title(this.title);
    ui.body(this.body);
    this.ui_open( this.player, this.entity );
    for(let i=0;i<this.buttons.length;i++){ ui.button(this.buttons[i].nome, this.buttons[i].img); }
    ui.show(player).then((response) => {
      if (response.isCanceled === true) { this.ui_close( this.player, this.entity ) }
      for(let i=0;i<this.buttons.length;i++){if (response.selection === i){ this.buttons[i].js(this.player, this.entity); }}
    });
  }
  
  
  get default_test(){
    this.title= "titulo";
    this.body= "descrição";
    this.ui_open= function(player, entity){
      player.runCommandAsync('say open');
    };
    this.ui_close= function(player, entity){
      player.runCommandAsync('say close');
    };
    this.button("nome1", "", function(player, entity){
      new gc_ui(player, entity).default_test;
    });
    this.button("nome2", "", function(player, entity){
      player.runCommandAsync("say foi");
      entity.runCommandAsync("say foi");
    });
    this.button("exit", "", function(player, entity){
      new gc_ui(player, entity).default;
    });
    
    
    this.show(this.player);
  }

  get move_npc_default(){
    let find = function (array, txt) { for(let i=0;i<array.length;i++){ if(array[i].substring(0, txt.length)===txt){ return array[i] } } },
          tagB= find(this.tags, "tag");
    this.title= "move npc";
    this.body= "";
    this.button(`gc.npc.ui.button.setTag.${tagB||"none"}`, "textures/ui/dressing_room_customization.png", function(player, entity){
      new gc_ui(player, entity).move_npc_default_setTag(1);
    });
    this.button(`speed: ${this.event.speed||"0"}`, "textures/ui/speed_effect.png", function(player, entity){
      new gc_ui(player, entity).move_npc_default_speed;
    });
    this.button(`kill`, "textures/ui/barrier.png", function(player, entity){
      entity.triggerEvent('gc:kill');
    });

    
    this.show(this.player);
  }
      move_npc_default_setTag(pag){
    let find = function (array, txt) { for(let i=0;i<array.length;i++){ if(array[i].substring(0, txt.length)===txt){ return array[i] } } },
        tagB= find(this.tags, "tag"),
        tags= this.tags;
    this.title= "move npc";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).move_npc_default;
    });
    if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).move_npc_default_setTag(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).move_npc_default_setTag(pag);
      });
    }
    if(pag<5){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).move_npc_default_setTag(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).move_npc_default_setTag(pag);
      });
    }

    if(pag===1){this.button(`none`, "textures/ui/creator_glyph_color.png", function(player, entity){
      try{entity.removeTag(tagB)}catch(e){}
      new gc_ui(player, entity).move_npc_default;
    })}
    for(let i=pag*20-20;i<pag*20;i++){
      this.button(`tag${i}`, "textures/ui/creator_glyph_color.png", function(player, entity){
        try{entity.removeTag(tagB)}catch(e){}
        entity.addTag(`tag${i}`);
        new gc_ui(player, entity).move_npc_default;
      });
      
    }    
    this.show(this.player);
  }
  get move_npc_default_speed(){
    let find = function (array, txt) { for(let i=0;i<array.length;i++){ if(array[i].substring(0, txt.length)===txt){ return array[i] } } },
        tagB= find(this.tags, "speed__"),
        tags= this.tags;
    this.title= "move npc";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).move_npc_default;
    });

    for(let i=0;i<11;i++){
      this.button(`${i}`, "textures/ui/creator_glyph_color.png", function(player, entity){
        try{entity.removeTag(tagB)}catch(e){}
        entity.addTag(`speed__${i}`);
        new gc_ui(player, entity).move_npc_default;
      });
      
    }    
    this.show(this.player);
  }
  
  get default(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.customize_appearance", "textures/ui/dressing_room_customization.png", function(player, entity){
      new gc_ui(player, entity).customize_appearance;
    });
    this.button("gc.npc.ui.button.inventory", "textures/ui/inventory_icon.png", function(player, entity){
      new gc_ui(player, entity).inventory;
    });
    this.button("gc.npc.ui.button.components", "textures/ui/creator_glyph_color.png", function(player, entity){
      new gc_ui(player, entity).components;
    });
    this.button("gc.npc.ui.button.behaviors", "textures/ui/creator_glyph_color.png", function(player, entity){
      new gc_ui(player, entity).behaviors;
    });
    this.button("gc.npc.ui.button.functions", "textures/ui/creator_glyph_color.png", function(player, entity){
      new gc_ui(player, entity).functions;
    });
    this.button("gc.npc.ui.button.experimental", "textures/ui/creator_glyph_color.png", function(player, entity){
      new gc_ui(player, entity).experimental;
    });
    this.button(`kill`, "textures/ui/barrier.png", function(player, entity){
      entity.triggerEvent('gc:kill');
    });
    
    
    this.show(this.player);
  }
  
  get behaviors(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).default;
    });
    
    this.button(`gc.npc.ui.button.behaviors.random_stroll_${this.event.random_stroll||"false"}`, "textures/ui/creator_glyph_color.png", function(player, entity){
      entity.triggerEvent('gc:random_stroll');
      new gc_ui(player, entity).behaviors;
    });
    this.button(`gc.npc.ui.button.behaviors.attackable_target_${this.event.attackable_target||"nothing"}`, "textures/ui/strength_effect.png", function(player, entity){
      new gc_ui(player, entity).behaviors_attackable_target;
    });
    this.button(`gc.npc.ui.button.behaviors.run_from_${this.event.run_from||"nothing"}`, "textures/ui/speed_effect.png", function(player, entity){
      new gc_ui(player, entity).behaviors_run_from;
    });
    if(this.event.look_at_player!=="ever"){
      this.button(`gc.npc.ui.button.behaviors.look_at_player_${this.event.look_at_player||"never"}`, "textures/ui/ender_eye.png", function(player, entity){
        entity.triggerEvent(`gc:look_at_player__ever`);
        new gc_ui(player, entity).behaviors;
      });
    } else {
      this.button(`gc.npc.ui.button.behaviors.look_at_player_${this.event.look_at_player||"never"}`, "textures/ui/ender_eye.png", function(player, entity){
        entity.triggerEvent(`gc:look_at_player__never`);
        new gc_ui(player, entity).behaviors;
      });
    }
    

    this.show(this.player);
  }
  get behaviors_attackable_target(){
    let lista= `nothing
all
monster
mob
fish
bat
blaze
cat
cavespider
chicken
cod
cow
creeper
dolphin
donkey
drowned
guardian_elder
dragon
enderman
endermite
evocation_illager
fox
ghast
guardian
horse
husk
irongolem
llama
magmacube
mushroomcow
mule
npc
ocelot
panda
phantom
pig
pillager
player
polarbear
pufferfish
rabbit
salmon
sheep
shulker
silverfish
skeletonhorse
skeleton
slime
snowgolem
spider
squid
stray
tnt
tropicalfish
turtle
villager
vindicator
wandering_trader
witch
wither
wolf
zombiehorse
zombie_pigman
zombie`.split("\n");
    
    this.title= "npc editor";
    this.body= 
`"minecraft:behaviors.nearest_attackable_target": {}
"test": "is_family"
`;
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).behaviors;
    });
    
		this.button(`gc.npc.ui.button.behaviors.attackable_target.target_by_hurt_${this.event.target_by_hurt||"false"}`, "textures/ui/sword.png", function(player, entity){
			entity.triggerEvent(`gc:target_by_hurt`);
			new gc_ui(player, entity).behaviors_attackable_target;
		});
    if(this.event.behavior_attack!=='melee'&&this.event.behavior_attack!=='ranged'&&this.event.behavior_attack!=='follow'){
      this.button(`gc.npc.ui.button.behaviors.attackable_target.behavior_attack_none`, "textures/ui/barrier.png", function(player, entity){
        entity.triggerEvent(`gc:behavior_attack__melee`);
        new gc_ui(player, entity).behaviors_attackable_target;
      });
    }
    if(this.event.behavior_attack==='melee'){
      this.button(`gc.npc.ui.button.behaviors.attackable_target.behavior_attack_melee`, "textures/ui/attack.png", function(player, entity){
        entity.triggerEvent(`gc:behavior_attack__ranged`);
        new gc_ui(player, entity).behaviors_attackable_target;
      });
      this.button(`gc.npc.ui.button.behaviors.attackable_target.damage_${this.event.damage||"1"}`, "textures/ui/strength_effect.png", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_damage(1);
      });
    }
    if(this.event.behavior_attack==='ranged'){
      this.button(`gc.npc.ui.button.behaviors.attackable_target.behavior_attack_ranged`, "textures/ui/interact.png", function(player, entity){
        entity.triggerEvent(`gc:behavior_attack__follow`);
        entity.triggerEvent(`gc:shooter__none`);
        new gc_ui(player, entity).behaviors_attackable_target;
      });
      this.button(`gc.npc.ui.button.behaviors.attackable_target.shooter_${this.event.shooter||"none"}`, "textures/ui/bow.png", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_shooter;
      });
    }
    if(this.event.behavior_attack==='follow'){
      this.button(`gc.npc.ui.button.behaviors.attackable_target.behavior_attack_follow`, "textures/ui/sprint.png", function(player, entity){
        entity.triggerEvent(`gc:behavior_attack__none`);
        entity.triggerEvent(`gc:follow_player__false`);
        new gc_ui(player, entity).behaviors_attackable_target;
      });
    }
    for (let i=0;i<lista.length;i++){
      this.button(`gc.npc.ui.button.behaviors.attackable_target.${lista[i]}`, "textures/ui/sword.png", function(player, entity){
        entity.triggerEvent(`gc:attackable_target__${lista[i]}`);
        new gc_ui(player, entity).behaviors;
      });
      if(i===1){
        this.button(`gc.npc.ui.button.behaviors.attackable_target.tags`, "textures/ui/sword.png", function(player, entity){
          new gc_ui(player, entity).behaviors_attackable_target_tag(1);
        });
      }
    }
    
    this.show(this.player);
  }
      behaviors_attackable_target_damage(pag){
        const player=this.player, entity=this.entity;
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).behaviors_attackable_target;
    });
    if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_damage(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_damage(pag);
      });
    }
    if(pag<50){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_damage(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_damage(pag);
      });
    }

    for(let i=pag*20-20;i<pag*20;i++){
      this.button(`${i}`, "textures/ui/strength_effect.png", function(player, entity){
        entity.triggerEvent(`gc:damage__${i}`);
        new gc_ui(player, entity).behaviors_attackable_target;
      });
      
    }


    this.show(this.player);
  }
  get behaviors_attackable_target_shooter(){
    let lista= `none
arrow
dragon_fireball
egg
fireball
fireworks_rocket
llama_spit
shulker_bullet
small_fireball
snowball
thrown_trident
wither_skull_dangerous
wither_skull`.split("\n");
    
    this.title= "npc editor";
    this.body= ``;
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).behaviors_attackable_target;
    });
    
    for (let i=0;i<lista.length;i++){
      this.button(`gc.npc.ui.button.behaviors.attackable_target.shooter.${lista[i]}`, "textures/ui/creator_glyph_color.png", function(player, entity){
        entity.triggerEvent(`gc:shooter__${lista[i]}`);
        new gc_ui(player, entity).behaviors_attackable_target;
      });
    }

    this.show(this.player);
  }
      behaviors_attackable_target_tag(pag){
        const player=this.player, entity=this.entity;
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).behaviors_attackable_target;
    });
    if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_tag(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_tag(pag);
      });
    }
    if(pag<5){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_tag(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).behaviors_attackable_target_tag(pag);
      });
    }

    for(let i=pag*20-20;i<pag*20;i++){
      this.button(`tag${i}`, "textures/ui/sword.png", function(player, entity){
        entity.triggerEvent(`gc:attackable_target__tag${i}`);
        new gc_ui(player, entity).behaviors;
      });
      
    }


    this.show(this.player);
  }
  get behaviors_run_from(){
    let lista= `nothing
all
monster
mob
fish
bat
blaze
cat
cavespider
chicken
cod
cow
creeper
dolphin
donkey
drowned
guardian_elder
dragon
enderman
endermite
evocation_illager
fox
ghast
guardian
horse
husk
irongolem
llama
magmacube
mushroomcow
mule
npc
ocelot
panda
phantom
pig
pillager
player
polarbear
pufferfish
rabbit
salmon
sheep
shulker
silverfish
skeletonhorse
skeleton
slime
snowgolem
spider
squid
stray
tnt
tropicalfish
turtle
villager
vindicator
wandering_trader
witch
wither
wolf
zombiehorse
zombie_pigman
zombie`.split("\n")

    this.title= "npc editor";
    this.body= 
`"minecraft:behaviors.avoid_mob_type": {}
"test": "is_family"
`;
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).behaviors;
    });
    
    for (let i=0;i<lista.length;i++){
      this.button(`gc.npc.ui.button.behaviors.run_from.${lista[i]}`, "textures/ui/speed_effect.png", function(player, entity){
        entity.triggerEvent(`gc:run_from__${lista[i]}`);
        new gc_ui(player, entity).behaviors;
      });
    }


    this.show(this.player);
  }
  
  get components(){
		let collision_box = this.event.collision_box||"0.6-1.7";
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).default;
    });
    this.button(`gc.npc.ui.button.components.npc_ui_${this.event.npc_ui||"false"}`, `textures/ui/npc_ui_${this.event.npc_ui||"false"}.png`, function(player, entity){
      entity.triggerEvent(`gc:npc_ui`);
	  new gc_ui(player, entity).components;
    });
    this.button(`gc.npc.ui.button.components.trade_${this.event.trade||"none"}`, "textures/ui/icon_deals.png", function(player, entity){
      new gc_ui(player, entity).components_trade;
    });
    this.button(`gc.npc.ui.button.components.health_${this.event.health||"1"}`, "textures/ui/heart.png", function(player, entity){
      new gc_ui(player, entity).components_health(1);
    });
    this.button(`gc.npc.ui.button.components.movementSpeed_${this.event.movementSpeed||"4"}`, "textures/ui/speed_effect.png", function(player, entity){
      new gc_ui(player, entity).components_moviment_speed;
    });
    this.button(`gc.npc.ui.button.behaviors.attackable_target.damage_${this.event.damage||"1"}`, "textures/ui/strength_effect.png", function(player, entity){
      new gc_ui(player, entity).components_damage(1);
    });
    this.button(`gc.npc.ui.button.components.scale_${this.event.scale||"1"}`, "textures/ui/profile_new_look.png", function(player, entity){
      new gc_ui(player, entity).components_scale(1);
    });
    this.button(`collision_box: §2[ §3${collision_box.split("-")[0]}§2, §3${collision_box.split("-")[1]}§2 ]`, `textures/ui/creator_glyph_color.png`, function(player, entity){
	  new gc_ui(player, entity).components_collision_box;
    });
    this.button(`family:§2 ${this.event.family||"npc"}`, "textures/ui/creator_glyph_color.png", function(player, entity){
      new gc_ui(player, entity).components_family;
    });

    this.show(this.player);
  }
  get components_family(){
    let lista= `monster
mob
fish
bat
blaze
cat
cavespider
chicken
cod
cow
creeper
dolphin
donkey
drowned
guardian_elder
dragon
enderman
endermite
evocation_illager
fox
ghast
guardian
horse
husk
irongolem
llama
magmacube
mushroomcow
mule
npc
ocelot
panda
phantom
pig
pillager
player
polarbear
pufferfish
rabbit
salmon
sheep
shulker
silverfish
skeletonhorse
skeleton
slime
snowgolem
spider
squid
stray
tnt
tropicalfish
turtle
villager
vindicator
wandering_trader
witch
wither
wolf
zombiehorse
zombie_pigman
zombie`.split("\n");
    
    this.title= "npc editor";
    this.body= ``;
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components;
    });
    
    for (let i=0;i<lista.length;i++){
      this.button(`§2${lista[i]}`, "textures/ui/creator_glyph_color.png", function(player, entity){
        entity.triggerEvent(`gc:family__${lista[i]}`);
        new gc_ui(player, entity).components;
      });
    }
    
    this.show(this.player);
  }
  get components_collision_box(){
		let collision_box = this.event.collision_box||"0.6-1.7";
    this.title= "npc editor";
    this.body= ``;
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components;
    });
    this.button(`x: ${collision_box.split("-")[0]}`, "textures/ui/creator_glyph_color.png", function(player, entity){
      new gc_ui(player, entity).components_collision_box_x(1);
    });
    this.button(`y: ${collision_box.split("-")[1]}`, "textures/ui/creator_glyph_color.png", function(player, entity){
      new gc_ui(player, entity).components_collision_box_y(1);
    });
    
    
    this.show(this.player);
  }
      components_collision_box_x(pag){
				let collision_box= this.event.collision_box||"0.6-1.7"
    const player=this.player, entity=this.entity; 
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components_collision_box;
    });
    if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).components_collision_box_x(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).components_collision_box_x(pag);
      });
    }
    if(pag<6){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).components_collision_box_x(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).components_collision_box_x(pag);
      });
    }


    if(pag<6){
			for(let i=pag*10-10;i<pag*10;i++){
				this.button(`${i/10}`, "textures/ui/creator_glyph_color.png", function(player, entity){
					entity.triggerEvent(`gc:collision_box__${i/10}-${collision_box.split("-")[1]}`);
					new gc_ui(player, entity).components_collision_box;
				});
			}
		} else {
      this.button(`5`, "textures/ui/creator_glyph_color.png", function(player, entity){
        entity.triggerEvent(`gc:collision_box__5-${collision_box.split("-")[1]}`);
        new gc_ui(player, entity).components_collision_box;
      });
		}
    this.show(this.player);
  }
      components_collision_box_y(pag){
				let collision_box= this.event.collision_box||"0.6-1.7"
    const player=this.player, entity=this.entity; 
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components_collision_box;
    });
    if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).components_collision_box_y(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).components_collision_box_y(pag);
      });
    }
    if(pag<6){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).components_collision_box_y(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).components_collision_box_y(pag);
      });
    }


    if(pag<6){
			for(let i=pag*10-10;i<pag*10;i++){
				this.button(`${i/10}`, "textures/ui/creator_glyph_color.png", function(player, entity){
					entity.triggerEvent(`gc:collision_box__${collision_box.split("-")[0]}-${i/10}`);
					new gc_ui(player, entity).components_collision_box;
				});
			}
		} else {
      this.button(`5`, "textures/ui/creator_glyph_color.png", function(player, entity){
        entity.triggerEvent(`gc:collision_box__${collision_box.split("-")[1]}-5`);
        new gc_ui(player, entity).components_collision_box;
      });
		}
    this.show(this.player);
  }

      components_damage(pag){
        const player=this.player, entity=this.entity;
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components;
    });
    if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).components_damage(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).components_damage(pag);
      });
    }
    if(pag<50){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).components_damage(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).components_damage(pag);
      });
    }

    for(let i=pag*20-20;i<pag*20;i++){
      this.button(`${i}`, "textures/ui/strength_effect.png", function(player, entity){
        entity.triggerEvent(`gc:damage__${i}`);
        new gc_ui(player, entity).components;
      });
      
    }


    this.show(this.player);
  }
  get components_trade(){
    this.title= "npc editor";
    this.body= ``;
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components;
    });
		this.button(`gc.npc.ui.button.components.trade.none`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__none`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.farmer`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__farmer`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.fisherman`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__fisherman`);
			new gc_ui(player, entity).components;
		});    
		this.button(`gc.npc.ui.button.components.trade.shepherd`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__shepherd`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.fletcher`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__fletcher`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.librarian`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__librarian`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.cartographer`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__cartographer`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.cleric`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__cleric`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.armor`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__armor`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.weapon`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__weapon`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.tool`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__tool`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.butcher`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__butcher`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.leather`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__leather`);
			new gc_ui(player, entity).components;
		});
		this.button(`gc.npc.ui.button.components.trade.mason`, `textures/ui/icon_deals.png`, function(player, entity){
			entity.triggerEvent(`gc:trade__mason`);
			new gc_ui(player, entity).components;
		});

    
    
    this.show(this.player);
  }
  get components_moviment_speed(){
    this.title= "npc editor";
    this.body= 
`"minecraft:movement": {}
"value": §e( +1 = +0.05 )`;
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components;
    });
    for (let i=0; i<11; i++) {
      this.button(`Speed: ${i}`, `textures/ui/speed_effect.png`, function(player, entity){
        entity.triggerEvent(`gc:movementSpeed__${i}`);
        new gc_ui(player, entity).components;
      });
    }
    
    
    
    this.show(this.player);
  }
      components_health(pag){
        const player=this.player, entity=this.entity;
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components;
    });
		this.button(`gc.npc.ui.button.components.boss_life_${this.event.boss_life||"false"}`, `textures/ui/heart.png`, function(player, entity){
			entity.triggerEvent(`gc:boss_life`);
			new gc_ui(player, entity).components_health(pag);
		});
    if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).components_health(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).components_health(pag);
      });
    }
    if(pag<50){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).components_health(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).components_health(pag);
      });
    }

		
    for(let i=pag*20-20;i<pag*20;i++){
      this.button(`${i}`, "textures/ui/heart.png", function(player, entity){
        entity.triggerEvent(`gc:health__${i}`);
        new gc_ui(player, entity).components;
      });
      
    }


    this.show(this.player);
  }
      components_scale(pag){
        const player=this.player, entity=this.entity;
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).components;
    });

    for(let i=pag*20-20+1;i<pag*20+1;i++){
      this.button(`${i/10}`, "textures/ui/profile_new_look.png", function(player, entity){
        entity.triggerEvent(`gc:scale__${i/10}`);
        new gc_ui(player, entity).components;
      });
      
    }


    this.show(this.player);
  }
  
  get experimental(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).default;
    });
    this.button(`gc.npc.ui.button.experimental.sleep_${this.event.sleep||"false"}`, "textures/ui/speed_effect.png", function(player, entity){
      entity.triggerEvent(`gc:sleep`);
      new gc_ui(player, entity).experimental;
    });
    this.button(`gc.npc.ui.button.transferNPC`, "textures/ui/backup_replace.png", function(player, entity){
      new gc_ui(player, entity).transferNPC;
    });
		

    this.show(this.player);
  }
  
  get functions(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).default;
    });
    this.button(`gc.npc.ui.button.functions.immortality_${this.event.immortality||"false"}`, "textures/ui/heart.png", function(player, entity){
      entity.triggerEvent(`gc:immortality`);
      new gc_ui(player, entity).functions;
    });
    this.button(`gc.npc.ui.button.functions.show_name_${this.event.show_name||"false"}`, "textures/ui/name_tag.png", function(player, entity){
      entity.triggerEvent(`gc:show_name`);
      new gc_ui(player, entity).functions;
    });
    this.button(`gc.npc.ui.button.functions.follow_player_${this.event.follow_player||"false"}`, "textures/ui/sprint.png", function(player, entity){
      entity.triggerEvent(`gc:follow_player`);
      new gc_ui(player, entity).functions;
    });
    if(this.event.pushable!==undefined){
      this.button(`gc.npc.ui.button.functions.pushable_${this.event.pushable||"true"}`, "textures/ui/armor_stand.png", function(player, entity){
        entity.triggerEvent(`gc:pushable`);
        new gc_ui(player, entity).functions;
      });
    }else{
      this.button(`gc.npc.ui.button.functions.pushable_${this.event.pushable||"true"}`, "textures/ui/armor_stand.png", function(player, entity){
        entity.triggerEvent(`gc:pushable__false`);
        new gc_ui(player, entity).functions;
      });
    }
    this.button(`gc.npc.ui.button.functions.team_${this.event.team||"none"}`, "textures/ui/dressing_room_skins.png", function(player, entity){
      new gc_ui(player, entity).functions_team;
    });
	

    this.show(this.player);
  }
  get functions_team(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).functions;
    });
    this.button(`gc.npc.ui.button.functions.team.none`, "textures/ui/barrier.png", function(player, entity){
      entity.triggerEvent(`gc:team__none`);
      new gc_ui(player, entity).functions;
    });
    this.button(`gc.npc.ui.button.functions.team.red`, "textures/ui/red.png", function(player, entity){
      entity.triggerEvent(`gc:team__red`);
      new gc_ui(player, entity).functions;
    });
    this.button(`gc.npc.ui.button.functions.team.blue`, "textures/ui/blue.png", function(player, entity){
      entity.triggerEvent(`gc:team__blue`);
      new gc_ui(player, entity).functions;
    });
    this.button(`gc.npc.ui.button.functions.team.green`, "textures/ui/green.png", function(player, entity){
      entity.triggerEvent(`gc:team__green`);
      new gc_ui(player, entity).functions;
    });
    this.button(`gc.npc.ui.button.functions.team.yellow`, "textures/ui/yellow.png", function(player, entity){
      entity.triggerEvent(`gc:team__yellow`);
      new gc_ui(player, entity).functions;
    });
		

    this.show(this.player);
  }
  
  get inventory(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).default;
    });
    this.button(`gc.npc.ui.button.inventory.inventory_${this.event.inventory||"false"}`, "textures/ui/inventory_icon.png", function(player, entity){
      entity.triggerEvent(`gc:inventory`);
	  new gc_ui(player, entity).inventory;
    });
    this.button(`Hand:§2 ${this.event.hand||"§4none"}`, "textures/ui/attack.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand;
    });
    this.button(`Helmet:§2 ${this.event.head||"§4none"}`, "textures/ui/npc_armor_slot_helmet.png", function(player, entity){
      new gc_ui(player, entity).inventory_head;
    });
    this.button(`Chestplate:§2 ${this.event.chestplate||"§4none"}`, "textures/ui/npc_armor_slot_chestplate.png", function(player, entity){
      new gc_ui(player, entity).inventory_chest;
    });
    this.button(`Legs:§2 ${this.event.legs||"§4none"}`, "textures/ui/npc_armor_slot_leggings.png", function(player, entity){
      new gc_ui(player, entity).inventory_legs;
    });
    this.button(`Boots:§2 ${this.event.feet||"§4none"}`, "textures/ui/npc_armor_slot_boots.png", function(player, entity){
      new gc_ui(player, entity).inventory_feet;
    });


    this.show(this.player);
  }
  get inventory_hand(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory;
    });
    this.button(`Put id`, "textures/ui/magnifyingGlass.png", function(player, entity){
      new put_id_command_ui(player, entity).inventory_hand;
    });
    this.button(`swords`, "textures/ui/sword.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand_swords;
    });
    this.button(`pickaxes`, "textures/ui/iron_pickaxe.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand_pickaxes;
    });
    this.button(`axes`, "textures/ui/iron_axe.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand_axes;
    });
    this.button(`shovels`, "textures/ui/iron_shovel.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand_shovels;
    });
    this.button(`hoes`, "textures/ui/iron_hoe.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand_hoes;
    });


    this.show(this.player);
  }
  get inventory_hand_swords(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand;
    });
    this.button(`item.wooden_sword.name`, "textures/items/wood_sword.png", function(player, entity){
      Tag(entity, `hand__wooden_sword`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 wooden_sword");
    });
    this.button(`item.stone_sword.name`, "textures/items/stone_sword.png", function(player, entity){
      Tag(entity, `hand__stone_sword`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 stone_sword");
    });
    this.button(`item.iron_sword.name`, "textures/items/iron_sword.png", function(player, entity){
      Tag(entity, `hand__iron_sword`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 iron_sword");
    });
    this.button(`item.golden_sword.name`, "textures/items/gold_sword.png", function(player, entity){
      Tag(entity, `hand__golden_sword`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 golden_sword");
    });
    this.button(`item.diamond_sword.name`, "textures/items/diamond_sword.png", function(player, entity){
      Tag(entity, `hand__diamond_sword`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 diamond_sword");
    });
    this.button(`item.netherite_sword.name`, "textures/items/netherite_sword.png", function(player, entity){
      Tag(entity, `hand__netherite_sword`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 netherite_sword");
    });


    this.show(this.player);
  }
  get inventory_hand_pickaxes(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand;
    });
    this.button(`item.wooden_pickaxe.name`, "textures/items/wood_pickaxe.png", function(player, entity){
      Tag(entity, `hand__wooden_pickaxe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 wooden_pickaxe");
    });
    this.button(`item.stone_pickaxe.name`, "textures/items/stone_pickaxe.png", function(player, entity){
      Tag(entity, `hand__stone_pickaxe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 stone_pickaxe");
    });
    this.button(`item.iron_pickaxe.name`, "textures/items/iron_pickaxe.png", function(player, entity){
      Tag(entity, `hand__iron_pickaxe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 iron_pickaxe");
    });
    this.button(`item.golden_pickaxe.name`, "textures/items/gold_pickaxe.png", function(player, entity){
      Tag(entity, `hand__golden_pickaxe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 golden_pickaxe");
    });
    this.button(`item.diamond_pickaxe.name`, "textures/items/diamond_pickaxe.png", function(player, entity){
      Tag(entity, `hand__diamond_pickaxe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 diamond_pickaxe");
    });
    this.button(`item.netherite_pickaxe.name`, "textures/items/netherite_pickaxe.png", function(player, entity){
      Tag(entity, `hand__netherite_pickaxe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 netherite_pickaxe");
    });


    this.show(this.player);
  }
  get inventory_hand_axes(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand;
    });
    this.button(`item.wooden_axe.name`, "textures/items/wood_axe.png", function(player, entity){
      Tag(entity, `hand__wooden_axe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 wooden_axe");
    });
    this.button(`item.stone_axe.name`, "textures/items/stone_axe.png", function(player, entity){
      Tag(entity, `hand__stone_axe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 stone_axe");
    });
    this.button(`item.iron_axe.name`, "textures/items/iron_axe.png", function(player, entity){
      Tag(entity, `hand__iron_axe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 iron_axe");
    });
    this.button(`item.golden_axe.name`, "textures/items/gold_axe.png", function(player, entity){
      Tag(entity, `hand__golden_axe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 golden_axe");
    });
    this.button(`item.diamond_axe.name`, "textures/items/diamond_axe.png", function(player, entity){
      Tag(entity, `hand__diamond_axe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 diamond_axe");
    });
    this.button(`item.netherite_axe.name`, "textures/items/netherite_axe.png", function(player, entity){
      Tag(entity, `hand__netherite_axe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 netherite_axe");
    });


    this.show(this.player);
  }
  get inventory_hand_shovels(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand;
    });
    this.button(`item.wooden_shovel.name`, "textures/items/wood_shovel.png", function(player, entity){
      Tag(entity, `hand__wooden_shovel`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 wooden_shovel");
    });
    this.button(`item.stone_shovel.name`, "textures/items/stone_shovel.png", function(player, entity){
      Tag(entity, `hand__stone_shovel`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 stone_shovel");
    });
    this.button(`item.iron_shovel.name`, "textures/items/iron_shovel.png", function(player, entity){
      Tag(entity, `hand__iron_shovel`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 iron_shovel");
    });
    this.button(`item.golden_shovel.name`, "textures/items/gold_shovel.png", function(player, entity){
      Tag(entity, `hand__golden_shovel`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 golden_shovel");
    });
    this.button(`item.diamond_shovel.name`, "textures/items/diamond_shovel.png", function(player, entity){
      Tag(entity, `hand__diamond_shovel`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 diamond_shovel");
    });
    this.button(`item.netherite_shovel.name`, "textures/items/netherite_shovel.png", function(player, entity){
      Tag(entity, `hand__netherite_shovel`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 netherite_shovel");
    });


    this.show(this.player);
  }
  get inventory_hand_hoes(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory_hand;
    });
    this.button(`item.wooden_hoe.name`, "textures/items/wood_hoe.png", function(player, entity){
      Tag(entity, `hand__wooden_hoe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 wooden_hoe");
    });
    this.button(`item.stone_hoe.name`, "textures/items/stone_hoe.png", function(player, entity){
      Tag(entity, `hand__stone_hoe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 stone_hoe");
    });
    this.button(`item.iron_hoe.name`, "textures/items/iron_hoe.png", function(player, entity){
      Tag(entity, `hand__iron_hoe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 iron_hoe");
    });
    this.button(`item.golden_hoe.name`, "textures/items/gold_hoe.png", function(player, entity){
      Tag(entity, `hand__golden_hoe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 golden_hoe");
    });
    this.button(`item.diamond_hoe.name`, "textures/items/diamond_hoe.png", function(player, entity){
      Tag(entity, `hand__diamond_hoe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 diamond_hoe");
    });
    this.button(`item.netherite_hoe.name`, "textures/items/netherite_hoe.png", function(player, entity){
      Tag(entity, `hand__netherite_hoe`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.weapon.mainhand 0 netherite_hoe");
    });


    this.show(this.player);
  }
  get inventory_head(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory;
    });
    this.button(`Put id`, "textures/ui/magnifyingGlass.png", function(player, entity){
      new put_id_command_ui(player, entity).inventory_head;
    });
    this.button(`item.leather_helmet.name`, "textures/items/leather_helmet", function(player, entity){
      Tag(entity, `head__leather_helmet`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.head 0 leather_helmet");
    });
    this.button(`item.chainmail_helmet.name`, "textures/items/chainmail_helmet.png", function(player, entity){
      Tag(entity, `head__chainmail_helmet`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.head 0 chainmail_helmet");
    });
    this.button(`item.iron_helmet.name`, "textures/items/iron_helmet.png", function(player, entity){
      Tag(entity, `head__iron_helmet`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.head 0 iron_helmet");
    });
    this.button(`item.golden_helmet.name`, "textures/items/gold_helmet.png", function(player, entity){
      Tag(entity, `head__golden_helmet`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.head 0 golden_helmet");
    });
    this.button(`item.diamond_helmet.name`, "textures/items/diamond_helmet.png", function(player, entity){
      Tag(entity, `head__diamond_helmet`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.head 0 diamond_helmet");
    });
    this.button(`item.netherite_helmet.name`, "textures/items/netherite_helmet.png", function(player, entity){
      Tag(entity, `head__netherite_helmet`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.head 0 netherite_helmet");
    });
    this.button(`item.turtle_helmet.name`, "textures/items/turtle_helmet.png", function(player, entity){
      Tag(entity, `head__turtle_helmet`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.head 0 turtle_helmet");
    });
    this.button(`tile.carved_pumpkin.name`, "textures/blocks/pumpkin_face_off.png", function(player, entity){
      Tag(entity, `head__carved_pumpkin`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.head 0 carved_pumpkin");
    });


    this.show(this.player);
  }
  get inventory_chest(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory;
    });
    this.button(`Put id`, "textures/ui/magnifyingGlass.png", function(player, entity){
      new put_id_command_ui(player, entity).inventory_chest;
    });
    this.button(`item.leather_chestplate.name`, "textures/items/leather_chestplate", function(player, entity){
      Tag(entity, `chestplate__leather_chestplate`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.chest 0 leather_chestplate");
    });
    this.button(`item.chainmail_chestplate.name`, "textures/items/chainmail_chestplate.png", function(player, entity){
      Tag(entity, `chestplate__chainmail_chestplate`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.chest 0 chainmail_chestplate");
    });
    this.button(`item.iron_chestplate.name`, "textures/items/iron_chestplate.png", function(player, entity){
      Tag(entity, `chestplate__iron_chestplate`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.chest 0 iron_chestplate");
    });
    this.button(`item.golden_chestplate.name`, "textures/items/gold_chestplate.png", function(player, entity){
      Tag(entity, `chestplate__golden_chestplate`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.chest 0 golden_chestplate");
    });
    this.button(`item.diamond_chestplate.name`, "textures/items/diamond_chestplate.png", function(player, entity){
      Tag(entity, `chestplate__diamond_chestplate`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.chest 0 diamond_chestplate");
    });
    this.button(`item.netherite_chestplate.name`, "textures/items/netherite_chestplate.png", function(player, entity){
      Tag(entity, `chestplate__netherite_chestplate`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.chest 0 netherite_chestplate");
    });
    this.button(`item.elytra.name`, "textures/items/elytra.png", function(player, entity){
      Tag(entity, `chestplate__elytra`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.chest 0 elytra");
    });


    this.show(this.player);
  }
  get inventory_legs(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory;
    });
    this.button(`Put id`, "textures/ui/magnifyingGlass.png", function(player, entity){
      new put_id_command_ui(player, entity).inventory_legs;
    });
    this.button(`item.leather_leggings.name`, "textures/items/leather_leggings", function(player, entity){
      Tag(entity, `legs__leather_leggings`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.legs 0 leather_leggings");
    });
    this.button(`item.chainmail_leggings.name`, "textures/items/chainmail_leggings.png", function(player, entity){
      Tag(entity, `legs__chainmail_leggings`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.legs 0 chainmail_leggings");
    });
    this.button(`item.iron_leggings.name`, "textures/items/iron_leggings.png", function(player, entity){
      Tag(entity, `legs__iron_leggings`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.legs 0 iron_leggings");
    });
    this.button(`item.golden_leggings.name`, "textures/items/gold_leggings.png", function(player, entity){
      Tag(entity, `legs__golden_leggings`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.legs 0 golden_leggings");
    });
    this.button(`item.diamond_leggings.name`, "textures/items/diamond_leggings.png", function(player, entity){
      Tag(entity, `legs__diamond_leggings`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.legs 0 diamond_leggings");
    });
    this.button(`item.netherite_leggings.name`, "textures/items/netherite_leggings.png", function(player, entity){
      Tag(entity, `legs__netherite_leggings`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.legs 0 netherite_leggings");
    });


    this.show(this.player);
  }
  get inventory_feet(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).inventory;
    });
    this.button(`Put id`, "textures/ui/magnifyingGlass.png", function(player, entity){
      new put_id_command_ui(player, entity).inventory_feet;
    });
    this.button(`item.leather_boots.name`, "textures/items/leather_boots", function(player, entity){
      Tag(entity, `feet__leather_boots`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.feet 0 leather_boots");
    });
    this.button(`item.chainmail_boots.name`, "textures/items/chainmail_boots.png", function(player, entity){
      Tag(entity, `feet__chainmail_boots`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.feet 0 chainmail_boots");
    });
    this.button(`item.iron_boots.name`, "textures/items/iron_boots.png", function(player, entity){
      Tag(entity, `feet__iron_boots`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.feet 0 iron_boots");
    });
    this.button(`item.golden_boots.name`, "textures/items/gold_boots.png", function(player, entity){
      Tag(entity, `feet__golden_boots`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.feet 0 golden_boots");
    });
    this.button(`item.diamond_boots.name`, "textures/items/diamond_boots.png", function(player, entity){
      Tag(entity, `feet__diamond_boots`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.feet 0 diamond_boots");
    });
    this.button(`item.netherite_boots.name`, "textures/items/netherite_boots.png", function(player, entity){
      Tag(entity, `feet__netherite_boots`);
      new gc_ui(player, entity).inventory;
      entity.runCommandAsync("replaceitem entity @s slot.armor.feet 0 netherite_boots");
    });


    this.show(this.player);
  }
  
  get transferNPC(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).experimental;
    });
    this.button(`gc.npc.ui.button.transferNPC.save`, "textures/ui/backup_replace.png", function(player, entity){
      new gc_ui(player, entity).transferNPC_save;
    });
    this.button(`gc.npc.ui.button.transferNPC.load`, "textures/ui/color_plus.png", function(player, entity){
      new gc_ui(player, entity).transferNPC_load;
    });


    this.show(this.player);
  }
  get transferNPC_save(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).transferNPC;
    });
		
		for(let i=1;i<11;i++){
			this.button(`gc.npc.ui.button.transferNPC.save${i}`, "textures/ui/backup_replace.png", function(player, entity){
				new gc_ui(player, entity).transferNPC;
				entity.runCommandAsync(`structure save CustomNPC_Save${i} ~~~ ~~~ true memory false`);
			});
		}


    this.show(this.player);
  }
  get transferNPC_load(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).transferNPC;
    });
		
		for(let i=1;i<11;i++){
			this.button(`gc.npc.ui.button.transferNPC.load${i}`, "textures/ui/color_plus.png", function(player, entity){
				entity.triggerEvent(`event:despawn`);
				entity.runCommandAsync(`structure load CustomNPC_Save${i} ~~~ 0_degrees none true false true`);
			});
		}


    this.show(this.player);
  }

	
  
  get animation(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).customize_appearance;
    });
		this.button(`gc.npc.ui.button.animation.0`, `textures/ui/sidebar_icons/character_creator.png`, function(player, entity){
			entity.triggerEvent(`gc:animation__0`);
			new gc_ui(player, entity).customize_appearance;
		});
		this.button(`gc.npc.ui.button.animation.custom`, "textures/ui/sidebar_icons/character_creator.png", function(player, entity){
      new gc_ui(player, entity).animation_custom(1);
		});
    for (let i=1001; i<1011; i++) {
      this.button(`gc.npc.ui.button.animation.${i}`, "textures/ui/sidebar_icons/character_creator.png", function(player, entity){
        entity.triggerEvent(`gc:animation__${i}`);
        new gc_ui(player, entity).customize_appearance;
      });
    }

    
    this.show(this.player);
  }
      animation_custom(pag){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).animation;
    });
		this.button(`gc.npc.ui.button.animation.runID`, "textures/ui/sidebar_icons/character_creator.png", function(player, entity){
      new put_ui(player, entity).animation;
		});
	if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).animation_custom(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).animation_custom(pag);
      });
    }
    if(pag<50){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).animation_custom(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).animation_custom(pag);
      });
    }

	
    for (let i=1+pag*20-20;i<1+pag*20;i++) {
      this.button(`gc.npc.ui.button.animation.${i}`, `textures/ui/sidebar_icons/character_creator.png`, function(player, entity){
        entity.triggerEvent(`gc:animation__${i}`);
        new gc_ui(player, entity).customize_appearance;
      });
    }
    
    this.show(this.player);
  }

  get customize_appearance(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).default;
    });
    this.button(`name: ${this.entityName}`, "textures/ui/name_tag.png", function(player, entity){
      new put_ui(player, entity).name_edit;
    });
    this.button("gc.npc.ui.button.customize_skin", "textures/ui/dressing_room_skins.png", function(player, entity){
      new gc_ui(player, entity).customize_skin;
    });
    this.button(`gc.npc.ui.button.animation_${this.event.animation||"0"}`, "textures/ui/sidebar_icons/character_creator.png", function(player, entity){
      new gc_ui(player, entity).animation;
    });
    
    
    this.show(this.player);
  }
  get customize_skin(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).customize_appearance;
    });
    this.button("gc.npc.ui.button.classic_skins", "textures/ui/sidebar_icons/classic_skins.png", function(player, entity){
      entity.triggerEvent('gc:skin_type__0');
      new gc_ui(player, entity).classic_skin_config;
    });
    this.button("gc.npc.ui.button.model_skins", "textures/ui/sidebar_icons/classic_skins.png", function(player, entity){
      entity.triggerEvent('gc:skin_type__2');
      new gc_ui(player, entity).model_skin_id;
    });
    this.button("gc.npc.ui.button.character_creator", "textures/ui/sidebar_icons/character_creator.png", function(player, entity){
      entity.triggerEvent('gc:skin_type__1');
      new gc_ui(player, entity).character_creator;
    });
    
    
    this.show(this.player);
  }

  get classic_skin_config(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).customize_skin;
    });
    
    if(this.event.classic_skin_model==="1"){
      this.button( "gc.npc.ui.button.classic_skin_model_alex", "textures/entity/npc/minecraft/classic_skin/alex/icon", function(player, entity){
      entity.triggerEvent('gc:classic_skin_model__0');
      new gc_ui(player, entity).classic_skin_config;
    });
    }else{
      this.button( "gc.npc.ui.button.classic_skin_model_steve", "textures/entity/npc/minecraft/classic_skin/steve/icon", function(player, entity){
        entity.triggerEvent('gc:classic_skin_model__1');
        new gc_ui(player, entity).classic_skin_config;
      });
    }
    this.button( `gc.npc.ui.button.classic_skin_id_${this.event.classic_skin_id||0}`, `textures/entity/npc/${this.classic_skin_id_icon[this.event.classic_skin_id||0]}`, function(player, entity){
      new gc_ui(player, entity).classic_skin_id;
    });
    this.show(this.player);
  }
  get classic_skin_id(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).classic_skin_config;
    });
    
    this.button(`gc.npc.ui.button.classic_skin.minecraft.steve`, "textures/entity/npc/minecraft/classic_skin/steve/icon", function(player, entity){
      entity.triggerEvent('gc:classic_skin_id__0');
      new gc_ui(player, entity).classic_skin_config;
    });
    this.button(`gc.npc.ui.button.classic_skin.minecraft.alex` , "textures/entity/npc/minecraft/classic_skin/alex/icon", function(player, entity){
      entity.triggerEvent('gc:classic_skin_id__1');
      new gc_ui(player, entity).classic_skin_config;
    });
    this.button(`gc.npc.ui.button.classic_skin.custom` , "textures/ui/user_icon.png", function(player, entity){
      new gc_ui(player, entity).classic_skin_id_custom(1);
    });

    for (let i=1; i<21; i++) {
      this.button(`gc.npc.ui.button.classic_skin.gabriielcraft.skin_${i}`, `textures/entity/npc/gabriielcraft/classic_skin/skin_${i}/icon`, function(player, entity){
        entity.triggerEvent(`gc:classic_skin_id__${i+1}`);
        new gc_ui(player, entity).classic_skin_config;
      });
    }
    
    this.show(this.player);
  }
      classic_skin_id_custom(pag){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).classic_skin_id;
    });
	if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).classic_skin_id_custom(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).classic_skin_id_custom(pag);
      });
    }
    if(pag<50){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).classic_skin_id_custom(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).classic_skin_id_custom(pag);
      });
    }

	
    for (let i=1+pag*20-20;i<1+pag*20;i++) {
      this.button(`gc.npc.ui.button.classic_skin.custom.skin_${i}`, `textures/entity/npc/custom/classic_skin/skin_${i}/skin`, function(player, entity){
        entity.triggerEvent(`gc:classic_skin_id__${i+1+20}`);
        new gc_ui(player, entity).classic_skin_config;
      });
    }
    
    this.show(this.player);
  }

  get model_skin_id(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).customize_skin;
    });
    
    this.button(`gc.npc.ui.button.model_skin.custom` , "textures/ui/user_icon.png", function(player, entity){
      new gc_ui(player, entity).model_skin_id_custom(1);
    });
		
    for (let i=0; i<13; i++) {
      this.button(`gc.npc.ui.button.model_skin.minecraft.model_${i}`, `models/entity/minecraft/model_${i}/icon`, function(player, entity){
        entity.triggerEvent(`gc:model_skin_id__${i}`);
        new gc_ui(player, entity).customize_skin;
      });
    }
    
    this.show(this.player);
  }
      model_skin_id_custom(pag){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).model_skin_id;
    });
	if(pag>1){
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).model_skin_id_custom(pag-1);
      });
    }else{
      this.button("gc.npc.ui.button.undo", "", function(player, entity){
        new gc_ui(player, entity).model_skin_id_custom(pag);
      });
    }
    if(pag<5){
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).model_skin_id_custom(pag+1);
      });
    }else{
      this.button("gc.npc.ui.button.next", "", function(player, entity){
        new gc_ui(player, entity).model_skin_id_custom(pag);
      });
    }

	
    for (let i=1+pag*20-20;i<1+pag*20;i++) {
      this.button(`gc.npc.ui.button.classic_skin.custom.skin_${i}`, `models/entity/custom/model_${i}/skin`, function(player, entity){
        entity.triggerEvent(`gc:model_skin_id__${i+12}`);
        new gc_ui(player, entity).customize_skin;
      });
    }
    
    this.show(this.player);
  }

  get character_creator(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).customize_skin;
    });
    
    this.button("gc.npc.ui.button.character_creator.skin_texture", "textures/ui/subcategory_icons/skin_texture.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });
    this.button("gc.npc.ui.button.character_creator.hair", "textures/ui/subcategory_icons/hair.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });
    this.button("gc.npc.ui.button.character_creator.mouth", "textures/ui/subcategory_icons/mouth.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });
    this.button("gc.npc.ui.button.character_creator.head", "textures/ui/subcategory_icons/head.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });
    this.button("gc.npc.ui.button.character_creator.arms", "textures/ui/subcategory_icons/arms.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });
    this.button("gc.npc.ui.button.character_creator.tops", "textures/ui/subcategory_icons/tops.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });
    this.button("gc.npc.ui.button.character_creator.outerwear", "textures/ui/subcategory_icons/outerwear.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });
    this.button("gc.npc.ui.button.character_creator.legs", "textures/ui/subcategory_icons/legs.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });
    this.button("gc.npc.ui.button.character_creator.feet", "textures/ui/subcategory_icons/feet.png", function(player, entity){
      new gc_ui(player, entity).character_creator;
    });

    this.show(this.player);
  }
  
  

  get save_npc(){
    this.title= "npc editor";
    this.body= "";
    this.button("gc.npc.ui.button.go_back", "textures/ui/BackArrow.png", function(player, entity){
      new gc_ui(player, entity).default;
    });
    

    this.show(this.player);
  }



}
function eventTag( entity, id ){
  let tags= entity.getTags();
  let event=id.substring(3).split("__");
  let find = function (array, txt) { for(let i=0;i<array.length;i++){ if(array[i].substring(0, txt.length)===txt){ return array[i] } } };
  //if para evento sem "value"
  if(event[1]===undefined){
    //if para ver se a tag existe
    if(find(tags, event[0])!==undefined){
      //if para saber se não é tag "true"
      if (find(tags, event[0]).split("__")[1]!=="true"){
        entity.removeTag(find(tags, event[0]));
        entity.addTag(`${event[0]}__true` );
      } else {//else caso seja "true"
        entity.removeTag(find(tags, event[0]));
        entity.addTag(`${event[0]}__false`);
      }
    } else {//else caso não exista a tag
      entity.addTag(`${event[0]}__true`);
    }
  } else {//else caso o event tenha "value"
    if(find(tags, event[0])!==undefined){
      entity.removeTag(find(tags, event[0]));
      entity.addTag(`${event[0]}__${event[1]}`);
    }else{
      entity.addTag(`${event[0]}__${event[1]}`);
    }
  }
}
function Tag( entity, id ){
  let tags= entity.getTags();
  let event=id.split("__");
  let find = function (array, txt) { for(let i=0;i<array.length;i++){ if(array[i].substring(0, txt.length)===txt){ return array[i] } } };
  //if para evento sem "value"
  if(event[1]===undefined){
    //if para ver se a tag existe
    if(find(tags, event[0])!==undefined){
      //if para saber se não é tag "true"
      if (find(tags, event[0]).split("__")[1]!=="true"){
        entity.removeTag(find(tags, event[0]));
        entity.addTag(`${event[0]}__true` );
      } else {//else caso seja "true"
        entity.removeTag(find(tags, event[0]));
        entity.addTag(`${event[0]}__false`);
      }
    } else {//else caso não exista a tag
      entity.addTag(`${event[0]}__true`);
    }
  } else {//else caso o event tenha "value"
    if(find(tags, event[0])!==undefined){
      entity.removeTag(find(tags, event[0]));
      entity.addTag(`${event[0]}__${event[1]}`);
    }else{
      entity.addTag(`${event[0]}__${event[1]}`);
    }
  }
}
function classic_skin_id_icon(id){
  array=[
    "minecraft/classic_skin/steve",
    "minecraft/classic_skin/alex",

    "gabriielcraft/classic_skin/skin_1",
    "gabriielcraft/classic_skin/skin_2",
    "gabriielcraft/classic_skin/skin_3",
    "gabriielcraft/classic_skin/skin_4",
    "gabriielcraft/classic_skin/skin_5",
    "gabriielcraft/classic_skin/skin_6",
    "gabriielcraft/classic_skin/skin_7",
    "gabriielcraft/classic_skin/skin_8",
    "gabriielcraft/classic_skin/skin_9",
    "gabriielcraft/classic_skin/skin_10",
    "gabriielcraft/classic_skin/skin_11",
    "gabriielcraft/classic_skin/skin_12",
    "gabriielcraft/classic_skin/skin_13",
    "gabriielcraft/classic_skin/skin_14",
    "gabriielcraft/classic_skin/skin_15",
    "gabriielcraft/classic_skin/skin_16",
    "gabriielcraft/classic_skin/skin_17",
    "gabriielcraft/classic_skin/skin_18",
    "gabriielcraft/classic_skin/skin_19",
    "gabriielcraft/classic_skin/skin_20"
  ];
  return array[id];
}

world.events.entityHit.subscribe(async(sla) => {
  let
    player= sla.entity,
    entity= sla.hitEntity,
    block= sla.hitBlock;
    
    if ((player.typeId === "minecraft:player") && (entity !== undefined) ) {
      if(entity.typeId === "npc:steve"){
				try{
					await player.runCommandAsync(`testfor @s[hasitem={location=slot.weapon.mainhand,item=gc:staff_edit}]`)
					new gc_ui(player, entity).default;
				} catch(e){}
      }
      if(entity.typeId === "gc:move_npc"){
				try{
					await player.runCommandAsync(`testfor @s[hasitem={location=slot.weapon.mainhand,item=gc:staff_edit}]`)
					new gc_ui(player, entity).move_npc_default;
				} catch(e){}
      }
    }
});
world.events.dataDrivenEntityTriggerEvent.subscribe(({ id, modifiers, entity }) => {
  if(entity.typeId === "npc:steve"&&id.substring(0, 2)=== "gc"){
    eventTag(entity, id);
    //world.getDimension("overworld").runCommandAsync(`tellraw @a {"rawtext":[{"text":"§eentity:§r${entity.typeId}\n§eevent:§r${id}\n§etags: §r${tags}"}]}`);
  }
});