@@ -136,13 +136,17 @@ default void renderComponentHoverEffect(GuiGraphics guiGraphics, @Nullable Style
136136 //TODO: we had a +1000 z translate here
137137 var newStyle = style ;
138138 if (style != null && style .getHoverEvent () != null ) {
139- if (style .getHoverEvent ().action () == HoverEvent .Action .SHOW_TEXT && style .getHoverEvent () instanceof HoverEvent .ShowText showText ) {
139+ if (style .getHoverEvent ().action () == HoverEvent .Action .SHOW_TEXT && style .getHoverEvent () instanceof HoverEvent .ShowText (
140+ Component oldComponent
141+ )) {
140142 var clickEvent = style .getClickEvent ();
141143 if (clickEvent != null ) {
142- if (clickEvent .action () == ClickEvent .Action .OPEN_FILE && clickEvent instanceof ClickEvent .OpenFile openFile ) {
144+ if (clickEvent .action () == ClickEvent .Action .OPEN_FILE && clickEvent instanceof ClickEvent .OpenFile (
145+ String path
146+ )) {
143147 //handle book links -> check if locked
144- if (BookLink .isBookLink (openFile . path () )) {
145- var link = BookLink .from (this .getBook (), openFile . path () );
148+ if (BookLink .isBookLink (path )) {
149+ var link = BookLink .from (this .getBook (), path );
146150 var book = BookDataManager .get ().getBook (link .bookId );
147151 if (link .entryId != null ) {
148152 var entry = book .getEntry (link .entryId );
@@ -156,7 +160,6 @@ default void renderComponentHoverEffect(GuiGraphics guiGraphics, @Nullable Style
156160 //handleComponentClicked will prevent the actual click
157161
158162 if (!BookUnlockStateManager .get ().isUnlockedFor (Minecraft .getInstance ().player , entry )) {
159- var oldComponent = showText .value ();
160163
161164 var newComponent = Component .translatable (
162165 ModonomiconConstants .I18n .Gui .HOVER_BOOK_LINK_LOCKED ,
@@ -175,7 +178,6 @@ default void renderComponentHoverEffect(GuiGraphics guiGraphics, @Nullable Style
175178
176179 newStyle = style .withHoverEvent (new HoverEvent .ShowText (newComponent ));
177180 } else if (page != null && !BookUnlockStateManager .get ().isUnlockedFor (Minecraft .getInstance ().player , entry .getPages ().get (page ))) {
178- var oldComponent = showText .value ();
179181
180182 var newComponent = Component .translatable (
181183 ModonomiconConstants .I18n .Gui .HOVER_BOOK_LINK_LOCKED ,
@@ -200,15 +202,15 @@ default void renderComponentHoverEffect(GuiGraphics guiGraphics, @Nullable Style
200202 }
201203 }
202204
203- if (clickEvent .action () == ClickEvent .Action .RUN_COMMAND && clickEvent instanceof ClickEvent .RunCommand runCommand ) {
204- if (CommandLink .isCommandLink (runCommand .command ())) {
205- var link = CommandLink .from (this .getBook (), runCommand .command ());
205+ if (clickEvent .action () == ClickEvent .Action .RUN_COMMAND && clickEvent instanceof ClickEvent .RunCommand (
206+ String command1
207+ )) {
208+ if (CommandLink .isCommandLink (command1 )) {
209+ var link = CommandLink .from (this .getBook (), command1 );
206210 var book = BookDataManager .get ().getBook (link .bookId );
207211 if (link .commandId != null ) {
208212 var command = book .getCommand (link .commandId );
209213
210- var oldComponent = showText .value ();
211-
212214 if (!BookUnlockStateManager .get ().canRunFor (Minecraft .getInstance ().player , command )) {
213215 var hoverComponent = Component .translatable (ModonomiconConstants .I18n .Gui .HOVER_COMMAND_LINK_UNAVAILABLE ).withStyle (ChatFormatting .RED );
214216 newStyle = style .withHoverEvent (new HoverEvent .ShowText (hoverComponent ));
0 commit comments