Small fixes, custom biome data

This commit is contained in:
paulevsGitch 2021-06-06 20:33:12 +03:00
parent 6487efb3de
commit 6e882d08d9
4 changed files with 48 additions and 11 deletions

View file

@ -2,9 +2,11 @@ package ru.bclib.world.biomes;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@ -31,6 +33,7 @@ public class BCLBiome {
protected float maxSubBiomeChance = 1;
protected final float genChance;
private final Map<String, Object> customData;
private final float fogDensity;
private BCLFeature structuresFeature;
private Biome actualBiome;
@ -44,6 +47,7 @@ public class BCLBiome {
this.biome = definition.build();
this.genChance = definition.getGenChance();
this.fogDensity = definition.getFodDensity();
this.customData = definition.getCustomData();
}
public BCLBiome(ResourceLocation id, Biome biome, float fogDensity, float genChance) {
@ -52,6 +56,7 @@ public class BCLBiome {
this.genChance = genChance;
this.fogDensity = fogDensity;
this.readStructureList();
this.customData = Maps.newHashMap();
}
public BCLBiome getEdge() {
@ -179,4 +184,9 @@ public class BCLBiome {
public int hashCode() {
return mcID.hashCode();
}
@SuppressWarnings("unchecked")
public <T> T getCustomData(String name) {
return (T) customData.get(name);
}
}

View file

@ -1,8 +1,10 @@
package ru.bclib.world.biomes;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleOptions;
@ -50,6 +52,7 @@ public class BCLBiomeDef {
private final List<CarverInfo> carvers = Lists.newArrayList();
private final List<SpawnInfo> mobs = Lists.newArrayList();
private final List<SpawnerData> spawns = Lists.newArrayList();
private final Map<String, Object> customData = Maps.newHashMap();
private final ResourceLocation id;
@ -369,4 +372,12 @@ public class BCLBiomeDef {
carvers.add(info);
return this;
}
public void addCustomData(String name, Object value) {
customData.put(name, value);
}
protected Map<String, Object> getCustomData() {
return customData;
}
}