// This script is so the fuel can does not take damage when hitting an entity whilst holding it. 
// This means that it will only lose durability when we tell it, inside the fuel use script.
import { world } from "@minecraft/server";

//put all your custom item setups in this array
const itemComponents = [
    {
        id: "pb_plane:no_damage",
        code: {
            onBeforeDurabilityDamage: (data) => {
                fuelCan.beforeDurabilityDamage(data)
            }
        }
    }
]

//register components from array
world.beforeEvents.worldInitialize.subscribe((data) => {
    for (const comp of itemComponents) {
        data.itemComponentRegistry.registerCustomComponent(comp.id, comp.code);
    }
});

//make up some manager class per item to handle events
export class fuelCan {
    static beforeDurabilityDamage(data) {
        data.durabilityDamage = 0;
    }
}