Feature array length fix
This commit is contained in:
parent
42aedf2525
commit
fc3dc71a44
2 changed files with 21 additions and 15 deletions
|
@ -11,7 +11,7 @@ loader_version= 0.12.4
|
||||||
fabric_version = 0.41.3+1.17
|
fabric_version = 0.41.3+1.17
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.5.2
|
mod_version = 0.5.3
|
||||||
maven_group = ru.bclib
|
maven_group = ru.bclib
|
||||||
archives_base_name = bclib
|
archives_base_name = bclib
|
||||||
|
|
||||||
|
|
|
@ -414,13 +414,7 @@ public class BiomeAPI {
|
||||||
public static void addBiomeFeature(Biome biome, ConfiguredFeature feature, Decoration step) {
|
public static void addBiomeFeature(Biome biome, ConfiguredFeature feature, Decoration step) {
|
||||||
GenerationSettingsAccessor accessor = (GenerationSettingsAccessor) biome.getGenerationSettings();
|
GenerationSettingsAccessor accessor = (GenerationSettingsAccessor) biome.getGenerationSettings();
|
||||||
List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = getMutableList(accessor.fabric_getFeatures());
|
List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = getMutableList(accessor.fabric_getFeatures());
|
||||||
int index = step.ordinal();
|
List<Supplier<ConfiguredFeature<?, ?>>> list = getList(step, biomeFeatures);
|
||||||
if (biomeFeatures.size() < index) {
|
|
||||||
for (int i = biomeFeatures.size(); i <= index; i++) {
|
|
||||||
biomeFeatures.add(Lists.newArrayList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<Supplier<ConfiguredFeature<?, ?>>> list = getMutableList(biomeFeatures.get(index));
|
|
||||||
list.add(() -> feature);
|
list.add(() -> feature);
|
||||||
accessor.fabric_setFeatures(biomeFeatures);
|
accessor.fabric_setFeatures(biomeFeatures);
|
||||||
}
|
}
|
||||||
|
@ -434,18 +428,30 @@ public class BiomeAPI {
|
||||||
GenerationSettingsAccessor accessor = (GenerationSettingsAccessor) biome.getGenerationSettings();
|
GenerationSettingsAccessor accessor = (GenerationSettingsAccessor) biome.getGenerationSettings();
|
||||||
List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = getMutableList(accessor.fabric_getFeatures());
|
List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = getMutableList(accessor.fabric_getFeatures());
|
||||||
for (BCLFeature feature: features) {
|
for (BCLFeature feature: features) {
|
||||||
int index = feature.getFeatureStep().ordinal();
|
List<Supplier<ConfiguredFeature<?, ?>>> list = getList(feature.getFeatureStep(), biomeFeatures);
|
||||||
if (biomeFeatures.size() < index) {
|
|
||||||
for (int i = biomeFeatures.size(); i <= index; i++) {
|
|
||||||
biomeFeatures.add(Lists.newArrayList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<Supplier<ConfiguredFeature<?, ?>>> list = getMutableList(biomeFeatures.get(index));
|
|
||||||
list.add(feature::getFeatureConfigured);
|
list.add(feature::getFeatureConfigured);
|
||||||
}
|
}
|
||||||
accessor.fabric_setFeatures(biomeFeatures);
|
accessor.fabric_setFeatures(biomeFeatures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for correct feature list from all biome feature list of lists.
|
||||||
|
* @param step feature {@link Decoration} step.
|
||||||
|
* @param lists biome accessor lists.
|
||||||
|
* @return mutable {@link ConfiguredFeature} list.
|
||||||
|
*/
|
||||||
|
private static List<Supplier<ConfiguredFeature<?, ?>>> getList(Decoration step, List<List<Supplier<ConfiguredFeature<?, ?>>>> lists) {
|
||||||
|
int index = step.ordinal();
|
||||||
|
if (lists.size() <= index) {
|
||||||
|
for (int i = lists.size(); i <= index; i++) {
|
||||||
|
lists.add(Lists.newArrayList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Supplier<ConfiguredFeature<?, ?>>> list = getMutableList(lists.get(index));
|
||||||
|
lists.set(index, list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds new structure feature to existing biome.
|
* Adds new structure feature to existing biome.
|
||||||
* @param biome {@link Biome} to add structure feature in.
|
* @param biome {@link Biome} to add structure feature in.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue