#teleporte script

1 messages · Page 1 of 1 (latest)

oblique wave
#

Why is it not possible to create more than one region in order to move to it? This is a script to open a menu. When you hold a compass and look at an iron block and press the right click, a menu opens and you can create one region in order to move to it, but I want to create more than one region in order to move to it. How can I please help?

inland wagon
#

use code blocks not files

oblique wave
#

The file is long and I cannot send it

inland wagon
#

Oh, that explains. I can't help without pc

oblique wave
#

Why

inland wagon
#

I won't download random main.js

oblique wave
#

@inland wagon I will send the script intermittently, please help me

inland wagon
#

Lemme hop on pc

#

if I don't forget I will hop on in 30 min to 1h

oblique wave
#

import {world, system, Player, Block, ItemStack, GameMode,Entity, EntityInventoryComponent} from "@minecraft/server";

import {ActionFormData, ModalFormData, MessageFormData} from "@minecraft/server-ui";

world.afterEvents.itemUse.subscribe(eventData => {
const item = eventData.itemStack;

const player = eventData.source;
const TAGSO = player.getTags()
if (item.typeId === 'minecraft:compass'){

const form = new ActionFormData()
const tags = TAGSO.filter(tag=>tag.startsWith("myArea")).map(tag => tag.replace('myArea','')).map(tag => tag.replace('minecraft:',''))

let cog = 'textures/icons_dimensions/'

if (tags.length>0){
tags.forEach(v=>form.button(v,cog + v.split('\n§a')[1]))

}else{ player.playSound('random.break')
player.sendMessage(§cyou haven't Area);
return;

}
form.show(player).then((result) => {
if(result.canceled) return;
const tagsl = TAGSO.filter(tag=>tag.startsWith("myArea"))
const ltagl = tagsl[result.selection]

const ltagsl = tags[result.selection].replace('myArea','')

const blockDim = TAGSO.filter(tag=>tag.startsWith(`${ltagl}`)).map(tag => tag.split(':')[1])

const TagS = ltagsl.replace(`\n§a${blockDim}`,'')
#

const xt = TAGSO.filter(tag => tag.startsWith(${TagS}:\n§b)).map(tag => tag.replace(${TagS}:\n§b,''));

const yt = TAGSO.filter(tag => tag.startsWith(`${TagS}:§6`)).map(tag => tag.replace(`${TagS}:§6`,''));

const zt = TAGSO.filter(tag => tag.startsWith(`${TagS}:§c`)).map(tag => tag.replace(`${TagS}:§c`,''))

const {x,y,z} = player.location

const d_x = xt - x
const d_y = yt - y
const d_z = zt - z

const blocks = Math.sqrt(d_x ** 2 + d_y ** 2 + d_z ** 2)
const myAreaOptions = new ActionFormData()

myAreaOptions.title('options')
myAreaOptions.body(The remaining space is (${Math.floor(blocks)}) a square block)
myAreaOptions.button('edit name')
myAreaOptions.button('delete myArea')
myAreaOptions.button('teleport')
myAreaOptions.show(player).then(r =>{
if (r.canceled) return;
if (r.selection === 0){

const colors = {
codes: "§4|§b|§a|§f|§6",
values: ['§l§4red', '§l§bblue', '§l§agreen', '§l§fwhite', '§l§6orange']
};
const icons ={
codes: "§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l ",
values: ["§l food icon","§l shop icon","§l miner icon","§l farm icon","§l iron icon","§l gold icon","§l diamond icon","§l emerald icon","§l copper icon","§l netherite icon","§l spawner icon","§l house icon","§l village icon"]
}

#

const open = new ModalFormData()
.title('Name your area')
.textField('rename your area','Type new name of your area')
.dropdown('Choose the icon you want',icons.values)
.dropdown('Choose the color you want', colors.values, 0)
.show(player).then(({canceled, formValues}) => {
if (canceled) return;

if (formValues[0] !== ''){
player.removeTag(ltagsl)
const ico = icons.codes.split(/|/)[formValues[1]]
const col = colors.codes.split(/|/)[formValues[2]]
if(TAGSO.find(tag => tag.startsWith(myArea${ico}${col}${formValues[0]}))?.replace(${ico}${col},'')){
player.sendMessage(§4Sorry, but this name §f( ${TAGSO.filter(tag => tag.startsWith(myArea${ico}${col}${formValues[0]})).map(tag => tag.replace(myArea${ico}${col},'')).map(tag => tag.replace(\n§aminecraft:${blockDim},''))}§r §f)§4 already exists)
player.playSound('random.break')
const golj = TAGSO.find(tag => tag.startsWith(myArea${ico}${col}${formValues[0]}))

} else{
player.playSound("random.levelup")
player.addTag(${TAGSO.filter(tag => tag.startsWith(${TagS}:\n§b)).map(tag => tag.replace(${TagS}:\n§b,${ico}${col}${formValues[0]}:\n§b))})

 player.removeTag(`${TAGSO.filter(tag => tag.startsWith(`${TagS}:\n§b`))}`)
#

player.addTag(${TAGSO.filter(tag => tag.startsWith(${TagS}:§6)).map(tag => tag.replace(${TagS}:§6,${ico}${col}${formValues[0]}:§6))})
player.removeTag(${TAGSO.find(tag => tag.startsWith(${TagS}:§6))})

 player.addTag(`${TAGSO.filter(tag => tag.startsWith(`${TagS}:§c`)).map(tag => tag.replace(`${TagS}:§c`,`${ico}${col}${formValues[0]}:§c`))}`)
 player.removeTag(`${TAGSO.find(tag => tag.startsWith(`${TagS}:§c`))}`)
 
 
 
 player.removeTag(`${TAGSO.find(tag => tag.startsWith(`${ltagsl}:§a`))}`)
 
 player.removeTag(ltagl)
 player.sendMessage(`myArea${ico}${col}${formValues[0]}\n${ltagl.split('\n')[1]}`)

player.addTag(myArea${ico}${col}${formValues[0]}\n${ltagl.split('\n')[1]})
}
}
}).catch((e) => {
console.error(e, e.stack);
});

#

}
if (r.selection === 1){
const deletes = new MessageFormData()
.title('delete myArea')
.body(Do you really want to delete the region named (${ltagsl})?)
.button1('§4delete')
.button2('§2retreat')
.show(player).then(r =>{
if(r.canceled) return;
if (r.selection === 0){

      player.removeTag(`${TAGSO.filter(tag => tag.startsWith(`${TagS}:\n§b`))}`)
      
 player.removeTag(`${TAGSO.find(tag => tag.startsWith(`${TagS}:§6`))}`)
      
      player.removeTag(`${TAGSO.find(tag => tag.startsWith(`${TagS}:§c`))}`)
      
      player.removeTag(`${TAGSO.filter(tag => tag.startsWith(`${ltagsl}:§a`))}`)
      
      player.removeTag(ltagl)
      if(!ltagl){

player.playSound('random.pop2')
player.sendMessage(§aThe yourArea named §r(${ltagsl}§r) §ahas been deleted.)
}
}
}).catch((e) => {
console.error(e, e.stack);
});
}
if(r.selection == 2){

  const xh = TAGSO.filter(tag => tag.startsWith(`${TagS}:\n§b`)).map(tag => tag.replace(`${TagS}:\n§b`,''));
  
  const yh = TAGSO.filter(tag => tag.startsWith(`${TagS}:§6`)).map(tag => tag.replace(`${TagS}:§6`,''));
  
  const zh = TAGSO.filter(tag => tag.startsWith(`${TagS}:§c`)).map(tag => tag.replace(`${TagS}:§c`,''));
#

player.runCommand(execute in ${blockDim} run tp @s ${xh} ${yh} ${zh})
player.runCommand(stopsound @s)
player.runCommand(execute if blocks ~~~ ${xh} ${yh} ${zh} ${xh} ${yh} ${zh} masked run playsound mob.endermen.portal @a[r=8])

player.runCommand(execute if blocks ~~~ ${xh} ${yh} ${zh} ${xh} ${yh} ${zh} masked run playsound mob.endermen.portal @a[r=8])
}
}).catch((e) => {
console.error(e, e.stack);
});

}).catch((e) => {
console.error(e, e.stack);
});
}
});

#

world.afterEvents.playerInteractWithBlock.subscribe((data) => {
const dimension = data.dimension;
const {itemStack} = data;
const player = data.player;
const TAGSO = player.getTags()
const { block } = data;
const {x,y,z} = block.location;
if (!itemStack) return;
if (block.typeId === 'minecraft:iron_block' && itemStack.typeId === 'minecraft:compass'){

const openForm = new ActionFormData()
openForm.title() openForm.body()
openForm.button(create new Area)
openForm.button(MyArea options)

openForm.show(player).then(r=>{
const selection = r.selection

if (selection == 0){

const colors = {
codes: "§4|§b|§a|§f|§6",
values: ['§l§4red', '§l§bblue', '§l§agreen', '§l§fwhite', '§l§6orange']
};
const icons ={
codes: "§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l ",
values: ["§l food icon","§l shop icon","§l miner icon","§l farm icon","§l iron icon","§l gold icon","§l diamond icon","§l emerald icon","§l copper icon","§l netherite icon","§l spawner icon","§l house icon","§l village icon"]
}

#

const open = new ModalFormData()
.title('Name your area')
.textField('name your area','Type the name of your area')
.dropdown('Choose the icon you want',icons.values)
.dropdown('Choose the color you want', colors.values, 0)
.show(player).then(({canceled, formValues}) => {
if (canceled) return;

if (formValues[0] !== ''){
const ico = icons.codes.split(/|/)[formValues[1]]
const col = colors.codes.split(/|/)[formValues[2]]

if(TAGSO.find(tag => tag.startsWith(myArea${ico}${col}${formValues[0]}))?.replace(${ico}${col},'')){
player.sendMessage(§4Sorry, but this name §f( ${TAGSO.filter(tag => tag.startsWith(myArea${ico}${col}${formValues[0]})).map(tag => tag.replace(myArea${ico}${col},'')).map(tag => tag.replace(\n§a${block.dimension.id},''))}§r §f)§4 already exists)
player.playSound('random.break')
const golj = TAGSO.find(tag => tag.startsWith(myArea${ico}${col}${formValues[0]}))

} else{
player.playSound("random.levelup")
player.addTag(myArea${ico}${col}${formValues[0]}\n§a${block.dimension.id})

#

player.addTag(${ico}${col}${formValues[0]}:\n§b${x})

player.addTag(${ico}${col}${formValues[0]}:§6${y})

player.addTag(${ico}${col}${formValues[0]}:§c${z})

}
}
}).catch((e) => {
console.error(e, e.stack);
});
}
if (selection == 1){

const form = new ActionFormData()
const tags = TAGSO.filter(tag=>tag.startsWith("myArea")).map(tag => tag.replace('myArea','')).map(tag => tag.replace('minecraft:',''))

let cog = 'textures/icons_dimensions/'

if (tags.length>0){
tags.forEach(v=>form.button(v,cog + v.split('\n§a')[1]))

}else{ player.playSound('random.break')
player.sendMessage(§cyou haven't Area);
return;
}
form.show(player).then((result) => {
if(result.canceled) return;
const tagsl = TAGSO.filter(tag=>tag.startsWith("myArea"))

#

const ltagl = tagsl[result.selection]
const ltagsl = tags[result.selection].replace('myArea','')

const blockDim = TAGSO.filter(tag=>tag.startsWith(`${ltagl}`)).map(tag => tag.split(':')[1])

const TagS = ltagsl.replace(`\n§a${blockDim}`,'')
player.sendMessage(TagS)
const xt = TAGSO.filter(tag => tag.startsWith(`${TagS}:\n§b`)).map(tag => tag.replace(`${TagS}:`,''));

const yt = TAGSO.filter(tag => tag.startsWith(`${TagS}:§6`)).map(tag => tag.replace(`${TagS}:§6`,''));

const zt = TAGSO.filter(tag => tag.startsWith(`${TagS}:§c`)).map(tag => tag.replace(`${TagS}:§c`,''))

const myAreaOptions = new ActionFormData()

myAreaOptions.title('options')
myAreaOptions.body(You will modify:\n${ltagsl}${xt} ${yt} ${zt})
myAreaOptions.button('edit name')
myAreaOptions.button('delete myArea')
myAreaOptions.button('teleport')
myAreaOptions.show(player).then(r =>{
if (r.canceled) return;
if (r.selection === 0){

const colors = {
codes: "§4|§b|§a|§f|§6",
values: ['§l§4red', '§l§bblue', '§l§agreen', '§l§fwhite', '§l§6orange']
};

#

const icons ={
codes: "§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l |§l ",
values: ["§l food icon","§l shop icon","§l miner icon","§l farm icon","§l iron icon","§l gold icon","§l diamond icon","§l emerald icon","§l copper icon","§l netherite icon","§l spawner icon","§l house icon","§l village icon"]
}

const open = new ModalFormData()
.title('Name your area')
.textField('rename your area','Type new name of your area')
.dropdown('Choose the icon you want',icons.values)
.dropdown('Choose the color you want', colors.values, 0)
.show(player).then(({canceled, formValues}) => {
if (canceled) return;

if (formValues[0] !== ''){
player.removeTag(ltagsl)
const ico = icons.codes.split(/|/)[formValues[1]]
const col = colors.codes.split(/|/)[formValues[2]]
if(TAGSO.find(tag => tag.startsWith(myArea${ico}${col}${formValues[0]}))?.replace(${ico}${col},'')){
player.playSound('random.break')
player.sendMessage(§4Sorry, but this name §f( ${TAGSO.filter(tag => tag.startsWith(myArea${ico}${col}${formValues[0]})).map(tag=> tag.replace(myArea${ico}${col},'')).map(tag=> tag.replace(\n§aminecraft:${blockDim},''))}§r §f)§4 already exists)

   const golj = TAGSO.find(tag => tag.startsWith(`myArea${ico}${col}${formValues[0]}`))

} else{
player.playSound("random.levelup")
player.addTag(${TAGSO.filter(tag => tag.startsWith(${TagS}:\n§b)).map(tag => tag.replace(${TagS}:\n§b,${ico}${col}${formValues[0]}:\n§b))})

 player.removeTag(`${TAGSO.filter(tag => tag.startsWith(`${TagS}:\n§b`))}`)
 
 player.addTag(`${TAGSO.filter(tag => tag.startsWith(`${TagS}:§6`)).map(tag => tag.replace(`${TagS}:§6`,`${ico}${col}${formValues[0]}:§6`))}`)
 player.removeTag(`${TAGSO.find(tag => tag.startsWith(`${TagS}:§6`))}`)
#

player.addTag(${TAGSO.filter(tag => tag.startsWith(${TagS}:§c)).map(tag => tag.replace(${TagS}:§c,${ico}${col}${formValues[0]}:§c))})
player.removeTag(${TAGSO.find(tag => tag.startsWith(${TagS}:§c))})

 player.removeTag(`${TAGSO.find(tag => tag.startsWith(`${ltagsl}:§a`))}`)
 
 player.removeTag(ltagl)
 player.sendMessage(`myArea${ico}${col}${formValues[0]}`)

player.addTag(myArea${ico}${col}${formValues[0]}\n${ltagl.split('\n')[1]})
}
}
}).catch((e) => {
console.error(e, e.stack);
});

}
if (r.selection === 1){
  const deletes = new MessageFormData()
  .title('delete myArea')
  .body(`Do you really want to delete the region named (${ltagsl})?`)
  .button1('§4delete')
  .button2('§2retreat')
  .show(player).then(r =>{
    if(r.canceled) return;
    if (r.selection === 0){
      
      player.removeTag(`${TAGSO.filter(tag => tag.startsWith(`${TagS}:\n§b`))}`)
      player.playSound("random.orb")
 player.removeTag(`${TAGSO.find(tag => tag.startsWith(`${TagS}:§6`))}`)
      
      player.removeTag(`${TAGSO.find(tag => tag.startsWith(`${TagS}:§c`))}`)
      
      player.removeTag(`${TAGSO.filter(tag => tag.startsWith(`${TagS}:§a`))}`)
      
      player.removeTag(ltagl)
      if(!ltagl){
      player.sendMessage(`§aThe yourArea named §r(${ltagsl}§r) §ahas been deleted.`)
      }
    }
  }).catch((e) => {
console.error(e, e.stack);

});
}

#

if(r.selection == 2){
const xh = TAGSO.filter(tag => tag.startsWith(${TagS}:\n§b)).map(tag => tag.replace(${TagS}:\n§b,''));

  const yh = TAGSO.filter(tag => tag.startsWith(`${TagS}:§6`)).map(tag => tag.replace(`${TagS}:§6`,''));
  
  const zh = TAGSO.filter(tag => tag.startsWith(`${TagS}:§c`)).map(tag => tag.replace(`${TagS}:§c`,''));

player.runCommand(execute in ${blockDim} run tp @s ${xh} ${yh} ${zh})

player.runCommand(stopsound @s)
player.runCommand(execute if blocks ~~~ ${xh} ${yh} ${zh} ${xh} ${yh} ${zh} masked run playsound mob.endermen.portal @a[r=8])

player.runCommand(execute if blocks ~~~ ${xh} ${yh} ${zh} ${xh} ${yh} ${zh} masked run playsound mob.endermen.portal @a[r=8])

}

}).catch((e) => {
console.error(e, e.stack);
});
}).catch((e) => {
console.error(e, e.stack);
});
}
}).catch((e) => {
console.error(e, e.stack);
});
}
})