*WIP:* Started code migration

This commit is contained in:
Frank 2022-03-07 22:09:57 +01:00
parent 557e69080b
commit 48db196c7b
22 changed files with 233 additions and 323 deletions

View file

@ -1,19 +1,15 @@
package ru.bclib.api.biomes;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.impl.biome.NetherBiomeData;
import net.fabricmc.fabric.impl.biome.TheEndBiomeData;
import net.fabricmc.fabric.impl.structure.FabricStructureImpl;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
@ -26,11 +22,7 @@ import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeGenerationSettings;
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.*;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
@ -41,27 +33,20 @@ import net.minecraft.world.level.levelgen.GenerationStep.Carving;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.StructureSettings;
import net.minecraft.world.level.levelgen.SurfaceRules;
import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource;
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.StructureFeatureConfiguration;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraft.world.level.levelgen.structure.StructureSet;
import org.apache.commons.lang3.mutable.MutableInt;
import org.jetbrains.annotations.Nullable;
import ru.bclib.BCLib;
import ru.bclib.entity.BCLEntityWrapper;
import ru.bclib.interfaces.BiomeSourceAccessor;
import ru.bclib.interfaces.NoiseGeneratorSettingsProvider;
import ru.bclib.interfaces.SurfaceMaterialProvider;
import ru.bclib.interfaces.SurfaceProvider;
import ru.bclib.interfaces.SurfaceRuleProvider;
import ru.bclib.interfaces.*;
import ru.bclib.mixin.common.BiomeGenerationSettingsAccessor;
import ru.bclib.mixin.common.MobSpawnSettingsAccessor;
import ru.bclib.mixin.common.StructureSettingsAccessor;
import ru.bclib.util.CollectionsUtil;
import ru.bclib.util.MHelper;
import ru.bclib.world.biomes.BCLBiome;
@ -69,18 +54,9 @@ import ru.bclib.world.biomes.FabricBiomesData;
import ru.bclib.world.biomes.VanillaBiomeSettings;
import ru.bclib.world.features.BCLFeature;
import ru.bclib.world.generator.BiomePicker;
import ru.bclib.world.structures.BCLStructureFeature;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@ -102,8 +78,7 @@ public class BiomeAPI {
private static final Map<PlacedFeature, Integer> FEATURE_ORDER = Maps.newHashMap();
private static final MutableInt FEATURE_ORDER_ID = new MutableInt(0);
private final static Map<StructureID, BiConsumer<Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>>, Map<StructureFeature<?>, StructureFeatureConfiguration>>> STRUCTURE_STARTS = new HashMap<>();
private static final Map<ResourceKey, List<BiConsumer<ResourceLocation, Biome>>> MODIFICATIONS = Maps.newHashMap();
private static final Map<ResourceLocation, SurfaceRules.RuleSource> SURFACE_RULES = Maps.newHashMap();
private static final Set<SurfaceRuleProvider> MODIFIED_SURFACE_PROVIDERS = new HashSet<>(8);
@ -161,8 +136,6 @@ public class BiomeAPI {
* called from {@link ru.bclib.mixin.client.MinecraftMixin}
*/
public static void prepareNewLevel(){
STRUCTURE_STARTS.clear();
MODIFIED_SURFACE_PROVIDERS.forEach(p->p.bclib_clearBiomeSources());
MODIFIED_SURFACE_PROVIDERS.clear();
}
@ -375,6 +348,19 @@ public class BiomeAPI {
}
return id == null ? EMPTY_BIOME.getID() : id;
}
/**
* Get biome {@link ResourceLocation} from given {@link Biome}.
* @param biome - {@link Holder<Biome>} from server world.
* @return biome {@link ResourceLocation}.
*/
public static ResourceLocation getBiomeID(Holder<Biome> biome) {
var oKey = biome.unwrapKey();
if (oKey.isPresent()){
return oKey.get().location();
}
return null;
}
/**
* Get {@link BCLBiome} from given {@link ResourceLocation}.
@ -393,6 +379,15 @@ public class BiomeAPI {
public static BCLBiome getBiome(Biome biome) {
return getBiome(BiomeAPI.getBiomeID(biome));
}
/**
* Get {@link BCLBiome} from given {@link Biome}.
* @param biome - biome {@link Biome}.
* @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}.
*/
public static BCLBiome getBiome(Holder<Biome> biome) {
return getBiome(BiomeAPI.getBiomeID(biome));
}
/**
* Check if biome with {@link ResourceLocation} exists in API registry.
@ -491,40 +486,54 @@ public class BiomeAPI {
* @param level
*/
public static void applyModifications(ServerLevel level) {
final BiomeSource source = level.getChunkSource().getGenerator().getBiomeSource();
final StructureSettings settings = level.getChunkSource().getGenerator().getSettings();
final Set<Biome> biomes = source.possibleBiomes();
NoiseGeneratorSettings noiseGeneratorSettings = null;
final ChunkGenerator chunkGenerator = level.getChunkSource().getGenerator();
final BiomeSource source = chunkGenerator.getBiomeSource();
final Set<Holder<Biome>> biomes = source.possibleBiomes();
NoiseGeneratorSettings generator = level
//TODO: 1.18.2 Is this stilla valid way to determine the correct noiseGeneratorSettings for the level?
final Registry<StructureSet> structureSetRegistry;
if (chunkGenerator instanceof ChunkGeneratorAccessor acc) {
structureSetRegistry = acc.bclib_getStructureSetsRegistry();
} else {
structureSetRegistry = null;
}
noiseGeneratorSettings = level
.getServer()
.getWorldData()
.worldGenSettings()
.dimensions()
.stream()
.map(dim->dim.generator())
.filter(gen->(gen instanceof NoiseGeneratorSettingsProvider) && gen.getSettings()==settings)
.filter(gen-> structureSetRegistry!=null && (gen instanceof NoiseGeneratorSettingsProvider) && (gen instanceof ChunkGeneratorAccessor) && ((ChunkGeneratorAccessor)gen).bclib_getStructureSetsRegistry()==structureSetRegistry)
.map(gen->((NoiseGeneratorSettingsProvider)gen).bclib_getNoiseGeneratorSettings())
.findFirst()
.orElse(null);
// Datapacks (like Amplified Nether)will change the GeneratorSettings upon load, so we will
// only use the default Setting for Nether/End if we were unable to find a settings object
if (generator==null){
if (noiseGeneratorSettings==null){
if (level.dimension() == Level.NETHER) {
generator = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.NETHER);
noiseGeneratorSettings = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.NETHER);
} else if (level.dimension() == Level.END) {
generator = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.END);
noiseGeneratorSettings = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.END);
}
}
List<BiConsumer<ResourceLocation, Biome>> modifications = MODIFICATIONS.get(level.dimension());
for (Biome biome : biomes) {
applyModificationsAndUpdateFeatures(modifications, biome);
for (Holder<Biome> biomeHolder : biomes) {
if (biomeHolder.isBound()) {
applyModificationsAndUpdateFeatures(modifications, biomeHolder.value());
}
}
if (generator != null) {
final SurfaceRuleProvider provider = SurfaceRuleProvider.class.cast(generator);
if (noiseGeneratorSettings != null) {
final SurfaceRuleProvider provider = SurfaceRuleProvider.class.cast(noiseGeneratorSettings);
// Multiple Biomes can use the same generator. So we need to keep track of all Biomes that are
// Provided by all the BiomeSources that use the same generator.
// This happens for example when using the MiningDimensions, which reuses the generator for the
@ -535,16 +544,6 @@ public class BiomeAPI {
BCLib.LOGGER.warning("No generator for " + source);
}
if (settings!=null){
final StructureSettingsAccessor settingsAccessor = (StructureSettingsAccessor)settings;
final Set<ResourceLocation> biomeIDs = biomes.stream().map(BiomeAPI::getBiomeID).collect(Collectors.toSet());
for (Entry<StructureID, BiConsumer<Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>>, Map<StructureFeature<?>, StructureFeatureConfiguration>>> e : STRUCTURE_STARTS.entrySet()) {
if (biomeIDs.contains(e.getKey().biomeID)) {
applyStructureStarts(settingsAccessor, e.getValue());
}
}
}
((BiomeSourceAccessor) source).bclRebuildFeatures();
}
@ -581,7 +580,7 @@ public class BiomeAPI {
accessor.bclib_setFeatures(featureList);
}
private static List<SurfaceRules.RuleSource> getRuleSourcesForBiomes(Set<Biome> biomes) {
private static List<SurfaceRules.RuleSource> getRuleSourcesForBiomes(Set<Holder<Biome>> biomes) {
Set<ResourceLocation> biomeIDs = biomes
.stream()
.map(biome -> getBiomeID(biome))
@ -600,7 +599,7 @@ public class BiomeAPI {
* @return A list of {@link RuleSource}-Objects that are needed to create those Biomes
*/
public static List<SurfaceRules.RuleSource> getRuleSources(Set<BiomeSource> sources) {
final Set<Biome> biomes = new HashSet<>();
final Set<Holder<Biome>> biomes = new HashSet<>();
for (BiomeSource s : sources) {
biomes.addAll(s.possibleBiomes());
}
@ -683,68 +682,6 @@ public class BiomeAPI {
accessor.bclib_setFeatureSet(set);
}
/**
* Adds new structure feature to existing biome.
* @param biomeKey {@link ResourceKey} for the {@link Biome} to add structure feature in.
* @param structure {@link ConfiguredStructureFeature} to add.
*/
public static void addBiomeStructure(ResourceKey biomeKey, ConfiguredStructureFeature structure) {
if (biomeKey == null){
BCLib.LOGGER.error("null is not a valid biomeKey for " + structure);
return;
}
changeStructureStarts(biomeKey.location(), structure, (structureMap, configMap) -> {
Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>> configuredMap = structureMap.computeIfAbsent(structure.feature, k -> HashMultimap.create());
configuredMap.put(structure, biomeKey);
StructureFeatureConfiguration config = FabricStructureImpl.STRUCTURE_TO_CONFIG_MAP.get(structure.feature);
if (config != null){
configMap.put(structure.feature, config);
}
});
}
/**
* Add an existing StructureFeature to a Biome
* @param biome The {@link Biome} you want to add teh feature to
* @param structure The {@link ConfiguredStructureFeature} to add
*/
public static void addBiomeStructure(Biome biome, ConfiguredStructureFeature structure) {
changeStructureStarts(BiomeAPI.getBiomeID(biome), structure, (structureMap, configMap) -> {
Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>> configuredMap = structureMap.computeIfAbsent(structure.feature, k -> HashMultimap.create());
var key = getBiomeKey(biome);
if (key != null) {
StructureFeatureConfiguration config = FabricStructureImpl.STRUCTURE_TO_CONFIG_MAP.get(structure.feature);
if (config != null) {
configMap.put(structure.feature, config);
}
configuredMap.put(structure, key);
} else {
BCLib.LOGGER.warning("Unable to find Biome " + getBiomeID(biome));
}
});
}
/**
* Adds new structure feature to existing biome.
* @param biomeKey {@link ResourceKey} for the {@link Biome} to add structure feature in.
* @param structure {@link BCLStructureFeature} to add.
*/
public static void addBiomeStructure(ResourceKey biomeKey, BCLStructureFeature structure) {
addBiomeStructure(biomeKey, structure.getFeatureConfigured());
}
/**
* Adds new structure features to existing biome.
* @param biomeKey {@link ResourceKey} for the {@link Biome} to add structure features in.
* @param structures array of {@link BCLStructureFeature} to add.
*/
public static void addBiomeStructures(ResourceKey biomeKey, BCLStructureFeature... structures) {
for (BCLStructureFeature structure: structures) {
addBiomeStructure(biomeKey, structure.getFeatureConfigured());
}
}
/**
* Adds new carver into existing biome.
* @param biome {@link Biome} to add carver in.
@ -862,11 +799,11 @@ public class BiomeAPI {
* Set biome in chunk at specified position.
* @param chunk {@link ChunkAccess} chunk to set biome in.
* @param pos {@link BlockPos} biome position.
* @param biome {@link Biome} instance. Should be biome from world.
* @param biome {@link Holder<Biome>} instance. Should be biome from world.
*/
public static void setBiome(ChunkAccess chunk, BlockPos pos, Biome biome) {
public static void setBiome(ChunkAccess chunk, BlockPos pos, Holder<Biome> biome) {
int sectionY = (pos.getY() - chunk.getMinBuildHeight()) >> 4;
PalettedContainer<Biome> biomes = chunk.getSection(sectionY).getBiomes();
PalettedContainer<Holder<Biome>> biomes = chunk.getSection(sectionY).getBiomes();
biomes.set((pos.getX() & 15) >> 2, (pos.getY() & 15) >> 2, (pos.getZ() & 15) >> 2, biome);
}
@ -874,9 +811,9 @@ public class BiomeAPI {
* Set biome in world at specified position.
* @param level {@link LevelAccessor} world to set biome in.
* @param pos {@link BlockPos} biome position.
* @param biome {@link Biome} instance. Should be biome from world.
* @param biome {@link Holder<Biome>} instance. Should be biome from world.
*/
public static void setBiome(LevelAccessor level, BlockPos pos, Biome biome) {
public static void setBiome(LevelAccessor level, BlockPos pos, Holder<Biome> biome) {
ChunkAccess chunk = level.getChunk(pos);
setBiome(chunk, pos, biome);
}
@ -909,23 +846,6 @@ public class BiomeAPI {
}
}
private static void changeStructureStarts(ResourceLocation biomeID, ConfiguredStructureFeature structure, BiConsumer<Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>>, Map<StructureFeature<?>, StructureFeatureConfiguration>> modifier) {
STRUCTURE_STARTS.put(new StructureID(biomeID, structure), modifier);
}
private static void applyStructureStarts(StructureSettingsAccessor access, BiConsumer<Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>>, Map<StructureFeature<?>, StructureFeatureConfiguration>> modifier) {
Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> structureMap;
Map<StructureFeature<?>, StructureFeatureConfiguration> configMap;
structureMap = getMutableConfiguredStructures(access);
configMap = getMutableStructureConfig(access);
modifier.accept(structureMap, configMap);
setMutableConfiguredStructures(access, structureMap);
setMutableStructureConfig(access, configMap);
}
private static void sortFeatures(List<Supplier<PlacedFeature>> features) {
initFeatureOrder();
@ -976,34 +896,4 @@ public class BiomeAPI {
features.set(index, mutable);
return mutable;
}
//inspired by net.fabricmc.fabric.impl.biome.modification.BiomeStructureStartsImpl
private static Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> getMutableConfiguredStructures(StructureSettingsAccessor access) {
ImmutableMap<StructureFeature<?>, ImmutableMultimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> configuredStructures = access.bcl_getConfiguredStructures();
Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> result = new HashMap<>(configuredStructures.size());
for (Map.Entry<StructureFeature<?>, ImmutableMultimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> entry : configuredStructures.entrySet()) {
result.put(entry.getKey(), HashMultimap.create(entry.getValue()));
}
return result;
}
//inspired by net.fabricmc.fabric.impl.biome.modification.BiomeStructureStartsImpl
private static void setMutableConfiguredStructures(StructureSettingsAccessor access, Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> structureStarts) {
access.bcl_setConfiguredStructures(
structureStarts
.entrySet()
.stream()
.collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, e -> ImmutableMultimap.copyOf(e.getValue())))
);
}
private static Map<StructureFeature<?>, StructureFeatureConfiguration> getMutableStructureConfig(StructureSettingsAccessor access) {
return CollectionsUtil.getMutable(access.bcl_getStructureConfig());
}
private static void setMutableStructureConfig(StructureSettingsAccessor access, Map<StructureFeature<?>, StructureFeatureConfiguration> structureConfig) {
access.bcl_setStructureConfig(structureConfig);
}
}

View file

@ -2,21 +2,20 @@ package ru.bclib.api.tag;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.fabricmc.fabric.api.tag.TagFactory;
import net.fabricmc.fabric.impl.tag.extension.TagDelegate;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.Tag;
import net.minecraft.tags.Tag.Named;
import net.minecraft.tags.TagCollection;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import ru.bclib.mixin.common.DiggerItemAccessor;
import java.util.List;
import java.util.Map;
@ -29,44 +28,44 @@ public class TagAPI {
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newConcurrentMap();
/**
* Get or create {@link Tag.Named}.
* Get or create {@link TagNamed}.
*
* @param containerSupplier - {@link TagCollection} {@link Supplier} tag collection;
* @param id - {@link ResourceLocation} tag id.
* @return {@link Tag.Named}.
* @return {@link TagNamed}.
*/
public static <T> TagNamed<T> makeTag(Supplier<TagCollection<T>> containerSupplier, TagLocation<T> id) {
Tag<T> tag = containerSupplier.get().getTag(id);
return tag == null ? new Delegate<>(id, containerSupplier) : CommonDelegate.proxy((Named<T>) tag);
return tag == null ? new Delegate<>(id, containerSupplier) : CommonDelegate.proxy((TagKey<T>) tag);
}
/**
* Get or create {@link Block} {@link Tag.Named} with mod namespace.
* Get or create {@link Block} {@link TagNamed} with mod namespace.
*
* @param modID - {@link String} mod namespace (mod id);
* @param name - {@link String} tag name.
* @return {@link Block} {@link Tag.Named}.
* @return {@link Block} {@link TagNamed}.
*/
public static TagNamed<Block> makeBlockTag(String modID, String name) {
return makeTag(BlockTags::getAllTags, new TagLocation<>(modID, name));
}
/**
* Get or create {@link Item} {@link Tag.Named} with mod namespace.
* Get or create {@link Item} {@link TagNamed} with mod namespace.
*
* @param modID - {@link String} mod namespace (mod id);
* @param name - {@link String} tag name.
* @return {@link Item} {@link Tag.Named}.
* @return {@link Item} {@link TagNamed}.
*/
public static TagNamed<Item> makeItemTag(String modID, String name) {
return makeTag(ItemTags::getAllTags, new TagLocation<>(modID, name));
}
/**
* Get or create {@link Block} {@link Tag.Named}.
* Get or create {@link Block} {@link TagNamed}.
*
* @param name - {@link String} tag name.
* @return {@link Block} {@link Tag.Named}.
* @return {@link Block} {@link TagNamed}.
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
*/
public static TagNamed<Block> makeCommonBlockTag(String name) {
@ -74,10 +73,10 @@ public class TagAPI {
}
/**
* Get or create {@link Item} {@link Tag.Named}.
* Get or create {@link Item} {@link TagNamed}.
*
* @param name - {@link String} tag name.
* @return {@link Item} {@link Tag.Named}.
* @return {@link Item} {@link TagNamed}.
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
*/
public static TagNamed<Item> makeCommonItemTag(String name) {
@ -85,16 +84,16 @@ public class TagAPI {
}
/**
* Get or create Minecraft {@link Block} {@link Tag.Named}.
* Get or create Minecraft {@link Block} {@link TagNamed}.
*
* @param name - {@link String} tag name.
* @return {@link Block} {@link Tag.Named}.
* @return {@link Block} {@link TagNamed}.
*/
@Deprecated(forRemoval = true)
public static TagNamed<Block> getMCBlockTag(String name) {
ResourceLocation id = new ResourceLocation(name);
Tag<Block> tag = BlockTags.getAllTags().getTag(id);
return CommonDelegate.proxy(tag == null ? (Named<Block>) TagFactory.BLOCK.create(id): (Named<Block>) tag);
return CommonDelegate.proxy(tag == null ? (TagKey<Block>) TagFactory.BLOCK.create(id): (TagKey<Block>) tag);
}
/**
@ -217,11 +216,11 @@ public class TagAPI {
}
/**
* Extends {@link Tag.Named} to return a type safe {@link TagLocation}. This Type was introduced to
* Extends {@link TagNamed} to return a type safe {@link TagLocation}. This Type was introduced to
* allow type-safe definition of Tags using their ResourceLocation.
* @param <T> The Type of the underlying {@link Tag}
*/
public interface TagNamed<T> extends Tag.Named<T>{
public interface TagNamed<T> extends TagKey<T>{
TagLocation<T> getName();
}
@ -243,18 +242,18 @@ public class TagAPI {
super(location.getNamespace(), location.getPath());
}
public static<R> TagLocation<R> of(Tag.Named<R> tag){
public static<R> TagLocation<R> of(TagKey<R> tag){
return new TagLocation<R>(tag.getName());
}
}
private abstract static class CommonDelegate<T> implements TagNamed<T> {
protected final Tag.Named<T> delegate;
protected CommonDelegate(Tag.Named<T> source){
protected final TagKey<T> delegate;
protected CommonDelegate(TagKey<T> source){
this.delegate = source;
}
public static<T> TagNamed<T> proxy(Tag.Named<T> source){
public static<T> TagNamed<T> proxy(TagKey<T> source){
if (source instanceof TagNamed typed) return typed;
return new ProxyDelegate<>(source);
}
@ -298,4 +297,11 @@ public class TagAPI {
return (TagLocation<T>)delegate.getName();
}
}
public static boolean isToolWithMineableTag(ItemStack stack, TagLocation<Block> tag){
if (stack.getItem() instanceof DiggerItemAccessor dig){
return dig.bclib_getBlockTag().location().equals(tag);
}
return false;
}
}

View file

@ -2,7 +2,6 @@ package ru.bclib.blocks;
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.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
@ -45,7 +44,8 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
public BaseDoublePlantBlock() {
this(
FabricBlockSettings.of(Material.PLANT)
.breakByHand(true)
//TODO: 1.18.2 make sure this works with the new tag system
//.breakByHand(true)
.sound(SoundType.GRASS)
.noCollission()
);

View file

@ -1,8 +1,6 @@
package ru.bclib.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.fabricmc.fabric.impl.object.builder.FabricBlockInternals;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
@ -60,7 +58,8 @@ public class BaseOreBlock extends OreBlock implements BlockModelProvider {
}
private static Properties makeProps(Properties properties, int level){
FabricBlockInternals.computeExtraData(properties).addMiningLevel(FabricToolTags.PICKAXES, level);
//TODO: 1.18.2 make sure this works with the new tag system
//FabricBlockInternals.computeExtraData(properties).addMiningLevel(FabricToolTags.PICKAXES, level);
return properties;
}

View file

@ -4,7 +4,6 @@ import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.core.BlockPos;
import net.minecraft.core.Direction;
@ -60,7 +59,8 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
this(
FabricBlockSettings
.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
.breakByHand(true)
//TODO: 1.18.2 make sure this works with the new tag system
//.breakByHand(true)
.sound(SoundType.GRASS)
.noCollission()
);

View file

@ -1,7 +1,6 @@
package ru.bclib.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
@ -15,6 +14,8 @@ import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.phys.BlockHitResult;
import ru.bclib.api.tag.NamedMineableTags;
import ru.bclib.api.tag.TagAPI;
public class BaseStripableLogBlock extends BaseRotatedPillarBlock {
private final Block striped;
@ -27,7 +28,9 @@ public class BaseStripableLogBlock extends BaseRotatedPillarBlock {
@Override
@SuppressWarnings("deprecation")
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) {
//TODO: 1.18.2 check
if (TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.AXE)){
//if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) {
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlock(pos,

View file

@ -3,8 +3,8 @@ package ru.bclib.blocks;
import com.google.common.collect.Maps;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
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.client.resources.model.UnbakedModel;
import net.minecraft.core.BlockPos;
@ -33,6 +33,8 @@ import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;
import ru.bclib.api.tag.NamedMineableTags;
import ru.bclib.api.tag.TagAPI;
import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper;
@ -69,7 +71,9 @@ public class BaseTerrainBlock extends BaseBlock {
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (pathBlock != null && FabricToolTags.SHOVELS.contains(player.getMainHandItem().getItem())) {
//TODO: 1.18.2 check
if (pathBlock != null && TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.SHOVEL)){
//if (pathBlock != null && FabricTagProvider.SHOVELS.contains(player.getMainHandItem().getItem())) {
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());

View file

@ -2,7 +2,6 @@ package ru.bclib.blocks;
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.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
@ -53,7 +52,8 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
this(
FabricBlockSettings
.of(Material.PLANT)
.breakByHand(true)
//TODO: 1.18.2 make sure this works with the new tag system
//.breakByHand(true)
.sound(SoundType.GRASS)
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light)
.noCollission()

View file

@ -1,7 +1,6 @@
package ru.bclib.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
@ -15,6 +14,8 @@ import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.phys.BlockHitResult;
import ru.bclib.api.tag.NamedMineableTags;
import ru.bclib.api.tag.TagAPI;
public class StripableBarkBlock extends BaseBarkBlock {
private final Block striped;
@ -27,7 +28,9 @@ public class StripableBarkBlock extends BaseBarkBlock {
@Override
@SuppressWarnings("deprecation")
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) {
//TODO: 1.18.2 check
if (TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.AXE)){
//if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) {
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlock(pos,

View file

@ -2,7 +2,6 @@ package ru.bclib.blocks;
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.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
@ -47,7 +46,8 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
this(
FabricBlockSettings
.of(Material.WATER_PLANT)
.breakByHand(true)
//TODO: 1.18.2 make sure this works with the new tag system
//.breakByHand(true)
.sound(SoundType.WET_GRASS)
.noCollission()
);

View file

@ -2,7 +2,6 @@ package ru.bclib.blocks;
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.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Player;
@ -39,7 +38,8 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements Rende
public UpDownPlantBlock() {
this(FabricBlockSettings
.of(Material.PLANT)
.breakByHand(true)
//TODO: 1.18.2 make sure this works with the new tag system
//.breakByHand(true)
.sound(SoundType.GRASS)
.noCollission()
);

View file

@ -7,6 +7,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Nullable;
@ -32,8 +33,8 @@ public abstract class ComplexMaterial {
private final List<BlockEntry> defaultBlockEntries = Lists.newArrayList();
private final List<ItemEntry> defaultItemEntries = Lists.newArrayList();
private final Map<String, Tag.Named<Block>> blockTags = Maps.newHashMap();
private final Map<String, Tag.Named<Item>> itemTags = Maps.newHashMap();
private final Map<String, TagKey<Block>> blockTags = Maps.newHashMap();
private final Map<String, TagKey<Item>> itemTags = Maps.newHashMap();
private final Map<String, Block> blocks = Maps.newHashMap();
private final Map<String, Item> items = Maps.newHashMap();

View file

@ -1,6 +1,5 @@
package ru.bclib.integration;
import net.fabricmc.fabric.api.tag.TagFactory;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
@ -9,7 +8,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tags.Tag.Named;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
@ -197,18 +196,18 @@ public abstract class ModIntegration {
return null;
}
public Tag.Named<Item> getItemTag(String name) {
public TagKey<Item> getItemTag(String name) {
ResourceLocation id = getID(name);
Tag<Item> tag = ItemTags.getAllTags().getTag(id);
//return tag == null ? (Named<Item>) TagRegistry.item(id) : (Named<Item>) tag;
return tag == null ? (Named<Item>) TagFactory.ITEM.create(id) : (Named<Item>) tag;
//return tag == null ? (TagKey<Item>) TagRegistry.item(id) : (TagKey<Item>) tag;
return tag == null ? (TagKey<Item>) TagFactory.ITEM.create(id) : (TagKey<Item>) tag;
}
public Tag.Named<Block> getBlockTag(String name) {
public TagKey<Block> getBlockTag(String name) {
ResourceLocation id = getID(name);
Tag<Block> tag = BlockTags.getAllTags().getTag(id);
//return tag == null ? (Named<Block>) TagRegistry.block(id) : (Named<Block>) tag;
return tag == null ? (Named<Block>) TagFactory.BLOCK.create(id) : (Named<Block>) tag;
return tag == null ? (TagKey<Block>) TagFactory.BLOCK.create(id) : (TagKey<Block>) tag;
}
}

View file

@ -0,0 +1,8 @@
package ru.bclib.interfaces;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.structure.StructureSet;
public interface ChunkGeneratorAccessor {
Registry<StructureSet> bclib_getStructureSetsRegistry();
}

View file

@ -4,7 +4,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.FallbackResourceManager;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -18,36 +17,37 @@ import ru.bclib.client.render.EmissiveTextureInfo;
import java.io.IOException;
import java.util.Map;
@Mixin(SimpleReloadableResourceManager.class)
public class SimpleReloadableResourceManagerMixin {
@Final
@Shadow
private Map<String, FallbackResourceManager> namespacedPacks;
private ResourceLocation bclib_alphaEmissionMaterial = BCLib.makeID("materialmaps/block/alpha_emission.json");
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
private void bclib_getResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Resource> info) throws IOException {
if (!ModIntegrationAPI.hasCanvas()) {
return;
}
if (!resourceLocation.getPath().startsWith("materialmaps")) {
return;
}
if (!resourceLocation.getPath().contains("/block/")) {
return;
}
String name = resourceLocation.getPath().replace("materialmaps/block/", "").replace(".json", "");
ResourceLocation blockID = new ResourceLocation(resourceLocation.getNamespace(), name);
if (!EmissiveTextureInfo.isEmissiveBlock(blockID)) {
return;
}
ResourceManager resourceManager = this.namespacedPacks.get(resourceLocation.getNamespace());
if (resourceManager != null && !resourceManager.hasResource(resourceLocation)) {
info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial));
}
}
}
//TODO: 1.18.2 Disabled to have a compilable Version
//@Mixin(SimpleReloadableResourceManager.class)
//public class SimpleReloadableResourceManagerMixin {
// @Final
// @Shadow
// private Map<String, FallbackResourceManager> namespacedPacks;
//
// private ResourceLocation bclib_alphaEmissionMaterial = BCLib.makeID("materialmaps/block/alpha_emission.json");
//
// @Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
// private void bclib_getResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Resource> info) throws IOException {
// if (!ModIntegrationAPI.hasCanvas()) {
// return;
// }
// if (!resourceLocation.getPath().startsWith("materialmaps")) {
// return;
// }
// if (!resourceLocation.getPath().contains("/block/")) {
// return;
// }
//
// String name = resourceLocation.getPath().replace("materialmaps/block/", "").replace(".json", "");
// ResourceLocation blockID = new ResourceLocation(resourceLocation.getNamespace(), name);
//
// if (!EmissiveTextureInfo.isEmissiveBlock(blockID)) {
// return;
// }
//
// ResourceManager resourceManager = this.namespacedPacks.get(resourceLocation.getNamespace());
// if (resourceManager != null && !resourceManager.hasResource(resourceLocation)) {
// info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial));
// }
// }
//}

View file

@ -24,10 +24,10 @@ public interface BiomeGenerationSettingsAccessor {
void bclib_setFeatures(List<List<Supplier<PlacedFeature>>> value);
@Accessor("featureSet")
Set<PlacedFeature> bclib_getFeatureSet();
Supplier<Set<PlacedFeature>> bclib_getFeatureSet();
@Accessor("featureSet")
void bclib_setFeatureSet(Set<PlacedFeature> features);
void bclib_setFeatureSet(Supplier<Set<PlacedFeature>> features);
@Accessor("carvers")
Map<Carving, List<Supplier<ConfiguredWorldCarver<?>>>> bclib_getCarvers();

View file

@ -1,17 +1,23 @@
package ru.bclib.mixin.common;
import net.minecraft.core.Registry;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.structure.StructureSet;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.bclib.interfaces.ChunkGeneratorAccessor;
@Mixin(ChunkGenerator.class)
public class ChunkGeneratorMixin {
public class ChunkGeneratorMixin implements ChunkGeneratorAccessor {
@Shadow @Final protected Registry<StructureSet> structureSets;
private int bclib_featureIteratorSeed;
@ModifyArg(method = "applyBiomeDecoration", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/WorldgenRandom;setFeatureSeed(JII)V"))
@ -23,4 +29,8 @@ public class ChunkGeneratorMixin {
private void bclib_obBiomeGenerate(WorldGenLevel worldGenLevel, ChunkAccess chunkAccess, StructureFeatureManager structureFeatureManager, CallbackInfo ci) {
bclib_featureIteratorSeed = 0;
}
public Registry<StructureSet> bclib_getStructureSetsRegistry(){
return structureSets;
}
}

View file

@ -0,0 +1,21 @@
package ru.bclib.mixin.common;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
import java.util.function.Supplier;
@Mixin(DiggerItem.class)
public interface DiggerItemAccessor {
@Accessor("blocks")
@Mutable
TagKey<Block> bclib_getBlockTag();
}

View file

@ -2,7 +2,6 @@ package ru.bclib.mixin.common;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.FallbackResourceManager;
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -12,28 +11,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map;
@Mixin(SimpleReloadableResourceManager.class)
public class SimpleReloadableResourceManagerMixin {
@Final
@Shadow
private Map<String, FallbackResourceManager> namespacedPacks;
private static final String[] BCLIB_MISSING_RESOURCES = new String[] {
"dimension/the_end.json",
"dimension/the_nether.json",
"dimension_type/the_end.json",
"dimension_type/the_nether.json"
};
@Inject(method = "hasResource", at = @At("HEAD"), cancellable = true)
private void bclib_hasResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Boolean> info) {
if (resourceLocation.getNamespace().equals("minecraft")) {
for (String key: BCLIB_MISSING_RESOURCES) {
if (resourceLocation.getPath().equals(key)) {
info.setReturnValue(false);
return;
}
}
}
}
}
//TODO: 1.18.2 Disabled to have a compilable Version
//@Mixin(SimpleReloadableResourceManager.class)
//public class SimpleReloadableResourceManagerMixin {
// @Final
// @Shadow
// private Map<String, FallbackResourceManager> namespacedPacks;
//
// private static final String[] BCLIB_MISSING_RESOURCES = new String[] {
// "dimension/the_end.json",
// "dimension/the_nether.json",
// "dimension_type/the_end.json",
// "dimension_type/the_nether.json"
// };
//
// @Inject(method = "hasResource", at = @At("HEAD"), cancellable = true)
// private void bclib_hasResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Boolean> info) {
// if (resourceLocation.getNamespace().equals("minecraft")) {
// for (String key: BCLIB_MISSING_RESOURCES) {
// if (resourceLocation.getPath().equals(key)) {
// info.setReturnValue(false);
// return;
// }
// }
// }
// }
//}

View file

@ -1,32 +0,0 @@
package ru.bclib.mixin.common;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.StructureSettings;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.StructureFeatureConfiguration;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Map;
@Mixin(StructureSettings.class)
public interface StructureSettingsAccessor {
@Accessor("configuredStructures")
ImmutableMap<StructureFeature<?>, ImmutableMultimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> bcl_getConfiguredStructures();
@Accessor("structureConfig")
Map<StructureFeature<?>, StructureFeatureConfiguration> bcl_getStructureConfig();
@Accessor("configuredStructures")
@Mutable
void bcl_setConfiguredStructures(ImmutableMap<StructureFeature<?>, ImmutableMultimap<ConfiguredStructureFeature<?, ?>, ResourceKey<Biome>>> configuredStructures);
@Accessor("structureConfig")
@Mutable
void bcl_setStructureConfig(Map<StructureFeature<?>, StructureFeatureConfiguration> structureConfig);
}

View file

@ -1,5 +1,6 @@
package ru.bclib.mixin.common;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.chunk.ChunkAccess;
@ -25,10 +26,7 @@ public interface SurfaceRulesContextAccessor {
int getSurfaceDepth();
@Accessor("biome")
Supplier<Biome> getBiome();
@Accessor("biomeKey")
Supplier<ResourceKey<Biome>> getBiomeKey();
Supplier<Holder<Biome>> getBiome();
@Accessor("chunk")
ChunkAccess getChunk();

View file

@ -13,7 +13,6 @@
"NoiseGeneratorSettingsMixin",
"SurfaceRulesContextAccessor",
"shears.TripWireBlockMixin",
"StructureSettingsAccessor",
"MobSpawnSettingsAccessor",
"shears.BeehiveBlockMixin",
"shears.PumpkinBlockMixin",
@ -21,6 +20,7 @@
"ComposterBlockAccessor",
"PotionBrewingAccessor",
"RecipeManagerAccessor",
"DiggerItemAccessor",
"shears.SnowGolemMixin",
"EnchantmentMenuMixin",
"MinecraftServerMixin",