diff --git a/src/main/java/com/volmit/iris/object/IrisBiomeCustom.java b/src/main/java/com/volmit/iris/object/IrisBiomeCustom.java index e7f5186ef..8f72b2fa3 100644 --- a/src/main/java/com/volmit/iris/object/IrisBiomeCustom.java +++ b/src/main/java/com/volmit/iris/object/IrisBiomeCustom.java @@ -26,6 +26,7 @@ import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.awt.*; +import java.util.Locale; @Accessors(chain = true) @NoArgsConstructor @@ -33,7 +34,6 @@ import java.awt.*; @Desc("A custom biome, generated through a datapack") @Data public class IrisBiomeCustom { - @Required @Desc("The resource key of this biome. Just a simple id such as 'plains' or something.") private String id = ""; @@ -48,35 +48,38 @@ public class IrisBiomeCustom { @Desc("The biome's downfall amount (snow / rain), see preci") private double humidity = 0.4; + @DependsOn("spawnRarity") + @ArrayType(min = 1, type = IrisBiomeCustomSpawn.class) + @Desc("The biome's mob spawns") + private KList spawns = new KList<>(); @Desc("The biome's downfall type") private IrisBiomeCustomPrecipType downfallType = IrisBiomeCustomPrecipType.rain; + @Desc("Define an ambient particle to be rendered clientside (no server cost!)") + private IrisBiomeCustomParticle ambientParticle = null; @Desc("The biome's category type") private IrisBiomeCustomCategory category = IrisBiomeCustomCategory.plains; + @Desc("The spawn rarity of any defined spawners") + private int spawnRarity = -1; @Desc("The color of the sky, top half of sky. (hex format)") private String skyColor = "#79a8e1"; - @Desc("The color of the fog, bottom half of sky. (hex format)") private String fogColor = "#c0d8e1"; - @Desc("The color of the water (hex format). Leave blank / don't define to not change") private String waterColor = "#3f76e4"; - @Desc("The color of water fog (hex format). Leave blank / don't define to not change") private String waterFogColor = "#050533"; - @Desc("The color of the grass (hex format). Leave blank / don't define to not change") private String grassColor = ""; - @Desc("The color of foliage (hex format). Leave blank / don't define to not change") private String foliageColor = ""; @@ -87,6 +90,16 @@ public class IrisBiomeCustom { effects.put("water_color", parseColor(getWaterColor())); effects.put("water_fog_color", parseColor(getWaterFogColor())); + if(ambientParticle != null) + { + JSONObject particle = new JSONObject(); + JSONObject po = new JSONObject(); + po.put("type", ambientParticle.getParticle().name().toLowerCase()); + particle.put("options", po); + particle.put("probability", ambientParticle.getRarity()); + effects.put("particle", particle); + } + if (!getGrassColor().isEmpty()) { effects.put("grass_color", parseColor(getGrassColor())); } @@ -101,6 +114,7 @@ public class IrisBiomeCustom { j.put("scale", 0.05); j.put("temperature", getTemperature()); j.put("downfall", getHumidity()); + j.put("creature_spawn_probability", getSpawnRarity()); j.put("precipitation", getDownfallType().toString().toLowerCase()); j.put("category", getCategory().toString().toLowerCase()); j.put("effects", effects); @@ -110,6 +124,35 @@ public class IrisBiomeCustom { j.put("carvers", new JSONObject()); j.put("features", new JSONArray()); + if(spawnRarity > 0) + { + j.put("creature_spawn_probability", spawnRarity); + } + + if(getSpawns() != null && getSpawns().isNotEmpty()) + { + JSONObject spawners = new JSONObject(); + KMap groups = new KMap<>(); + + for(IrisBiomeCustomSpawn i : getSpawns()) + { + JSONArray g = groups.compute(i.getGroup(), (k, v) -> v != null ? v : new JSONArray()); + JSONObject o = new JSONObject(); + o.put("type", "minecraft:" + i.getType().name().toLowerCase()); + o.put("weight", i.getWeight()); + o.put("minCount", i.getMinCount()); + o.put("maxCount", i.getMaxCount()); + g.put(o); + } + + for(IrisBiomeCustomSpawnType i : groups.k()) + { + spawners.put(i.name().toLowerCase(Locale.ROOT), groups.get(i)); + } + + j.put("spawners", spawners); + } + return j.toString(4); } diff --git a/src/main/java/com/volmit/iris/object/IrisBiomeCustomParticle.java b/src/main/java/com/volmit/iris/object/IrisBiomeCustomParticle.java new file mode 100644 index 000000000..1e5ad9f48 --- /dev/null +++ b/src/main/java/com/volmit/iris/object/IrisBiomeCustomParticle.java @@ -0,0 +1,45 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.object; + +import com.volmit.iris.Iris; +import com.volmit.iris.util.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.bukkit.Particle; + +import java.awt.*; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("A custom biome ambient particle") +@Data +public class IrisBiomeCustomParticle { + @Required + @Desc("The biome's particle type") + private Particle particle = Particle.FLASH; + + @MinNumber(1) + @MaxNumber(10000) + @Desc("The rarity") + private int rarity = 35; +} diff --git a/src/main/java/com/volmit/iris/object/IrisBiomeCustomSpawn.java b/src/main/java/com/volmit/iris/object/IrisBiomeCustomSpawn.java new file mode 100644 index 000000000..4d68ec4b8 --- /dev/null +++ b/src/main/java/com/volmit/iris/object/IrisBiomeCustomSpawn.java @@ -0,0 +1,58 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.object; + +import com.volmit.iris.util.Desc; +import com.volmit.iris.util.MaxNumber; +import com.volmit.iris.util.MinNumber; +import com.volmit.iris.util.Required; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.bukkit.entity.EntityType; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("A custom biome spawn") +@Data +public class IrisBiomeCustomSpawn { + @Required + @Desc("The biome's particle type") + private EntityType type = EntityType.COW; + + @MinNumber(1) + @MaxNumber(20) + @Desc("The min to spawn") + private int minCount = 2; + + @MinNumber(1) + @MaxNumber(20) + @Desc("The max to spawn") + private int maxCount = 5; + + @MinNumber(1) + @MaxNumber(1000) + @Desc("The weight in this group. Higher weight, the more common this type is spawned") + private int weight = 1; + + @Desc("The rarity") + private IrisBiomeCustomSpawnType group = IrisBiomeCustomSpawnType.MISC; +} diff --git a/src/main/java/com/volmit/iris/object/IrisBiomeCustomSpawnType.java b/src/main/java/com/volmit/iris/object/IrisBiomeCustomSpawnType.java new file mode 100644 index 000000000..2d5586644 --- /dev/null +++ b/src/main/java/com/volmit/iris/object/IrisBiomeCustomSpawnType.java @@ -0,0 +1,32 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.object; + +import com.volmit.iris.util.Desc; + +@Desc("The mob spawn group") +public enum IrisBiomeCustomSpawnType { + MONSTER, + CREATURE, + AMBIENT, + UNDERGROUND_WATER_CREATURE, + WATER_CREATURE, + WATER_AMBIENT, + MISC +}