#Help with my command "!furnace"

1 messages · Page 1 of 1 (latest)

undone flax
#

Hello ! When I execute the command "!furnace", this didn't work and I have this error In my console : [2023-06-23 18:11:00:551 ERROR] [Scripting] Unhandled promise rejection: TypeError: not a function

This is my code in the file "furnace.js"

import { world } from "@minecraft/server"

world.beforeEvents.chatSend.subscribe(async (ev) => {
    const player = ev.sender
    const msg = ev.message
    if (!msg.startsWith("!",0)) return
    ev.cancel = true
    await null
      if (msg == "!furnace") {
    const mainHandItem = player.getMainhandItem();

    if (mainHandItem) {
      const meltedItem = world.createItemStack("minecraft:melted_item", mainHandItem.count, mainHandItem.metadata);
      player.setMainhandItem(meltedItem);
      player.sendMessage("§aVotre minerai a été fondu !");
    }
  }
});```

Can you help me please ? 

Thanks in advance !
tranquil pumice
#

You use 1.3.0-beta server right?

undone flax
#

Yes

#

The last

tranquil pumice
#

Just paste in the terminal your use vsc right

undone flax
#

I run this were on my vps ? Because i am on a pterodactyle panel

tranquil pumice
#

No its for typings in visual studio code

undone flax
#

Just to be sure, how I can find i use 1.3.0-beta server

tranquil pumice
undone flax
tranquil pumice
#

That seems fine

undone flax
#

Is thats correct ?

tranquil pumice
#

You dont run it in a panel you run it in the terminal in like visual studio code or some other editor to get auto completion so you dont have to constantly reference docs

#

since you got an error its working fine just you are useing functions and properties that dont exist

undone flax
#

Oh okay, this isn't compatible with my panel, sorry, but maybe there is a documentation for all the functions and properties

#

I have understand, sorry I have a bad english

undone flax
tranquil pumice
# undone flax DId you know something similar ? I don't find the similar functions ?
import { Container, world, MinecraftItemTypes, ItemStack } from "@minecraft/server";

import { parseCommand } from './parse_command.js';
const prefix = '!';
world.beforeEvents.chatSend.subscribe(async (event) => {
    const { sender, message } = event;
    if (!message.startsWith(prefix)) return;
    event.sendToTargets = true;
    event.setTargets([]);
    await null;
    const [command] = parseCommand(message, prefix);
    switch (command) {
        case 'furnace': {
            const { selectedSlot } = sender;
            /**
             * @type {Container}
             */
            const container = sender.getComponent('minecraft:inventory').container;
            const mainhand = container.getSlot(selectedSlot);
            //probably going to need a object of keys of ore ids and values of itemstacks of the resulting ores
            //new ItemStack(MinecraftItemTypes.iron, amount) is how yo make items
            sender.sendMessage("§aVotre minerai a été fondu !");
        }
    }
});```
undone flax
#

Okay tanks, I try to test it soon

onyx shale
#

dude used chatgpt 💀

subtle sand