Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore 0.6.x Biomes o' Plenty sub-biome generation #7

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public BoPSubBiomeReplacer(IntRandomizer randomizer) {
public int replacement(int currentBiomeId, IntRandomizer randomizer, int x, int z) {

List<BiomeEntry> currentSubBiomes = BOPBiomeManager.overworldSubBiomes[currentBiomeId];

if (currentBiomeId == 24) { // maybe make this be toggleable with a setting in future
currentSubBiomes = null; // prevents BoP sub-biomes generating in deep ocean
}

BOPSubBiome selectedSubBiome = currentSubBiomes != null
? (BOPSubBiome) currentSubBiomes.get(randomizer.nextInt(currentSubBiomes.size())).biome
: null;
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/climateControl/customGenLayer/GenLayerSubBiome.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache;

import climateControl.biomeSettings.BiomeReplacer;
import climateControl.biomeSettings.BoPSubBiomeReplacer;
import climateControl.genLayerPack.GenLayerPack;
import climateControl.generator.BiomeSwapper;
import climateControl.generator.SubBiomeChooser;
Expand All @@ -23,6 +25,7 @@ public class GenLayerSubBiome extends GenLayerPack {
private GenLayer rivers;
private final SubBiomeChooser subBiomeChooser;
private final BiomeSwapper mBiomes;
private BiomeReplacer BoPSubBiomeReplacer;

private IntRandomizer randomCallback = new IntRandomizer() {

Expand All @@ -39,6 +42,15 @@ public GenLayerSubBiome(long p_i45479_1_, GenLayer biomes, GenLayer rivers, SubB
this.subBiomeChooser = subBiomeChooser;
this.mBiomes = mBiomes;
this.initChunkSeed(0, 0);
try {
if (doBoP) {
BoPSubBiomeReplacer = new BoPSubBiomeReplacer(randomCallback);
logger.info("Bop set up");
}
} catch (java.lang.NoClassDefFoundError e) {
BoPSubBiomeReplacer = null;
logger.info("no bop ");
}
Comment on lines +45 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this with a cached Loader.isModLoaded check

Copy link
Author

@not-nocturnal not-nocturnal May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you be able to point me to an example of that? I'm not very familiar with java/mc modding.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firstly, create static field and initialize it at pre-init phase:

    private static boolean isBoPLoaded;
    // then at pre-init:
    isBoPLoaded =  = Loader.isModLoaded("BiomesOPlenty");

Secondly, replace this code with:

Suggested change
try {
if (doBoP) {
BoPSubBiomeReplacer = new BoPSubBiomeReplacer(randomCallback);
logger.info("Bop set up");
}
} catch (java.lang.NoClassDefFoundError e) {
BoPSubBiomeReplacer = null;
logger.info("no bop ");
}
if (isBoPLoaded && doBoP) {
BoPSubBiomeReplacer = new BoPSubBiomeReplacer(randomCallback);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @not-nocturnal do you want to finish up this PR so it can be accepted please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, this ended up being too much for me to get my head around and i burned out trying to finish it

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, this ended up being too much for me to get my head around and i burned out trying to finish it

just the check? or what were you stuck on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the check, but it's been a very long time and i feel very out of depth

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OneEyeMaker would you like to pick this up?

}

/**
Expand Down Expand Up @@ -110,6 +122,16 @@ public int[] getInts(int par1, int par2, int par3, int par4) {
}
}
}
// now the GenLayerHills stuff is done so run BoP subbiome replacements if it's on
if (this.BoPSubBiomeReplacer != null) {
this.initChunkSeed((long) (j1 + par1), (long) (i1 + par2));
int old = aint2[j1 + i1 * par3];
aint2[j1 + i1 * par3] = BoPSubBiomeReplacer
.replacement(aint2[j1 + i1 * par3], randomCallback, j1 + par1, i1 + par2);
if (aint2[j1 + i1 * par3] != old) {
// logger.info("BoP subbiome :"+old + " to "+aint2[j1 + i1 * par3]);
}
}
}
}

Expand Down