From ee2e0f781488fbf290bd2f0c9f8cef0cf2471636 Mon Sep 17 00:00:00 2001 From: 90 Date: Wed, 30 Aug 2023 14:57:56 +0100 Subject: [PATCH] Remove reversibility override system for the time being (At least until an implementation is found that doesn't fucking OOM) --- .../megacells/datagen/CommonTagProvider.java | 10 ----- .../_90/megacells/definition/MEGATags.java | 3 -- .../item/cell/BulkCellInventory.java | 2 +- .../megacells/util/CompressionService.java | 39 +------------------ 4 files changed, 2 insertions(+), 52 deletions(-) diff --git a/common/src/data/java/gripe/_90/megacells/datagen/CommonTagProvider.java b/common/src/data/java/gripe/_90/megacells/datagen/CommonTagProvider.java index 52c7f9e0..16d51f67 100644 --- a/common/src/data/java/gripe/_90/megacells/datagen/CommonTagProvider.java +++ b/common/src/data/java/gripe/_90/megacells/datagen/CommonTagProvider.java @@ -8,7 +8,6 @@ import net.minecraft.data.PackOutput; import net.minecraft.data.tags.IntrinsicHolderTagsProvider; import net.minecraft.data.tags.ItemTagsProvider; -import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import appeng.api.features.P2PTunnelAttunement; @@ -36,15 +35,6 @@ protected void addTags(HolderLookup.Provider provider) { tag(MEGATags.MEGA_PATTERN_PROVIDER) .add(MEGABlocks.MEGA_PATTERN_PROVIDER.asItem()) .add(MEGAItems.MEGA_PATTERN_PROVIDER.asItem()); - - tag(MEGATags.COMPRESSION_OVERRIDES) - .add(Items.QUARTZ) - .add(Items.AMETHYST_SHARD) - .add(Items.GLOWSTONE_DUST) - .add(Items.CLAY_BALL) - .add(Items.MELON_SLICE) - .add(Items.MAGMA_CREAM) - .add(Items.ICE, Items.PACKED_ICE); } } diff --git a/common/src/main/java/gripe/_90/megacells/definition/MEGATags.java b/common/src/main/java/gripe/_90/megacells/definition/MEGATags.java index bb01379e..1b27627f 100644 --- a/common/src/main/java/gripe/_90/megacells/definition/MEGATags.java +++ b/common/src/main/java/gripe/_90/megacells/definition/MEGATags.java @@ -27,7 +27,4 @@ public final class MEGATags { public static final TagKey MEGA_PATTERN_PROVIDER = TagKey.create(Registries.ITEM, MEGACells.makeId("mega_pattern_provider")); - - public static final TagKey COMPRESSION_OVERRIDES = - TagKey.create(Registries.ITEM, MEGACells.makeId("compression_overrides")); } diff --git a/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java b/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java index 9300a9f7..9752f7c2 100644 --- a/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java +++ b/common/src/main/java/gripe/_90/megacells/item/cell/BulkCellInventory.java @@ -204,7 +204,7 @@ public void getAvailableStacks(KeyCounter out) { if (storedItem != null) { var stackLimit = (long) Math.pow(2, 42); - if (compressionEnabled && storedItem.equals(filterItem)) { + if (compressionEnabled && storedItem.equals(filterItem) && !compressionChain.isEmpty()) { var count = unitCount; var chain = compressionChain.lastMultiplierSwapped(); diff --git a/common/src/main/java/gripe/_90/megacells/util/CompressionService.java b/common/src/main/java/gripe/_90/megacells/util/CompressionService.java index 61066d76..29c0dd18 100644 --- a/common/src/main/java/gripe/_90/megacells/util/CompressionService.java +++ b/common/src/main/java/gripe/_90/megacells/util/CompressionService.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.stream.Stream; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; @@ -18,11 +17,8 @@ import appeng.api.stacks.AEItemKey; -import gripe._90.megacells.definition.MEGATags; - public class CompressionService { private static final Set compressionChains = new ObjectLinkedOpenHashSet<>(); - private static final Set overrides = new ObjectLinkedOpenHashSet<>(); public static Optional getChain(AEItemKey item) { return compressionChains.stream() @@ -33,7 +29,6 @@ public static Optional getChain(AEItemKey item) { public static void loadRecipes(RecipeManager recipeManager, RegistryAccess access) { // Clear old variant cache in case of the server restarting or recipes being reloaded compressionChains.clear(); - overrides.clear(); // Retrieve all available "compression" and "decompression" recipes from the current server's recipe manager var allRecipes = recipeManager.getAllRecipesFor(RecipeType.CRAFTING); @@ -54,8 +49,7 @@ public static void loadRecipes(RecipeManager recipeManager, RegistryAccess acces .toList(); // Pull all available compression chains from the recipe shortlist and add these to the cache - for (var recipe : - Stream.concat(compressed.stream(), decompressed.stream()).toList()) { + for (var recipe : compressed) { var baseVariant = recipe.getResultItem(access).getItem(); if (compressionChains.stream().noneMatch(chain -> chain.containsVariant(AEItemKey.of(baseVariant)))) { @@ -97,16 +91,6 @@ private static CompressionChain generateChain( private static CompressionVariant getNextVariant( Item item, List recipes, boolean compressed, RegistryAccess access) { - for (var override : overrides) { - if (override.smaller.equals(item) && compressed) { - return new CompressionVariant(override.larger, override.factor); - } - - if (override.larger.equals(item) && !compressed) { - return new CompressionVariant(override.smaller, override.factor); - } - } - for (var recipe : recipes) { for (var input : recipe.getIngredients().get(0).getItems()) { if (input.getItem().equals(item)) { @@ -163,10 +147,6 @@ private static boolean sameIngredient(CraftingRecipe recipe) { private static boolean isReversibleRecipe( CraftingRecipe recipe, List candidates, RegistryAccess access) { - if (overrideRecipe(recipe, access)) { - return true; - } - var compressible = false; var decompressible = false; @@ -191,21 +171,4 @@ private static boolean isReversibleRecipe( return false; } - - private static boolean overrideRecipe(CraftingRecipe recipe, RegistryAccess access) { - for (var item : recipe.getIngredients().get(0).getItems()) { - if (item.is(MEGATags.COMPRESSION_OVERRIDES)) { - var variant = recipe.getResultItem(access); - var compressed = isCompressionRecipe(recipe, access); - var factor = compressed ? recipe.getIngredients().size() : variant.getCount(); - - overrides.add(new Override(item.getItem(), variant.getItem(), compressed, factor)); - return true; - } - } - - return false; - } - - private record Override(Item smaller, Item larger, boolean compressed, int factor) {} }