Realistic Terrain Generation

Realistic Terrain Generation

3M Downloads

Desert villages use cobblestone structures

KeepOnDigging opened this issue · 30 comments

commented

Villages generated in desert are made up of standard cobblestone structures:
image of desert village

They should be made up of sandstone structures, as in Vanilla.

KeepOnDigging!

commented

@KeepOnDigging - forgot to ask, is this happening with just RTG, or does it only happen when used in conjunction with biome-adding mods? If the latter, which one's the culprit?

commented

I have only found a desert village made with cbbl when it was right next to a non desert biome and even then half the village was still in sandstone. I do not have cbbl villages in ny deserts in my world

commented

Yeah, that would explain it actually... I believe the village algorithm works the same way as the structure algorithm in that it just needs to find a viable block in a viable biome, and then it can start generating the village up to 20(?) blocks away from that block. (I think)

commented

I set up a world which generates only desert… and rivers.
This village generated with no other biomes for hundreds of blocks:
image of desert village

I don't have CC installed, or any other mods which add biomes.
RTG has:
I:"Generate only this biome ID"=2
B:"RTG Biome Layout"=true

just to make it generate only desert (a nice feature which I will miss when RTG layouts go away!).

Is there anything else I can do to help diagnose this problem?

KeepOnDigging!

commented

I have just confirmed this bug with CC (latest) and snapshot5-rc1.

commented

Is this with ONLY using rtg also ? Cause I may know why it's happening then and also why I don't have it :p

commented

Maybe add StructureVillagePieces.java to RTG so we know its gonna read it.
I dunno if it helps but i think that is the file where it reads if desert use sandstone.

just my 2 cents ;)

commented

Ok, it was definitely working in 0.4.0, and I've just compared 0.4.0 vs 0.5.0-snapshot-1 and narrowed it down to the following files:

RealisticBiomeBase.java
RealisticBiomePool.java
WorldChunkManagerRTG.java
ChunkProviderRTG.java
WorldTypeRTG.java

I suspect it might have something to do with how we're calculating getBiomeGenAt() in ChunkManagerRTG because in net.minecraft.world.gen.structure.StructureVillagePieces, there's the following lines (1512-1513):

BiomeGenBase biomegenbase = p_i2104_1_.getBiomeGenAt(p_i2104_4_, p_i2104_5_);
this.inDesert = biomegenbase == BiomeGenBase.desert || biomegenbase == BiomeGenBase.desertHills;

If you trace the relevant variables around, you eventually end up at line 1725, which is where the sandstone vs. cobblestone comes into play.

commented

It happens with RTG only installed (i.e. using RTG to restructure and redecorate vanilla biomes).

It also happens with CC installed, but no other biome-adding mods.

commented

With only I mean it be the only mod installed besides forge :)

commented

Yes.

With RTG as the ONLY mod installed, villages in deserts are made up of cobblestone buildings, never sandstone.

commented

I've confirmed that it's definitely happening - just been trying to figure out why. The main village file in RTG is MapGenVillageRTG, which hasn't really changed in any sort of significant way for a couple of months, so I'm currently trying to figure out when the issue first started happening so that I can compare the entire source and see if anything sticks out.

commented

what ?
mc desert is 2 rtg desert is 2

commented

I think I know what Zeno means... we just need to write our own StructureVillagePieces and compare biome IDs instead of comparing full biomes because BiomeGenBase.desert isn't the same as RealisticBiomeVanillaBase.vanillaDesert, which might be what's happening. And even if that's not exactly what's happening, writing our own StructureVillagePieces will allow us to write our own logic for determining whether to use sandstone or cobblestone... should be relatively easy to fix.

commented

so basicly he could say, yeah lets do what ezo suggested :P

commented

i can do that if you want, cause i am cool and smart and shit ;)

commented

ok so i made a map using the rc2

2016-01-22_12 50 29
2016-01-22_12 49 30
2016-01-22_12 49 00

commented

and like i said, i always have sandstone, so how is this possible

commented

It could just be that RealisticBiomeBase.desert != BiomeGenBase.desert and I ended up switching the BiomeGenBase that comes out from vanilla to realistic. Try comparing by biome ID - that will work on any mix of vanilla and realistic biomes.

commented

No, I meant change it to
BiomeGenBase biomegenbase = p_i2104_1_.getBiomeGenAt(p_i2104_4_, p_i2104_5_);
this.inDesert = biomegenbase.biomeID == BiomeGenBase.desert.biomeID || biomegenbase.biomeID == BiomeGenBase.desertHills.biomeID;

A strict equality test might fail even for a BiomeGenBase.desert because there could be more than one such object created. I don't think they bothered to overwrite the equality test.

commented

Here is a MultiMC instance:
http://www.keepondigging.com/RTG.zip

It runs with Forge 1558.
The only mod installed is RTG 0.5.0-RC2
RTG config is all default.

I have included a save showing a cobblestone desert village.

Seed is 35267400
/tp 950 71 -1550

commented

This is proving more difficult than I thought it was going to be. My approach was to copy StructureVillagePieces as StructureVillagePiecesRTG which extends StructureVillagePieces, get rid of all the errors, and override the method that checks for desert stuff... but because the village system consists of so many different classes (and classes within classes), I'm struggling to get anything working.

Is there any easier way to do this that I'm just not seeing?

I had a look at how EB handles village stuff for inspiration, but that looks even more complicated.

commented

Actually, Forge has an event (BiomeEvent.GetVillageBlockID) that might work. Trying it now.

commented

Ok, so... BiomeEvent.GetVillageBlockID does seem like it would work. It basically gets called every time the village generator chooses a block to place, based on the biome that it's in. The idea is, the event tells you which biome it's in and the block that it wants to place, and then you can set the block to be something else.

So...

I wrote an event listener to see if I could replace the cobblestone in desert biomes, but it didn't work. The reason? The event's 'biome' variable is always null. And I have no idea why.

If I comment out the biome check and just replace cobble with sandstone no matter what, it works - the cobble is replaced. So in theory I think this could resolve the issue... but first we just need to figure out why event.biome is always null.

commented

Um - that doesn't fix the problem, that just replaces the "cobble everywhere" problem with a "sandstone everywhere" problem, which is IMO worse.

UB replaces village stone and it had this problem. My solution was to add a event listener for pre-BiomeDecorate events:
public void preBiomeDecorate(DecorateBiomeEvent.Pre event) {
if (this.ubOn() == false) return;
BiomeGenUndergroundBase[] undergroundBiomesForGeneration = null;
undergroundBiomesForGeneration = loadUndergroundBlockGeneratorData(undergroundBiomesForGeneration, event.chunkX,event.chunkZ, 16, 16);
villageStoneChanger.setStoneCode(
getUndergroundBiomeGenAt(event.chunkX, event.chunkZ).fillerBlockCodes);
}

You would want different code; rather than getting the undergroundBiomeForGeneration you'd call

chunkManagerRTG.getBiomeGetAt(event.chunkX_16+7, event.chunkZ_16+7))
[I think this is chunk coords and so you have to convert to world coords but this has to be tested]
and then check whether it's a desert biome (by ID or via the biome dictionary, not with equality checks). If desert, you'll need to store that fact somewhere. I have a villageStoneChanger object which is handling the village stone replacement so I just inform it.

commented

Taking a step back…

How about hooking this up with the config system.
So there's a config in each biome to specify the village's building material

It would be nice to also allow ice villages in frozen biomes.
And Hardened Clay villages in Mesa.

commented

I seem to be having an issue getting the correct biome from ChunkManagerRTG.getBiomeDataAt() --- I'm subscribing to the preBiomeDecorate event and using the same code that I'm using to determine whether a biome should allow villages to generate (which seems to be working fine), but the same code isn't working reliably here.

Currently, I'm only replacing cobble with sandstone as a way to see if things are working, and sometimes it replaces part of the village's cobble with sandstone, but never all of it.

Any feedback on what I might be doing wrong would be appreciated.

commented

Well I'll be... never in a million years would I have figured out that variables called "chunkX" and "chunkZ" would actually be world coords.

Thank you! It's working a treat - now I just gotta replace all the other blocks and this one will finally be resolved. 👍

commented

Fixed in a2fb7b8 and merged into dev

commented

Name notwithstanding, I think the coordinates are already world coordinates, so try not multiplying by 16