AllYourBlocks / ChunkWars

Chunk Wars is a team-based attack-defend minigame for Minecraft. You play in an arena of different Chunks, all carefully handcrafted to replicate different Minecraft biomes and structures as closely as possible. Along with your team you will face everything that vanilla Minecraft can throw at you. Your goal is to be the last team standing.
https://www.planetminecraft.com/project/chunk-wars-1487425
GNU General Public License v3.0
1 stars 0 forks source link

/function build:every_nether is breaking the Arena rebuilding #189

Open AllYourBlocks opened 10 months ago

AllYourBlocks commented 10 months ago

This is an expansion on issue #178 which I will close as there is information provided here...

When /function build:every_nether has been used, the Arena does not rebuild correctly afterwards when using /function rebuild:arena

Behaviour is... Yellow Side builds... Blue side does not build, apart from Blue Home Chunk which does build... then wool does get painted correctly

Running /function build:blue_nether and /function build:yellow_nether separately does not cause the subsequent /function rebuild:arena command to fail on Blue side

AllYourBlocks commented 10 months ago

Notably, in Random Condensed, executing /function build:every_nether did not break the Arena rebuild afterwards

The number of commands run was different... 480 vs 490 (the standard number) on occasion, unclear why this is

AllYourBlocks commented 10 months ago

I also note that the number of commands run in /function build:every_nether is substantially more than the sum total number of commands in /function build:blue_nether and /function build:yellow_nether

slipcor commented 10 months ago

I think Mojang did a few changes to chunk loading or unloading order, and thus now it became a problem that we do all the painting of chunks in one tick, and then also in the same tick move the markers away.

Especially when we do multiple paintings (which happens at "every nether") this becomes a bug.

I could recreate the error simply by running the blue nether function - which made no sense to me, somewhere along the way I might have just fixed it now.

Also, the red and green nether-functions were always completely called even with 2 team mode. This can definitely have messed up the timings, so much so that we had 4 threads fighting over the paste markers going back and forth between pasting another nether chunk and getting reset before the next color tries to paste its nether chunks, somehow losing the paster markers in the process.

Fact of the matter is, with any function apart from "build yellow", we ended up deleting 2 out of the 4 markers. Now all 4 markers persist. Let us examine this further. maybe I need to rewrite the marker safety feature.

slipcor commented 10 months ago

Can be tested now, should be fixed in latest commit

slipcor commented 10 months ago

To explain, this issue was caused by two things at the same time:

First issue: Attempt to build green and red nether

We were calling red and green nether build functions regardless of how many teams we actually need. I assumed this can do no harm. I was wrong.

This is the code we used to have, it will always be called, when asking to build either every nether or in this case green:

https://github.com/AllYourBlocks/ChunkWars/blob/f5e502d74cc7608df731c3f7c785191c4542f68e/chunkwars/data/arena/functions/build/green_nether.mcfunction#L4

Now let us assume the highlighted line is the one we call, we are in a 2 team arena, modern, not condensed. This will call this function:

https://github.com/AllYourBlocks/ChunkWars/blob/f5e502d74cc7608df731c3f7c785191c4542f68e/chunkwars/data/arena/functions/build/4teams/modern/standard/green_nether.mcfunction#L9

Here the highlighted function attempts to build the green nether in location of the 4 teams modern standard arena, thus teleporting the green marker out of bounds, unloading it. Furthermore, the function function arena:paint/4teams/modern/standard - at the end - moves ALL markers to the mid point of the 4 teams modern standard arena, effectively trapping all markers. It is random and lucky that any markers survive this and come back by the painting that we do in the proper required yellow/blue call.

First fix: Verify that we are in a 4 team arena before even trying to deal with green and red nether:

https://github.com/AllYourBlocks/ChunkWars/blob/8538c2d35d9a628f4a72337ea717701b272ca80e/chunkwars/data/arena/functions/build/green_nether.mcfunction#L4

Check that we are in 4 teams mode, otherwise skip green and red nether building.

Second issue: 4 team standard arena actually attempted to build condensed arena chunks

Here is the example with red, but it was copypasted wrongly for all colors:

https://github.com/AllYourBlocks/ChunkWars/blob/8538c2d35d9a628f4a72337ea717701b272ca80e/chunkwars/data/arena/functions/build/4teams/modern/standard/red_nether.mcfunction#L9

So we moved the build-markers over into the wrong arena, unloading them.

Red is an even more special case because you might see it is calling "0_4" which is the chunk with index 4 - correct - but with orientation "no rotation offset", which is wrong because that is the blue chunk. So the red nether tried to build the blue chunk. This is now also fixed.

Second fix: call proper functions of standard arena, and use actual red chunk for red nether

AllYourBlocks commented 10 months ago

Fantastic, thanks @slipcor - I'll test as soon as I can!

AllYourBlocks commented 10 months ago

Arena now does not rebuild after a standard game.

On running /function rebuild:arena the Arena is cleared, then Yellow Home Chunk builds, then after a pause Blue Home Chunk builds, Wool gets painted correctly.

The pause is the point at which the rest of the Arena should build, but it does not.

New system seems to have introduced a new bug.

AllYourBlocks commented 10 months ago

On continued testing after a full map reset, this bug still presented in the same manner

I then did another full reset, and in the subsequent game, I ran all 3 of the following commands...

/function build:blue_nether /function build:yellow_nether /function build:every_nether

I then did a standard /function rebuild:arena at the end of that game, and the Arena did rebuild correctly.

Is it possible that a single run-through of the fixed 'Nether commands' has fixed the underlying Markers issue?

I will keep a watching brief on this in the next round of test games and report back.