mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
Initial Bukkit Biome Config
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
||||
|
||||
|
||||
public class BiomeAdditionsSoundTemplate implements ObjectTemplate<AmbientAdditionsSettings> {
|
||||
@Value("sound")
|
||||
@Default
|
||||
private SoundEvent sound = null;
|
||||
|
||||
@Value("sound-chance")
|
||||
@Default
|
||||
private Double soundChance = null;
|
||||
|
||||
@Override
|
||||
public AmbientAdditionsSettings get() {
|
||||
if(sound == null || soundChance == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new AmbientAdditionsSettings(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(sound), soundChance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
||||
|
||||
|
||||
public class BiomeMoodSoundTemplate implements ObjectTemplate<AmbientMoodSettings> {
|
||||
@Value("sound")
|
||||
@Default
|
||||
private SoundEvent sound = null;
|
||||
|
||||
@Value("cultivation-ticks")
|
||||
@Default
|
||||
private Integer soundCultivationTicks = null;
|
||||
|
||||
@Value("spawn-range")
|
||||
@Default
|
||||
private Integer soundSpawnRange = null;
|
||||
|
||||
@Value("extra-distance")
|
||||
@Default
|
||||
private Double soundExtraDistance = null;
|
||||
|
||||
@Override
|
||||
public AmbientMoodSettings get() {
|
||||
if(sound == null || soundCultivationTicks == null || soundSpawnRange == null || soundExtraDistance == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new AmbientMoodSettings(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(sound), soundCultivationTicks, soundSpawnRange, soundExtraDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.commands.arguments.ParticleArgument;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
||||
|
||||
|
||||
public class BiomeParticleConfigTemplate implements ObjectTemplate<AmbientParticleSettings> {
|
||||
@Value("particle")
|
||||
@Default
|
||||
private String particle = null;
|
||||
|
||||
@Value("probability")
|
||||
@Default
|
||||
private Integer probability = null;
|
||||
|
||||
@Override
|
||||
public AmbientParticleSettings get() {
|
||||
if(particle == null || probability == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return new AmbientParticleSettings(ParticleArgument.readParticle(new StringReader(particle), BuiltInRegistries.PARTICLE_TYPE.asLookup()), probability);
|
||||
} catch(CommandSyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
|
||||
public class EntityTypeTemplate implements ObjectTemplate<EntityType<?>> {
|
||||
@Value("id")
|
||||
@Default
|
||||
private ResourceLocation id = null;
|
||||
|
||||
@Override
|
||||
public EntityType<?> get() {
|
||||
return BuiltInRegistries.ENTITY_TYPE.get(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
|
||||
|
||||
public class MusicSoundTemplate implements ObjectTemplate<Music> {
|
||||
@Value("sound")
|
||||
@Default
|
||||
private SoundEvent sound = null;
|
||||
|
||||
@Value("min-delay")
|
||||
@Default
|
||||
private Integer minDelay = null;
|
||||
|
||||
@Value("max-delay")
|
||||
@Default
|
||||
private Integer maxDelay = null;
|
||||
|
||||
@Value("replace-current-music")
|
||||
@Default
|
||||
private Boolean replaceCurrentMusic = null;
|
||||
|
||||
@Override
|
||||
public Music get() {
|
||||
if(sound == null || minDelay == null || maxDelay == null || replaceCurrentMusic == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new Music(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(sound), minDelay, maxDelay, replaceCurrentMusic);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
|
||||
|
||||
public class SoundEventTemplate implements ObjectTemplate<SoundEvent> {
|
||||
@Value("id")
|
||||
@Default
|
||||
private ResourceLocation id = null;
|
||||
|
||||
@Value("distance-to-travel")
|
||||
@Default
|
||||
private Float distanceToTravel = null;
|
||||
|
||||
@Override
|
||||
public SoundEvent get() {
|
||||
if(id == null) {
|
||||
return null;
|
||||
} else if(distanceToTravel == null) {
|
||||
return SoundEvent.createVariableRangeEvent(id);
|
||||
} else {
|
||||
return SoundEvent.createFixedRangeEvent(id, distanceToTravel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
|
||||
public class SpawnCostConfig implements ObjectTemplate<SpawnCostConfig> {
|
||||
@Value("type")
|
||||
@Default
|
||||
private EntityType<?> type = null;
|
||||
|
||||
@Value("mass")
|
||||
@Default
|
||||
private Double mass = null;
|
||||
|
||||
@Value("gravity")
|
||||
@Default
|
||||
private Double gravity = null;
|
||||
|
||||
public EntityType<?> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Double getMass() {
|
||||
return mass;
|
||||
}
|
||||
|
||||
public Double getGravity() {
|
||||
return gravity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnCostConfig get() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
|
||||
|
||||
public class SpawnEntryTemplate implements ObjectTemplate<SpawnerData> {
|
||||
@Value("type")
|
||||
@Default
|
||||
private EntityType<?> type = null;
|
||||
|
||||
@Value("weight")
|
||||
@Default
|
||||
private Integer weight = null;
|
||||
|
||||
@Value("min-group-size")
|
||||
@Default
|
||||
private Integer minGroupSize = null;
|
||||
|
||||
@Value("max-group-size")
|
||||
@Default
|
||||
private Integer maxGroupSize = null;
|
||||
|
||||
@Override
|
||||
public SpawnerData get() {
|
||||
return new SpawnerData(type, weight, minGroupSize, maxGroupSize);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class SpawnSettingsTemplate implements ObjectTemplate<MobSpawnSettings> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SpawnTypeConfig.class);
|
||||
private static boolean used = false;
|
||||
|
||||
@Value("spawns")
|
||||
@Default
|
||||
private List<SpawnTypeConfig> spawns = null;
|
||||
|
||||
@Value("costs")
|
||||
@Default
|
||||
private List<SpawnCostConfig> costs = null;
|
||||
|
||||
@Value("probability")
|
||||
@Default
|
||||
private Float probability = null;
|
||||
|
||||
@Override
|
||||
public MobSpawnSettings get() {
|
||||
MobSpawnSettings.Builder builder = new MobSpawnSettings.Builder();
|
||||
for(SpawnTypeConfig spawn : spawns) {
|
||||
MobCategory group = spawn.getGroup();
|
||||
if (spawn.getEntries() != null) {
|
||||
for(SpawnerData entry : spawn.getEntries()) {
|
||||
builder.addSpawn(group, entry);
|
||||
}
|
||||
} else if (spawn.getEntry() != null) {
|
||||
if(!used) {
|
||||
logger.warn("The entry sub-field of spawns is deprecated. " +
|
||||
"It is recommended to use the entries sub-field instead.");
|
||||
used = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(SpawnCostConfig cost : costs) {
|
||||
builder.addMobCharge(cost.getType(), cost.getMass(), cost.getGravity());
|
||||
}
|
||||
if(probability != null) {
|
||||
builder.creatureGenerationProbability(probability);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
|
||||
|
||||
public class SpawnTypeConfig implements ObjectTemplate<SpawnTypeConfig> {
|
||||
@Value("group")
|
||||
@Default
|
||||
private MobCategory group = null;
|
||||
|
||||
@Value("entries")
|
||||
@Default
|
||||
private List<SpawnerData> entries = null;
|
||||
|
||||
@Value("entry")
|
||||
@Default
|
||||
@Deprecated
|
||||
private SpawnerData entry = null;
|
||||
|
||||
public MobCategory getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public List<SpawnerData> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SpawnerData getEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnTypeConfig get() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import java.util.List;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.npc.VillagerType;
|
||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
||||
import net.minecraft.world.level.biome.AmbientMoodSettings;
|
||||
import net.minecraft.world.level.biome.AmbientParticleSettings;
|
||||
import net.minecraft.world.level.biome.Biome.Precipitation;
|
||||
import net.minecraft.world.level.biome.Biome.TemperatureModifier;
|
||||
import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
|
||||
|
||||
public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
|
||||
@Value("tags")
|
||||
@Default
|
||||
private List<ResourceLocation> tags = null;
|
||||
|
||||
@Value("colors.grass")
|
||||
@Default
|
||||
private Integer grassColor = null;
|
||||
|
||||
@Value("colors.fog")
|
||||
@Default
|
||||
private Integer fogColor = null;
|
||||
|
||||
@Value("colors.water")
|
||||
@Default
|
||||
private Integer waterColor = null;
|
||||
|
||||
@Value("colors.water-fog")
|
||||
@Default
|
||||
private Integer waterFogColor = null;
|
||||
|
||||
@Value("colors.foliage")
|
||||
@Default
|
||||
private Integer foliageColor = null;
|
||||
|
||||
@Value("colors.sky")
|
||||
@Default
|
||||
private Integer skyColor = null;
|
||||
|
||||
@Value("colors.modifier")
|
||||
@Default
|
||||
private GrassColorModifier grassColorModifier = null;
|
||||
|
||||
@Value("particles")
|
||||
@Default
|
||||
private AmbientParticleSettings particleConfig = null;
|
||||
|
||||
@Value("climate.precipitation")
|
||||
@Default
|
||||
private Boolean precipitation = null;
|
||||
|
||||
@Value("climate.temperature")
|
||||
@Default
|
||||
private Float temperature = null;
|
||||
|
||||
@Value("climate.temperature-modifier")
|
||||
@Default
|
||||
private TemperatureModifier temperatureModifier = null;
|
||||
|
||||
@Value("climate.downfall")
|
||||
@Default
|
||||
private Float downfall = null;
|
||||
|
||||
@Value("sound.loop-sound.sound")
|
||||
@Default
|
||||
private SoundEvent loopSound = null;
|
||||
|
||||
@Value("sound.mood-sound")
|
||||
@Default
|
||||
private AmbientMoodSettings moodSound = null;
|
||||
|
||||
@Value("sound.additions-sound")
|
||||
@Default
|
||||
private AmbientAdditionsSettings additionsSound = null;
|
||||
|
||||
@Value("sound.music")
|
||||
@Default
|
||||
private Music music = null;
|
||||
|
||||
@Value("spawning")
|
||||
@Default
|
||||
private MobSpawnSettings spawnSettings = null;
|
||||
|
||||
@Value("villager-type")
|
||||
@Default
|
||||
private VillagerType villagerType = null;
|
||||
|
||||
public List<ResourceLocation> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public Integer getGrassColor() {
|
||||
return grassColor;
|
||||
}
|
||||
|
||||
public Integer getFogColor() {
|
||||
return fogColor;
|
||||
}
|
||||
|
||||
public Integer getWaterColor() {
|
||||
return waterColor;
|
||||
}
|
||||
|
||||
public Integer getWaterFogColor() {
|
||||
return waterFogColor;
|
||||
}
|
||||
|
||||
public Integer getFoliageColor() {
|
||||
return foliageColor;
|
||||
}
|
||||
|
||||
public Integer getSkyColor() {
|
||||
return skyColor;
|
||||
}
|
||||
|
||||
public GrassColorModifier getGrassColorModifier() {
|
||||
return grassColorModifier;
|
||||
}
|
||||
|
||||
public AmbientParticleSettings getParticleConfig() {
|
||||
return particleConfig;
|
||||
}
|
||||
|
||||
public Boolean getPrecipitation() {
|
||||
return precipitation;
|
||||
}
|
||||
|
||||
public Float getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public TemperatureModifier getTemperatureModifier() {
|
||||
return temperatureModifier;
|
||||
}
|
||||
|
||||
public Float getDownfall() {
|
||||
return downfall;
|
||||
}
|
||||
|
||||
public SoundEvent getLoopSound() {
|
||||
return loopSound;
|
||||
}
|
||||
|
||||
public AmbientMoodSettings getMoodSound() {
|
||||
return moodSound;
|
||||
}
|
||||
|
||||
public AmbientAdditionsSettings getAdditionsSound() {
|
||||
return additionsSound;
|
||||
}
|
||||
|
||||
public Music getMusic() {
|
||||
return music;
|
||||
}
|
||||
|
||||
public MobSpawnSettings getSpawnSettings() {
|
||||
return spawnSettings;
|
||||
}
|
||||
|
||||
public VillagerType getVillagerType() {
|
||||
return villagerType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_20_R2.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryCodecs;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.npc.VillagerType;
|
||||
|
||||
|
||||
public class VillagerTypeTemplate implements ObjectTemplate<VillagerType> {
|
||||
@Value("id")
|
||||
@Default
|
||||
private ResourceLocation id = null;
|
||||
|
||||
@Override
|
||||
public VillagerType get() {
|
||||
return BuiltInRegistries.VILLAGER_TYPE.get(id);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class SpawnSettingsTemplate implements ObjectTemplate<SpawnSettings> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SpawnTypeConfig.class);
|
||||
private static boolean used = false;
|
||||
|
||||
@Value("spawns")
|
||||
@Default
|
||||
private List<SpawnTypeConfig> spawns = null;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
|
||||
@Value("climate.precipitation")
|
||||
@Default
|
||||
private Boolean precipitation = true;
|
||||
private Boolean precipitation = null;
|
||||
|
||||
@Value("climate.temperature")
|
||||
@Default
|
||||
|
||||
Reference in New Issue
Block a user