I’m trying to make a KubeJS script for my modpack that automatically spawns the Level 1 Wither Storm into the world after a late-game amount of time, something like 300 to 400 Minecraft days or whatever is considered a reasonable timeframe for players to beat bosses and the Ender Dragon first. The idea is that once the time condition is met, the Wither Storm spawns somewhere in the world at a random location and all players receive a global chat message like “The End has come.” to signal that the final phase of the pack has begun.
I want this to only happen once per world and not repeat on server restarts. I don’t need anything complex yet, just the core logic for tracking days, triggering the spawn, spawning the level 1 version, and sending a server-wide announcement. If anyone has example scripts or knows the cleanest way to structure this in KubeJS, I’d really appreciate the help.
#How to spawn Wither Storm after X days + global announcement?
15 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
I don't have any experience scripting so if need be I'll pay to commission someone for the scripts I need done for my modpack if that's cool
well well well. We meet again 😈
Seems like this boils down to two parts
Part one, game time tracking.
Part two, the actual spawning of the wither storm.
The game tick tracking can be a bit tricky, but I’ll see if I can dig up some posts that have code to reference
The second part can be tested pretty easily.
Just define a function, that runs when somebody says something in chat, and then tweak that function till it does what you want.
Making it a function so you can reload the script while testing, so you don’t need to restart your game
For part 1:
Here is one that runs logic at 6 AM each Minecraft day:
https://discord.com/channels/303440391124942858/1459594065011281920
For part 2:
this has one way to spawn a mob, specifically by running a command to spawn the entity:
[➤](#1216964089411145770 message)
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
EntityEvents.spawned(event => {
let entity = event.entity
if (event.level.getLunarContext() === null) return
const event_string = event.level.getLunarContext().getLunarForecast().getCurrentEventRaw().key().location().toString()
if (event.level.getLunarContext() === null) {
if (entity.type == 'minecraft:creeper' && entity.level.canSeeSky(entity.blockPosition()) && event_string === "enhancedcelestials:blood_moon") {
if (getRandomInt(2) == 0) {
event.server.runCommandSilent(`execute in ${entity.level.dimension} positioned ${entity.x} ${entity.y} ${entity.z} run summon mobz:tank`)
event.cancel()
}
}
}
})```
The creepers are still spawning as creepers during the blood moon. I guess even with examples this is above my level.
Trying to find an example of spawning via code but having a tough time with discord search
Here is an example of telling the server something:
[➤](#1217465456756260994 message)
// Global function to handle applying extra ticks to blocks below
/** @param {Internal.BlockEntityJS} entity */
global.extraTickBlock = entity => {
const { block, level, blockPos } = entity;
entity.level.server.tell(`Current block: ${block.id}`); // Log the current block ID
const belowPos = blockPos.below(); // Position of the block directly below
const belowBlock = level.getBlockState(belowPos); // Get the block directly below
const extraTicks = 3; // Number of extra ticks to apply
// Apply extra random ticks to the block below
for (let i = 0; i < extraTicks; i++) {
belowBlock.randomTick(level, belowPos, level.random);
entity.level.server.tell(`Applied extra tick ${i + 1} to block below.`); // Log each extra tick application
}
};
// Use StartupEvents.registry to register the custom block
StartupEvents.registry("block", event => {
event.create('enhanced_stimulating_block') // Changed the name to reflect new functionality
.hardness(0.5)
.resistance(0.5)
.displayName('Enhanced Stimulating Block')
.blockEntity(entityInfo => {
entityInfo.serverTick(20, 0, entity => {
global.extraTickBlock(entity); // Call the function to apply extra ticks
}); // Every 20 ticks, with 0 tick offset
});
});
``` not sure I changed anything except the server tell location lol
Specifically the server.tell part
Im in the kitchen cooking that 91 percent like Walter chill