This repository has been archived on 2023-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
jland-packwiz-pack/kubejs/server_scripts/weather/twilight/clear_weather.js

23 lines
823 B
JavaScript
Raw Permalink Normal View History

2023-11-02 12:32:44 -05:00
BlockEvents.rightClicked((event) => {
const { entity, block, level, server } = event;
if (!entity.isPlayer() || entity.isFake()) {
return;
}
const dimension = String(level.getDimension());
if (
(level.isRaining || level.isThundering) &&
dimension == 'twilightforest:twilight_forest' &&
block.getId().match(/(minecraft:|comforts:).*(_bed|sleeping_bag|hammock_)/)
) {
// clear weather after 100 ticks
server.scheduleInTicks(100, (schedule) => {
let interval = randomInt(3, 7) * 24000;
console.log(`Halting Rain for ${interval} ticks!`);
let command = `/execute in minecraft:overworld run weather clear ${interval}`;
schedule.server.runCommandSilent(command);
});
}
});