temporary workaround for threading issue with REI async search (#2386)
This commit is contained in:
parent
584e822fa3
commit
20317f20ec
1 changed files with 9 additions and 2 deletions
|
@ -27,6 +27,7 @@ package techreborn.events;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
|
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.item.TooltipContext;
|
import net.minecraft.client.item.TooltipContext;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -34,6 +35,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import reborncore.common.BaseBlockEntityProvider;
|
import reborncore.common.BaseBlockEntityProvider;
|
||||||
|
import techreborn.TechReborn;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
import techreborn.items.UpgradeItem;
|
import techreborn.items.UpgradeItem;
|
||||||
import techreborn.utils.ToolTipAssistUtils;
|
import techreborn.utils.ToolTipAssistUtils;
|
||||||
|
@ -53,7 +55,12 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
||||||
public void getTooltip(ItemStack stack, TooltipContext tooltipContext, List<Text> tooltipLines) {
|
public void getTooltip(ItemStack stack, TooltipContext tooltipContext, List<Text> tooltipLines) {
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
|
|
||||||
if (!ITEM_ID.computeIfAbsent(item, this::isTRItem))
|
// Can currently be executed by a ForkJoinPool.commonPool-worker when REI is in async search mode
|
||||||
|
// We skip this method until a thread-safe solution is in place
|
||||||
|
if (!MinecraftClient.getInstance().isOnThread())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!ITEM_ID.computeIfAbsent(item, StackToolTipHandler::isTRItem))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Machine info and upgrades helper section
|
// Machine info and upgrades helper section
|
||||||
|
@ -71,7 +78,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTRItem(Item item) {
|
private static boolean isTRItem(Item item) {
|
||||||
return Registry.ITEM.getId(item).getNamespace().equals("techreborn");
|
return Registry.ITEM.getId(item).getNamespace().equals("techreborn");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue