#error help

1 messages · Page 1 of 1 (latest)

shadow copper
#

good news, it's as simple as changing it to world.beforeEvents.chatSend

pseudo arch
#

Same as above, make it
world.beforeEvents.itemUse

#

And change data.item to data.itemStack

#

Have u imported world?

#

Add line on top
import {world} from "@minecraft/server

#

"

#

add the " before ; 😭

#
system.run(() =>
    ModalFormData.show().then(result => {
        //whatever code is there
    }
}
pseudo arch
#

For the form script file

#

That's not how u add it 😭

#

Delete first line

Modify 3rd like to add {world,system} in place of {world}

#

🫠

#

line 13 will be

#

system.run(() => {

#

Line 18

#

}) }

#

Send the whole ass code

#

Text

#

Brb I'm gonna get some snack

pseudo arch
#
import {
    ActionFormData,
    MessageFormData,
    ModalFormData
} from '@minecraft/server-ui';
import {
    world,
    system
} from "@minecraft/server"

world.beforeEvents.itemUse.subscribe(data => {
    if (data.itemStack.typeId == "minecraft:compass") clanForm(data.source)
})

export function clanForm(player) {
    let modalForm = new ModalFormData()
        .title('§l§4Clan UI')
        .textField('§cJoin or create a clan', 'Type text here')

    system.run(() => {
        ModalFormData.show().then(result => {
            removePreviousClanTag(player);
            player.sendMessage("§aSuccessfully set Clan!")
            player.addTag(`clan:${result.formValues[0]}`);
        })
    })
}

function removePreviousClanTag(player) {
    const clanTagPrefix = 'clan:';
    if (player.getTags) {
        const playerTags = player.getTags();
        for (const tag of playerTags) {
            if (tag.startsWith(clanTagPrefix)) {
                player.removeTag(tag);
            }
        }
    }
}
pseudo arch
# pseudo arch ```js import { ActionFormData, MessageFormData, ModalFormData } from...
import {
    ActionFormData,
    MessageFormData,
    ModalFormData
} from '@minecraft/server-ui';
import {
    world,
    system
} from "@minecraft/server"

world.beforeEvents.itemUse.subscribe(data => {
    if (data.itemStack.typeId == "minecraft:compass") clanForm(data.source)
})

export function clanForm(player) {
    
    system.run(() => {
        let modalForm = new ModalFormData()
            .title('§l§4Clan UI')
            .textField('§cJoin or create a clan', 'Type text here')
        ModalFormData.show().then(result => {
            removePreviousClanTag(player);
            player.sendMessage("§aSuccessfully set Clan!")
            player.addTag(`clan:${result.formValues[0]}`);
        })
    })
}

function removePreviousClanTag(player) {
    const clanTagPrefix = 'clan:';
    if (player.getTags) {
        const playerTags = player.getTags();
        for (const tag of playerTags) {
            if (tag.startsWith(clanTagPrefix)) {
                player.removeTag(tag);
            }
        }
    }
}
#
import {world} from "@minecraft/server";

import { clanForm} from "./form.js";

world.beforeEvents.itemUse.subscribe(data => {
    const player = data.source;
  if (data.itemStack.typeId === "minecraft:compass" && player.typeId === 'minecraft:player')
    clanForm(player);
});
pseudo arch
#

oops

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

world.beforeEvents.itemUse.subscribe(data => {
    if (data.itemStack.typeId == "minecraft:compass") clanForm(data.source)
})

export function clanForm(player) {
    
    system.run(() => {
        let modalForm = new ModalFormData()
            .title('§l§4Clan UI')
            .textField('§cJoin or create a clan', 'Type text here')
        modalForm.show().then(result => {
            removePreviousClanTag(player);
            player.sendMessage("§aSuccessfully set Clan!")
            player.addTag(`clan:${result.formValues[0]}`);
        })
    })
}

function removePreviousClanTag(player) {
    const clanTagPrefix = 'clan:';
    if (player.getTags) {
        const playerTags = player.getTags();
        for (const tag of playerTags) {
            if (tag.startsWith(clanTagPrefix)) {
                player.removeTag(tag);
            }
        }
    }
}
#

that will do

#

brain dead today

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

world.beforeEvents.itemUse.subscribe(data => {
    if (data.itemStack.typeId == "minecraft:compass") clanForm(data.source)
})

export function clanForm(player) {
    
    system.run(() => {
        let modalForm = new ModalFormData()
            .title('§l§4Clan UI')
            .textField('§cJoin or create a clan', 'Type text here')
        modalForm.show(player).then(result => {
            removePreviousClanTag(player);
            player.sendMessage("§aSuccessfully set Clan!")
            player.addTag(`clan:${result.formValues[0]}`);
        })
    })
}

function removePreviousClanTag(player) {
    const clanTagPrefix = 'clan:';
    if (player.getTags) {
        const playerTags = player.getTags();
        for (const tag of playerTags) {
            if (tag.startsWith(clanTagPrefix)) {
                player.removeTag(tag);
            }
        }
    }
}
#

this will work for sure...

pseudo arch
#

okay this is happening because when you item use the compass, the function keeps on calling as long as you are pressing use/right click