//    =====  =====  =====  =====  ====   =====  =====      ==       ==  =======  ====
//    =      =      =   =  =   =  =   =  =   =  =          = =     = =  =     =  =   =
//    ===     ===   = ==   =====  =   =  =====   ===       =  =   =  =  =     =  =   =
//    =          =  =      =   =  =   =  =   =      =      =   = =   =  =     =  =   =
//    =====   ====  =      =   =  ====   =   =   ====      =    =    =  =======  ====


//Otros

ModPE. setFov(85);

var ores_sword = 408;

var oreIds = [129, 56, 14, 16, 15,];

var oreNames = ["Esmeralda", "Diamante", "Oro", "Carbon", "Hierro"];

//Items

ModPE.setItem(368,"record_ward",0,"Ender Pearl");
ModPE.setItem(401,"experience_bottle",0,"Espada de Meteorito");
ModPE.setItem(400,"fireball",0,"Espada de Fuego");
ModPE.setItem(406,"ender_eye", 0, "Espada de Vida");
ModPE.setItem(404,"comparator", 0, "Espada de Lava");
ModPE.setItem(403,"ender_pearl", 0, "Espada de Agua");
ModPE.setItem(402,"fireworks",0,"Espada de Diamante+");
ModPE.setItem(408,"iron_horse_armor", 0, "Espada Mineral");  
ModPE.setItem(407,"gold_horse_armor", 0, "Espada Ender");
ModPE.setItem(405,"fishing_rod_cast", 0, "Espada Pico");
ModPE.setItem(409,"skull_creeper", 0, "Espada De Madera+"); 
ModPE.setItem(410,"skull_skeleton", 0, "Espada De Piedra+"); 
ModPE.setItem(411,"skull_steve", 0, "Espada De Hierro+"); 
ModPE.setItem(412,"skull_wither", 0, "Espada De Oro+");
ModPE.setItem(413,"skull_zombie", 0, "Espada De Meteorito+");
ModPE.setItem(414,"record_11", 0, "Espada Nuclear");
ModPE.setItem(415,"record_13", 0, "Espada Placentera");
ModPE.setItem(416,"boat", 0, "Espada Ninja");
ModPE.setItem(417,"record_blocks", 0, "Espada de Redstone");
ModPE.setItem(418,"record_cat", 0, "Espada nether");
ModPE.setItem(419,"record_chirp", 0, "Espada Negra");
ModPE.setItem(420,"record_far", 0, "Espada del Diablo");


//Item Damage
Item.setMaxDamage(400, 75);
Item.setMaxDamage(401, 75);
Item.setMaxDamage(402, 750);
Item.setMaxDamage(403, 75);
Item.setMaxDamage(404, 75);
Item.setMaxDamage(405, 350);
Item.setMaxDamage(406, 75);
Item.setMaxDamage(407, 100);
Item.setMaxDamage(408, 75);
Item.setMaxDamage(409, 50);
Item.setMaxDamage(410, 75);
Item.setMaxDamage(411, 125);
Item.setMaxDamage(412, 60);
Item.setMaxDamage(413, 185);
Item.setMaxDamage(414, 750);
Item.setMaxDamage(415, 100);
Item.setMaxDamage(416, 450);
Item.setMaxDamage(417, 175);
Item.setMaxDamage(418, 200);
Item.setMaxDamage(419, 200);
Item.setMaxDamage(420, 600);

//Crafteos

Item.addShapedRecipe(10,1,0,[
"   ",
" l ",
"   "],["l",325,10]);                        
Item.addShapedRecipe(8,1,0,[
"   ",
" 1 ",
"   "],["1",325,8]);
Item.addShapedRecipe(79,1,0,[
"111",
"121",
"111"],["1",332,0,"2",8,0,]);  
Item.addShapedRecipe(401,1,0,[
"414",
"424",
" 3 "],["1",265,0,"2",289,0,"3",280,0,"4",266,0]);    	    
Item.addShapedRecipe(406,1,0,[
"232",
"232",
" 1 "],["1",280,0,"2",392,0,"3",17,0]);        
Item.addShapedRecipe(404,1,0,[
"232",
"222",
" 1 "],["1",280,0,"2",87,0,"3",264,0]);     
Item.addShapedRecipe(403,1,0,[
" 3 ",
"222",
" 1 "],["1",280,0,"2",351,6,"3",264,0]);     
Item.addShapedRecipe(402,1,0,[
" 1 ",
"111",
"121"],["1",264,0,"2",276,0]);   	    	   
Item.addShapedRecipe(408,1,0,[
" 2 ",
"534",
" 1 "],["1",280,0,"2",263,0,"3",264,0,"4",265,0,"5",266,0]);   	    	       	        	    
Item.addShapedRecipe(405,1,0,[
" 2 ",
"222",
" 1 "],["1",280,0,"2",264,0]);       	    
Item.addShapedRecipe(400,1,0,[
"414",
"424",
" 3 "],["1",265,0,"2",263,0,"3",280,0,"4",266,0]);
Item.addShapedRecipe(409,1,0,[
" 1 ",
"111",
"121"],["1",5,0,"2",268,0]); 
Item.addShapedRecipe(410,1,0,[
" 1 ",
"111",
"121"],["1",4,0,"2",272,0]); 
Item.addShapedRecipe(411,1,0,[
" 1 ",
"111",
"121"],["1",265,0,"2",267,0]); 
Item.addShapedRecipe(412,1,0,[
" 1 ",
"111",
"121"],["1",266,0,"2",283,0]); 
Item.addShapedRecipe(413,1,0,[
" 1 ",
"111",
"121"],["1",289,0,"2",401,0]); 
Item.addShapedRecipe(414,1,0,[
" 1 ",
"111",
"121"],["1",413,0,"2",413,0]); 
Item.addShapedRecipe(416,1,0,[
"   ",
" 1 ",
" 2 "],["1",264,0,"2",280,0]); 
Item.addShapedRecipe(417,1,0,[
" 1 ",
" 1 ",
" 2 "],["1",331,0,"2",280,0]); 
Item.addShapedRecipe(418,1,0,[
"313",
"313",
" 2 "],["1",265,0,"2",280,0,"3",49,0]); 
Item.addShapedRecipe(419,1,0,[
"313",
"313",
" 2 "],["1",87,0,"2",265,0,"3",49,0]); 
Item.addShapedRecipe(420,1,0,[
"111",
"111",
" 2 "],["1",331,0,"2",280,0]); 
Item.addShapedRecipe(407,1,0,[
" 1 ",
" 1 ",
" 2 "],["1",368,0,"2",280,0]); 

//Codigo

function useItem(x,y,z,itemId,blockId,side,data) 
{
if(itemId == 405){
Level.dropItem(x, y, z, 1, getTile(x, y, z), 1);    
Level.destroyBlock(x, y, z);
	Espadas(350,405);
}
if(itemId==407){
var  player = getPlayerEnt();
getTile(x,y,z);
setPosition(player,x+0.5,y+2.62,z+0.5); 
setTile(x,y+2,z,35,10)
Level.destroyBlock(x,y+2,z);
setTile(x,y+2,z,49)
Level.destroyBlock(x,y+2,z);
setTile(x,y+2,z,35,10)
Level.destroyBlock(x,y+2,z);
setTile(x,y+2,z,49)
Level.destroyBlock(x,y+2,z);
setTile(x,y+2,z,35,10)
Level.destroyBlock(x,y+2,z);
setTile(x,y+2,z,49)
Level.destroyBlock(x,y+2,z);
setTile(x,y+2,z,35,10)
Level.destroyBlock(x,y+2,z);
setTile(x,y+2,z,49)
Level.destroyBlock(x,y+2,z);
	Espadas(100,407);
}
if(itemId == ores_sword) 
{
bestValue = -1;
for(var i = 0;i <= y;i++)
{
var bestXYZ;
var tile = getTile(x, i, z);
if (tile == oreIds[0]) 
{
if (bestValue < 0)
{
bestValue = 0;
bestXYZ = ("X: " + x + " Y: " + i + " Z: " + z);
}
} 
else if (tile == oreIds[1]) 
{
if (bestValue < 1) 
{
bestValue = 1;
bestXYZ = ("X: " + x + " Y: " + i + " Z: " + z);
}
}
else if (tile == oreIds[2]) 
{
if (bestValue < 2) 
{
bestValue = 2;
bestXYZ = ("X: " + x + " Y: " + i + " Z: " + z);
}
} 
else if (tile == oreIds[3]) 
{
if (bestValue < 3) 
{
bestValue = 3;
bestXYZ = ("X: " + x + " Y: " + i + " Z: " + z);
}
} 
else if (tile == oreIds[4]) {;
bestValue = 4;
bestXYZ = ("X: " + x + " Y: " + i + " Z: " + z);
break;
}
}
if(bestValue == -1)
{
clientMessage(ChatColor.RED + "No Se Encontraron Minerales");
} 
else 
{
clientMessage(ChatColor.GREEN + "Se Encontro " + oreNames[bestValue] + " " + bestXYZ);
}
}
}
function newLevel()
{
clientMessage(ChatColor.GREEN + "Mod creado por Ramirokueik y TheDroxiGames");
clientMessage(ChatColor.RED + "Comando /help para ayuda");
}
function attackHook(attacker,victim)
{
if(getCarriedItem()==401)
{
explode(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 5);
	Espadas(75,401);
}
if(getCarriedItem()==400)
{
Entity.setFireTicks(victim,50);
	Espadas(75,400);
}
if(getCarriedItem()==406&&Entity.getHealth(Player.getEntity()) <= 19)
{
Player.setHealth(Entity.getHealth(Player.getEntity())+1);
	Espadas(75,406);
}
if (getCarriedItem()==404) 
{
setTile(Entity.getX(victim),Entity.getY(victim)+1,Entity.getZ(victim),10);
	Espadas(75,404);
}
if (getCarriedItem()==403) 
{
setTile(Entity.getX(victim),Entity.getY(victim)+1,Entity.getZ(victim),8);
	Espadas(75,403);
}
if (getCarriedItem()==402) 
{
Entity.setHealth(victim,0);
	Espadas(750,402);
}
if (getCarriedItem()==409) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 5);
	Espadas(50,409);
}
if (getCarriedItem()==410) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 6);
	Espadas(75,410);
}
if (getCarriedItem()==411) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 7);
	Espadas(125,411);
}
if (getCarriedItem()==412) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 5);
	Espadas(60,412);
}
if(getCarriedItem()==413)
{
explode(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 10);
	Espadas(185,413);
}
if(getCarriedItem()==414)
{
explode(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 30);
	Espadas(750,414);
}
if (getCarriedItem()==415) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 1);
	Espadas(100,415);

}
if (getCarriedItem()==416) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 6);
	Espadas(450,416);
}
if (getCarriedItem()==417) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 6);
	Espadas(175,417);
}
if (getCarriedItem()==418) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 20);
	Espadas(200,418);
}
if (getCarriedItem()==419) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 20);
	Espadas(200,419);
}
if (getCarriedItem()==420) 
{
Entity.setHealth(victim, Entity.getHealth(victim) - 80);
	Espadas(600,420);
}
}


//Funcion Ender pearlç

function deathHook(murderer, victim)
{
if(Entity.getMobSkin(victim)=="mob/enderman.png")
{
Level.dropItem(Entity.getX(victim), Entity.getY(victim) + 1, Entity.getZ(victim), 0.5, 368, 1, 0);
}
}


//Funcion pa gastarse

function Espadas(maxDamage,id) {
var pcid=Player.getCarriedItemData();
if(pcid!==maxDamage){
Entity.setCarriedItem(getPlayerEnt(),id,1,pcid+1);
}else if(pcid==maxDamage) {
Level.playSound(Player.getX(),Player.getY(),Player.getZ(),"random.break",2);
Entity.setCarriedItem(getPlayerEnt(),0,0,0);
}
}


//Funcion de comandos

function procCmd(cmd)
{
var command = cmd.split(" ");
  
if(command[0] == "ModPE")
{
addItemInventory(400,1);
addItemInventory(401,1);
addItemInventory(402,1);
addItemInventory(403,1);
addItemInventory(404,1);
addItemInventory(405,1);
addItemInventory(406,1);
addItemInventory(407,1);
addItemInventory(408,1);
addItemInventory(409,1);
addItemInventory(410,1);
addItemInventory(411,1);
addItemInventory(412,1);
addItemInventory(413,1);
addItemInventory(414,1);
addItemInventory(415,1);
addItemInventory(416,1);
addItemInventory(417,1);
addItemInventory(418,1);
addItemInventory(419,1);
addItemInventory(420,1);
}
var command = cmd.split(" ");
  
if(command[0] == "Fov85")
{
ModPE. setFov(85);
}
var command = cmd.split(" ");
  
if(command[0] == "Fov60")
{
ModPE. setFov(60);
}
var command = cmd.split(" ");
  
if(command[0] == "Fov100")
{
ModPE. setFov(100);
}
var command = cmd.split(" ");
  
if(command[0] == "Fov125")
{
ModPE. setFov(125);
}
var command = cmd.split(" ");
  
if(command[0] == "FovNormal")
{
ModPE. setFov(70);
}
  cmd = cmd.toLowerCase();
    if (cmd == "help"){ 
       clientMessage("★/ModPE Añadir todas las espadas");
       clientMessage("★/Fov60 Campo de vision 60");
       clientMessage("★/Fov85 Campo de vision 85");
       clientMessage("★/Fov100 Campo de vision 100");
       clientMessage("★/Fov125 Campo de vision 125");
       clientMessage("★/FovNormal Campo de vision normal");
     } 
}

//Añadir espadas creativo
	Player.addItemCreativeInv(400,1,0);
	Player.addItemCreativeInv(401,1,0);
	Player.addItemCreativeInv(402,1,0);
	Player.addItemCreativeInv(403,1,0);
	Player.addItemCreativeInv(404,1,0);
	Player.addItemCreativeInv(405,1,0);
	Player.addItemCreativeInv(406,1,0);
	Player.addItemCreativeInv(407,1,0);
	Player.addItemCreativeInv(408,1,0);
	Player.addItemCreativeInv(409,1,0);
	Player.addItemCreativeInv(410,1,0);
	Player.addItemCreativeInv(411,1,0);
	Player.addItemCreativeInv(412,1,0);
	Player.addItemCreativeInv(413,1,0);
	Player.addItemCreativeInv(414,1,0);
	Player.addItemCreativeInv(415,1,0);
	Player.addItemCreativeInv(416,1,0);
	Player.addItemCreativeInv(417,1,0);
	Player.addItemCreativeInv(418,1,0);
	Player.addItemCreativeInv(419,1,0);
	Player.addItemCreativeInv(420,1,0);

print("Espadas Mod por Ramirokueik")



