Optimize performance and memory usage (#1850)

This commit is contained in:
SuperCoder79 2021-05-06 06:49:47 -04:00 committed by GitHub
parent 030559a74a
commit c1615c50ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 58 deletions

View file

@ -28,6 +28,11 @@ public class BiomeFeatureHelper
return (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(state), new DoublePlantBlockPlacer())).tries(64).noProjection().build(); return (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(state), new DoublePlantBlockPlacer())).tries(64).noProjection().build();
} }
public static BlockClusterFeatureConfig createClusterConfigurationDoubleProjects(BlockState state)
{
return (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(state), new DoublePlantBlockPlacer())).tries(64).build();
}
public static BlockClusterFeatureConfig createClusterConfigurationDoubleWater(BlockState state) public static BlockClusterFeatureConfig createClusterConfigurationDoubleWater(BlockState state)
{ {
return (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(state), new DoublePlantBlockPlacer())).canReplace().tries(64).noProjection().build(); return (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(state), new DoublePlantBlockPlacer())).canReplace().tries(64).noProjection().build();

View file

@ -170,9 +170,9 @@ public class BOPConfiguredFeatures
public static final ConfiguredFeature<?, ?> CHERRY_BLOSSOM_GROVE_FLOWERS = register("cherry_blossom_grove_flowers", Feature.FLOWER.configured(BOPFeatures.CHERRY_BLOSSOM_GROVE_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(5))); public static final ConfiguredFeature<?, ?> CHERRY_BLOSSOM_GROVE_FLOWERS = register("cherry_blossom_grove_flowers", Feature.FLOWER.configured(BOPFeatures.CHERRY_BLOSSOM_GROVE_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(5)));
public static final ConfiguredFeature<?, ?> CONIFEROUS_FOREST_FLOWERS = register("coniferous_forest_flowers", Feature.FLOWER.configured(BOPFeatures.CONIFEROUS_FOREST_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(4))); public static final ConfiguredFeature<?, ?> CONIFEROUS_FOREST_FLOWERS = register("coniferous_forest_flowers", Feature.FLOWER.configured(BOPFeatures.CONIFEROUS_FOREST_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(4)));
public static final ConfiguredFeature<?, ?> LUSH_DESERT_FLOWERS = register("lush_desert_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(BOPBlocks.wildflower.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(6))); public static final ConfiguredFeature<?, ?> LUSH_DESERT_FLOWERS = register("lush_desert_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(BOPBlocks.wildflower.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(6)));
public static final ConfiguredFeature<?, ?> FLOWER_MEADOW_FLOWERS = register("flower_meadow_flowers", Feature.FLOWER.configured(BOPFeatures.FLOWER_MEADOW_FLOWER_CONFIG).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE).decorated(FeatureUtil.denseCount(150))); public static final ConfiguredFeature<?, ?> FLOWER_MEADOW_FLOWERS = register("flower_meadow_flowers", Feature.FLOWER.configured(BOPFeatures.FLOWER_MEADOW_FLOWER_CONFIG).decorated(Features.Placements.HEIGHTMAP_SQUARE).count(4));
public static final ConfiguredFeature<?, ?> GROVE_FLOWERS = register("grove_flowers", Feature.FLOWER.configured(BOPFeatures.EXTENDED_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(6))); public static final ConfiguredFeature<?, ?> GROVE_FLOWERS = register("grove_flowers", Feature.FLOWER.configured(BOPFeatures.EXTENDED_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(6)));
public static final ConfiguredFeature<?, ?> LAVENDER_FLOWERS = register("lavender_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(BOPBlocks.lavender.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE).decorated(FeatureUtil.denseCount(500))); public static final ConfiguredFeature<?, ?> LAVENDER_FLOWERS = register("lavender_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(BOPBlocks.lavender.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.HEIGHTMAP_SQUARE).count(15));
public static final ConfiguredFeature<?, ?> MEADOW_FLOWERS = register("meadow_flowers", Feature.FLOWER.configured(BOPFeatures.MEADOW_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(6))); public static final ConfiguredFeature<?, ?> MEADOW_FLOWERS = register("meadow_flowers", Feature.FLOWER.configured(BOPFeatures.MEADOW_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(6)));
public static final ConfiguredFeature<?, ?> MEADOW_FLOWERS_2 = register("meadow_flowers_2", Feature.FLOWER.configured(BOPFeatures.FLOWER_MEADOW_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(3))); public static final ConfiguredFeature<?, ?> MEADOW_FLOWERS_2 = register("meadow_flowers_2", Feature.FLOWER.configured(BOPFeatures.FLOWER_MEADOW_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(3)));
public static final ConfiguredFeature<?, ?> MOOR_FLOWERS = register("moor_flowers", Feature.FLOWER.configured(BOPFeatures.MOOR_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(5))); public static final ConfiguredFeature<?, ?> MOOR_FLOWERS = register("moor_flowers", Feature.FLOWER.configured(BOPFeatures.MOOR_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(5)));
@ -182,7 +182,7 @@ public class BOPConfiguredFeatures
public static final ConfiguredFeature<?, ?> OMINOUS_WOODS_FLOWERS = register("ominous_woods_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.WITHER_ROSE.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(3))); public static final ConfiguredFeature<?, ?> OMINOUS_WOODS_FLOWERS = register("ominous_woods_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.WITHER_ROSE.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(3)));
public static final ConfiguredFeature<?, ?> ORCHARD_FLOWERS = register("orchard_flowers", Feature.FLOWER.configured(BOPFeatures.EXTENDED_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(15))); public static final ConfiguredFeature<?, ?> ORCHARD_FLOWERS = register("orchard_flowers", Feature.FLOWER.configured(BOPFeatures.EXTENDED_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(15)));
public static final ConfiguredFeature<?, ?> ORIGIN_FLOWERS = register("origin_flowers", Feature.FLOWER.configured(BOPFeatures.ORIGIN_VALLEY_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(4))); public static final ConfiguredFeature<?, ?> ORIGIN_FLOWERS = register("origin_flowers", Feature.FLOWER.configured(BOPFeatures.ORIGIN_VALLEY_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(4)));
public static final ConfiguredFeature<?, ?> POPPY_FLOWERS = register("poppy_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.POPPY.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE).decorated(FeatureUtil.denseCount(500))); public static final ConfiguredFeature<?, ?> POPPY_FLOWERS = register("poppy_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.POPPY.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.HEIGHTMAP_SQUARE).count(15));
public static final ConfiguredFeature<?, ?> RAINBOW_HILLS_FLOWERS = register("rainbow_hills_flowers", Feature.FLOWER.configured(BOPFeatures.RAINBOW_HILLS_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(25))); public static final ConfiguredFeature<?, ?> RAINBOW_HILLS_FLOWERS = register("rainbow_hills_flowers", Feature.FLOWER.configured(BOPFeatures.RAINBOW_HILLS_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(25)));
public static final ConfiguredFeature<?, ?> RAINFOREST_FLOWERS = register("rainforest_flowers", Feature.FLOWER.configured(BOPFeatures.RAINFOREST_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(5))); public static final ConfiguredFeature<?, ?> RAINFOREST_FLOWERS = register("rainforest_flowers", Feature.FLOWER.configured(BOPFeatures.RAINFOREST_FLOWER_CONFIG).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(5)));
public static final ConfiguredFeature<?, ?> SHRUBLAND_FLOWERS = register("shrubland_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.ALLIUM.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(3))); public static final ConfiguredFeature<?, ?> SHRUBLAND_FLOWERS = register("shrubland_flowers", Feature.FLOWER.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.ALLIUM.defaultBlockState()), SimpleBlockPlacer.INSTANCE)).tries(64).build()).decorated(Features.Placements.ADD_32).decorated(Features.Placements.HEIGHTMAP_SQUARE.count(3)));
@ -255,7 +255,7 @@ public class BOPConfiguredFeatures
public static final ConfiguredFeature<?, ?> GLOWSHROOM_UNCOMMON = register("glowshroom_uncommon", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(BOPBlocks.glowshroom.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(7))); public static final ConfiguredFeature<?, ?> GLOWSHROOM_UNCOMMON = register("glowshroom_uncommon", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(BOPBlocks.glowshroom.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(7)));
public static final ConfiguredFeature<?, ?> GLOWSHROOM_NORMAL = register("glowshroom_normal", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(BOPBlocks.glowshroom.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(20))); public static final ConfiguredFeature<?, ?> GLOWSHROOM_NORMAL = register("glowshroom_normal", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(BOPBlocks.glowshroom.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(20)));
public static final ConfiguredFeature<?, ?> GLOWSHROOM_EXTRA = register("glowshroom_extra", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(BOPBlocks.glowshroom.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(50))); public static final ConfiguredFeature<?, ?> GLOWSHROOM_EXTRA = register("glowshroom_extra", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfiguration(BOPBlocks.glowshroom.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(50)));
public static final ConfiguredFeature<?, ?> BARLEY = register("barley", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfigurationDouble(BOPBlocks.barley.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE).decorated(FeatureUtil.denseCount(500))); public static final ConfiguredFeature<?, ?> BARLEY = register("barley", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfigurationDoubleProjects(BOPBlocks.barley.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_SQUARE).count(15));
// Water Plants // Water Plants
public static final ConfiguredFeature<?, ?> REED_5 = register("reed_5", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfigurationDoubleWater(BOPBlocks.reed.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(5))); public static final ConfiguredFeature<?, ?> REED_5 = register("reed_5", Feature.RANDOM_PATCH.configured(BiomeFeatureHelper.createClusterConfigurationDoubleWater(BOPBlocks.reed.defaultBlockState())).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(5)));

View file

@ -1,9 +1,9 @@
package biomesoplenty.common.world.gen.feature; package biomesoplenty.common.world.gen.feature;
import biomesoplenty.api.block.BOPBlocks;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ISeedReader; import net.minecraft.world.ISeedReader;
import net.minecraft.world.gen.ChunkGenerator; import net.minecraft.world.gen.ChunkGenerator;
@ -22,22 +22,24 @@ public class CragSplatterFeature extends Feature<NoFeatureConfig>
@Override @Override
public boolean place(ISeedReader worldIn, ChunkGenerator chunkGenerator, Random rand, BlockPos pos, NoFeatureConfig config) public boolean place(ISeedReader worldIn, ChunkGenerator chunkGenerator, Random rand, BlockPos pos, NoFeatureConfig config)
{ {
int i = 0; BlockPos.Mutable mutable = pos.mutable();
int j = rand.nextInt(8 - 2) + 2; int placed = 0;
int radius = rand.nextInt(8 - 2) + 2;
for (int k = pos.getX() - j; k <= pos.getX() + j; ++k) for (int x = pos.getX() - radius; x <= pos.getX() + radius; ++x)
{ {
for (int l = pos.getZ() - j; l <= pos.getZ() + j; ++l) for (int z = pos.getZ() - radius; z <= pos.getZ() + radius; ++z)
{ {
int i1 = k - pos.getX(); int dx = x - pos.getX();
int j1 = l - pos.getZ(); int dz = z - pos.getZ();
if (i1 * i1 + j1 * j1 <= j * j) if (dx * dx + dz * dz <= radius * radius)
{ {
for (int k1 = pos.getY() - 6; k1 <= pos.getY() + 6; ++k1) for (int k1 = pos.getY() - 6; k1 <= pos.getY() + 6; ++k1)
{ {
BlockPos blockpos = new BlockPos(k, k1, l); mutable.set(x, k1, z);
BlockState blockstate = worldIn.getBlockState(blockpos); BlockState blockstate = worldIn.getBlockState(mutable);
BlockState blockstate1 = worldIn.getBlockState(blockpos.above()); BlockState blockstate1 = worldIn.getBlockState(mutable.move(Direction.UP));
mutable.move(Direction.DOWN);
if ((blockstate.getBlock() == Blocks.STONE || blockstate.getBlock() == Blocks.GRAVEL || blockstate.getBlock() == Blocks.ANDESITE || blockstate.getBlock() == Blocks.DIORITE || blockstate.getBlock() == Blocks.GRANITE || blockstate.getBlock() == Blocks.DIRT)) if ((blockstate.getBlock() == Blocks.STONE || blockstate.getBlock() == Blocks.GRAVEL || blockstate.getBlock() == Blocks.ANDESITE || blockstate.getBlock() == Blocks.DIORITE || blockstate.getBlock() == Blocks.GRANITE || blockstate.getBlock() == Blocks.DIRT))
{ {
@ -47,36 +49,35 @@ public class CragSplatterFeature extends Feature<NoFeatureConfig>
case 0: case 0:
case 1: case 1:
case 2: case 2:
worldIn.setBlock(blockpos, Blocks.COBBLESTONE.defaultBlockState(), 2); worldIn.setBlock(mutable, Blocks.COBBLESTONE.defaultBlockState(), 2);
break; break;
case 3: case 3:
case 4: case 4:
case 5: case 5:
worldIn.setBlock(blockpos, Blocks.GRAVEL.defaultBlockState(), 2); worldIn.setBlock(mutable, Blocks.GRAVEL.defaultBlockState(), 2);
break; break;
case 6: case 6:
case 7: case 7:
worldIn.setBlock(blockpos, Blocks.MOSSY_COBBLESTONE.defaultBlockState(), 2); worldIn.setBlock(mutable, Blocks.MOSSY_COBBLESTONE.defaultBlockState(), 2);
break; break;
case 8: case 8:
case 9: case 9:
worldIn.setBlock(blockpos, Blocks.ANDESITE.defaultBlockState(), 2); worldIn.setBlock(mutable, Blocks.ANDESITE.defaultBlockState(), 2);
break; break;
case 10: case 10:
if (blockstate1.isAir(worldIn, blockpos.above())) if (blockstate1.isAir(worldIn, mutable.move(Direction.UP)))
{ {
worldIn.setBlock(blockpos, Blocks.GRASS_BLOCK.defaultBlockState(), 2); worldIn.setBlock(mutable, Blocks.GRASS.defaultBlockState(), 2);
worldIn.setBlock(blockpos.above(), Blocks.GRASS.defaultBlockState(), 2); worldIn.setBlock(mutable.move(Direction.DOWN), Blocks.GRASS_BLOCK.defaultBlockState(), 2);
} }
break; break;
} }
++i; ++placed;
break; break;
} }
} }
@ -84,6 +85,6 @@ public class CragSplatterFeature extends Feature<NoFeatureConfig>
} }
} }
return i > 0; return placed > 0;
} }
} }

View file

@ -79,7 +79,7 @@ public class BigTreeFeature extends TreeFeatureBase
// radius is the radius of the section from the center // radius is the radius of the section from the center
// direction is the direction the cross section is pointed, 0 for x, 1 // direction is the direction the cross section is pointed, 0 for x, 1
// for y, 2 for z material is the index number for the material to use // for y, 2 for z material is the index number for the material to use
private void crossSection(IWorld world, BlockPos pos, float radius, MutableBoundingBox boundingBox, Set<BlockPos> changedBlocks) private void crossSection(IWorld world, BlockPos pos, float radius, Random random, MutableBoundingBox boundingBox, Set<BlockPos> changedBlocks)
{ {
final int r = (int)((double)radius + trunkHeightScale); final int r = (int)((double)radius + trunkHeightScale);
@ -95,7 +95,7 @@ public class BigTreeFeature extends TreeFeatureBase
// Mojang sets leaves via the method used for logs. Probably intentional? // Mojang sets leaves via the method used for logs. Probably intentional?
if (this.altLeaves != Blocks.AIR.defaultBlockState()) if (this.altLeaves != Blocks.AIR.defaultBlockState())
{ {
int rand = new Random().nextInt(4); int rand = random.nextInt(4);
if (rand == 0) if (rand == 0)
{ {
@ -182,11 +182,11 @@ public class BigTreeFeature extends TreeFeatureBase
// Generate a cluster of foliage, with the base at blockPos // Generate a cluster of foliage, with the base at blockPos
// The shape of the cluster is derived from foliageShape // The shape of the cluster is derived from foliageShape
// crossection is called to make each level. // crossection is called to make each level.
private void foliageCluster(IWorld world, BlockPos pos, MutableBoundingBox boundingBox, Set<BlockPos> changedBlocks) private void foliageCluster(IWorld world, BlockPos pos, Random random, MutableBoundingBox boundingBox, Set<BlockPos> changedBlocks)
{ {
for (int y = 0; y < foliageHeight; y++) for (int y = 0; y < foliageHeight; y++)
{ {
this.crossSection(world, pos.above(y), this.foliageShape(y), boundingBox, changedBlocks); this.crossSection(world, pos.above(y), this.foliageShape(y), random, boundingBox, changedBlocks);
} }
} }
@ -268,13 +268,13 @@ public class BigTreeFeature extends TreeFeatureBase
return axis; return axis;
} }
private void makeFoliage(IWorld worldIn, int height, BlockPos pos, List<FoliageCoordinates> coordinates, MutableBoundingBox boundingBox, Set<BlockPos> changedBlocks) private void makeFoliage(IWorld worldIn, int height, BlockPos pos, List<FoliageCoordinates> coordinates, Random random, MutableBoundingBox boundingBox, Set<BlockPos> changedBlocks)
{ {
for (FoliageCoordinates coordinate : coordinates) for (FoliageCoordinates coordinate : coordinates)
{ {
if (this.trimBranches(height, coordinate.getBranchBase() - pos.getY())) if (this.trimBranches(height, coordinate.getBranchBase() - pos.getY()))
{ {
this.foliageCluster(worldIn, coordinate, boundingBox, changedBlocks); this.foliageCluster(worldIn, coordinate, random, boundingBox, changedBlocks);
} }
} }
} }
@ -394,7 +394,7 @@ public class BigTreeFeature extends TreeFeatureBase
} }
} }
this.makeFoliage(world, height, pos, foliageCoords, boundingBox, changedLeaves); this.makeFoliage(world, height, pos, foliageCoords, random, boundingBox, changedLeaves);
this.makeTrunk(changedLogs, world, pos, trunkHeight, boundingBox); this.makeTrunk(changedLogs, world, pos, trunkHeight, boundingBox);
this.makeBranches(changedLogs, world, height, pos, foliageCoords, boundingBox); this.makeBranches(changedLogs, world, height, pos, foliageCoords, boundingBox);
return true; return true;

View file

@ -24,40 +24,46 @@ public enum LargeIslandLayer implements IAreaTransformer2, IDimOffset1Transforme
@Override @Override
public int applyPixel(INoiseRandom context, IArea landSeaArea, IArea climateArea, int x, int z) public int applyPixel(INoiseRandom context, IArea landSeaArea, IArea climateArea, int x, int z)
{ {
int northVal = landSeaArea.get(x + 1, z + 0);
int eastVal = landSeaArea.get(x + 2, z + 1);
int southVal = landSeaArea.get(x + 1, z + 2);
int westVal = landSeaArea.get(x + 0, z + 1);
int centerVal = landSeaArea.get(x + 1, z + 1); int centerVal = landSeaArea.get(x + 1, z + 1);
int climateVal = climateArea.get(x, z);
BOPClimates climate; if (context.nextRandom(50) == 0)
try
{ {
climate = BOPClimates.lookup(climateVal); int northVal = landSeaArea.get(x + 1, z + 0);
} int eastVal = landSeaArea.get(x + 2, z + 1);
catch (ArrayIndexOutOfBoundsException e) int southVal = landSeaArea.get(x + 1, z + 2);
{ int westVal = landSeaArea.get(x + 0, z + 1);
// This shouldn't happen - but apparently it (rarely) does (https://github.com/Glitchfiend/BiomesOPlenty/issues/983) int climateVal = climateArea.get(x, z);
// If it does it means that something weird happened with the climate layer / lookup
// Rethrow with hopefully a more useful message
String msg = "Climate lookup failed climateOrdinal: " + climateVal;
throw new RuntimeException(msg,e);
}
if (centerVal == 0 && northVal == 0 && eastVal == 0 && southVal == 0 && westVal == 0 && context.nextRandom(50) == 0) BOPClimates climate;
{ try
RegistryKey<Biome> islandBiome = climate.getRandomIslandBiome(context, null);
if (islandBiome == null)
{ {
return centerVal; climate = BOPClimates.lookup(climateVal);
} }
else catch (ArrayIndexOutOfBoundsException e)
{ {
return BiomeUtil.getBiomeId(islandBiome); // This shouldn't happen - but apparently it (rarely) does (https://github.com/Glitchfiend/BiomesOPlenty/issues/983)
// If it does it means that something weird happened with the climate layer / lookup
// Rethrow with hopefully a more useful message
String msg = "Climate lookup failed climateOrdinal: " + climateVal;
throw new RuntimeException(msg,e);
} }
if (centerVal == 0 && northVal == 0 && eastVal == 0 && southVal == 0 && westVal == 0)
{
RegistryKey<Biome> islandBiome = climate.getRandomIslandBiome(context, null);
if (islandBiome == null)
{
return centerVal;
}
else
{
return BiomeUtil.getBiomeId(islandBiome);
}
}
else return centerVal;
} else {
return centerVal;
} }
else return centerVal;
} }
} }