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

fix flowering oak not spawning in mutated forest (flower forest) #104

Open
wants to merge 2 commits into
base: 1.12.2
Choose a base branch
from
Open
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 @@ -54,6 +54,7 @@ protected void setDefaultGrowingParameters() {
this.envFactor(BiomeDictionary.Type.COLD, 0.75F);
this.envFactor(BiomeDictionary.Type.HOT, 0.75F);
this.envFactor(BiomeDictionary.Type.DRY, 0.25F);
this.envFactor(BiomeDictionary.Type.FOREST, 1.05f);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,43 @@ public class SpeciesFloweringOak extends Species {
public SpeciesFloweringOak(ResourceLocation name, TreeFamily treeFamily, ILeavesProperties leavesProperties) {
super(name, treeFamily, leavesProperties);
setDefaultGrowingParameters();
setupStandardSeedDropping();
generateSeed();

setRequiresTileEntity(true);
}

treeFamily.addConnectableVanillaLeaves((state) -> state.getBlock() instanceof BlockBOPLeaves && state.getValue(((BlockBOPLeaves) state.getBlock()).variantProperty) == BOPTrees.FLOWERING);
public SpeciesFloweringOak(TreeFamily treeFamily) {
this(new ResourceLocation(DynamicTreesBOP.MODID, ModContent.FLOWERINGOAK), treeFamily, ModContent.floweringOakLeavesProperties[0]);
setDefaultGrowingParameters();
setupStandardSeedDropping();
generateSeed();

if (!ModConfigs.enablePeachTrees)
addDropCreator(new DropCreatorFruit(BOPItems.peach));
}

protected void setDefaultGrowingParameters (){
setBasicGrowingParameters(0.3f, 12.0f, upProbability, lowestBranchHeight, 0.85f);

setupStandardSeedDropping();


envFactor(Type.COLD, 0.75f);
envFactor(Type.HOT, 0.50f);
envFactor(Type.DRY, 0.50f);
envFactor(Type.FOREST, 1.05f);
}

public SpeciesFloweringOak(TreeFamily treeFamily) {
this(new ResourceLocation(DynamicTreesBOP.MODID, ModContent.FLOWERINGOAK), treeFamily, ModContent.floweringOakLeavesProperties[0]);

setRequiresTileEntity(true);


addValidLeavesBlocks(ModContent.floweringOakLeavesProperties);
ModContent.floweringOakLeavesProperties[0].setTree(treeFamily);
ModContent.floweringOakLeavesProperties[1].setTree(treeFamily);

generateSeed();

if (!ModConfigs.enablePeachTrees)
addDropCreator(new DropCreatorFruit(BOPItems.peach));

treeFamily.addConnectableVanillaLeaves((state) -> state.getBlock() instanceof BlockBOPLeaves && state.getValue(((BlockBOPLeaves) state.getBlock()).variantProperty) == BOPTrees.FLOWERING);

}

@Override
Expand All @@ -73,12 +82,12 @@ public int colorTreeQuads(int defaultColor, ModelEntityFallingTree.TreeQuadData
public boolean isBiomePerfect(Biome biome) {
return BiomeDictionary.hasType(biome, Type.FOREST);
}

@Override
public int maxBranchRadius() {
return 8;
}

@Override
public boolean rot(World world, BlockPos pos, int neighborCount, int radius, Random random, boolean rapid) {
if(super.rot(world, pos, neighborCount, radius, random, rapid)) {
Expand All @@ -88,10 +97,10 @@ public boolean rot(World world, BlockPos pos, int neighborCount, int radius, Ran
}
return true;
}

return false;
}

@Override
public int saplingColorMultiplier(IBlockState state, IBlockAccess access, BlockPos pos, int tintIndex) {
return tintIndex != 0 ? 0xffffff : getLeavesProperties().foliageColorMultiplier(state, access, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void populate(BiomeDataBase dbase) {
//Remove generators from extended biomes(No JSON support for extended biomes)
removeTreeGen(BOPBiomes.forest_extension);
removeTreeGen(BOPBiomes.forest_hills_extension);
removeTreeGen(BOPBiomes.flower_forest_extension);
removeTreeGen(BOPBiomes.extreme_hills_extension);
removeTreeGen(BOPBiomes.extreme_hills_plus_extension);
removeTreeGen(BOPBiomes.swampland_extension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
import net.minecraft.world.biome.Biome;

public class OldBiomeDataBasePopulator implements IBiomeDataBasePopulator {

private static final IChanceSelector ok = (rnd, spc, rad) -> EnumChance.OK;
private static final IChanceSelector cancel = (rnd, spc, rad) -> EnumChance.CANCEL;

private static Species swamp, apple, jungle, spruce, birch, oak, acacia, acaciaBrush, oakFloweringVine, oakConifer, megaOakConifer, darkOakConifer, darkOakDyingConifer, oakTwiglet, oakSparse, poplar, darkPoplar, jungleTwiglet, acaciaTwiglet, yellowAutumn, orangeAutumn, magic, floweringOak, umbran, umbranConifer, umbranConiferMega, oakDying, decayed, fir, firSmall, pinkCherry, whiteCherry, maple, dead, jacaranda, redwood, willow, pine, palm, ebony, ebonyTwiglet, mahogany, eucalyptus, bamboo, hellbark;
private static Species acaciaBush, oakBush;
private static Species cactus;
private static Species mushroomRed, mushroomBrown;

private static void createStaticAliases() {
apple = findVanSpecies("apple");
jungle = findVanSpecies("jungle");
Expand Down Expand Up @@ -78,7 +78,7 @@ private static void createStaticAliases() {
eucalyptus = findBopSpecies("eucalyptus");
bamboo = findBopSpecies("bamboo");
hellbark = findBopSpecies("hellbark");
floweringOak = findBopSpecies("floweringoak");
floweringOak = findBopSpecies("flowering_oak");
decayed = findBopSpecies("decayed");
palm = findBopSpecies("palm");
cactus = findVanSpecies("cactus");
Expand All @@ -87,13 +87,13 @@ private static void createStaticAliases() {
mushroomRed = findVanSpecies("mushroomred");
mushroomBrown = findVanSpecies("mushroombrn");
}

public void populate(BiomeDataBase dbase) {

if(oak == null) {
createStaticAliases();
}

//Species Selectors
addSpeciesSelector(dbase, BOPBiomes.alps_foothills, new StaticSpeciesSelector(firSmall));
addSpeciesSelector(dbase, BOPBiomes.bamboo_forest, new RandomSpeciesSelector().add(bamboo, 4));
Expand Down Expand Up @@ -141,11 +141,13 @@ public void populate(BiomeDataBase dbase) {
addSpeciesSelector(dbase, Biomes.BEACH, new StaticSpeciesSelector(palm));
addSpeciesSelector(dbase, Biomes.FOREST, new RandomSpeciesSelector().add(oak, 8).add(birch, 2).add(floweringOak, 1));
addSpeciesSelector(dbase, Biomes.FOREST_HILLS, new RandomSpeciesSelector().add(oak, 8).add(birch, 2).add(floweringOak, 1));
addSpeciesSelector(dbase, Biomes.MUTATED_FOREST, new RandomSpeciesSelector().add(oak, 4).add(birch, 2).add(floweringOak, 5));
addSpeciesSelector(dbase, Biomes.MUTATED_BIRCH_FOREST_HILLS, new RandomSpeciesSelector().add(oak, 4).add(birch, 2).add(floweringOak, 5));
addSpeciesSelector(dbase, Biomes.EXTREME_HILLS, new StaticSpeciesSelector(spruce));
addSpeciesSelector(dbase, Biomes.EXTREME_HILLS_WITH_TREES, new StaticSpeciesSelector(spruce));
addSpeciesSelector(dbase, Biomes.SWAMPLAND, new RandomSpeciesSelector().add(swamp, 5).add(willow, 1));


//Density Selectors
addDensitySelector(dbase, BOPBiomes.alps_foothills, scale(0.05) );
addDensitySelector(dbase, BOPBiomes.bamboo_forest, scale(0.25, 0.75) );
Expand Down Expand Up @@ -189,8 +191,8 @@ public void populate(BiomeDataBase dbase) {
addDensitySelector(dbase, BOPBiomes.wetland, scale() );
addDensitySelector(dbase, BOPBiomes.woodland, scale() );
addDensitySelector(dbase, BOPBiomes.xeric_shrubland, scale(0.4) );


//Chance Selectors
addChanceSelector(dbase, BOPBiomes.alps_foothills, rand(0.5f));
addChanceSelector(dbase, BOPBiomes.bamboo_forest, ok);
Expand Down Expand Up @@ -241,7 +243,7 @@ public void populate(BiomeDataBase dbase) {
blackList.addAll(BOPBiomes.shrubland.asSet());
blackList.addAll(BOPBiomes.tundra.asSet());
blackList.addAll(BOPBiomes.mangrove.asSet());

Biome.REGISTRY.forEach(biome -> {
if (biome.getRegistryName().getResourceDomain().equals("biomesoplenty") && !blackList.contains(biome) ) {
if (biome != null && biome instanceof BOPBiome) {
Expand All @@ -253,30 +255,30 @@ public void populate(BiomeDataBase dbase) {
}
}
dbase.setCancelVanillaTreeGen(biome, true);

//Identify the "forestness" of the biome. Affects forest spread rate for biome.
//dbase.setForestness(biome, identifyForestness(biome));
}
});

if (BOPBiomes.tundra.isPresent()) dbase.setCancelVanillaTreeGen(BOPBiomes.tundra.get(), true);
if (BOPBiomes.shrubland.isPresent()) dbase.setCancelVanillaTreeGen(BOPBiomes.shrubland.get(), true);
if (BOPBiomes.mangrove.isPresent()) dbase.setCancelVanillaTreeGen(BOPBiomes.mangrove.get(), true);

//Remove generators from extended biomes
removeTreeGen(BOPBiomes.forest_extension);
removeTreeGen(BOPBiomes.forest_hills_extension);
removeTreeGen(BOPBiomes.extreme_hills_extension);
removeTreeGen(BOPBiomes.extreme_hills_plus_extension);
removeTreeGen(BOPBiomes.swampland_extension);

dbase.setIsSubterranean(BOPBiomes.undergarden.orNull(), true);
}

private void removeTreeGen(IExtendedBiome extendedBiome) {
extendedBiome.getGenerationManager().removeGenerator("trees");
extendedBiome.getGenerationManager().removeGenerator("trees");
}

////////////////////////////////////////////////////////////////
// Helper Members
////////////////////////////////////////////////////////////////
Expand All @@ -288,27 +290,27 @@ private static Species findBopSpecies(String name) {
private static Species findVanSpecies(String name) {
return TreeRegistry.findSpecies(new ResourceLocation(ModConstants.MODID, name));
}

private void addSpeciesSelector(BiomeDataBase dbase, Optional<Biome> biome, ISpeciesSelector selector) {
if(biome.isPresent()) {
addSpeciesSelector(dbase, biome.get(), selector);
}
}

private void addSpeciesSelector(BiomeDataBase dbase, Biome biome, ISpeciesSelector selector) {
dbase.setSpeciesSelector(biome, selector, Operation.REPLACE);
}

private void addChanceSelector(BiomeDataBase dbase, Optional<Biome> biome, IChanceSelector selector) {
if(biome.isPresent()) {
dbase.setChanceSelector(biome.get(), selector, Operation.REPLACE);
}
}

private IChanceSelector rand(float threshhold) {
return (rnd, spc, rad) -> rnd.nextFloat() < threshhold ? EnumChance.OK : EnumChance.CANCEL;
}

private void addDensitySelector(BiomeDataBase dbase, Optional<Biome> biome, IDensitySelector selector) {
if(biome.isPresent()) {
dbase.setDensitySelector(biome.get(), selector, Operation.REPLACE);
Expand All @@ -318,17 +320,17 @@ private void addDensitySelector(BiomeDataBase dbase, Optional<Biome> biome, IDen
private IDensitySelector scale() {
return (rnd, nd) -> nd;
}

private IDensitySelector scale(double factor1) {
return (rnd, nd) -> nd * factor1;
}

private IDensitySelector scale(double factor1, double addend) {
return (rnd, nd) -> (nd * factor1) + addend;
}

private IDensitySelector scale(double factor1, double addend, double factor2) {
return (rnd, nd) -> ((nd * factor1) + addend) * factor2;
}

}