23w16a is here with tons of breaking changes. Yikes.
Fabric API received many breaking changes, specifically: Content Registries, Data Generation, Item Groups API, Object Builder, Rendering API, and Screen API. (Can you believe Screen API's patch version was 1.0.44 before the bump?)
VillagerPlantableRegistry was replaced with ItemTags.VILLAGER_PLANTABLE_SEEDS (data pack). For other changes, see below.
DrawableHelper, a utility interface that is frequently used by implementing it, turned into an object passed to rendering methods: DrawContext. This replaces the various MatrixStack matrices parameters. You usually do not need to construct one yourself.
- public void render(MatrixStack matrices) {
- RenderSystem.setShaderTexture(0, TEXTURE);
- drawTexture(matrices, ...);
+ public void render(DrawContext context) {
+ context.drawTexture(TEXTURE, ...); // texture ID is now specified hereThe following new methods were added to DrawContext, replacing other methods in various places:
setShaderColor(wrapsRenderSystemone, which still exists)drawTextWithShadow(replacesTextRenderer#drawWithShadow)drawText(wrapsTextRenderer#draw)drawTextWrappeddrawItemdrawItemWithoutEntitydrawItemInSlotdrawItemTooltipdrawTooltip(replacesScreen#renderTooltip)drawHoverEvent
In addition, various rendering methods now take DrawContext instead of MatrixStack. If you still somehow need the matrix stack, you can call DrawContext#getMatrices.
Fabric API changes related to this:
- Rendering API's
HudRenderCallback, Screen API'sScreenEvents.beforeRender, andScreenEvents.beforeRendernow takeDrawContextinstead ofMatrixStack. Screens.getItemRendereris removed. This can be easily replaced withMinecraftClient#getItemRenderer, although this is usually not necessary.
And one unrelated change: Screen#passEvents was removed. It seems like screens can no longer pass events.
ItemGroups are now registered in a registry. This means that the vanilla game tracks them using identifiers, just like blocks and items - and it is registered in the same way as those.
- public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder(new Identifier(MOD_ID, "example"))
- .icon(() -> new ItemStack(Items.DIAMOND_PICKAXE))
- .displayName(Text.translatable("example-mod.group.example"))
- .build();
+ public static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier(MOD_ID, "example"));
+
+ @Override
+ public void onInitialize() {
+ Registry.register(Registries.ITEM_GROUP, ITEM_GROUP, FabricItemGroup.builder()
+ .icon(() -> new ItemStack(Items.DIAMOND_PICKAXE))
+ .displayName(Text.translatable("example-mod.group.example"))
+ .build()); // build() no longer registers by itself
+ }Notice that FabricItemGroup#builder takes no arguments now, since the ID is assigned by the registry. Note, you must now call displayName manually or it will crash!
ItemGroupEvents.modifyEntriesEvent will now take RegistryKey<ItemGroup> instead of ItemGroup or Identifier. Note that vanilla ItemGroups fields are now registry keys, so those code just needs to be recompiled. And with the game now providing the identifier, IdentifiableItemGroup is removed.
Finally, one small breaking change to Data Generation: FabricLanguageProvider.TranslationBuilder#add will now take RegistryKey<ItemGroup> instead of ItemGroup.
In case you weren't aware: Material class will be dead soon. In this snapshot, almost all Material fields have been moved to block settings (and therefore BlockState).
The following block settings were added:
solid- forces a block to be solidnotSolid- forces a block to be not solidinstrument- specifies note block instrumentreplaceable- specifies that the block is replaceable
If a block is not specified as solid or not solid explicitly, then the game checks whether the shape's average side length is more than 0.73 OR whether the block is taller than 1 block. If either is true, the block is solid.
BlockState received isSolid and getInstrument methods, as well as blocksMovement - whether a block is solid and is not cobweb/bamboo shoot. Yes, it is hardcoded.
Since there is no value in building a new material, FabricMaterialBuilder is removed.
Cropinterface was removed and replaced with a block tag,maintains_farmland.
SplashTextResourceSupplier#getnow returnsSplashTextRenderer, notString.- Public
ItemStackconstructor no longer acceptsnull. - Vibration frequencies are now stored in
Vibrations, instead ofVibrationListener.
CraftingInventory#getInputStacksto get the input item stacks.PublicPlayerSession#isKeyExpiredto check whether the public key is expired.