Skip to content

Commit

Permalink
fix(1.20.6): Fix menu bytebuf on Forge
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed May 23, 2024
1 parent 6857832 commit f035f81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public class ForgeBalmMenus implements BalmMenus {
@Override
public <TMenu extends AbstractContainerMenu, TPayload> DeferredObject<MenuType<TMenu>> registerMenu(ResourceLocation identifier, BalmMenuFactory<TMenu, TPayload> factory) {
DeferredRegister<MenuType<?>> register = DeferredRegisters.get(ForgeRegistries.MENU_TYPES, identifier.getNamespace());
// TODO we have to create a RegistryFriendlyByteBuf ourselves because Forge is out of date
RegistryObject<MenuType<TMenu>> registryObject = register.register(identifier.getPath(),
() -> new MenuType<>((IContainerFactory<TMenu>) (syncId, inventory, buf) -> factory.create(syncId, inventory, factory.getStreamCodec().decode((RegistryFriendlyByteBuf) buf)),
() -> new MenuType<>((IContainerFactory<TMenu>) (syncId, inventory, buf) -> factory.create(syncId, inventory, factory.getStreamCodec().decode(new RegistryFriendlyByteBuf(buf, inventory.player.registryAccess()))),
FeatureFlagSet.of(FeatureFlags.VANILLA)));
return new DeferredObject<>(identifier, registryObject, registryObject::isPresent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public void openGui(Player player, MenuProvider menuProvider) {
}

private <T> void openGui(ServerPlayer player, BalmMenuProvider<T> menuProvider) {
player.openMenu(menuProvider, buf -> menuProvider.getScreenStreamCodec().encode((RegistryFriendlyByteBuf) buf, menuProvider.getScreenOpeningData(player)));
// TODO we have to create a RegistryFriendlyByteBuf ourselves because Forge is out of date
player.openMenu(menuProvider, buf -> menuProvider.getScreenStreamCodec().encode(new RegistryFriendlyByteBuf(buf, player.registryAccess()), menuProvider.getScreenOpeningData(player)));
}

@Override
Expand Down

0 comments on commit f035f81

Please sign in to comment.