import { getRandomItem } from "../../functions";

const messages = [
    "trueweapons.contusion.line1",
    "trueweapons.contusion.line2",
    "trueweapons.contusion.line3",
    "trueweapons.contusion.line4"
];

export default {
    async execute(item, entity) {
        const tag = item?.getTags()?.find(tag => tag == "contusion");

        if (!tag) return;
        if (Math.random() > (4 / 100)) return;
        if (entity.typeId == "minecraft:player") {
            entity.onScreenDisplay.setActionBar({ translate: getRandomItem(messages) });
            entity.camera.fade({ fadeColor: { red: 1, green: 1, blue: 1 }, fadeTime: { fadeInTime: 0.4, fadeOutTime: 0.7, holdTime: 1 } });
            entity.playSound("true.player.contusion", { location: entity.location });
        }
    }
}