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:
parent
661ab668df
commit
ef65a66bdb
|
@ -126,11 +126,11 @@ public class RecipeManager {
|
||||||
String name = biomeRecipeConfig.getString("biome").toUpperCase();
|
String name = biomeRecipeConfig.getString("biome").toUpperCase();
|
||||||
if (Enums.getIfPresent(Biome.class, name).isPresent()) {
|
if (Enums.getIfPresent(Biome.class, name).isPresent()) {
|
||||||
return Biome.valueOf(name);
|
return Biome.valueOf(name);
|
||||||
}
|
}
|
||||||
// Special case for nether
|
// Special case for nether
|
||||||
if (name.equals("NETHER") || name.equals("NETHER_WASTES")) {
|
if (name.equals("NETHER") || name.equals("NETHER_WASTES")) {
|
||||||
return Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.PLAINS));
|
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("Biome " + name + " is invalid! Use one of these...");
|
||||||
addon.logError(Arrays.stream(Biome.values()).map(Biome::name).collect(Collectors.joining(",")));
|
addon.logError(Arrays.stream(Biome.values()).map(Biome::name).collect(Collectors.joining(",")));
|
||||||
return null;
|
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) {
|
private void loadMobs(ConfigurationSection biomeRecipeConfig, BiomeRecipe b) {
|
||||||
|
|
|
@ -94,12 +94,13 @@ biomes:
|
||||||
plants:
|
plants:
|
||||||
DEAD_BUSH: 10:SAND
|
DEAD_BUSH: 10:SAND
|
||||||
CACTUS: 10:SAND
|
CACTUS: 10:SAND
|
||||||
# Conversions
|
# Conversion list
|
||||||
# Format is:
|
# 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!
|
# So, for below, dirt has a 30% chance of changing into SAND if it is next to SAND!
|
||||||
conversions:
|
# Multiple conversions can be listed
|
||||||
DIRT: 30:SAND:SAND
|
conversion-list:
|
||||||
|
- DIRT:30:SAND:SAND
|
||||||
FOREST:
|
FOREST:
|
||||||
friendlyname: "Flowery forest"
|
friendlyname: "Flowery forest"
|
||||||
biome: FLOWER_FOREST
|
biome: FLOWER_FOREST
|
||||||
|
@ -188,12 +189,12 @@ biomes:
|
||||||
SAND: 1
|
SAND: 1
|
||||||
# 50% water required
|
# 50% water required
|
||||||
watercoverage: 50
|
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:
|
# 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!
|
# So, for below, dirt has a 50% chance of changing into clay if it is next to water!
|
||||||
conversions:
|
conversion-list:
|
||||||
DIRT: 50:CLAY:WATER
|
- DIRT:50:CLAY:WATER
|
||||||
SAVANNA:
|
SAVANNA:
|
||||||
biome: SAVANNA
|
biome: SAVANNA
|
||||||
icon: ACACIA_LEAVES
|
icon: ACACIA_LEAVES
|
||||||
|
|
Loading…
Reference in New Issue