Skip to content

Commit c75092f

Browse files
committed
Clear creative tab parameter cache after search order refresh
1 parent e3ecc26 commit c75092f

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

common/src/main/java/dev/terminalmc/clientsort/client/order/CreativeSearchOrder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import dev.terminalmc.clientsort.client.ClientSort;
2121
import dev.terminalmc.clientsort.client.config.Config;
22+
import dev.terminalmc.clientsort.mixin.client.accessor.CreativeModeTabsAccessor;
2223
import it.unimi.dsi.fastutil.objects.Object2IntMap;
2324
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
2425
import net.minecraft.client.Minecraft;
@@ -94,9 +95,8 @@ private static void refreshStackPositionMap() {
9495
return;
9596
}
9697
FeatureFlagSet enabledFeatures = mc.level.enabledFeatures();
97-
boolean opTab = mc.player.canUseGameMasterBlocks() && mc.options.operatorItemsTab().get();
9898

99-
CreativeModeTabs.tryRebuildTabContents(enabledFeatures, !opTab, mc.level.registryAccess());
99+
CreativeModeTabs.tryRebuildTabContents(enabledFeatures, true, mc.level.registryAccess());
100100

101101
Collection<ItemStack> displayStacks =
102102
new ArrayList<>(CreativeModeTabs.searchTab().getDisplayItems());
@@ -123,5 +123,7 @@ private static void refreshStackPositionMap() {
123123
lock.unlock();
124124
}, ClientSort.MOD_NAME + ": creative search stack position lookup builder"
125125
).start();
126+
127+
CreativeModeTabsAccessor.setCachedParameters(null);
126128
}
127129
}

common/src/main/java/dev/terminalmc/clientsort/mixin/client/LocalPlayerMixin.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import dev.terminalmc.clientsort.client.interaction.InteractionManager;
2222
import dev.terminalmc.clientsort.client.order.CreativeSearchOrder;
2323
import net.minecraft.client.player.LocalPlayer;
24-
import net.minecraft.world.level.GameType;
2524
import org.spongepowered.asm.mixin.Mixin;
2625
import org.spongepowered.asm.mixin.injection.At;
2726
import org.spongepowered.asm.mixin.injection.Inject;
@@ -52,12 +51,4 @@ private void afterPermissionLevelChange(int level, CallbackInfo ci) {
5251
CreativeSearchOrder.tryRefreshStackPositionMap();
5352
}
5453
}
55-
56-
@Inject(
57-
method = "onGameModeChanged",
58-
at = @At("RETURN")
59-
)
60-
private void afterGameModeChange(GameType gameMode, CallbackInfo ci) {
61-
CreativeSearchOrder.tryRefreshStackPositionMap();
62-
}
6354
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2025 TerminalMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package dev.terminalmc.clientsort.mixin.client.accessor;
18+
19+
import net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters;
20+
import net.minecraft.world.item.CreativeModeTabs;
21+
import org.spongepowered.asm.mixin.Mixin;
22+
import org.spongepowered.asm.mixin.gen.Accessor;
23+
24+
@Mixin(CreativeModeTabs.class)
25+
public interface CreativeModeTabsAccessor {
26+
27+
@Accessor("CACHED_PARAMETERS")
28+
static void setCachedParameters(ItemDisplayParameters parameters) {
29+
throw new UnsupportedOperationException();
30+
}
31+
}

common/src/main/resources/clientsort.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"client.MinecraftMixin",
1717
"client.ScreenMixin",
1818
"client.accessor.AbstractContainerScreenAccessor",
19+
"client.accessor.CreativeModeTabsAccessor",
1920
"client.accessor.KeyMappingAccessor",
2021
"client.accessor.ScreenAccessor",
2122
"client.compat.emi.ReloadWorkerMixin",

0 commit comments

Comments
 (0)