Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi, thanks for taking the time to read my question.


I'm trying to emulate a custom FontRenderer. I say emulate because I don't want to create a custom FontRenderer, I just want to parse text into sections, then render those with the default FontRenderer. Normally that would be no problem, but in my case it's complicated by the fact that a TextComponent includes no way to get style data that I can modify (Or at least that I know of, hopefully the answers will shed some light on this). To simplify my general problem with a single question;

How could I get the string (including style codes) of a TextComponent?

What I'm hoping to achieve is get the string of a TextComponent, say "Player has made the advancement [Hot Stuff]" as "Player has made the advancement [§aHot Stuff]"

I've tried looking at the Style class, the problem here is I can't get the style for a specific part of a string

 

Thanks for reading my question

- ConsumerJunk

All ITextProperties (which TextComponent extend) holds a method called getString which should do this for you iirc. If that doesn't work, you can always use one of the components that return an optional of the specific IStyledTextAcceptor passed in. However, you should look into using IReordingProcessor in some fashion similarly to FontRenderer for support in different languages. Worst case scenario, you get the JSON conversion of the specific text component and parse from there.

  • Guest locked and unlocked this topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.