Add max mobs option #99

This commit is contained in:
tastybento 2023-03-01 08:26:34 -08:00
parent 4351247de2
commit 66270cf3e7
4 changed files with 66 additions and 3 deletions

View File

@ -32,7 +32,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Hoglin; import org.bukkit.entity.Hoglin;
import org.bukkit.entity.Piglin; import org.bukkit.entity.Piglin;
import org.bukkit.material.CocoaPlant;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.google.common.base.Enums; import com.google.common.base.Enums;
@ -102,6 +101,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
private String permission = ""; private String permission = "";
private final Random random = new Random(); private final Random random = new Random();
private int maxMob;
/** /**
@ -715,5 +715,20 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
return mobTree.values().stream().map(GreenhouseMob::mobType).collect(Collectors.toSet()); return mobTree.values().stream().map(GreenhouseMob::mobType).collect(Collectors.toSet());
} }
/**
* Set the maximum number of mobs in a greenhouse
* @param maxMob maximum
*/
public void setMaxMob(int maxMob) {
this.maxMob = maxMob;
}
/**
* @return the maxMob
*/
public int getMaxMob() {
return maxMob;
}
} }

View File

@ -161,6 +161,9 @@ public class EcoSystemManager {
Collections.shuffle(list, new Random(System.currentTimeMillis())); Collections.shuffle(list, new Random(System.currentTimeMillis()));
Iterator<GrowthBlock> it = list.iterator(); Iterator<GrowthBlock> it = list.iterator();
// Check if the greenhouse is full // Check if the greenhouse is full
if (sum >= gh.getBiomeRecipe().getMaxMob()) {
return;
}
while (it.hasNext() && (sum == 0 || gh.getArea() / sum >= gh.getBiomeRecipe().getMobLimit())) { while (it.hasNext() && (sum == 0 || gh.getArea() / sum >= gh.getBiomeRecipe().getMobLimit())) {
// Spawn something if chance says so // Spawn something if chance says so
if (gh.getBiomeRecipe().spawnMob(it.next().block())) { if (gh.getBiomeRecipe().spawnMob(it.next().block())) {

View File

@ -155,6 +155,7 @@ public class RecipeManager {
b.setLavacoverage(biomeRecipeConfig.getInt("lavacoverage",-1)); b.setLavacoverage(biomeRecipeConfig.getInt("lavacoverage",-1));
b.setIcecoverage(biomeRecipeConfig.getInt("icecoverage",-1)); b.setIcecoverage(biomeRecipeConfig.getInt("icecoverage",-1));
b.setMobLimit(biomeRecipeConfig.getInt("moblimit", 9)); b.setMobLimit(biomeRecipeConfig.getInt("moblimit", 9));
b.setMaxMob(biomeRecipeConfig.getInt("maxmob", -1));
return b; return b;
} }

View File

@ -38,8 +38,12 @@ biomes:
# The minimum number of blocks each mob requires. # The minimum number of blocks each mob requires.
# Mobs will not spawn if there is more than 1 per this number of # Mobs will not spawn if there is more than 1 per this number of
# blocks in the greenhouse. e.g., in this case only 2 mobs will spawn if the # blocks in the greenhouse. e.g., in this case only 2 mobs will spawn if the
# greenhouse area is 18 blocks # greenhouse area is 18 blocks. This enables bigger greenhouses to spawn more.
moblimit: 9 moblimit: 9
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 5
Snowy_beach: Snowy_beach:
friendlyname: "Snowy beach" friendlyname: "Snowy beach"
biome: SNOWY_BEACH biome: SNOWY_BEACH
@ -65,6 +69,10 @@ biomes:
mobs: mobs:
WOLF: 10:SNOW WOLF: 10:SNOW
moblimit: 9 moblimit: 9
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 5
Cold_Rabbit: Cold_Rabbit:
friendlyname: "Cold Taiga Forest" friendlyname: "Cold Taiga Forest"
biome: OLD_GROWTH_SPRUCE_TAIGA biome: OLD_GROWTH_SPRUCE_TAIGA
@ -80,6 +88,10 @@ biomes:
mobs: mobs:
RABBIT: 10:SNOW RABBIT: 10:SNOW
moblimit: 9 moblimit: 9
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 20
DESERT: DESERT:
friendlyname: "Desert" friendlyname: "Desert"
biome: DESERT biome: DESERT
@ -134,6 +146,10 @@ biomes:
STRIDER: 10:LAVA STRIDER: 10:LAVA
ENDERMAN: 5:NETHERRACK ENDERMAN: 5:NETHERRACK
moblimit: 9 moblimit: 9
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 50
permission: greenhouses.biome.nether permission: greenhouses.biome.nether
SOUL_SAND_VALLEY: SOUL_SAND_VALLEY:
friendlyname: "&cSoul Sand Valley" friendlyname: "&cSoul Sand Valley"
@ -149,6 +165,10 @@ biomes:
mobs: mobs:
SKELETON: 10:SOUL_SAND SKELETON: 10:SOUL_SAND
moblimit: 9 moblimit: 9
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 50
permission: greenhouses.biome.nether permission: greenhouses.biome.nether
# Conversion list - 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:
@ -173,6 +193,10 @@ biomes:
PIGLIN: 10:CRIMSON_NYLIUM PIGLIN: 10:CRIMSON_NYLIUM
HOGLIN: 10:CRIMSON_NYLIUM HOGLIN: 10:CRIMSON_NYLIUM
moblimit: 9 moblimit: 9
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 50
permission: greenhouses.biome.nether permission: greenhouses.biome.nether
WARPED_FOREST: WARPED_FOREST:
friendlyname: "&cWarped Forest" friendlyname: "&cWarped Forest"
@ -190,6 +214,10 @@ biomes:
STRIDER: 10:LAVA STRIDER: 10:LAVA
ENDERMAN: 20:WARPED_NYLIUM ENDERMAN: 20:WARPED_NYLIUM
moblimit: 9 moblimit: 9
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 50
permission: greenhouses.biome.nether permission: greenhouses.biome.nether
JUNGLE: JUNGLE:
biome: JUNGLE biome: JUNGLE
@ -221,6 +249,10 @@ biomes:
mobs: mobs:
MUSHROOM_COW: 10:MYCELIUM MUSHROOM_COW: 10:MYCELIUM
moblimit: 9 moblimit: 9
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 20
OCEAN: OCEAN:
biome: OCEAN biome: OCEAN
icon: WATER_BUCKET icon: WATER_BUCKET
@ -242,6 +274,10 @@ biomes:
mobs: mobs:
HORSE: 10:GRASS_BLOCK HORSE: 10:GRASS_BLOCK
moblimit: 1 moblimit: 1
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 10
RIVER: RIVER:
friendlyname: "Clay river" friendlyname: "Clay river"
biome: RIVER biome: RIVER
@ -286,6 +322,10 @@ biomes:
mobs: mobs:
SLIME: 5:WATER SLIME: 5:WATER
moblimit: 3 moblimit: 3
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 10
dripstone_caves: dripstone_caves:
friendlyname: "&6Drippy Drops" friendlyname: "&6Drippy Drops"
biome: dripstone_caves biome: dripstone_caves
@ -304,4 +344,8 @@ biomes:
mobs: mobs:
skeleton: 5:STONE skeleton: 5:STONE
glow_squid: 5:WATER glow_squid: 5:WATER
moblimit: 5 moblimit: 5
# Maxmobs - this is the maximum number of greenhouse-spawed mobs allowed in
# the greenhouse at once. Spawning will stop when this limit is reached.
# If this value is not given, there is no maximum.
maxmobs: 25