Changes the way conversions work to use a list.

Multiple conversions to the same material is now possible.
Backward compatible to old biomes.yml files.

Fixes https://github.com/BentoBoxWorld/Greenhouses/issues/53
This commit is contained in:
tastybento 2020-08-16 10:18:18 -07:00
parent 661ab668df
commit ef65a66bdb
2 changed files with 26 additions and 10 deletions

View File

@ -126,11 +126,11 @@ public class RecipeManager {
String name = biomeRecipeConfig.getString("biome").toUpperCase();
if (Enums.getIfPresent(Biome.class, name).isPresent()) {
return Biome.valueOf(name);
}
}
// Special case for nether
if (name.equals("NETHER") || name.equals("NETHER_WASTES")) {
return Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.PLAINS));
}
}
addon.logError("Biome " + name + " is invalid! Use one of these...");
addon.logError(Arrays.stream(Biome.values()).map(Biome::name).collect(Collectors.joining(",")));
return null;
@ -190,6 +190,21 @@ public class RecipeManager {
}
}
// Get the list of conversions
for (String oldMat : biomeRecipeConfig.getStringList("conversion-list")) {
try {
// Split the string
String[] split = oldMat.split(":");
Material oldMaterial = Material.valueOf(split[0].toUpperCase());
int convChance = Integer.parseInt(split[1]);
Material newMaterial = Material.valueOf(split[2]);
Material localMaterial = Material.valueOf(split[3]);
b.addConvBlocks(oldMaterial, newMaterial, convChance, localMaterial);
} catch (Exception e) {
addon.logError("Could not parse " + oldMat);
}
}
}
private void loadMobs(ConfigurationSection biomeRecipeConfig, BiomeRecipe b) {

View File

@ -94,12 +94,13 @@ biomes:
plants:
DEAD_BUSH: 10:SAND
CACTUS: 10:SAND
# Conversions
# Conversion list
# Format is:
# Original Block: % chance:New Block:Adjacent Block
# Original Block:% chance:New Block:Adjacent Block
# So, for below, dirt has a 30% chance of changing into SAND if it is next to SAND!
conversions:
DIRT: 30:SAND:SAND
# Multiple conversions can be listed
conversion-list:
- DIRT:30:SAND:SAND
FOREST:
friendlyname: "Flowery forest"
biome: FLOWER_FOREST
@ -188,12 +189,12 @@ biomes:
SAND: 1
# 50% water required
watercoverage: 50
# Conversions - in this case, an adjacent block is required to convert
# Conversion list - in this case, an adjacent block is required to convert
# Format is:
# Original Block: % chance:New Block:Adjacent Block
# Original Block:% chance:New Block:Adjacent Block
# So, for below, dirt has a 50% chance of changing into clay if it is next to water!
conversions:
DIRT: 50:CLAY:WATER
conversion-list:
- DIRT:50:CLAY:WATER
SAVANNA:
biome: SAVANNA
icon: ACACIA_LEAVES