Adds dimension blacklist for hive generation.

This commit is contained in:
phillipasmith1995 committed 2018-01-08 09:18:49 -06:00
1 parent 42865951a9
commit 7b8b317ffe
2 files changed
+13

No files matched your search

@@ -22,8 +22,13 @@ public class HiveConfig {
private final Set<BiomeDictionary.Type> blacklistedTypes = new HashSet<>();
private final Set<Biome> blacklistedBiomes = new HashSet<>();
private static final Set<Integer> blacklistedDims = new HashSet<>();
public static void parse(LocalizedConfiguration config){
config.addCategoryCommentLocalized(CATEGORY);
for(int dimId : config.get("world.generate.beehives", "dimBlacklist", new int[0]).getIntList()){
blacklistedDims.add(dimId);
}
for(IHiveRegistry.HiveType type : IHiveRegistry.HiveType.values()){
String[] entries = config.get(CATEGORY, type.getName(), new String[0]).getStringList();
configs.put(type, new HiveConfig(entries));
@@ -56,4 +61,8 @@ public class HiveConfig {
}
return BiomeDictionary.getTypes(biome).stream().anyMatch(blacklistedTypes::contains);
}
public static boolean isDimBlacklisted(int dimId){
return blacklistedDims.contains(dimId);
}
}
@@ -19,6 +19,7 @@ import forestry.api.apiculture.IHiveDrop;
import forestry.api.apiculture.hives.IHiveDescription;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.apiculture.HiveConfig;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -66,6 +67,9 @@ public final class Hive {
}
public boolean isValidLocation(World world, BlockPos pos) {
if(HiveConfig.isDimBlacklisted(world.provider.getDimension())) {
return false;
}
return hiveDescription.getHiveGen().isValidLocation(world, pos);
}