Move item filling quirk to correct vanilla location on 1.19+

This commit is contained in:
embeddedt 2023-08-03 13:07:34 -04:00
parent 33fa870f04
commit 72e3a115d6
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 11 additions and 17 deletions

View File

@ -3,11 +3,6 @@ package org.embeddedt.modernfix.common.mixin.perf.blast_search_trees;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.searchtree.SearchRegistry;
import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.embeddedt.modernfix.ModernFix;
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
import org.embeddedt.modernfix.searchtree.DummySearchTree;
@ -32,7 +27,6 @@ public class MinecraftMixin {
if(provider == null)
return;
ModernFix.LOGGER.info("Replacing search trees with '{}' provider", provider.getName());
mfix$runItemFillingQuirk();
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, list -> provider.getSearchTree(false));
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> provider.getSearchTree(true));
this.searchRegistry.register(SearchRegistry.RECIPE_COLLECTIONS, list -> new DummySearchTree<>());
@ -46,14 +40,4 @@ public class MinecraftMixin {
GLFW.glfwSetErrorCallback(oldCb);
ci.cancel();
}
private void mfix$runItemFillingQuirk() {
// quirk: call fillItemCategory on all items in the registry in case they do classloading inside it
// see https://github.com/Shadows-of-Fire/GatewaysToEternity/issues/29 for an example of this
NonNullList<ItemStack> stacks = NonNullList.create();
for(Item item : Registry.ITEM) {
stacks.clear();
item.fillItemCategory(CreativeModeTab.TAB_SEARCH, stacks);
}
}
}

View File

@ -1,6 +1,10 @@
package org.embeddedt.modernfix.searchtree;
import net.minecraft.client.searchtree.RefreshableSearchTree;
import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import java.util.Collections;
@ -16,7 +20,13 @@ public class DummySearchTree<T> implements RefreshableSearchTree<T> {
@Override
public void refresh() {
// quirk: call fillItemCategory on all items in the registry in case they do classloading inside it
// see https://github.com/Shadows-of-Fire/GatewaysToEternity/issues/29 for an example of this
NonNullList<ItemStack> stacks = NonNullList.create();
for(Item item : Registry.ITEM) {
stacks.clear();
item.fillItemCategory(CreativeModeTab.TAB_SEARCH, stacks);
}
}
@Override