Vampirism - Become a vampire!

Vampirism - Become a vampire!

16M Downloads

RTG compatibility

whichonespink44 opened this issue ยท 11 comments

commented

Hi -

I'm working on a terrain generation mod called RTG, and I'm trying to add support for Vampirism.

The Vampire Forest biome is generating fine, and so are the various mobs, but... the Vampire Castle doesn't seem to like the RTG world type.

Am I right in thinking that the Vampire Castle can only generate in the default world type? If so, is there any way that RTG could generate it manually somehow? Perhaps through the API?

Thanks for your time,
Pink

commented

Hi,

I didn't find a reason why the castle is not generating yet.
Can you provide me with a build in which the Vampire Forest already is working (or does it already work in your current build on curse forge), so I can try out some things?

Thanks,
Maxanier

commented

Sure thing, here's a build of the vampirism-support branch:

https://goo.gl/afDPds

Using that build and Vampirism 0.7.8.4, this seed should spawn you a few meters from a Vampire Forest biome:

-8676017689292570262

Thanks for looking into this - If you need anything else from me, just let me know.

commented

Forgot to mention... depending on the seed, sometimes I would see a message that said something like:

"Vampirism could not find a suitable location for the Vampire Castle... etc."

It doesn't happen with every seed, but even with the seeds that don't have that message, the Vampire Castle still doesn't seem to generate... unless I'm getting extremely unlucky in finding one.

commented

I think there are two separate problems:

First thing is that it seems the vampire forest is generated too rarely. Vampirism checks 128 chunks for the Vampire Forest in a radius of 32 chunks, which probably is a little bit low. But even if I increase that value to 12800 in a range of 9600 chunks it does not find anything.
I also wrote small script/command that checks every second chunk in a given range. I'm not 100% sure it works, but in non realistic world types it seems so. I checked several realistic world types with a radius 100.000 chunks, but even that did not find any biome.

Second thing is that the castle generator needs a large enough area (4x4) to generate.

/**
* Optimizes the given position by choosing a large area only containing the vampire biome, setting a useable size and adjusting the position
* Finds the largest area with this algorithm http://www.geeksforgeeks.org/maximum-size-sub-matrix-with-all-1s-in-a-binary-matrix/
*
* @param position
* @param world
* @param rnd
* @return Modified position or null if the positions is useless
*/
private @Nullable
CastlePositionData.Position optimizePosition(CastlePositionData.Position position, World world, Random rnd) {
Logger.d(TAG, "Optimizing Position %s", position);
long t = System.currentTimeMillis();
final int TEST_SIZE = 10;
final int D_TEST_SIZE = TEST_SIZE * 2;
Boolean[][] biomes = new Boolean[D_TEST_SIZE][D_TEST_SIZE];
for (int i = -TEST_SIZE; i < TEST_SIZE; i++) {
for (int j = -TEST_SIZE; j < TEST_SIZE; j++) {
biomes[i + TEST_SIZE][j + TEST_SIZE] = ModBiomes.biomeVampireForest.equals(world.getWorldChunkManager().getBiomeGenAt((position.chunkXPos + i << 4)+8, (position.chunkZPos + j << 4)+8));
}
}
// Logger.i(TAG,"Biomes");
// this.printMatrix(biomes);
Integer[][] help = new Integer[D_TEST_SIZE][D_TEST_SIZE];
for (int i = 0; i < D_TEST_SIZE; i++) {
help[i][0] = (biomes[i][0]) ? 1 : 0;
}
for (int i = 0; i < D_TEST_SIZE; i++) {
help[0][i] = (biomes[0][i]) ? 1 : 0;
}
for (int i = 1; i < D_TEST_SIZE; i++) {
for (int j = 1; j < D_TEST_SIZE; j++) {
if (biomes[i][j]) {
help[i][j] = Math.min(help[i - 1][j], Math.min(help[i][j - 1], help[i - 1][j - 1])) + 1;
} else {
help[i][j] = 0;
}
}
}
int[] max = { -1, -1, -1 };
for (int i = 2; i < D_TEST_SIZE; i++) {
for (int j = 2; j < D_TEST_SIZE; j++) {
if (help[i][j] > max[0]) {
max[0] = help[i][j];
max[1] = i;
max[2] = j;
}
}
}
// Logger.i(TAG,"Help");
// this.printMatrix(help);
if (max[0] >= MIN_SIZE+2) {
int highcx = position.chunkXPos - TEST_SIZE + max[1];
int highcz = position.chunkZPos - TEST_SIZE + max[2];
int lowcx = highcx - max[0];
int lowcz = highcz - max[0];
Logger.d(TAG, "Found fitting area with size %d at coords %d %d (%d %d) after %s ms", max[0], lowcx, lowcz, highcx, highcz, System.currentTimeMillis() - t);
int sx = MIN_SIZE + rnd.nextInt(Math.min(max[0]-2, MAX_SIZE) - MIN_SIZE + 1);
int sz = MIN_SIZE + rnd.nextInt(Math.min(max[0]-2, MAX_SIZE) - MIN_SIZE + 1);
CastlePositionData.Position p = new CastlePositionData.Position(lowcx + ((max[0] - sx) / 2), lowcz + ((max[0] - sz) / 2));
p.setSize(sx, sz);
return p;
}
Logger.d(TAG, "Failed to optimizing position after %s ms", System.currentTimeMillis() - t);
return null;

Here is a build with the latest changes:
Normal Version: https://drive.google.com/file/d/0B-pjZUDQ-WdEZUhYX0Z4YlU3blk/view?usp=sharing
Deobfuscated Version: https://drive.google.com/file/d/0B-pjZUDQ-WdEQXFpVldFV2xpX1E/view?usp=sharing
By the way: If you use Vampirism in a deobfuscated/dev environment, there are a some debug messages.
The command to search is /vampirism checkForVampireBiome

commented

Ok, I think I just found the root issue, unfortunately I have not noticed this earlier:
RTG replaces the Vampirism biome instance by a own version, so the checks like:
ModBiomes.biomeVampireForest.equals(world.getWorldChunkManager().getBiomeGenAt((position.chunkXPos + i << 4)+8, (position.chunkZPos + j << 4)+8))
or instanceof BiomeVampireForest
do not work.

I will think about a solution tomorrow

commented

Ah yes, I see what's happening.

For the equals() check, maybe comparing against biome IDs would work as RTG doesn't change those:

ModBiomes.biomeVampireForest.biomeID.equals(world.getWorldChunkManager().getBiomeGenAt((position.chunkXPos + i << 4)+8, (position.chunkZPos + j << 4)+8).biomeID)

And for the instanceof check... hmm... not sure what to do about that one. I was going to suggest maybe registering a custom biome type to the Vampire Forest, so instead of checking instanceof, Vampirism could check BiomeDictionary#isBiomeOfType(VAMPIRE_FOREST), but... obviously that might not be suitable in all cases.

commented

Ok most things are working now, but Vampirism still cannot find the biome in advance.
I'm using WorldChunkManager#findBiomePosition for that (here), which needs a biome instance.
One idea might be that Vampirism accepts castle biomes via IMC message. But there might be an easier way, if your world provider overrides that method and either replaces the biomes in the argument list or implements it's own check, it could work.

commented

RTG was already overriding WorldChunkManager#findBiomePosition, but it was hardcoded to always return null for some reason. Probably a legacy stub leftover from before we forked the project.

In any case, it's using the vanilla findBiomePosition() in my dev environment, and I'm now able to use the /vampirism checkForVampireBiome command successfully, returning accurate coords for the closest Vampire Forest.

Does that mean it should also be working on the startup search as well?

I can also confirm that using the latest 1.7.10 dev build of Vampirism and the latest dev build of RTG, everything seems to be working great. :)

commented

Yes it should.

You can try it out with the new build (with id comparison). Try throwing a "blood eye" after generating a new world, if it flies somewhere there is a castle.
Normal
Dev
As long as it is in a deobfuscated environment it also should something like this on world start:

[Server thread/INFO] [vampirism]: [CastleGenerator]Looking for Positions  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Found position 4 -21   
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Found position 5 -21  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Found position 48 -13  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Looking for positions took 25 ms  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Optimizing Position [4, -21][0,0]  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Found fitting area with size 7 at coords 6 -31 (13 -24) after 161 ms  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Optimizing Position [5, -21][0,0]  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Found fitting area with size 7 at coords 6 -31 (13 -24) after 19 ms  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Optimizing Position [48, -13][0,0]  
[14:57:14] [Server thread/INFO] [vampirism]: [CastleGenerator]Found fitting area with size 7 at coords 49 -17 (56 -10) after 103 ms  

The position coords are displayed in chunks.

commented

Yep, the blood eyes now fly in the direction of the nearest castle. :)

Thanks for all your help with this - is it safe to assume that the new ID comparison will be in Vampirism 0.7.8.5?

commented

yes, I will try to release it in the next few days.

As you probably already noticed, the castle does not really (at all) adjust itself to height variation, so maybe you can try to keep the modified biome relatively flat.