#unhandled promise

1 messages · Page 1 of 1 (latest)

vale bison
#

try evd.itemStack.nameTag = __NAME_TAG__;

violet tundra
#

it's not working

vale bison
#

hmm, try logging __NAME_TAG__ into content log

violet tundra
#

its not working from let __NAME_TAG__ = res.formValues[0]

#

console.log(__NAME_TAG__) is after this line

#

@vale bison sorry for ping but it's not working

vale bison
#

hmm

#

are you clicking submit or just closing the ui

violet tundra
#

content log is not showing up |:
also console.log

#

submit

vale bison
#

jaylybot is still down, which means that i have to test it in game

#

brb

violet tundra
#

before console.log it throws unhandeled promise rejection | typeError: unexpected at '0'

#

something like this

vale bison
#

it works fine for me

#

@violet tundra

violet tundra
#

try adding the last line

#

@vale bison

vale bison
#

@violet tundra

violet tundra
#

yeah

#

@vale bison

vale bison
violet tundra
#

yeah also the item is not changing name

violet tundra
vale bison
#
import * as MC from '@minecraft/server';
import * as UI from '@minecraft/server-ui';

MC.world.afterEvents.itemUse.subscribe(
    ({ source: player, itemStack }) => {
        if (itemStack.typeId == "minecraft:name_tag") {
            new UI.ModalFormData()
            .title( "Easy Name Tag" )
            .textField( "Enter new name: ", "Name" )
            .show( player ).then(
                ({ canceled, formValues }) => {
                    const [ __NAME_TAG__ ] = formValues;
                    if (res.canceled || !__NAME_TAG__.trim().length) return;
                    itemStack.nameTag = __NAME_TAG__;
                    player. getComponent( "minecraft:inventory" ).container.setItem( player.selectedSlot, itemStack );
                },
            );
        };
    },
);
#

hope this helps ^-^

violet tundra
#

okay thanks

#

unhandeled promise rejection typeError not a function

#

@vale bison

violet tundra
#

what was the problem here?

vale bison
violet tundra
#

i mean the error i showed you

violet tundra
#

well forgot about it

errant vapor
#
import * as MC from '@minecraft/server';
import * as UI from '@minecraft/server-ui';

MC.world.afterEvents.itemUse.subscribe(evd => {
  if (evd.itemStack.typeId == 'minecraft:name_tag') {
    let EasyNameTagUi = new UI.ModalFormData();
    EasyNameTagUi.title('Easy Name Tag')
    EasyNameTagUi.textField('Enter new name: ', 'Name', "new name for name tag")
    EasyNameTagUi.show(evd.source).then((res) => {
        let __NAME_TAG__ = res.formValues[0];
        evd.itemStack.nameTag = __NAME_TAG__;
    })
  }
})
errant vapor
#

Man, you did not need to add .values at the end of __NAME_TAG__

errant vapor
#

Really?

vale bison
vale bison
violet tundra
#

yeah now it's perfect thanks

vale bison
#

yay! :D

violet tundra
#

can i upload it on mcpedl?

vale bison
#

it’s your code not mine

violet tundra
#

but you're script too

#

i have your name in credits.txt

vale bison
#

you don’t have to add me lol

violet tundra
#

but i would like it in credit.txt

#

@vale bison

#

i have "xkingdark"

vale bison
#

if it makes you happy then sure

violet tundra