I'm having an issue where certain functions do not execute properly. As I'll show here:
world.afterEvents.entityDie.subscribe(async evd => {
const player = evd.deadEntity
const attacker = evd.damageSource
if (player.typeId !== "minecraft:player") return;
{
const gamemode = world.getDynamicProperty('gamemode')
const inRound = player.getDynamicProperty('inRound')
if (inRound == true && gamemode == 1) {
let life = player.getDynamicProperty(`life`)
if (life != 0) {
life -= 1
player.setDynamicProperty("life", life)
{
//TODO: Verify integrity of random spawns, this is just tempoary code until I make something better for now
const spawns = world.getDimension('overworld').getEntities({ type: 'chaotic:multi' }).filter(e => e.getDynamicProperty('multiType') === 'spawn').sort(() => Math.random() - Math.random())
const x = spawns[0].location.x
const y = spawns[0].location.y
const z = spawns[0].location.z
player.camera.fade({ fadeColor: { red: 0, green: 0, blue: 0 }, fadeTime: { fadeInTime: 0, fadeOutTime: 1, holdTime: 0 } })
player.setSpawnPoint({ dimension: player.dimension, x: x, y: y, z: z })
}
} else {
console.warn(`Calling exitRound`)
exitRound(player)
}
Here, exitRound will sometimes not show up in logs for no seemingly reason, but will run through anyways?? I'm honestly not sure whats going on here, but its messing with me debugging another issue.
Another issue is another seperate function, checkPlayerArray which gets called multiple times. Never seems to work, with no logs simply showing up or getting past calling it. once again not sure why.
function checkPlayerArray(){
const playerArray = world.getPlayers().filter(e => e.getDynamicProperty(`inRound`) === true)
console.warn(`playerArray`)
if (playerArray.length == 0) {
world.sendMessage(`END THE ROUND NOW 0 ${playerArray.length}`)
console.warn(`Check 1 Pass`)
} else if (playerArray.length == 1) {
world.sendMessage(`END THE ROUND NOW 1 ${playerArray.length}`)
console.warn(`Check 2 Pass`)
}
console.warn(`Checks Attempted`)
}
I could very well be doing alot wrong, but I'm just not sure what anymore with the fact console.warn randomly outputs nothing. I've tried moving console.warn up and down lines in case order was messing it up, but it seems not?