Skip to content

GenPOI fixes w/ Backwards Compatibility

Pre-release
Pre-release
Compare
Choose a tag to compare
@Gregory-AM Gregory-AM released this 10 Jul 15:29
· 148 commits to main since this release

GenPOI signFilter Function for Configuration Files

def signFilter(poi):
    # Default Sign Filter Function (pre v1.20)
    if poi['id'] == 'Sign' or poi['id'] == 'minecraft:sign':
        if 'Text1' in poi:
            text_lines = [line for line in [poi['Text1'], poi['Text2'], poi['Text3'], poi['Text4']] if line.strip()]
        else:
           # v1.20+ Sign Filter
            text_lines = []
            front_text = poi.get('front_text', {})
            back_text = poi.get('back_text', {})
            text_lines.extend(line for line in front_text.get('messages', []) if line.strip())
            text_lines.extend(line for line in back_text.get('messages', []) if line.strip())
        return '\n'.join(text_lines)
# Specifically for v1.20 Worlds
def signFilter(poi):
    if poi['id'] == 'Sign' or poi['id'] == 'minecraft:sign':
        text_lines = []
        front_text = poi.get('front_text', {})
        back_text = poi.get('back_text', {})
        text_lines.extend(line for line in front_text.get('messages', []) if line.strip())
        text_lines.extend(line for line in back_text.get('messages', []) if line.strip())
        return "\n".join(text_lines)
# Specifically for Worlds before v1.20
def signFilter(poi):
    if poi['id'] == 'Sign' or poi['id'] == 'minecraft:sign':
        return "\n".join([poi['Text1'], poi['Text2'], poi['Text3'], poi['Text4']])

Since the "\n" does not produce a new line.
you can change this out with "<br>" ( HTML Line Break ).

Using <br> DOES NOT work with:

global escape <- This
from html import escape <- This
def signFilter(poi):
    if poi['id'] == 'Sign' or poi['id'] == 'minecraft:sign':
     AND This -> return escape("\n".join([poi['Text1'], poi['Text2'], poi['Text3'], poi['Text4']]))

This is because it escapes all HTML and JavaScript code, causing it to render as text.