Skip to content

Commit

Permalink
Move item filling quirk to correct vanilla location on 1.19+
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Aug 3, 2023
1 parent 33fa870 commit 72e3a11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
Expand Up @@ -3,11 +3,6 @@
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;
Expand All @@ -32,7 +27,6 @@ private void replaceSearchTrees(CallbackInfo ci) {
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<>());
Expand All @@ -46,14 +40,4 @@ private void replaceSearchTrees(CallbackInfo ci) {
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);
}
}
}
@@ -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;
Expand All @@ -16,7 +20,13 @@ public DummySearchTree() {

@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
Expand Down

0 comments on commit 72e3a11

Please sign in to comment.