#can i get help (resolved)

1 messages · Page 1 of 1 (latest)

tame ingot
#

how can i add night vision effect when i equip my mitril helmet

jade night
#
let itemEffects = {
  "custom:my_helmet": {
    type: "night_vision",
    duration: 260,
    amplifier: 1
  }  
}
const slots = ["Head","Chest","Legs","Feet"]

system.runInterval(() => {
  for (let player of world.getAllPlayers()) {
    let equip = player.getComponent("minecraft:equippable")
    for (let slot of slots) {
      let item = equip.getEquipment(slot)
      if (itemEffects[item?.typeId] == undefined) continue
      player.addEffect(itemEffects[item.typeId].type, itemEffects[item.typeId].duration || 5, { amplifier: itemEffects[item.typeId].amplifier, showParticles: false })
    }
  }
}, 2)
tame ingot
# jade night ```js let itemEffects = { "custom:my_helmet": { type: "night_vision", ...
let itemEffects = {
    "myname:mitril_helmet": {
      type: "nigth_vision",
      duration: 200,
      amplifier: 1
    }  
  }
  const slots = ["Head","Chest","Legs","Feet"]
  
  system.runInterval(() => {
    for (let player of world.getAllPlayers()) {
      let equip = player.getComponent("minecraft:equippable")
      for (let slot of slots) {
        let item = equip.getEquipment(slot)
        if (itemEffects[item?.typeId] == undefined) continue
        player.addEffect(itemEffects[item.typeId].type, itemEffects[item.typeId].duration || 5, { amplifier: itemEffects[item.typeId].amplifier, showParticles: false })
      }
    }
  }, 2) 

not work

wise isleBOT
# tame ingot ```js let itemEffects = { "myname:mitril_helmet": { type: "nigth_visio...

Debug result for [code](#1304754192283602994 message)

Compiler Result

Compiler found 1 errors:

<REPL0>.js:14:39 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'EquipmentSlot'.

14         let item = equip.getEquipment(slot)
                                         ~~~~

Lint Result

There are no errors from ESLint.

tame ingot
#

oh okay

uneven pond
#
const EquipmentSlot = {
  Head: "head",
  Chest: "chest",
  Legs: "legs",
  Feet: "feet"
};

let itemEffects = {
  "myname:mitril_helmet": {
    type: "night_vision",
    duration: 200,
    amplifier: 1
  }  
};

const slots = [EquipmentSlot.Head, EquipmentSlot.Chest, EquipmentSlot.Legs, EquipmentSlot.Feet];

system.runInterval(() => {
  for (let player of world.getAllPlayers()) {
    let equip = player.getComponent("minecraft:equippable");
    for (let slot of slots) {
      let item = equip.getEquipment(slot as keyof typeof EquipmentSlot);
      if (itemEffects[item?.typeId] == undefined) continue;
      player.addEffect(itemEffects[item.typeId].type, itemEffects[item.typeId].duration || 5, { amplifier: itemEffects[item.typeId].amplifier, showParticles: false });
    }
  }
}, 2);
wise isleBOT
# uneven pond ```js const EquipmentSlot = { Head: "head", Chest: "chest", Legs: "legs", ...

Debug result for [code](#1304754192283602994 message)

Compiler Result

Compiler found 4 errors:

<REPL0>.js:1:7 - error TS2567: Enum declarations can only merge with namespace or other enum declarations.

1 const EquipmentSlot = {
        ~~~~~~~~~~~~~

  @minecraft/server.d.ts:3541:14
    3541         enum EquipmentSlot {
                      ~~~~~~~~~~~~~
    'EquipmentSlot' was also declared here.

``````ansi
<REPL0>.js:22:37 - error TS2345: Argument of type '"Chest" | "Feet" | "Head" | "Legs"' is not assignable to parameter of type 'EquipmentSlot'.
  Type '"Chest"' is not assignable to type 'EquipmentSlot'.

22       let item = equip.getEquipment(slot as keyof typeof EquipmentSlot);
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``````ansi
<REPL0>.js:22:45 - error TS8016: Type assertion expressions can only be used in TypeScript files.

22       let item = equip.getEquipment(slot as keyof typeof EquipmentSlot);
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~

``````ansi
@minecraft/server.d.ts:3541:14 - error TS2567: Enum declarations can only merge with namespace or other enum declarations.

3541         enum EquipmentSlot {
                  ~~~~~~~~~~~~~

  <REPL0>.js:1:7
    1 const EquipmentSlot = {
            ~~~~~~~~~~~~~
    'EquipmentSlot' was also declared here.

Lint Result

There are no errors from ESLint.

uneven pond
#

@tame ingot wait I will code for u

tame ingot
#

thanks

tame ingot
uneven pond
#
import { EquipmentSlot, world, system } from "@minecraft/server";

let itemEffects = {
    "myname:mitril_helmet": {
        type: "night_vision",
        duration: 200,
        amplifier: 1
    }
};

const slots = [
    EquipmentSlot.Head,
    EquipmentSlot.Chest,
    EquipmentSlot.Legs,
    EquipmentSlot.Feet
];

system.runInterval(() => {
    for (let player of world.getAllPlayers()) {
        let equip = player.getComponent("minecraft:equippable");
        for (let slot of slots) {
            let item = equip.getEquipment(slot);
            if (!item || !itemEffects[item.typeId]) continue;

            player.addEffect(
                itemEffects[item.typeId].type,
                itemEffects[item.typeId].duration || 5, {
                    amplifier: itemEffects[item.typeId].amplifier,
                    showParticles: false
                }
            );
        }
    }
}, 2);

@tame ingot this will working probably

tame ingot
#

okay

uneven pond
tame ingot
#

okay

#

thx

tame ingot
uneven pond
#

Wait

tame ingot
#

okay

#

dont import i have arleady import

uneven pond
#

Okay

#
let itemEffects = {
  "myname:mitril_helmet": {
    type: "night_vision",
    duration: 200,
    amplifier: 1
  }  
};

const slots = ["head", "chest", "legs", "feet"];

system.runInterval(() => {
  for (let player of world.getAllPlayers()) {
    let equip = player.getComponent("minecraft:equippable");
    for (let slot of slots) {
      let item = equip.getEquipment(slot);
      if (!item || !itemEffects[item.typeId]) continue;
      
      player.addEffect(
        itemEffects[item.typeId].type,
        itemEffects[item.typeId].duration || 5,
        { amplifier: itemEffects[item.typeId].amplifier, showParticles: false }
      );
    }
  }
}, 2);
#

@tame ingot

#

Remember import EquipmentSlot

tame ingot
#

[Scripting][error]-TypeError: Native type conversion failed. Function argument [0] expected type: EquipmentSlot at <anonymous> (main.js:953)

#

@uneven pond

uneven pond
#
// import { EquipmentSlot } from "@minecraft/server";

let itemEffects = {
  "myname:mitril_helmet": {
    type: "night_vision",
    duration: 200,
    amplifier: 1
  }  
};

const slots = [
  EquipmentSlot.Head,
  EquipmentSlot.Chest,
  EquipmentSlot.Legs,
  EquipmentSlot.Feet
];

system.runInterval(() => {
  for (let player of world.getAllPlayers()) {
    let equip = player.getComponent("minecraft:equippable");
    for (let slot of slots) {
      try {
        let item = equip.getEquipment(slot);
        if (!item || !itemEffects[item.typeId]) continue;
        
        player.addEffect(
          itemEffects[item.typeId].type,
          itemEffects[item.typeId].duration || 5,
          { amplifier: itemEffects[item.typeId].amplifier, showParticles: false }
        );
      } catch (error) {
        console.error(`Error retrieving equipment for slot ${slot}:`, error);
      }
    }
  }
}, 2);
wise isleBOT
tame ingot
#

[Scripting][error]-Unhandled promise rejection: ReferenceError: 'EquipmentSlot' is not defined

[Scripting][error]-Unhandled promise rejection: ReferenceError: 'EquipmentSlot' is not defined

[Scripting][error]-Plugin [ElysiumCraft - 0.1.0] - [main.js] ran with error: [ReferenceError: 'EquipmentSlot' is not defined at <anonymous> (main.js:951)
]

uneven pond
#

Did U imported

#

EquipmentSlot

tame ingot
#

i need import ???

uneven pond
#

On top of your code

tame ingot
#

okay

uneven pond
#

Like this

import { EquipmentSlot } from "@minecraft/server";
tame ingot
#

its the top of my code

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

export function log(text) { world.getDimension('overworld').runCommandAsync(tellraw @a[tag=log] {"rawtext":[{"text":"§7{log} §r${text.replace(/"/g, "\'")}"}]}) }

export function getScore(target, objective) {
target = target.scoreboardIdentity ?? target;
const o = getObjective(objective);
return o.hasParticipant(target) ? o.getScore(target) : o.addScore(target, 0);
}
function getObjective(objective) {
return world.scoreboard.getObjective(objective) ?? world.scoreboard.addObjective(objective);
}
export function runCommandAsync(command) {
try {
return { error: false, ...world.getDimension(overworld).runCommandAsync(command) };
} catch (error) {
return { error: true };
}
}

log("§dServeur juste avent")
log("§fBlitz Kitmap §7>> §9Map reloaded")
runCommandAsync("scoreboard objectives add money dummy")
runCommandAsync("scoreboard objectives add gems dummy")

uneven pond
#

Wait

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

export function log(text) { world.getDimension('overworld').runCommandAsync(`tellraw @a[tag=log] {"rawtext":[{"text":"§7{log} §r${text.replace(/"/g, "\'")}"}]}`) }

export function getScore(target, objective) {
    target = target.scoreboardIdentity ?? target;
    const o = getObjective(objective);
    return o.hasParticipant(target) ? o.getScore(target) : o.addScore(target, 0);
}
function getObjective(objective) {
    return world.scoreboard.getObjective(objective) ?? world.scoreboard.addObjective(objective);
}
export function runCommandAsync(command) {
    try {
        return { error: false, ...world.getDimension(`overworld`).runCommandAsync(command) };
    } catch (error) {
        return { error: true };
    }
}

log("§dServeur juste avent")
log("§fBlitz Kitmap §7>> §9Map reloaded")
runCommandAsync("scoreboard objectives add money dummy")
runCommandAsync("scoreboard objectives add gems dummy")
#

Nah like this

tame ingot
#

okay

uneven pond
#

See if will working

tame ingot
#

thank you so much

uneven pond
#

It worked ?

tame ingot
#

yaeh

uneven pond
#

Alr I'm happy too

tame ingot
#

how can i close

#

can i get help (resolved)

uneven pond
tame ingot
uneven pond
#

@tame ingot

#
let itemEffects = {
  "myname:mitril_helmet": {
    type: "night_vision",
    duration: 200,
    amplifier: 1
  },
  "myname:mitril_chestplate": {
    type: "strength",
    duration: 200,
    amplifier: 2
  },
  "myname:mitril_leggings": {
    type: "speed",
    duration: 200,
    amplifier: 1
  },
  "myname:mitril_boots": {
    type: "jump_boost",
    duration: 200,
    amplifier: 1
  }
};

const slots = [
  EquipmentSlot.Head,
  EquipmentSlot.Chest,
  EquipmentSlot.Legs,
  EquipmentSlot.Feet
];

system.runInterval(() => {
  for (let player of world.getAllPlayers()) {
    let equip = player.getComponent("minecraft:equippable");
    for (let slot of slots) {
      try {
        let item = equip.getEquipment(slot);
        if (!item || !itemEffects[item.typeId]) continue;
        
        player.addEffect(
          itemEffects[item.typeId].type,
          itemEffects[item.typeId].duration || 5,
          { amplifier: itemEffects[item.typeId].amplifier, showParticles: false }
        );
      } catch (error) {
        console.error(`Error retrieving equipment for slot ${slot}:`, error);
      }
    }
  }
}, 2);
wise isleBOT
jade night
#

..............

uneven pond
uneven pond
jade night
uneven pond
# jade night By the indentations you can understand that you inserted this code into some fun...
system.runInterval(() => {
    itemEffect(player)
});

function itemEffect(player) {
    let itemEffects = {
        "myname:mitril_helmet": {
            type: "night_vision",
            duration: 200,
            amplifier: 1
        },
        "myname:mitril_chestplate": {
            type: "strength",
            duration: 200,
            amplifier: 2
        },
        "myname:mitril_leggings": {
            type: "speed",
            duration: 200,
            amplifier: 1
        },
        "myname:mitril_boots": {
            type: "jump_boost",
            duration: 200,
            amplifier: 1
        }
    };

    const slots = [
        EquipmentSlot.Head,
        EquipmentSlot.Chest,
        EquipmentSlot.Legs,
        EquipmentSlot.Feet
    ];

    for (let player of world.getAllPlayers()) {
        let equip = player.getComponent("minecraft:equippable");
        for (let slot of slots) {
            try {
                let item = equip.getEquipment(slot);
                if (!item || !itemEffects[item.typeId]) continue;

                player.addEffect(
                    itemEffects[item.typeId].type,
                    itemEffects[item.typeId].duration || 5, {
                        amplifier: itemEffects[item.typeId].amplifier,
                        showParticles: false
                    }
                );
            } catch (error) {
                console.error(`Error retrieving equipment for slot ${slot}:`, error);
            }
        }
    }
}, 2);
}

I think U means like this

uneven pond
jade night
#

Yes. Absolutely incorrect code, due to which the lags will increase with each tick

jade night
#

Why was it necessary to remake it like that?

wise isleBOT
# uneven pond ```js system.runInterval(() => { itemEffect(player) }); function itemEffect...

Debug result for [code](#1304754192283602994 message)

Compiler Result

Compiler found 4 errors:

<REPL0>.js:2:16 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

2     itemEffect(player)
                 ~~~~~~

  @minecraft/server.d.ts:5272:15
    5272         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.

``````ansi
<REPL0>.js:55:2 - error TS1128: Declaration or statement expected.

55 }, 2);
    ~

``````ansi
<REPL0>.js:55:5 - error TS1005: ';' expected.

55 }, 2);
       ~

``````ansi
<REPL0>.js:56:1 - error TS1128: Declaration or statement expected.

56 }
   ~

Lint Result

ESLint results:

<REPL0>.js

55:1 error Parsing error: Declaration or statement expected

uneven pond
#

Oh

uneven pond
jade night
#

Ahhh. I just entered the name of the effect incorrectly. Write night_vision

tame ingot
jade night
#

Hmm, okay. You just made my code bigger

tame ingot
#

no

jade night
#

Show the correct code

jade night
tame ingot
# jade night Show the correct code

can you help me to create a box ???


let ElysiumCraft = {
    Box: function(player) {
        const form = new ActionFormData();
        form.title("Choisissez une box");
        form.button("Box en diamant", "textures/items/diamond_box.png");
        form.button("Box en mithril", "textures/items/mitril_box.png");
        form.button("Box en topaze", "textures/items/topaze_box.png");

        form.show(player).then((response) => {
            if (response.selection === 0) {
                this.diamond_box(player);
            } else if (response.selection === 1) {
                this.mitril_box(player);
            } else if (response.selection === 2) {
                this.topaze_box(player);
            }
        });
    },

    mitril_box: function(player) {
        const chance = Math.floor(Math.random() * 4);
        let armure = "";

        switch (chance) {
            case 0:
                armure = "mitril_Chestplate";
                break;
            case 1:
                armure = "mitril_Leggings";
                break;
            case 2:
                armure = "mitril_Boots";
                break;
            case 3:
                armure = "mitril_Helmet";
                break;
        }

        player.sendMessage("Vous avez obtenu : " + armure + " !");
        
    },

    diamond_box: function(player) {
        player.sendMessage("Vous avez ouvert une box en diamant !");
    },

    topaze_box: function(player) {
        player.sendMessage("Vous avez ouvert une box en topaze !");
    }
};

world.events.playerInteract.subscribe((event) => {
    let player = event.player;
    if (event.action === "interact") {
        ElysiumCraft.Box(player);
    }
});

uneven pond
#
let ElysiumCraft = {
    Box: function(player) {
        const form = new ActionFormData();
        form.title("Choisissez une box");
        form.button("Box en diamant", "textures/items/diamond_box.png");
        form.button("Box en mithril", "textures/items/mitril_box.png");
        form.button("Box en topaze", "textures/items/topaze_box.png");

        form.show(player).then((response) => {
            if (response.selection === 0) {
                this.diamond_box(player);
            } else if (response.selection === 1) {
                this.mitril_box(player);
            } else if (response.selection === 2) {
                this.topaze_box(player);
            }
        });
    },

    mitril_box: function(player) {
        const chance = Math.floor(Math.random() * 4);
        let armure = "";

        switch (chance) {
            case 0:
                armure = "mitril_Chestplate";
                break;
            case 1:
                armure = "mitril_Leggings";
                break;
            case 2:
                armure = "mitril_Boots";
                break;
            case 3:
                armure = "mitril_Helmet";
                break;
        }

        player.sendMessage("Vous avez obtenu : " + armure + " !");
        
    },

    diamond_box: function(player) {
        player.sendMessage("Vous avez ouvert une box en diamant !");
    },

    topaze_box: function(player) {
        player.sendMessage("Vous avez ouvert une box en topaze !");
    }
};

world.events.playerInteract.subscribe((event) => {
    let player = event.player;
    if (event.action === "interact") {
        ElysiumCraft.Box(player);
    }
});
wise isleBOT
#
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1304754192283602994 message).
You can either send the script in code block highlighted in JS format:

​`​`​`js
world.sendMessage("Hello World");
​`​`​`

Or Send an attachment end in .js to debug the file.

uneven pond
uneven pond
#

Up to u

tame ingot
# uneven pond <@987355857467633665> U also can write like this ```js player.sendMessage(`Vous...

[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'playerInteract' of undefined

[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'playerInteract' of undefined

[Scripting][error]-Plugin [ElysiumCraft - 0.1.0] - [main.js] ran with error: [TypeError: cannot read property 'playerInteract' of undefined at <anonymous> (main.js:664)
]

uneven pond
#

Thats might be error

#

Wait

#

@tame ingot what are U trying to do with player interact?

#

It's seems like not have things like this

world.events.playerInteract
#

Did U generate the code with ai?

#

If right then tell me what U do I will correct it