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
Registry
orDynamicRegistryManager
. 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.WrapperLookup
which 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) fromRegistryKey
orTagKey
. This mostly replaced directRegistry
access for DRM-managed registry lookups. You can also get this fromRegistry#getReadOnlyWrapper
orgetTagCreatingWrapper
(corresponding to theCommandRegistryAccess
policies).- Inner interface
RegistryEntryLookup.RegistryLookup
describes the lookup for registries. RegistryEntry
andRegistryEntryList
are 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. (RegistryLoader
is still responsible for in-game loading of JSON files.) This validates the registry and builds a registry wrapper of registries added viaaddRegistry
method, calling thebootstrap
method to fill them with vanilla values in between.Registerable
, something that a builtin value is registered to. This can be seen inbootstrap
methods (oldinitAndGetDefault
).BuiltinRegistries
is now just a holder ofstatic final RegistryBuilder REGISTRY_BUILDER
. It also has some registry specific validations.RegistryOps
receivedgetEntryCodec
andgetEntryLookupCodec
.
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#createExplosion
overload 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.Builder
andLookupBackedBuilder
, 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#getStructurePlacementCalculator
andThreadedAnvilChunkStorage#StructurePlacementCalculator
to get the calculator.ClientPlayerEntity#canSprint
, which returns whether a player can sprint.
HoglinStableData
is renamed toBastionHoglinStableData
.initAndGetDefault
and similar methods (for DRM registry) are renamed tobootstrap
.WorldgenProvider
is renamed toDynamicRegistriesProvider
.AbstractTagProvider.ObjectBuilder
is renamed toProvidedTagBuilder.
AxolotlSwimNavigation
is renamed toAmphibiousSwimNavigation
.- 22w43a had a last-minute renames for rendering related methods, mostly to fix mistakes.