Skip to content

Instantly share code, notes, and snippets.

@apple502j
Created April 22, 2023 13:59
Show Gist options
  • Save apple502j/3f46f097b2187bbcca0c6d6ef1ad210a to your computer and use it in GitHub Desktop.
Save apple502j/3f46f097b2187bbcca0c6d6ef1ad210a to your computer and use it in GitHub Desktop.

23w16a: Screen Update

23w16a is here with tons of breaking changes. Yikes.

Fabric changes

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.

Minecraft changes

Screen and rendering

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 here

The following new methods were added to DrawContext, replacing other methods in various places:

  • setShaderColor (wraps RenderSystem one, which still exists)
  • drawTextWithShadow (replaces TextRenderer#drawWithShadow)
  • drawText (wraps TextRenderer#draw)
  • drawTextWrapped
  • drawItem
  • drawItemWithoutEntity
  • drawItemInSlot
  • drawItemTooltip
  • drawTooltip (replaces Screen#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's ScreenEvents.beforeRender, and ScreenEvents.beforeRender now take DrawContext instead of MatrixStack.
  • Screens.getItemRenderer is removed. This can be easily replaced with MinecraftClient#getItemRenderer, although this is usually not necessary.

And one unrelated change: Screen#passEvents was removed. It seems like screens can no longer pass events.

Item Group Registry

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.

Material changes

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 solid
  • notSolid - forces a block to be not solid
  • instrument - specifies note block instrument
  • replaceable - 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.

Removals

  • Crop interface was removed and replaced with a block tag, maintains_farmland.

Changes

  • SplashTextResourceSupplier#get now returns SplashTextRenderer, not String.
  • Public ItemStack constructor no longer accepts null.
  • Vibration frequencies are now stored in Vibrations, instead of VibrationListener.

Additions

  • CraftingInventory#getInputStacks to get the input item stacks.
  • PublicPlayerSession#isKeyExpired to check whether the public key is expired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment