// Define the waves of enemies in array
// Start the Mob Portal
const activationItem1 = "minecraft:leather";
// Define the length of the waves
const waveLength = 3;
BlockEvents.rightClicked( event => {
const { item, hand, player, block, level } = event;
const {x, y, z} = block.getPos();
if (hand != 'MAIN_HAND') return;
if (item.getId() == activationItem1) {
//event.success(mobPortals(level, player,x,y,z));
item.count--
event.success(mobPortals(level, player,x,y,z))
}
});
// Function to start the Mob Portal
function mobPortals(level,player,x,y,z) {
// Mob Portal Activation message
player.tell(["Mob Portal now Activated!"]);
// Loop through waves
for (let waveIndex = 0; waveIndex < waveLength; waveIndex++) {
let currentWave = [waveIndex + 1];
// Define each wave
currentWave.forEach(() => {
player.tell(["Wave: ", waveIndex + 1]);
let entity = level.createEntity("minecraft:zombie")
entity.x = x + 0.5
entity.y = y + 1
entity.z = z + 0.5
entity.mergeNbt({
ActiveEffects:[{Duration:9999,ShowParticles:0,"forge:id":"minecraft:glowing"}]
})
entity.spawn();
});
}
// Mob Portal completion reward and completion message
//player.tell(["Mob Portal now Completed!"]);
// Mob Portal failure message
//player.tell(["You have failed"]);
}
#How can i Increase amount of mobs spawned per wave and how do i add a timer to each wave
8 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
and sorry if my code is ass 
You don't need the "currentWave" array because it only contains one number at any given time. This also makes the "forEach" obsolete.
Would i not need the foreach to define what spawns in each wave?
No, because your array always only has a length of 1. This means that "forEach" is always only executed once.. And I found the idea interesting and tried something around. This has a timer and an increase in mob per wave ```js
// Start the Mob Portal
const activationItem = 'minecraft:leather';
// Define the length of the waves
const waveLength = 5;
//time between waves in secs
const time = 5;
BlockEvents.rightClicked('minecraft:stone', (event) => {
const {
item,
hand,
player,
server,
block: { x, y, z },
} = event;
if (hand != 'MAIN_HAND') return;
if (item.id !== activationItem) return;
item.count--;
// Mob Portal Activation message
player.tell(Text.of('Mob Portal now Activated!').green());
for (let i = 0; i < waveLength; i++) {
server.scheduleInTicks(i * (time * 20), (cb) => {
const waveNum = cb.timer === 0 ? 1 : cb.timer / (time * 20) + 1;
player.tell(Text.of(Wave: ${waveNum}).yellow());
for (let i = 0; i < waveNum; i++) {
//for some reason this creates only the same zombie with the same uuid
/* const entity = level.createEntity('minecraft:zombie');
entity.x = x + 0.5;
entity.y = y + 1 + i * 2;
entity.z = z + 0.5;
entity.spawn(); */
server.runCommandSilent(
summon minecraft:zombie ${x + 0.5} ${y + 1} ${z + 0.5}
);
}
});
}
});
ahh i see, that would explain one of the issues i ran into(i should mention this is my first time experimenting with kubejs) The idea is to basically make the "gateways to eternity" mod concept in kubejs
And damn that script is nice, it def gives me something to work on and add to. Thanks for the help, it really is appreciated!
You're welcome 🙂