Terrain Control

Terrain Control

235k Downloads

ReplacedBlocks ignores random chunks

Mysteryem opened this issue · 13 comments

commented

For quite a while now, I've noticed that ReplacedBlocks seems to ignore seemingly random chunks. The SurfaceBlock and GroundBlock still works correctly in these chunks, but all of the ReplacedBlocks in these chunks are ignored. In the image below, the lava should have been replaced with ice and the stone with netherrack. (The bedrock has been replaced with obsidian using BedrockobBlock:49 in the world config)
replacedblocks failure
The exact ReplacedBlocks line for the biome in the picture is:

ReplacedBlocks:(STONE,NETHERRACK),(GRASS,ICE),(LAVA,ICE),(STATIONARY_LAVA,ICE),(YELLOW_FLOWER,REDSTONE_TORCH_ON),(RED_ROSE,REDSTONE_TORCH_ON)

This bug occurs in all biomes.

If I regen the affected chunks with worldedit, they generate correctly.

From my experience, it seems as if this only happens (or most frequently happens) near certain areas of chunks which suffer from another problem.

commented

@Timethor @rutgerkok affects 2.7.2-snapshot

commented

ReplacedBlocks has always been buggy since Bucyruss implemented it in Minecraft Alpha. It seems to happen more often when the server is under high load. 3 of the 10 current bugs are caused by it and over the past 2.5 years nobody has been able to fix it. 😦

commented

That would seem to fit with my initial thought that it happened more often in the start region around the initial spawn.

While looking around about this, I also came across #125, which appears to be affecting my server too :(. It would appear that this particular bug with the chunks can also affect the one with the ores. Time for some experimenting I think.

commented

I found that the affected chunks remains constant according to the seed. I added a couple of lines to com.khorn.terraincontrol.bukkit.TCBlockPopulator to tell me if the chunk from

public void populate(World world, Random random, Chunk chunk)

had the same chunk co-ordinates as the affected chunk. Chunks which are correctly replaced show up, but those that aren't replaced at all never show up. Seeing as the above function is an override for org.bukkit.generator.Block.Populator, I'm guessing this is a bukkit related bug.

commented

it happens in forge so it's not a bukkit issue. I'm running forge without any bukkit-style compatibility added.

commented

That's good to know zanotam.

One thing I did notice in craftbukkit was https://github.com/Bukkit/CraftBukkit/blob/master/src/main/java/net/minecraft/server/ChunkProviderServer.java#L130 which suggests to me that it might be connected to why some of the chunks are ignored. While most of the chunks which ReplaceBlocks does nothing to are very close to spawn, the occasional few aren't, so I'm not sure this is the exact problem we're facing here.

By moving the ReplacedBlocks's function to be called for every bukkit ChunkPopulateEvent I managed to eliminate the ReplacedBlocks problem entirely. Interestingly, the rather broken ore generation (#125) appeared to remain exactly the same.

I haven't had the time to do any further work on this since just after I posted this issue, but I intend to once the exam season is over. Though it should be noted that anything I do will probably be for bukkit, since I've not had a look at modding with forge at all.

It unfortunately looks like the easiest method to fix this problem will be separating the ReplacedBlocks (and potentially ore generation) into individual bukkit and forge versions.

I can also confirm that ReplacedBlocks failing to work does not at all seem to be affected by server load as keeping the seed of the server constant will produce exactly the same chunks which do not get their blocks replaced. -2719171063581370876 is a seed in which where you spawn will often be in one of the chunks which isn't affected; there are also a lot more chunks like this nearby.

commented

Thanks, just tested it. After moving the spawn point and removing the region and player folders, I spawned at the new spawn. After teleporting back to the old spawn, the chunks at there were replaced. However, bug #125 (ore generation inconsistent) popped up again. So your theory about it only affecting spawn chunks is most likely correct.

A radical fix would be to move ReplacedBlocks to the generation, just after the base terrain is generated (so just after this method has been called). This would also solve #125, but it will make some old configs incompatible. It would also be impossible to replace blocks in dungeons, mineshafts, strongholds, etc. , but that can be worked around using your own BO3s.

(@Wickth, if you have time, what do you think about it?)

commented

It may be worth noting that I've always found that replacing blocks in dungeons, mineshafts and strongholds to not be at all reliable. A lot of chunks end up not being replaced: http://i.imgur.com/kiQKsPT.png (not necessarily always in such straight lines as this I don't think)

commented

@Mysteryem Thanks for all your work.

If skipped chunks are dependant on the seed, then it must also be dependant on the settings. I tried your seed with the beaches and hills world from here, and I couldn't reproduce the problem, the beaches (which are made using ReplacedBlocks) generated fine.

commented

@rutgerkok I've sent you an email with my server files attached. (seed is again -2719171063581370876)

commented

Can confirm that this is still an issue in 1.7.2: http://imgkk.com/i/4j6q.png

commented

#285
this atleast was still an issue recently in 1.7.10 idk if it still is or not havent tested

commented

Confirmed too by @riddle that this still happens in 1.7.10. #305