mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-28 22:05:01 +01:00
Drain category improvements (#7277)
This commit is contained in:
parent
0870d34033
commit
be026ece02
1 changed files with 9 additions and 0 deletions
|
@ -10,8 +10,10 @@ import com.simibubi.create.content.fluids.potion.PotionFluidHandler;
|
|||
import com.simibubi.create.content.fluids.transfer.EmptyingRecipe;
|
||||
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
import com.simibubi.create.foundation.item.ItemHelper;
|
||||
import com.simibubi.create.foundation.utility.RegisteredObjects;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.forge.ForgeTypes;
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
||||
|
@ -22,6 +24,7 @@ import mezz.jei.api.runtime.IIngredientManager;
|
|||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStackLinkedSet;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.PotionItem;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
|
@ -41,6 +44,7 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
|
|||
}
|
||||
|
||||
public static void consumeRecipes(Consumer<EmptyingRecipe> consumer, IIngredientManager ingredientManager) {
|
||||
ObjectOpenCustomHashSet<ItemStack> emptiedItems = new ObjectOpenCustomHashSet<>(ItemStackLinkedSet.TYPE_AND_TAG);
|
||||
for (ItemStack stack : ingredientManager.getAllIngredients(VanillaTypes.ITEM_STACK)) {
|
||||
if (PotionFluidHandler.isPotionItem(stack)) {
|
||||
FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack);
|
||||
|
@ -68,6 +72,11 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
|
|||
if (result.isEmpty())
|
||||
continue;
|
||||
|
||||
// There can be a lot of duplicate empty tanks (e.g. from emptying tanks with different fluids). Merge
|
||||
// them to reduce memory usage. If the item is exactly the same as the input, just use the input stack
|
||||
// instead of the copy.
|
||||
result = ItemHelper.sameItem(stack, result) ? stack : emptiedItems.addOrGet(result);
|
||||
|
||||
Ingredient ingredient = Ingredient.of(stack);
|
||||
ResourceLocation itemName = RegisteredObjects.getKeyOrThrow(stack.getItem());
|
||||
ResourceLocation fluidName = RegisteredObjects.getKeyOrThrow(extracted.getFluid());
|
||||
|
|
Loading…
Reference in a new issue