Skip to content

Commit

Permalink
fix(bot): 🩹 resolve dimension translation text in 1.19 (resolve #210)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnzhiZhang committed Aug 26, 2024
1 parent b60d8c1 commit bf62e74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
14 changes: 0 additions & 14 deletions src/bot/bot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ class DIMENSION:
THE_NETHER = -1
THE_END = 1

DISPLAY_TRANSLATION = {
0: RTextTranslation(
'createWorld.customize.preset.overworld',
color=RColor.green
),
-1: RTextTranslation(
'advancements.nether.root.title',
color=RColor.dark_red
),
1: RTextTranslation(
'advancements.end.root.title',
color=RColor.light_purple
)
}
STR_TRANSLATION = {
0: 'minecraft:overworld',
-1: 'minecraft:the_nether',
Expand Down
23 changes: 18 additions & 5 deletions src/bot/bot/location.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List, Dict, Any

from mcdreforged.api.rtext import RTextTranslation
import minecraft_data_api as api
from mcdreforged.api.rtext import RText, RColor

from bot.constants import DIMENSION

Expand Down Expand Up @@ -33,12 +34,24 @@ def str_dimension(self) -> str:
return DIMENSION.STR_TRANSLATION[self.dimension]

@property
def display_dimension(self) -> RTextTranslation:
def display_dimension(self) -> RText:
"""
Get RTextTranslation dimension to display.
:return: RTextTranslation.
Get dimension RText to display.
:return: RText.
"""
return DIMENSION.DISPLAY_TRANSLATION[self.dimension]
# get translation
translation: RText = api.get_dimension_translation_text(self.dimension)

# set color
if self.dimension == DIMENSION.OVERWORLD:
translation.set_color(RColor.green)
elif self.dimension == DIMENSION.THE_NETHER:
translation.set_color(RColor.dark_red)
elif self.dimension == DIMENSION.THE_END:
translation.set_color(RColor.light_purple)

# return
return translation

@staticmethod
def from_dict(data: Dict[str, Any]) -> 'Location':
Expand Down

0 comments on commit bf62e74

Please sign in to comment.