Custom biome particles & spawns

This commit is contained in:
Daniel Mills 2021-07-16 00:09:25 -04:00
parent fff6e50702
commit 2624315bd5
4 changed files with 184 additions and 6 deletions

View File

@ -26,6 +26,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.awt.*; import java.awt.*;
import java.util.Locale;
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
@ -33,7 +34,6 @@ import java.awt.*;
@Desc("A custom biome, generated through a datapack") @Desc("A custom biome, generated through a datapack")
@Data @Data
public class IrisBiomeCustom { public class IrisBiomeCustom {
@Required @Required
@Desc("The resource key of this biome. Just a simple id such as 'plains' or something.") @Desc("The resource key of this biome. Just a simple id such as 'plains' or something.")
private String id = ""; private String id = "";
@ -48,35 +48,38 @@ public class IrisBiomeCustom {
@Desc("The biome's downfall amount (snow / rain), see preci") @Desc("The biome's downfall amount (snow / rain), see preci")
private double humidity = 0.4; private double humidity = 0.4;
@DependsOn("spawnRarity")
@ArrayType(min = 1, type = IrisBiomeCustomSpawn.class)
@Desc("The biome's mob spawns")
private KList<IrisBiomeCustomSpawn> spawns = new KList<>();
@Desc("The biome's downfall type") @Desc("The biome's downfall type")
private IrisBiomeCustomPrecipType downfallType = IrisBiomeCustomPrecipType.rain; 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") @Desc("The biome's category type")
private IrisBiomeCustomCategory category = IrisBiomeCustomCategory.plains; 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)") @Desc("The color of the sky, top half of sky. (hex format)")
private String skyColor = "#79a8e1"; private String skyColor = "#79a8e1";
@Desc("The color of the fog, bottom half of sky. (hex format)") @Desc("The color of the fog, bottom half of sky. (hex format)")
private String fogColor = "#c0d8e1"; private String fogColor = "#c0d8e1";
@Desc("The color of the water (hex format). Leave blank / don't define to not change") @Desc("The color of the water (hex format). Leave blank / don't define to not change")
private String waterColor = "#3f76e4"; private String waterColor = "#3f76e4";
@Desc("The color of water fog (hex format). Leave blank / don't define to not change") @Desc("The color of water fog (hex format). Leave blank / don't define to not change")
private String waterFogColor = "#050533"; private String waterFogColor = "#050533";
@Desc("The color of the grass (hex format). Leave blank / don't define to not change") @Desc("The color of the grass (hex format). Leave blank / don't define to not change")
private String grassColor = ""; private String grassColor = "";
@Desc("The color of foliage (hex format). Leave blank / don't define to not change") @Desc("The color of foliage (hex format). Leave blank / don't define to not change")
private String foliageColor = ""; private String foliageColor = "";
@ -87,6 +90,16 @@ public class IrisBiomeCustom {
effects.put("water_color", parseColor(getWaterColor())); effects.put("water_color", parseColor(getWaterColor()));
effects.put("water_fog_color", parseColor(getWaterFogColor())); 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()) { if (!getGrassColor().isEmpty()) {
effects.put("grass_color", parseColor(getGrassColor())); effects.put("grass_color", parseColor(getGrassColor()));
} }
@ -101,6 +114,7 @@ public class IrisBiomeCustom {
j.put("scale", 0.05); j.put("scale", 0.05);
j.put("temperature", getTemperature()); j.put("temperature", getTemperature());
j.put("downfall", getHumidity()); j.put("downfall", getHumidity());
j.put("creature_spawn_probability", getSpawnRarity());
j.put("precipitation", getDownfallType().toString().toLowerCase()); j.put("precipitation", getDownfallType().toString().toLowerCase());
j.put("category", getCategory().toString().toLowerCase()); j.put("category", getCategory().toString().toLowerCase());
j.put("effects", effects); j.put("effects", effects);
@ -110,6 +124,35 @@ public class IrisBiomeCustom {
j.put("carvers", new JSONObject()); j.put("carvers", new JSONObject());
j.put("features", new JSONArray()); j.put("features", new JSONArray());
if(spawnRarity > 0)
{
j.put("creature_spawn_probability", spawnRarity);
}
if(getSpawns() != null && getSpawns().isNotEmpty())
{
JSONObject spawners = new JSONObject();
KMap<IrisBiomeCustomSpawnType, JSONArray> 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); return j.toString(4);
} }

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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
}