Skip to content

Instantly share code, notes, and snippets.

@apple502j
Last active November 10, 2022 05:13
Show Gist options
  • Save apple502j/e496ca3cd75dc47742362e9d328d34e5 to your computer and use it in GitHub Desktop.
Save apple502j/e496ca3cd75dc47742362e9d328d34e5 to your computer and use it in GitHub Desktop.
22w44a changelog

22w44a: Every Week's a DataGen Update

Here's yet another snapshot where the advertised changes make up less than 30% of overall changes...

Fabric API

fabric-biome-api-v1 and fabric-data-generation-api-v1 received breaking changes.

Changes

RIP BuiltinRegistries??

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 or DynamicRegistryManager. 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's RegistryWrapper.WrapperLookup which works like the old DynamicRegistryManager - a lookup of registries. This is now passed to datagen providers.
  • RegistryEntryLookup, which is an interface to look up the entry (list) from RegistryKey or TagKey. This mostly replaced direct Registry access for DRM-managed registry lookups. You can also get this from Registry#getReadOnlyWrapper or getTagCreatingWrapper (corresponding to the CommandRegistryAccess policies).
  • Inner interface RegistryEntryLookup.RegistryLookup describes the lookup for registries.
  • RegistryEntry and RegistryEntryList 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 via addRegistry method, calling the bootstrap method to fill them with vanilla values in between.
  • Registerable, something that a builtin value is registered to. This can be seen in bootstrap methods (old initAndGetDefault).
  • BuiltinRegistries is now just a holder of static final RegistryBuilder REGISTRY_BUILDER. It also has some registry specific validations.
  • RegistryOps received getEntryCodec and getEntryLookupCodec.

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"));

Data generation changes

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
    }
}

New classes, methods, and fields

  • 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 and LookupBackedBuilder, 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, returns getRandomSeed.
  • StructurePlacementCalculator, which calculates the positions of structures.
  • ServerChunkManager#getStructurePlacementCalculator and ThreadedAnvilChunkStorage#StructurePlacementCalculator to get the calculator.
  • ClientPlayerEntity#canSprint, which returns whether a player can sprint.

Renames

  • HoglinStableData is renamed to BastionHoglinStableData.
  • initAndGetDefault and similar methods (for DRM registry) are renamed to bootstrap.
  • WorldgenProvider is renamed to DynamicRegistriesProvider.
  • AbstractTagProvider.ObjectBuilder is renamed to ProvidedTagBuilder.
  • AxolotlSwimNavigation is renamed to AmphibiousSwimNavigation.
  • 22w43a had a last-minute renames for rendering related methods, mostly to fix mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment