diff --git a/src/main/java/biomesoplenty/api/biome/BOPBiome.java b/src/main/java/biomesoplenty/api/biome/BOPBiome.java index 2980f56a9..b2901027b 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.IGeneratorController; +import biomesoplenty.api.biome.generation.IGenerator; 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, IGeneratorController generator) + public void addGenerator(String name, GeneratorStage stage, IGenerator 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 34324215b..a01225300 100644 --- a/src/main/java/biomesoplenty/api/biome/IExtendedBiome.java +++ b/src/main/java/biomesoplenty/api/biome/IExtendedBiome.java @@ -13,12 +13,12 @@ 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.IGeneratorController; +import biomesoplenty.api.biome.generation.IGenerator; public interface IExtendedBiome { public BiomeOwner getBiomeOwner(); - public void addGenerator(String name, GeneratorStage stage, IGeneratorController generator); + public void addGenerator(String name, GeneratorStage stage, IGenerator 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 d70cef14a..243a2a0bf 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 IGeneratorController +public abstract class CustomizableGenerator implements IGenerator { private final String identifier; private String name; @@ -16,7 +16,7 @@ public abstract class CustomizableGenerator implements IGeneratorController 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/GenerationManager.java b/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java index 4a09bc981..c162a9247 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, IGeneratorController generator) + public void addGenerator(String name, GeneratorStage stage, IGenerator 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 (IGeneratorController generator : this.generatorTable.values()) + for (IGenerator 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(); - IGeneratorController generator = entry.getValue(); + IGenerator 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 91d27f748..405dc0aa7 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/GeneratorWeighted.java b/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeighted.java index 771599fe2..1649fad1b 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeighted.java +++ b/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeighted.java @@ -27,7 +27,7 @@ public class GeneratorWeighted extends CustomizableGenerator public GeneratorWeighted() {} - public void add(int weight, IGeneratorController entry) + public void add(int weight, IGenerator entry) { this.weightedEntries.add(new GeneratorWeightedEntry(weight, entry)); } diff --git a/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeightedEntry.java b/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeightedEntry.java index db76fba78..5b2571b3f 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeightedEntry.java +++ b/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeightedEntry.java @@ -19,22 +19,22 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; -public final class GeneratorWeightedEntry extends WeightedRandom.Item implements IGeneratorController +public final class GeneratorWeightedEntry extends WeightedRandom.Item implements IGenerator { private final String identifier; private GeneratorStage stage; - private IGeneratorController wrappedGenerator; + private IGenerator wrappedGenerator; public GeneratorWeightedEntry() { this(-1, null); } - public GeneratorWeightedEntry(int weight, IGeneratorController wrappedGenerator) + public GeneratorWeightedEntry(int weight, IGenerator wrappedGenerator) { super(weight); - this.identifier = GeneratorRegistry.getIdentifier((Class)this.getClass()); + this.identifier = GeneratorRegistry.getIdentifier((Class)this.getClass()); this.stage = GeneratorStage.PARENT; this.wrappedGenerator = wrappedGenerator; diff --git a/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java b/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java index 210a97275..46a7d96d9 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java +++ b/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java @@ -17,10 +17,18 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; -public interface IGeneratorBase +public interface IGenerator { - public void setStage(GeneratorStage stage); + public void scatter(World world, Random random, BlockPos pos); + public boolean generate(World world, Random random, BlockPos pos); + public void setStage(GeneratorStage stage); + 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(); /**The identifier for this generator should be consistent across all instances of the same type*/ public String getIdentifier(); public GeneratorStage getStage(); diff --git a/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java b/src/main/java/biomesoplenty/common/biome/ExtendedBiomeRegistry.java index 620250aa7..3bccfd484 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.IGeneratorController; +import biomesoplenty.api.biome.generation.IGenerator; public class ExtendedBiomeRegistry { @@ -65,7 +65,7 @@ public class ExtendedBiomeRegistry } @Override - public void addGenerator(String name, GeneratorStage stage, IGeneratorController generator) + public void addGenerator(String name, GeneratorStage stage, IGenerator generator) { this.generationManager.addGenerator(name, stage, generator); } diff --git a/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java b/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java index 77aeb8c4c..5854de550 100644 --- a/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java +++ b/src/main/java/biomesoplenty/common/handler/decoration/DecorateBiomeEventHandler.java @@ -21,8 +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.IGeneratorBase; -import biomesoplenty.api.biome.generation.IGeneratorController; +import biomesoplenty.api.biome.generation.IGenerator; +import biomesoplenty.api.biome.generation.IGenerator; import biomesoplenty.common.biome.ExtendedBiomeRegistry; public class DecorateBiomeEventHandler @@ -59,7 +59,7 @@ public class DecorateBiomeEventHandler { GenerationManager generationManager = extendedBiome.getGenerationManager(); - for (IGeneratorController generator : generationManager.getGeneratorsForStage(stage)) + for (IGenerator generator : generationManager.getGeneratorsForStage(stage)) { generator.scatter(world, random, pos); } diff --git a/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java b/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java index 64ca4a6fc..5310fb27e 100644 --- a/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java +++ b/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java @@ -12,8 +12,8 @@ import java.util.Random; import org.apache.commons.lang3.tuple.Pair; -import biomesoplenty.api.biome.generation.IGeneratorBase; -import biomesoplenty.api.biome.generation.IGeneratorController; +import biomesoplenty.api.biome.generation.IGenerator; +import biomesoplenty.api.biome.generation.IGenerator; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; @@ -73,12 +73,12 @@ public class GeneratorUtils return state; } - public static IGeneratorController deserializeGenerator(JsonObject json, String memberName, JsonDeserializationContext context) + public static IGenerator deserializeGenerator(JsonObject json, String memberName, JsonDeserializationContext context) { - return deserializeGeneratorOfType(json, memberName, context, IGeneratorController.class); + return deserializeGeneratorOfType(json, memberName, context, IGenerator.class); } - public static T deserializeGeneratorOfType(JsonObject json, String memberName, JsonDeserializationContext context, Class type) + public static T deserializeGeneratorOfType(JsonObject json, String memberName, JsonDeserializationContext context, Class type) { T generator = context.deserialize(json.get(memberName), type); diff --git a/src/main/java/biomesoplenty/common/util/config/GeneratorTypeAdaptor.java b/src/main/java/biomesoplenty/common/util/config/GeneratorTypeAdaptor.java index bebb0f8e7..4bed47de7 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.IGeneratorBase; +import biomesoplenty.api.biome.generation.IGenerator; 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(IGeneratorBase src, Type typeOfSrc, JsonSerializationContext context) + public JsonElement serialize(IGenerator src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObject = new JsonObject(); src.writeToJson(jsonObject, context); @@ -39,14 +39,14 @@ public class GeneratorTypeAdaptor implements JsonSerializer, Jso } @Override - public IGeneratorBase deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException + public IGenerator 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, Jso } else { - IGeneratorBase generator; + IGenerator generator; try { - generator = (IGeneratorBase)generatorClass.newInstance(); + generator = (IGenerator)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 13bb2c788..41b4fbe94 100644 --- a/src/main/java/biomesoplenty/common/util/config/JsonBiome.java +++ b/src/main/java/biomesoplenty/common/util/config/JsonBiome.java @@ -19,8 +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.IGeneratorBase; -import biomesoplenty.api.biome.generation.IGeneratorController; +import biomesoplenty.api.biome.generation.IGenerator; +import biomesoplenty.api.biome.generation.IGenerator; import biomesoplenty.common.biome.BOPBiomeManager; import biomesoplenty.common.biome.ExtendedBiomeRegistry; @@ -32,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(IGeneratorBase.class, new GeneratorTypeAdaptor()).create(); + 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 String biomeName; public int biomeId; @@ -46,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) {