Fix huge mushroom generation in BOP biomes. Note that this is still broken in Vanilla biomes due to a Forge bug. The Forge bug is present with or without BOP installed.

This commit is contained in:
Adubbz 2020-01-01 17:15:49 +11:00
parent 01eabf4aab
commit f9d4959bc8
8 changed files with 250 additions and 8 deletions

View File

@ -8,7 +8,6 @@ import biomesoplenty.common.world.gen.feature.BOPBiomeFeatures;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.fluid.Fluids;
import net.minecraft.world.biome.DefaultBiomeFeatures;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.carver.WorldCarver;
@ -39,8 +38,8 @@ public class FungiForestBiome extends NetherBiomeBOP
this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, Feature.GLOWSTONE_BLOB.configured(IFeatureConfig.NONE).decorated(Placement.COUNT_RANGE.configured(new CountRangeConfig(10, 0, 0, 128))));
//Vegetation
this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, Feature.HUGE_RED_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(250))));
this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, Feature.HUGE_BROWN_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_BROWN_MUSHROOM_CONFIG).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(75))));
this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, BOPBiomeFeatures.BIG_RED_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(250))));
this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, BOPBiomeFeatures.BIG_BROWN_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_BROWN_MUSHROOM_CONFIG).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(75))));
this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(BOPBlocks.toadstool.defaultBlockState())).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(7))));
this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, BOPBiomeFeatures.NETHERWART_BUBBLE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(3))));
this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, BOPBiomeFeatures.SCATTERED_NETHER_WART.configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(4))));

View File

@ -50,7 +50,7 @@ public class LushSwampBiome extends BiomeBOP
// Vegetation
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPBiomeFeatures.TALL_SWAMP_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).decorated(Placement.COUNT_EXTRA_HEIGHTMAP.configured(new AtSurfaceWithExtraConfig(3, 0.1F, 1))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.HUGE_RED_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG).decorated(Placement.COUNT_EXTRA_HEIGHTMAP.configured(new AtSurfaceWithExtraConfig((int)0.5F, 0.1F, 1))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPBiomeFeatures.BIG_RED_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG).decorated(Placement.COUNT_EXTRA_HEIGHTMAP.configured(new AtSurfaceWithExtraConfig((int)0.5F, 0.1F, 1))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPBiomeFeatures.LUSH_SWAMP_FLOWERS.configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_32.configured(new FrequencyConfig(5))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, new StandardGrassFeature(NoFeatureConfig::deserialize).configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(8))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfigurationDouble(BOPBlocks.tall_cattail.defaultBlockState())).decorated(Placement.COUNT_HEIGHTMAP_32.configured(new FrequencyConfig(4))));

View File

@ -60,7 +60,7 @@ public class MireBiome extends BiomeBOP
// Vegetation
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_SELECTOR.configured(new MultipleRandomFeatureConfig(ImmutableList.of(BOPBiomeFeatures.DARK_OAK_TWIGLET_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).weighted(0.8F), BOPBiomeFeatures.TALL_TWIGLET_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).weighted(0.4F), BOPBiomeFeatures.DEAD_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).weighted(0.1F)), BOPBiomeFeatures.DYING_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG))).decorated(Placement.COUNT_EXTRA_HEIGHTMAP.configured(new AtSurfaceWithExtraConfig(2, 0.2F, 1))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.HUGE_BROWN_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_BROWN_MUSHROOM_CONFIG).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(17))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPBiomeFeatures.BIG_BROWN_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_BROWN_MUSHROOM_CONFIG).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(17))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, new StandardGrassFeature(NoFeatureConfig::deserialize).configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(4))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(Blocks.BROWN_MUSHROOM.defaultBlockState())).decorated(Placement.CHANCE_HEIGHTMAP_DOUBLE.configured(new ChanceConfig(15))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(Blocks.RED_MUSHROOM.defaultBlockState())).decorated(Placement.CHANCE_HEIGHTMAP_DOUBLE.configured(new ChanceConfig(8))));

View File

@ -60,7 +60,7 @@ public class MysticGroveBiome extends BiomeBOP
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_SELECTOR.configured(new MultipleRandomFeatureConfig(ImmutableList.of(BOPBiomeFeatures.GIANT_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).weighted(0.025F), BOPBiomeFeatures.TALL_SWAMP_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).weighted(0.1F), BOPBiomeFeatures.BIG_FLOWERING_OAK_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).weighted(0.2F), BOPBiomeFeatures.JACARANDA_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).weighted(0.3F), BOPBiomeFeatures.BIG_MAGIC_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG).weighted(0.3F)), BOPBiomeFeatures.MAGIC_TREE.configured(DefaultBiomeFeatures.NORMAL_TREE_CONFIG))).decorated(Placement.COUNT_EXTRA_HEIGHTMAP.configured(new AtSurfaceWithExtraConfig(10, 0.5F, 1))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPBiomeFeatures.MYSTIC_GROVE_FLOWERS.configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_32.configured(new FrequencyConfig(18))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.HUGE_RED_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG).decorated(Placement.COUNT_EXTRA_HEIGHTMAP.configured(new AtSurfaceWithExtraConfig(1, 0.1F, 1))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPBiomeFeatures.BIG_RED_MUSHROOM.configured(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG).decorated(Placement.COUNT_EXTRA_HEIGHTMAP.configured(new AtSurfaceWithExtraConfig(1, 0.1F, 1))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfigurationDouble(BOPBlocks.blue_hydrangea.defaultBlockState())).decorated(Placement.COUNT_HEIGHTMAP_32.configured(new FrequencyConfig(4))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfigurationDouble(Blocks.LILAC.defaultBlockState())).decorated(Placement.COUNT_HEIGHTMAP_32.configured(new FrequencyConfig(1))));
this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, new StandardGrassFeature(NoFeatureConfig::deserialize).configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(15))));

View File

@ -0,0 +1,118 @@
/*******************************************************************************
* Copyright 2014-2019, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import biomesoplenty.core.BiomesOPlenty;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.HugeMushroomBlock;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.feature.BigBrownMushroomFeature;
import net.minecraft.world.gen.feature.BigMushroomFeatureConfig;
import java.util.Random;
import java.util.function.Function;
public class BOPBigBrownMushroomFeature extends BigBrownMushroomFeature
{
public BOPBigBrownMushroomFeature(Function<Dynamic<?>, ? extends BigMushroomFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
protected void placeTrunk(IWorld world, Random random, BlockPos pos, BigMushroomFeatureConfig config, int height, BlockPos.Mutable mutablePos)
{
for (int i = 0; i < height; ++i)
{
mutablePos.set(pos).move(Direction.UP, i);
// Fix Forge's inversion bug
if (world.getBlockState(mutablePos).canBeReplacedByLeaves(world, mutablePos))
{
this.setBlock(world, mutablePos, config.stemProvider.getState(random, pos));
}
}
}
@Override
protected void makeCap(IWorld world, Random random, BlockPos pos, int height, BlockPos.Mutable mutablePos, BigMushroomFeatureConfig config)
{
int radius = config.foliageRadius;
for (int x = -radius; x <= radius; ++x)
{
for (int z = -radius; z <= radius; ++z)
{
boolean westEdge = x == -radius;
boolean eastEdge = x == radius;
boolean northEdge = z == -radius;
boolean southEdge = z == radius;
boolean eastOrWestEdge = westEdge || eastEdge;
boolean northOrSouthEdge = northEdge || southEdge;
if (!eastOrWestEdge || !northOrSouthEdge)
{
mutablePos.set(pos).move(x, height, z);
// Fix Forge's inversion bug
if (world.getBlockState(mutablePos).canBeReplacedByLeaves(world, mutablePos))
{
boolean westFace = westEdge || northOrSouthEdge && x == 1 - radius;
boolean eastFace = eastEdge || northOrSouthEdge && x == radius - 1;
boolean northFace = northEdge || eastOrWestEdge && z == 1 - radius;
boolean southFace = southEdge || eastOrWestEdge && z == radius - 1;
this.setBlock(world, mutablePos, config.capProvider.getState(random, pos).setValue(HugeMushroomBlock.WEST, Boolean.valueOf(westFace)).setValue(HugeMushroomBlock.EAST, Boolean.valueOf(eastFace)).setValue(HugeMushroomBlock.NORTH, Boolean.valueOf(northFace)).setValue(HugeMushroomBlock.SOUTH, Boolean.valueOf(southFace)));
}
}
}
}
}
@Override
protected boolean isValidPosition(IWorld world, BlockPos pos, int height, BlockPos.Mutable mutablePos, BigMushroomFeatureConfig config)
{
int i = pos.getY();
if (i >= 1 && i + height + 1 < world.getMaxHeight())
{
Block groundBlock = world.getBlockState(pos.below()).getBlock();
// Allow growth in the nether
if (!isDirt(groundBlock) && groundBlock != Blocks.NETHERRACK && groundBlock != Blocks.SOUL_SAND)
{
return false;
}
else
{
for (int y = 0; y <= height; ++y)
{
int radius = this.getTreeRadiusForHeight(-1, -1, config.foliageRadius, y);
for (int x = -radius; x <= radius; ++x)
{
for (int z = -radius; z <= radius; ++z)
{
BlockState obstructingState = world.getBlockState(mutablePos.set(pos).move(x, y, z));
if (!obstructingState.isAir(world, mutablePos) && !obstructingState.is(BlockTags.LEAVES))
{
return false;
}
}
}
}
return true;
}
}
else
{
return false;
}
}
}

View File

@ -0,0 +1,118 @@
/*******************************************************************************
* Copyright 2014-2019, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import biomesoplenty.core.BiomesOPlenty;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.HugeMushroomBlock;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.feature.BigMushroomFeatureConfig;
import net.minecraft.world.gen.feature.BigRedMushroomFeature;
import java.util.Random;
import java.util.function.Function;
public class BOPBigRedMushroomFeature extends BigRedMushroomFeature
{
public BOPBigRedMushroomFeature(Function<Dynamic<?>, ? extends BigMushroomFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
protected void placeTrunk(IWorld world, Random random, BlockPos pos, BigMushroomFeatureConfig config, int height, BlockPos.Mutable mutablePos)
{
for (int i = 0; i < height; ++i)
{
mutablePos.set(pos).move(Direction.UP, i);
// Fix Forge's inversion bug
if (world.getBlockState(mutablePos).canBeReplacedByLeaves(world, mutablePos))
{
this.setBlock(world, mutablePos, config.stemProvider.getState(random, pos));
}
}
}
@Override
protected void makeCap(IWorld world, Random random, BlockPos pos, int height, BlockPos.Mutable mutablePos, BigMushroomFeatureConfig config)
{
for (int y = height - 3; y <= height; ++y)
{
int radius = y < height ? config.foliageRadius : config.foliageRadius - 1;
int innerRadius = config.foliageRadius - 2;
for (int x = -radius; x <= radius; ++x)
{
for (int z = -radius; z <= radius; ++z)
{
boolean westEdge = x == -radius;
boolean eastEdge = x == radius;
boolean northEdge = z == -radius;
boolean southEdge = z == radius;
boolean eastOrWestEdge = westEdge || eastEdge;
boolean northOrSouthEdge = northEdge || southEdge;
if (y >= height || eastOrWestEdge != northOrSouthEdge)
{
mutablePos.set(pos).move(x, y, z);
// Fix Forge's inversion bug
if (world.getBlockState(mutablePos).canBeReplacedByLeaves(world, mutablePos))
{
this.setBlock(world, mutablePos, config.capProvider.getState(random, pos).setValue(HugeMushroomBlock.UP, Boolean.valueOf(y >= height - 1)).setValue(HugeMushroomBlock.WEST, Boolean.valueOf(x < -innerRadius)).setValue(HugeMushroomBlock.EAST, Boolean.valueOf(x > innerRadius)).setValue(HugeMushroomBlock.NORTH, Boolean.valueOf(z < -innerRadius)).setValue(HugeMushroomBlock.SOUTH, Boolean.valueOf(z > innerRadius)));
}
}
}
}
}
}
@Override
protected boolean isValidPosition(IWorld world, BlockPos pos, int height, BlockPos.Mutable mutablePos, BigMushroomFeatureConfig config)
{
int i = pos.getY();
if (i >= 1 && i + height + 1 < world.getMaxHeight())
{
Block groundBlock = world.getBlockState(pos.below()).getBlock();
// Allow growth in the Nether
if (!isDirt(groundBlock) && groundBlock != Blocks.NETHERRACK && groundBlock != Blocks.SOUL_SAND)
{
return false;
}
else
{
for (int y = 0; y <= height; ++y)
{
int radius = this.getTreeRadiusForHeight(-1, -1, config.foliageRadius, y);
for (int x = -radius; x <= radius; ++x)
{
for (int z = -radius; z <= radius; ++z)
{
BlockState obstructingState = world.getBlockState(mutablePos.set(pos).move(x, y, z));
if (!obstructingState.isAir(world, mutablePos) && !obstructingState.is(BlockTags.LEAVES))
{
return false;
}
}
}
}
return true;
}
}
else
{
return false;
}
}
}

View File

@ -14,8 +14,6 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.SaplingBlock;
import net.minecraft.util.Direction;
import net.minecraft.world.gen.blockplacer.DoublePlantBlockPlacer;
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig;
@ -125,6 +123,8 @@ public class BOPBiomeFeatures
public static final Feature<NoFeatureConfig> NETHER_VINES = new NetherVinesFeature(NoFeatureConfig::deserialize);
public static final Feature<NoFeatureConfig> FLESH_SPLATTER = new FleshSplatterFeature(NoFeatureConfig::deserialize);
public static final Feature<NoFeatureConfig> BONE_SPINE = new BoneSpineFeature(NoFeatureConfig::deserialize);
public static final Feature<BigMushroomFeatureConfig> BIG_BROWN_MUSHROOM = new BOPBigBrownMushroomFeature(BigMushroomFeatureConfig::deserialize);
public static final Feature<BigMushroomFeatureConfig> BIG_RED_MUSHROOM = new BOPBigRedMushroomFeature(BigMushroomFeatureConfig::deserialize);
public static final Feature<BaseTreeFeatureConfig> NETHERWART_BUBBLE = new BushTreeFeature.Builder().placeOn((world, pos) -> world.getBlockState(pos).getBlock() == Blocks.NETHERRACK).log(Blocks.NETHER_WART_BLOCK.defaultBlockState()).leaves(Blocks.NETHER_WART_BLOCK.defaultBlockState()).maxHeight(2).create();
public static final Feature<NoFeatureConfig> ASH_SPLATTER = new AshSplatterFeature(NoFeatureConfig::deserialize);
public static final Feature<NoFeatureConfig> SCATTERED_NETHER_WART = new NetherWartFeature(NoFeatureConfig::deserialize);

View File

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"minecraft:grass_block",
"minecraft:mycelium"
]
}