From 8f7c37384f300e860443c3e9366ab7e40c2113a4 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Thu, 9 Apr 2015 10:58:27 +1000 Subject: [PATCH] Divided IGenerator into IGeneratorController and IGeneratorDelegate, to clarify generators belonging to another (e.g. GeneratorWeighted has 'sub' generators which it randomly picks from) --- .../biomesoplenty/api/biome/BOPBiome.java | 4 +-- .../api/biome/IExtendedBiome.java | 6 ++-- .../generation/CustomizableGenerator.java | 4 +-- .../CustomizableWeightedGenerator.java | 21 ++----------- .../biome/generation/GenerationManager.java | 26 ++++++++-------- .../biome/generation/GeneratorRegistry.java | 8 ++--- .../{IGenerator.java => IGeneratorBase.java} | 10 +----- .../generation/IGeneratorController.java | 31 +++++++++++++++++++ .../biome/generation/IGeneratorDelegate.java | 24 ++++++++++++++ .../common/biome/ExtendedBiomeRegistry.java | 4 +-- .../biome/overworld/BiomeGenOriginValley.java | 2 +- .../decoration/DecorateBiomeEventHandler.java | 5 +-- .../common/init/ModGenerators.java | 2 +- .../util/config/GeneratorTypeAdaptor.java | 14 ++++----- .../common/util/config/JsonBiome.java | 7 +++-- .../feature/{tree => }/GeneratorWeighted.java | 15 +++------ .../feature/tree/GeneratorBasicTree.java | 15 ++++++++- 17 files changed, 119 insertions(+), 79 deletions(-) rename src/main/java/biomesoplenty/api/biome/generation/{IGenerator.java => IGeneratorBase.java} (71%) create mode 100644 src/main/java/biomesoplenty/api/biome/generation/IGeneratorController.java create mode 100644 src/main/java/biomesoplenty/api/biome/generation/IGeneratorDelegate.java rename src/main/java/biomesoplenty/common/world/feature/{tree => }/GeneratorWeighted.java (85%) diff --git a/src/main/java/biomesoplenty/api/biome/BOPBiome.java b/src/main/java/biomesoplenty/api/biome/BOPBiome.java index b2901027b..2980f56a9 100644 --- a/src/main/java/biomesoplenty/api/biome/BOPBiome.java +++ b/src/main/java/biomesoplenty/api/biome/BOPBiome.java @@ -15,7 +15,7 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeManager.BiomeType; import biomesoplenty.api.biome.generation.GenerationManager; import biomesoplenty.api.biome.generation.GeneratorStage; -import biomesoplenty.api.biome.generation.IGenerator; +import biomesoplenty.api.biome.generation.IGeneratorController; public class BOPBiome extends BiomeGenBase implements IExtendedBiome { @@ -41,7 +41,7 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome } @Override - public void addGenerator(String name, GeneratorStage stage, IGenerator generator) + public void addGenerator(String name, GeneratorStage stage, IGeneratorController generator) { this.generationManager.addGenerator(name, stage, generator); } diff --git a/src/main/java/biomesoplenty/api/biome/IExtendedBiome.java b/src/main/java/biomesoplenty/api/biome/IExtendedBiome.java index 3e1ab0553..34324215b 100644 --- a/src/main/java/biomesoplenty/api/biome/IExtendedBiome.java +++ b/src/main/java/biomesoplenty/api/biome/IExtendedBiome.java @@ -10,15 +10,15 @@ package biomesoplenty.api.biome; import java.util.Map; +import net.minecraftforge.common.BiomeManager.BiomeType; import biomesoplenty.api.biome.generation.GenerationManager; import biomesoplenty.api.biome.generation.GeneratorStage; -import biomesoplenty.api.biome.generation.IGenerator; -import net.minecraftforge.common.BiomeManager.BiomeType; +import biomesoplenty.api.biome.generation.IGeneratorController; public interface IExtendedBiome { public BiomeOwner getBiomeOwner(); - public void addGenerator(String name, GeneratorStage stage, IGenerator generator); + public void addGenerator(String name, GeneratorStage stage, IGeneratorController generator); public GenerationManager getGenerationManager(); public Map getWeightMap(); public void clearWeights(); diff --git a/src/main/java/biomesoplenty/api/biome/generation/CustomizableGenerator.java b/src/main/java/biomesoplenty/api/biome/generation/CustomizableGenerator.java index 243a2a0bf..d70cef14a 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/CustomizableGenerator.java +++ b/src/main/java/biomesoplenty/api/biome/generation/CustomizableGenerator.java @@ -8,7 +8,7 @@ package biomesoplenty.api.biome.generation; -public abstract class CustomizableGenerator implements IGenerator +public abstract class CustomizableGenerator implements IGeneratorController { private final String identifier; private String name; @@ -16,7 +16,7 @@ public abstract class CustomizableGenerator implements IGenerator protected CustomizableGenerator() { - this.identifier = GeneratorRegistry.getIdentifier((Class)this.getClass()); + this.identifier = GeneratorRegistry.getIdentifier((Class)this.getClass()); if (this.identifier == null) { diff --git a/src/main/java/biomesoplenty/api/biome/generation/CustomizableWeightedGenerator.java b/src/main/java/biomesoplenty/api/biome/generation/CustomizableWeightedGenerator.java index d8f2bed3b..11aa58631 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/CustomizableWeightedGenerator.java +++ b/src/main/java/biomesoplenty/api/biome/generation/CustomizableWeightedGenerator.java @@ -14,10 +14,9 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.WeightedRandom; import net.minecraft.world.World; -public abstract class CustomizableWeightedGenerator extends WeightedRandom.Item implements IGenerator +public abstract class CustomizableWeightedGenerator extends WeightedRandom.Item implements IGeneratorDelegate { private final String identifier; - private String name; private GeneratorStage stage; protected CustomizableWeightedGenerator() @@ -29,7 +28,7 @@ public abstract class CustomizableWeightedGenerator extends WeightedRandom.Item { super(weight); - this.identifier = GeneratorRegistry.getIdentifier((Class)this.getClass()); + this.identifier = GeneratorRegistry.getIdentifier((Class)this.getClass()); this.stage = GeneratorStage.PARENT; if (this.identifier == null) @@ -37,16 +36,6 @@ public abstract class CustomizableWeightedGenerator extends WeightedRandom.Item throw new RuntimeException("The identifier for " + this.getClass().getCanonicalName() + " cannot be null!"); } } - - //Scattering should be handled in GeneratorWeighted - @Override - public final void scatter(World world, Random random, BlockPos pos) {} - - @Override - public void setName(String name) - { - this.name = name; - } @Override public void setStage(GeneratorStage stage) @@ -54,12 +43,6 @@ public abstract class CustomizableWeightedGenerator extends WeightedRandom.Item this.stage = stage; } - @Override - public String getName() - { - return this.name; - } - @Override public GeneratorStage getStage() { diff --git a/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java b/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java index c162a9247..4a09bc981 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java +++ b/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java @@ -20,9 +20,9 @@ import com.google.common.collect.Table; public class GenerationManager { - private Table generatorTable = HashBasedTable.create(); + private Table generatorTable = HashBasedTable.create(); - public void addGenerator(String name, GeneratorStage stage, IGenerator generator) + public void addGenerator(String name, GeneratorStage stage, IGeneratorController generator) { if (!this.generatorTable.containsColumn(name)) { @@ -37,19 +37,19 @@ public class GenerationManager } } - public ImmutableCollection getGeneratorsForStage(GeneratorStage stage) + public ImmutableCollection getGeneratorsForStage(GeneratorStage stage) { - Map columnMap = this.generatorTable.rowMap().get(stage); - Collection result = columnMap == null ? null : columnMap.values(); + Map columnMap = this.generatorTable.rowMap().get(stage); + Collection result = columnMap == null ? null : columnMap.values(); - return result == null ? ImmutableList.of() : ImmutableList.copyOf(result); + return result == null ? ImmutableList.of() : ImmutableList.copyOf(result); } - public Map createGeneratorMap() + public Map createGeneratorMap() { - Map result = new HashMap(); + Map result = new HashMap(); - for (IGenerator generator : this.generatorTable.values()) + for (IGeneratorController generator : this.generatorTable.values()) { result.put(generator.getName(), generator); } @@ -57,14 +57,14 @@ public class GenerationManager return result; } - public void createGeneratorTable(Map generators) + public void createGeneratorTable(Map generators) { - Table result = HashBasedTable.create(); + Table result = HashBasedTable.create(); - for (Entry entry : generators.entrySet()) + for (Entry entry : generators.entrySet()) { String name = entry.getKey(); - IGenerator generator = entry.getValue(); + IGeneratorController generator = entry.getValue(); generator.setName(name); result.put(generator.getStage(), generator.getName(), generator); diff --git a/src/main/java/biomesoplenty/api/biome/generation/GeneratorRegistry.java b/src/main/java/biomesoplenty/api/biome/generation/GeneratorRegistry.java index 405dc0aa7..91d27f748 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/GeneratorRegistry.java +++ b/src/main/java/biomesoplenty/api/biome/generation/GeneratorRegistry.java @@ -13,19 +13,19 @@ import com.google.common.collect.HashBiMap; public class GeneratorRegistry { - private static BiMap> generatorClasses = HashBiMap.create(); + private static BiMap> generatorClasses = HashBiMap.create(); - public static void registerGenerator(String identifier, Class generatorClass) + public static void registerGenerator(String identifier, Class generatorClass) { generatorClasses.put(identifier, generatorClass); } - public static String getIdentifier(Class generatorClass) + public static String getIdentifier(Class generatorClass) { return generatorClasses.inverse().get(generatorClass); } - public static Class getGeneratorClass(String identifier) + public static Class getGeneratorClass(String identifier) { return generatorClasses.get(identifier); } diff --git a/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java b/src/main/java/biomesoplenty/api/biome/generation/IGeneratorBase.java similarity index 71% rename from src/main/java/biomesoplenty/api/biome/generation/IGenerator.java rename to src/main/java/biomesoplenty/api/biome/generation/IGeneratorBase.java index 358a5dfd4..210a97275 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java +++ b/src/main/java/biomesoplenty/api/biome/generation/IGeneratorBase.java @@ -17,20 +17,12 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; -public interface IGenerator +public interface IGeneratorBase { - public void scatter(World world, Random random, BlockPos pos); - public boolean generate(World world, Random random, BlockPos pos); - - public void setName(String name); public void setStage(GeneratorStage stage); /**The identifier for this generator should be consistent across all instances of the same type*/ public String getIdentifier(); - /**A unique name use to classify the purpose of a generator. For example, emeralds and ruby use the - * same generator (and thus, have the same identifier) but have differing names. - */ - public String getName(); public GeneratorStage getStage(); public void writeToJson(JsonObject json, JsonSerializationContext context); diff --git a/src/main/java/biomesoplenty/api/biome/generation/IGeneratorController.java b/src/main/java/biomesoplenty/api/biome/generation/IGeneratorController.java new file mode 100644 index 000000000..3257b0d38 --- /dev/null +++ b/src/main/java/biomesoplenty/api/biome/generation/IGeneratorController.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright 2015, 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.api.biome.generation; + +import java.util.Random; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +/** + * Responsible for handling its own associated generation, or referring it + * to delegate generators. + */ +public interface IGeneratorController extends IGeneratorBase +{ + public void scatter(World world, Random random, BlockPos pos); + public boolean generate(World world, Random random, BlockPos pos); + + public void setName(String name); + + /**A unique name use to classify the purpose of a generator. For example, emeralds and ruby use the + * same generator (and thus, have the same identifier) but have differing names. + */ + public String getName(); +} diff --git a/src/main/java/biomesoplenty/api/biome/generation/IGeneratorDelegate.java b/src/main/java/biomesoplenty/api/biome/generation/IGeneratorDelegate.java new file mode 100644 index 000000000..477ae1759 --- /dev/null +++ b/src/main/java/biomesoplenty/api/biome/generation/IGeneratorDelegate.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2015, 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.api.biome.generation; + +import java.util.Random; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +/** + * Handles its own generation when referred to by a + * controller. + */ +public interface IGeneratorDelegate extends IGeneratorBase +{ + public void scatter(World world, Random random, BlockPos pos, int amountPerChunk); + public boolean generate(World world, Random random, BlockPos pos, int amountPerChunk); +} diff --git a/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java b/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java index 3bccfd484..620250aa7 100644 --- a/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java +++ b/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java @@ -17,7 +17,7 @@ import biomesoplenty.api.biome.BiomeOwner; import biomesoplenty.api.biome.IExtendedBiome; import biomesoplenty.api.biome.generation.GenerationManager; import biomesoplenty.api.biome.generation.GeneratorStage; -import biomesoplenty.api.biome.generation.IGenerator; +import biomesoplenty.api.biome.generation.IGeneratorController; public class ExtendedBiomeRegistry { @@ -65,7 +65,7 @@ public class ExtendedBiomeRegistry } @Override - public void addGenerator(String name, GeneratorStage stage, IGenerator generator) + public void addGenerator(String name, GeneratorStage stage, IGeneratorController generator) { this.generationManager.addGenerator(name, stage, generator); } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenOriginValley.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenOriginValley.java index fd145750d..65edb2423 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenOriginValley.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenOriginValley.java @@ -20,8 +20,8 @@ import biomesoplenty.common.block.BlockBOPLeaves; import biomesoplenty.common.block.BlockBOPLeaves2; import biomesoplenty.common.block.BlockBOPGrass.BOPGrassType; import biomesoplenty.common.config.MiscConfigurationHandler; +import biomesoplenty.common.world.feature.GeneratorWeighted; import biomesoplenty.common.world.feature.tree.GeneratorBasicTree; -import biomesoplenty.common.world.feature.tree.GeneratorWeighted; public class BiomeGenOriginValley extends BOPBiome { diff --git a/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java b/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java index 78b28f0df..77aeb8c4c 100644 --- a/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java +++ b/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java @@ -21,7 +21,8 @@ import biomesoplenty.api.biome.BiomeOwner; import biomesoplenty.api.biome.IExtendedBiome; import biomesoplenty.api.biome.generation.GenerationManager; import biomesoplenty.api.biome.generation.GeneratorStage; -import biomesoplenty.api.biome.generation.IGenerator; +import biomesoplenty.api.biome.generation.IGeneratorBase; +import biomesoplenty.api.biome.generation.IGeneratorController; import biomesoplenty.common.biome.ExtendedBiomeRegistry; public class DecorateBiomeEventHandler @@ -58,7 +59,7 @@ public class DecorateBiomeEventHandler { GenerationManager generationManager = extendedBiome.getGenerationManager(); - for (IGenerator generator : generationManager.getGeneratorsForStage(stage)) + for (IGeneratorController generator : generationManager.getGeneratorsForStage(stage)) { generator.scatter(world, random, pos); } diff --git a/src/main/java/biomesoplenty/common/init/ModGenerators.java b/src/main/java/biomesoplenty/common/init/ModGenerators.java index 87416d8ef..fa2fb607f 100644 --- a/src/main/java/biomesoplenty/common/init/ModGenerators.java +++ b/src/main/java/biomesoplenty/common/init/ModGenerators.java @@ -11,8 +11,8 @@ package biomesoplenty.common.init; import static biomesoplenty.api.biome.generation.GeneratorRegistry.registerGenerator; import biomesoplenty.common.world.feature.GeneratorOreCluster; import biomesoplenty.common.world.feature.GeneratorOreSingle; +import biomesoplenty.common.world.feature.GeneratorWeighted; import biomesoplenty.common.world.feature.tree.GeneratorBasicTree; -import biomesoplenty.common.world.feature.tree.GeneratorWeighted; public class ModGenerators { diff --git a/src/main/java/biomesoplenty/common/util/config/GeneratorTypeAdaptor.java b/src/main/java/biomesoplenty/common/util/config/GeneratorTypeAdaptor.java index 4bed47de7..bebb0f8e7 100644 --- a/src/main/java/biomesoplenty/common/util/config/GeneratorTypeAdaptor.java +++ b/src/main/java/biomesoplenty/common/util/config/GeneratorTypeAdaptor.java @@ -12,7 +12,7 @@ import java.lang.reflect.Type; import biomesoplenty.api.biome.generation.GeneratorRegistry; import biomesoplenty.api.biome.generation.GeneratorStage; -import biomesoplenty.api.biome.generation.IGenerator; +import biomesoplenty.api.biome.generation.IGeneratorBase; import com.google.common.reflect.TypeToken; import com.google.gson.JsonDeserializationContext; @@ -24,10 +24,10 @@ import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.google.gson.JsonSyntaxException; -public class GeneratorTypeAdaptor implements JsonSerializer, JsonDeserializer +public class GeneratorTypeAdaptor implements JsonSerializer, JsonDeserializer { @Override - public JsonElement serialize(IGenerator src, Type typeOfSrc, JsonSerializationContext context) + public JsonElement serialize(IGeneratorBase src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObject = new JsonObject(); src.writeToJson(jsonObject, context); @@ -39,14 +39,14 @@ public class GeneratorTypeAdaptor implements JsonSerializer, JsonDes } @Override - public IGenerator deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException + public IGeneratorBase deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); if (jsonObject.has("generator")) { String generatorIdentifier = jsonObject.get("generator").getAsString(); - Class generatorClass = GeneratorRegistry.getGeneratorClass(generatorIdentifier); + Class generatorClass = GeneratorRegistry.getGeneratorClass(generatorIdentifier); if (generatorClass == null) { @@ -54,10 +54,10 @@ public class GeneratorTypeAdaptor implements JsonSerializer, JsonDes } else { - IGenerator generator; + IGeneratorBase generator; try { - generator = (IGenerator)generatorClass.newInstance(); + generator = (IGeneratorBase)generatorClass.newInstance(); Type generatorStageType = new TypeToken() {}.getType(); GeneratorStage generatorStage = (GeneratorStage)context.deserialize(jsonObject.get("stage"), generatorStageType); diff --git a/src/main/java/biomesoplenty/common/util/config/JsonBiome.java b/src/main/java/biomesoplenty/common/util/config/JsonBiome.java index 8463faf79..13bb2c788 100644 --- a/src/main/java/biomesoplenty/common/util/config/JsonBiome.java +++ b/src/main/java/biomesoplenty/common/util/config/JsonBiome.java @@ -19,7 +19,8 @@ import net.minecraftforge.common.BiomeManager.BiomeType; import biomesoplenty.api.biome.BiomeOwner; import biomesoplenty.api.biome.IExtendedBiome; import biomesoplenty.api.biome.generation.GenerationManager; -import biomesoplenty.api.biome.generation.IGenerator; +import biomesoplenty.api.biome.generation.IGeneratorBase; +import biomesoplenty.api.biome.generation.IGeneratorController; import biomesoplenty.common.biome.BOPBiomeManager; import biomesoplenty.common.biome.ExtendedBiomeRegistry; @@ -31,7 +32,7 @@ import com.google.gson.GsonBuilder; public class JsonBiome { - public static final Gson serializer = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).registerTypeHierarchyAdapter(IBlockState.class, new JsonBlockState()).registerTypeHierarchyAdapter(IGenerator.class, new GeneratorTypeAdaptor()).create(); + public static final Gson serializer = new GsonBuilder().setPrettyPrinting().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).registerTypeHierarchyAdapter(IBlockState.class, new JsonBlockState()).registerTypeHierarchyAdapter(IGeneratorBase.class, new GeneratorTypeAdaptor()).create(); public String biomeName; public int biomeId; @@ -45,7 +46,7 @@ public class JsonBiome public int color; public int waterColorMultiplier; public ArrayList entities; - public Map decoration; + public Map decoration; public static JsonBiome createFromBiomeGenBase(BiomeGenBase baseBiome) { diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorWeighted.java b/src/main/java/biomesoplenty/common/world/feature/GeneratorWeighted.java similarity index 85% rename from src/main/java/biomesoplenty/common/world/feature/tree/GeneratorWeighted.java rename to src/main/java/biomesoplenty/common/world/feature/GeneratorWeighted.java index e50b8f5da..afa517512 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorWeighted.java +++ b/src/main/java/biomesoplenty/common/world/feature/GeneratorWeighted.java @@ -6,7 +6,7 @@ * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. ******************************************************************************/ -package biomesoplenty.common.world.feature.tree; +package biomesoplenty.common.world.feature; import java.util.ArrayList; import java.util.List; @@ -43,14 +43,9 @@ public class GeneratorWeighted extends CustomizableGenerator @Override public void scatter(World world, Random random, BlockPos pos) { - for (int i = 0; i < this.amountPerChunk; i++) - { - int x = random.nextInt(16) + 8; - int z = random.nextInt(16) + 8; - BlockPos genPos = world.getHeight(pos.add(x, 0, z)); - - generate(world, random, genPos); - } + CustomizableWeightedGenerator generator = (CustomizableWeightedGenerator)WeightedRandom.getRandomItem(random, this.weightedEntries); + + generator.scatter(world, random, pos, this.amountPerChunk); } @Override @@ -58,7 +53,7 @@ public class GeneratorWeighted extends CustomizableGenerator { CustomizableWeightedGenerator generator = (CustomizableWeightedGenerator)WeightedRandom.getRandomItem(random, this.weightedEntries); - return generator.generate(world, random, pos); + return generator.generate(world, random, pos, this.amountPerChunk); } @Override diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java index ad05133c2..3487c5474 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java @@ -61,7 +61,20 @@ public class GeneratorBasicTree extends CustomizableWeightedGenerator } @Override - public boolean generate(World world, Random random, BlockPos pos) + public void scatter(World world, Random random, BlockPos pos, int amountPerChunk) + { + for (int i = 0; i < amountPerChunk; i++) + { + int x = random.nextInt(16) + 8; + int z = random.nextInt(16) + 8; + BlockPos genPos = world.getHeight(pos.add(x, 0, z)); + + generate(world, random, genPos, amountPerChunk); + } + } + + @Override + public boolean generate(World world, Random random, BlockPos pos, int amountPerChunk) { int height = random.nextInt(this.maxHeight - this.minHeight) + this.minHeight; boolean hasSpace = true;