77import com .ldtteam .structurize .Network ;
88import com .ldtteam .structurize .api .util .constant .Constants ;
99import com .ldtteam .structurize .blockentities .interfaces .IBlueprintDataProviderBE ;
10+ import com .ldtteam .structurize .blocks .interfaces .IAnchorBlock ;
1011import com .ldtteam .structurize .items .ItemTagTool ;
1112import com .ldtteam .structurize .network .messages .AddRemoveTagMessage ;
1213import com .ldtteam .structurize .network .messages .SetTagInTool ;
1314import com .ldtteam .structurize .util .BlockUtils ;
15+ import com .ldtteam .structurize .util .TagManager ;
1416import net .minecraft .client .Minecraft ;
1517import net .minecraft .network .chat .Component ;
1618import net .minecraft .world .item .ItemStack ;
2022
2123import java .util .*;
2224
23- import static com .ldtteam .structurize .api .util .constant .Constants .GROUNDLEVEL_TAG ;
24-
2525public class WindowTagTool extends AbstractWindowSkeleton
2626{
27- /**
28- * List of tag options. Mods can just insert on this in mod constructor.
29- */
30- public static List <String > TAG_OPTIONS = new ArrayList <>();
31-
32- static
33- {
34- TAG_OPTIONS .add (GROUNDLEVEL_TAG );
35- }
36-
3727 private static final String WINDOW_TAG_TOOL = ":gui/windowtagtool.xml" ;
3828 private static final String INPUT_FIELD = "currentTag" ;
3929 private static final String LIST_TAG_POS = "tagposlist" ;
@@ -75,12 +65,16 @@ public class WindowTagTool extends AbstractWindowSkeleton
7565 */
7666 private List <BlockPos > positionsList = Collections .emptyList ();
7767
78-
7968 /**
8069 * The tags list
8170 */
8271 private ScrollingList tagOptionList ;
8372
73+ /**
74+ * Tag options.
75+ */
76+ private List <String > tagOptions = new ArrayList <>();
77+
8478 /**
8579 * Constructor for the skeleton class of the windows.
8680 */
@@ -92,13 +86,23 @@ public WindowTagTool(String currentTag, BlockPos anchorPos, final Level world, f
9286 this .anchorPos = anchorPos ;
9387 this .stack = stack ;
9488
89+ tagOptions .addAll (TagManager .getGlobalTagOptions ());
90+
91+ if (anchorPos != null )
92+ {
93+ final BlockEntity blockEntity = world .getBlockEntity (anchorPos );
94+ if (blockEntity instanceof IAnchorBlock anchorBlock )
95+ {
96+ tagOptions .addAll (TagManager .getMatchingTagOptions (anchorBlock ));
97+ }
98+ }
9599 registerButton (TAG_SELECT , this ::tagOptionSelected );
96100 }
97101
98102 private void tagOptionSelected (final Button button )
99103 {
100104 final int row = tagOptionList .getListElementIndexByPane (button );
101- this .currentTag = TAG_OPTIONS .get (row );
105+ this .currentTag = tagOptions .get (row );
102106 findPaneOfTypeByID (INPUT_FIELD , TextField .class ).setText (currentTag );
103107 }
104108
@@ -238,19 +242,19 @@ public void updateTagOptionList()
238242 @ Override
239243 public int getElementCount ()
240244 {
241- return TAG_OPTIONS .size ();
245+ return tagOptions .size ();
242246 }
243247
244248 @ Override
245249 public void updateElement (final int index , final Pane rowPane )
246250 {
247251 final Text tagsText = rowPane .findPaneOfTypeByID (TAG_TEXT , Text .class );
248- tagsText .setText (Component .literal (TAG_OPTIONS .get (index )));
252+ tagsText .setText (Component .literal (tagOptions .get (index )));
249253 PaneBuilders .tooltipBuilder ().hoverPane (tagsText ).build ()
250- .setText (Component .translatable ("com.ldtteam.tag.tooltip." + TAG_OPTIONS .get (index )));
254+ .setText (Component .translatable ("com.ldtteam.tag.tooltip." + tagOptions .get (index )));
251255
252256 final Button button = rowPane .findPaneOfTypeByID (TAG_SELECT , Button .class );
253- button .setEnabled (!TAG_OPTIONS .get (index ).equals (currentTag ));
257+ button .setEnabled (!tagOptions .get (index ).equals (currentTag ));
254258 }
255259 });
256260 }
0 commit comments