mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-14 01:14:07 +00:00
Fix WorldClient leak after leaving the world (#1115)
This commit is contained in:
1 parent
9839d1d08f
commit
fbbeafcd79
5 files changed
+42
-12
No files matched your search
@@ -54,7 +54,10 @@ import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.RecipeHandlerRef;
|
||||
import codechicken.nei.recipe.RecipeItemInputHandler;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.recipe.debug.DebugHandlerWidget;
|
||||
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
@@ -444,6 +447,11 @@ public class ClientHandler {
|
||||
if (event.world == mc.theWorld) {
|
||||
NEIClientConfig.unloadWorld();
|
||||
ItemMobSpawner.clearEntityReferences();
|
||||
RecipeItemInputHandler.instance.clearTooltipCache();
|
||||
RecipeHandlerRef.clearCache();
|
||||
ItemPanels.itemPanel.craftablesPanel.clearGuiReferences();
|
||||
DebugHandlerWidget.instance.clearGuiReferences();
|
||||
NEIController.manager = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,11 @@ public class ItemCraftablesPanel
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
pendingResult.set(generateCraftables(ItemCraftablesPanel.this.pendingSnapshot));
|
||||
final CraftablesSnapshot snapshot = ItemCraftablesPanel.this.pendingSnapshot;
|
||||
|
||||
if (snapshot != null) {
|
||||
pendingResult.set(generateCraftables(snapshot));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -298,6 +302,11 @@ public class ItemCraftablesPanel
|
||||
}
|
||||
}
|
||||
|
||||
public void clearGuiReferences() {
|
||||
this.lastGuiContainer = null;
|
||||
this.pendingSnapshot = null;
|
||||
}
|
||||
|
||||
private GuiContainer getGuiContainer() {
|
||||
final GuiContainer firstGui = NEIClientUtils.getGuiContainer();
|
||||
return (firstGui instanceof GuiRecipe<?>gui) ? gui.firstGui : firstGui;
|
||||
|
||||
@@ -19,12 +19,21 @@ import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
|
||||
public class RecipeItemInputHandler implements IContainerInputHandler, IContainerTooltipHandler {
|
||||
|
||||
public static final RecipeItemInputHandler instance = new RecipeItemInputHandler();
|
||||
|
||||
protected RecipeTooltipLineHandler recipeTooltipLineHandler = null;
|
||||
|
||||
protected RecipeItemInputHandler() {
|
||||
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
RecipeItemInputHandler recipeHandler = new RecipeItemInputHandler();
|
||||
GuiContainerManager.addInputHandler(recipeHandler);
|
||||
GuiContainerManager.addTooltipHandler(recipeHandler);
|
||||
GuiContainerManager.addInputHandler(instance);
|
||||
GuiContainerManager.addTooltipHandler(instance);
|
||||
}
|
||||
|
||||
public void clearTooltipCache() {
|
||||
this.recipeTooltipLineHandler = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,16 +73,17 @@ public class RecipeItemInputHandler implements IContainerInputHandler, IContaine
|
||||
: null;
|
||||
|
||||
if (recipeId == null) {
|
||||
recipeTooltipLineHandler = null;
|
||||
} else if (recipeTooltipLineHandler == null || !recipeTooltipLineHandler.getRecipeId().equals(recipeId)) {
|
||||
recipeTooltipLineHandler = new RecipeTooltipLineHandler(recipeId);
|
||||
}
|
||||
clearTooltipCache();
|
||||
} else if (this.recipeTooltipLineHandler == null
|
||||
|| !this.recipeTooltipLineHandler.getRecipeId().equals(recipeId)) {
|
||||
this.recipeTooltipLineHandler = new RecipeTooltipLineHandler(recipeId);
|
||||
}
|
||||
|
||||
if (recipeTooltipLineHandler != null) {
|
||||
currenttip.add(GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId(recipeTooltipLineHandler));
|
||||
if (this.recipeTooltipLineHandler != null) {
|
||||
currenttip.add(GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId(this.recipeTooltipLineHandler));
|
||||
}
|
||||
} else {
|
||||
recipeTooltipLineHandler = null;
|
||||
clearTooltipCache();
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
|
||||
@@ -35,7 +35,6 @@ public class RecipeTooltipLineHandler implements ITooltipLineHandler {
|
||||
|
||||
protected long lastUpdate = System.currentTimeMillis();
|
||||
protected String recipeName = "";
|
||||
protected GuiRecipe<?> gui = null;
|
||||
protected RecipeHandlerRef handlerRef = null;
|
||||
protected RecipeWidget widget = null;
|
||||
protected RecipeId recipeId = null;
|
||||
|
||||
@@ -733,6 +733,10 @@ public class DebugHandlerWidget extends Widget implements IContainerTooltipHandl
|
||||
});
|
||||
}
|
||||
|
||||
public void clearGuiReferences() {
|
||||
this.hoveredRecipe = null;
|
||||
}
|
||||
|
||||
public void loadHandlerInfoPatch() {
|
||||
|
||||
ClientHandler.loadSettingsFile("handlers.patch", lines -> {
|
||||
|
||||
Reference in new issue
Block a user