Custom Abilities
This page of the wiki will show you how to make a custom ability. Custom abilities are made using KubeJS scripts.
- Make a file in the addon scripts directory.
- Add the code to register the ability.
StartupEvents.registry('palladium:abilities', (event) => {
// ID of the condition will be: 'kubejs:mycoolpack/mycoolability'
event.create('mycoolpack/mycoolability')
});
- Add a preset icon.
StartupEvents.registry('palladium:abilities', (event) => {
event.create('mycoolpack/mycoolability')
.icon(palladium.createItemIcon('palladium:vibranium_circuit'))
});
- [OPTIONAL] Add the first tick handler. You can dfine the behaviour of what happens during the first tick of the ability being enabled.
StartupEvents.registry('palladium:abilities', (event) => {
event.create('mycoolpack/mycoolability')
.icon(palladium.createItemIcon('palladium:vibranium_circuit'))
.firstTick((entity, entry, holder, enabled) => {
entity.tell('First Tick!');
});
});
- [OPTIONAL] Add the tick handler. You can dfine the behaviour of what happens during every tick of the ability. You should use
enabled
to see if the ability is enabled.
StartupEvents.registry('palladium:abilities', (event) => {
event.create('mycoolpack/mycoolability')
.icon(palladium.createItemIcon('palladium:vibranium_circuit'))
.firstTick((entity, entry, holder, enabled) => {
entity.tell('First Tick!');
})
.tick((entity, entry, holder, enabled) => {
if (enabled) {
entity.tell('Tick!');
}
});
});
- [OPTIONAL] Add the last tick handler. You can dfine the behaviour of what happens during the last tick of the ability being enabled.
StartupEvents.registry('palladium:abilities', (event) => {
event.create('mycoolpack/mycoolability')
.icon(palladium.createItemIcon('palladium:vibranium_circuit'))
.firstTick((entity, entry, holder, enabled) => {
entity.tell('First Tick!');
})
.tick((entity, entry, holder, enabled) => {
if (enabled) {
entity.tell('Tick!');
}
})
.lastTick((entity, entry, holder, enabled) => {
entity.tell('Last Tick!');
});
});
That's it! Now you can use your ability in your power json file. You can find the ID in the abilities.html.