Sweep 'N Slash completely disables the vanilla damage mechanics. Because of this, it is necessary to pre-define stats for the weapons to function correctly. This also means you can define any stats for any item, even if the item is not intended to be used as a weapon.
Existing stats can be defined internally and/or by sending items data from external addons.
Overwrite orders work the same as how you order RP/BP in the game. The topmost addon will have the final stats.
In weaponStats folder, you can simply add entries in the existing files. Or if you want to import it from separate files, create a file in the 'weaponStats' folder and add an entry in the 'importStats' array inside the 'importStats.ts'. After that, compile the pack and the stats will be added in the pack. You can also manually add stats inside the already compiled pack, but it's not recommended.
First, install IPC for your addon from this website: https://github.com/OmniacDev/MCBE-IPC
Or you can use the IPC built for Sweep 'N Slash if you don't know what you're doing. (IPC.zip) You can also use a complete IPC pack for better understanding. (IPC_example_pack.zip)
Extract the zip file into scripts folder. After that, make a file or use an already existing file to define your stats on.
In your stats file, import these:
import { WeaponStatsSerializer } from './IPC/weapon_stats.ipc';
import { IPC, PROTO } from './IPC/ipc';
import { world } from '@minecraft/server';And then, paste this into the stats file:
- Script v1
world.afterEvents.worldInitialize.subscribe((event) => {
IPC.send(
'sweep-and-slash:register-weapons',
PROTO.Array(WeaponStatsSerializer),
weaponStats
);
});- Script v2
world.afterEvents.worldLoad.subscribe((event) => {
IPC.send(
'sweep-and-slash:register-weapons',
PROTO.Array(WeaponStatsSerializer),
weaponStats
);
});The 'weaponStats' will be the name of the stats array:
const weaponStats = [
{
id: 'namespace:example1',
attackSpeed: 1.6,
// ...
},
];If the stats are not importing, turn on Debug Mode and reload the world to see if the stats are importing correctly.
NOTE: Sweep 'N Slash uses 2.1.0-beta module for @minecraft/server. This means IPC exported functions are required to follow 2.1.0-beta formats.
(Credits to Hog554 and OmniacDev for the help!)