Here's yet another snapshot where the advertised changes make up less than 30% of overall changes...
fabric-biome-api-v1 and fabric-data-generation-api-v1 received breaking changes.
We all knew the builtin registries were dying. Now they're dead. Or, sort of.
Since the builtin registry was no longer used for anything other than datagen, they decided to yeet the BuiltinRegistries altogether. Instead, they added a whole new classes and stuff:
- The game no longer creates a built-in
RegistryorDynamicRegistryManager. They now only exist as part of the combined registry bound to a server instance/client session. - Remember
CommandRegistryWrapper? It was made a generic wrapper of a registry,RegistryWrapper. Also, there'sRegistryWrapper.WrapperLookupwhich works like the oldDynamicRegistryManager- a lookup of registries. This is now passed to datagen providers. RegistryEntryLookup, which is an interface to look up the entry (list) fromRegistryKeyorTagKey. This mostly replaced directRegistryaccess for DRM-managed registry lookups. You can also get this fromRegistry#getReadOnlyWrapperorgetTagCreatingWrapper(corresponding to theCommandRegistryAccesspolicies).- Inner interface
RegistryEntryLookup.RegistryLookupdescribes the lookup for registries. RegistryEntryandRegistryEntryListare owned by an "owner" object. Previously it was always owned by a registry.RegistryBuilder, a big class that builds the builtin registry for use by datagen. (RegistryLoaderis still responsible for in-game loading of JSON files.) This validates the registry and builds a registry wrapper of registries added viaaddRegistrymethod, calling thebootstrapmethod to fill them with vanilla values in between.Registerable, something that a builtin value is registered to. This can be seen inbootstrapmethods (oldinitAndGetDefault).BuiltinRegistriesis now just a holder ofstatic final RegistryBuilder REGISTRY_BUILDER. It also has some registry specific validations.RegistryOpsreceivedgetEntryCodecandgetEntryLookupCodec.
Example of vanilla registration code (note, you shouldn't mixin to this, use JSON):
class StuffKeys {
public static void bootstrap(Registerable<Stuff> stuffRegisterable) {
stuffRegisterable.register(KEY_1, new Stuff());
// You can get lookups here too, but it might not be initialized:
RegistryEntryLookup<Stuff> lookup = stuffRegisterable.getRegistryLookup(STUFF_KEY);
}
}Using RegistryEntryLookup:
RegistryEntryLookup<Block> blockLookup = Registry.BLOCK.getReadOnlyWrapper();
Optional<Block> randomBlock = blockLookup.getOptional(BlockTags.PLANKS).flatMap(entry -> entry.getRandom(random)).map(RegistryEntry::value);
// Throws if dirt is not present
RegistryEntry<Block> dirt = blockLookup.getOrThrow(RegistryKey.of(Registry.BLOCK_KEY), new Identifier("minecraft:dirt"));All providers now take CompletableFuture<WrapperLookup> argument in the constructor. There is a new FabricWorldgenProvider to generate dynamic registry objects:
public class MyModWorldgenProvider extends FabricWorldgenProvider {
public WorldgenProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}
@Override
protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) {
// GenerationSettings.Builder takes RegistryEntryLookup for PlacedFeature and ConfiguredCarver
// which you can get via entries.placedFeatures and entries.configuredCarvers respectively
Biome biome = ...;
entries.add(MyMod.BIOME_KEY, biome);
// Use entries.ref to get a reference registry entry for use by other objects
}
}ItemStack#copyWithCount, which copies the stack with the given stack count.EquipmentSlot#isArmorSlot, which returns whether a slot is for armors.MobEntity#getSlotToEquip, which returns the slot that an item stack should be equipped to.StackMappingInventory, which represents an overly complicated chiseled bookshelf inventory.World#createExplosionoverload that allows particles to be toggled on or off.World.ExplosionSourceType, which is an enum representing the source of the explosion for game rule based drop-rate determination.GenerationSettings.BuilderandLookupBackedBuilder, where the former requires feature entries while the latter allows use of feature keys.Explosion#shouldDestroy, which returns whether an explosion should destroy blocks.GeneratorOptions#parseSeed, which parses the given seed and, if empty, returnsgetRandomSeed.StructurePlacementCalculator, which calculates the positions of structures.ServerChunkManager#getStructurePlacementCalculatorandThreadedAnvilChunkStorage#StructurePlacementCalculatorto get the calculator.ClientPlayerEntity#canSprint, which returns whether a player can sprint.
HoglinStableDatais renamed toBastionHoglinStableData.initAndGetDefaultand similar methods (for DRM registry) are renamed tobootstrap.WorldgenProvideris renamed toDynamicRegistriesProvider.AbstractTagProvider.ObjectBuilderis renamed toProvidedTagBuilder.AxolotlSwimNavigationis renamed toAmphibiousSwimNavigation.- 22w43a had a last-minute renames for rendering related methods, mostly to fix mistakes.