Surface rule fixes
This commit is contained in:
parent
699332600b
commit
92dae621f1
5 changed files with 39 additions and 32 deletions
|
@ -4,7 +4,6 @@ import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
|
|||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.data.worldgen.BiomeDefaultFeatures;
|
||||
import net.minecraft.data.worldgen.SurfaceRuleData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
|
@ -42,9 +41,11 @@ import java.util.function.Consumer;
|
|||
public class BCLBiomeBuilder {
|
||||
private static final BCLBiomeBuilder INSTANCE = new BCLBiomeBuilder();
|
||||
|
||||
private List<ConfiguredStructureFeature> structures = new ArrayList<>(16);
|
||||
private BiomeGenerationSettings.Builder generationSettings;
|
||||
private BiomeSpecialEffects.Builder effectsBuilder;
|
||||
private MobSpawnSettings.Builder spawnSettings;
|
||||
private SurfaceRules.RuleSource surfaceRule;
|
||||
private Precipitation precipitation;
|
||||
private ResourceLocation biomeID;
|
||||
private BiomeCategory category;
|
||||
|
@ -64,6 +65,7 @@ public class BCLBiomeBuilder {
|
|||
INSTANCE.generationSettings = null;
|
||||
INSTANCE.effectsBuilder = null;
|
||||
INSTANCE.spawnSettings = null;
|
||||
INSTANCE.structures.clear();
|
||||
INSTANCE.temperature = 1.0F;
|
||||
INSTANCE.fogDensity = 1.0F;
|
||||
INSTANCE.downfall = 1.0F;
|
||||
|
@ -451,7 +453,6 @@ public class BCLBiomeBuilder {
|
|||
return feature(feature.getDecoration(), feature.getPlacedFeature());
|
||||
}
|
||||
|
||||
private List<ConfiguredStructureFeature> structures = new ArrayList<>(2);
|
||||
/**
|
||||
* Adds new structure feature into the biome.
|
||||
* @param structure {@link ConfiguredStructureFeature} to add.
|
||||
|
@ -484,14 +485,22 @@ public class BCLBiomeBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
private List<SurfaceRules.RuleSource> surfaceRules = new ArrayList<>(2);
|
||||
/**
|
||||
* Adds new world surface rule for the given block
|
||||
* @param surfaceBlock {@link Block} to use.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder surface(Block surfaceBlock) {
|
||||
surfaceRules.add(SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.state(surfaceBlock.defaultBlockState())));
|
||||
return surface(SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.state(surfaceBlock.defaultBlockState())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds surface rule to this biome.
|
||||
* @param surfaceRule {link SurfaceRules.RuleSource} surface rule.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder surface(SurfaceRules.RuleSource surfaceRule) {
|
||||
this.surfaceRule = surfaceRule;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -528,8 +537,8 @@ public class BCLBiomeBuilder {
|
|||
}
|
||||
|
||||
final T res = biomeConstructor.apply(biomeID, builder.build());
|
||||
res.attachedStructures = structures;
|
||||
res.surfaceRules = surfaceRules;
|
||||
res.attachStructures(structures);
|
||||
res.setSurface(surfaceRule);
|
||||
res.setFogDensity(fogDensity);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import net.fabricmc.fabric.impl.biome.TheEndBiomeData;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.data.worldgen.SurfaceRuleData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -24,12 +23,10 @@ import net.minecraft.world.entity.Mob;
|
|||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep.Carving;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
|
@ -58,7 +55,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
|
|
|
@ -4,10 +4,8 @@ import com.google.common.collect.Lists;
|
|||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.data.loot.BlockLoot;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -17,7 +15,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.bclib.api.TagAPI;
|
||||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.BlockModelProvider;
|
||||
import ru.bclib.interfaces.RenderLayerProvider;
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.world.level.material.Material;
|
|||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.bclib.api.TagAPI;
|
||||
import ru.bclib.interfaces.BlockModelProvider;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ru.bclib.world.biomes;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
|
@ -17,11 +18,13 @@ import java.util.Map;
|
|||
import java.util.Random;
|
||||
|
||||
public class BCLBiome {
|
||||
private final List<ConfiguredStructureFeature> structures = Lists.newArrayList();
|
||||
private final WeightedList<BCLBiome> subbiomes = new WeightedList<>();
|
||||
private final Map<String, Object> customData = Maps.newHashMap();
|
||||
private final ResourceLocation biomeID;
|
||||
private final Biome biome;
|
||||
|
||||
private SurfaceRules.RuleSource surface;
|
||||
private BCLBiome biomeParent;
|
||||
private Biome actualBiome;
|
||||
private BCLBiome edge;
|
||||
|
@ -207,20 +210,6 @@ public class BCLBiome {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* For internal use only!!!
|
||||
* maintains a list of all structures added to this biome, this is automatically set by
|
||||
* {@link ru.bclib.api.biomes.BCLBiomeBuilder}
|
||||
*/
|
||||
public List<ConfiguredStructureFeature> attachedStructures = null;
|
||||
|
||||
/**
|
||||
* For internal use only!!!
|
||||
* maintains a list of all structures added to this biome, this is automatically set by
|
||||
* {@link ru.bclib.api.biomes.BCLBiomeBuilder}
|
||||
*/
|
||||
public List<SurfaceRules.RuleSource> surfaceRules = null;
|
||||
|
||||
/**
|
||||
* Recursively update biomes to correct world biome registry instances, for internal usage only.
|
||||
* @param biomeRegistry {@link Registry} for {@link Biome}.
|
||||
|
@ -235,11 +224,10 @@ public class BCLBiome {
|
|||
edge.updateActualBiomes(biomeRegistry);
|
||||
}
|
||||
this.actualBiome = biomeRegistry.get(biomeID);
|
||||
if (this.attachedStructures!=null)
|
||||
attachedStructures.forEach(s -> BiomeAPI.addBiomeStructure(BiomeAPI.getBiomeKey(actualBiome), s));
|
||||
|
||||
if (this.surfaceRules!=null)
|
||||
surfaceRules.forEach(s -> BiomeAPI.addSurfaceRule(biomeID, s));
|
||||
if (!this.structures.isEmpty()) {
|
||||
structures.forEach(s -> BiomeAPI.addBiomeStructure(BiomeAPI.getBiomeKey(actualBiome), s));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -311,4 +299,22 @@ public class BCLBiome {
|
|||
public String toString() {
|
||||
return biomeID.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds structures to this biome. For internal use only.
|
||||
* Used inside {@link ru.bclib.api.biomes.BCLBiomeBuilder}.
|
||||
*/
|
||||
public void attachStructures(List<ConfiguredStructureFeature> structures) {
|
||||
this.structures.addAll(structures);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets biome surface rule.
|
||||
* @param surface {@link SurfaceRules.RuleSource} rule.
|
||||
*/
|
||||
public void setSurface(SurfaceRules.RuleSource surface) {
|
||||
ResourceKey key = BiomeAPI.getBiomeKey(biome);
|
||||
BiomeAPI.addSurfaceRule(biomeID, SurfaceRules.ifTrue(SurfaceRules.isBiome(key), surface));
|
||||
this.surface = surface;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue