1717import net .minecraft .client .gui .screen .ingame .CraftingScreen ;
1818import net .minecraft .client .gui .screen .ingame .HandledScreen ;
1919import net .minecraft .component .DataComponentTypes ;
20- import net .minecraft .component .type .MapIdComponent ;
2120import net .minecraft .item .FilledMapItem ;
2221import net .minecraft .item .ItemStack ;
23- import net .minecraft .item .Items ;
2422import net .minecraft .item .map .MapState ;
2523import net .minecraft .screen .slot .Slot ;
2624import net .minecraft .text .MutableText ;
@@ -48,7 +46,8 @@ public static boolean isInInvAndContainer(UUID colorsId){
4846 private static final List <ItemStack > getAllMapItemsInContainer (List <Slot > slots ){
4947 final List <Slot > containerSlots = slots .subList (0 , slots .size ()-36 );
5048 return InvUtils .getAllNestedItems (containerSlots .stream ().map (Slot ::getStack ))
51- .filter (s -> s .getItem () == Items .FILLED_MAP )
49+ // .filter(s -> s.getItem() == Items.FILLED_MAP)
50+ .filter (s -> s .get (DataComponentTypes .MAP_ID ) != null )
5251 .toList ();
5352 }
5453 private static final boolean mixedOnDisplayAndNotOnDisplay (List <UUID > nonFillerIds ){
@@ -75,16 +74,16 @@ public static final void onTickStart(MinecraftClient client){
7574 }
7675 final boolean renderAsterisks = Configs .Visuals .MAP_HIGHLIGHT_CONTAINER_NAME .getBooleanValue ();
7776
78- final List <ItemStack > items = getAllMapItemsInContainer (hs .getScreenHandler ().slots );
77+ final List <ItemStack > mapItems = getAllMapItemsInContainer (hs .getScreenHandler ().slots );
7978
80- mapsInContainerHash = hs .getScreenHandler ().syncId + items .hashCode ();
79+ mapsInContainerHash = hs .getScreenHandler ().syncId + mapItems .hashCode ();
8180 final int currHash = UpdateInventoryHighlights .getMapInInvHash () + mapsInContainerHash ;
8281 if (lastHash == currHash ) return ;
8382 lastHash = currHash ;
8483// Main.LOGGER.info("ContainerHighlighter: Recomputing cache");
8584
86- if (items .isEmpty ()) return ;
87- final List <MapState > states = items .stream ().map (i -> FilledMapItem .getMapState (i , client .world )).filter (Objects ::nonNull ).toList ();
85+ if (mapItems .isEmpty ()) return ;
86+ final List <MapState > states = mapItems .stream ().map (i -> FilledMapItem .getMapState (i , client .world )).filter (Objects ::nonNull ).toList ();
8887 final List <UUID > nonTransparentIds = (!Configs .Generic .SKIP_VOID_MAPS .getBooleanValue () ? states .stream () :
8988 states .stream ().filter (s -> !MapColorUtils .isFullyTransparent (s .colors ))).map (MapGroupUtils ::getIdForMapState ).toList ();
9089
@@ -94,11 +93,8 @@ public static final void onTickStart(MinecraftClient client){
9493 if (!inContainerAndInInv .isEmpty ()) asterisks .add (Configs .Visuals .MAP_COLOR_IN_INV .getIntegerValue ());
9594 if (states .stream ().anyMatch (MapGroupUtils ::shouldHighlightNotInCurrentGroup )) asterisks .add (Configs .Visuals .MAP_COLOR_NOT_IN_GROUP .getIntegerValue ());
9695 if (states .stream ().anyMatch (s -> !s .locked )) asterisks .add (Configs .Visuals .MAP_COLOR_UNLOCKED .getIntegerValue ());
97- if (items .size () > states .size () + (!Configs .Generic .SKIP_NULL_MAPS .getBooleanValue () ? 0 : items .stream ().filter (stack -> {
98- // assert mapId != null;
99- MapIdComponent mapId = stack .get (DataComponentTypes .MAP_ID );
100- return mapId != null && MapGroupUtils .nullMapIds .contains (mapId .id ());
101- }).count ()
96+ if (mapItems .size () > states .size () + (!Configs .Generic .SKIP_NULL_MAPS .getBooleanValue () ? 0
97+ : mapItems .stream ().filter (stack -> MapGroupUtils .nullMapIds .contains (stack .get (DataComponentTypes .MAP_ID ).id ())).count ()
10298 )){
10399 asterisks .add (Configs .Visuals .MAP_COLOR_UNLOADED .getIntegerValue ());
104100 }
@@ -114,7 +110,7 @@ public static final void onTickStart(MinecraftClient client){
114110 uniqueIdsStream .filter (Predicate .not (uniqueMapIds ::add )).forEach (duplicatesInContainer ::add );
115111 if (renderAsterisks ){
116112 if (!duplicatesInContainer .isEmpty ()) asterisks .add (Configs .Visuals .MAP_COLOR_MULTI_CONTAINER .getIntegerValue ());
117- if (items .stream ().anyMatch (i -> i .getCustomName () == null )) asterisks .add (Configs .Visuals .MAP_COLOR_UNNAMED .getIntegerValue ());
113+ if (mapItems .stream ().anyMatch (i -> i .getCustomName () == null )) asterisks .add (Configs .Visuals .MAP_COLOR_UNNAMED .getIntegerValue ());
118114 }
119115
120116 if (renderAsterisks && !asterisks .isEmpty ()){
0 commit comments