#unhandled promise
1 messages · Page 1 of 1 (latest)
it's not working
hmm, try logging __NAME_TAG__ into content log
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
before console.log it throws unhandeled promise rejection | typeError: unexpected at '0'
something like this
is this the error that you’re getting?
@violet tundra
i get that error when i click on the “X” button
yeah also the item is not changing name
perviously it was on when i click submit
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 ^-^
try now, i edited it
oh wait
what was the problem here?
i mean the error i showed you
this one?
well forgot about it
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__;
})
}
})
?
Man, you did not need to add .values at the end of __NAME_TAG__
i already told them lol
yeah, i removed it
does it work now? or have you not tried it yet
yeah now it's perfect thanks
yay! :D
can i upload it on mcpedl?
it’s your code not mine
you don’t have to add me lol
if it makes you happy then sure
thanks again 😄