From 525a6ecf69abdd937fad709566dc5d1ff154e004 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Fri, 13 Nov 2026 21:11:25 +0800 Subject: [PATCH 01/17] material-refactor cleanup --- .../content/block/stone/OreHostFacts.java | 103 +++ .../content/block/wood/WoodSpecies.java | 5 - .../gregtech/content/data/FluidCatalog.java | 37 +- .../content/data/MaterialDataRules.java | 5 - .../content/material/MaterialDefinitions.java | 11 + .../content/material/MaterialFactKeys.java | 190 +++++ .../catalog/DecompositionMaterials.java | 4 +- .../catalog/GenerifyingMaterialFacts.java | 72 ++ .../catalog/MaterialFluidUnitFacts.java | 196 +++++ .../PurifiedCentrifugeMaterialFacts.java | 56 ++ .../catalog/ReviewedOreMaterialFacts.java | 173 ++++ .../catalog/ReviewedSourceMaterialFacts.java} | 130 ++- .../catalog/SourceExtrusionMaterialFacts.java | 797 ++++++++++++++++++ .../catalog/SourceLensMaterialFacts.java | 54 +- .../SourceMacerationMaterialFacts.java} | 41 +- .../SourceOreCrushingMaterialFacts.java | 63 ++ .../SourceRecyclingMaterialFacts.java} | 102 +-- .../catalog/SourceWashingMaterialFacts.java} | 54 +- .../content/recipe/FurnaceSmeltingRules.java | 13 +- .../content/recipe/GenerifyingRules.java | 57 +- .../content/recipe/OreSourcePolicy.java | 47 +- .../recipe/OriginalMaterialFluidUnits.java | 104 --- .../recipe/ReviewedMagneticMaterials.java | 77 -- .../recipe/ReviewedOreGeneratedFluids.java | 72 -- .../recipe/ReviewedSiftingGemForms.java | 36 - .../content/recipe/SourceExtrusionRules.java | 796 +---------------- .../content/recipe/SourceLensRoles.java | 27 + .../content/recipe/SourceOilSandRules.java | 19 +- .../recipe/SourceOreCrushingFacts.java | 177 ---- .../recipe/SourceOreCrushingRules.java | 23 +- .../recipe/SourceOreShreddingRules.java | 7 +- .../content/recipe/SourceOreWashingRules.java | 9 +- .../recipe/SourcePurifiedAcidData.java | 72 +- .../recipe/SourcePurifiedAcidRules.java | 13 +- .../recipe/SourceRollingWireRules.java | 9 +- .../recipe/SourceThermalInputRules.java | 12 +- .../recipe/SourceThermalRecyclingRules.java | 2 +- .../content/recipe/SourceWaxMaterials.java | 34 - .../engine/recipe/SourceRecyclingMath.java | 2 +- .../recipe/chem/MaterialFluidBinding.java | 12 +- .../resources/assets/gt6ce/lang/en_us.json | 4 +- .../resources/assets/gt6ce/lang/zh_cn.json | 4 +- .../content/material/MaterialCatalogTest.java | 160 +++- .../MaterialDecompositionPlannerTest.java | 19 +- .../recipe/chem/MaterialAmountTest.java | 24 +- docs/architecture/packages/content.md | 8 +- .../material-system-refactor/05-recovery.md | 4 +- .../07-cleanup-and-acceptance.md | 172 +++- .../07-recipe-package-audit.md | 83 ++ .../08-material-data-api.md | 4 +- .../material-system-refactor/README.md | 12 +- .../pr-374-review-actions.md | 146 ++++ .../material-refactor-05-recovery.md | 2 +- .../gregtech/client/MaterialTooltips.java | 7 +- .../material/MaterialItemCompositions.java | 80 +- .../PanelMaterialCompositions.java} | 8 +- .../TransportMaterialCompositions.java} | 7 +- .../material/WoodMaterialCompositions.java | 137 +++ .../content/recipe/BathMaterialRecipes.java | 10 +- .../content/recipe/CapsuleCellRecipes.java | 12 - .../content/recipe/DiggableRecipes.java | 13 - .../content/recipe/ElectronicsRecipes.java | 5 +- .../recipe/GenerifierRecipeFamily.java | 5 +- .../content/recipe/LaserStoneRecipes.java | 27 +- .../recipe/MaterialFormConversionRecipes.java | 5 +- .../recipe/NonOreContinuationEvidence.java | 7 +- .../content/recipe/NonOreMacerationRows.java | 5 +- .../recipe/OreFluidBindingAdapter.java | 19 +- .../recipe/OreProcessingRecipeLoader.java | 24 +- .../content/recipe/PartRecipeLoader.java | 2 +- .../recipe/RegisteredWoodSurvivalRecipes.java | 64 -- .../recipe/ReviewedOreFluidBindings.java | 30 - .../recipe/ReviewedOreInputProfile.java | 83 -- .../SharedMineralSteamCrackingRows.java | 29 +- .../content/recipe/SharedOilSandRows.java | 2 +- .../content/recipe/SharedOreCrushingRows.java | 2 +- .../content/recipe/SharedOreWashingRows.java | 31 +- .../recipe/SharedPurifiedAcidRows.java | 31 +- .../recipe/SharedPurifiedCentrifugeRows.java | 37 +- .../recipe/SharedThermalRecyclingRows.java | 32 +- .../recipe/SingleItemSourceRecipes.java | 9 - ...ava => SourceCinnabarFollowonAdapter.java} | 73 +- ...ion.java => SourceCrushedFormAdapter.java} | 33 +- ...pes.java => SourceDustThermalRecipes.java} | 6 +- .../content/recipe/SourceExtruderRecipes.java | 3 +- .../recipe/SourceFurnaceNativeAdapter.java | 12 +- .../recipe/SourceGemGradeResolver.java | 12 +- .../recipe/SourceGeneratedFluidAdapter.java | 63 ++ .../content/recipe/SourceLensRecipeItems.java | 22 + .../recipe/SourceOreCrushingAdapter.java | 35 +- ...cts.java => SourceOreFollowonAdapter.java} | 35 +- .../content/recipe/SourceOreInputForms.java | 2 +- .../recipe/SourceOreMacerationAdapter.java | 14 +- .../content/recipe/SourceOreOutputRows.java | 2 +- .../recipe/SourceThermalNativeAdapter.java | 55 +- .../recipe/ThermalRecoveryOwnership.java | 6 +- .../content/recipe/TreatedWoodRecipes.java | 11 +- .../recipe/VanillaRecoveryRecipes.java | 6 +- .../recipe/VanillaWoodProcessingRecipes.java | 40 - .../recipe/generated/ChemRecipeResolver.java | 4 +- 100 files changed, 3240 insertions(+), 2272 deletions(-) create mode 100644 core/src/main/java/gregtech/content/block/stone/OreHostFacts.java create mode 100644 core/src/main/java/gregtech/content/material/MaterialFactKeys.java create mode 100644 core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java create mode 100644 core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java create mode 100644 core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java create mode 100644 core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java rename core/src/main/java/gregtech/content/{recipe/ReviewedOreSourceProfile.java => material/catalog/ReviewedSourceMaterialFacts.java} (72%) create mode 100644 core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java rename minecraft/src/main/java/gregtech/content/recipe/SourceLensRoles.java => core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java (76%) rename core/src/main/java/gregtech/content/{recipe/SourceOreMacerationFacts.java => material/catalog/SourceMacerationMaterialFacts.java} (82%) create mode 100644 core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java rename core/src/main/java/gregtech/content/{recipe/SourceRecyclingFacts.java => material/catalog/SourceRecyclingMaterialFacts.java} (95%) rename core/src/main/java/gregtech/content/{recipe/SourceOreWashingData.java => material/catalog/SourceWashingMaterialFacts.java} (84%) delete mode 100644 core/src/main/java/gregtech/content/recipe/OriginalMaterialFluidUnits.java delete mode 100644 core/src/main/java/gregtech/content/recipe/ReviewedMagneticMaterials.java delete mode 100644 core/src/main/java/gregtech/content/recipe/ReviewedOreGeneratedFluids.java delete mode 100644 core/src/main/java/gregtech/content/recipe/ReviewedSiftingGemForms.java create mode 100644 core/src/main/java/gregtech/content/recipe/SourceLensRoles.java delete mode 100644 core/src/main/java/gregtech/content/recipe/SourceOreCrushingFacts.java delete mode 100644 core/src/main/java/gregtech/content/recipe/SourceWaxMaterials.java create mode 100644 docs/development/material-system-refactor/07-recipe-package-audit.md create mode 100644 docs/development/material-system-refactor/pr-374-review-actions.md rename minecraft/src/main/java/gregtech/content/{recipe/PanelMaterialRegistration.java => material/PanelMaterialCompositions.java} (95%) rename minecraft/src/main/java/gregtech/content/{recipe/TransportMaterialRegistration.java => material/TransportMaterialCompositions.java} (93%) create mode 100644 minecraft/src/main/java/gregtech/content/material/WoodMaterialCompositions.java delete mode 100644 minecraft/src/main/java/gregtech/content/recipe/ReviewedOreFluidBindings.java delete mode 100644 minecraft/src/main/java/gregtech/content/recipe/ReviewedOreInputProfile.java rename minecraft/src/main/java/gregtech/content/recipe/{ReviewedCinnabarFacts.java => SourceCinnabarFollowonAdapter.java} (65%) rename minecraft/src/main/java/gregtech/content/recipe/{ReviewedCrushedFormGeneration.java => SourceCrushedFormAdapter.java} (69%) rename minecraft/src/main/java/gregtech/content/recipe/{ReviewedCinnabarThermalRecipes.java => SourceDustThermalRecipes.java} (96%) create mode 100644 minecraft/src/main/java/gregtech/content/recipe/SourceGeneratedFluidAdapter.java create mode 100644 minecraft/src/main/java/gregtech/content/recipe/SourceLensRecipeItems.java rename minecraft/src/main/java/gregtech/content/recipe/{ReviewedOreShredderFacts.java => SourceOreFollowonAdapter.java} (77%) diff --git a/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java b/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java new file mode 100644 index 000000000..faf7c1e01 --- /dev/null +++ b/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java @@ -0,0 +1,103 @@ +package gregtech.content.block.stone; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import static gregtech.api.material.GTValues.U; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; + +/** Source ore-host prefixes, gangue composition and broken-ore pairing. */ +public final class OreHostFacts { + private OreHostFacts() {} + + public record HostProfile( + String sourcePrefix, Identity gangueMaterial, long gangueAmount, boolean hexoriumAdjusted) { + public HostProfile { + Objects.requireNonNull(sourcePrefix); + if (gangueAmount < 0) throw new IllegalArgumentException("Negative gangue amount"); + if (gangueAmount > 0) Objects.requireNonNull(gangueMaterial); + } + + public boolean hasGangue() { + return gangueAmount > 0; + } + } + + private static final Map HOSTS = createHosts(); + private static final Set BROKEN_SOURCE_PAIRS = Set.of( + "oreVanillastone", "oreNetherrack", "oreEndstone", "oreBlackgranite", "oreRedgranite", + "oreBasalt", "oreMarble", "oreLimestone", "oreVanillagranite", "oreDiorite", "oreAndesite", + "oreKomatiite", "oreGreenschist", "oreBlueschist", "oreKimberlite", "oreQuartzite", + "oreLightprismarine", "oreDarkprismarine", "oreSlate", "oreShale"); + + public static HostProfile hostProfile(String nativeHostId) { + return nativeHostId == null ? null : HOSTS.get(nativeHostId); + } + + public static Decision hostDecision(String nativeHostId) { + if (hostProfile(nativeHostId) != null) return Decision.YES; + if ("bedrock".equals(nativeHostId) + || "sand".equals(nativeHostId) + || "red_sand".equals(nativeHostId) + || "gravel".equals(nativeHostId) + || "mud".equals(nativeHostId)) return Decision.NO; + return Decision.UNKNOWN; + } + + public static boolean hasBrokenSourcePair(String nativeHostId) { + HostProfile profile = hostProfile(nativeHostId); + return profile != null && BROKEN_SOURCE_PAIRS.contains(profile.sourcePrefix()); + } + + private static Map createHosts() { + var result = new LinkedHashMap(); + host(result, "oreVanillastone", 8500, "Stone", false, "stone"); + host(result, "oreVanillagranite", 8518, "Granite", false, "granite", "stone_granite"); + host(result, "oreDiorite", 8511, "Diorite", false, "diorite", "stone_diorite"); + host(result, "oreAndesite", 9188, "Andesite", false, "andesite", "stone_andesite"); + host(result, "oreDeepslate", 9248, "Deepslate", true, "deepslate"); + host(result, "oreNetherrack", 8502, "Netherrack", true, "netherrack"); + host(result, "oreEndstone", 8504, "Endstone", false, "end_stone"); + host(result, "oreBlackgranite", 8508, "GraniteBlack", false, "stone_granite_black"); + host(result, "oreRedgranite", 8507, "GraniteRed", false, "stone_granite_red"); + host(result, "oreKomatiite", 9177, "Komatiite", true, "stone_komatiite"); + host(result, "oreBasalt", 8505, "Basalt", true, "stone_basalt"); + host(result, "oreMarble", 8506, "Marble", false, "stone_marble"); + host(result, "oreLimestone", 9189, "Limestone", false, "stone_limestone"); + host(result, "oreShale", 9190, "Shale", false, "stone_shale"); + host(result, "oreSlate", 9222, "Slate", false, "stone_slate"); + host(result, "oreGreenschist", 9171, "Greenschist", false, "stone_greenschist"); + host(result, "oreBlueschist", 9184, "Blueschist", false, "stone_blueschist"); + host(result, "oreLightprismarine", 9219, "Prismarine", false, "stone_prismarine_light"); + host(result, "oreDarkprismarine", 9220, "PrismarineDark", false, "stone_prismarine_dark"); + host(result, "oreKimberlite", 9218, "Kimberlite", false, "stone_kimberlite"); + host(result, "oreQuartzite", 9180, "Quartzite", false, "stone_quartzite"); + if (result.put("sandstone", new HostProfile("oreSandstone", null, 0, false)) != null) + throw new IllegalStateException("Duplicate source host sandstone"); + portHost(result, "gypsum", 9161, "Gypsum"); + portHost(result, "salt", 8204, "Salt"); + return Map.copyOf(result); + } + + private static void host( + Map result, + String prefix, + int materialId, + String canonicalName, + boolean adjusted, + String... nativeHostIds) { + var profile = new HostProfile(prefix, new Identity(materialId, canonicalName), 4 * U, adjusted); + for (String host : nativeHostIds) + if (result.put(host, profile) != null) throw new IllegalStateException("Duplicate source host " + host); + } + + private static void portHost(Map result, String stone, int materialId, String name) { + String host = "stone_" + stone; + String prefix = "portOre" + Character.toUpperCase(stone.charAt(0)) + stone.substring(1); + if (result.put(host, new HostProfile(prefix, new Identity(materialId, name), 4 * U, false)) != null) + throw new IllegalStateException("Duplicate source host " + host); + } +} diff --git a/core/src/main/java/gregtech/content/block/wood/WoodSpecies.java b/core/src/main/java/gregtech/content/block/wood/WoodSpecies.java index ef3ba20eb..7eb5ea21a 100644 --- a/core/src/main/java/gregtech/content/block/wood/WoodSpecies.java +++ b/core/src/main/java/gregtech/content/block/wood/WoodSpecies.java @@ -46,9 +46,4 @@ public boolean fireproof() { public String enName() { return enName; } - /** Compatibility only; localized names come from language resources. */ - @Deprecated - public String zhName() { - return enName; - } } diff --git a/core/src/main/java/gregtech/content/data/FluidCatalog.java b/core/src/main/java/gregtech/content/data/FluidCatalog.java index b14eb7053..a2d5c9a72 100644 --- a/core/src/main/java/gregtech/content/data/FluidCatalog.java +++ b/core/src/main/java/gregtech/content/data/FluidCatalog.java @@ -3,6 +3,8 @@ import gregtech.api.material.GTMaterial; import gregtech.api.material.MaterialProperty; import gregtech.content.data.generated.MaterialForms; +import gregtech.content.material.MaterialDefinitions; +import gregtech.content.material.MaterialFactKeys; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Locale; @@ -991,33 +993,16 @@ public static Map all() { } /** - * Missing imported MOLTEN declarations, not new general material properties. - * GT6 3703e40308c8c030763fd6297dea8b210d2a77b1 MT; - * Loader_Fluids creates these phases through FL.createMolten. - * Keep this finite ID/name proof local to fluid generation: MELTING, METAL, item forms, - * targets and compatibility overrides must not be inferred or mutated from it. + * Missing imported MOLTEN declarations are material facts. Fluid generation only consumes the + * typed process; MELTING, METAL, item forms, targets and overrides are not inferred from it. */ - private static boolean hasReviewedSourceMoltenPhase(GTMaterial material) { + private static boolean hasSourceMoltenPhase(GTMaterial material) { if (!gregtech.engine.material.GTMaterialRegistry.isCoreMaterial(material)) return false; - String name = switch (material.getId()) { - case 62 -> "Carbon14"; - case 1250 -> "TritaniumElemental"; - case 1260 -> "Trinium"; - case 1450 -> "DuraniumElemental"; - case 1740 -> "Naquadah"; - case 1741 -> "NaquadahEnriched"; - case 1742 -> "Naquadria"; - case 8020 -> "PotassiumCarbonate"; - case 8026 -> "TungstenTrioxide"; - case 8030 -> "FerrousChloride"; - case 8034 -> "LithiumPerchlorate"; - case 8266 -> "Asphalt"; - case 8500 -> "Stone"; - case 9120 -> "Ilmenite"; - case 9192 -> "Rutile"; - default -> null; - }; - return material.getName().equals(name); + return MaterialDefinitions.info(material.getName()) + .processes() + .findSingle(MaterialFactKeys.SOURCE_MOLTEN_FLUID) + .map(rule -> rule.value().booleanValue()) + .orElse(false); } /** @@ -1043,7 +1028,7 @@ public static void registerGeneratedMoltenFluids(Collection material && !material.has(MaterialProperty.METAL) && !material.has(MaterialProperty.ALLOY) && !MaterialForms.has(material, "MOLTEN") - && !hasReviewedSourceMoltenPhase(material)) { + && !hasSourceMoltenPhase(material)) { continue; } String field = "GenMolten_" + material.getName(); diff --git a/core/src/main/java/gregtech/content/data/MaterialDataRules.java b/core/src/main/java/gregtech/content/data/MaterialDataRules.java index ee3d354d9..4c638fcd7 100644 --- a/core/src/main/java/gregtech/content/data/MaterialDataRules.java +++ b/core/src/main/java/gregtech/content/data/MaterialDataRules.java @@ -1,6 +1,5 @@ package gregtech.content.data; -import gregtech.api.material.*; import java.util.List; /** Source1 scanner/printer/replicator work and material-form preference. Units remain at the platform boundary. */ @@ -21,10 +20,6 @@ private MaterialDataRules() {} public static final int ENVIRONMENT_KELVIN = 293; - /** Compatibility name from the earlier port; its value is duration, not packet power. */ - @Deprecated - public static final long REPLICATOR_POWER_PER_NUCLEON = REPLICATOR_TICKS_PER_NUCLEON; - public enum AmbientPhase { SOLID, LIQUID, diff --git a/core/src/main/java/gregtech/content/material/MaterialDefinitions.java b/core/src/main/java/gregtech/content/material/MaterialDefinitions.java index b8846ea7c..eb0da9fcd 100644 --- a/core/src/main/java/gregtech/content/material/MaterialDefinitions.java +++ b/core/src/main/java/gregtech/content/material/MaterialDefinitions.java @@ -27,6 +27,17 @@ private static List collect() { result.addAll(WoodMaterials.definitions()); result.addAll(SpecialMaterials.definitions()); result.addAll(GroupMaterials.definitions()); + result.replaceAll(ReviewedSourceMaterialFacts::applyOne); + result.replaceAll(ReviewedOreMaterialFacts::apply); + result.replaceAll(SourceMacerationMaterialFacts::apply); + result.replaceAll(SourceWashingMaterialFacts::apply); + result.replaceAll(MaterialFluidUnitFacts::apply); + result.replaceAll(GenerifyingMaterialFacts::apply); + result.replaceAll(SourceExtrusionMaterialFacts::apply); + result.replaceAll(SourceLensMaterialFacts::apply); + result.replaceAll(SourceRecyclingMaterialFacts::apply); + result.replaceAll(SourceOreCrushingMaterialFacts::apply); + result.replaceAll(PurifiedCentrifugeMaterialFacts::apply); result.replaceAll(MaterialDefinitions::attachDecomposition); DecompositionMaterials.validateConsumed(result); result.sort(Comparator.comparing(MaterialDefinition.Declaration::name)); diff --git a/core/src/main/java/gregtech/content/material/MaterialFactKeys.java b/core/src/main/java/gregtech/content/material/MaterialFactKeys.java new file mode 100644 index 000000000..b9ff9e63d --- /dev/null +++ b/core/src/main/java/gregtech/content/material/MaterialFactKeys.java @@ -0,0 +1,190 @@ +package gregtech.content.material; + +import gregtech.api.addon.material.DataKey; +import gregtech.api.addon.material.MaterialInfoTool; +import gregtech.api.addon.material.MaterialKey; +import gregtech.api.addon.material.MaterialProcessKey; +import gregtech.api.material.GTMaterial; +import gregtech.content.material.catalog.SourceExtrusionMaterialFacts; +import gregtech.content.material.catalog.SourceLensMaterialFacts; +import gregtech.content.material.catalog.SourceRecyclingMaterialFacts; +import gregtech.content.material.catalog.SourceWashingMaterialFacts; +import java.util.Optional; +import java.util.Set; + +/** Typed material process keys for facts consumed by recipe families. */ +public final class MaterialFactKeys { + private MaterialFactKeys() {} + + public enum Decision { + YES, + NO, + UNKNOWN + } + + public record Identity(int id, String name) { + public Identity { + java.util.Objects.requireNonNull(name, "name"); + } + + public boolean matches(int materialId, String canonicalName) { + return id == materialId && name.equals(canonicalName); + } + } + + public static final MaterialProcessKey SOURCE_FURNACE = + single("source_furnace", Decision.class); + public static final MaterialProcessKey SOURCE_GRADED_GEM = + single("source_graded_gem", Decision.class); + public static final MaterialProcessKey SOURCE_ORE_INPUT = + single("source_ore_input", Decision.class); + public static final MaterialProcessKey SOURCE_SIFTING_EXCLUSIONS = + single("source_sifting_exclusions", PrefixExclusions.class); + public static final MaterialProcessKey SOURCE_CRUSHED_EXCLUSIONS = + single("source_crushed_exclusions", PrefixExclusions.class); + public static final MaterialProcessKey SOURCE_ORE_SHREDDER = + single("source_ore_shredder", OreShredderProfile.class); + public static final MaterialProcessKey SOURCE_MACERATION = + single("source_maceration", Decision.class); + public static final MaterialProcessKey SOURCE_WASHING = + single("source_washing", SourceWashingMaterialFacts.Binding.class); + public static final MaterialProcessKey MATERIAL_FLUID_UNIT = + single("material_fluid_unit", MaterialFluidUnits.class); + public static final MaterialProcessKey GENERIFICATION_TARGET = + single("generification_target", GenerificationTarget.class); + public static final MaterialProcessKey SOURCE_EXTRUSION = + single("source_extrusion", SourceExtrusionMaterialFacts.Profile.class); + public static final MaterialProcessKey SOURCE_LENS_ROLE = + single("source_lens_role", SourceLensMaterialFacts.Color.class); + public static final MaterialProcessKey SOURCE_CINNABAR_FOLLOWON = + single("source_cinnabar_followon", CinnabarFollowonRule.class); + public static final MaterialProcessKey SOURCE_GENERATED_FLUID = + single("source_generated_fluid", GeneratedFluidRules.class); + public static final MaterialProcessKey SOURCE_RECYCLING = + single("source_recycling", SourceRecyclingMaterialFacts.Facts.class); + public static final MaterialProcessKey SOURCE_MOLTEN_FLUID = + single("source_molten_fluid", Boolean.class); + public static final MaterialProcessKey SOURCE_ORE_CRUSHING = + single("source_ore_crushing", OreCrushingFact.class); + public static final MaterialProcessKey SOURCE_PURIFIED_CENTRIFUGE_PHASE = + single("source_purified_centrifuge_phase", PurifiedCentrifugePhase.class); + public static final MaterialProcessKey SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT = + single("source_purified_centrifuge_no_default", PurifiedCentrifugeNoDefault.class); + public static final MaterialProcessKey SOURCE_ADDITIONAL_WIRE_FAMILY = + single("source_additional_wire_family", Boolean.class); + public static final MaterialProcessKey COMPRESSOR_DUST_TO_GEM_PLATE = + single("compressor_dust_to_gem_plate", Boolean.class); + + public record PrefixExclusions(Set prefixes) { + public PrefixExclusions { + prefixes = Set.copyOf(prefixes); + } + + public boolean excludes(String prefix) { + return prefixes.contains(prefix); + } + } + + public record OreShredderProfile(int quality, boolean mortar) { + public OreShredderProfile { + if (quality < 0) throw new IllegalArgumentException("Negative source tool quality"); + } + } + + public record MaterialFluidUnit( + String phase, + String fluidField, + String registryPath, + long referenceSourceUnits, + long referenceMillibuckets) { + public MaterialFluidUnit { + if (phase == null || phase.isBlank()) throw new IllegalArgumentException("Missing material fluid phase"); + if (fluidField == null || fluidField.isBlank()) + throw new IllegalArgumentException("Missing material fluid field"); + if (registryPath == null || registryPath.isBlank()) + throw new IllegalArgumentException("Missing material fluid registry path"); + if (referenceSourceUnits <= 0 || referenceMillibuckets <= 0) + throw new IllegalArgumentException("Invalid material fluid unit"); + } + } + + public record MaterialFluidUnits(Set units) { + public MaterialFluidUnits { + units = Set.copyOf(units); + if (units.isEmpty()) throw new IllegalArgumentException("Material fluid units must not be empty"); + } + } + + public record GenerificationTarget(int materialId) { + public GenerificationTarget { + if (materialId <= 0 || materialId >= 10_000) + throw new IllegalArgumentException("Invalid generification target id: " + materialId); + } + } + + public record CinnabarFollowonRule(Identity cinnabar, java.util.List byproducts, Identity sluiceSand) { + public CinnabarFollowonRule { + java.util.Objects.requireNonNull(cinnabar, "cinnabar"); + byproducts = java.util.List.copyOf(byproducts); + java.util.Objects.requireNonNull(sluiceSand, "sluiceSand"); + } + } + + public record GeneratedFluidRule( + String field, String registryPath, int temperature, float materialDensity, boolean wholeDustMetal) { + public GeneratedFluidRule { + if (field == null || field.isBlank() || registryPath == null || registryPath.isBlank()) + throw new IllegalArgumentException("Invalid generated fluid binding"); + if (temperature < 0 || !Float.isFinite(materialDensity) || materialDensity < 0) + throw new IllegalArgumentException("Invalid generated fluid physical facts"); + } + } + + public record GeneratedFluidRules(Set rules) { + public GeneratedFluidRules { + rules = Set.copyOf(rules); + if (rules.isEmpty()) throw new IllegalArgumentException("Generated fluid rules must not be empty"); + } + } + + public enum HexoriumKind { + NONE, + BLACK_WHITE, + RED_GREEN_BLUE + } + + public record OreCrushingFact(Decision pulverizing, HexoriumKind hexorium) { + public OreCrushingFact { + java.util.Objects.requireNonNull(pulverizing, "pulverizing"); + java.util.Objects.requireNonNull(hexorium, "hexorium"); + } + } + + public record PurifiedCentrifugePhase(String phase, int meltingKelvin, int boilingKelvin) { + public PurifiedCentrifugePhase { + if (!"gas".equals(phase) && !"liquid".equals(phase)) + throw new IllegalArgumentException("Invalid purified centrifuge phase"); + } + } + + public record PurifiedCentrifugeNoDefault(String phase, int meltingKelvin, int boilingKelvin) { + public PurifiedCentrifugeNoDefault { + if (!"gas".equals(phase) && !"liquid".equals(phase)) + throw new IllegalArgumentException("Invalid purified centrifuge default phase"); + } + } + + public static Optional value(GTMaterial material, MaterialProcessKey key) { + if (material == null || !material.isValid()) return Optional.empty(); + return MaterialInfoTool.currentProcess(new MaterialKey(material.resolve().getName()), key) + .map(rule -> rule.value()); + } + + public static Optional sourceRecycling(GTMaterial material) { + return value(material, SOURCE_RECYCLING); + } + + private static MaterialProcessKey single(String path, Class type) { + return MaterialProcessKey.single(new DataKey("gt6ce", path), type); + } +} diff --git a/core/src/main/java/gregtech/content/material/catalog/DecompositionMaterials.java b/core/src/main/java/gregtech/content/material/catalog/DecompositionMaterials.java index 54d7ba483..4c71526ad 100644 --- a/core/src/main/java/gregtech/content/material/catalog/DecompositionMaterials.java +++ b/core/src/main/java/gregtech/content/material/catalog/DecompositionMaterials.java @@ -4,9 +4,7 @@ import gregtech.api.addon.material.MaterialDecompositionRule.Route; import gregtech.api.addon.material.MaterialProcessKeys; import gregtech.api.material.GTValues; -import gregtech.content.recipe.OriginalMaterialFluidUnits; import gregtech.engine.material.MaterialDefinition; - import java.util.*; /** @@ -228,7 +226,7 @@ private static Thermal thermal(int id, String name) { } private static Binding shared(String material, int id, String phase) { - var binding = OriginalMaterialFluidUnits.binding(material, id, phase); + var binding = MaterialFluidUnitFacts.binding(material, id, phase); if (binding == null) throw new IllegalStateException("Missing shared fluid binding for " + material + " / " + phase); return new Binding(binding.registryName(), binding.referenceSourceUnits(), binding.referenceMillibuckets()); diff --git a/core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java new file mode 100644 index 000000000..225de9944 --- /dev/null +++ b/core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java @@ -0,0 +1,72 @@ +package gregtech.content.material.catalog; + +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * GT6's generifier rule: every material whose {@code mTargetGenerifying} differs from itself becomes + * one {@code RecipeMapHandlerMaterial} on {@code RM.Generifier}, and that handler expands over every + * prefix the condition {@code And(SIMPLIFIABLE, ingotHot.NOT)} accepts. Each row converts one item of + * a form in the source material into one item of the same form in the target material; the duration + * is the form's material weight in ticks, the EU cost is zero, and nothing converts back. + * + *

The material targets are {@code MT.java}'s {@code setGenerifying} calls plus the + * {@code ANY.*.mToThis} loops that follow them, keyed by GT6 material id so the table does not depend + * on display names. {@code ANY} groups that point at a plain material other than their own name + * (ashes, gems, woods, wax, rubber, plastics, phosphorus, clay, silicon) are already folded into the + * targets, because the loops overwrite the explicit rows they contain.

+ */ +public final class GenerifyingMaterialFacts { + private GenerifyingMaterialFacts() {} + + /** {@code MT.java} {@code setGenerifying} rows and {@code ANY.*.mToThis} loops, as source/target ids. */ + private static final int[] TARGET_IDS = { + 8196, 8218, 8197, 8218, 8201, 8200, 8222, 8221, 8224, 8221, 8236, 8235, 8238, 8235, 8239, 8235, 8267, 8221, + 8276, 8215, 8278, 8300, 8289, 8221, 8290, 8221, 8296, 8221, 8297, 8221, 8302, 8304, 8305, 8304, 8307, 8306, + 8314, 8304, 8315, 8304, 8323, 8301, 8324, 8301, 8328, 8304, 8346, 8445, 8347, 8445, 8348, 8347, 8375, 8333, + 8376, 8332, 8377, 8300, 8378, 8334, 8379, 8301, 8380, 260, 8383, 8304, 8384, 8301, 8385, 8301, 8386, 8301, 8387, + 8301, 8393, 8445, 8395, 8445, 8396, 8445, 8397, 8445, 8399, 8445, 8418, 8221, 8423, 8300, 8424, 8300, 8425, + 8309, 8426, 8309, 8427, 8309, 8428, 8309, 8429, 8309, 8431, 8430, 8432, 8430, 8433, 8430, 8434, 8430, 8435, + 8430, 8436, 9215, 8437, 9215, 8438, 9215, 8439, 9215, 8440, 9215, 8441, 9215, 8442, 9215, 8443, 9215, 8444, + 9215, 8455, 8215, 8458, 8208, 8459, 8208, 8460, 8208, 8464, 8300, 8465, 8300, 8467, 8300, 8468, 8300, 8501, + 8500, 8503, 8502, 8505, 8500, 8506, 8500, 8507, 8500, 8508, 8500, 8511, 8500, 8516, 8500, 8518, 8500, 8521, + 8500, 8528, 8500, 8599, 8500, 8640, 290, 8643, 260, 8645, 260, 8646, 8630, 8647, 600, 8652, 740, 8674, 8630, + 8675, 8630, 8679, 260, 8697, 8634, 8698, 8673, 8720, 260, 8803, 260, 9000, 8500, 9153, 8215, 9154, 8215, 9167, + 8215, 9170, 8500, 9171, 8500, 9176, 8500, 9177, 8500, 9179, 8500, 9180, 8500, 9184, 8500, 9185, 8500, 9186, + 8500, 9187, 8500, 9188, 8500, 9189, 8500, 9190, 8500, 9218, 8500, 9222, 8500, 9223, 8500, 9248, 8500, 9261, + 8500, 9300, 8221, 9301, 8221, 9302, 8221, 9303, 8221, 9304, 8221, 9305, 8221, 9306, 8221, 9307, 8221, 9308, + 8221, 9309, 8221, 9310, 8221, 9311, 8221, 9312, 8221, 9313, 8221, 9314, 8221, 9315, 8221, 9316, 8221, 9317, + 8221, 9318, 8221, 9319, 8221, 9344, 8221, 9372, 8221, 9409, 8221, 9853, 9190, + }; + + private static final Map TARGETS; + + static { + Map targets = new HashMap<>(TARGET_IDS.length / 2); + for (int i = 0; i < TARGET_IDS.length; i += 2) targets.put(TARGET_IDS[i], TARGET_IDS[i + 1]); + TARGETS = Map.copyOf(targets); + } + + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + var target = TARGETS.get(declaration.id()); + if (target == null || target == declaration.id()) return declaration; + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + rules.put( + MaterialFactKeys.GENERIFICATION_TARGET, + List.of(MaterialProcessRule.anyForm(new MaterialFactKeys.GenerificationTarget(target)))); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); + } +} diff --git a/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java b/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java new file mode 100644 index 000000000..7ae659e84 --- /dev/null +++ b/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java @@ -0,0 +1,196 @@ +package gregtech.content.material.catalog; + +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.api.material.GTMaterial; +import gregtech.api.material.GTValues; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; +import gregtech.engine.recipe.UnitConversion; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Set; + +/** + * Explicit source phase bindings for audited chemistry and fixed Centrifuge rows. + * Original CS.U=648648000; FL.createMolten uses144mB/U, createGas1000mB/U. + * Physical temperature, texture, and current legacy fluid names do not determine this dimension. + */ +public final class MaterialFluidUnitFacts { + public static final long SOURCE_UNIT = GTValues.U; + + public record Binding( + String materialName, + int materialId, + String phase, + String fluidField, + String registryName, + long referenceSourceUnits, + long referenceMillibuckets) {} + + private static final Binding[] BINDINGS = { + new Binding("AquaRegia", 9827, "liquid", "GenLiquid_AquaRegia", "aquaregia", SOURCE_UNIT, 1000), + new Binding("Glass", 8001, "liquid", "Glass", "glass", SOURCE_UNIT, 144), + new Binding("Blaze", 8211, "liquid", "Blaze", "blaze", SOURCE_UNIT, 1296), + new Binding("BlueVitriol", 8404, "liquid", "GenLiquid_BlueVitriol", "bluevitriol", SOURCE_UNIT, 1000), + new Binding("Plastic", 8218, "liquid", "Plastic", "molten.plastic", SOURCE_UNIT, 1000), + new Binding("Ender", 8318, "liquid", "Ender", "molten.enderpearl", SOURCE_UNIT, 144), + new Binding("Redstone", 8333, "liquid", "Redstone", "molten.redstone", SOURCE_UNIT, 144), + new Binding("Lava", 9810, "liquid", "Lava", "lava", 9 * SOURCE_UNIT, 1000), + new Binding("CFoam", 9883, "liquid", "CFoam", "ic2constructionfoam", SOURCE_UNIT, 100), + new Binding("Rubber", 8217, "liquid", "GenMolten_Rubber", "molten.rubber", SOURCE_UNIT, 144), + new Binding("Sugar", 9703, "liquid", "GenMolten_Sugar", "molten.sugar", SOURCE_UNIT, 144), + new Binding("Cheese", 9780, "liquid", "GenMolten_Cheese", "molten.cheese", SOURCE_UNIT, 144), + new Binding("Cryolite", 8009, "liquid", "GenLiquid_Cryolite", "cryolite", SOURCE_UNIT, 144), + new Binding( + "AluminiumFluoride", + 8010, + "liquid", + "GenLiquid_AluminiumFluoride", + "aluminiumfluoride", + SOURCE_UNIT, + 144), + new Binding( + "LithiumChloride", 8029, "liquid", "GenLiquid_LithiumChloride", "lithiumchloride", SOURCE_UNIT, 144), + new Binding( + "LithiumChlorate", 8033, "liquid", "GenLiquid_LithiumChlorate", "lithiumchlorate", SOURCE_UNIT, 144), + new Binding("CarbonDioxide", 9836, "gas", "CarbonDioxide", "carbondioxide", SOURCE_UNIT, 1000), + new Binding("Chlorine", 170, "gas", "GenGas_Chlorine", "chlorine", SOURCE_UNIT, 1000), + new Binding( + "ChloroplatinicAcid", + 8401, + "liquid", + "GenLiquid_ChloroplatinicAcid", + "chloroplatinicacid", + SOURCE_UNIT, + 1000), + new Binding("CyanVitriol", 8408, "liquid", "GenLiquid_CyanVitriol", "cyanvitriol", SOURCE_UNIT, 1000), + new Binding("Fluorine", 90, "gas", "GenGas_Fluorine", "fluorine", SOURCE_UNIT, 1000), + new Binding("Chocolate", 9783, "liquid", "GenMolten_Chocolate", "molten.chocolate", SOURCE_UNIT, 144), + new Binding("Deuterium", 11, "gas", "Deuterium", "deuterium", SOURCE_UNIT, 1000), + new Binding("FishOil", 9871, "liquid", "Oil_Fish", "fishoil", SOURCE_UNIT, 1000), + new Binding("GrayVitriol", 8410, "liquid", "GenLiquid_GrayVitriol", "grayvitriol", SOURCE_UNIT, 1000), + new Binding("GreenVitriol", 8405, "liquid", "GenLiquid_GreenVitriol", "greenvitriol", SOURCE_UNIT, 1000), + new Binding("HeavyWater", 9812, "liquid", "GenGas_HeavyWater", "heavywater", SOURCE_UNIT, 1000), + new Binding("Helium", 20, "gas", "Helium", "helium", SOURCE_UNIT, 1000), + new Binding("Helium3", 21, "gas", "GenGas_Helium3", "helium3", SOURCE_UNIT, 1000), + new Binding("Honey", 9791, "liquid", "Honey", "honey", SOURCE_UNIT, 1000), + new Binding("Honeydew", 9793, "liquid", "Honeydew", "honeydew", SOURCE_UNIT, 1000), + new Binding( + "HydrochloricAcid", + 9826, + "gas", + "GenGas_HydrochloricAcid", + "hydrochloricacid", + SOURCE_UNIT, + 1000), + new Binding("HydrogenFluoride", 9829, "gas", "GenGas_HydrogenFluoride", "hydrogenfluoride", SOURCE_UNIT, 1000), + new Binding("Hydrogen", 10, "gas", "Hydrogen", "hydrogen", SOURCE_UNIT, 1000), + new Binding("Ice", 9802, "liquid", "Ice", "ice", SOURCE_UNIT, 1000), + new Binding("Mercury", 800, "liquid", "GenLiquid_Mercury", "mercury", SOURCE_UNIT, 144), + new Binding("NitrogenDioxide", 9831, "gas", "GenGas_NitrogenDioxide", "nitrogendioxide", SOURCE_UNIT, 1000), + new Binding("NitrogenMonoxide", 9837, "gas", "GenGas_NitrogenMonoxide", "nitrogenmonoxide", SOURCE_UNIT, 1000), + new Binding("PinkVitriol", 8407, "liquid", "GenLiquid_PinkVitriol", "pinkvitriol", SOURCE_UNIT, 1000), + new Binding("RedVitriol", 8406, "liquid", "GenLiquid_RedVitriol", "redvitriol", SOURCE_UNIT, 1000), + new Binding("SemiheavyWater", 9811, "liquid", "GenGas_SemiheavyWater", "semiheavywater", SOURCE_UNIT, 1000), + new Binding("SulfuricAcid", 9824, "liquid", "GenLiquid_SulfuricAcid", "sulfuricacid", SOURCE_UNIT, 1000), + new Binding("TritiatedWater", 9813, "liquid", "GenGas_TritiatedWater", "tritiatedwater", SOURCE_UNIT, 1000), + new Binding( + "Uranium235Hexafluoride", + 9012, + "gas", + "GenGas_Uranium235Hexafluoride", + "uranium235hexafluoride", + SOURCE_UNIT, + 1000), + new Binding( + "Uranium238Hexafluoride", + 9010, + "gas", + "GenGas_Uranium238Hexafluoride", + "uranium238hexafluoride", + SOURCE_UNIT, + 1000), + new Binding( + "UraniumHexafluoride", + 9008, + "gas", + "GenGas_UraniumHexafluoride", + "uraniumhexafluoride", + SOURCE_UNIT, + 1000), + new Binding("VitriolOfClay", 8412, "liquid", "GenLiquid_VitriolOfClay", "vitriolofclay", SOURCE_UNIT, 1000), + new Binding("Water", 9800, "liquid", "Water", "water", SOURCE_UNIT, 1000), + new Binding("Wax", 8235, "liquid", "GenMolten_Wax", "molten.wax", SOURCE_UNIT, 144), + new Binding("WaxBee", 8236, "liquid", "GenMolten_WaxBee", "molten.waxbee", SOURCE_UNIT, 144), + new Binding("WaxParaffin", 8238, "liquid", "GenMolten_WaxParaffin", "molten.waxparaffin", SOURCE_UNIT, 144), + new Binding("WaxPlant", 8239, "liquid", "GenMolten_WaxPlant", "molten.waxplant", SOURCE_UNIT, 144), + new Binding("WhiteVitriol", 8409, "liquid", "GenLiquid_WhiteVitriol", "whitevitriol", SOURCE_UNIT, 1000), + }; + + private MaterialFluidUnitFacts() {} + + /** Unknown or conflicting source identities are deliberately unsupported, not guessed. */ + static Binding binding(String canonicalName, int materialId, String phase) { + for (Binding binding : BINDINGS) { + if (binding.materialName().equals(canonicalName) + && binding.materialId() == materialId + && binding.phase().equals(phase)) return binding; + } + return null; + } + + public static Binding binding(GTMaterial material, String phase) { + if (material == null || !material.isValid()) return null; + var resolved = material.resolve(); + return MaterialFactKeys.value(resolved, MaterialFactKeys.MATERIAL_FLUID_UNIT) + .flatMap(rule -> rule.units().stream() + .filter(value -> value.phase().equals(phase)) + .findFirst()) + .map(value -> new Binding( + resolved.getName(), + resolved.getId(), + value.phase(), + value.fluidField(), + value.registryPath(), + value.referenceSourceUnits(), + value.referenceMillibuckets())) + .orElse(null); + } + + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + var values = new java.util.ArrayList(); + for (Binding binding : BINDINGS) { + if (binding.materialId() != declaration.id() || !binding.materialName().equals(declaration.name())) continue; + values.add(new MaterialFactKeys.MaterialFluidUnit( + binding.phase(), + binding.fluidField(), + binding.registryName(), + binding.referenceSourceUnits(), + binding.referenceMillibuckets())); + } + if (values.isEmpty()) return declaration; + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + rules.put( + MaterialFactKeys.MATERIAL_FLUID_UNIT, + List.of(MaterialProcessRule.anyForm(new MaterialFactKeys.MaterialFluidUnits(Set.copyOf(values))))); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); + } + + /** + * Original UT.Code.units ratio and final rounding, without signed multiplication overflow. + * Returns -1 for invalid inputs or results outside native FluidStack int capacity; zero stays + * zero, never coerced to1. This is quantity arithmetic, not zero-volume catalyst semantics. + */ + public static int millibuckets(long sourceAmount, long sourceUnit, long referenceMillibuckets, boolean roundUp) { + return UnitConversion.fluidAmount(sourceUnit, referenceMillibuckets, sourceAmount, roundUp); + } +} diff --git a/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java new file mode 100644 index 000000000..962c67aa1 --- /dev/null +++ b/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java @@ -0,0 +1,56 @@ +package gregtech.content.material.catalog; + +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; +import java.util.LinkedHashMap; +import java.util.List; + +/** Material-owned ambient phase and explicit no-default-phase facts for purified Centrifuge. */ +public final class PurifiedCentrifugeMaterialFacts { + private PurifiedCentrifugeMaterialFacts() {} + + private record Phase(int id, String name, MaterialFactKeys.PurifiedCentrifugePhase value) {} + private record None(int id, String name, MaterialFactKeys.PurifiedCentrifugeNoDefault value) {} + + private static final List PHASES = List.of( + new Phase(21, "Helium3", new MaterialFactKeys.PurifiedCentrifugePhase("gas", 1, 4)), + new Phase(90, "Fluorine", new MaterialFactKeys.PurifiedCentrifugePhase("gas", 53, 85)), + new Phase(800, "Mercury", new MaterialFactKeys.PurifiedCentrifugePhase("liquid", 234, 629)), + new Phase(9791, "Honey", new MaterialFactKeys.PurifiedCentrifugePhase("liquid", 273, 373)), + new Phase(9793, "Honeydew", new MaterialFactKeys.PurifiedCentrifugePhase("liquid", 273, 373)), + new Phase(9802, "Ice", new MaterialFactKeys.PurifiedCentrifugePhase("liquid", 273, 373))); + + private static final List NONE = List.of( + new None(1120, "Copernicium", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 150, 357)), + new None(1180, "Oganesson", new MaterialFactKeys.PurifiedCentrifugeNoDefault("gas", 258, 263)), + new None(9110, "Celestine", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 275, 455)), + new None(9199, "DuraniumHexafluoride", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 216, 428)), + new None(9801, "Snow", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 273, 373)), + new None(9851, "OilSand", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 100, 400)), + new None(9852, "CrudeOil", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 100, 400))); + + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + MaterialFactKeys.PurifiedCentrifugePhase phase = null; + MaterialFactKeys.PurifiedCentrifugeNoDefault none = null; + for (Phase value : PHASES) + if (value.id == declaration.id() && value.name.equals(declaration.name())) phase = value.value; + for (None value : NONE) + if (value.id == declaration.id() && value.name.equals(declaration.name())) none = value.value; + if (phase == null && none == null) return declaration; + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + if (phase != null) + rules.put(MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_PHASE, List.of(MaterialProcessRule.anyForm(phase))); + if (none != null) + rules.put(MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT, List.of(MaterialProcessRule.anyForm(none))); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); + } +} diff --git a/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java new file mode 100644 index 000000000..0c78fbea1 --- /dev/null +++ b/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java @@ -0,0 +1,173 @@ +package gregtech.content.material.catalog; + +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** Reviewed processing facts whose payload is bound to exact built-in material identities. */ +public final class ReviewedOreMaterialFacts { + private ReviewedOreMaterialFacts() {} + + /** Bounded baseline ORES-property proof; omission is UNKNOWN, not a negative. */ + private static final Map ORE_INPUT_NO = Map.ofEntries( + Map.entry(8418, "Bamboo"), + Map.entry(8275, "Bark"), + Map.entry(8620, "Brass"), + Map.entry(8610, "Bronze"), + Map.entry(8501, "Concrete"), + Map.entry(8290, "Dreamwood"), + Map.entry(8751, "Duranium"), + Map.entry(8504, "Endstone"), + Map.entry(8035, "FerricOxyhydroxide"), + Map.entry(8698, "Fireleaf"), + Map.entry(9712, "FishRaw"), + Map.entry(8002, "Flint"), + Map.entry(90, "Fluorine"), + Map.entry(9175, "Graphene"), + Map.entry(8296, "Greatwood"), + Map.entry(9802, "Ice"), + Map.entry(8645, "IronMagnetic"), + Map.entry(8241, "Leather"), + Map.entry(9189, "Limestone"), + Map.entry(8289, "Livingwood"), + Map.entry(8506, "Marble"), + Map.entry(9700, "MeatRaw"), + Map.entry(8647, "NeodymiumMagnetic"), + Map.entry(8502, "Netherrack"), + Map.entry(8214, "Obsidian"), + Map.entry(8218, "Plastic"), + Map.entry(8197, "PVC"), + Map.entry(8104, "RedSand"), + Map.entry(8217, "Rubber"), + Map.entry(8297, "Silverwood"), + Map.entry(9801, "Snow"), + Map.entry(8673, "Steeleaf"), + Map.entry(8651, "SteelGalvanized"), + Map.entry(8646, "SteelMagnetic"), + Map.entry(8196, "Teflon"), + Map.entry(8752, "Tritanium"), + Map.entry(8027, "TungsticAcid"), + Map.entry(8221, "Wood"), + Map.entry(8224, "WoodRubber")); + + private static final Set CRUSHED_EXCLUSIONS = Set.of( + "crushed", + "crushedTiny", + "crushedPurified", + "crushedPurifiedTiny", + "crushedCentrifuged", + "crushedCentrifugedTiny"); + + /** Handlers145-150 source ORES/MORTAR/self-pulver profiles. */ + private record ShredderFact(String name, MaterialFactKeys.OreShredderProfile profile) {} + + private static final Map SHREDDER = Map.ofEntries( + Map.entry(290, new ShredderFact("Copper", new MaterialFactKeys.OreShredderProfile(0, true))), + Map.entry(9117, new ShredderFact("Galena", new MaterialFactKeys.OreShredderProfile(0, true))), + Map.entry(8346, new ShredderFact("NetherQuartz", new MaterialFactKeys.OreShredderProfile(3, true))), + Map.entry(9111, new ShredderFact("Chalcopyrite", new MaterialFactKeys.OreShredderProfile(0, true))), + Map.entry(9145, new ShredderFact("Pentlandite", new MaterialFactKeys.OreShredderProfile(0, true))), + Map.entry(9130, new ShredderFact("Sphalerite", new MaterialFactKeys.OreShredderProfile(0, true))), + Map.entry(9132, new ShredderFact("Tetrahedrite", new MaterialFactKeys.OreShredderProfile(0, true))), + Map.entry(9125, new ShredderFact("Pyrite", new MaterialFactKeys.OreShredderProfile(0, true))), + Map.entry(280, new ShredderFact("Nickel", new MaterialFactKeys.OreShredderProfile(2, true))), + Map.entry(9116, new ShredderFact("Cooperite", new MaterialFactKeys.OreShredderProfile(0, true))), + Map.entry(9137, new ShredderFact("YellowLimonite", new MaterialFactKeys.OreShredderProfile(0, true)))); + + private static final Map CRUSHED_SOURCE_MATERIALS = Map.ofEntries( + Map.entry(2220, "Adamantium"), + Map.entry(260, "Iron"), + Map.entry(140, "Silicon"), + Map.entry(130, "Aluminium"), + Map.entry(220, "Titanium"), + Map.entry(740, "Tungsten"), + Map.entry(90, "Fluorine"), + Map.entry(730, "Tantalum"), + Map.entry(410, "Niobium")); + + /** Shared MT3709/w3803 Cinnabar follow-on identity set. */ + private static final MaterialFactKeys.CinnabarFollowonRule CINNABAR_FOLLOWON = + new MaterialFactKeys.CinnabarFollowonRule( + new MaterialFactKeys.Identity(9114, "Cinnabar"), + List.of( + new MaterialFactKeys.Identity(8333, "Redstone"), + new MaterialFactKeys.Identity(160, "Sulfur"), + new MaterialFactKeys.Identity(8341, "Glowstone"), + new MaterialFactKeys.Identity(340, "Selenium")), + new MaterialFactKeys.Identity(8102, "SluiceSand")); + + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + String name = declaration.name(); + if (name.equals(ORE_INPUT_NO.get(declaration.id()))) { + rules.put( + MaterialFactKeys.SOURCE_ORE_INPUT, + List.of(MaterialProcessRule.anyForm(MaterialFactKeys.Decision.NO))); + } + var shredder = SHREDDER.get(declaration.id()); + if (shredder != null && shredder.name().equals(name)) { + rules.put( + MaterialFactKeys.SOURCE_ORE_SHREDDER, + List.of(MaterialProcessRule.anyForm(shredder.profile()))); + } + if (name.equals(CRUSHED_SOURCE_MATERIALS.get(declaration.id()))) { + rules.put( + MaterialFactKeys.SOURCE_CRUSHED_EXCLUSIONS, + List.of(MaterialProcessRule.anyForm( + new MaterialFactKeys.PrefixExclusions(CRUSHED_EXCLUSIONS)))); + } + if (declaration.id() == 9114 && name.equals("Cinnabar")) { + rules.put( + MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON, + List.of(MaterialProcessRule.anyForm(CINNABAR_FOLLOWON))); + } + var generatedFluid = generatedFluid(declaration.id(), name); + if (generatedFluid != null) { + rules.put( + MaterialFactKeys.SOURCE_GENERATED_FLUID, + List.of(MaterialProcessRule.anyForm( + new MaterialFactKeys.GeneratedFluidRules(Set.of(generatedFluid))))); + } + if (declaration.id() == 8745 && name.equals("Netherite") + || declaration.id() == 1740 && name.equals("Naquadah")) { + rules.put( + MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY, + List.of(MaterialProcessRule.anyForm(Boolean.TRUE))); + } + if (declaration.id() == 9802 && name.equals("Ice")) { + rules.put( + MaterialFactKeys.COMPRESSOR_DUST_TO_GEM_PLATE, + List.of(MaterialProcessRule.anyForm(Boolean.FALSE))); + } + if (rules.equals(info.processes().rules())) return declaration; + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); + } + + private static MaterialFactKeys.GeneratedFluidRule generatedFluid(int id, String name) { + return switch (id) { + case 800 -> name.equals("Mercury") + ? new MaterialFactKeys.GeneratedFluidRule("GenLiquid_Mercury", "mercury", 300, 0F, false) + : null; + case 220 -> name.equals("Titanium") + ? new MaterialFactKeys.GeneratedFluidRule( + "GenMolten_Titanium", "molten.titanium", 1941, 4.54F, true) + : null; + case 260 -> name.equals("Iron") + ? new MaterialFactKeys.GeneratedFluidRule("GenMolten_Iron", "molten.iron", 1811, 7.874F, true) + : null; + default -> null; + }; + } +} diff --git a/core/src/main/java/gregtech/content/recipe/ReviewedOreSourceProfile.java b/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java similarity index 72% rename from core/src/main/java/gregtech/content/recipe/ReviewedOreSourceProfile.java rename to core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java index 5f42fa19e..ae671d5f6 100644 --- a/core/src/main/java/gregtech/content/recipe/ReviewedOreSourceProfile.java +++ b/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java @@ -1,28 +1,28 @@ -package gregtech.content.recipe; +package gregtech.content.material.catalog; +import gregtech.api.addon.material.MaterialProcessRule; import gregtech.api.material.GTMaterial; -import gregtech.engine.addon.AddonMaterials; -import gregtech.engine.material.GTMaterialRegistry; +import gregtech.api.material.MaterialProperty; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; -/** Generated from reviewed-source-policy.json. Incomplete by design; absent is UNKNOWN. */ -public final class ReviewedOreSourceProfile { - public enum Decision { - YES, - NO, - UNKNOWN; +import java.util.*; - public boolean orLegacy(boolean legacy) { - return this == UNKNOWN ? legacy : this == YES; - } - } +import static gregtech.content.material.MaterialFactKeys.Decision; - public enum Rule { +/** Bounded source facts whose scope is an exact built-in material identity. */ +public final class ReviewedSourceMaterialFacts { + private ReviewedSourceMaterialFacts() {} + + private enum Rule { FURNACE, GRADED_GEM } private record Entry(int id, String name, Rule rule, Decision decision) {} + /** FURNACE and GRADED_GEM decisions from the reviewed source-policy extract. */ private static final Entry[] ENTRIES = { new Entry(30, "Lithium", Rule.FURNACE, Decision.YES), new Entry(31, "Lithium-6", Rule.FURNACE, Decision.YES), @@ -226,15 +226,99 @@ private record Entry(int id, String name, Rule rule, Decision decision) {} new Entry(9114, "Cinnabar", Rule.GRADED_GEM, Decision.YES), }; - private ReviewedOreSourceProfile() {} + /** Paired MT direct magnetic-tag positives; omission is UNKNOWN, never a negative. */ + private static final Map MAGNETIC = Map.ofEntries( + Map.entry(250, "Manganese"), + Map.entry(260, "Iron"), + Map.entry(270, "Cobalt"), + Map.entry(278, "Cobalt60"), + Map.entry(280, "Nickel"), + Map.entry(600, "Neodymium"), + Map.entry(670, "Holmium"), + Map.entry(830, "Bismuth"), + Map.entry(2220, "Adamantium"), + Map.entry(8030, "FerrousChloride"), + Map.entry(8234, "VanadiumPentoxide"), + Map.entry(8247, "Basalz"), + Map.entry(8630, "Steel"), + Map.entry(8634, "DamascusSteel"), + Map.entry(8635, "Tungstensteel"), + Map.entry(8643, "WroughtIron"), + Map.entry(8645, "IronMagnetic"), + Map.entry(8646, "SteelMagnetic"), + Map.entry(8647, "NeodymiumMagnetic"), + Map.entry(8653, "VanadiumSteel"), + Map.entry(8661, "Invar"), + Map.entry(8662, "Constantan"), + Map.entry(8672, "Ironwood"), + Map.entry(8673, "Steeleaf"), + Map.entry(8674, "Knightmetal"), + Map.entry(8675, "FierySteel"), + Map.entry(8679, "Thaumium"), + Map.entry(8685, "ChromiumDioxide"), + Map.entry(8697, "FlamascusSteel"), + Map.entry(8698, "Fireleaf"), + Map.entry(8704, "VibraniumSteel"), + Map.entry(8706, "Vibramantium"), + Map.entry(8727, "ConductiveIron"), + Map.entry(8730, "ElectricalSteel"), + Map.entry(8744, "AncientDebris"), + Map.entry(8745, "Netherite"), + Map.entry(8746, "NetherizedDiamond"), + Map.entry(8747, "Efrine"), + Map.entry(8784, "Adamantine"), + Map.entry(8803, "CastIron"), + Map.entry(9003, "BasalticMineralSand"), + Map.entry(9004, "GraniticMineralSand"), + Map.entry(9104, "Hematite"), + Map.entry(9106, "BrownLimonite"), + Map.entry(9115, "Cobaltite"), + Map.entry(9118, "Garnierite"), + Map.entry(9120, "Ilmenite"), + Map.entry(9122, "Magnetite"), + Map.entry(9125, "Pyrite"), + Map.entry(9126, "Pyrolusite"), + Map.entry(9137, "YellowLimonite"), + Map.entry(9143, "VanadiumMagnetite"), + Map.entry(9145, "Pentlandite")); + + private static final Set SIFTING_ABSENT = Set.of("gemLegendary", "gemExquisite", "gemFlawless"); - public static Decision decision(GTMaterial material, Rule rule) { - if (material == null || !material.isValid()) return Decision.UNKNOWN; - material = material.resolve(); - if (AddonMaterials.owns(material) || !GTMaterialRegistry.isCoreMaterial(material)) return Decision.UNKNOWN; - for (Entry row : ENTRIES) - if (row.id == material.getId() && row.name.equals(material.getName()) && row.rule == rule) - return row.decision; - return Decision.UNKNOWN; + public static MaterialDefinition.Declaration applyOne(MaterialDefinition.Declaration declaration) { + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + for (var entry : ENTRIES) { + if (entry.id != declaration.id() + || !GTMaterial.sanitize(entry.name).equals(declaration.name())) continue; + var key = entry.rule == Rule.FURNACE ? MaterialFactKeys.SOURCE_FURNACE : MaterialFactKeys.SOURCE_GRADED_GEM; + rules.put(key, List.of(MaterialProcessRule.anyForm(entry.decision))); + } + if (declaration.id() == 9802 && declaration.name().equals("Ice")) { + rules.put( + MaterialFactKeys.SOURCE_SIFTING_EXCLUSIONS, + List.of(MaterialProcessRule.anyForm(new MaterialFactKeys.PrefixExclusions(SIFTING_ABSENT)))); + } + + var material = declaration.material(); + if (MAGNETIC.get(declaration.id()) != null + && MAGNETIC.get(declaration.id()).equals(declaration.name())) { + var properties = EnumSet.noneOf(MaterialProperty.class); + properties.addAll(material.properties()); + properties.add(MaterialProperty.MAGNETIC); + material = new MaterialDefinition( + material.identity(), + material.presentation(), + material.physical(), + properties, + material.source()); + } + if (rules.equals(info.processes().rules()) && material == declaration.material()) return declaration; + return new MaterialDefinition.Declaration( + material, + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); } } diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java new file mode 100644 index 000000000..46e060ae4 --- /dev/null +++ b/core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java @@ -0,0 +1,797 @@ +package gregtech.content.material.catalog; + +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** Native GT6 MT factory/direct extrusion flags and forging targets, pinned to 3703e403. + * Generated from GT6 {@code MT.java} at 3703e403; absence is not inferred from the port's broad METAL flag. + * Profiles are bound to exact native identities; addons are not assigned original identities by name. + */ +public final class SourceExtrusionMaterialFacts { + private SourceExtrusionMaterialFacts() {} + + public record Profile(boolean extrudable, boolean simple, boolean smithable, String target, long forgingAmount) {} + + private record Row(String name, Profile profile) {} + + private static final Map ROWS = new HashMap<>(); + private static final String DATA = """ + 0|Empty|000||648648000 + 1|Photon|000||648648000 + 2|Neutrino|000||648648000 + 3|Neutron|000||648648000 + 4|Proton|000||648648000 + 5|Electron|000||648648000 + 10|Hydrogen|000||648648000 + 11|Deuterium|000||648648000 + 12|Tritium|000||648648000 + 20|Helium|000||648648000 + 21|Helium3|000||648648000 + 30|Lithium|111||648648000 + 31|Lithium6|111||648648000 + 40|Beryllium|101||648648000 + 41|Beryllium7|101||648648000 + 42|Beryllium8|101||648648000 + 50|Boron|101||648648000 + 51|Boron11|101||648648000 + 60|Carbon|000||648648000 + 61|Carbon13|000||648648000 + 62|Carbon14|000||648648000 + 70|Nitrogen|000||648648000 + 80|Oxygen|000||648648000 + 90|Fluorine|000||648648000 + 100|Neon|000||648648000 + 110|Sodium|111||648648000 + 120|Magnesium|111||648648000 + 130|Aluminium|111||648648000 + 140|Silicon|101||648648000 + 150|Phosphor|000||648648000 + 160|Sulfur|000||648648000 + 170|Chlorine|000||648648000 + 180|Argon|000||648648000 + 190|Potassium|111||648648000 + 200|Calcium|111||648648000 + 210|Scandium|101||648648000 + 220|Titanium|101||648648000 + 230|Vanadium|101||648648000 + 240|Chromium|101||648648000 + 250|Manganese|101||648648000 + 260|Iron|101||648648000 + 270|Cobalt|101||648648000 + 278|Cobalt60|101||648648000 + 280|Nickel|101||648648000 + 290|Copper|111||648648000 + 300|Zinc|111||648648000 + 310|Gallium|111||648648000 + 320|Germanium|111||648648000 + 330|Arsenic|111||648648000 + 340|Selenium|000||648648000 + 350|Bromine|000||648648000 + 360|Krypton|000||648648000 + 370|Rubidium|111||648648000 + 380|Strontium|111||648648000 + 390|Yttrium|101||648648000 + 400|Zirconium|101||648648000 + 410|Niobium|101||648648000 + 420|Molybdenum|101||648648000 + 430|Technetium|101||648648000 + 440|Ruthenium|101||648648000 + 450|Rhodium|101||648648000 + 460|Palladium|101||648648000 + 470|Silver|101||648648000 + 480|Cadmium|111||648648000 + 490|Indium|111||648648000 + 500|Tin|111||648648000 + 510|Antimony|111||648648000 + 520|Tellurium|111||648648000 + 530|Iodine|000||648648000 + 540|Xenon|000||648648000 + 550|Caesium|111||648648000 + 560|Barium|111||648648000 + 570|Lanthanium|111||648648000 + 580|Cerium|111||648648000 + 590|Praseodymium|101||648648000 + 600|Neodymium|101||648648000 + 610|Promethium|101||648648000 + 620|Samarium|101||648648000 + 630|Europium|111||648648000 + 640|Gadolinium|101||648648000 + 650|Terbium|101||648648000 + 660|Dysprosium|101||648648000 + 670|Holmium|101||648648000 + 680|Erbium|101||648648000 + 690|Thulium|101||648648000 + 700|Ytterbium|111||648648000 + 710|Lutetium|101||648648000 + 720|Hafnium|101||648648000 + 730|Tantalum|101||648648000 + 740|Tungsten|101||648648000 + 750|Rhenium|101||648648000 + 760|OsmiumElemental|101||648648000 + 770|Iridium|101||648648000 + 780|Platinum|101||648648000 + 790|Gold|101||648648000 + 791|Gold198|101||648648000 + 800|Mercury|111||648648000 + 810|Thallium|111||648648000 + 820|Lead|111||648648000 + 830|Bismuth|111||648648000 + 840|Polonium|111||648648000 + 850|Astatine|111||648648000 + 860|Radon|000||648648000 + 870|Francium|111||648648000 + 880|Radium|111||648648000 + 890|Actinium|101||648648000 + 900|Thorium|101||648648000 + 910|Protactinium|101||648648000 + 920|Uranium|101||648648000 + 921|Uranium235|101||648648000 + 922|Uranium233|101||648648000 + 930|Neptunium|111||648648000 + 940|Plutonium|111||648648000 + 942|Plutonium240|111||648648000 + 943|Plutonium241|111||648648000 + 945|Plutonium243|111||648648000 + 946|Plutonium238|111||648648000 + 947|Plutonium239|111||648648000 + 950|Americium|101||648648000 + 951|Americium241|101||648648000 + 952|Americium242|101||648648000 + 960|Curium|101||648648000 + 970|Berkelium|101||648648000 + 980|Californium|111||648648000 + 990|Einsteinium|111||648648000 + 1000|Fermium|111||648648000 + 1010|Mendelevium|111||648648000 + 1020|Nobelium|111||648648000 + 1030|Lawrencium|101||648648000 + 1040|Rutherfordium|101||648648000 + 1050|Dubnium|111||648648000 + 1060|Seaborgium|111||648648000 + 1070|Bohrium|111||648648000 + 1080|Hassium|111||648648000 + 1090|Meitnerium|000||648648000 + 1100|Darmstadtium|000||648648000 + 1110|Roentgenium|000||648648000 + 1120|Copernicium|111||648648000 + 1130|Nihonium|000||648648000 + 1140|Flerovium|111||648648000 + 1148|Flerovium298|111||648648000 + 1150|Moscovium|000||648648000 + 1160|Livermorium|000||648648000 + 1170|Farnsium|000||648648000 + 1180|Oganesson|000||648648000 + 1250|TritaniumElemental|101||648648000 + 1260|Trinium|101||648648000 + 1450|DuraniumElemental|111||648648000 + 1520|Vibranium|000||648648000 + 1740|Naquadah|101||648648000 + 1741|NaquadahEnriched|101||648648000 + 1742|Naquadria|101||648648000 + 2220|Adamantium|101||648648000 + 3720|Gravitonium|000||648648000 + 4000|Magic|000||648648000 + 8000|SiliconDioxide|000||648648000 + 8001|Glass|110||648648000 + 8002|Flint|000||648648000 + 8003|Carborundum|101||648648000 + 8006|Datolite|000||648648000 + 8007|HydrogenBorate|000||648648000 + 8008|Alumina|000||648648000 + 8009|Cryolite|000||648648000 + 8010|AluminiumFluoride|000||648648000 + 8011|HexafluorosilicicAcid|000||648648000 + 8012|SodiumAluminate|000||648648000 + 8013|SodiumCarbonate|000||648648000 + 8014|AluminiumHydroxide|000||648648000 + 8015|PotassiumHydroxide|000||648648000 + 8016|MagnesiumCarbonate|000||648648000 + 8017|FerricChloride|000||648648000 + 8018|MagnesiumChloride|000||648648000 + 8019|SodiumNitrate|000||648648000 + 8020|PotassiumCarbonate|000||648648000 + 8021|PotassiumSulfite|000||648648000 + 8022|PotassiumPersulfate|000||648648000 + 8023|PotassiumAluminate|000||648648000 + 8024|HydrosulfuricAcid|000||648648000 + 8025|Ammonia|000||648648000 + 8026|TungstenTrioxide|000||648648000 + 8027|TungsticAcid|000||648648000 + 8028|CalciumChloride|000||648648000 + 8029|LithiumChloride|000||648648000 + 8030|FerrousChloride|000||648648000 + 8031|ManganeseChloride|000||648648000 + 8032|LithiumHydroxide|000||648648000 + 8033|LithiumChlorate|000||648648000 + 8034|LithiumPerchlorate|000||648648000 + 8035|FerricOxyhydroxide|000||648648000 + 8036|PotassiumFluoride|000||648648000 + 8037|SodiumFluoride|000||648648000 + 8038|PotassiumHeptafluorotantalate|000||648648000 + 8039|SodiumHydrogencarbonate|000||648648000 + 8100|Sand|000||648648000 + 8101|Soulsand|000||648648000 + 8102|SluiceSand|000||648648000 + 8103|PlatinumGroupSludge|000||648648000 + 8104|RedSand|000||648648000 + 8196|Teflon|110||648648000 + 8197|PVC|110||648648000 + 8200|Ashes|000||648648000 + 8201|DarkAshes|000||648648000 + 8203|Sylvite|000||648648000 + 8204|Salt|000||648648000 + 8205|PotassiumNitrate|000||648648000 + 8206|Niter|000||648648000 + 8207|Phosphate|000||648648000 + 8208|Phosphorus|000||648648000 + 8209|Apatite|000||648648000 + 8210|Blizz|000||648648000 + 8211|Blaze|000||648648000 + 8214|Obsidian|000||648648000 + 8215|Clay|000||648648000 + 8216|Paper|000||648648000 + 8217|Rubber|110||648648000 + 8218|Plastic|110||648648000 + 8219|Bone|000||648648000 + 8220|Gunpowder|000||648648000 + 8221|Wood|000||648648000 + 8222|WoodTreated|000||648648000 + 8223|LiveRoot|000||648648000 + 8224|WoodRubber|000||648648000 + 8225|Ceramic|000||648648000 + 8226|Phosphorite|000||648648000 + 8229|CobaltHexahydrate|000||648648000 + 8230|SodiumBisulfate|000||648648000 + 8231|SodiumPyrosulfate|000||648648000 + 8232|PotassiumBisulfate|000||648648000 + 8233|PotassiumPyrosulfate|000||648648000 + 8234|VanadiumPentoxide|000||648648000 + 8235|Wax|110||648648000 + 8236|WaxBee|110||648648000 + 8238|WaxParaffin|110||648648000 + 8239|WaxPlant|110||648648000 + 8241|Leather|000||648648000 + 8242|IodineSalt|000||648648000 + 8247|Basalz|000||648648000 + 8248|Blitz|000||648648000 + 8249|Dynamite|000||648648000 + 8250|DyeBlack|000||648648000 + 8251|DyeRed|000||648648000 + 8252|DyeGreen|000||648648000 + 8253|DyeBrown|000||648648000 + 8254|DyeBlue|000||648648000 + 8255|DyePurple|000||648648000 + 8256|DyeCyan|000||648648000 + 8257|DyeLightGray|000||648648000 + 8258|DyeGray|000||648648000 + 8259|DyePink|000||648648000 + 8260|DyeLime|000||648648000 + 8261|DyeYellow|000||648648000 + 8262|DyeLightBlue|000||648648000 + 8263|DyeMagenta|000||648648000 + 8264|DyeOrange|000||648648000 + 8265|DyeWhite|000||648648000 + 8266|Asphalt|110||648648000 + 8267|WoodPolished|000||648648000 + 8268|SodiumHydroxide|000||648648000 + 8269|SodiumSulfite|000||648648000 + 8270|SodiumSulfate|000||648648000 + 8271|PotassiumSulfate|000||648648000 + 8272|PotassiumSulfide|000||648648000 + 8273|Porcelain|000||648648000 + 8274|CalciumSulfate|000||648648000 + 8275|Bark|000||648648000 + 8276|ClayBrown|000||648648000 + 8277|PetrifiedWood|000||648648000 + 8278|ManaDiamond|000||648648000 + 8289|Livingwood|000||648648000 + 8290|Dreamwood|000||648648000 + 8296|Greatwood|000||648648000 + 8297|Silverwood|000||648648000 + 8298|EnergiumRed|000||648648000 + 8299|EnergiumCyan|000||648648000 + 8300|Diamond|000||648648000 + 8301|Emerald|000||648648000 + 8302|Ruby|000||648648000 + 8303|BalasRuby|000||648648000 + 8304|Sapphire|000||648648000 + 8305|GreenSapphire|000||648648000 + 8306|Topaz|000||648648000 + 8307|BlueTopaz|000||648648000 + 8308|Tanzanite|000||648648000 + 8309|RedJasper|000||648648000 + 8310|Amber|000||648648000 + 8311|Peridot|000||648648000 + 8312|Opal|000||648648000 + 8313|Amethyst|000||648648000 + 8314|OrangeSapphire|000||648648000 + 8315|YellowSapphire|000||648648000 + 8318|EnderPearl|000||648648000 + 8319|EnderEye|000||648648000 + 8320|NetherStar|000||648648000 + 8321|Jade|000||648648000 + 8322|Craponite|000||648648000 + 8323|Aquamarine|000||648648000 + 8324|Morganite|000||648648000 + 8325|Dioptase|000||648648000 + 8326|Spinel|000||648648000 + 8328|BlueSapphire|000||648648000 + 8330|Lazurite|000||648648000 + 8331|Sodalite|000||648648000 + 8332|Lapis|000||648648000 + 8333|Redstone|000||648648000 + 8334|Coal|000||648648000 + 8335|HydratedCoal|000||648648000 + 8336|Charcoal|000||648648000 + 8337|Lignite|000||648648000 + 8338|Monazite|000||648648000 + 8340|Nikolite|000||648648000 + 8341|Glowstone|000||648648000 + 8342|Firestone|000||648648000 + 8346|NetherQuartz|000||648648000 + 8347|CertusQuartz|000||648648000 + 8348|ChargedCertusQuartz|000||648648000 + 8349|CoalCoke|000||648648000 + 8360|Peat|000||648648000 + 8365|LigniteCoke|000||648648000 + 8383|PurpleSapphire|000||648648000 + 8384|Heliodor|000||648648000 + 8385|Goshenite|000||648648000 + 8386|Bixbite|000||648648000 + 8387|Maxixe|000||648648000 + 8389|Fluix|000||648648000 + 8390|PetroleumCoke|000||648648000 + 8393|SunnyQuartz|000||648648000 + 8395|RedQuartz|000||648648000 + 8396|BlazeQuartz|000||648648000 + 8397|SmokeyQuartz|000||648648000 + 8399|ElvenQuartz|000||648648000 + 8400|ChloroauricAcid|000||648648000 + 8401|ChloroplatinicAcid|000||648648000 + 8402|StannicChloride|000||648648000 + 8403|BlackVitriol|000||648648000 + 8404|BlueVitriol|000||648648000 + 8405|GreenVitriol|000||648648000 + 8406|RedVitriol|000||648648000 + 8407|PinkVitriol|000||648648000 + 8408|CyanVitriol|000||648648000 + 8409|WhiteVitriol|000||648648000 + 8410|GrayVitriol|000||648648000 + 8412|VitriolOfClay|000||648648000 + 8413|TitaniumTetrachloride|000||648648000 + 8415|OnyxRed|000||648648000 + 8416|OnyxBlack|000||648648000 + 8417|Amazonite|000||648648000 + 8418|Bamboo|000||648648000 + 8419|Zircon|000||648648000 + 8420|Azurite|000||648648000 + 8421|Eudialyte|000||648648000 + 8423|DiamondIndustrial|000||648648000 + 8424|PinkDiamond|000||648648000 + 8425|OceanJasper|000||648648000 + 8426|RainforestJasper|000||648648000 + 8427|BlueJasper|000||648648000 + 8428|GreenJasper|000||648648000 + 8429|YellowJasper|000||648648000 + 8430|TigerEye|000||648648000 + 8431|CatsEye|000||648648000 + 8432|DragonEye|000||648648000 + 8433|HawksEye|000||648648000 + 8434|BlackEye|000||648648000 + 8435|TigerIron|000||648648000 + 8436|RedFluorite|000||648648000 + 8437|PinkFluorite|000||648648000 + 8438|BlueFluorite|000||648648000 + 8439|GreenFluorite|000||648648000 + 8440|BlackFluorite|000||648648000 + 8441|WhiteFluorite|000||648648000 + 8442|YellowFluorite|000||648648000 + 8443|OrangeFluorite|000||648648000 + 8444|MagentaFluorite|000||648648000 + 8445|MilkyQuartz|000||648648000 + 8446|BrownAventurine|000||648648000 + 8447|YellowAventurine|000||648648000 + 8448|GreenAventurine|000||648648000 + 8449|BlackAventurine|000||648648000 + 8450|BlueAventurine|000||648648000 + 8451|RedAventurine|000||648648000 + 8455|ClayRed|000||648648000 + 8458|BluePhosphorus|000||648648000 + 8459|RedPhosphorus|000||648648000 + 8460|WhitePhosphorus|000||648648000 + 8461|NiobiumPentoxide|000||648648000 + 8462|TantalumPentoxide|000||648648000 + 8464|BlueDiamond|000||648648000 + 8465|GreenDiamond|000||648648000 + 8467|RedDiamond|000||648648000 + 8468|YellowDiamond|000||648648000 + 8470|Carminite|000||648648000 + 8471|Breeze|000||648648000 + 8500|Stone|110||648648000 + 8501|Concrete|110||648648000 + 8502|Netherrack|110||648648000 + 8503|NetherBrick|110||648648000 + 8504|Endstone|110||648648000 + 8505|Basalt|110||648648000 + 8506|Marble|110||648648000 + 8507|GraniteRed|110||648648000 + 8508|GraniteBlack|110||648648000 + 8511|Diorite|110||648648000 + 8516|MarsSand|110||648648000 + 8518|Granite|110||648648000 + 8521|Livingrock|110||648648000 + 8528|SkyStone|110||648648000 + 8599|Bedrock|000||648648000 + 8600|Electrum|101||648648000 + 8601|SterlingSilver|101||648648000 + 8602|RoseGold|101||648648000 + 8605|CdInAgAlloy|101||648648000 + 8610|Bronze|111||648648000 + 8611|BlackBronze|101||648648000 + 8612|BismuthBronze|111||648648000 + 8614|ArsenicCopper|111||648648000 + 8615|ArsenicBronze|111||648648000 + 8620|Brass|111||648648000 + 8621|CobaltBrass|111||648648000 + 8622|AluminiumAlloy|101||648648000 + 8630|Steel|101||648648000 + 8631|BlackSteel|101||648648000 + 8632|BlueSteel|101||648648000 + 8633|RedSteel|101||648648000 + 8634|DamascusSteel|101||648648000 + 8635|Tungstensteel|101||648648000 + 8636|StainlessSteel|101||648648000 + 8638|TungstenCarbide|101||648648000 + 8640|AnnealedCopper|111||648648000 + 8643|WroughtIron|101||648648000 + 8645|IronMagnetic|101|Fe|648648000 + 8646|SteelMagnetic|101|Steel|648648000 + 8647|NeodymiumMagnetic|101|Nd|648648000 + 8651|SteelGalvanized|101|Steel|648648000 + 8652|TungstenSintered|101||648648000 + 8653|VanadiumSteel|101||648648000 + 8658|ElectrotineAlloy|111||648648000 + 8659|BlueAlloy|111||648648000 + 8660|RedAlloy|111||648648000 + 8661|Invar|101||648648000 + 8662|Constantan|101||648648000 + 8663|Nichrome|101||648648000 + 8664|Kanthal|101||648648000 + 8665|Magnalium|111||648648000 + 8666|Ultimet|101||648648000 + 8667|TinAlloy|111||648648000 + 8668|BatteryAlloy|111||648648000 + 8669|SolderingAlloy|111||648648000 + 8672|Ironwood|111||648648000 + 8673|Steeleaf|101||648648000 + 8674|Knightmetal|101||648648000 + 8675|FierySteel|101||648648000 + 8679|Thaumium|101||648648000 + 8682|Osmiridium|101||648648000 + 8684|Trinaquadalloy|101||648648000 + 8685|ChromiumDioxide|101||648648000 + 8686|VanadiumGallium|101||648648000 + 8687|YttriumBariumCuprate|101||648648000 + 8689|NiobiumTitanium|101||648648000 + 8697|FlamascusSteel|101||648648000 + 8698|Fireleaf|101||648648000 + 8700|AluminiumBrass|111||648648000 + 8702|Alumite|101||648648000 + 8704|VibraniumSteel|101||648648000 + 8705|VibraniumSilver|101||648648000 + 8706|Vibramantium|101||648648000 + 8708|Signalum|111||648648000 + 8709|Lumium|111||648648000 + 8710|Enderium|101||648648000 + 8717|Cyanite|101||648648000 + 8720|Manasteel|101||648648000 + 8721|Terrasteel|101||648648000 + 8722|ElvenElementium|101||648648000 + 8726|VibrantAlloy|101||648648000 + 8727|ConductiveIron|101||648648000 + 8729|EnderiumBase|101||648648000 + 8730|ElectricalSteel|101||648648000 + 8732|Soularium|101||648648000 + 8733|RedstoneAlloy|101||648648000 + 8735|GaiaSpirit|101||648648000 + 8737|NikolineAlloy|101||648648000 + 8744|AncientDebris|101||648648000 + 8745|Netherite|101||648648000 + 8746|NetherizedDiamond|101||648648000 + 8747|Efrine|101||648648000 + 8751|Duranium|101||648648000 + 8752|Tritanium|101||648648000 + 8756|Duralumin|101||648648000 + 8784|Adamantine|101||648648000 + 8790|Trinitanium|101||648648000 + 8793|TitaniumIridium|101||648648000 + 8796|HSSG|101||648648000 + 8797|HSSE|101||648648000 + 8798|HSSS|101||648648000 + 8799|CrystalMatrix|101||648648000 + 8800|CosmicNeutronium|101||648648000 + 8802|TantalumHafniumCarbide|101||648648000 + 8803|CastIron|101||648648000 + 9000|Pumice|110||648648000 + 9001|Diatomite|000||648648000 + 9003|BasalticMineralSand|000||648648000 + 9004|GraniticMineralSand|000||648648000 + 9005|GarnetSand|000||648648000 + 9006|QuartzSand|000||648648000 + 9007|UraniumTetrafluoride|000||648648000 + 9008|UraniumHexafluoride|000||648648000 + 9009|Uranium238Tetrafluoride|000||648648000 + 9010|Uranium238Hexafluoride|000||648648000 + 9011|Uranium235Tetrafluoride|000||648648000 + 9012|Uranium235Hexafluoride|000||648648000 + 9100|RareEarth|000||648648000 + 9101|Almandine|000||648648000 + 9102|Andradite|000||648648000 + 9103|Asbestos|110||648648000 + 9104|Hematite|000||648648000 + 9105|Bauxite|000||648648000 + 9106|BrownLimonite|000||648648000 + 9107|Calcite|000||648648000 + 9108|Cassiterite|000||648648000 + 9109|Realgar|000||648648000 + 9110|Celestine|000||648648000 + 9111|Chalcopyrite|000||648648000 + 9113|Chromite|000||648648000 + 9114|Cinnabar|000||648648000 + 9115|Cobaltite|000||648648000 + 9116|Cooperite|000||648648000 + 9117|Galena|000||648648000 + 9118|Garnierite|000||648648000 + 9119|Grossular|000||648648000 + 9120|Ilmenite|000||648648000 + 9122|Magnetite|000||648648000 + 9123|Molybdenite|000||648648000 + 9124|Powellite|000||648648000 + 9125|Pyrite|000||648648000 + 9126|Pyrolusite|000||648648000 + 9127|Pyrope|000||648648000 + 9128|Scheelite|000||648648000 + 9129|Spessartine|000||648648000 + 9130|Sphalerite|000||648648000 + 9131|Stibnite|000||648648000 + 9132|Tetrahedrite|000||648648000 + 9133|Tungstate|000||648648000 + 9134|Uraninite|000||648648000 + 9135|Uvarovite|000||648648000 + 9136|Wulfenite|000||648648000 + 9137|YellowLimonite|000||648648000 + 9138|Perlite|000||648648000 + 9139|Borax|000||648648000 + 9140|PotassiumFeldspar|000||648648000 + 9141|Biotite|000||648648000 + 9143|VanadiumMagnetite|000||648648000 + 9144|Bastnasite|000||648648000 + 9145|Pentlandite|000||648648000 + 9146|Spodumene|000||648648000 + 9147|Pollucite|000||648648000 + 9148|Tantalite|000||648648000 + 9149|Lepidolite|000||648648000 + 9150|Glauconite|000||648648000 + 9152|Vermiculite|000||648648000 + 9153|Bentonite|000||648648000 + 9154|Palygorskite|000||648648000 + 9155|Pitchblende|000||648648000 + 9156|Malachite|000||648648000 + 9157|Mirabilite|000||648648000 + 9158|Mica|000||648648000 + 9159|Trona|000||648648000 + 9160|Barite|000||648648000 + 9161|Gypsum|000||648648000 + 9162|Alunite|000||648648000 + 9164|Wollastonite|000||648648000 + 9165|Zeolite|000||648648000 + 9166|Kyanite|000||648648000 + 9167|Kaolinite|000||648648000 + 9169|Talc|000||648648000 + 9171|Greenschist|110||648648000 + 9174|Graphite|000||648648000 + 9175|Graphene|000||648648000 + 9177|Komatiite|110||648648000 + 9180|Quartzite|110||648648000 + 9184|Blueschist|110||648648000 + 9185|Bluestone|110||648648000 + 9186|Chert|110||648648000 + 9187|Dacite|110||648648000 + 9188|Andesite|110||648648000 + 9189|Limestone|110||648648000 + 9190|Shale|110||648648000 + 9192|Rutile|000||648648000 + 9193|Stolzite|000||648648000 + 9194|Ferberite|000||648648000 + 9195|Huebnerite|000||648648000 + 9196|Russellite|000||648648000 + 9197|Pinalite|000||648648000 + 9198|DiduraniumTrioxide|000||648648000 + 9199|DuraniumHexafluoride|000||648648000 + 9200|DuraniumHexachloride|000||648648000 + 9201|DuraniumHexabromide|000||648648000 + 9202|DuraniumHexaiodide|000||648648000 + 9203|DuraniumHexaastatide|000||648648000 + 9204|TritaniumDioxide|000||648648000 + 9205|TritaniumHexafluoride|000||648648000 + 9206|TritaniumHexachloride|000||648648000 + 9207|TritaniumHexabromide|000||648648000 + 9208|TritaniumHexaiodide|000||648648000 + 9209|TritaniumHexaastatide|000||648648000 + 9210|Bromargyrite|000||648648000 + 9211|Smithsonite|000||648648000 + 9212|Sperrylite|000||648648000 + 9213|Kesterite|000||648648000 + 9214|Stannite|000||648648000 + 9215|Fluorite|000||648648000 + 9216|Arsenopyrite|000||648648000 + 9217|Wolframite|000||648648000 + 9218|Kimberlite|110||648648000 + 9219|Prismarine|110||648648000 + 9220|PrismarineDark|110||648648000 + 9221|Bischofite|000||648648000 + 9222|Slate|110||648648000 + 9223|Blackstone|110||648648000 + 9243|ClayBrick|000||648648000 + 9246|Columbite|000||648648000 + 9247|Coltan|000||648648000 + 9248|Deepslate|110||648648000 + 9261|TitanRock|110||648648000 + 9271|Quicklime|000||648648000 + 9300|Oak|000||648648000 + 9301|Birch|000||648648000 + 9302|Spruce|000||648648000 + 9303|Junglewood|000||648648000 + 9304|Acacia|000||648648000 + 9305|DarkOak|000||648648000 + 9306|Crimsonwood|000||648648000 + 9307|Warpedwood|000||648648000 + 9308|WoodCompressed|000||648648000 + 9309|WoodDead|000||648648000 + 9310|WoodRotten|000||648648000 + 9311|WoodMossy|000||648648000 + 9312|WoodFrozen|000||648648000 + 9313|Maple|000||648648000 + 9314|Willow|000||648648000 + 9315|BlueMahoe|000||648648000 + 9316|Hazel|000||648648000 + 9317|Cinnamonwood|000||648648000 + 9318|Coconutwood|000||648648000 + 9319|Rainbowood|000||648648000 + 9344|Cherrywood|000||648648000 + 9372|Mangrove|000||648648000 + 9409|BlueSpruce|000||648648000 + 9700|MeatRaw|110|MeatCooked|648648000 + 9701|MeatCooked|110||648648000 + 9702|Wheat|000||648648000 + 9703|Sugar|000||648648000 + 9705|Rye|000||648648000 + 9709|Potato|000||648648000 + 9710|MeatRotten|110||648648000 + 9711|FishCooked|110||648648000 + 9712|FishRaw|110|FishCooked|648648000 + 9713|FishRotten|110||648648000 + 9779|SoylentGreen|110||648648000 + 9780|Cheese|110||648648000 + 9781|Chili|000||648648000 + 9782|Cocoa|000||648648000 + 9783|Chocolate|110||648648000 + 9784|Coffee|000||648648000 + 9785|Cinnamon|000||648648000 + 9790|Milk|000||648648000 + 9791|Honey|000||648648000 + 9792|Tea|000||648648000 + 9793|Honeydew|000||648648000 + 9794|Mint|000||648648000 + 9796|Hazelnut|000||648648000 + 9800|Water|000||648648000 + 9801|Snow|000||648648000 + 9802|Ice|000||648648000 + 9803|FreshWater|000||648648000 + 9804|Saltwater|000||648648000 + 9805|HolyWater|000||648648000 + 9806|SeaWater|000||648648000 + 9808|WaterDistilled|000||648648000 + 9809|HydrogenPeroxide|000||648648000 + 9810|Lava|000||648648000 + 9811|SemiheavyWater|000||648648000 + 9812|HeavyWater|000||648648000 + 9813|TritiatedWater|000||648648000 + 9814|Steam|000||648648000 + 9815|SaltedWater|000||648648000 + 9820|NitroCarbon|000||648648000 + 9821|Glyceryl|000||648648000 + 9822|SodiumPersulfate|000||648648000 + 9823|SodiumSulfide|000||648648000 + 9824|SulfuricAcid|000||648648000 + 9825|NitricAcid|000||648648000 + 9826|HydrochloricAcid|000||648648000 + 9827|AquaRegia|000||648648000 + 9828|Glycerol|000||648648000 + 9829|HydrogenFluoride|000||648648000 + 9830|Air|000||648648000 + 9831|NitrogenDioxide|000||648648000 + 9832|Methane|000||648648000 + 9833|MethaneIce|000||648648000 + 9834|SulfurDioxide|000||648648000 + 9835|SulfurTrioxide|000||648648000 + 9836|CarbonDioxide|000||648648000 + 9837|NitrogenMonoxide|000||648648000 + 9838|CarbonMonoxide|000||648648000 + 9839|HeliumNeon|000||648648000 + 9840|Biomass|000||648648000 + 9841|BioFuel|000||648648000 + 9842|Ethanol|000||648648000 + 9843|CarbonTrioxide|000||648648000 + 9844|DisulfuricAcid|000||648648000 + 9850|Oil|000||648648000 + 9851|OilSand|000||648648000 + 9852|CrudeOil|000||648648000 + 9853|OilShale|000||648648000 + 9860|Fuel|000||648648000 + 9861|NitroFuel|000||648648000 + 9862|Kerosine|000||648648000 + 9863|Diesel|000||648648000 + 9864|Petrol|000||648648000 + 9865|Propane|000||648648000 + 9866|Butane|000||648648000 + 9867|Propylene|000||648648000 + 9868|Ethylene|000||648648000 + 9870|Creosote|000||648648000 + 9871|FishOil|000||648648000 + 9872|SeedOil|000||648648000 + 9873|HempOil|000||648648000 + 9874|LinOil|000||648648000 + 9875|SunflowerOil|000||648648000 + 9876|NutOil|000||648648000 + 9877|OliveOil|000||648648000 + 9880|FryingOilHot|000||648648000 + 9881|Glue|000||648648000 + 9882|Lubricant|000||648648000 + 9883|ConstructionFoam|000||648648000 + 9886|Latex|000||648648000 + """; + + static { + for (String line : DATA.strip().split("\n")) { + String[] f = line.strip().split("\\|", -1); + ROWS.put( + Integer.parseInt(f[0]), + new Row( + f[1], + new Profile( + f[2].charAt(0) == '1', + f[2].charAt(1) == '1', + f[2].charAt(2) == '1', + f[3], + Long.parseLong(f[4])))); + } + } + + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + Row row = ROWS.get(declaration.id()); + if (row == null || !sameName(row.name(), declaration.name())) return declaration; + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + rules.put(MaterialFactKeys.SOURCE_EXTRUSION, List.of(MaterialProcessRule.anyForm(row.profile()))); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); + } + + /** The source list spells e.g. {@code SpaceStone} where the port spells {@code Space Stone}. */ + private static boolean sameName(String source, String port) { + if (source.equals(port)) return true; + return source.replaceAll("[^A-Za-z0-9]", "").equalsIgnoreCase(port.replaceAll("[^A-Za-z0-9]", "")); + } +} diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceLensRoles.java b/core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java similarity index 76% rename from minecraft/src/main/java/gregtech/content/recipe/SourceLensRoles.java rename to core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java index e5512919a..180f29d48 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceLensRoles.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java @@ -1,19 +1,18 @@ -package gregtech.content.recipe; +package gregtech.content.material.catalog; // source-rows: the per-row MT line numbers are transcription labels. -import gregtech.api.material.GTMaterial; -import gregtech.content.data.MaterialPrefix; -import gregtech.content.registry.GTItems; -import gregtech.engine.material.GTMaterialRegistry; -import java.util.ArrayList; +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; +import java.util.LinkedHashMap; import java.util.List; -import net.minecraft.world.item.ItemStack; /** Explicit MT.lens roles, including diamond/emerald/sapphire/garnet/jasper/tigereye/aventurine factories. * Source: GregTech6 3703e40308c8c030763fd6297dea8b210d2a77b1, MT.java. * Color is a crafting role, never inferred from RGB. IDs and canonical names guard native identities. */ -public final class SourceLensRoles { +public final class SourceLensMaterialFacts { public enum Color { WHITE, RED, @@ -86,28 +85,27 @@ private record Role(int id, String name, Color color) {} new Role(8450, "BlueAventurine", Color.BLUE) /* MT:1421 */, new Role(8451, "RedAventurine", Color.RED) /* MT:1422 */); - private SourceLensRoles() {} + private SourceLensMaterialFacts() {} - public static Color color(GTMaterial material) { - if (material == null || !material.isValid() || gregtech.engine.addon.AddonMaterials.owns(material)) return null; - for (Role role : ROLES) - if (material.getId() == role.id - && material.getName().replace(" ", "").equals(role.name) - && GTMaterialRegistry.get(role.id) == material - && GTMaterialRegistry.get(role.name) == material) return role.color; - return null; - } - - /** Only actual registered native lens holders; recipe matching retains normal form/tag equivalence. */ - public static List lenses(Color color) { - var result = new ArrayList(); + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { for (Role role : ROLES) { - if (role.color != color) continue; - var material = GTMaterialRegistry.get(role.id); - if (color(material) != color) continue; - var lens = GTItems.getStack(MaterialPrefix.lens, material, 1); - if (!lens.isEmpty()) result.add(lens); + if (role.id != declaration.id()) continue; + if (!materialNameMatches(role.name, declaration.name())) continue; + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + rules.put(MaterialFactKeys.SOURCE_LENS_ROLE, List.of(MaterialProcessRule.anyForm(role.color))); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); } - return List.copyOf(result); + return declaration; + } + + private static boolean materialNameMatches(String source, String port) { + return source.equals(port); } } diff --git a/core/src/main/java/gregtech/content/recipe/SourceOreMacerationFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java similarity index 82% rename from core/src/main/java/gregtech/content/recipe/SourceOreMacerationFacts.java rename to core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java index e58483218..76c999121 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOreMacerationFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java @@ -1,12 +1,16 @@ -package gregtech.content.recipe; - -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; +package gregtech.content.material.catalog; +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Set; /** * Producer-local MORTAR facts for 997 exact default input identities. Original GT6 is pinned at - * 3703e40308c8c030763fd6297dea8b210d2a77b1. SourceRecyclingFacts supplies ONLY the canonical identity + * 3703e40308c8c030763fd6297dea8b210d2a77b1. SourceRecyclingMaterialFacts supplies ONLY the canonical identity * and declaration location; its thermal flags, smelting targets and native fingerprints are not gates. * *

Both positive and negative sets were closed over MT factories/declarations. Element metal and @@ -22,10 +26,10 @@ * not proof of a native item's ownership, registration, generation eligibility or output availability. * External/addon overrides must be handled by the native caller before using these facts. */ -public final class SourceOreMacerationFacts { - private SourceOreMacerationFacts() {} +public final class SourceMacerationMaterialFacts { + private SourceMacerationMaterialFacts() {} - // 589 source positives: factory closure, original element condition, or explicit declaration. + // 588 source positives: factory closure, original element condition, or explicit declaration. private static final Set MORTAR_YES = Set.of( 30, 31, 40, 60, 110, 120, 130, 150, 160, 190, 200, 260, 270, 278, 280, 290, 300, 310, 320, 330, 370, 380, 470, 480, 490, 500, 510, 520, 550, 560, 570, 580, 630, 700, 780, 790, 800, 810, 820, 830, 840, 850, 870, @@ -86,10 +90,23 @@ private SourceOreMacerationFacts() {} 9133, 9134, 9135, 9140, 9141, 9164, 9169, 9183, 9192, 9193, 9194, 9195, 9196, 9197, 9198, 9199, 9200, 9201, 9202, 9203, 9204, 9205, 9206, 9207, 9208, 9209, 9217, 9820, 9824, 9825, 9827, 9844, 9851, 9852, 9853, 9883); - public static Decision mortar(int id, String canonicalName) { - if (SourceRecyclingFacts.find(id, canonicalName) == null) return Decision.UNKNOWN; - if (MORTAR_YES.contains(id)) return Decision.YES; - if (MORTAR_NO.contains(id)) return Decision.NO; - return Decision.UNKNOWN; + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + if (SourceRecyclingMaterialFacts.find(declaration.id(), declaration.name()) == null) return declaration; + var decision = MORTAR_YES.contains(declaration.id()) + ? MaterialFactKeys.Decision.YES + : MORTAR_NO.contains(declaration.id()) + ? MaterialFactKeys.Decision.NO + : MaterialFactKeys.Decision.UNKNOWN; + if (decision == MaterialFactKeys.Decision.UNKNOWN) return declaration; + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + rules.put(MaterialFactKeys.SOURCE_MACERATION, List.of(MaterialProcessRule.anyForm(decision))); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); } } diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java new file mode 100644 index 000000000..28de11199 --- /dev/null +++ b/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java @@ -0,0 +1,63 @@ +package gregtech.content.material.catalog; + +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; +import java.util.LinkedHashMap; +import java.util.List; + +/** Material-specific source Crusher/Hammer facts; host rocks are owned by {@code OreHostFacts}. */ +public final class SourceOreCrushingMaterialFacts { + private SourceOreCrushingMaterialFacts() {} + + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + var hexorium = hexorium(declaration.id(), declaration.name()); + var reviewed = SourceRecyclingMaterialFacts.find(declaration.id(), declaration.name()); + if (reviewed == null && hexorium == MaterialFactKeys.HexoriumKind.NONE) return declaration; + var fact = new MaterialFactKeys.OreCrushingFact( + pulverizing(declaration.id(), declaration.name(), hexorium), hexorium); + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + rules.put(MaterialFactKeys.SOURCE_ORE_CRUSHING, List.of(MaterialProcessRule.anyForm(fact))); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); + } + + private static MaterialFactKeys.Decision pulverizing( + int id, String name, MaterialFactKeys.HexoriumKind hexorium) { + if (hexorium != MaterialFactKeys.HexoriumKind.NONE) + return MaterialFactKeys.Decision.NO; + return id == 800 && name.equals("Mercury") + || id == 8333 && name.equals("Redstone") + || id == 9114 && name.equals("Cinnabar") + ? MaterialFactKeys.Decision.YES + : MaterialFactKeys.Decision.NO; + } + + private static MaterialFactKeys.HexoriumKind hexorium(int id, String name) { + return switch (id) { + case 9224 -> name.equals("HexoriumBlack") + ? MaterialFactKeys.HexoriumKind.BLACK_WHITE + : MaterialFactKeys.HexoriumKind.NONE; + case 9239 -> name.equals("HexoriumWhite") + ? MaterialFactKeys.HexoriumKind.BLACK_WHITE + : MaterialFactKeys.HexoriumKind.NONE; + case 9225 -> name.equals("HexoriumRed") + ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE + : MaterialFactKeys.HexoriumKind.NONE; + case 9226 -> name.equals("HexoriumGreen") + ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE + : MaterialFactKeys.HexoriumKind.NONE; + case 9228 -> name.equals("HexoriumBlue") + ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE + : MaterialFactKeys.HexoriumKind.NONE; + default -> MaterialFactKeys.HexoriumKind.NONE; + }; + } +} diff --git a/core/src/main/java/gregtech/content/recipe/SourceRecyclingFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java similarity index 95% rename from core/src/main/java/gregtech/content/recipe/SourceRecyclingFacts.java rename to core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java index 0477a39be..8d3196376 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceRecyclingFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java @@ -1,13 +1,15 @@ -package gregtech.content.recipe; +package gregtech.content.material.catalog; -import static gregtech.api.material.GTValues.U; +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; + +import java.util.*; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import static gregtech.api.material.GTValues.U; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; /** * Finite facts for the existing dust-or-ingot 1U thermal recycling producer, not global material metadata. @@ -23,14 +25,8 @@ * loop at 657-662. Source density is not inferred here: the planner consumes valid runtime density, * target melting and actual fluid temperature without claiming imported-stat parity. */ -public final class SourceRecyclingFacts { - private SourceRecyclingFacts() {} - - public enum Decision { - YES, - NO, - UNKNOWN - } +public final class SourceRecyclingMaterialFacts { + private SourceRecyclingMaterialFacts() {} public enum PhaseKind { DEFAULT_BINDING, @@ -44,15 +40,6 @@ public enum Accessor { GAS } - public record Identity(int id, String name) { - public Identity { - Objects.requireNonNull(name); - } - - public boolean matches(int materialId, String canonicalName) { - return id == materialId && name.equals(canonicalName); - } - } /** The source path is provenance, not a promise of the same modern native registry spelling. */ public record Binding( String sourceRegistryPath, @@ -97,6 +84,7 @@ public record Facts( long targetUnitsPerU, Phase phase, PortDefaults portDefaults, + boolean inputEligible, int sourceLine) { public Facts { Objects.requireNonNull(identity); @@ -105,6 +93,7 @@ public record Facts( Objects.requireNonNull(furnace); Objects.requireNonNull(target); Objects.requireNonNull(phase); + Objects.requireNonNull(portDefaults); if (targetUnitsPerU < 0 || sourceLine <= 0) throw new IllegalArgumentException("Invalid source fact"); } } @@ -143,34 +132,46 @@ private record Seed(Identity identity, int flags, int targetId, long amount, int private static final Set OPTIONAL_EXTERNAL = Set.of( 120, 130, 220, 260, 270, 280, 290, 300, 320, 470, 500, 780, 790, 820, 8318, 8333, 8341, 8600, 8610, 8630, 8661, 8700, 8702, 8708, 8709, 8710, 8752); + private static final Map SOURCE_MOLTEN_FLUIDS = Map.ofEntries( + Map.entry(62, "Carbon14"), + Map.entry(1250, "TritaniumElemental"), + Map.entry(1260, "Trinium"), + Map.entry(1450, "DuraniumElemental"), + Map.entry(1740, "Naquadah"), + Map.entry(1741, "NaquadahEnriched"), + Map.entry(1742, "Naquadria"), + Map.entry(8020, "PotassiumCarbonate"), + Map.entry(8026, "TungstenTrioxide"), + Map.entry(8030, "FerrousChloride"), + Map.entry(8034, "LithiumPerchlorate"), + Map.entry(8266, "Asphalt"), + Map.entry(8500, "Stone"), + Map.entry(9120, "Ilmenite"), + Map.entry(9192, "Rutile")); private static final Map BY_ID = createFacts(); - private static final List ALL = List.copyOf(BY_ID.values()); - // These two output-only identities have no default 1U input, but their own target metadata - // still participates in the Melter target-to-Calcite gate. Reviewed port defaults, not source flags. - private static final Map TARGET_ONLY_DEFAULTS = Map.of( - 9800, new PortDefaults(false, new Identity(9800, "Water"), U, false), - 9810, new PortDefaults(false, new Identity(9810, "Lava"), U, false)); /** Null means unsupported identity, never an implicit source-negative decision. */ - public static Facts find(int id, String canonicalName) { + static Facts find(int id, String canonicalName) { Facts value = BY_ID.get(id); return value != null && value.identity().matches(id, canonicalName) ? value : null; } - public static PortDefaults defaults(int id, String canonicalName) { - Facts facts = find(id, canonicalName); - return facts == null ? null : facts.portDefaults(); - } - /** Includes the two reviewed target-only profiles; this does not grant input-form eligibility. */ - public static PortDefaults contextDefaults(int id, String canonicalName) { - Facts facts = find(id, canonicalName); - return facts == null - ? null - : facts.portDefaults() != null ? facts.portDefaults() : TARGET_ONLY_DEFAULTS.get(id); - } - - public static List all() { - return ALL; + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + Facts facts = find(declaration.id(), declaration.name()); + if (facts == null) return declaration; + var info = declaration.info(); + var rules = new java.util.LinkedHashMap<>(info.processes().rules()); + rules.put(MaterialFactKeys.SOURCE_RECYCLING, List.of(MaterialProcessRule.anyForm(facts))); + if (declaration.name().equals(SOURCE_MOLTEN_FLUIDS.get(declaration.id()))) { + rules.put(MaterialFactKeys.SOURCE_MOLTEN_FLUID, List.of(MaterialProcessRule.anyForm(Boolean.TRUE))); + } + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); } private static Decision decision(int flags, int bit) { @@ -199,8 +200,12 @@ private static Map createFacts() { binding, optional); boolean melting = decision(seed.flags(), M) == Decision.YES; - PortDefaults port = null; - if (id != 9800 && id != 9810) { + boolean inputEligible = id != 9800 && id != 9810; + PortDefaults port; + if (!inputEligible) { + // Output-only identities still carry target metadata for Melter context queries. + port = new PortDefaults(false, seed.identity(), U, false); + } else { boolean nativeMelting = PORT_EXTRA_MELTING.contains(id) || (melting && !PORT_NO_MELTING.contains(id)); boolean self = PORT_SELF_TARGET.contains(id); port = new PortDefaults( @@ -220,6 +225,7 @@ private static Map createFacts() { seed.amount(), phase, port, + inputEligible, seed.sourceLine())); } for (int id : bindings.keySet()) diff --git a/core/src/main/java/gregtech/content/recipe/SourceOreWashingData.java b/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java similarity index 84% rename from core/src/main/java/gregtech/content/recipe/SourceOreWashingData.java rename to core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java index 0da7da726..c2d5271f4 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOreWashingData.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java @@ -1,20 +1,26 @@ -package gregtech.content.recipe; +package gregtech.content.material.catalog; +import gregtech.api.addon.material.MaterialProcessRule; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; + +import java.util.LinkedHashMap; import java.util.List; import java.util.Set; /** * Bounded, exact-identity washing facts from original GT6 MT at * 3703e40308c8c030763fd6297dea8b210d2a77b1 (W: 607771f74acb0fe647f7e9412676e72094799545). - * Includes every source positive (20 Mercury, 12 Persulfate, 29 Firestone; 59 identities), - * including the nine inherited refractmetal Firestone tags at MT. The 109 explicit - * negatives are source-declared candidates of the 159 reviewed positive-candidate/tag cases, - * not a blanket default for SupplementalMaterials, addons, or arbitrary matching names. + * Includes every source positive tag edge (20 Mercury, 12 Persulfate, 29 Firestone; 54 + * identities). The current 142 exact identity rows also retain reviewed negatives and + * multi-tag declarations; they are not a blanket default for SupplementalMaterials, addons, + * or arbitrary matching names. * IDs AND canonical names must agree; callers must separately verify native provenance * and must not use these facts as defaults for unreviewed or replaced material identities. */ -public final class SourceOreWashingData { - private SourceOreWashingData() {} +public final class SourceWashingMaterialFacts { + private SourceWashingMaterialFacts() {} public enum Tag { MERCURY, @@ -22,12 +28,6 @@ public enum Tag { FIRESTONE } - public enum Decision { - YES, - NO, - UNKNOWN - } - public record Binding(int materialId, String materialName, Set tags, int sourceLine) { public Binding { tags = Set.copyOf(tags); @@ -184,24 +184,24 @@ private static Binding row(int id, String name, int line, Tag... tags) { row(9214, "Stannite", 3721), row(9216, "Arsenopyrite", 3715)); - public static List bindings() { - return BINDINGS; - } - - public static Binding binding(int id, String canonicalName) { + private static Binding binding(int id, String canonicalName) { for (Binding binding : BINDINGS) if (binding.materialId() == id && binding.materialName().equals(canonicalName)) return binding; return null; } - /** Null means unreviewed, not a known empty source tag set. */ - public static Set expectedTags(int id, String canonicalName) { - Binding binding = binding(id, canonicalName); - return binding == null ? null : binding.tags(); - } - public static Decision decision(int id, String canonicalName, Tag tag) { - Binding binding = binding(id, canonicalName); - if (binding == null || tag == null) return Decision.UNKNOWN; - return binding.tags().contains(tag) ? Decision.YES : Decision.NO; + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + Binding binding = binding(declaration.id(), declaration.name()); + if (binding == null) return declaration; + var info = declaration.info(); + var rules = new LinkedHashMap<>(info.processes().rules()); + rules.put(MaterialFactKeys.SOURCE_WASHING, List.of(MaterialProcessRule.anyForm(binding))); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(rules))); } } diff --git a/core/src/main/java/gregtech/content/recipe/FurnaceSmeltingRules.java b/core/src/main/java/gregtech/content/recipe/FurnaceSmeltingRules.java index 7f3c2f993..3c15cb8d8 100644 --- a/core/src/main/java/gregtech/content/recipe/FurnaceSmeltingRules.java +++ b/core/src/main/java/gregtech/content/recipe/FurnaceSmeltingRules.java @@ -1,10 +1,13 @@ /* Gregorius Techneticies / GregTech-6 Team source rules, LGPL-3.0-or-later. */ package gregtech.content.recipe; -import gregtech.api.material.*; +import gregtech.api.material.GTMaterial; +import gregtech.api.material.GTValues; +import gregtech.api.material.MaterialProperty; import gregtech.content.data.MaterialPrefix; import gregtech.content.data.generated.MaterialWorkability; -import gregtech.engine.material.*; +import gregtech.content.material.MaterialFactKeys; + import java.math.BigInteger; import java.util.List; @@ -38,7 +41,7 @@ public long amount() { public static boolean allows(GTMaterial material) { if (material == null || !material.isValid()) return false; var decision = OreSourcePolicy.furnaceDecision(material); - return decision == SourceRecyclingFacts.Decision.UNKNOWN + return decision == MaterialFactKeys.Decision.UNKNOWN ? legacyAllows(material) : reviewedAllows(decision, material.resolve().has(MaterialProperty.HIDDEN)); } @@ -51,8 +54,8 @@ public static boolean legacyAllows(GTMaterial material) { } /** Shared routing guard for known source decisions. UNKNOWN callers choose their own old fallback; * the source FURNACE fact itself is not rewritten to pretend HIDDEN means source UNUSED. */ - public static boolean reviewedAllows(SourceRecyclingFacts.Decision decision, boolean hidden) { - return decision == SourceRecyclingFacts.Decision.YES && !hidden; + public static boolean reviewedAllows(MaterialFactKeys.Decision decision, boolean hidden) { + return decision == MaterialFactKeys.Decision.YES && !hidden; } /** Target solidifying amount is U, not the source material's smelting amount again. */ public static long amount(long formAmount, long smeltingPerUnit) { diff --git a/core/src/main/java/gregtech/content/recipe/GenerifyingRules.java b/core/src/main/java/gregtech/content/recipe/GenerifyingRules.java index 7918ca205..9fdc82441 100644 --- a/core/src/main/java/gregtech/content/recipe/GenerifyingRules.java +++ b/core/src/main/java/gregtech/content/recipe/GenerifyingRules.java @@ -1,51 +1,12 @@ package gregtech.content.recipe; import gregtech.api.material.GTValues; -import java.util.HashMap; -import java.util.Map; import java.util.Set; -/** - * GT6's generifier rule: every material whose {@code mTargetGenerifying} differs from itself becomes - * one {@code RecipeMapHandlerMaterial} on {@code RM.Generifier}, and that handler expands over every - * prefix the condition {@code And(SIMPLIFIABLE, ingotHot.NOT)} accepts. Each row converts one item of - * a form in the source material into one item of the same form in the target material; the duration - * is the form's material weight in ticks, the EU cost is zero, and nothing converts back. - * - *

The material targets are {@code MT.java}'s {@code setGenerifying} calls plus the - * {@code ANY.*.mToThis} loops that follow them, keyed by GT6 material id so the table does not depend - * on display names. {@code ANY} groups that point at a plain material other than their own name - * (ashes, gems, woods, wax, rubber, plastics, phosphorus, clay, silicon) are already folded into the - * targets, because the loops overwrite the explicit rows they contain.

- */ +/** Form applicability and cost for the generifier recipe family. */ public final class GenerifyingRules { private GenerifyingRules() {} - /** {@code MT.java} {@code setGenerifying} rows and {@code ANY.*.mToThis} loops, as source/target ids. */ - private static final int[] TARGET_IDS = { - 8196, 8218, 8197, 8218, 8201, 8200, 8222, 8221, 8224, 8221, 8236, 8235, 8238, 8235, 8239, 8235, 8267, 8221, - 8276, 8215, 8278, 8300, 8289, 8221, 8290, 8221, 8296, 8221, 8297, 8221, 8302, 8304, 8305, 8304, 8307, 8306, - 8314, 8304, 8315, 8304, 8323, 8301, 8324, 8301, 8328, 8304, 8346, 8445, 8347, 8445, 8348, 8347, 8375, 8333, - 8376, 8332, 8377, 8300, 8378, 8334, 8379, 8301, 8380, 260, 8383, 8304, 8384, 8301, 8385, 8301, 8386, 8301, 8387, - 8301, 8393, 8445, 8395, 8445, 8396, 8445, 8397, 8445, 8399, 8445, 8418, 8221, 8423, 8300, 8424, 8300, 8425, - 8309, 8426, 8309, 8427, 8309, 8428, 8309, 8429, 8309, 8431, 8430, 8432, 8430, 8433, 8430, 8434, 8430, 8435, - 8430, 8436, 9215, 8437, 9215, 8438, 9215, 8439, 9215, 8440, 9215, 8441, 9215, 8442, 9215, 8443, 9215, 8444, - 9215, 8455, 8215, 8458, 8208, 8459, 8208, 8460, 8208, 8464, 8300, 8465, 8300, 8467, 8300, 8468, 8300, 8501, - 8500, 8503, 8502, 8505, 8500, 8506, 8500, 8507, 8500, 8508, 8500, 8511, 8500, 8516, 8500, 8518, 8500, 8521, - 8500, 8528, 8500, 8599, 8500, 8640, 290, 8643, 260, 8645, 260, 8646, 8630, 8647, 600, 8652, 740, 8674, 8630, - 8675, 8630, 8679, 260, 8697, 8634, 8698, 8673, 8720, 260, 8803, 260, 9000, 8500, 9153, 8215, 9154, 8215, 9167, - 8215, 9170, 8500, 9171, 8500, 9176, 8500, 9177, 8500, 9179, 8500, 9180, 8500, 9184, 8500, 9185, 8500, 9186, - 8500, 9187, 8500, 9188, 8500, 9189, 8500, 9190, 8500, 9218, 8500, 9222, 8500, 9223, 8500, 9248, 8500, 9261, - 8500, 9300, 8221, 9301, 8221, 9302, 8221, 9303, 8221, 9304, 8221, 9305, 8221, 9306, 8221, 9307, 8221, 9308, - 8221, 9309, 8221, 9310, 8221, 9311, 8221, 9312, 8221, 9313, 8221, 9314, 8221, 9315, 8221, 9316, 8221, 9317, - 8221, 9318, 8221, 9319, 8221, 9344, 8221, 9372, 8221, 9409, 8221, 9853, 9190, - }; - - /** - * GT6 {@code OP.java} prefixes carrying {@code TD.Prefix.SIMPLIFIABLE}, under the port's prefix - * name ({@code OP.casingSmall} is {@code itemCasing} and {@code OP.boule} is {@code bouleGt}). - * {@code OP.ingotHot} carries no SIMPLIFIABLE tag, which is how hot ingots stay out of the rule. - */ private static final Set SIMPLIFIABLE = Set.of( "arrowGtPlastic", "arrowGtWood", @@ -149,26 +110,10 @@ private GenerifyingRules() {} "wireGt15", "wireGt16"); - private static final Map TARGETS; - - static { - Map targets = new HashMap<>(TARGET_IDS.length / 2); - for (int i = 0; i < TARGET_IDS.length; i += 2) targets.put(TARGET_IDS[i], TARGET_IDS[i + 1]); - TARGETS = Map.copyOf(targets); - } - - /** The target material id, or {@code materialId} itself when the source has no conversion. */ - public static int target(int materialId) { - Integer target = TARGETS.get(materialId); - return target == null ? materialId : target; - } - - /** Whether the source applies the material conversion to this form at all. */ public static boolean simplifiable(String prefixName) { return SIMPLIFIABLE.contains(prefixName); } - /** {@code RecipeMapHandlerMaterial.getCosts}: the form's material weight in ticks, at least one. */ public static long duration(long formWeight) { return Math.max(1, (formWeight + GTValues.U - 1) / GTValues.U); } diff --git a/core/src/main/java/gregtech/content/recipe/OreSourcePolicy.java b/core/src/main/java/gregtech/content/recipe/OreSourcePolicy.java index 0e1d89343..742c1cd50 100644 --- a/core/src/main/java/gregtech/content/recipe/OreSourcePolicy.java +++ b/core/src/main/java/gregtech/content/recipe/OreSourcePolicy.java @@ -2,6 +2,8 @@ import gregtech.api.material.GTMaterial; import gregtech.api.material.MaterialProperty; +import gregtech.content.material.MaterialFactKeys; +import gregtech.content.material.catalog.SourceRecyclingMaterialFacts; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.GTMaterialRegistry; import java.util.ArrayList; @@ -18,23 +20,27 @@ private OreSourcePolicy() {} /** Pure observations used to test default/override boundaries without mutating the registry. * Native callers must obtain ownership observations from the actual registry, not matching names. */ public record FurnaceContext( - SourceRecyclingFacts.Identity material, + MaterialFactKeys.Identity material, boolean coreMaterial, boolean addonMaterial, boolean melting, - SourceRecyclingFacts.Identity target, + MaterialFactKeys.Identity target, boolean coreTarget, boolean addonTarget, long targetUnitsPerU) {} - public static SourceRecyclingFacts.Decision furnaceDecision(GTMaterial material) { + public static MaterialFactKeys.Decision furnaceDecision(GTMaterial material) { var facts = reviewedFurnaceFacts(material); - return facts == null ? SourceRecyclingFacts.Decision.UNKNOWN : facts.furnace(); + if (facts != null) + return facts.furnace() == MaterialFactKeys.Decision.YES + ? MaterialFactKeys.Decision.YES + : MaterialFactKeys.Decision.NO; + return reviewedDecision(material, MaterialFactKeys.SOURCE_FURNACE); } /** Null is unsupported context, not a reviewed source prohibition. Hidden/form availability * remain separate caller guards; HIDDEN is not claimed equivalent to the source UNUSED tag. */ - public static SourceRecyclingFacts.Facts reviewedFurnaceFacts(GTMaterial material) { + public static SourceRecyclingMaterialFacts.Facts reviewedFurnaceFacts(GTMaterial material) { if (material == null || !material.isValid()) return null; var resolved = material.resolve(); if (!resolved.isValid()) return null; @@ -43,17 +49,17 @@ public static SourceRecyclingFacts.Facts reviewedFurnaceFacts(GTMaterial materia target = target.resolve(); if (!target.isValid()) return null; return reviewedFurnaceContext(new FurnaceContext( - new SourceRecyclingFacts.Identity(resolved.getId(), resolved.getName()), + new MaterialFactKeys.Identity(resolved.getId(), resolved.getName()), GTMaterialRegistry.isCoreMaterial(resolved), AddonMaterials.owns(resolved), resolved.has(MaterialProperty.MELTING), - new SourceRecyclingFacts.Identity(target.getId(), target.getName()), + new MaterialFactKeys.Identity(target.getId(), target.getName()), GTMaterialRegistry.isCoreMaterial(target), AddonMaterials.owns(target), resolved.getTargetSmeltingAmount())); } - public static SourceRecyclingFacts.Facts reviewedFurnaceContext(FurnaceContext context) { + public static SourceRecyclingMaterialFacts.Facts reviewedFurnaceContext(FurnaceContext context) { if (context == null || context.material() == null || context.target() == null @@ -62,8 +68,11 @@ public static SourceRecyclingFacts.Facts reviewedFurnaceContext(FurnaceContext c || !context.coreTarget() || context.addonTarget()) return null; var identity = context.material(); - var facts = SourceRecyclingFacts.find(identity.id(), identity.name()); - var defaults = SourceRecyclingFacts.contextDefaults(identity.id(), identity.name()); + var material = GTMaterialRegistry.get(identity.id()); + var facts = material.isValid() && material.getName().equals(identity.name()) + ? MaterialFactKeys.sourceRecycling(material).orElse(null) + : null; + var defaults = facts == null ? null : facts.portDefaults(); return facts != null && defaults != null && defaults.matches( @@ -79,23 +88,20 @@ public static boolean furnaceInput(GTMaterial material) { if (material == null || !material.isValid()) return false; var resolved = material.resolve(); var decision = furnaceDecision(resolved); - if (decision != SourceRecyclingFacts.Decision.UNKNOWN) + if (decision != MaterialFactKeys.Decision.UNKNOWN) return FurnaceSmeltingRules.reviewedAllows(decision, resolved.has(MaterialProperty.HIDDEN)); // Preserve this caller's old bounded profile/MELTING compatibility behavior only for UNKNOWN. - return ReviewedOreSourceProfile.decision(resolved, ReviewedOreSourceProfile.Rule.FURNACE) - .orLegacy(resolved.has(MaterialProperty.MELTING)); + return resolved.has(MaterialProperty.MELTING); } /** Reviewed native inputs belong to the later source furnace listener, not legacy dust-first producers. */ public static boolean usesReviewedFurnaceListener(GTMaterial material) { if (material == null || !material.isValid()) return false; var resolved = material.resolve(); var decision = furnaceDecision(resolved); - if (decision != SourceRecyclingFacts.Decision.UNKNOWN) + if (decision != MaterialFactKeys.Decision.UNKNOWN) return FurnaceSmeltingRules.reviewedAllows(decision, resolved.has(MaterialProperty.HIDDEN)); // Do not reserve unknown inputs unless their pre-existing reviewed listener path already did. - return ReviewedOreSourceProfile.decision(material, ReviewedOreSourceProfile.Rule.FURNACE) - == ReviewedOreSourceProfile.Decision.YES - && FurnaceSmeltingRules.allows(material); + return false; } /** Loader_Recipes_Ores389-393: only opposite magnetic class, declaration order unchanged. */ public static List magneticCandidates(GTMaterial material) { @@ -108,6 +114,11 @@ public static List magneticCandidates(GTMaterial material) { /** Direct paired-source magnetic positives; omitted/addon identities retain legacy flags. */ private static boolean magneticClass(GTMaterial material) { var m = material.resolve(); - return ReviewedMagneticMaterials.sourcePositive(m) || m.has(MaterialProperty.MAGNETIC); + return m.has(MaterialProperty.MAGNETIC); + } + + private static MaterialFactKeys.Decision reviewedDecision( + GTMaterial material, gregtech.api.addon.material.MaterialProcessKey key) { + return MaterialFactKeys.value(material, key).orElse(MaterialFactKeys.Decision.UNKNOWN); } } diff --git a/core/src/main/java/gregtech/content/recipe/OriginalMaterialFluidUnits.java b/core/src/main/java/gregtech/content/recipe/OriginalMaterialFluidUnits.java deleted file mode 100644 index d8feeb7bd..000000000 --- a/core/src/main/java/gregtech/content/recipe/OriginalMaterialFluidUnits.java +++ /dev/null @@ -1,104 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.api.material.GTValues; -import gregtech.engine.recipe.UnitConversion; - -/** - * Explicit source phase bindings for audited chemistry and fixed Centrifuge rows. - * Original CS.U=648648000; FL.createMolten uses144mB/U, createGas1000mB/U. - * Physical temperature, texture, and current legacy fluid names do not determine this dimension. - */ -public final class OriginalMaterialFluidUnits { - public static final long SOURCE_UNIT = GTValues.U; - - public record Binding( - String materialName, - int materialId, - String phase, - String fluidField, - String registryName, - long referenceSourceUnits, - long referenceMillibuckets) {} - - private static final Binding[] BINDINGS = { - new Binding("Cryolite", 8009, "liquid", "GenLiquid_Cryolite", "cryolite", SOURCE_UNIT, 144), - new Binding( - "AluminiumFluoride", - 8010, - "liquid", - "GenLiquid_AluminiumFluoride", - "aluminiumfluoride", - SOURCE_UNIT, - 144), - new Binding( - "LithiumChloride", 8029, "liquid", "GenLiquid_LithiumChloride", "lithiumchloride", SOURCE_UNIT, 144), - new Binding( - "LithiumChlorate", 8033, "liquid", "GenLiquid_LithiumChlorate", "lithiumchlorate", SOURCE_UNIT, 144), - new Binding("CarbonDioxide", 9836, "gas", "CarbonDioxide", "carbondioxide", SOURCE_UNIT, 1000), - new Binding("Fluorine", 90, "gas", "GenGas_Fluorine", "fluorine", SOURCE_UNIT, 1000), - new Binding("Chocolate", 9783, "liquid", "GenMolten_Chocolate", "molten.chocolate", SOURCE_UNIT, 144), - new Binding("Deuterium", 11, "gas", "Deuterium", "deuterium", SOURCE_UNIT, 1000), - new Binding("FishOil", 9871, "liquid", "Oil_Fish", "fishoil", SOURCE_UNIT, 1000), - new Binding("HeavyWater", 9812, "liquid", "GenGas_HeavyWater", "heavywater", SOURCE_UNIT, 1000), - new Binding("Helium", 20, "gas", "Helium", "helium", SOURCE_UNIT, 1000), - new Binding("Helium3", 21, "gas", "GenGas_Helium3", "helium3", SOURCE_UNIT, 1000), - new Binding("Hydrogen", 10, "gas", "Hydrogen", "hydrogen", SOURCE_UNIT, 1000), - new Binding("Mercury", 800, "liquid", "GenLiquid_Mercury", "mercury", SOURCE_UNIT, 144), - new Binding("NitrogenDioxide", 9831, "gas", "GenGas_NitrogenDioxide", "nitrogendioxide", SOURCE_UNIT, 1000), - new Binding("SemiheavyWater", 9811, "liquid", "GenGas_SemiheavyWater", "semiheavywater", SOURCE_UNIT, 1000), - new Binding("TritiatedWater", 9813, "liquid", "GenGas_TritiatedWater", "tritiatedwater", SOURCE_UNIT, 1000), - new Binding( - "Uranium235Hexafluoride", - 9012, - "gas", - "GenGas_Uranium235Hexafluoride", - "uranium235hexafluoride", - SOURCE_UNIT, - 1000), - new Binding( - "Uranium238Hexafluoride", - 9010, - "gas", - "GenGas_Uranium238Hexafluoride", - "uranium238hexafluoride", - SOURCE_UNIT, - 1000), - new Binding( - "UraniumHexafluoride", - 9008, - "gas", - "GenGas_UraniumHexafluoride", - "uraniumhexafluoride", - SOURCE_UNIT, - 1000), - }; - - private OriginalMaterialFluidUnits() {} - - /** Unknown or conflicting source identities are deliberately unsupported, not guessed. */ - public static Binding binding(String canonicalName, int materialId, String phase) { - for (Binding binding : BINDINGS) { - if (binding.materialName().equals(canonicalName) - && binding.materialId() == materialId - && binding.phase().equals(phase)) return binding; - } - return null; - } - - /** Name/phase lookup for callers that do not carry the numeric material id. */ - public static Binding binding(String canonicalName, String phase) { - for (Binding binding : BINDINGS) { - if (binding.materialName().equals(canonicalName) && binding.phase().equals(phase)) return binding; - } - return null; - } - - /** - * Original UT.Code.units ratio and final rounding, without signed multiplication overflow. - * Returns -1 for invalid inputs or results outside native FluidStack int capacity; zero stays - * zero, never coerced to1. This is quantity arithmetic, not zero-volume catalyst semantics. - */ - public static int millibuckets(long sourceAmount, long sourceUnit, long referenceMillibuckets, boolean roundUp) { - return UnitConversion.fluidAmount(sourceUnit, referenceMillibuckets, sourceAmount, roundUp); - } -} diff --git a/core/src/main/java/gregtech/content/recipe/ReviewedMagneticMaterials.java b/core/src/main/java/gregtech/content/recipe/ReviewedMagneticMaterials.java deleted file mode 100644 index 6d5a45d13..000000000 --- a/core/src/main/java/gregtech/content/recipe/ReviewedMagneticMaterials.java +++ /dev/null @@ -1,77 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.api.material.GTMaterial; -import gregtech.engine.addon.AddonMaterials; -import gregtech.engine.material.GTMaterialRegistry; - -/** Paired MT direct magnetic-tag positives only; omission is UNKNOWN, never a negative. - * ID+canonical name and core ownership bind source facts; no global material flags mutate. - * Original MT SHA12936831b1b5f419dc783c5f32f3cc07a329734ca6c5c11757d52e1be27904b2; - * paired w SHA9530c229de3483ab7be300c49ce1e08e44bcabfe9bdebd7844becefbd4782728. - */ -public final class ReviewedMagneticMaterials { - private ReviewedMagneticMaterials() {} - - private static final java.util.Map POSITIVE = java.util.Map.ofEntries( - java.util.Map.entry(250, "Manganese"), - java.util.Map.entry(260, "Iron"), - java.util.Map.entry(270, "Cobalt"), - java.util.Map.entry(278, "Cobalt60"), - java.util.Map.entry(280, "Nickel"), - java.util.Map.entry(600, "Neodymium"), - java.util.Map.entry(670, "Holmium"), - java.util.Map.entry(830, "Bismuth"), - java.util.Map.entry(2220, "Adamantium"), - java.util.Map.entry(8030, "FerrousChloride"), - java.util.Map.entry(8234, "VanadiumPentoxide"), - java.util.Map.entry(8247, "Basalz"), - java.util.Map.entry(8630, "Steel"), - java.util.Map.entry(8634, "DamascusSteel"), - java.util.Map.entry(8635, "Tungstensteel"), - java.util.Map.entry(8643, "WroughtIron"), - java.util.Map.entry(8645, "IronMagnetic"), - java.util.Map.entry(8646, "SteelMagnetic"), - java.util.Map.entry(8647, "NeodymiumMagnetic"), - java.util.Map.entry(8653, "VanadiumSteel"), - java.util.Map.entry(8661, "Invar"), - java.util.Map.entry(8662, "Constantan"), - java.util.Map.entry(8672, "Ironwood"), - java.util.Map.entry(8673, "Steeleaf"), - java.util.Map.entry(8674, "Knightmetal"), - java.util.Map.entry(8675, "FierySteel"), - java.util.Map.entry(8679, "Thaumium"), - java.util.Map.entry(8685, "ChromiumDioxide"), - java.util.Map.entry(8697, "FlamascusSteel"), - java.util.Map.entry(8698, "Fireleaf"), - java.util.Map.entry(8704, "VibraniumSteel"), - java.util.Map.entry(8706, "Vibramantium"), - java.util.Map.entry(8727, "ConductiveIron"), - java.util.Map.entry(8730, "ElectricalSteel"), - java.util.Map.entry(8744, "AncientDebris"), - java.util.Map.entry(8745, "Netherite"), - java.util.Map.entry(8746, "NetherizedDiamond"), - java.util.Map.entry(8747, "Efrine"), - java.util.Map.entry(8784, "Adamantine"), - java.util.Map.entry(8803, "CastIron"), - java.util.Map.entry(9003, "BasalticMineralSand"), - java.util.Map.entry(9004, "GraniticMineralSand"), - java.util.Map.entry(9104, "Hematite"), - java.util.Map.entry(9106, "BrownLimonite"), - java.util.Map.entry(9115, "Cobaltite"), - java.util.Map.entry(9118, "Garnierite"), - java.util.Map.entry(9120, "Ilmenite"), - java.util.Map.entry(9122, "Magnetite"), - java.util.Map.entry(9125, "Pyrite"), - java.util.Map.entry(9126, "Pyrolusite"), - java.util.Map.entry(9137, "YellowLimonite"), - java.util.Map.entry(9143, "VanadiumMagnetite"), - java.util.Map.entry(9145, "Pentlandite")); - - public static boolean sourcePositive(GTMaterial material) { - if (material == null || !material.isValid()) return false; - var m = material.resolve(); - return GTMaterialRegistry.isCoreMaterial(m) - && !AddonMaterials.owns(m) - && m.getName().equals(POSITIVE.get(m.getId())); - } -} diff --git a/core/src/main/java/gregtech/content/recipe/ReviewedOreGeneratedFluids.java b/core/src/main/java/gregtech/content/recipe/ReviewedOreGeneratedFluids.java deleted file mode 100644 index 02c9caa56..000000000 --- a/core/src/main/java/gregtech/content/recipe/ReviewedOreGeneratedFluids.java +++ /dev/null @@ -1,72 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.api.material.*; -import gregtech.content.data.FluidCatalog; -import gregtech.engine.addon.AddonMaterials; -import gregtech.engine.material.GTMaterialRegistry; - -/** Source-bound generated Mercury only. Never treats equal external definitions as factory-owned. */ -public final class ReviewedOreGeneratedFluids { - private ReviewedOreGeneratedFluids() {} - - public static boolean mercury(FluidCatalog.FluidEntry entry) { - String field = "GenLiquid_Mercury"; - if (entry == null - || !FluidCatalog.canonicalField(field).equals(field) - || !FluidCatalog.isGeneratedGasLiquidDefinition(field, entry)) return false; - var material = GTMaterialRegistry.get("Mercury"); - if (material == null || !material.isValid()) return false; - material = material.resolve(); - if (material.getId() != 800 - || !material.getName().equals("Mercury") - || !GTMaterialRegistry.isCoreMaterial(material) - || AddonMaterials.owns(material)) return false; - return entry.registryName().equals("mercury") - && "Mercury".equals(entry.materialKey()) - && entry.textureMode() == FluidCatalog.FluidTextureMode.DEDICATED - && entry.tintArgb() == 0 - && entry.tintTexture() - && !entry.glint() - && !entry.gas() - && entry.density() == 0 - && entry.viscosity() == 0 - && entry.luminosity() == 0 - && entry.temperature() == 300 - && entry.flags() == FluidCatalog.FluidFlags.LIQUID; - } - /** Two source-reviewed ordinary-dust targets; absent/unowned/mutated identities defer. */ - public static boolean wholeDustMetal(gregtech.api.material.GTMaterial material, FluidCatalog.FluidEntry entry) { - if (material == null || entry == null) return false; - material = material.resolve(); - if (!GTMaterialRegistry.isCoreMaterial(material) || AddonMaterials.owns(material)) return false; - int temperature; - float density; - if (material.getId() == 220 && material.getName().equals("Titanium")) { - temperature = 1941; - density = 4.54F; - } else if (material.getId() == 260 && material.getName().equals("Iron")) { - temperature = 1811; - density = 7.874F; - } else return false; - String field = "GenMolten_" + material.getName(); - return FluidCatalog.isGeneratedMoltenDefinition(field, entry) - && material.getTargetSmeltingMaterial() != null - && material.getTargetSmeltingMaterial().resolve() == material - && material.getTargetSmeltingAmount() == gregtech.api.material.GTValues.U - && material.getMeltingPoint() == temperature - && material.getDensity() == density - && material.has(gregtech.api.material.MaterialProperty.MELTING) - && !material.has(gregtech.api.material.MaterialProperty.ANTIMATTER) - && entry.registryName().equals("molten." + material.getName().toLowerCase(java.util.Locale.ROOT)) - && material.getName().equals(entry.materialKey()) - && entry.textureMode() == FluidCatalog.FluidTextureMode.GENERIC_MOLTEN - && entry.tintTexture() - && !entry.glint() - && !entry.gas() - && entry.density() == 0 - && entry.viscosity() == 0 - && entry.luminosity() == 10 - && entry.temperature() == temperature - && entry.flags() == FluidCatalog.FluidFlags.LIQUID; - } -} diff --git a/core/src/main/java/gregtech/content/recipe/ReviewedSiftingGemForms.java b/core/src/main/java/gregtech/content/recipe/ReviewedSiftingGemForms.java deleted file mode 100644 index 802e80b68..000000000 --- a/core/src/main/java/gregtech/content/recipe/ReviewedSiftingGemForms.java +++ /dev/null @@ -1,36 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.api.material.GTMaterial; -import gregtech.content.data.MaterialPrefix; -import gregtech.engine.addon.AddonMaterials; -import gregtech.engine.material.GTMaterialRegistry; -import java.util.Set; - -/** Bounded per-form source generation facts, not a ban on actual external registrations. - * Original OP174-178 / W178-182 require CRYSTAL for upper grades; Ice MT1013 / W1020 - * has TRANSPARENT, not CRYSTAL. OP613-615 / W617-619 force only common/flawed/chipped. - * Existing IDs remain registered. The native resolver checks supported startup external overrides before this table. - * A later crafting-grade tag alias alone is not a supported Sifting output binding. - * All omitted identities/forms remain UNKNOWN; the earlier material-wide profile is unchanged. - */ -public final class ReviewedSiftingGemForms { - private ReviewedSiftingGemForms() {} - - private record Entry(int id, String name, Set absentPrefixes) {} - - private static final Entry[] ENTRIES = { - new Entry(9802, "Ice", Set.of("gemLegendary", "gemExquisite", "gemFlawless")) - }; - - public static ReviewedOreSourceProfile.Decision decision(GTMaterial material, MaterialPrefix prefix) { - if (material == null || prefix == null) return ReviewedOreSourceProfile.Decision.UNKNOWN; - material = material.resolve(); - if (!material.isValid() || !GTMaterialRegistry.isCoreMaterial(material) || AddonMaterials.owns(material)) - return ReviewedOreSourceProfile.Decision.UNKNOWN; - for (var row : ENTRIES) - if (row.id == material.getId() - && row.name.equals(material.getName()) - && row.absentPrefixes.contains(prefix.getName())) return ReviewedOreSourceProfile.Decision.NO; - return ReviewedOreSourceProfile.Decision.UNKNOWN; - } -} diff --git a/core/src/main/java/gregtech/content/recipe/SourceExtrusionRules.java b/core/src/main/java/gregtech/content/recipe/SourceExtrusionRules.java index bd20ad5e9..3a41fe418 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceExtrusionRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceExtrusionRules.java @@ -2,806 +2,38 @@ import gregtech.api.material.GTMaterial; import gregtech.api.material.GTValues; +import gregtech.api.material.MaterialProperty; +import gregtech.content.material.MaterialFactKeys; +import gregtech.content.material.catalog.SourceExtrusionMaterialFacts; import gregtech.content.recipe.generated.GTMaterialFields; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.GTMaterialRegistry; -import java.util.HashMap; -import java.util.Map; -/** Native GT6 MT factory/direct extrusion flags and forging targets, pinned to 3703e403. - * Generated from GT6 {@code MT.java} at 3703e403; absence is not inferred from the port's broad METAL flag. - * Profiles are bound to exact native identities; addons are not assigned original identities by name. - */ +/** Native extrusion recipe behavior backed by the material's source profile. */ public final class SourceExtrusionRules { private SourceExtrusionRules() {} - public record Profile(boolean extrudable, boolean simple, boolean smithable, String target, long forgingAmount) {} - - private record Row(String name, Profile profile) {} - - private static final Map ROWS = new HashMap<>(); - private static final String DATA = """ - 0|Empty|000||648648000 - 1|Photon|000||648648000 - 2|Neutrino|000||648648000 - 3|Neutron|000||648648000 - 4|Proton|000||648648000 - 5|Electron|000||648648000 - 10|Hydrogen|000||648648000 - 11|Deuterium|000||648648000 - 12|Tritium|000||648648000 - 20|Helium|000||648648000 - 21|Helium3|000||648648000 - 30|Lithium|111||648648000 - 31|Lithium6|111||648648000 - 40|Beryllium|101||648648000 - 41|Beryllium7|101||648648000 - 42|Beryllium8|101||648648000 - 50|Boron|101||648648000 - 51|Boron11|101||648648000 - 60|Carbon|000||648648000 - 61|Carbon13|000||648648000 - 62|Carbon14|000||648648000 - 70|Nitrogen|000||648648000 - 80|Oxygen|000||648648000 - 90|Fluorine|000||648648000 - 100|Neon|000||648648000 - 110|Sodium|111||648648000 - 120|Magnesium|111||648648000 - 130|Aluminium|111||648648000 - 140|Silicon|101||648648000 - 150|Phosphor|000||648648000 - 160|Sulfur|000||648648000 - 170|Chlorine|000||648648000 - 180|Argon|000||648648000 - 190|Potassium|111||648648000 - 200|Calcium|111||648648000 - 210|Scandium|101||648648000 - 220|Titanium|101||648648000 - 230|Vanadium|101||648648000 - 240|Chromium|101||648648000 - 250|Manganese|101||648648000 - 260|Iron|101||648648000 - 270|Cobalt|101||648648000 - 278|Cobalt60|101||648648000 - 280|Nickel|101||648648000 - 290|Copper|111||648648000 - 300|Zinc|111||648648000 - 310|Gallium|111||648648000 - 320|Germanium|111||648648000 - 330|Arsenic|111||648648000 - 340|Selenium|000||648648000 - 350|Bromine|000||648648000 - 360|Krypton|000||648648000 - 370|Rubidium|111||648648000 - 380|Strontium|111||648648000 - 390|Yttrium|101||648648000 - 400|Zirconium|101||648648000 - 410|Niobium|101||648648000 - 420|Molybdenum|101||648648000 - 430|Technetium|101||648648000 - 440|Ruthenium|101||648648000 - 450|Rhodium|101||648648000 - 460|Palladium|101||648648000 - 470|Silver|101||648648000 - 480|Cadmium|111||648648000 - 490|Indium|111||648648000 - 500|Tin|111||648648000 - 510|Antimony|111||648648000 - 520|Tellurium|111||648648000 - 530|Iodine|000||648648000 - 540|Xenon|000||648648000 - 550|Caesium|111||648648000 - 560|Barium|111||648648000 - 570|Lanthanium|111||648648000 - 580|Cerium|111||648648000 - 590|Praseodymium|101||648648000 - 600|Neodymium|101||648648000 - 610|Promethium|101||648648000 - 620|Samarium|101||648648000 - 630|Europium|111||648648000 - 640|Gadolinium|101||648648000 - 650|Terbium|101||648648000 - 660|Dysprosium|101||648648000 - 670|Holmium|101||648648000 - 680|Erbium|101||648648000 - 690|Thulium|101||648648000 - 700|Ytterbium|111||648648000 - 710|Lutetium|101||648648000 - 720|Hafnium|101||648648000 - 730|Tantalum|101||648648000 - 740|Tungsten|101||648648000 - 750|Rhenium|101||648648000 - 760|OsmiumElemental|101||648648000 - 770|Iridium|101||648648000 - 780|Platinum|101||648648000 - 790|Gold|101||648648000 - 791|Gold198|101||648648000 - 800|Mercury|111||648648000 - 810|Thallium|111||648648000 - 820|Lead|111||648648000 - 830|Bismuth|111||648648000 - 840|Polonium|111||648648000 - 850|Astatine|111||648648000 - 860|Radon|000||648648000 - 870|Francium|111||648648000 - 880|Radium|111||648648000 - 890|Actinium|101||648648000 - 900|Thorium|101||648648000 - 910|Protactinium|101||648648000 - 920|Uranium|101||648648000 - 921|Uranium235|101||648648000 - 922|Uranium233|101||648648000 - 930|Neptunium|111||648648000 - 940|Plutonium|111||648648000 - 942|Plutonium240|111||648648000 - 943|Plutonium241|111||648648000 - 945|Plutonium243|111||648648000 - 946|Plutonium238|111||648648000 - 947|Plutonium239|111||648648000 - 950|Americium|101||648648000 - 951|Americium241|101||648648000 - 952|Americium242|101||648648000 - 960|Curium|101||648648000 - 970|Berkelium|101||648648000 - 980|Californium|111||648648000 - 990|Einsteinium|111||648648000 - 1000|Fermium|111||648648000 - 1010|Mendelevium|111||648648000 - 1020|Nobelium|111||648648000 - 1030|Lawrencium|101||648648000 - 1040|Rutherfordium|101||648648000 - 1050|Dubnium|111||648648000 - 1060|Seaborgium|111||648648000 - 1070|Bohrium|111||648648000 - 1080|Hassium|111||648648000 - 1090|Meitnerium|000||648648000 - 1100|Darmstadtium|000||648648000 - 1110|Roentgenium|000||648648000 - 1120|Copernicium|111||648648000 - 1130|Nihonium|000||648648000 - 1140|Flerovium|111||648648000 - 1148|Flerovium298|111||648648000 - 1150|Moscovium|000||648648000 - 1160|Livermorium|000||648648000 - 1170|Farnsium|000||648648000 - 1180|Oganesson|000||648648000 - 1250|TritaniumElemental|101||648648000 - 1260|Trinium|101||648648000 - 1450|DuraniumElemental|111||648648000 - 1520|Vibranium|000||648648000 - 1740|Naquadah|101||648648000 - 1741|NaquadahEnriched|101||648648000 - 1742|Naquadria|101||648648000 - 2220|Adamantium|101||648648000 - 3720|Gravitonium|000||648648000 - 4000|Magic|000||648648000 - 8000|SiliconDioxide|000||648648000 - 8001|Glass|110||648648000 - 8002|Flint|000||648648000 - 8003|Carborundum|101||648648000 - 8006|Datolite|000||648648000 - 8007|HydrogenBorate|000||648648000 - 8008|Alumina|000||648648000 - 8009|Cryolite|000||648648000 - 8010|AluminiumFluoride|000||648648000 - 8011|HexafluorosilicicAcid|000||648648000 - 8012|SodiumAluminate|000||648648000 - 8013|SodiumCarbonate|000||648648000 - 8014|AluminiumHydroxide|000||648648000 - 8015|PotassiumHydroxide|000||648648000 - 8016|MagnesiumCarbonate|000||648648000 - 8017|FerricChloride|000||648648000 - 8018|MagnesiumChloride|000||648648000 - 8019|SodiumNitrate|000||648648000 - 8020|PotassiumCarbonate|000||648648000 - 8021|PotassiumSulfite|000||648648000 - 8022|PotassiumPersulfate|000||648648000 - 8023|PotassiumAluminate|000||648648000 - 8024|HydrosulfuricAcid|000||648648000 - 8025|Ammonia|000||648648000 - 8026|TungstenTrioxide|000||648648000 - 8027|TungsticAcid|000||648648000 - 8028|CalciumChloride|000||648648000 - 8029|LithiumChloride|000||648648000 - 8030|FerrousChloride|000||648648000 - 8031|ManganeseChloride|000||648648000 - 8032|LithiumHydroxide|000||648648000 - 8033|LithiumChlorate|000||648648000 - 8034|LithiumPerchlorate|000||648648000 - 8035|FerricOxyhydroxide|000||648648000 - 8036|PotassiumFluoride|000||648648000 - 8037|SodiumFluoride|000||648648000 - 8038|PotassiumHeptafluorotantalate|000||648648000 - 8039|SodiumHydrogencarbonate|000||648648000 - 8100|Sand|000||648648000 - 8101|Soulsand|000||648648000 - 8102|SluiceSand|000||648648000 - 8103|PlatinumGroupSludge|000||648648000 - 8104|RedSand|000||648648000 - 8196|Teflon|110||648648000 - 8197|PVC|110||648648000 - 8200|Ashes|000||648648000 - 8201|DarkAshes|000||648648000 - 8203|Sylvite|000||648648000 - 8204|Salt|000||648648000 - 8205|PotassiumNitrate|000||648648000 - 8206|Niter|000||648648000 - 8207|Phosphate|000||648648000 - 8208|Phosphorus|000||648648000 - 8209|Apatite|000||648648000 - 8210|Blizz|000||648648000 - 8211|Blaze|000||648648000 - 8214|Obsidian|000||648648000 - 8215|Clay|000||648648000 - 8216|Paper|000||648648000 - 8217|Rubber|110||648648000 - 8218|Plastic|110||648648000 - 8219|Bone|000||648648000 - 8220|Gunpowder|000||648648000 - 8221|Wood|000||648648000 - 8222|WoodTreated|000||648648000 - 8223|LiveRoot|000||648648000 - 8224|WoodRubber|000||648648000 - 8225|Ceramic|000||648648000 - 8226|Phosphorite|000||648648000 - 8229|CobaltHexahydrate|000||648648000 - 8230|SodiumBisulfate|000||648648000 - 8231|SodiumPyrosulfate|000||648648000 - 8232|PotassiumBisulfate|000||648648000 - 8233|PotassiumPyrosulfate|000||648648000 - 8234|VanadiumPentoxide|000||648648000 - 8235|Wax|110||648648000 - 8236|WaxBee|110||648648000 - 8238|WaxParaffin|110||648648000 - 8239|WaxPlant|110||648648000 - 8241|Leather|000||648648000 - 8242|IodineSalt|000||648648000 - 8247|Basalz|000||648648000 - 8248|Blitz|000||648648000 - 8249|Dynamite|000||648648000 - 8250|DyeBlack|000||648648000 - 8251|DyeRed|000||648648000 - 8252|DyeGreen|000||648648000 - 8253|DyeBrown|000||648648000 - 8254|DyeBlue|000||648648000 - 8255|DyePurple|000||648648000 - 8256|DyeCyan|000||648648000 - 8257|DyeLightGray|000||648648000 - 8258|DyeGray|000||648648000 - 8259|DyePink|000||648648000 - 8260|DyeLime|000||648648000 - 8261|DyeYellow|000||648648000 - 8262|DyeLightBlue|000||648648000 - 8263|DyeMagenta|000||648648000 - 8264|DyeOrange|000||648648000 - 8265|DyeWhite|000||648648000 - 8266|Asphalt|110||648648000 - 8267|WoodPolished|000||648648000 - 8268|SodiumHydroxide|000||648648000 - 8269|SodiumSulfite|000||648648000 - 8270|SodiumSulfate|000||648648000 - 8271|PotassiumSulfate|000||648648000 - 8272|PotassiumSulfide|000||648648000 - 8273|Porcelain|000||648648000 - 8274|CalciumSulfate|000||648648000 - 8275|Bark|000||648648000 - 8276|ClayBrown|000||648648000 - 8277|PetrifiedWood|000||648648000 - 8278|ManaDiamond|000||648648000 - 8289|Livingwood|000||648648000 - 8290|Dreamwood|000||648648000 - 8296|Greatwood|000||648648000 - 8297|Silverwood|000||648648000 - 8298|EnergiumRed|000||648648000 - 8299|EnergiumCyan|000||648648000 - 8300|Diamond|000||648648000 - 8301|Emerald|000||648648000 - 8302|Ruby|000||648648000 - 8303|BalasRuby|000||648648000 - 8304|Sapphire|000||648648000 - 8305|GreenSapphire|000||648648000 - 8306|Topaz|000||648648000 - 8307|BlueTopaz|000||648648000 - 8308|Tanzanite|000||648648000 - 8309|RedJasper|000||648648000 - 8310|Amber|000||648648000 - 8311|Peridot|000||648648000 - 8312|Opal|000||648648000 - 8313|Amethyst|000||648648000 - 8314|OrangeSapphire|000||648648000 - 8315|YellowSapphire|000||648648000 - 8318|EnderPearl|000||648648000 - 8319|EnderEye|000||648648000 - 8320|NetherStar|000||648648000 - 8321|Jade|000||648648000 - 8322|Craponite|000||648648000 - 8323|Aquamarine|000||648648000 - 8324|Morganite|000||648648000 - 8325|Dioptase|000||648648000 - 8326|Spinel|000||648648000 - 8328|BlueSapphire|000||648648000 - 8330|Lazurite|000||648648000 - 8331|Sodalite|000||648648000 - 8332|Lapis|000||648648000 - 8333|Redstone|000||648648000 - 8334|Coal|000||648648000 - 8335|HydratedCoal|000||648648000 - 8336|Charcoal|000||648648000 - 8337|Lignite|000||648648000 - 8338|Monazite|000||648648000 - 8340|Nikolite|000||648648000 - 8341|Glowstone|000||648648000 - 8342|Firestone|000||648648000 - 8346|NetherQuartz|000||648648000 - 8347|CertusQuartz|000||648648000 - 8348|ChargedCertusQuartz|000||648648000 - 8349|CoalCoke|000||648648000 - 8360|Peat|000||648648000 - 8365|LigniteCoke|000||648648000 - 8383|PurpleSapphire|000||648648000 - 8384|Heliodor|000||648648000 - 8385|Goshenite|000||648648000 - 8386|Bixbite|000||648648000 - 8387|Maxixe|000||648648000 - 8389|Fluix|000||648648000 - 8390|PetroleumCoke|000||648648000 - 8393|SunnyQuartz|000||648648000 - 8395|RedQuartz|000||648648000 - 8396|BlazeQuartz|000||648648000 - 8397|SmokeyQuartz|000||648648000 - 8399|ElvenQuartz|000||648648000 - 8400|ChloroauricAcid|000||648648000 - 8401|ChloroplatinicAcid|000||648648000 - 8402|StannicChloride|000||648648000 - 8403|BlackVitriol|000||648648000 - 8404|BlueVitriol|000||648648000 - 8405|GreenVitriol|000||648648000 - 8406|RedVitriol|000||648648000 - 8407|PinkVitriol|000||648648000 - 8408|CyanVitriol|000||648648000 - 8409|WhiteVitriol|000||648648000 - 8410|GrayVitriol|000||648648000 - 8412|VitriolOfClay|000||648648000 - 8413|TitaniumTetrachloride|000||648648000 - 8415|OnyxRed|000||648648000 - 8416|OnyxBlack|000||648648000 - 8417|Amazonite|000||648648000 - 8418|Bamboo|000||648648000 - 8419|Zircon|000||648648000 - 8420|Azurite|000||648648000 - 8421|Eudialyte|000||648648000 - 8423|DiamondIndustrial|000||648648000 - 8424|PinkDiamond|000||648648000 - 8425|OceanJasper|000||648648000 - 8426|RainforestJasper|000||648648000 - 8427|BlueJasper|000||648648000 - 8428|GreenJasper|000||648648000 - 8429|YellowJasper|000||648648000 - 8430|TigerEye|000||648648000 - 8431|CatsEye|000||648648000 - 8432|DragonEye|000||648648000 - 8433|HawksEye|000||648648000 - 8434|BlackEye|000||648648000 - 8435|TigerIron|000||648648000 - 8436|RedFluorite|000||648648000 - 8437|PinkFluorite|000||648648000 - 8438|BlueFluorite|000||648648000 - 8439|GreenFluorite|000||648648000 - 8440|BlackFluorite|000||648648000 - 8441|WhiteFluorite|000||648648000 - 8442|YellowFluorite|000||648648000 - 8443|OrangeFluorite|000||648648000 - 8444|MagentaFluorite|000||648648000 - 8445|MilkyQuartz|000||648648000 - 8446|BrownAventurine|000||648648000 - 8447|YellowAventurine|000||648648000 - 8448|GreenAventurine|000||648648000 - 8449|BlackAventurine|000||648648000 - 8450|BlueAventurine|000||648648000 - 8451|RedAventurine|000||648648000 - 8455|ClayRed|000||648648000 - 8458|BluePhosphorus|000||648648000 - 8459|RedPhosphorus|000||648648000 - 8460|WhitePhosphorus|000||648648000 - 8461|NiobiumPentoxide|000||648648000 - 8462|TantalumPentoxide|000||648648000 - 8464|BlueDiamond|000||648648000 - 8465|GreenDiamond|000||648648000 - 8467|RedDiamond|000||648648000 - 8468|YellowDiamond|000||648648000 - 8470|Carminite|000||648648000 - 8471|Breeze|000||648648000 - 8500|Stone|110||648648000 - 8501|Concrete|110||648648000 - 8502|Netherrack|110||648648000 - 8503|NetherBrick|110||648648000 - 8504|Endstone|110||648648000 - 8505|Basalt|110||648648000 - 8506|Marble|110||648648000 - 8507|GraniteRed|110||648648000 - 8508|GraniteBlack|110||648648000 - 8511|Diorite|110||648648000 - 8516|MarsSand|110||648648000 - 8518|Granite|110||648648000 - 8521|Livingrock|110||648648000 - 8528|SkyStone|110||648648000 - 8599|Bedrock|000||648648000 - 8600|Electrum|101||648648000 - 8601|SterlingSilver|101||648648000 - 8602|RoseGold|101||648648000 - 8605|CdInAgAlloy|101||648648000 - 8610|Bronze|111||648648000 - 8611|BlackBronze|101||648648000 - 8612|BismuthBronze|111||648648000 - 8614|ArsenicCopper|111||648648000 - 8615|ArsenicBronze|111||648648000 - 8620|Brass|111||648648000 - 8621|CobaltBrass|111||648648000 - 8622|AluminiumAlloy|101||648648000 - 8630|Steel|101||648648000 - 8631|BlackSteel|101||648648000 - 8632|BlueSteel|101||648648000 - 8633|RedSteel|101||648648000 - 8634|DamascusSteel|101||648648000 - 8635|Tungstensteel|101||648648000 - 8636|StainlessSteel|101||648648000 - 8638|TungstenCarbide|101||648648000 - 8640|AnnealedCopper|111||648648000 - 8643|WroughtIron|101||648648000 - 8645|IronMagnetic|101|Fe|648648000 - 8646|SteelMagnetic|101|Steel|648648000 - 8647|NeodymiumMagnetic|101|Nd|648648000 - 8651|SteelGalvanized|101|Steel|648648000 - 8652|TungstenSintered|101||648648000 - 8653|VanadiumSteel|101||648648000 - 8658|ElectrotineAlloy|111||648648000 - 8659|BlueAlloy|111||648648000 - 8660|RedAlloy|111||648648000 - 8661|Invar|101||648648000 - 8662|Constantan|101||648648000 - 8663|Nichrome|101||648648000 - 8664|Kanthal|101||648648000 - 8665|Magnalium|111||648648000 - 8666|Ultimet|101||648648000 - 8667|TinAlloy|111||648648000 - 8668|BatteryAlloy|111||648648000 - 8669|SolderingAlloy|111||648648000 - 8672|Ironwood|111||648648000 - 8673|Steeleaf|101||648648000 - 8674|Knightmetal|101||648648000 - 8675|FierySteel|101||648648000 - 8679|Thaumium|101||648648000 - 8682|Osmiridium|101||648648000 - 8684|Trinaquadalloy|101||648648000 - 8685|ChromiumDioxide|101||648648000 - 8686|VanadiumGallium|101||648648000 - 8687|YttriumBariumCuprate|101||648648000 - 8689|NiobiumTitanium|101||648648000 - 8697|FlamascusSteel|101||648648000 - 8698|Fireleaf|101||648648000 - 8700|AluminiumBrass|111||648648000 - 8702|Alumite|101||648648000 - 8704|VibraniumSteel|101||648648000 - 8705|VibraniumSilver|101||648648000 - 8706|Vibramantium|101||648648000 - 8708|Signalum|111||648648000 - 8709|Lumium|111||648648000 - 8710|Enderium|101||648648000 - 8717|Cyanite|101||648648000 - 8720|Manasteel|101||648648000 - 8721|Terrasteel|101||648648000 - 8722|ElvenElementium|101||648648000 - 8726|VibrantAlloy|101||648648000 - 8727|ConductiveIron|101||648648000 - 8729|EnderiumBase|101||648648000 - 8730|ElectricalSteel|101||648648000 - 8732|Soularium|101||648648000 - 8733|RedstoneAlloy|101||648648000 - 8735|GaiaSpirit|101||648648000 - 8737|NikolineAlloy|101||648648000 - 8744|AncientDebris|101||648648000 - 8745|Netherite|101||648648000 - 8746|NetherizedDiamond|101||648648000 - 8747|Efrine|101||648648000 - 8751|Duranium|101||648648000 - 8752|Tritanium|101||648648000 - 8756|Duralumin|101||648648000 - 8784|Adamantine|101||648648000 - 8790|Trinitanium|101||648648000 - 8793|TitaniumIridium|101||648648000 - 8796|HSSG|101||648648000 - 8797|HSSE|101||648648000 - 8798|HSSS|101||648648000 - 8799|CrystalMatrix|101||648648000 - 8800|CosmicNeutronium|101||648648000 - 8802|TantalumHafniumCarbide|101||648648000 - 8803|CastIron|101||648648000 - 9000|Pumice|110||648648000 - 9001|Diatomite|000||648648000 - 9003|BasalticMineralSand|000||648648000 - 9004|GraniticMineralSand|000||648648000 - 9005|GarnetSand|000||648648000 - 9006|QuartzSand|000||648648000 - 9007|UraniumTetrafluoride|000||648648000 - 9008|UraniumHexafluoride|000||648648000 - 9009|Uranium238Tetrafluoride|000||648648000 - 9010|Uranium238Hexafluoride|000||648648000 - 9011|Uranium235Tetrafluoride|000||648648000 - 9012|Uranium235Hexafluoride|000||648648000 - 9100|RareEarth|000||648648000 - 9101|Almandine|000||648648000 - 9102|Andradite|000||648648000 - 9103|Asbestos|110||648648000 - 9104|Hematite|000||648648000 - 9105|Bauxite|000||648648000 - 9106|BrownLimonite|000||648648000 - 9107|Calcite|000||648648000 - 9108|Cassiterite|000||648648000 - 9109|Realgar|000||648648000 - 9110|Celestine|000||648648000 - 9111|Chalcopyrite|000||648648000 - 9113|Chromite|000||648648000 - 9114|Cinnabar|000||648648000 - 9115|Cobaltite|000||648648000 - 9116|Cooperite|000||648648000 - 9117|Galena|000||648648000 - 9118|Garnierite|000||648648000 - 9119|Grossular|000||648648000 - 9120|Ilmenite|000||648648000 - 9122|Magnetite|000||648648000 - 9123|Molybdenite|000||648648000 - 9124|Powellite|000||648648000 - 9125|Pyrite|000||648648000 - 9126|Pyrolusite|000||648648000 - 9127|Pyrope|000||648648000 - 9128|Scheelite|000||648648000 - 9129|Spessartine|000||648648000 - 9130|Sphalerite|000||648648000 - 9131|Stibnite|000||648648000 - 9132|Tetrahedrite|000||648648000 - 9133|Tungstate|000||648648000 - 9134|Uraninite|000||648648000 - 9135|Uvarovite|000||648648000 - 9136|Wulfenite|000||648648000 - 9137|YellowLimonite|000||648648000 - 9138|Perlite|000||648648000 - 9139|Borax|000||648648000 - 9140|PotassiumFeldspar|000||648648000 - 9141|Biotite|000||648648000 - 9143|VanadiumMagnetite|000||648648000 - 9144|Bastnasite|000||648648000 - 9145|Pentlandite|000||648648000 - 9146|Spodumene|000||648648000 - 9147|Pollucite|000||648648000 - 9148|Tantalite|000||648648000 - 9149|Lepidolite|000||648648000 - 9150|Glauconite|000||648648000 - 9152|Vermiculite|000||648648000 - 9153|Bentonite|000||648648000 - 9154|Palygorskite|000||648648000 - 9155|Pitchblende|000||648648000 - 9156|Malachite|000||648648000 - 9157|Mirabilite|000||648648000 - 9158|Mica|000||648648000 - 9159|Trona|000||648648000 - 9160|Barite|000||648648000 - 9161|Gypsum|000||648648000 - 9162|Alunite|000||648648000 - 9164|Wollastonite|000||648648000 - 9165|Zeolite|000||648648000 - 9166|Kyanite|000||648648000 - 9167|Kaolinite|000||648648000 - 9169|Talc|000||648648000 - 9171|Greenschist|110||648648000 - 9174|Graphite|000||648648000 - 9175|Graphene|000||648648000 - 9177|Komatiite|110||648648000 - 9180|Quartzite|110||648648000 - 9184|Blueschist|110||648648000 - 9185|Bluestone|110||648648000 - 9186|Chert|110||648648000 - 9187|Dacite|110||648648000 - 9188|Andesite|110||648648000 - 9189|Limestone|110||648648000 - 9190|Shale|110||648648000 - 9192|Rutile|000||648648000 - 9193|Stolzite|000||648648000 - 9194|Ferberite|000||648648000 - 9195|Huebnerite|000||648648000 - 9196|Russellite|000||648648000 - 9197|Pinalite|000||648648000 - 9198|DiduraniumTrioxide|000||648648000 - 9199|DuraniumHexafluoride|000||648648000 - 9200|DuraniumHexachloride|000||648648000 - 9201|DuraniumHexabromide|000||648648000 - 9202|DuraniumHexaiodide|000||648648000 - 9203|DuraniumHexaastatide|000||648648000 - 9204|TritaniumDioxide|000||648648000 - 9205|TritaniumHexafluoride|000||648648000 - 9206|TritaniumHexachloride|000||648648000 - 9207|TritaniumHexabromide|000||648648000 - 9208|TritaniumHexaiodide|000||648648000 - 9209|TritaniumHexaastatide|000||648648000 - 9210|Bromargyrite|000||648648000 - 9211|Smithsonite|000||648648000 - 9212|Sperrylite|000||648648000 - 9213|Kesterite|000||648648000 - 9214|Stannite|000||648648000 - 9215|Fluorite|000||648648000 - 9216|Arsenopyrite|000||648648000 - 9217|Wolframite|000||648648000 - 9218|Kimberlite|110||648648000 - 9219|Prismarine|110||648648000 - 9220|PrismarineDark|110||648648000 - 9221|Bischofite|000||648648000 - 9222|Slate|110||648648000 - 9223|Blackstone|110||648648000 - 9243|ClayBrick|000||648648000 - 9246|Columbite|000||648648000 - 9247|Coltan|000||648648000 - 9248|Deepslate|110||648648000 - 9261|TitanRock|110||648648000 - 9271|Quicklime|000||648648000 - 9300|Oak|000||648648000 - 9301|Birch|000||648648000 - 9302|Spruce|000||648648000 - 9303|Junglewood|000||648648000 - 9304|Acacia|000||648648000 - 9305|DarkOak|000||648648000 - 9306|Crimsonwood|000||648648000 - 9307|Warpedwood|000||648648000 - 9308|WoodCompressed|000||648648000 - 9309|WoodDead|000||648648000 - 9310|WoodRotten|000||648648000 - 9311|WoodMossy|000||648648000 - 9312|WoodFrozen|000||648648000 - 9313|Maple|000||648648000 - 9314|Willow|000||648648000 - 9315|BlueMahoe|000||648648000 - 9316|Hazel|000||648648000 - 9317|Cinnamonwood|000||648648000 - 9318|Coconutwood|000||648648000 - 9319|Rainbowood|000||648648000 - 9344|Cherrywood|000||648648000 - 9372|Mangrove|000||648648000 - 9409|BlueSpruce|000||648648000 - 9700|MeatRaw|110|MeatCooked|648648000 - 9701|MeatCooked|110||648648000 - 9702|Wheat|000||648648000 - 9703|Sugar|000||648648000 - 9705|Rye|000||648648000 - 9709|Potato|000||648648000 - 9710|MeatRotten|110||648648000 - 9711|FishCooked|110||648648000 - 9712|FishRaw|110|FishCooked|648648000 - 9713|FishRotten|110||648648000 - 9779|SoylentGreen|110||648648000 - 9780|Cheese|110||648648000 - 9781|Chili|000||648648000 - 9782|Cocoa|000||648648000 - 9783|Chocolate|110||648648000 - 9784|Coffee|000||648648000 - 9785|Cinnamon|000||648648000 - 9790|Milk|000||648648000 - 9791|Honey|000||648648000 - 9792|Tea|000||648648000 - 9793|Honeydew|000||648648000 - 9794|Mint|000||648648000 - 9796|Hazelnut|000||648648000 - 9800|Water|000||648648000 - 9801|Snow|000||648648000 - 9802|Ice|000||648648000 - 9803|FreshWater|000||648648000 - 9804|Saltwater|000||648648000 - 9805|HolyWater|000||648648000 - 9806|SeaWater|000||648648000 - 9808|WaterDistilled|000||648648000 - 9809|HydrogenPeroxide|000||648648000 - 9810|Lava|000||648648000 - 9811|SemiheavyWater|000||648648000 - 9812|HeavyWater|000||648648000 - 9813|TritiatedWater|000||648648000 - 9814|Steam|000||648648000 - 9815|SaltedWater|000||648648000 - 9820|NitroCarbon|000||648648000 - 9821|Glyceryl|000||648648000 - 9822|SodiumPersulfate|000||648648000 - 9823|SodiumSulfide|000||648648000 - 9824|SulfuricAcid|000||648648000 - 9825|NitricAcid|000||648648000 - 9826|HydrochloricAcid|000||648648000 - 9827|AquaRegia|000||648648000 - 9828|Glycerol|000||648648000 - 9829|HydrogenFluoride|000||648648000 - 9830|Air|000||648648000 - 9831|NitrogenDioxide|000||648648000 - 9832|Methane|000||648648000 - 9833|MethaneIce|000||648648000 - 9834|SulfurDioxide|000||648648000 - 9835|SulfurTrioxide|000||648648000 - 9836|CarbonDioxide|000||648648000 - 9837|NitrogenMonoxide|000||648648000 - 9838|CarbonMonoxide|000||648648000 - 9839|HeliumNeon|000||648648000 - 9840|Biomass|000||648648000 - 9841|BioFuel|000||648648000 - 9842|Ethanol|000||648648000 - 9843|CarbonTrioxide|000||648648000 - 9844|DisulfuricAcid|000||648648000 - 9850|Oil|000||648648000 - 9851|OilSand|000||648648000 - 9852|CrudeOil|000||648648000 - 9853|OilShale|000||648648000 - 9860|Fuel|000||648648000 - 9861|NitroFuel|000||648648000 - 9862|Kerosine|000||648648000 - 9863|Diesel|000||648648000 - 9864|Petrol|000||648648000 - 9865|Propane|000||648648000 - 9866|Butane|000||648648000 - 9867|Propylene|000||648648000 - 9868|Ethylene|000||648648000 - 9870|Creosote|000||648648000 - 9871|FishOil|000||648648000 - 9872|SeedOil|000||648648000 - 9873|HempOil|000||648648000 - 9874|LinOil|000||648648000 - 9875|SunflowerOil|000||648648000 - 9876|NutOil|000||648648000 - 9877|OliveOil|000||648648000 - 9880|FryingOilHot|000||648648000 - 9881|Glue|000||648648000 - 9882|Lubricant|000||648648000 - 9883|ConstructionFoam|000||648648000 - 9886|Latex|000||648648000 - """; - - static { - for (String line : DATA.strip().split("\n")) { - String[] f = line.strip().split("\\|", -1); - ROWS.put( - Integer.parseInt(f[0]), - new Row( - f[1], - new Profile( - f[2].charAt(0) == '1', - f[2].charAt(1) == '1', - f[2].charAt(2) == '1', - f[3], - Long.parseLong(f[4])))); - } - } - - public static Profile profile(GTMaterial material) { + public static SourceExtrusionMaterialFacts.Profile profile(GTMaterial material) { if (material == null || !material.isValid() || material.resolve() != material || AddonMaterials.owns(material)) return null; - Row row = ROWS.get(material.getId()); - return row != null - && sameName(row.name(), material.getName()) - && GTMaterialRegistry.get(material.getId()) == material - && GTMaterialRegistry.get(material.getName()) == material - ? row.profile() - : null; - } - /** The source list spells e.g. {@code SpaceStone} where the port spells {@code Space Stone}. */ - private static boolean sameName(String source, String port) { - if (source.equals(port)) return true; - return source.replaceAll("[^A-Za-z0-9]", "").equalsIgnoreCase(port.replaceAll("[^A-Za-z0-9]", "")); + if (GTMaterialRegistry.get(material.getId()) != material + || GTMaterialRegistry.get(material.getName()) != material) return null; + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_EXTRUSION) + .orElse(null); } - /** Source SMITHABLE where the profile exists; unknown/addon materials keep the port property. */ + public static boolean smithable(GTMaterial material) { - Profile profile = profile(material); - return profile != null ? profile.smithable() : material.has(gregtech.api.material.MaterialProperty.SMITHABLE); + var profile = profile(material); + return profile != null ? profile.smithable() : material.has(MaterialProperty.SMITHABLE); } - public static GTMaterial target(GTMaterial material, Profile profile) { + public static GTMaterial target(GTMaterial material, SourceExtrusionMaterialFacts.Profile profile) { if (profile.target().isEmpty()) return material; String name = GTMaterialFields.materialOf(profile.target()); GTMaterial result = name == null ? null : GTMaterialRegistry.get(name); return result == null ? null : result.resolve(); } - /** Original ceil input / floor output ratio, and the two 64-stack output limit. */ + public static long[] amounts(long inputWeight, long outputWeight) { if (inputWeight <= 0 || outputWeight <= 0) return null; long input = outputWeight > inputWeight ? (outputWeight + inputWeight - 1) / inputWeight : 1; diff --git a/core/src/main/java/gregtech/content/recipe/SourceLensRoles.java b/core/src/main/java/gregtech/content/recipe/SourceLensRoles.java new file mode 100644 index 000000000..2f78a952c --- /dev/null +++ b/core/src/main/java/gregtech/content/recipe/SourceLensRoles.java @@ -0,0 +1,27 @@ +package gregtech.content.recipe; + +import gregtech.api.material.GTMaterial; +import gregtech.content.material.MaterialFactKeys; +import gregtech.content.material.catalog.SourceLensMaterialFacts; +import gregtech.engine.addon.AddonMaterials; +import java.util.ArrayList; +import java.util.List; + +/** Recipe-facing lookup over the material-owned lens role facts. */ +public final class SourceLensRoles { + private SourceLensRoles() {} + + public static SourceLensMaterialFacts.Color color(GTMaterial material) { + if (material == null || !material.isValid() || AddonMaterials.owns(material)) return null; + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_LENS_ROLE).orElse(null); + } + + public static List materials(SourceLensMaterialFacts.Color color) { + var result = new ArrayList(); + for (var material : gregtech.engine.material.GTMaterialRegistry.allMaterials()) { + var resolved = material.resolve(); + if (color(resolved) == color) result.add(resolved); + } + return List.copyOf(result); + } +} diff --git a/core/src/main/java/gregtech/content/recipe/SourceOilSandRules.java b/core/src/main/java/gregtech/content/recipe/SourceOilSandRules.java index 4488914fc..40b491075 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOilSandRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceOilSandRules.java @@ -1,19 +1,18 @@ package gregtech.content.recipe; -import static gregtech.api.material.GTValues.U; -import static gregtech.content.recipe.SourceOreCrushingRules.Form; -import static gregtech.content.recipe.SourceOreCrushingRules.Resolver; -import static gregtech.content.recipe.SourceOreCrushingRules.Slot; -import static gregtech.content.recipe.SourceOreCrushingRules.Stack; -import static gregtech.content.recipe.SourceOreWashingRules.Availability; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; -import static gregtech.content.recipe.SourceRecyclingFacts.Identity; +import gregtech.content.block.stone.OreHostFacts; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; +import static gregtech.api.material.GTValues.U; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; +import static gregtech.content.recipe.SourceOreCrushingRules.*; +import static gregtech.content.recipe.SourceOreWashingRules.Availability; + /** * The OilSand ore-registration Centrifuge event, not generic material decomposition. * Pinned GT6 3703e40308c8c030763fd6297dea8b210d2a77b1: Loader_OreProcessing 196-197/296-303, @@ -90,7 +89,7 @@ public static HostProfile hostProfile(String nativeHostId) { }; // OP 115/117/118: 2U, DUST_ORE, and no byproduct assignment in the source init closure. if (sediment != null) return new HostProfile(sediment, WEIGHT_STANDARD, List.of()); - var host = SourceOreCrushingFacts.hostProfile(nativeHostId); + var host = OreHostFacts.hostProfile(nativeHostId); return host == null ? null : new HostProfile( @@ -108,7 +107,7 @@ public static Decision hostDecision(String nativeHostId) { /** False means unproved mode, not source NO. Sediment, Deepslate and Gneiss broken modes are * not inferred merely from their ordinary prefix definitions. */ public static boolean hasBrokenSourcePair(String nativeHostId) { - return SourceOreCrushingFacts.hasBrokenSourcePair(nativeHostId); + return OreHostFacts.hasBrokenSourcePair(nativeHostId); } public static Result plan(Request request, Resolver resolver) { diff --git a/core/src/main/java/gregtech/content/recipe/SourceOreCrushingFacts.java b/core/src/main/java/gregtech/content/recipe/SourceOreCrushingFacts.java deleted file mode 100644 index 27b058660..000000000 --- a/core/src/main/java/gregtech/content/recipe/SourceOreCrushingFacts.java +++ /dev/null @@ -1,177 +0,0 @@ -package gregtech.content.recipe; - -import static gregtech.api.material.GTValues.U; -import static gregtech.content.recipe.SourceOreCrushingRules.Hexorium; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; -import static gregtech.content.recipe.SourceRecyclingFacts.Identity; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -/** - * Finite source facts for native ore Crusher/Hammer planning, not global material metadata. - * Pinned GT6 3703e40308c8c030763fd6297dea8b210d2a77b1: Crushing 50-140, MT 470/1540/3709, - * OP 653-714. Existing recycling facts supply only the 1,002 exact input identities, never their - * thermal flags/targets/default fingerprints. The five special Hexorium identities are separately - * proven by MT 203/1596-1611. Caller must independently prove native material, item and host/mode. - * - *

PULVERIZING_CINNABAR has exactly three explicit positive declarations in this scope and no - * factory implication. MT and the bounded main/API/ANY/item/ore/rock/wood initialization closure - * contain no further assignment or ALL_ORES tag-list application. Group re-registration and - * setAllToTheOutputOf do not copy processing tags. Unknown/addon overrides are not a source NO. - */ -public final class SourceOreCrushingFacts { - private SourceOreCrushingFacts() {} - - private static boolean reviewedInput(int id, String name) { - var fact = SourceRecyclingFacts.find(id, name); - return fact != null && fact.portDefaults() != null; // roster membership ONLY - } - - public static Decision pulverizingCinnabar(int id, String canonicalName) { - if (specialHexorium(id, canonicalName) != null) return Decision.NO; - if (!reviewedInput(id, canonicalName)) return Decision.UNKNOWN; - return id == 800 || id == 8333 || id == 9114 ? Decision.YES : Decision.NO; - } - /** Null is unreviewed identity, not the NONE classification of a proven ordinary material. */ - public static Hexorium hexorium(int id, String canonicalName) { - Hexorium special = specialHexorium(id, canonicalName); - return special != null ? special : reviewedInput(id, canonicalName) ? Hexorium.NONE : null; - } - - private static Hexorium specialHexorium(int id, String name) { - return switch (id) { - case 9224 -> "HexoriumBlack".equals(name) ? Hexorium.BLACK_WHITE : null; - case 9239 -> "HexoriumWhite".equals(name) ? Hexorium.BLACK_WHITE : null; - case 9225 -> "HexoriumRed".equals(name) ? Hexorium.RED_GREEN_BLUE : null; - case 9226 -> "HexoriumGreen".equals(name) ? Hexorium.RED_GREEN_BLUE : null; - case 9228 -> "HexoriumBlue".equals(name) ? Hexorium.RED_GREEN_BLUE : null; - default -> null; - }; - } - - /** Source prefix association only. A normal/broken native representation needs separate proof; - * this table is not an item matcher or a promise that a native holder currently exists. */ - public record HostProfile( - String sourcePrefix, Identity gangueMaterial, long gangueAmount, boolean hexoriumAdjusted) { - public HostProfile { - Objects.requireNonNull(sourcePrefix); - if (gangueAmount < 0) throw new IllegalArgumentException("Negative gangue amount"); - // Sandstone has an empty source byproduct list; only a positive amount needs an identity. - if (gangueAmount > 0) Objects.requireNonNull(gangueMaterial); - } - - public boolean hasGangue() { - return gangueAmount > 0; - } - } - - private static final Map HOSTS = createHosts(); - // Same OP prefix for normal/broken: Loader_Ores 56/58/59, Loader_Rocks 57-138. - private static final Set BROKEN_SOURCE_PAIRS = Set.of( - "oreVanillastone", - "oreNetherrack", - "oreEndstone", - "oreBlackgranite", - "oreRedgranite", - "oreBasalt", - "oreMarble", - "oreLimestone", - "oreVanillagranite", - "oreDiorite", - "oreAndesite", - "oreKomatiite", - "oreGreenschist", - "oreBlueschist", - "oreKimberlite", - "oreQuartzite", - "oreLightprismarine", - "oreDarkprismarine", - "oreSlate", - "oreShale"); - - public static HostProfile hostProfile(String nativeHostId) { - return nativeHostId == null ? null : HOSTS.get(nativeHostId); - } - - public static Decision hostDecision(String nativeHostId) { - if (hostProfile(nativeHostId) != null) return Decision.YES; - // GT6's crusher handler excludes every DUST_ORE prefix, so their hosts never get a - // crushing row of their own (the sifter and OilSand events handle them instead). - if ("bedrock".equals(nativeHostId) - || "sand".equals(nativeHostId) - || "red_sand".equals(nativeHostId) - || "gravel".equals(nativeHostId) - || "mud".equals(nativeHostId)) return Decision.NO; - return Decision.UNKNOWN; - } - /** False is lack of paired source evidence, not a new material/host prohibition. - * In particular, Deepslate and Gneiss have ordinary OP profiles but no reviewed broken pair. */ - public static boolean hasBrokenSourcePair(String nativeHostId) { - HostProfile profile = hostProfile(nativeHostId); - return profile != null && BROKEN_SOURCE_PAIRS.contains(profile.sourcePrefix()); - } - - private static Map createHosts() { - var result = new LinkedHashMap(); - host(result, "oreVanillastone", 8500, "Stone", false, "stone"); // OP659, MT1631 - host(result, "oreVanillagranite", 8518, "Granite", false, "granite", "stone_granite"); // OP658, MT3831 - host(result, "oreDiorite", 8511, "Diorite", false, "diorite", "stone_diorite"); // OP654, MT3833 - host(result, "oreAndesite", 9188, "Andesite", false, "andesite", "stone_andesite"); // OP653, MT3832 - host(result, "oreDeepslate", 9248, "Deepslate", true, "deepslate"); // OP660, MT3842 - host(result, "oreNetherrack", 8502, "Netherrack", true, "netherrack"); // OP707, MT1633 - host(result, "oreEndstone", 8504, "Endstone", false, "end_stone"); // OP709, MT1635 - host(result, "oreBlackgranite", 8508, "GraniteBlack", false, "stone_granite_black"); // OP657, MT3830 - host(result, "oreRedgranite", 8507, "GraniteRed", false, "stone_granite_red"); // OP656, MT3829 - host(result, "oreKomatiite", 9177, "Komatiite", true, "stone_komatiite"); // OP691, MT3816 - host(result, "oreBasalt", 8505, "Basalt", true, "stone_basalt"); // OP692, MT3819 - host(result, "oreMarble", 8506, "Marble", false, "stone_marble"); // OP693, MT3820 - host(result, "oreLimestone", 9189, "Limestone", false, "stone_limestone"); // OP694, MT3821 - host(result, "oreShale", 9190, "Shale", false, "stone_shale"); // OP696, MT3814 - host(result, "oreSlate", 9222, "Slate", false, "stone_slate"); // OP697, MT3841 - host(result, "oreGreenschist", 9171, "Greenschist", false, "stone_greenschist"); // OP698, MT3822 - host(result, "oreBlueschist", 9184, "Blueschist", false, "stone_blueschist"); // OP699, MT3823 - host(result, "oreLightprismarine", 9219, "Prismarine", false, "stone_prismarine_light"); // OP703, MT1639 - host(result, "oreDarkprismarine", 9220, "PrismarineDark", false, "stone_prismarine_dark"); // OP704, MT1640 - host(result, "oreKimberlite", 9218, "Kimberlite", false, "stone_kimberlite"); // OP705, MT3827 - host(result, "oreQuartzite", 9180, "Quartzite", false, "stone_quartzite"); // OP706, MT3828 - // OP.oreSandstone declares no byproducts, so this host contributes no gangue slot. - if (result.put("sandstone", new HostProfile("oreSandstone", null, 0, false)) != null) - throw new IllegalStateException("Duplicate source host sandstone"); - // Port-only hosts: these StoneTypes are GT6 worldgen *stone layers*, not ore-host blocks - // (GT6's WD.setOre does not place ores in them), so the reference dump has no rows for them. - // The port's block-state model does place ores in every StoneType, so each gets the same - // 4U self-gangue profile as the reviewed hosts; the prefix names are port-local, not GT6. - portHost(result, "gypsum", 9161, "Gypsum"); - portHost(result, "salt", 8204, "Salt"); - return Map.copyOf(result); - } - - private static void host( - Map result, - String prefix, - int materialId, - String canonicalName, - boolean adjusted, - String... nativeHostIds) { - var profile = new HostProfile(prefix, new Identity(materialId, canonicalName), 4 * U, adjusted); - for (String host : nativeHostIds) { - if (result.put(host, profile) != null) throw new IllegalStateException("Duplicate source host " + host); - } - } - - /** One port-only stone-layer host, keyed by its {@code StoneType.registryId()}. */ - private static void portHost(Map result, String stone, int materialId, String name) { - String host = "stone_" + stone; - if (result.put( - host, - new HostProfile( - "portOre" + Character.toUpperCase(stone.charAt(0)) + stone.substring(1), - new Identity(materialId, name), - 4 * U, - false)) - != null) throw new IllegalStateException("Duplicate source host " + host); - } -} diff --git a/core/src/main/java/gregtech/content/recipe/SourceOreCrushingRules.java b/core/src/main/java/gregtech/content/recipe/SourceOreCrushingRules.java index f96507bb8..d8731c025 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOreCrushingRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceOreCrushingRules.java @@ -1,15 +1,17 @@ package gregtech.content.recipe; -import static gregtech.api.material.GTValues.U; -import static gregtech.content.recipe.SourceOreWashingRules.Availability; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; -import static gregtech.content.recipe.SourceRecyclingFacts.Identity; +import gregtech.content.material.MaterialFactKeys.HexoriumKind; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; +import static gregtech.api.material.GTValues.U; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; +import static gregtech.content.recipe.SourceOreWashingRules.Availability; + /** Pinned GT6 3703e40308c8c030763fd6297dea8b210d2a77b1, * RecipeMapHandlerCrushing 50-140 / RecipeMapHammer 88-118 / OM 460-467. * Caller proves native identity, source prefix/host classification, and relevant source tag. @@ -43,12 +45,6 @@ public enum Form { BLOCK_DUST } - public enum Hexorium { - NONE, - BLACK_WHITE, - RED_GREEN_BLUE - } - public enum Status { ROW, NO_ROW, @@ -77,7 +73,7 @@ public record Input( int processingMultiplier, int quality, Bonus bonus, - Hexorium hexorium) {} + HexoriumKind hexorium) {} /** Quality belongs to material, not crushingTarget. amount is the prefix's gangue amount. */ public record Gangue( Identity material, long amount, int quality, Identity crushingTarget, long crushingUnitsPerU) {} @@ -171,8 +167,9 @@ private static Result checkedPlan(Request r, Resolver resolver) { boolean crusher = r.machine() == Machine.CRUSHER; long oreMultiplier = in.oreMultiplier(); if (crusher && r.hexoriumAdjustedHost()) - oreMultiplier += - in.hexorium() == Hexorium.BLACK_WHITE ? 1 : in.hexorium() == Hexorium.RED_GREEN_BLUE ? -1 : 0; + oreMultiplier += in.hexorium() == HexoriumKind.BLACK_WHITE + ? 1 + : in.hexorium() == HexoriumKind.RED_GREEN_BLUE ? -1 : 0; if (oreMultiplier < 0) return result(Status.UNSUPPORTED, "negative adjusted multiplier"); long multiplier = Math.multiplyExact(oreMultiplier, in.processingMultiplier()); multiplier = Math.multiplyExact( diff --git a/core/src/main/java/gregtech/content/recipe/SourceOreShreddingRules.java b/core/src/main/java/gregtech/content/recipe/SourceOreShreddingRules.java index d6a78ad92..564173b76 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOreShreddingRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceOreShreddingRules.java @@ -1,14 +1,15 @@ package gregtech.content.recipe; -import static gregtech.content.recipe.SourceOreWashingRules.Availability; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; - import gregtech.api.material.GTValues; import gregtech.content.data.MaterialPrefix; + import java.math.BigInteger; import java.util.List; import java.util.Objects; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.recipe.SourceOreWashingRules.Availability; + /** * The six explicit Shredder handlers, original GT6 3703e40308c8c030763fd6297dea8b210d2a77b1, * Loader_Recipes_Handlers 138-150 and RecipeMapHandlerPrefix 204-226. diff --git a/core/src/main/java/gregtech/content/recipe/SourceOreWashingRules.java b/core/src/main/java/gregtech/content/recipe/SourceOreWashingRules.java index 19248d6dc..9cf788a32 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOreWashingRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceOreWashingRules.java @@ -1,6 +1,7 @@ package gregtech.content.recipe; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -177,7 +178,7 @@ public record Selection(Availability availability, M material) {} * an unknown earlier candidate defers instead of silently changing first-match semantics. */ public static Selection selectByproduct( - M self, List ordered, Function tag, Function tiny) { + M self, List ordered, Function tag, Function tiny) { Objects.requireNonNull(self); Objects.requireNonNull(ordered); Objects.requireNonNull(tag); @@ -185,12 +186,12 @@ public static Selection selectByproduct( var candidates = new ArrayList(ordered); candidates.add(self); for (M candidate : candidates) { - SourceOreWashingData.Decision decision = tag.apply(candidate); - if (decision == SourceOreWashingData.Decision.NO) continue; + MaterialFactKeys.Decision decision = tag.apply(candidate); + if (decision == MaterialFactKeys.Decision.NO) continue; Availability available = tiny.apply(candidate); if (available == Availability.ABSENT) continue; if (decision == null - || decision == SourceOreWashingData.Decision.UNKNOWN + || decision == MaterialFactKeys.Decision.UNKNOWN || available == null || available == Availability.UNKNOWN) return new Selection<>(Availability.UNKNOWN, null); return new Selection<>(Availability.PRESENT, candidate); diff --git a/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java b/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java index 74efa8ab4..1cda035e0 100644 --- a/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java +++ b/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java @@ -1,10 +1,9 @@ package gregtech.content.recipe; -import static gregtech.api.material.GTValues.U; -import static gregtech.content.recipe.SourceRecyclingFacts.Identity; - import java.util.List; +import static gregtech.content.material.MaterialFactKeys.Identity; + /** * Finite purified-acid families from GT6 3703e40308c8c030763fd6297dea8b210d2a77b1, * Loader_Recipes_Ores 108-159. Canonical identities come from the pinned MT declarations; @@ -19,40 +18,31 @@ public enum State { LIQUID, GAS } - /** All 18 bindings are 1000 mB/U. Source ambient fluid() calls resolve liquid at 293 K; - * HF/HCl/H/NO/Cl calls explicitly request gas. The native field/path is a binding assertion, - * not permission to resolve an arbitrary same-name external registry entry. */ + /** The phase selects a recipe material; binding and unit facts live in the material catalog. */ public enum Phase { - AQUAREGIA(id(9827, "AquaRegia"), State.LIQUID, "GenLiquid_AquaRegia", "gt6ce:aquaregia"), - BLUEVITRIOL(id(8404, "BlueVitriol"), State.LIQUID, "GenLiquid_BlueVitriol", "gt6ce:bluevitriol"), - CHLOROPLATINICACID( - id(8401, "ChloroplatinicAcid"), - State.LIQUID, - "GenLiquid_ChloroplatinicAcid", - "gt6ce:chloroplatinicacid"), - CHLORINE(id(170, "Chlorine"), State.GAS, "GenGas_Chlorine", "gt6ce:chlorine"), - CYANVITRIOL(id(8408, "CyanVitriol"), State.LIQUID, "GenLiquid_CyanVitriol", "gt6ce:cyanvitriol"), - GRAYVITRIOL(id(8410, "GrayVitriol"), State.LIQUID, "GenLiquid_GrayVitriol", "gt6ce:grayvitriol"), - GREENVITRIOL(id(8405, "GreenVitriol"), State.LIQUID, "GenLiquid_GreenVitriol", "gt6ce:greenvitriol"), - HYDROGEN(id(10, "Hydrogen"), State.GAS, "Hydrogen", "gt6ce:hydrogen"), - SULFURICACID(id(9824, "SulfuricAcid"), State.LIQUID, "GenLiquid_SulfuricAcid", "gt6ce:sulfuricacid"), - HYDROCHLORICACID(id(9826, "HydrochloricAcid"), State.GAS, "GenGas_HydrochloricAcid", "gt6ce:hydrochloricacid"), - HYDROGENFLUORIDE(id(9829, "HydrogenFluoride"), State.GAS, "GenGas_HydrogenFluoride", "gt6ce:hydrogenfluoride"), - NITROGENMONOXIDE(id(9837, "NitrogenMonoxide"), State.GAS, "GenGas_NitrogenMonoxide", "gt6ce:nitrogenmonoxide"), - PINKVITRIOL(id(8407, "PinkVitriol"), State.LIQUID, "GenLiquid_PinkVitriol", "gt6ce:pinkvitriol"), - REDVITRIOL(id(8406, "RedVitriol"), State.LIQUID, "GenLiquid_RedVitriol", "gt6ce:redvitriol"), - VITRIOLOFCLAY(id(8412, "VitriolOfClay"), State.LIQUID, "GenLiquid_VitriolOfClay", "gt6ce:vitriolofclay"), - WATER(id(9800, "Water"), State.LIQUID, "minecraft:water", "minecraft:water"), - WHITEVITRIOL(id(8409, "WhiteVitriol"), State.LIQUID, "GenLiquid_WhiteVitriol", "gt6ce:whitevitriol"); + AQUAREGIA(id(9827, "AquaRegia"), State.LIQUID), + BLUEVITRIOL(id(8404, "BlueVitriol"), State.LIQUID), + CHLOROPLATINICACID(id(8401, "ChloroplatinicAcid"), State.LIQUID), + CHLORINE(id(170, "Chlorine"), State.GAS), + CYANVITRIOL(id(8408, "CyanVitriol"), State.LIQUID), + GRAYVITRIOL(id(8410, "GrayVitriol"), State.LIQUID), + GREENVITRIOL(id(8405, "GreenVitriol"), State.LIQUID), + HYDROGEN(id(10, "Hydrogen"), State.GAS), + SULFURICACID(id(9824, "SulfuricAcid"), State.LIQUID), + HYDROCHLORICACID(id(9826, "HydrochloricAcid"), State.GAS), + HYDROGENFLUORIDE(id(9829, "HydrogenFluoride"), State.GAS), + NITROGENMONOXIDE(id(9837, "NitrogenMonoxide"), State.GAS), + PINKVITRIOL(id(8407, "PinkVitriol"), State.LIQUID), + REDVITRIOL(id(8406, "RedVitriol"), State.LIQUID), + VITRIOLOFCLAY(id(8412, "VitriolOfClay"), State.LIQUID), + WATER(id(9800, "Water"), State.LIQUID), + WHITEVITRIOL(id(8409, "WhiteVitriol"), State.LIQUID); private final Identity material; private final State state; - private final String nativeField, registryId; - Phase(Identity material, State state, String nativeField, String registryId) { + Phase(Identity material, State state) { this.material = material; this.state = state; - this.nativeField = nativeField; - this.registryId = registryId; } public Identity material() { @@ -62,22 +52,6 @@ public Identity material() { public State state() { return state; } - - public String nativeField() { - return nativeField; - } - - public String registryId() { - return registryId; - } - - public long millibucketsPerUnit() { - return 1000; - } - - public long materialUnit() { - return U; - } } public record Fluid(Phase phase, long millibuckets) {} @@ -322,7 +296,9 @@ public static boolean matchesManganeseDefault(int id, String name, List f.members().contains(material)) + return java.util.Arrays.stream(Phase.values()) + .anyMatch(phase -> phase.material().equals(material)) + || FAMILIES.stream().anyMatch(f -> f.members().contains(material)) || MANGANESE_DEFAULTS.stream().anyMatch(d -> d.material().equals(material)); } diff --git a/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidRules.java b/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidRules.java index 8c87f58b8..93fe42c5a 100644 --- a/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidRules.java @@ -1,15 +1,16 @@ package gregtech.content.recipe; -import static gregtech.content.recipe.SourceOreWashingRules.Availability; -import static gregtech.content.recipe.SourcePurifiedAcidData.*; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; -import static gregtech.content.recipe.SourceRecyclingFacts.Identity; - import gregtech.content.data.MaterialPrefix; + import java.util.ArrayList; import java.util.List; import java.util.Objects; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; +import static gregtech.content.recipe.SourceOreWashingRules.Availability; +import static gregtech.content.recipe.SourcePurifiedAcidData.*; + /** * Purified-acid Bath algorithms from GT6 3703e40308c8c030763fd6297dea8b210d2a77b1, * Loader_Recipes_Ores 108-159. Native identity/phase proof and registration are separate. @@ -80,7 +81,7 @@ public boolean optimize() { public interface Resolver { /** Exact direct form and quantity, without purified/refined fallback or target conversion. */ Availability item(MaterialPrefix prefix, Identity material, int count); - /** Source absence differs from unavailable native binding: these 18 source phases exist, + /** Source absence differs from unavailable native binding: these 17 source phases exist, * so an unproved/replaced/missing native holder must be UNKNOWN, not silently discarded. */ Availability fluid(Phase phase, long millibuckets); } diff --git a/core/src/main/java/gregtech/content/recipe/SourceRollingWireRules.java b/core/src/main/java/gregtech/content/recipe/SourceRollingWireRules.java index 2c00a1f51..9e4c2ff5e 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceRollingWireRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceRollingWireRules.java @@ -4,6 +4,7 @@ import gregtech.api.material.GTValues; import gregtech.api.material.MaterialProperty; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.material.SourceLatheMaterialProfiles; import gregtech.engine.prefix.BlockMaterialPrefix; import java.math.BigInteger; @@ -125,12 +126,8 @@ public static Decision physicalWire( if (profile == null) return new Decision(legacyAllowed, legacyTicks, false); // Only these two actual native families have proven admission beyond the legacy policy. boolean provenAddition = sourceAdditionalFamily - && (material == gregtech.content.material.Materials.Netherite - && material.getId() == 8745 - && material.getName().equals("Netherite") - || material == gregtech.content.material.Materials.Naquadah - && material.getId() == 1740 - && material.getName().equals("Naquadah")); + && MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY) + .orElse(false); return new Decision( (legacyAllowed || provenAddition) && profile.smithable() diff --git a/core/src/main/java/gregtech/content/recipe/SourceThermalInputRules.java b/core/src/main/java/gregtech/content/recipe/SourceThermalInputRules.java index 71d161e1a..424739918 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceThermalInputRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceThermalInputRules.java @@ -1,16 +1,12 @@ package gregtech.content.recipe; -import static gregtech.content.recipe.SourceThermalRecyclingRules.Decision; -import static gregtech.content.recipe.SourceThermalRecyclingRules.Facts; -import static gregtech.content.recipe.SourceThermalRecyclingRules.Phase; -import static gregtech.content.recipe.SourceThermalRecyclingRules.Plan; -import static gregtech.content.recipe.SourceThermalRecyclingRules.Stats; -import static gregtech.content.recipe.SourceThermalRecyclingRules.Truth; - import gregtech.content.data.MaterialPrefix; + import java.util.List; import java.util.stream.Stream; +import static gregtech.content.recipe.SourceThermalRecyclingRules.*; + /** * Eighty-five single-component item-input contracts for source RecyclingProcessing, not the complete * listener and not a global prefix policy. Pinned GT6 3703e40308c8c030763fd6297dea8b210d2a77b1: @@ -22,7 +18,7 @@ public final class SourceThermalInputRules { private SourceThermalInputRules() {} - private static final long U = OriginalMaterialFluidUnits.SOURCE_UNIT; + private static final long U = gregtech.content.material.catalog.MaterialFluidUnitFacts.SOURCE_UNIT; public enum InputProof { VERIFIED_SINGLE_COMPONENT, diff --git a/core/src/main/java/gregtech/content/recipe/SourceThermalRecyclingRules.java b/core/src/main/java/gregtech/content/recipe/SourceThermalRecyclingRules.java index 5f32beee9..b7956045e 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceThermalRecyclingRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceThermalRecyclingRules.java @@ -14,7 +14,7 @@ private SourceThermalRecyclingRules() {} public static final int POWER = 16; public static final long ENVIRONMENT_TEMPERATURE = 293; - private static final long U = OriginalMaterialFluidUnits.SOURCE_UNIT; + private static final long U = gregtech.content.material.catalog.MaterialFluidUnitFacts.SOURCE_UNIT; public enum Truth { YES, diff --git a/core/src/main/java/gregtech/content/recipe/SourceWaxMaterials.java b/core/src/main/java/gregtech/content/recipe/SourceWaxMaterials.java deleted file mode 100644 index 796a3afb6..000000000 --- a/core/src/main/java/gregtech/content/recipe/SourceWaxMaterials.java +++ /dev/null @@ -1,34 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.api.material.GTMaterial; -import gregtech.engine.addon.AddonMaterials; -import gregtech.engine.material.GTMaterialRegistry; -import java.util.ArrayList; -import java.util.List; - -/** Retained source wax identities used by mineral steam cracking. */ -public final class SourceWaxMaterials { - private SourceWaxMaterials() {} - - private record Identity(int id, String name) {} - - private static final List WAXES = List.of( - new Identity(8235, "Wax"), - new Identity(8236, "WaxBee"), - new Identity(8238, "WaxParaffin"), - new Identity(8239, "WaxPlant")); - - public static List materials() { - var result = new ArrayList(); - for (var identity : WAXES) { - var material = GTMaterialRegistry.get(identity.name()); - if (material != null - && material.isValid() - && !AddonMaterials.owns(material) - && GTMaterialRegistry.isCoreMaterial(material.resolve()) - && material.resolve().getId() == identity.id() - && material.resolve().getName().equals(identity.name())) result.add(material); - } - return List.copyOf(result); - } -} diff --git a/core/src/main/java/gregtech/engine/recipe/SourceRecyclingMath.java b/core/src/main/java/gregtech/engine/recipe/SourceRecyclingMath.java index 73a9d5fc0..4440a3b9f 100644 --- a/core/src/main/java/gregtech/engine/recipe/SourceRecyclingMath.java +++ b/core/src/main/java/gregtech/engine/recipe/SourceRecyclingMath.java @@ -81,7 +81,7 @@ public static Result singleFluid( || environmentTemperature < 0) throw new IllegalArgumentException("Unreviewed thermal arithmetic inputs"); long target = unitsDown(inputUnits, sourceUnit, targetPerUnit); - int mb = gregtech.content.recipe.OriginalMaterialFluidUnits.millibuckets( + int mb = gregtech.content.material.catalog.MaterialFluidUnitFacts.millibuckets( target, referenceFluidUnits, referenceMillibuckets, false); if (mb < 0) throw new ArithmeticException("Fluid amount exceeds native int capacity"); // Source uses input mass, not output mass, and keeps this exact double expression/order. diff --git a/core/src/main/java/gregtech/engine/recipe/chem/MaterialFluidBinding.java b/core/src/main/java/gregtech/engine/recipe/chem/MaterialFluidBinding.java index 3d19b3d92..04d7c76ef 100644 --- a/core/src/main/java/gregtech/engine/recipe/chem/MaterialFluidBinding.java +++ b/core/src/main/java/gregtech/engine/recipe/chem/MaterialFluidBinding.java @@ -1,7 +1,7 @@ package gregtech.engine.recipe.chem; import gregtech.content.data.FluidCatalog; -import gregtech.content.recipe.OriginalMaterialFluidUnits; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; @@ -20,7 +20,7 @@ public record MaterialFluidBinding( int referenceMillibuckets) { public int millibuckets(MaterialAmount amount, Rounding rounding) { - int value = OriginalMaterialFluidUnits.millibuckets( + int value = MaterialFluidUnitFacts.millibuckets( amount.units(), referenceUnits, referenceMillibuckets, rounding == Rounding.CEIL); if (value <= 0) throw new IllegalArgumentException("Fluid amount out of range: " + amount); return value; @@ -96,7 +96,7 @@ private static Map build() { FluidPhase phase = fluid.gas() ? FluidPhase.GAS : FluidPhase.LIQUID; int reference = reference(materialKey, field, fluid, phase); var binding = new MaterialFluidBinding( - materialKey, phase, field, fluid.registryName(), OriginalMaterialFluidUnits.SOURCE_UNIT, reference); + materialKey, phase, field, fluid.registryName(), MaterialFluidUnitFacts.SOURCE_UNIT, reference); var key = new Key(binding.material(), binding.phase()); var previous = out.putIfAbsent(key, binding); if (previous != null && previous.referenceMillibuckets() != reference) @@ -107,7 +107,8 @@ private static Map build() { } private static int reference(String material, String field, FluidCatalog.FluidEntry entry, FluidPhase phase) { - var explicit = OriginalMaterialFluidUnits.binding(material, phase.sourceName()); + var resolved = gregtech.engine.material.GTMaterialRegistry.get(material); + var explicit = resolved.isValid() ? MaterialFluidUnitFacts.binding(resolved, phase.sourceName()) : null; if (explicit != null) { long millibuckets = explicit.referenceMillibuckets(); if (millibuckets <= 0 || millibuckets > Integer.MAX_VALUE) @@ -117,8 +118,7 @@ private static int reference(String material, String field, FluidCatalog.FluidEn boolean molten = entry.textureMode() == FluidCatalog.FluidTextureMode.GENERIC_MOLTEN || FluidCatalog.isGeneratedMoltenDefinition(field, entry); if (molten) { - var resolved = gregtech.engine.material.GTMaterialRegistry.get(material); - return resolved != null && resolved.isValid() + return resolved.isValid() ? gregtech.engine.fluid.MoltenMaterialUnits.ratio(resolved).millibucketsPerUnit() : 144; } diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index ef7028c54..c9cf20738 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -12687,8 +12687,6 @@ "tooltip.gt6ce.chemical_battery.place": "Sneak to place; stored charge is retained when picked up", "tooltip.gt6ce.coin_mold.1": "Place a tiny metal plate on top, strike it with a hammer, and take the coin", "tooltip.gt6ce.coin_mold.2": "No GUI; click to interact (top or sides)", - "tooltip.gt6ce.composition_descriptive": "Composition reference only; not enabled for bulk recovery", - "tooltip.gt6ce.composition_nonmaterial": "No recoverable bulk material (technical/entity item)", "tooltip.gt6ce.contained_materials": "Contained Materials:", "tooltip.gt6ce.crucible.acidproof": "Acid Proof!", "tooltip.gt6ce.crucible.contact_damage": "Causes Damage when touched while active!", @@ -13737,4 +13735,4 @@ "enchantment.gt6ce.gt_haste": "Efficiency", "enchantment.gt6ce.sharpness_multi": "Sharpness", "enchantment.gt6ce.smite_multi": "Smite" -} \ No newline at end of file +} diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index 2179067e3..fd09c1632 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -96384,8 +96384,6 @@ "tooltip.gt6ce.chemical_battery.place": "Sneak to place; stored charge is retained when picked up", "tooltip.gt6ce.coin_mold.1": "在顶部放置一块小型金属板,用锤敲击后取出硬币", "tooltip.gt6ce.coin_mold.2": "没有 GUI;点击顶部或侧面进行交互", - "tooltip.gt6ce.composition_descriptive": "Composition reference only; not enabled for bulk recovery", - "tooltip.gt6ce.composition_nonmaterial": "No recoverable bulk material (technical/entity item)", "tooltip.gt6ce.contained_materials": "含有材料:", "tooltip.gt6ce.crucible.acidproof": "Acid Proof!", "tooltip.gt6ce.crucible.contact_damage": "当它在运作的时候接触会受伤!", @@ -98033,4 +98031,4 @@ "enchantment.gt6ce.gt_haste": "效率", "enchantment.gt6ce.sharpness_multi": "锋利", "enchantment.gt6ce.smite_multi": "亡灵杀手" -} \ No newline at end of file +} diff --git a/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java b/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java index 94d70ddfe..efb1b4321 100644 --- a/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java +++ b/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java @@ -1,32 +1,144 @@ package gregtech.content.material; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; - +import gregtech.api.addon.material.GregTechMaterials; +import gregtech.api.addon.material.MaterialKey; import gregtech.content.fluid.FluidDefinitions; -import gregtech.content.recipe.SourceRecyclingFacts; -import gregtech.content.recipe.SourceWaxMaterials; import gregtech.content.storage.ItemBarrelCatalog; import gregtech.content.tool.AnvilVariantCatalog; import gregtech.engine.material.GTMaterialRegistry; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + class MaterialCatalogTest { + @Test + void reviewedRecipeFactsAreFullyProjectedIntoMaterialDeclarations() { + var declarations = MaterialDefinitions.declarations(); + assertEquals(198, processCount(declarations, MaterialFactKeys.SOURCE_FURNACE)); + assertEquals(2, processCount(declarations, MaterialFactKeys.SOURCE_GRADED_GEM)); + assertEquals(39, processCount(declarations, MaterialFactKeys.SOURCE_ORE_INPUT)); + assertEquals(1, processCount(declarations, MaterialFactKeys.SOURCE_SIFTING_EXCLUSIONS)); + assertEquals(9, processCount(declarations, MaterialFactKeys.SOURCE_CRUSHED_EXCLUSIONS)); + assertEquals(11, processCount(declarations, MaterialFactKeys.SOURCE_ORE_SHREDDER)); + assertEquals(670, processCount(declarations, MaterialFactKeys.SOURCE_MACERATION)); + assertEquals(142, processCount(declarations, MaterialFactKeys.SOURCE_WASHING)); + assertEquals(51, processCount(declarations, MaterialFactKeys.MATERIAL_FLUID_UNIT)); + assertEquals(134, processCount(declarations, MaterialFactKeys.GENERIFICATION_TARGET)); + assertEquals(733, processCount(declarations, MaterialFactKeys.SOURCE_EXTRUSION)); + // Four additional source lens roles belong to absent optional Hexorium materials. + assertEquals(53, processCount(declarations, MaterialFactKeys.SOURCE_LENS_ROLE)); + assertEquals(1, processCount(declarations, MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON)); + assertEquals(3, processCount(declarations, MaterialFactKeys.SOURCE_GENERATED_FLUID)); + assertEquals(672, processCount(declarations, MaterialFactKeys.SOURCE_RECYCLING)); + assertEquals(15, processCount(declarations, MaterialFactKeys.SOURCE_MOLTEN_FLUID)); + assertEquals(672, processCount(declarations, MaterialFactKeys.SOURCE_ORE_CRUSHING)); + assertEquals(6, processCount(declarations, MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_PHASE)); + assertEquals(7, processCount(declarations, MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT)); + assertEquals(2, processCount(declarations, MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY)); + assertEquals(1, processCount(declarations, MaterialFactKeys.COMPRESSOR_DUST_TO_GEM_PLATE)); + } + @Test void standaloneMaterialsAndDeviceCatalogsResolveWithoutLegacyMods() { MaterialTestFixture.ensureInitialized(); FluidDefinitions.prepare(); verifyCanonicalFluids(); verifyAlloyMeltingAndMoltenTemperature(); - // Building the thermal facts also verifies every phase binding and target has an identity. - assertTrue(!SourceRecyclingFacts.all().isEmpty()); - assertNotNull(SourceRecyclingFacts.find(260, "Iron")); - assertNotNull(SourceRecyclingFacts.find(790, "Gold")); - assertNull(SourceRecyclingFacts.find(1850, "Abyssalnite")); - assertNull(SourceRecyclingFacts.find(8703, "Manyullyn")); + var processes = GregTechMaterials.processes(); + // The material process payload verifies every source phase binding and target identity. + assertTrue(processes + .findSingle(new MaterialKey("Iron"), MaterialFactKeys.SOURCE_RECYCLING) + .isPresent()); + assertTrue(processes + .findSingle(new MaterialKey("Gold"), MaterialFactKeys.SOURCE_RECYCLING) + .isPresent()); + assertTrue(processes + .findSingle(new MaterialKey("Abyssalnite"), MaterialFactKeys.SOURCE_RECYCLING) + .isEmpty()); + assertTrue(processes + .findSingle(new MaterialKey("Manyullyn"), MaterialFactKeys.SOURCE_RECYCLING) + .isEmpty()); + assertFalse(processes + .findSingle(new MaterialKey("Water"), MaterialFactKeys.SOURCE_RECYCLING) + .orElseThrow() + .value() + .inputEligible()); + assertTrue(processes + .findSingle(new MaterialKey("Iron"), MaterialFactKeys.SOURCE_EXTRUSION) + .isPresent()); + var aquaRegia = processes + .findSingle(new MaterialKey("AquaRegia"), MaterialFactKeys.MATERIAL_FLUID_UNIT) + .orElseThrow() + .value(); + assertTrue(aquaRegia.units().stream() + .anyMatch(unit -> unit.phase().equals("liquid") + && unit.fluidField().equals("GenLiquid_AquaRegia") + && unit.referenceMillibuckets() == 1000)); + for (var phase : gregtech.content.recipe.SourcePurifiedAcidData.Phase.values()) { + var units = processes + .findSingle(new MaterialKey(phase.material().name()), MaterialFactKeys.MATERIAL_FLUID_UNIT) + .orElseThrow(() -> new AssertionError("Missing acid fluid units: " + phase)) + .value() + .units(); + assertTrue( + units.stream() + .anyMatch(unit -> + unit.phase().equals(phase.state().name().toLowerCase(java.util.Locale.ROOT))), + phase.name()); + } + var titaniumFluid = processes + .findSingle(new MaterialKey("Titanium"), MaterialFactKeys.SOURCE_GENERATED_FLUID) + .orElseThrow() + .value() + .rules() + .stream() + .findFirst() + .orElseThrow(); + assertTrue(titaniumFluid.wholeDustMetal()); + assertEquals(4.54F, titaniumFluid.materialDensity()); + assertTrue(processes + .findSingle(new MaterialKey("Carbon14"), MaterialFactKeys.SOURCE_MOLTEN_FLUID) + .orElseThrow() + .value()); + var cinnabarRule = processes + .findSingle(new MaterialKey("Cinnabar"), MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON) + .orElseThrow() + .value(); + assertEquals(9114, cinnabarRule.cinnabar().id()); + for (String byproduct : java.util.List.of("Redstone", "Sulfur", "Glowstone", "Selenium", "SluiceSand")) { + assertTrue(processes + .findSingle(new MaterialKey(byproduct), MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON) + .isEmpty()); + } + assertTrue(GTMaterialRegistry.get("Iron").has(gregtech.api.material.MaterialProperty.MAGNETIC)); + assertEquals( + MaterialFactKeys.Decision.YES, + processes + .findSingle(new MaterialKey("Lithium6"), MaterialFactKeys.SOURCE_FURNACE) + .orElseThrow() + .value()); + assertEquals( + MaterialFactKeys.Decision.YES, + processes + .findSingle(new MaterialKey("HydratedCoal"), MaterialFactKeys.SOURCE_FURNACE) + .orElseThrow() + .value()); + assertTrue(processes + .findSingle(new MaterialKey("Netherite"), MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY) + .orElseThrow() + .value()); + assertTrue(processes + .findSingle(new MaterialKey("Naquadah"), MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY) + .orElseThrow() + .value()); + assertTrue(processes + .findSingle(new MaterialKey("Titanium"), MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY) + .isEmpty()); + assertTrue(processes + .findSingle(new MaterialKey("Ice"), MaterialFactKeys.SOURCE_SIFTING_EXCLUSIONS) + .orElseThrow() + .value() + .excludes("gemLegendary")); assertTrue(gregtech.content.energy.WireCatalog.specifications().stream() .anyMatch(wire -> wire.material() == Materials.Gold && wire.insulated() && wire.size() == 4)); for (int id : new int[] { @@ -45,7 +157,9 @@ void standaloneMaterialsAndDeviceCatalogsResolveWithoutLegacyMods() { assertEquals(8250 + i, dye.getId()); assertTrue(dye.getName().startsWith("Dye")); assertTrue(!GTMaterialRegistry.get(9500 + i).isValid()); - assertNotNull(SourceRecyclingFacts.find(dye.getId(), dye.getName())); + assertTrue(processes + .findSingle(new MaterialKey(dye.getName()), MaterialFactKeys.SOURCE_RECYCLING) + .isPresent()); } for (String retained : java.util.List.of( "Greatwood", @@ -62,13 +176,6 @@ void standaloneMaterialsAndDeviceCatalogsResolveWithoutLegacyMods() { for (int id : new int[] {1250, 8752, 9204, 9205, 9206, 9207, 9208, 9209}) assertTrue(GTMaterialRegistry.get(id).isValid(), "Restored Tritanium material " + id); assertSame(GTMaterialRegistry.get("Tn"), GTMaterialRegistry.get(1250), "Tn alias"); - var waxes = SourceWaxMaterials.materials(); - assertEquals( - java.util.List.of(8235, 8236, 8238, 8239), - waxes.stream().map(material -> material.getId()).toList()); - assertEquals( - java.util.List.of("Wax", "WaxBee", "WaxParaffin", "WaxPlant"), - waxes.stream().map(material -> material.getName()).toList()); for (String name : new String[] { "Iron", "Amethyst", @@ -201,4 +308,13 @@ void netherBedrockOresKeepOnlyTheRetainedMaterials() { assertTrue(!GTMaterialRegistry.get(8456).isValid()); assertTrue(!GTMaterialRegistry.get(8457).isValid()); } + + private static long processCount( + java.util.List declarations, + gregtech.api.addon.material.MaterialProcessKey key) { + return declarations.stream() + .filter(declaration -> + declaration.info().processes().findSingle(key).isPresent()) + .count(); + } } diff --git a/core/src/test/java/gregtech/engine/recipe/MaterialDecompositionPlannerTest.java b/core/src/test/java/gregtech/engine/recipe/MaterialDecompositionPlannerTest.java index 644ec5b34..ae0025c9d 100644 --- a/core/src/test/java/gregtech/engine/recipe/MaterialDecompositionPlannerTest.java +++ b/core/src/test/java/gregtech/engine/recipe/MaterialDecompositionPlannerTest.java @@ -5,9 +5,10 @@ import gregtech.api.addon.material.MaterialProcessKeys; import gregtech.api.material.GTValues; import gregtech.content.material.MaterialDefinitions; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.material.MaterialTestFixture; import gregtech.content.material.catalog.DecompositionMaterials; -import gregtech.content.recipe.OriginalMaterialFluidUnits; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.engine.material.MaterialInfoRegistry; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -99,20 +100,28 @@ void declaredWaterPhasesRemainAvailableWithoutInventingARoute() { @Test void decompositionReusesSharedFluidUnitFacts() { - assertEquals(GTValues.U, OriginalMaterialFluidUnits.SOURCE_UNIT); + assertEquals(GTValues.U, MaterialFluidUnitFacts.SOURCE_UNIT); var rule = MaterialInfoRegistry.processes(new MaterialKey("Chocolate")) .findSingle(MaterialProcessKeys.DECOMPOSITION) .orElseThrow() .value(); - var shared = OriginalMaterialFluidUnits.binding("Chocolate", 9783, "liquid"); + var shared = MaterialInfoRegistry.processes(new MaterialKey("Chocolate")) + .findSingle(MaterialFactKeys.MATERIAL_FLUID_UNIT) + .orElseThrow() + .value() + .units() + .stream() + .filter(binding -> binding.phase().equals("liquid")) + .findFirst() + .orElseThrow(); assertTrue(rule.fluids() .contains(new MaterialDecompositionRule.FluidBinding( MaterialDecompositionRule.Phase.LIQUID, - shared.registryName(), + shared.registryPath(), shared.referenceSourceUnits(), shared.referenceMillibuckets()))); assertEquals( - OriginalMaterialFluidUnits.millibuckets(GTValues.U, GTValues.U, 144, false), + MaterialFluidUnitFacts.millibuckets(GTValues.U, GTValues.U, 144, false), UnitConversion.fluidAmount(GTValues.U, GTValues.U, 144, false)); } diff --git a/core/src/test/java/gregtech/engine/recipe/chem/MaterialAmountTest.java b/core/src/test/java/gregtech/engine/recipe/chem/MaterialAmountTest.java index 347f7436e..24efc933a 100644 --- a/core/src/test/java/gregtech/engine/recipe/chem/MaterialAmountTest.java +++ b/core/src/test/java/gregtech/engine/recipe/chem/MaterialAmountTest.java @@ -1,13 +1,11 @@ package gregtech.engine.recipe.chem; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - import gregtech.api.material.GTValues; -import gregtech.content.recipe.OriginalMaterialFluidUnits; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + /** Material units are exact and only material fluids cross a reviewed millibucket boundary. */ final class MaterialAmountTest { @Test @@ -31,14 +29,13 @@ void fractionConstantU50IsOneFiftiethOfAUnit() { assertEquals(GTValues.U / 50, MaterialAmount.fraction(1, 50).units()); assertEquals( 20, - OriginalMaterialFluidUnits.millibuckets( - GTValues.U / 50, OriginalMaterialFluidUnits.SOURCE_UNIT, 1000, false)); + MaterialFluidUnitFacts.millibuckets(GTValues.U / 50, MaterialFluidUnitFacts.SOURCE_UNIT, 1000, false)); } @Test void cryoliteTwentyUnitsUseTheMoltenBinding() { - int millibuckets = OriginalMaterialFluidUnits.millibuckets( - 20 * GTValues.U, OriginalMaterialFluidUnits.SOURCE_UNIT, 144, false); + int millibuckets = + MaterialFluidUnitFacts.millibuckets(20 * GTValues.U, MaterialFluidUnitFacts.SOURCE_UNIT, 144, false); assertEquals(2880, millibuckets); } @@ -46,15 +43,12 @@ void cryoliteTwentyUnitsUseTheMoltenBinding() { void aluminiumFluorideProductionAndElectrolysisShareOneRule() { assertEquals( 576, - OriginalMaterialFluidUnits.millibuckets( - 4 * GTValues.U, OriginalMaterialFluidUnits.SOURCE_UNIT, 144, false)); + MaterialFluidUnitFacts.millibuckets(4 * GTValues.U, MaterialFluidUnitFacts.SOURCE_UNIT, 144, false)); assertEquals( 1152, - OriginalMaterialFluidUnits.millibuckets( - 8 * GTValues.U, OriginalMaterialFluidUnits.SOURCE_UNIT, 144, false)); + MaterialFluidUnitFacts.millibuckets(8 * GTValues.U, MaterialFluidUnitFacts.SOURCE_UNIT, 144, false)); assertEquals( 1728, - OriginalMaterialFluidUnits.millibuckets( - 12 * GTValues.U, OriginalMaterialFluidUnits.SOURCE_UNIT, 144, false)); + MaterialFluidUnitFacts.millibuckets(12 * GTValues.U, MaterialFluidUnitFacts.SOURCE_UNIT, 144, false)); } } diff --git a/docs/architecture/packages/content.md b/docs/architecture/packages/content.md index 7a594e07e..cdb613415 100644 --- a/docs/architecture/packages/content.md +++ b/docs/architecture/packages/content.md @@ -9,12 +9,12 @@ | 包 | 应当承担 | 代表入口/说明 | | --- | --- | --- | | `content` | 内容层总体职责说明 | `package-info.java` | -| `content.material` | 材料目录入口、物性规则和稳定符号门面 | `MaterialDefinitions`、`Materials`;读取符号不触发注册 | -| `content.material.catalog` | 元素、化合物、矿石、石材、木材、特殊材料和组的规范声明 | `ElementMaterials`、`CompoundMaterials`、`GroupMaterials`;每项材料事实只在这里维护 | +| `content.material` | 材料目录入口、物性规则、类型化 process 键与稳定符号门面 | `MaterialDefinitions`、`MaterialFactKeys`、`Materials`;读取符号不触发注册 | +| `content.material.catalog` | 元素、化合物、矿石、石材、木材、特殊材料、组的规范声明及有界工艺事实 | `ElementMaterials`、`CompoundMaterials`、`GroupMaterials`、`SourceExtrusionMaterialFacts`;每项材料事实只在这里维护 | | `content.material.generated` | 既有 GT6 字段符号门面 | `ElementMaterials`、`CompoundMaterials`;引用规范目录中的已安装对象 | | `content.data` | 原版参数、跨领域内容事实与标识表 | `FluidCatalog`、`MaterialGroups`;仅跨领域事实放这里 | | `content.data.generated` | 尚留存的兼容查询门面和历史字段映射 | `MaterialForms`、`MaterialProcessingTargets`;权威材料事实位于 `content.material.catalog` | -| `content.recipe` | 具体配方行、合成目录与内容规则 | `AutoclaveRecipeRows`、`ClayMoldCatalog` | +| `content.recipe` | 具体配方行、合成目录、机器模板与原生适配 | `AutoclaveRecipeRows`、`ClayMoldCatalog`;不保存可直接归入材料目录的重复事实 | | `content.recipe.generated` | 提取/转换后的原 GT6 配方数据 | `GTAlloyTable`、`GeneratedRecipeSink` | | `content.machine` | 基础机器种类、材料、面与原版参数 | `BasicMachineCatalog`、`OriginalBasicMachineRules` | | `content.multiblock` | 原版多方块控制器参数与布局相关定义 | `OriginalAdvancedControllerData` 等;不访问世界 | @@ -57,7 +57,7 @@ | `content.data`、`content.data.generated` | 内容数据的原生适配和既有兼容数据;新代码优先放明确领域 | | `content.machine` | 基础机器定义在游戏侧的物化和调参,如 `BasicMachineDefinitions` | | `content.multiblock` | `ControllerDeclarations` 绑定具体主控,`ControllerStructureLayouts` 从相同声明产生预览;布局与设备规格 | -| `content.material` | 原版物品成分、统一化与模组物品绑定的加载;共享 `MaterialItemCompositions` 汇集两平台纯物品/方块提交 | +| `content.material` | 原版物品成分、统一化与模组物品绑定的加载;共享 `MaterialItemCompositions` 汇集两平台纯物品/方块提交,`PanelMaterialCompositions`、`TransportMaterialCompositions`、`WoodMaterialCompositions` 承担分域固定成分,recipe 生产类不安装固定成分 | | `content.energy` | 能源设备的具体游戏接入;节点的 `content.fluid` 承担原生流体对象 | | `content.transport`、`content.transport.fluid` | 管道定义物化、物品转移适配及流体 tick 阶段 | | `content.cover`、`content.logistics` | 覆盖板宿主/交互/信号、`CoverStore` 共享存储与生命周期,及物流核心结构、路由接入 | diff --git a/docs/development/material-system-refactor/05-recovery.md b/docs/development/material-system-refactor/05-recovery.md index 12265c832..a8d063504 100644 --- a/docs/development/material-system-refactor/05-recovery.md +++ b/docs/development/material-system-refactor/05-recovery.md @@ -6,7 +6,7 @@ ## 当前入口与目标 -实际生产端包括 `VanillaRecoveryRecipes`、`ShredderRecyclingRecipes`、`AnvilShreddingRecipes`、`SharedThermalRecyclingRows`、`SharedThermalInputRows`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader`、`ReviewedCinnabarThermalRecipes`、`ExternalOreProcessing`、`StoneVariantRecipes`、`CapsuleCellRecipes` 等。清理和重载还涉及 `MachineRecipeLifecycle`、`MachineRecipeOverlay`、`ExternalOreRecipeLifecycle`、`MoltenMetalUnitRecipes`。 +实际生产端包括 `VanillaRecoveryRecipes`、`ShredderRecyclingRecipes`、`AnvilShreddingRecipes`、`SharedThermalRecyclingRows`、`SharedThermalInputRows`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader`、`SourceDustThermalRecipes`、`ExternalOreProcessing`、`StoneVariantRecipes`、`CapsuleCellRecipes` 等。清理和重载还涉及 `MachineRecipeLifecycle`、`MachineRecipeOverlay`、`ExternalOreRecipeLifecycle`、`MoltenMetalUnitRecipes`。 目标数据流是“有效成分+栈状态+指定工艺 → 回收计划 → 原生配方或运行期处理”。计划包含输入基准量、完整输出量、耗时/能量、输入限制以及不能执行的原因;计算规则不持有 `ItemStack`,游戏层负责绑定物品、流体与机器槽。 @@ -115,7 +115,7 @@ JUnit 验证计算边界;GameTest 要通过最终 `RecipeMap`/运行期入 ## PR #374 复核补正(2026-11-12) -- `ReviewedCinnabarThermalRecipes`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader` 与 `VanillaStoneMachineRecipes` 遗留的 Melter/Smelter/石质 Shredder 直写全部改经 `RecoveryRecipePublisher`。审核、native 和石材分支使用 explicit ownership,兼容回退使用 generic ownership,不再绕过 typed family 冲突处理。 +- `SourceDustThermalRecipes`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader` 与 `VanillaStoneMachineRecipes` 遗留的 Melter/Smelter/石质 Shredder 直写全部改经 `RecoveryRecipePublisher`。审核、native 和石材分支使用 explicit ownership,兼容回退使用 generic ownership,不再绕过 typed family 冲突处理。 - `ItemMaterialRegistry.beginTagGeneration()` 返回上一代检查点;`MachineRecipeOverlay` 失败恢复时回滚标签候选、有效成分、诊断、readiness、tag generation 与 composition revision。上一份 `MaterialPublication` stamp 保持不变。 - `ThermalRecoveryOwnership` 删除 9114/`Cinnabar` 及其 dust/crushed 前缀硬编码,只保留已审核的 Ti/Fe 粉尘分数组所有者。GameTest 同时覆盖失败代回滚与朱砂普通所有权。 - 验证通过:双平台生产与测试源码编译、`:minecraft:spotlessCheck`、Forge 1.20.1 GameTest 92/92、NeoForge 1.21.1 GameTest 97/97。 diff --git a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md index 81dd4c30a..c5232cee1 100644 --- a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md +++ b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md @@ -1,6 +1,37 @@ # 07:清理与双平台整体验收 -本计划在数据与执行路径已收敛后移除旧实现,审计无消费内容,完成用户可见行为与双平台验收。状态:待实施;前置为 [02](02-material-registration.md)—[06](06-decomposition.md) 及 [08](08-material-data-api.md) 的集成切片。 +本计划在数据与执行路径已收敛后移除旧实现,审计无消费内容,完成用户可见行为与双平台验收。状态:内部清理已实施;[02](02-material-registration.md)—[06](06-decomposition.md) 已合入 master。07-A—D 的首轮清理已完成并通过 core 测试与双平台编译;07-E 已完成文档点名的高优先级形态定向审计,但完整注册项清单和 07-F 最终验收仍未完成;[08](08-material-data-api.md)-D—E 也尚未实施,因此不能把全部 07 标为完成。 + +本页原清单按 master `f096a79ee`(2026-11-12)核对源码。2026-11-13 已完成首轮内部迁移:材料事实归入 `content.material.catalog` 的类型化 process 规则,运行时消费者改经材料查询,recipe 包只保留配方模板、特殊工艺和原生适配。下文保留旧类名用于追溯删除对象;实际新入口见“本轮实施结果”。 + +## 本轮实施结果 + +| 原入口 | 新权威入口 | 已迁移消费者 | 结果 | +| --- | --- | --- | --- | +| `ReviewedOreSourceProfile`、`ReviewedMagneticMaterials`、`ReviewedSiftingGemForms` | `ReviewedSourceMaterialFacts` | `OreSourcePolicy`、`FurnaceSmeltingRules`、`SourceFurnaceNativeAdapter`、`SourceGemGradeResolver`、`OreProcessingRecipeLoader` | 旧类删除;磁性正例写入材料 `MAGNETIC` 属性,其余事实写入 `SOURCE_*` process | +| `ReviewedOreInputProfile`、`ReviewedOreShredderFacts`、`ReviewedCrushedFormGeneration` | `ReviewedOreMaterialFacts`、`SourceOreFollowonAdapter`、`SourceCrushedFormAdapter` | 非矿延续、研钵、粉碎、洗矿与输出证明 | 重复资格和逐材料常量删除,原生所有权检查保留 | +| `ReviewedCinnabarFacts`、`ReviewedOreFluidBindings`、`ReviewedOreGeneratedFluids`、`ReviewedCinnabarThermalRecipes` | `ReviewedOreMaterialFacts`、`MaterialFluidUnitFacts`、`SourceCinnabarFollowonAdapter`、`SourceGeneratedFluidAdapter`、`SourceDustThermalRecipes` | 朱砂后续路线、蒸汽裂解、洗矿、离心和 Ti/Fe 热回收 | 朱砂局部蜡集合移入蒸汽裂解 recipe 自身;流体身份与 recipe 发布分开 | +| `SourceRecyclingFacts` | `SourceRecyclingMaterialFacts` 的 `SOURCE_RECYCLING` process | 炉、粉碎、洗矿、离心、酸洗和热回收适配 | 数据归入材料目录;运行时只经 `MaterialFactKeys` 读取,Water/Lava 的仅目标上下文也随 process 发布 | +| `GenerifyingRules.TARGET_IDS` | `GenerifyingMaterialFacts` | `GenerifierRecipeFamily` | 目标由材料 process 提供;prefix 条件和工时仍留在 recipe 同名类 | +| `SourceExtrusionRules.DATA` | `SourceExtrusionMaterialFacts` | `SourceExtruderRecipes`、`MaterialPrefix`、`MaterialPrefixes` | 挤压能力、锻造目标和可锻性归入材料事实;数量计算与配方向 recipe 门面保留 | +| `SourceOreMacerationFacts`、`SourceOreWashingData`、`SourceOreCrushingFacts` | `SourceMacerationMaterialFacts`、`SourceWashingMaterialFacts`、`SourceOreCrushingMaterialFacts`、`OreHostFacts` | 研钵、洗矿、Crusher/Hammer、OilSand | 材料能力与宿主岩石事实分开;Hexorium 产物策略仍留 recipe | +| `SourceLensRoles.ROLES` | `SourceLensMaterialFacts` | `ElectronicsRecipes`、`LaserStoneRecipes` | 透镜颜色角色进入材料 process;原生物品解析留在 `SourceLensRecipeItems` | +| `OriginalMaterialFluidUnits`、`SourcePurifiedAcidData.Phase` 的绑定字段、`PurifiedCentrifugeMaterialFacts` 的重复流体字段 | `MaterialFluidUnitFacts` | 分解、酸洗、离心、热回收、洗矿、化学解析 | 流体身份、相态和单位只由 `MATERIAL_FLUID_UNIT` 提供;配方枚举保留材料选择与工艺配比,不再保存第二份原生字段/单位 | +| `PanelMaterialRegistration`、`TransportMaterialRegistration` | `PanelMaterialCompositions`、`TransportMaterialCompositions` | `MaterialItemCompositions`、`VanillaRecoveryRecipes` | 固定成分安装不再由 recipe 生产类承担 | +| `RegisteredWoodSurvivalRecipes.registerMaterials()`、`VanillaWoodProcessingRecipes.registerMaterials()`、`DiggableRecipes.registerMaterials()`、单物品与空胶囊写入 | `WoodMaterialCompositions`、`MaterialItemCompositions` | 木材、黏土、食物条、化合物和空胶囊回收 | 固定成分在配方发布前显式登记;配方类只发布配方 | +| `MaterialTooltips.appendForeign()` 的失效回收分支 | 04 有效成分快照 | 普通/高级 tooltip | 删除 `composition_nonmaterial`、`composition_descriptive` 及其语言键 | + +### 复核补正 + +- `MaterialFactKeys` 现在是事实值类型的唯一定义点:`Decision`、`Identity` 以及所有内建事实键只定义一次。配方适配器不再在 `ReviewedSourceMaterialFacts`、`SourceRecyclingMaterialFacts`、`SourceWashingMaterialFacts` 之间转换相同枚举。 +- 新增 Java 类已逐个反查:11 个 catalog fact provider 都由 `MaterialDefinitions` 的装配顺序引用,`MaterialFactKeys` 的 21 个内建键都有生产读取方,6 个 recipe 适配器、3 个固定成分安装器和 `SourceLensRoles` 门面均有真实消费者;没有只改包名或只转发一次的残留类。 +- 无消费者的弃用别名 `MaterialDataRules.REPLICATOR_POWER_PER_NUCLEON` 与 `WoodSpecies.zhName()` 已删除。`ItemComposition` 的 legacy 构造/访问器和 `ImportedMaterialData` 仍有明确源码兼容用途,按前置审查结论保留,不把它们当作新的材料事实权威。 +- Reviewed 炉/分级宝石事实表只在声明装配期按 ID+规范化名称投影为 process;生产运行时查询统一走 `MaterialFactKeys`,不再直接读取 `SourceRecyclingMaterialFacts.find()` 或静态流体绑定表。声明期辅助查找保持包内可见。 +- Reviewed 炉授权的源名含空格或连字符时按 `GTMaterial.sanitize` 规范化后与当前规范名校验;否则 `Lithium-6`、`Red Sand` 等 22 条源行会因显示名格式差异永久不命中。 +- `MaterialFluidUnitFacts` 同时覆盖通用流体、酸洗相态、蜂蜜/冰和离心相态;`MaterialFluidBinding`、酸洗和离心适配都从同一材料视图取得字段与比例。 +- `FluidCatalog` 的生成熔融物例外改由 `SOURCE_MOLTEN_FLUID` process 提供;Ti/Fe 的整粉热回收所有权改由 `SOURCE_GENERATED_FLUID` process 判定,不再在 recipe 中复制材料身份。 +- 蒸汽裂解的四个蜡反应物保留 recipe 局部集合,但恢复 ID+名称校验;朱砂副产物声明恢复带 ID 的身份并只挂在 Cinnabar 自身,适配器从这一个规范身份查询,避免同名、别名或相关副产物出现多份同级规则。 +- Ti/Fe 生成流体的材料密度与流体条目密度是两个不同事实:前者与材料密度比较,后者仍要求为 0。 ## 目标与边界 @@ -8,18 +39,80 @@ 本阶段不预先承诺删除 chain、minecartWheels 等具体内容。行为减少和纯内部清理分开验收;确需删除注册项时先准备兼容处理和 parity 记录。 +### material 与 recipe 的分界 + +沿用 [content 包职责](../../architecture/packages/content.md)与[总计划的分层约束](README.md#共同实施约束)。清理的单位是事实和职责;一个混合类可以拆开,不能仅根据 `Reviewed*`、`Source*` 或材料名称整类搬迁。 + +| 内容 | 权威位置与消费者 | +| --- | --- | +| 材料身份、物性、化学组成、粉碎/熔炼目标及比例、通用矿石副产物、形态规则、加工能力 | core `content.material.catalog` 的材料声明,必要时采用同目录的类型化辅助声明;通过既有材料查询提供给配方生成器 | +| 通用加工模板的机器、输入形态、工时、能耗、概率、选择器及输出槽约束 | core `content.recipe`;生成器读取材料事实,通用计算放 `engine.material`/`engine.recipe` | +| 某材料的独立化学反应或特殊机器路线,包括额外反应物、流体与独立产物配比 | `content.recipe` 的显式配方声明;原生配方装配和发布留 Minecraft `content.recipe` | +| 运行期物品/方块/流体存在性、外部覆盖、栈状态和输入证明 | Minecraft 层按材料、流体、配方的实际职责适配;不把 `ItemStack`、原生注册表或 loader 类型搬进 core | +| 原始上游事实、当前默认值指纹、有限审核范围 | 保留适用范围的依据与校验;经裁决的领域事实再归入材料或配方声明,不能把审核白名单直接当全局禁用规则 | + +**朱砂与铝土矿的具体处理:** + +- 朱砂的通用粉碎目标、倍率、副产物顺序等属于材料事实;例如 `OreMaterials` 中已有朱砂组成与 `Redstone → Sulfur → Glowstone → Selenium` 副产物声明。生成粉碎、洗矿等通用路线时读取这些事实,recipe 不再维护一份朱砂属性副本。机器的具体产率、工时和输入形态仍由配方模板决定,化学组成也不能直接替代矿石副产物。 +- 铝土矿的高压釜路线属于特殊配方。当前由共享 Minecraft `content.recipe.generated.GTChemRecipes.autoclaveAndAluminiumElectrolysisRows()` 显式声明 12 条配方,`autoclave(...)` 绑定铝土矿、NaOH/KOH 和蒸汽,输出对应铝酸盐、蒸馏水与概率副产物;`MachineRecipeBootstrap` 调用该配方族。**保留在 recipe,不迁入 `OreMaterials` 或通用分解声明。** 如需拆出纯配方表,声明放 core `content.recipe`,原生装配留游戏层,且单独核验现有声明的来源约束。 +- `AutoclaveRecipeRows`/`AutoclaveRecipes` 是另一条按材料可结晶能力生成的通用宝石生长路线,不是上述铝土矿化学配方的所有者。材料的“可结晶”能力与高压釜模板分工维护,不因共用机器而合并两族配方。 +- 同一材料可以同时具有通用处理与特殊配方;特殊路线是否替换某条通用路线必须有明确工艺依据和所有权,不能见到特殊配方就关闭该材料全部通用处理。08-D—E 从最终有效配方派生铝土矿的来源/用途与处理图,材料目录不再保存一份高压釜路径。 + +### 本轮已清理的 Reviewed/Source 清单 + +以下保留旧文件与旧职责用于追溯,已经完成消费者迁移和回归验证,旧表或旧类不再存在。当前权威实现见上方结果表和代码中的 `MaterialFactKeys`;“材料声明”包括有明确适用范围的加工/形态声明,不等于向 `GTMaterial` 增加字段。 + +| 模块与当前类 | 当前职责及主要消费者 | 07 的具体处理与退出条件 | +| --- | --- | --- | +| core `ReviewedOreSourceProfile` | `FURNACE`、`GRADED_GEM` 的有限 YES/NO/UNKNOWN 表;`OreSourcePolicy`、`SourceGemGradeResolver`、炉配方适配消费 | 将已确认的炉授权和分级宝石能力归入材料加工/形态声明;统一与 `SourceRecyclingFacts` 的重叠查询。所有调用改读同一权威后删除该表;未覆盖身份不能变成 NO | +| core `ReviewedMagneticMaterials` | 磁性正例名单;`OreSourcePolicy.magneticCandidates()` 间接消费 | 磁性分类归回材料声明;核对现有 `MAGNETIC` 与正例名单差异及全部属性消费者。替换 `名单 OR flag` 后删名单;磁选机器的候选筛选和概率仍留 recipe | +| core `ReviewedSiftingGemForms` | Ice 的三个高级宝石形态负例;`SourceGemGradeResolver` 消费 | 将形态事实归入材料形态规则,保留“配方产出不可选”与“旧物品身份仍注册”的区别。外部显式表示仍按现有优先级选择,不能顺手注销 Ice 的旧形态 | +| Minecraft `ReviewedCrushedFormGeneration` | 九种材料的 crushed 系列排除及原生绑定证明;`SourceOreInputForms`、`SourceOreOutputRows`、洗矿适配消费 | 纯材料/形态排除并入规范规则;原生物品所有权、成分和外部覆盖检查留薄适配。统一输入/输出查询后删重复名单;当前是 recipe 局部排除,扩大到注册规则须另列行为影响 | +| Minecraft `ReviewedOreInputProfile` | 非矿输入的有限 ORES 负例及附属形态退让;非矿粉碎与后续路线消费 | 材料的矿物处理资格归入材料声明,外部形态与兼容退让留游戏侧。消除按 ID 的第二张资格表;不能把“没有 ORES”扩张为禁止一切配方或外部形态 | +| Minecraft `ReviewedOreShredderFacts` | 十一种材料的质量、MORTAR/self-pulver 审核范围和物品绑定;`SourceOreFollowonRows`/矿处理 loader 消费 | 材料质量、研钵能力和粉碎目标改读材料规则;形态、成分、外部所有权证明留适配。通用 shredder/研钵模板继续在 recipe;移除逐材料重复常量后再合并该适配器 | +| Minecraft `ReviewedCinnabarFacts` | 朱砂及副产物身份/属性指纹、原生形态和常温状态证明;粉碎、后续处理、蒸汽裂解消费 | 材料事实读 `OreMaterials` 及相关材料声明;本地物品解析留适配,共用配方规则保留。删除仅为断言目录未漂移而重复写出的整组常量,改用目录校验和工艺准入;先处理外部覆盖与 UNKNOWN 退让,不能直接放开所有材料 | +| core `SourceWaxMaterials`/Minecraft `ReviewedCinnabarFacts.sourceWaxes()` | 四种蜡的名单经朱砂类转发给 `SharedMineralSteamCrackingRows` | 去掉蒸汽裂解对朱砂类的依赖。若该集合表示材料分类,用材料 tag/group;若只是此工艺支持的四个反应物,保留 recipe 的局部输入集合。裁决后只有一处成员定义,不为了搬包扩大其他蜡的工艺资格 | +| Minecraft `ReviewedOreFluidBindings`、core `ReviewedOreGeneratedFluids` | 汞/蜡的单位绑定与汞、Ti/Fe 的生成流体指纹;洗矿、离心、热配方和 `OreFluidBindingAdapter` 消费 | 材料相态/单位声明、流体内容定义、原生所有权检查分开:分别复用材料 process、流体目录和薄适配。合并与 05/06 的重复换算及绑定定义;同一流体的声明一致不代表已原生注册,也不能统一假定 144 或 1000 mB/U | +| Minecraft `ReviewedCinnabarThermalRecipes` → `SourceDustThermalRecipes` | `emitIfSupported()` 只走 Ti/Fe 整粉与分数粉 Smelter 路线;`OreProcessingRecipeLoader` 消费 | 已按真实职责更名;氧化物热回收特权未恢复。熔点、密度、熔炼目标及流体单位从材料事实读取,工时/分数粉模板和发布仍在 recipe | +| core `SourceRecyclingFacts` 与 `OreSourcePolicy` | 源版热处理事实、当前端口默认值和炉授权的有界适配 | 逐字段区分源版事实、现行材料事实和工艺策略,再与前述表去重。源版与现行定义冲突时先裁决并评估所有消费者;不能直接把 source flags 全局回写材料,不能仅为了删表去掉外部/变更元数据退让 | + +首轮之外的具体对象见 [recipe 包补充审计](07-recipe-package-audit.md):`GenerifyingRules` 与 `SourceExtrusionRules` 已拆成“材料事实 + recipe 模板”,其余材料表和固定物品成分写入已迁出。机器独有的酸洗反应物、概率、选择器及输出预算继续保留在 recipe。两份清单仍不代表全部配方已经完成 07-E 的注册项去留裁决。 + +当前可跟踪文件中仍未找到已删除审核类所称的 `reviewed-source-policy.json`、`nonore-input-source-profile.json`,也未找到 `RecyclablePrefixes`、`MaterialDataFacts` 注释所称的抽取脚本。已迁移数据按现状保留并进入目录校验;缺失资料仍列为依据缺口,不能假称现有构建可以再生成。 + ## 实施步骤 -### 1. 完成旧权威退出清单 +### 1. 建立字段级退出清单,先处理重复事实 -1. 对 `Materials`、`GT6Materials`、`ImportedMaterialData`、旧属性字段和生成表逐项标明消费者、是否只读转发、被哪个规范声明替代。 +1. 对上表按字段登记:当前声明、规范声明、读/写调用方、适用工艺、原生绑定、附属覆盖、替代查询、迁移后保留项、删除条件和验收样例。已经与目录重合的常量优先去重;目录尚不能表达的能力先设计类型化声明,不新增无作用域的 boolean 白名单。 +2. 明确 YES/NO/UNKNOWN 的原有语义。未审核、非内置所有者、外部形态和修改后的默认值可能属于 UNKNOWN,不能用普通 boolean 合并后当作 NO;合法不支持与缺绑定分别诊断。 +3. 先以朱砂通用粉碎作为迁移样例,贯通材料声明、通用模板、原生输入证明与最终发布;再迁磁性、炉授权和形态限制等多材料名单。每次只切换一个配方族的写入者,比较最终可查询行为,不能长期双写。 +4. 对铝土矿高压釜作保留对照:确认显式配方未被材料化,也未因通用矿物能力迁移而消失或重复生成。额外碱输入、蒸汽消耗、蒸馏水和概率产出属于配方本身的验收内容。 + +交付:字段级清单、材料事实迁移 diff、保留的特殊配方与运行期适配说明,以及旧/新路径的预期差异。纯搬迁不得悄悄改变工艺资格、产率和原生注册范围。 + +### 2. 清理兼容门面、旧写入与重复发布 + +1. 对 `Materials`、`GT6Materials`、`ImportedMaterialData`、旧属性字段和生成表逐项标明消费者、是否只读转发、被哪个规范声明替代。`Materials` 是当前可读符号入口,应保留;`GT6Materials`、`ImportedMaterialData` 与 `content.material.generated` 已有大量引用,不在本阶段按“旧类”整类删除。 2. 对已迁移字段和配方族搜索全部写入与调用,确认生产中只有一个决定位置;测试与兼容访问器不得继续暗中初始化旧表。 3. 删除零消费者的内部表、死方法和重复初始化;保留仍有公共消费者的兼容访问器,并写明废弃版本及迁移方式。 4. 验证最终生产路径不再出现无理由的 `continue`、`return null` 或 collision 丢弃来隐藏非法引用;合法“不支持此工艺”继续允许,但有明确分类。 +| 当前入口 | 本阶段必须核对的内容 | 保留/删除条件 | +| --- | --- | --- | +| `Materials`、`GT6Materials`、`ImportedMaterialData`、`content.material.generated` | 静态字段是否只引用规范目录对象、类加载顺序、哨兵与别名、生成区的来源约束 | 保留有效符号与公开兼容;仅迁移确有必要的局部调用,不全仓改名。不得恢复各自安装或后置修改材料事实 | +| `MaterialForms`、`MaterialProcessingTargets`、`MaterialWorkability` | 区分规范目录查询门面与独立常量;检查老工艺是否仍读另一份默认规则 | 当前只读门面可保留;删的是重复事实或已经迁移且无消费者的方法。公开签名按 API 兼容边界处理 | +| `MaterialGroups`、旧 re-registration 入口 | 组成员是否来自规范组视图,匹配是否误改真实材料身份 | 有兼容消费者则保留转发;生产侧不再维护第二份成员或通过重注册合并材料 | +| `RecyclablePrefixes`、`MaterialDataFacts`、`RecoveryFormCatalog` | 回收形态、可扫描形态和实际注册规则之间的重叠与差异 | 同一语义只留一份声明;可扫描不等于可回收,不按集合相似就合并。生成来源不明时先记录缺口 | +| `GTMaterial` 的兼容属性/target、`MaterialInfoRegistry` 发布快照 | 每个已迁移字段的写入时点与单向派生;明确允许的附属回调 | 兼容读不再反写规范声明;不要删除仍承载运行时查询的字段,也不要重新引入 flag/typed rule 往返同步 | +| `bulkRecoveryAllowed` 兼容入口与消费者 | 当前构造已归一为 true,tooltip 和 producer 是否还把它当独立加工权威 | 移除内部失效分支和误导展示;旧参数/访问器如需保留只作兼容,不重新引入物品级回收否决 | +| `OreProcessingRecipeLoader`、Shredder/热回收/分解生产端 | 对照 `RecoveryRecipePublisher`、`ThermalRecoveryOwnership`、`DecompositionRecipeLoader` 的族所有权与重载撤销 | 通用、源版有界、显式特殊、动态/unit 各行只有一个有效发布者;迁出特殊分支时同步退出旧 owner,防止漏行与双发 | + +保留 04—06 已收敛的行为:使用 `ItemRecoveryPlanner` 和类型化分解规则;保留 `MaterialPublication` 的成功代发布、失败代成分与配方整体恢复、标签撤销和单行冲突隔离。它们承担实际生命周期职责,不属于本阶段应删除的“重构脚手架”。 + 交付:逐项清理表和实际删除 diff,能够追溯到前面各阶段的替代能力。 -### 2. 审计材料与形态的来源和终端 +### 3. 审计材料与形态的来源和终端 1. 从实际注册形态与配方查询结果建立“来源 → 中间转换 → 消费终端”关系,不仅靠 Java 字符串搜索。 2. 消费端包含机器部件、工具、配方输入、存储/建筑、附属请求和有意展示用途;纯“转成自己再回收”的闭环不算充分消费理由。 @@ -27,14 +120,30 @@ 4. 对无来源或无终端项列出选择:保留并说明用途、停止生成相应配方、停止新注册并保留旧身份读取、删除。注册项删除需额外考虑旧世界中的物品/方块与流体。 5. 仅在证据和兼容方案完整后实施;材料、物品、流体的有意移除分别更新现有 parity 台账。未完成裁决的候选可以明确保留,但不能宣称审计已全部完成。 -### 3. 整理 tooltip 与语言 +每项至少记录:材料与形态身份、实际注册对象、获得途径、有效配方输入/输出、终端用途、公开附属契约、存档影响、去留决定和证据。没有 08-D 索引时可先对候选做定向注册/查询审计,不能把文本命中数当最终可达性,也不能声称已经覆盖全部处理图。 + +### 07-E 定向审计记录 + +2026-11-13 使用最终双平台 GameTest 生成的 `reload-items.tsv` 与源码配方入口做了首轮定向审计。注册数是实际发布物品数,不是 Java 字符串命中数;两端完全相同,因此没有观察到版本专属缺口。 + +| 形态 | 实际注册物品数(Forge/NeoForge) | 已确认获得途径 | 已确认消费终端 | 本轮决定 | +| --- | --- | --- | --- | --- | +| `chain` | 407/407 | `AnvilRecipeDefinitions`:2 ring → 1 chain | `SourceThermalInputRules` 热回收输入、`SourceExtruderRecipes` 特殊输入矩阵、`PolarizerMaterialRecipes`、材料形态组界面 | 保留;有来源和终端,不删除身份 | +| `minecartWheels` | 207/207 | `HandMaterialCraftingRecipes`:2 ring + stick + hammer + wrench → 1 set | 热回收输入、特殊挤压输入、偏振器输入、材料形态组界面 | 保留;不从名称推断无消费者 | +| `billet` | 258/258 | 坩埚/模具、材料形态转换及显式配方 | 工具、研钵、挤压、偏振器和多项机器配方输入 | 保留;继续作为具体形态使用 | +| `gearGt`/`gearGtSmall` | 407/407 | 挤压、木材配方、坩埚模具及材料形态转换 | 旋转动力设备、齿轮箱、工作站建造、纳米制造和配方输入 | 保留;不是可批量注销的兼容形态 | +| `itemCasing` | 407/407 | 挤压与材料形态转换 | Welder、石墨烯路线、电源单元和机器建造输入 | 保留;源版 `casingSmall` 别名仍有实际消费者 | + +本次没有找到足以删除上述注册项的无来源、无终端证据,因此没有改变物品 ID、NBT、配方身份或存档兼容性。完整来源/用途边仍由 08-D—E 的最终处理图验收覆盖。 -1. 以 04 的有效成分与加工判定为数据源,明确展示组成、批量授权与当前状态;删除“完全损坏工具属于 technical/entity item”这样的错误分类。 -2. 优先复用一个状态展示入口;决定 `composition_nonmaterial` 是否移除、`composition_descriptive` 是否合并后,清理对应调用与语言键。 +### 4. 整理 tooltip 与语言 + +1. 以 04 的有效成分与加工判定为数据源,明确展示组成、具体工艺准入与当前状态;删除“完全损坏工具属于 technical/entity item”这样的错误分类。物品含哪些材料、能否执行当前工艺、损坏后剩余多少必须分别判断。 +2. 从共享 `MaterialTooltips.appendForeign()`、两节点 tooltip 接线和对应语言资源逐项核对。`composition_nonmaterial` 不能只凭主材料 ID 判定所有拒绝原因;`composition_descriptive` 当前依赖已归一的 `bulkRecoveryAllowed()`,核验可达性后清理失效分支与语言键。复用现有状态展示入口,不另造第三套授权。 3. `zh_cn` 提供实际中文,普通/高级 tooltip 的门槛两平台一致;不把数据源、内部生产端、诊断术语塞进玩家常规流程。 4. 材料键与 lang 覆盖检查只处理本域,不批量改写或重新排序整份大型语言资源。 -### 4. 验收初始化、查询、运行与重载 +### 5. 验收初始化、查询、运行与重载 按下表执行,使用 01 的归一化输出对照;每个差异都有对应变更、测试和规则依据。 @@ -50,7 +159,18 @@ 两个版本共有的材料信息与规则应相同;版本独有物品和原生绑定差异单独说明。配方展示抽样不能代替最终查询与机器执行;服务端 GameTest 也不能代替客户端视觉检查。 -### 5. 核对发行包与维护入口 +清理专项至少增加或复用以下断言,按真实测试源码集接入;现有用例不是所有新迁移项已经有覆盖的证明。 + +| 迁移风险 | 必须观察的结果 | 优先复用入口 | +| --- | --- | --- | +| 删表后材料事实漂移 | 材料身份/别名不变;修改一个规范声明即可改变相应通用生成结果;无需同步修改审核名单 | core `MaterialCatalogTest`、`MaterialFormCatalogTest`、`MaterialReferenceAudit` | +| 有限名单被误当全局否决 | 原有正例、负例、未覆盖材料、附属材料、变更元数据和外部显式表示分别验证 | core 工艺规则测试与共享 `MaterialBaselineTests`,补足本次实际迁移范围 | +| 朱砂/Ti/Fe 旧 owner 回归 | 朱砂无专用热回收绕过;Ti/Fe 分数粉不漏行或双发,输入证明与损坏/容器状态仍生效 | `RecoveryRecipePublisherTests`、材料领域 GameTest 与最终 `RecipeMap` 查询 | +| 特殊配方被材料化或挤掉 | 铝土矿高压釜的 NaOH/KOH 两支、等量粉末形态、额外物料与概率输出保持;通用结晶路线仍独立 | 化学配方解析结果、最终高压釜查询;迁移触及该族时补对应执行用例 | +| 清理影响成分和回收 | 铜块 9U、72U 输出、复合工具头、损坏工具、空/满容器及已凿模具的量和拒绝行为不回归 | `MaterialBaselineTests` 与 core `ItemCompositionResolverTest` | +| 重载只撤销了一半状态 | 连续两次真实重载无旧行;移除 tag 后表示与派生行退出;失败代保留上一成功成分和配方 | `MaterialBaselineTests` 的 tag generation、失败恢复与真实资源重载用例 | + +### 6. 核对发行包与维护入口 1. 使用 Forge `distributionJar` 和 NeoForge `jar` 的实际产物验收,不把 SDK 或 Forge 中间 JAR 当最终模组。 2. 检查两种发行包中无 GameTest 类、模板、案例 TSV、原始 dump、导入脚本或任务日志;运行资源与 API 类按既有打包规则各出现正确份数。 @@ -61,6 +181,27 @@ 检查集:D、F、J、A(涉及公开 API 时)、C、G、B、M。检查命令及先后要求见[总计划](README.md#检查的使用方式)和相应检查文档。 +### 本轮验证记录(2026-11-13) + +执行且通过: + +- D:`python3 tools/validation/route.py check`,路由闭合、检查文档和相对链接通过。 +- J:`./gradlew :core:test`,core 全套 174 tests 通过;新增事实投影计数覆盖全部迁移类别。 +- C:`./gradlew compileBothPlatforms`,Forge 与 NeoForge 节点均编译通过。 +- F(改动范围):`-PspotlessRatchet=HEAD` 的 core 与 Minecraft 格式检查通过;`git diff --check` 与注释引用检查通过。 +- G:最终代码在全新目录 `work/material-system-refactor/07-review2-forge-20261113` 与 `07-review2-neo-20261113` 分别运行 Forge/NeoForge `runGameTestServer`,结果为 94/94 与 99/99;两节点均执行 `material_baseline`、`material_baseline_reload` 和配方发布批次。 +- B(首轮):两个平台实际发行 JAR 构建成功;最新 JAR 中未发现已删除旧类、GameTest 类、案例 TSV 或测试模板。 + +执行但失败或阻塞: + +- 不带 ratchet 的 `:core:spotlessJavaCheck` 仍会报告 HEAD 既有的 `OriginalMachineMaterialData`、`RecoveryFormCatalog` 等格式差异;本次没有为通过检查而批量改写这些无关文件。按本次改动路径的 ratchet 检查已通过。 + +尚未执行: + +- 07-E 的完整材料/形态清单裁决;`chain`、`minecartWheels`、`billet`、两种齿轮和 `itemCasing` 的定向审计已完成。 +- 07-F / 08-D—E 的有效来源/用途索引、有界处理图和远程客户端验收。 +- 客户端 tooltip、JEI/EMI 展示及机器实际交互的人工验收。 + - 新增/修改普通材料只改一处领域声明;组件、燃料、形态和分解不再跨表重复维护同一字段。 - 同一物品只有一份有效成分解释,冲突可定位,加载顺序不再决定结果。 - 回收/分解同一配方族只有一个发布者;不支持、缺绑定、量化损耗与真正冲突可区分。 @@ -71,6 +212,17 @@ ## 拆分与兼容处理 -建议先删已替代内部代码,再交付 tooltip,最后逐项处理有产品影响的材料/形态去留。这样任何注册项删除都可单独审阅和撤回。 +建议按下列小变更实施,每项独立保留可编译、可验证的最终生产路径: + +| 切片 | 内容 | 前置与完成条件 | +| --- | --- | --- | +| 07-A | 字段级清单、朱砂通用事实样例与蜡集合解耦 | 02—06;材料事实只维护一处,铝土矿特殊配方保留,外部/未知范围不被误禁用 | +| 07-B | 磁性、炉授权、形态与流体绑定名单收敛;热类名称/所有权整理 | 按 07-A 的边界逐族迁移;旧表退出、原生证明保留、最终可查询结果可解释 | +| 07-C | 兼容门面、死分支、旧写入和重复发布清理 | 对应消费者已迁移;公开兼容和成功/失败代语义不回归 | +| 07-D | tooltip 与语言清理 | 使用现有有效成分与状态;两个客户端确认普通/高级展示 | +| 07-E | 材料/形态去留与必要迁移 | 定向审计可先开始;删注册项必须单独提供可达性、存档和 parity 依据 | +| 07-F | 全链路、处理图、远程客户端与发行包总验收 | 08-D—E 完成;按本页矩阵补齐,分别记录两个平台与未覆盖场景 | + +07-A—D 无需等待 08-D—E;07-E 的定向审计也可以先开展。08 的有效来源与共享图仍是 07-F 的交付前置,不能用内部清理完成替代。每个切片的检查按实际改动路径与总计划检查集执行,不把纯文档清单的检查结果沿用为实施代码的验收结果。 仅删除内部代码时,可回退对应小变更并恢复旧适配器;一旦删除了世界中可持久化的身份,恢复源码不等于恢复已保存的数据,必须在实施删除前选择并验证迁移/保留读取策略。测试世界使用隔离副本,不对真实服务器执行本计划。 diff --git a/docs/development/material-system-refactor/07-recipe-package-audit.md b/docs/development/material-system-refactor/07-recipe-package-audit.md new file mode 100644 index 000000000..a393ae1e2 --- /dev/null +++ b/docs/development/material-system-refactor/07-recipe-package-audit.md @@ -0,0 +1,83 @@ +# 07 补充:recipe 包中的材料事实审计 + +本页给出 [07 清理计划](07-cleanup-and-acceptance.md)首轮 Reviewed 清单之外的具体对象。源码核对起点为 master `f096a79ee`(2026-11-12),2026-11-13 已完成下表中的材料事实与固定成分迁移;本页保留原检查和边界,用于追溯新入口和仍需 07-E/07-F 验证的范围。 + +本轮对 core 与共享 Minecraft 的 `content.recipe` 共 258 个 Java 文件、两版本节点的同包共 14 个 Java 文件做文件清点和模式搜索,对疑似项阅读声明、方法和调用方;另外扫描两层 `engine.recipe` 共 44 个 Java 文件的同类特征。检索覆盖材料 ID/名称名单、属性与 target 表、相态单位、成分写入和默认值指纹。该范围不等于对所有配方逐条核验,也不包含 JSON、脚本及第三方模组的完整运行期审计。 + +迁移后逐表复核确认:挤压源表 734 行的 payload 完全一致;回收 seed、研钵正负集合、洗矿行和透镜角色没有在复制时改值;新增 process 投影后,炉授权 198 条与分级宝石 2 条全部命中,其中 22 条源名需经 `GTMaterial.sanitize` 才能对应 `Lithium6`、`RedSand` 等规范名。4 个 Hexorium 透镜角色因当前没有该可选材料而保持未投影,不会被当成普通材料身份。 + +职责判断沿用 [material 与 recipe 的分界](07-cleanup-and-acceptance.md#material-与-recipe-的分界)。以下建议不增加已支持的公共 API;目录缺少表达能力时,在实施切片中设计声明并验证消费者。 + +## 一、需要归入材料声明的新增对象 + +| 当前对象与证据 | 材料事实与当前消费者 | 具体清理方式 | +| --- | --- | --- | +| [GenerifyingMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java) 的 `TARGET_IDS` | 143 对材料 source/target ID;Minecraft `GenerifierRecipeFamily.target()` 据此决定转换目标 | 已迁入 `GENERIFICATION_TARGET` process;配方的适用 prefix、工时、动态查询与显式配方优先级仍在 [GenerifyingRules](../../../core/src/main/java/gregtech/content/recipe/GenerifyingRules.java) | +| [SourceExtrusionMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java) 的 `DATA`/`Profile` | 734 行材料挤压能力、简单挤压、可锻性和 forging target/amount;`SourceExtruderRecipes`、`MaterialPrefix`、`MaterialPrefixes` 消费 | 已迁入 `SOURCE_EXTRUSION` process;[SourceExtrusionRules](../../../core/src/main/java/gregtech/content/recipe/SourceExtrusionRules.java) 只保留数量的取整、工时和原生查询门面 | +| [SourceMacerationMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java) 的 `MORTAR_YES`/`MORTAR_NO` | 两套研钵能力 ID 集合;`SourceOreMacerationAdapter` 使用 | 已迁入 `SOURCE_MACERATION`;适配器仍保留 UNKNOWN、外部形态和原生输入证明 | +| [SourceWashingMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java) 的 `Binding.tags` | 按材料声明 MERCURY/PERSULFATE/FIRESTONE 三种通用洗矿能力;`SharedOreWashingRows` 查询 | 已迁入 `SOURCE_WASHING`;具体反应物、用量、产出与概率留 recipe | +| [SourceOreCrushingMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java) 与 [OreHostFacts](../../../core/src/main/java/gregtech/content/block/stone/OreHostFacts.java) | 特殊粉碎/Hexorium 分类与宿主岩石、脉石、破碎配对 | 材料能力进入 `SOURCE_ORE_CRUSHING`,宿主关系进入石材内容声明;适配器保留原生所有权检查 | +| [SourceLensMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java) 的 `ROLES` | 57 条材料透镜颜色角色;`ElectronicsRecipes`、`LaserStoneRecipes` 消费 | 已迁入 `SOURCE_LENS_ROLE`;`SourceLensRecipeItems` 只解析已注册原生物品 | +| Minecraft [BathMaterialRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java) 的 `NOT_ANY_WOOD_DUST` 与 [TreatedWoodRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/TreatedWoodRecipes.java) 的 `NOT_UNTREATED_WOOD` | 两处分别用 WOOD 属性加 `PetrifiedWood` 排除来近似 `AnyWood`/`AnyUntreatedWood`;已有 `MaterialGroups.Wood`/`WoodUntreated` 与规范组目录 | 核对全部现有成员与附属扩展后改读对应组;纸浆配方额外接受 Bark/Paper、处理木材的转换输出仍留 recipe。组替换必须比较行为差异,不能只把条件机械改写后认定等价 | + +其中两个大型目标表现已拆为材料事实和 recipe 模板。首轮 Reviewed 类清单及迁移结果仍见 [07 主计划](07-cleanup-and-acceptance.md#本轮已清理的-reviewedsource-清单)。 + +## 二、混合类中需要拆出的事实和绑定 + +这些类承担有效的配方职责,应按字段/方法拆分,不能整类迁到 material。 + +| 当前对象 | 应收敛的部分 | 仍应保留的职责与删除条件 | +| --- | --- | --- | +| Minecraft [SharedPurifiedCentrifugeRows](../../../minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedCentrifugeRows.java) | 六条相态记录与七条显式无默认相态记录 | 已迁入 `PurifiedCentrifugeMaterialFacts` 的两个材料 process;原生注册字段/所有权、离心槽位、概率、重载发布和兼容分支仍留 recipe | +| [MaterialFluidUnitFacts](../../../core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java) 与 core `engine.recipe.chem.MaterialFluidBinding` | 材料相态/单位/流体身份绑定,后者从材料视图和流体目录建立索引 | 绑定事实进入 `MATERIAL_FLUID_UNIT` process;`UnitConversion` 只保留换算机制 | +| Minecraft [SourceThermalNativeAdapter](../../../minecraft/src/main/java/gregtech/content/recipe/SourceThermalNativeAdapter.java) 的 `nativeBinding()` | Glass、Blaze、Plastic、Ender、Redstone、Lava、CFoam、蜡及熔盐等原生字段/ID | 精确字段和单位从 `MaterialFluidUnitFacts` 查询;特殊原生持有检查与配方适配仍在游戏侧 | +| core [SourcePurifiedAcidData](../../../core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java) | 酸洗 `Phase` 的材料选择;`MANGANESE_DEFAULTS` 中重复的材料副产物快照 | `Phase` 的原生字段、相态和 1000 mB/U 已归入 `MaterialFluidUnitFacts`,recipe 只保留材料选择器。酸洗 `FAMILIES` 的共同反应物、配比和尾产物继续保留。`manganeseDefaults()`/`matchesManganeseDefault()` 未找到外部调用,但 `reviewedIdentity()` 仍使用默认表确认身份,不能把整表当死测试数据删除;先拆出仍生效的身份范围,再决定默认快照是否进入测试 | +| core [SourceRollingWireRules](../../../core/src/main/java/gregtech/content/recipe/SourceRollingWireRules.java) 的 `physicalWire()` | Netherite/Naquadah 的额外线材族准入 | 已迁入 `SOURCE_ADDITIONAL_WIRE_FAMILY`;轧制/拉丝模板、工时与实际线材族注册仍留 recipe | +| Minecraft [MaterialFormConversionRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/MaterialFormConversionRecipes.java) 的 `compressor()` | Ice 的 `dust → plateGem` 排除 | 已迁入 `COMPRESSOR_DUST_TO_GEM_PLATE`,与筛矿高级宝石限制保持独立;装箱、拆箱、压缩模板仍留 recipe | +| core `OreHostFacts` 的 `HOSTS`/`BROKEN_SOURCE_PAIRS` | 宿主岩石、矿石 prefix、4U 脉石和破碎矿块表示关系;`SourceOilSandRules` 也消费 | 已位于石材内容声明;原生 host ID 解析和机器对脉石的产出策略仍留 recipe;不写入矿物化学组成 | + +`SourceLatheRules`、`SourceCutterRules`、`SourceFormingRules` 和 `SourceRollingWireRules` 已共同读取包外 `content.material.SourceLatheMaterialProfiles`。这部分结构可复用:recipe 保留工艺模板。后续还要审计该 material helper 与规范 catalog、`MaterialWorkability` 的事实重叠,不能仅因为已经移出 recipe 就宣称材料事实已只维护一处。 + +## 三、应归入游戏侧物品成分接入的对象 + +这是“物品包含什么材料”的事实,目标是 Minecraft `content.material`/现有物品领域声明;不是把这些物品配比写进 core 材料化学组成。 + +| 当前对象 | 证据与迁移范围 | 必须保留的边界 | +| --- | --- | --- | +| [PanelMaterialCompositions](../../../minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java) | 提交基础/彩色/增强混凝土和面板成分,维护回收物品集合 | 已归 `content.material`;`RECIPE_REVERSE` 来源、声明 ID、优先级和回收消费者保持 | +| [TransportMaterialCompositions](../../../minecraft/src/main/java/gregtech/content/material/TransportMaterialCompositions.java) | 提交管道、储罐、物流部件成分及 prefix 绑定 | 已归 `content.material`;规格仍由 transport 领域维护 | +| `DiggableRecipes.registerMaterials()`、`RegisteredWoodSurvivalRecipes.registerMaterials()`、`VanillaWoodProcessingRecipes.registerMaterials()` | 黏土块/球/泥炭、树种、树皮、原木、木板、楼梯和台阶成分 | 已迁到 `MaterialItemCompositions` 与 `WoodMaterialCompositions`;实际加工/合成配方仍留原类,材料量、树皮复合成分和 JSON 显式覆盖来源不变 | +| [SingleItemSourceRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/SingleItemSourceRecipes.java) 中 `register()`/`compounds()`/`meat()` 等成分写入 | dry bark、compound、肉条等固定成分 | 已提前交给 `MaterialItemCompositions`;原版炉、坩埚展示和食物加工路线保留 | +| [CapsuleCellRecipes.registerRecycling()](../../../minecraft/src/main/java/gregtech/content/recipe/CapsuleCellRecipes.java) | 空胶囊 1/9U 成分 | 已在 `MaterialItemCompositions` 安装;回收端只读取有效成分并发布配方,空/满容器状态和共享静态工时保持 | + +迁移后,`MaterialItemCompositions` 不应再为安装固定成分而调用 recipe 生产类;配方发布也不应偷偷创建固定材料事实。接线要在显式成分关闭前完成,并保留当前来源优先级、覆盖关系和注册后才访问原生物品的时点。 + +## 四、经区分应继续留在 recipe 的对象 + +| 对象 | 保留原因与边界 | +| --- | --- | +| `GTChemRecipes` 的铝土矿高压釜、`SourcePurifiedAcidData.FAMILIES`/`SourcePurifiedAcidRules` | 明确反应物、流体、比例和产物的特殊化学工艺;共用材料不等于材料属性。仅抽离重复身份/单位绑定 | +| `SourceAlloyRecipes`、`SourceOilSandRules`、`SourceOreSiftingRules.specialRows()`、`SourceOreMagneticRules.blockRows()` | 显式合金、油砂事件、特殊筛矿和固定磁选路线;输入/输出/概率就是配方内容,不因含材料名单而整体材料化 | +| `TechnologyIngredients.PISTON_METALS`、`craftingRedstone()` | 工艺局部的原料替代集合和形态选择。可以声明为配方专用组,不能由此推导全局“可做所有机械零件”能力,也不能合并不同语义的 `Any*` 组 | +| `PolarizerMaterialRecipes` 的材料对、`BathMaterialRecipes` 的材料转化与流体、`UtilityProcessingRecipes` 的木材提取产率 | 当前表达具体工艺的输入/输出或用量;应保留为配方关系。若以后确认为跨消费者的通用 target,可另行收敛声明,不能仅凭材料名称硬编码认定应全局化 | +| `SourceCentrifugeOptionalBindings` 及可选物品输出 | 版本、提供模组和实际注册项决定的外部集成适配;不是材料身份或加工能力。保留缺失/未知区别及未装模组时的类加载隔离 | +| `MaterialRecoveryRules`、`SourceThermalInputRules`、`SourceThermalRecyclingRules`、各 `*RecipeRows` 的通用机器模板 | 描述配方族、工时、形态数量和槽位策略。只把重复材料事实移出;纯换算机制是否归 engine 按既有分层另行整理,不将整套生成器搬进 material | + +## 五、实施顺序与验收补充 + +1. 通用目标、挤压、透镜、研钵、洗矿、相态单位和固定成分写入已完成迁移。 +2. `MaterialWorkability`、`SourceLatheMaterialProfiles`、`SourcePurifiedAcidData` 等混合对象仍需在 07-E 定向审计中逐字段裁决去留;没有足够来源时保留并记录缺口。 +3. 对局部工艺例外继续按“材料加工声明”或“显式配方声明”裁决;不能用全局 flag 扩大效果。 + +源码中的数量注释也需要核实:`SourceOreMacerationFacts` 注释写 589 个正例/997 个身份,实际集合为 588 个正例加 408 个负例;`SourceOreWashingData` 注释中的 59/159 等口径与实际 142 个身份行、54 个含正例 tag 的身份不一致。酸洗相态迁移时确认实际枚举为 17 个,旧注释的 18 已修正。 + +实施时在 [07 的清理专项断言](07-cleanup-and-acceptance.md#5-验收初始化查询运行与重载)之外补以下范围: + +- 简化目标:动态查询与枚举得到同一目标,显式配方仍优先,未知/附属身份不误套 ID 表。 +- 挤压:锻造目标和比例、简单/热挤压工时、依赖 smithable 的形态注册同时验证。 +- 透镜:颜色角色与材料显示颜色独立,激光石材和电子配方使用同一角色声明。 +- 木材组:比较两组完整成员、PetrifiedWood、处理/抛光木材以及附属成员;纸浆特许 Bark/Paper 不丢失。 +- 物品成分:不生成任何加工配方时固定成分仍可查;重新发布配方不追加固定声明;树皮、楼梯、面板、运输容器和空/满胶囊的数量与状态不回归。 +- 相态与单位:核对汞 144 mB/U、显式熔盐、气体/普通液体和 source NONE;连续重载、外部覆盖与缺绑定保持可区分。 + +本页没有裁决任何注册项删除或 GT6 行为变化。实际发生行为变更时,仍按主计划提供来源、兼容影响、必要的 parity 记录和双平台验证结果。 diff --git a/docs/development/material-system-refactor/08-material-data-api.md b/docs/development/material-system-refactor/08-material-data-api.md index 900a8ea85..5f520454f 100644 --- a/docs/development/material-system-refactor/08-material-data-api.md +++ b/docs/development/material-system-refactor/08-material-data-api.md @@ -1,8 +1,8 @@ # 08:材料标签、形态、来源与处理图 API -本计划将独立的材料相关系统通过查询与投影纳入材料 API,保持主材料对象简洁。状态:部分实施;A(定义视图与 metadata)已完成,B 的 tag/替代组定义与查询已随 02 完成,常见形态的生产消费者迁移随 03 完成;C 的定义期规则、实际 item/block/fluid 绑定和 tag 桥接声明已随 03 完成,外部 tag 导入候选已随 04 接入统一裁决;D—E 待实施。接口与语义权威见[设计提议 0001](../../decisions/0001-material-data-api.md),本页只维护实施顺序与独立验收。 +本计划将独立的材料相关系统通过查询与投影纳入材料 API,保持主材料对象简洁。状态:部分实施;A(定义视图与 metadata)已完成,B 的 tag/替代组定义与查询已随 02 完成,常见形态的生产消费者迁移随 03 完成;C 的定义期规则、实际 item/block/fluid 绑定和 tag 桥接声明已随 03 完成,外部 tag 导入候选已随 04 接入统一裁决;07 的内部材料事实清理已使用这些查询入口。D—E 待实施。接口与语义权威见[设计提议 0001](../../decisions/0001-material-data-api.md),本页只维护实施顺序与独立验收。 -08 是贯穿原计划的集成工作,不是在 07 后重做材料系统。A 在 01 的调查基础上、02 的接口定稿前完成;B 并入 02/03,C 并入 03/04,D 随 05/06 的有效结果发布,E 在 D 后实施;最终由 07 联合验收。 +08 是贯穿原计划的集成工作,不是在 07 后重做材料系统。A 在 01 的调查基础上、02 的接口定稿前完成;B 并入 02/03,C 并入 03/04,D 随 05/06 的有效结果发布,E 在 D 后实施;最终由 07 联合验收。07 的内部事实与兼容入口清理可先进行,D—E 是其最终来源/处理图验收的前置,详见 [07 拆分](07-cleanup-and-acceptance.md#拆分与兼容处理)。 ## 当前入口与前置事实 diff --git a/docs/development/material-system-refactor/README.md b/docs/development/material-system-refactor/README.md index b7062e120..53efba0f1 100644 --- a/docs/development/material-system-refactor/README.md +++ b/docs/development/material-system-refactor/README.md @@ -1,6 +1,10 @@ # 材料系统重构实施计划 -本组文档用于把 [issue #351](https://github.com/GregTech6CE/GregTech6/issues/351) 拆成可实施、可逐份验收的工作。01 已建立可执行基线,验收范围与已知差异见[基线报告](../../integration/material-baseline.md);02 已完成注册、目录和 08-A/B 的定义与查询切片;03 已完成属性收敛、燃料闭环、08-C 实际形态绑定和资源 tag 桥接声明;04 已完成来源化候选裁决、有效成分快照、状态查询和双平台共享安装;05 已完成成分驱动的回收计划、数量表达、主要生产端迁移和重载诊断;06 已完成类型化分解声明、计划器和双平台执行验收。08-D—E 与 07 仍待实施。尚未实施阶段的目标接口、测试和数据集不代表当前已经存在。阅读顺序为本页、对应分计划、该计划引用的现有架构与检查文档。 +本组文档用于把 [issue #351](https://github.com/GregTech6CE/GregTech6/issues/351) 拆成可实施、可逐份验收的工作。01 已建立可执行基线,验收范围与已知差异见[基线报告](../../integration/material-baseline.md);02 已完成注册、目录和 08-A/B 的定义与查询切片;03 已完成属性收敛、燃料闭环、08-C 实际形态绑定和资源 tag 桥接声明;04 已完成来源化候选裁决、有效成分快照、状态查询和双平台共享安装;05 已完成成分驱动的回收计划、数量表达、主要生产端迁移和重载诊断;06 已完成类型化分解声明、计划器和双平台执行验收。07 的内部材料事实、配方/原生职责拆分、成品成分安装、tooltip 失效分支和首轮清理已完成;08-D—E、07-E 注册项去留裁决与 07-F 最终验收仍待实施。尚未实施阶段的目标接口、测试和数据集不代表当前已经存在。阅读顺序为本页、对应分计划、该计划引用的现有架构与检查文档。 + +01—06 当前均已合入 master,本次核对点为 PR #374 合并后的 `f096a79ee`。07 的首轮内部清理已实施;[07 清单](07-cleanup-and-acceptance.md)按当前源码列出 Reviewed/Source 类中的材料事实、通用配方模板、特殊配方与原生适配的处理方式,并以朱砂和铝土矿高压釜区分职责。07 最终整体验收仍以前置 08-D—E 完成为条件。 + +[recipe 包补充审计](07-recipe-package-audit.md)记录通用材料转换目标、挤压/研钵/洗矿能力、透镜角色、相态绑定和固定物品成分登记的迁移结果,并区分保留的特殊配方与原生适配。 已完成的 01–03 简明范围、权威入口和兼容边界见[实施摘要](01-03-implementation-summary.md)。 @@ -34,10 +38,10 @@ | 04 | [统一物品成分解析](04-item-composition.md) | 01;接入材料身份部分需 02 | 显式优先级、冲突检测、查询与遍历一致的成分快照 | | 05 | [统一回收计算与生成](05-recovery.md) | 02、03、04 | 共用输入判定、数量计算、回收生成和重载生命周期 | | 06 | [统一材料分解](06-decomposition.md) | 02、03、04;复用 05 的发布与诊断约定 | 权限、配比、相态和单位共同驱动的离心/电解分解 | -| 07 | [清理与双平台整体验收](07-cleanup-and-acceptance.md) | 02—06、08 的接入切片 | 旧数据和重复入口退出、消费端审计、全链路验收 | +| 07 | [清理与双平台整体验收](07-cleanup-and-acceptance.md) | 内部清理需 02—06;最终验收需 08 的接入切片 | 材料事实归位、特殊配方边界、旧数据和重复入口退出、消费端审计、全链路验收 | | 08 | [材料标签、形态、来源与处理图 API](08-material-data-api.md) | A—E 分别并入 02—06,最后在 07 前整体验收 | 薄视图、领域查询、资源 tag 桥接、有效来源索引与共享处理图 | -01—06 按前置项实施,04 的纯候选裁决规则可在 01 后先做。08 贯穿这些阶段:A 在 02 的接口定稿前完成,B/C 随 02—04,D 随 05/06,E 在 D 后;07 最后整体验收。每个分计划可以拆成多个小变更,每个变更都应能编译并通过对应检查;不要求把一整份计划塞进一次大改动。“独立验证”指在前置项成立后,本阶段有自己的输入、断言和完成条件,无需等待 07 才确认正确性。 +01—06 按前置项实施,04 的纯候选裁决规则可在 01 后先做。08 贯穿这些阶段:A 在 02 的接口定稿前完成,B/C 随 02—04,D 随 05/06,E 在 D 后;07 的内部清理已实施,最终整体验收仍在 08-D—E 后完成。每个分计划可以拆成多个小变更,每个变更都应能编译并通过对应检查;不要求把一整份计划塞进一次大改动。“独立验证”指在前置项成立后,本阶段有自己的输入、断言和完成条件,无需等待 07 才确认正确性。 ## 共同实施约束 @@ -81,4 +85,4 @@ | 多组件热回收、输出槽限制与无法表示的余量 | 05、06 | 逐机器核对规则,不要求所有工艺都产出全部成分 | | chain、minecartWheels 及兼容 prefix 的去留 | 07 | 同时检查实际消费端、外部声明契约和已有存档影响 | -01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收。07、08-D—E 尚未实施。本页不替代现行架构或已接受的决策。 +01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收;07 已完成首轮内部清理。07-E/F、08-D—E 尚未实施。本页不替代现行架构或已接受的决策。 diff --git a/docs/development/material-system-refactor/pr-374-review-actions.md b/docs/development/material-system-refactor/pr-374-review-actions.md new file mode 100644 index 000000000..bae33a801 --- /dev/null +++ b/docs/development/material-system-refactor/pr-374-review-actions.md @@ -0,0 +1,146 @@ +# PR #374 非文档审查意见整理 + +本页汇总 [PR #374](https://github.com/GregTech6CE/GregTech6/pull/374) 中与代码、行为、架构和发布决策有关的审查意见,合并重复问题,供后续分步处理。整理日期为 2026-11-12;审查针对的提交为 `a7c03f27759396b8d918ef7186719f0395373aec`。 + +**状态:审查意见已由用户确认属实。步骤三至七均已完成代码修复;2026-11-12 复核补正后通过双平台编译与全量 GameTest(Forge 92/92、NeoForge 97/97)。本页记录各步骤的验收边界,不据此宣称客户端交互、第三方模组联动或整个 PR 已验收。** + +不收录 docs 目录定位、文档迁移、索引、模板、报告、计数、链接、清理表、parity 记录及文档披露要求。混合意见仅保留其中的实现问题与行为选择,例如保留 API 兼容性变化,排除“文档未披露”的要求。 + +## 来源与阅读方式 + +| 代号 | 来源 | 范围 | +| --- | --- | --- | +| C1 | [lombinaxmasson 的复核评论][C1] | 测试导入、分解输入、热回收比例、外部矿石转换 | +| C2 | [takanashisatou 的架构建议][C2] | 成分优先级、注册结构与同级覆盖策略 | +| R | [Tanimodori 的完整审阅][R] | 回收、成分、生命周期、行为差异、兼容性与设计分歧 | + +读取范围包含 PR 讨论评论与正式 review;读取时没有行内审查评论。正式审阅末尾的结论及测试说明已归并到对应问题,不重复列项。 + +以下步骤是建议处理顺序。步骤一可先独立完成;步骤二处理明确提出的行为问题;步骤三至六处理结构与契约;步骤七集中裁决尚未确定的行为。涉及相同决策的项目通过编号引用,避免重复安排。 + +## 步骤一:恢复测试源码编译 + +- **1.1 补齐 JUnit 断言导入(C1 标为 P1)。** 审查指出 `GregTechAddonsTest` 使用了未导入的 `assertEquals`、`assertTrue`,`MaterialViewTest` 缺少 `assertEquals` 导入;所引用的 CI 有 24 个 `cannot find symbol`,后续构建与发布任务被跳过。先修复导入,再由实施任务执行对应检查。[C1][R] + +## 步骤二:处理配方与数量问题 + +- **2.1 无流体绑定时保留固体分解入口(C1 标为 P2)。** 审查指出 `MaterialDecompositionPlanner` 在无 liquid/gas 绑定时推断 `1000 mB/U`,`DecompositionRecipeLoader` 随后认为流体入口已发布并跳过固体入口。示例为 `AluminiumAlloy`:45U 被转换为 45000 mB,原有 45 粉末/5 粉块入口消失。建议取消无声明绑定的通用流体兜底,按实际绑定决定流体入口,否则走固体入口。[C1][R] + +- **2.2 附属材料热回收按声明比例与权限生成(C1 标为 P2)。** `SharedThermalRecyclingRows.planDeclared()` 被指出只使用绑定字段名,再从 `MoltenFluidHandler.ratio()` 取得 144 mB/U,忽略声明的 1000 mB/U;`BaselineThermalAddon` 可触发该差异,`MaterialBaselineTests` 还把 144 写成期望值。另缺少 `MELTING`/`BLACKLISTED_SMELTER` 检查。建议一并修正单位来源、准入判定和相应测试期望。[C1][R] + +- **2.3 恢复外部 ore tag 的手工转换(C1 标为 P2)。** `CraftingMaterialForms.tagged()` 要求成分快照,但 `ExternalOreProcessingRules.COMPOSITION_FORMS` 不含 `ore`,使仅带 `forge:ores/tin`/`c:ores/tin` 等标签的外部矿石无法进入 `nativeAliases()`,矿石到原矿的配方生成与合成校验均受影响。建议补齐外部 ore 形态进入成分与转换链路的路径。[C1] + +- **2.4 区分 Shredder 静态行与动态回退工时。** 审阅指出静态前缀行使用了 2/64/256,而所引用的 GT6 静态倍率为 256/16;2/64/256 属于动态回退公式。同时缺少 `STRETCHY`、`BOUNCY`、`MEAT`、`ROTTEN` 条件,Quartz 仍按名称识别。建议按两种入口分别确定规则,并与 3.2 的工时收口一起实施。[R] + +- **2.5 统一缺失组件或输出时的处理策略。** 审阅多处指出:多组件回收缺少 pulver target、分解产物绑定失败或缺少输出时,会拒绝整条配方;其引用的 GT6 行为是跳过该组件并保留可生成部分。这里合并为一个策略项,分别覆盖 Shredder 与分解器;需要决定恢复部分输出还是保留整条拒绝,并统一相关分支。[R] + +- **2.6 补齐 tag 派生形态的炉配方接替。** 审阅指出 tag 派生的 dust/gem/crushed 没有相应原版炉行,而 `hasMaterialProcessingRule()` 会删除外来炉行,可能出现删除旧配方后没有新配方接替的缺口。建议把删除条件与实际可发布的替代行关联起来。[R] + +## 步骤三:收敛回收计算、发布和所有权 + +- **3.1 材料数量到粉尘栈只保留一套权威。** `MaterialRecoveryRules.dustPlan()` 按栈上限拆分并报告余量,`OM.dust()` 则选择单栈表达,不同消费者可能得到不同结果。建议明确权威计算入口,让另一个入口转发或退出,并明确单栈调用方如何处理多栈与余量。[R] + + **已修复:** `dustPlan()` 是完整输出权威,`dustSlotPlan()` 是同一算法的单栈视图;`OM.dust()` 使用单栈视图,`OM.dustAll()` 保留全部栈。分解、零件余料、流化床和外部矿石等可容纳多输出的入口改用完整列表,Dust Funnel 按单栈计划实际表示量扣减库存。 + +- **3.2 工时计算统一进入共享计划器。** `MaterialRecoveryRules.shredderWork()` 与 `CapsuleCellRecipes.registerRecycling()` 分别维护公式。建议在完成 2.4 的静态/动态规则裁决后,让各生产端读取同一工时规则,避免继续内联另一份公式。[R] + + **已修复:** 胶囊回收改为调用 `planShredderStatic()`,输出形态和时长均来自共享静态计划,不再内联 `(work + 8) / 9`。 + +- **3.3 每个配方族只有一个发布者与一份形态集合。** `CapsuleCellRecipes`、`StoneVariantRecipes`、`OreProcessingRecipeLoader`、`AnvilForgingRecipes` 被指出仍直接写入 Shredder/Anvil 行,`RecoveryRecipeConflicts` 仅做仲裁;热回收的 `RECYCLABLE` 与粉碎使用的 `RecyclablePrefixes` 又并行维护。建议把这些路径纳入按族归属的统一发布入口,并收敛形态集合,防止同一输入由不同路径生成不同数量。[R] + + **已修复:** 上述生产端及热回收、外部矿石、原生矿石回收路径统一经 `RecoveryRecipePublisher` 发布,并声明所属 family。Shredder 与热回收的形态准入集中到 `RecoveryFormCatalog`。 + + **复核补正:** `SourceDustThermalRecipes`、`SourceThermalNativeAdapter` 和 `OreProcessingRecipeLoader` 的兼容热回收路径此前仍直接写 Melter/Smelter,`VanillaStoneMachineRecipes` 的石质 Smelter/Shredder 也仍直接写 map。现在这些路径分别以 explicit/generic ownership 经统一发布器提交,不再绕过 typed ownership、去重和冲突处理。 + +- **3.4 类型化回收行所有权,并建立输入索引。** `RecoveryRecipeConflicts.generic()` 依赖 `mSource` 的 `-generic` 后缀;`guardedCollision` 未命中后扫描全部配方,审阅认为两万余行规模下可能形成 O(N²) 发布成本。建议用结构化所有权替代命名约定,通过按输入建立的索引完成所有者与冲突查询。[R] + + **已修复:** 回收行在 `Recipe` 上携带 typed generic/explicit ownership;`RecoveryRecipePublisher` 不再解析来源字符串,并在 `findCollision()` 未覆盖 guarded rows 时只查询 `RecipeMap.mRecipeItemMap` 的候选输入桶。 + +## 步骤四:明确成分裁决与附属兼容契约 + +- **4.1 显式提交来源与优先级,并裁决同级冲突。** 两位审查者都要求减少隐式推断,但方案不同:C2 建议在 `ItemMaterialRegistry` 用显式整数优先级及默认值,按 `(key, priority)` 存储,同键同级后写覆盖并告警;R 建议显式受控来源类别,保留同层不同内容失败与覆盖链。共同问题是 `ItemCompositionSource.fromLegacy()` 依赖 `block composition`、`cr.rev`、`common form tags` 等文本反推类别,方块重量与 CR.REV 生产端仍提交旧字符串。先确定冲突契约,再迁移生产端、移除文本反推;两种同级处理方案互斥,不能合并为已达成共识的实现要求。[C2][R] + + **已修复:** 采用受控来源类别:同一优先级只有内容与回收授权完全一致时才合并,不同内容继续失败;显式覆盖仍要求命名现存声明并保留覆盖链。`fromLegacy()` 不再从自由文本猜测类别,旧调用统一标为 `LEGACY`。方块重量、CR.REV、机器构造、运输构件、木材及物品构造器自注册已改为提交结构化来源。 + +- **4.2 保留落选候选及原因。** 审阅指出 `ItemCompositionResolver.resolveItem()` 在首个有胜出者的层返回,`EFFECTIVE` 只保留胜出者,低层候选与淘汰原因不可查。建议提供每个物品的完整裁决诊断,包含胜出来源、落选来源及原因。[R] + + **已修复:** `ItemCompositionResolver.resolveDetailed()` 返回 `ItemCompositionResolution`,逐项保留 `SELECTED`、`REPLACED`、`LOWER_PRIORITY` 候选及原因;`ItemMaterialRegistry.compositionDiagnosis()` 发布与有效快照同代的诊断。tag generation 更新和撤销会同步替换或移除诊断。 + +- **4.3 处理旧注册与查询接口的兼容性变化。** `register(Item, ItemComposition)` 被指出从后写覆盖变为同声明 ID 冲突失败,可能使依赖重复注册的附属启动失败;其最终策略依赖 4.1。另有多组分 legacy 行的 `material()`/`amount()` 从首组件及其数量变为 `INVALID`/0,以及 `recoverable()` 被移除。需要分别决定保留旧行为、提供兼容入口或接受契约变化。[R] + + **已修复:** 弃用的 `register(Item, ItemComposition)` 为兼容入口:同一物品的重复旧调用保留最后写入语义,结构化提交仍执行严格冲突检查。legacy 多组件构造恢复首组件主材料及其数量;`recoverable()` 以弃用方法恢复并转发 `bulkRecoveryAllowed()`。 + +- **4.4 确认 API 版本与发布坐标的变更决策。** 审阅要求确认 API 1.7 → 1.8 的批准来源及发布坐标变化。本项仅保留版本与发布决定,不纳入提交说明或文档同步要求;审阅对授权的质疑不代表本次已核实存在未经授权的变更。[R] + + **已确定:** 保留累计功能对应的 API `1.8.0`;API 1.4—1.8 依次承载材料定义目录、解析处理键、材料信息工具、形态视图和 1.8 的类型化分解规则,因此不能只记为 1.7。发布坐标仍为 Maven `gregtech:gt6ce-api:1.8.0`,只递增版本,不改 groupId、artifactId 或 SDK 组成。 + + 验证:`:api:check`、`:core:test`、双平台生产与测试源码编译、ratchet Spotless、路由与注释检查通过;Forge 1.20.1 全量 GameTest 90/90,NeoForge 1.21.1 全量 GameTest 95/95。首轮 Forge 运行暴露 Stone 铸模主材料兼容回归,修复后最终全量运行通过。 + +## 步骤五:收敛分解声明与数据消费 + +- **5.1 明确 typed rule 与 flag 谁是权威,合并派生映射。** 审阅指出 catalog 写入 `CENTRIFUGE`/`ELECTROLYSER` flag,`MaterialDefinitions.attachDecomposition` 据此生成类型化规则,`MaterialInfoRegistry.syncDecompositionFlags` 又回写 flag;属性到分解路线的映射还在两处重复。建议确定唯一声明来源与单向派生关系,消除往返同步和重复默认语义。[R] + + **已修复:** 路线与相态统一由 `DecompositionMaterials` 声明,规范材料目录不再保存三个分解兼容 flag。`MaterialDefinitions` 一次生成 typed rule;冻结期只把 rule 单向镜像到 `GTMaterial`。旧附属 flag 仅在没有 typed rule 时作为兼容兜底。 + +- **5.2 检出未被消费的分解数据行。** `DecompositionMaterials.input()`/`thermal()` 对没有匹配活动声明的 `(id, name)` 返回 null,审阅认为缺少反向检查。建议让每条数据行都明确属于已消费或有意停用,避免孤儿行静默失效。[R] + + **已修复:** 规范目录装配后反向检查全部相态行和路线。重复、无所有者、typed rule 未保留或路线不一致均在初始化时失败;显式停用集合为空,停用行必须登记后才能跳过。 + +- **5.3 确定流体内容范围是否先于绑定定稿。** 审阅指出 [issue #369](https://github.com/GregTech6CE/GregTech6/issues/369) 关于熔融态及 EMI/坩埚/液化炉配方的取舍仍未决,而本次已确定 69 个材料的液体/气体绑定。需要决定该议题是否是绑定与默认规则定稿的前置,避免内容范围收缩后再次重做。[R] + + **已确定:** 不是前置。typed 分解规则保留固定来源的候选流体身份与单位换算;原生流体注册、EMI 展示、坩埚与熔化器配方属于运行时内容投影。issue #369 收缩范围时,对应绑定按既有诊断缺失;扩展展示时也不改分解规则本身。 + + 验证:完整 `:core:test` 171 个 JUnit、ratchet Spotless、路由与注释检查通过;Forge 1.20.1 全量 GameTest 90/90,NeoForge 1.21.1 全量 GameTest 95/95。 + +## 步骤六:明确快照生命周期、失败边界与分层 + +- **6.1 材料、成分与配方使用一致的发布版本。** 审阅指出 `MaterialInfoRegistry.freeze()` 一次性冻结,`MaterialViews.revision()` 恒为 1,成分 revision 与 `MachineRecipeOverlay` generation 分别递增,缺少统一发布点。需要决定在 08-D 前引入共同 stamp/发布服务,还是采用平台侧快照加 core 纯查询的设计,并明确材料定义不可重载是长期契约还是阶段限制。[R] + + **已修复:** 明确材料定义与显式成分是进程内静态契约,标签成分和配方按平台代次重新发布。新增 `MaterialPublication` 稳定 stamp;`MachineRecipeOverlay` 仅在整代成功后提交材料、成分 revision 与 overlay generation,失败代保留上一份成功戳。`MaterialCatalogView.revision()` 返回材料定义版本,配方查询版本同时观察该稳定戳。 + + **复核补正:** `ItemMaterialRegistry.beginTagGeneration()` 现在返回代次检查点。overlay 在开始重建前捕获上一代标签候选、有效成分、诊断、readiness、tag generation 与 composition revision;失败恢复时整体回滚该检查点,再恢复 baseline 与配方 owner。失败代不会留下“旧 stamp 指向已改变成分状态”的不一致。 + +- **6.2 建立 server/level/会话边界。** `ItemMaterialRegistry` 的 `EFFECTIVE`、`COMPOSITION_REVISION`、`explicitClosed`、`tagInputReady` 被指出是全局静态状态,后两个标志只置位不复位。建议明确多服务器、多世界及切换存档时的状态归属、重置与快照获取方式;本项与 6.1 一起确定生命周期。[R] + + **已修复:** `beginTagGeneration()` 在每代 overlay 与服务端停止时递增 tag generation、撤销上一代标签候选并进入未就绪状态,完整发布后原子替换 `EFFECTIVE`。`compositionState()` 暴露 revision、代次、readiness 与显式关闭状态。`explicitClosed` 是有意保持的 JVM 生命周期契约,不在世界或资源重载时复位。 + +- **6.3 统一异常策略与失败影响范围。** 审阅指出成分同级冲突终止启动、分解失败仅告警跳过、回收冲突则可能触发整代 overlay 回滚,单个附属或数据包冲突会波及全部动态行。建议明确何时启动失败、跳过单行或整代回滚,并与 4.1 的冲突契约一致。[R] + + **已修复:** 策略固定为:显式成分歧义、静态内置配方冲突及初始化结构损坏终止启动;外部 tag/数据包/附属派生的单行回收冲突通过 `publishIsolated(...)` 告警并跳过;分解候选保留逐项拒绝诊断;非行级结构性异常整代回滚到 baseline。动态 Shredder、热回收、外部矿石和源矿石适配路径已接入单行隔离。 + +- **6.4 消除新增的 content/engine 双向知识依赖。** 审阅列出 `MaterialRecoveryRules` 依赖 `engine.material.ItemComposition`、`MaterialDecompositionPlanner` 依赖 `content.recipe.SourceDecompositionRules`;另有 `ItemMaterialRegistry.authorizesMaterialProcessingRule()` 直接依赖 `VanillaCompositionLoader.inheritsVanillaUnification()`,使 registry 知晓 MoldBlock、ClayMoldCatalog、LootChestBlock、MetalChestBlock。建议将内容事实留在内容层,以规则或声明输入通用引擎。[R] + + **已修复:** 单位换算移入 `engine.recipe.UnitConversion`;回收计算拆为引擎层 `ItemRecoveryPlanner` 与内容侧 `MaterialFacts` 适配。原版炉授权随 `ItemCompositionSource` 提交,模具与箱子的空内容语义经 `ItemMaterialRuntimeFacts` 注入。材料 registry 不再直接引用 `VanillaCompositionLoader`、`MoldBlock`、`ClayMoldCatalog`、`LootChestBlock` 或 `MetalChestBlock`。 + +- **6.5 清理无消费者 API。** 审阅将 `MaterialInfoRegistry.compositionDefinition` 列为无调用者的死 API,建议在兼容边界明确后处理其去留。[R] + + **已修复:** 删除 `MaterialInfoRegistry.compositionDefinition(...)`;组成读取保留公开 `MaterialInfoTool.composition(...)` 与内部当前快照入口,不保留重复的冻结访问 API。 + + 验证(2026-11-12): + - 执行且通过:`:core:test` 171 个 JUnit;`compileBothPlatforms`;Forge/NeoForge `compileTestJava`;`:minecraft:spotlessCheck`;Forge 1.20.1 全量 GameTest 90/90,NeoForge 1.21.1 全量 GameTest 95/95。GameTest 覆盖两次真实资源重载、标签代次重置、稳定发布戳和单行冲突隔离。 + - 执行但失败:`:core:spotlessCheck` 与节点级 `spotlessCheck` 仍报告本步骤未修改文件的导入顺序问题;未在本步骤顺手改写。 + - 尚未执行:客户端界面手工检查。本步骤没有新增客户端交互或网络格式。 + +## 步骤七:逐项裁决保留或恢复的行为 + +本步骤只列行为选择,不包含新增 parity 文档的要求。2.1、2.2、2.4、2.5、2.6 已收录的差异不再重复;下列项目均已按 GT6 行为修复。 + +| 项目 | 裁决与实现 | +| --- | --- | +| 损坏物品的固定输出回收 | **恢复比例回收。** Shredder 查询从损坏栈的剩余 `ItemComposition` 重新执行共享计划,再生成该次实际输出;静态 prefix 行保留 16/256 规则,动态行保留 2/64/256 规则。`RecipeMap` 为带运行时解析器的行提供执行期配方,guard 固定预期耐久并重新检查回收准入。[R] | +| 朱砂专用热回收与输入证明 | **移除特例。** 删除 9114/`Cinnabar` 的 Melter/Smelter 硬编码及 `captureCinnabarBlock`;`ThermalRecoveryOwnership` 中遗留的 9114/dust/crushed 前缀所有权也已删除,朱砂不再绕过 `MELTING`、`BLACKLISTED_SMELTER` 和常规相态绑定。`emitWholeDustMetal` 的 Ti/Fe 分数组仍按原审核边界保留,并有 GameTest 防止朱砂重新进入特殊所有者集合。[R] | +| 物品级回收授权 | **恢复原行为。** `bulkRecoveryAllowed` 仅作为 legacy 构造参数和兼容访问器输入保留,规范构造时统一归一为 `true`;回收准入改由有效成分、形态、具体工艺与栈状态决定,`canMelt` 继续独立。[R] | +| tag 形态覆盖范围 | **补齐。** common form tag 新增齿轮、小齿轮、环、螺栓、螺丝和箔;`storage_blocks` 与 `cables` 作为没有一对 `MaterialPrefix` 身份的 tag 组直接生成 9U 与 1/2U 成分候选。ore 转换缺口仍由 2.3 的专门路径处理。[R] | +| 胶囊专用回收行 | **保留为平台适配,不另立规则。** `fluid_cell_*` 是端口对 GT6 `capcellcon` 具体材质变体的表示,空壳按 1/9U 输出,时长由 `planShredderStatic()` 的 16/256 静态规则计算;盛装内容物的胶囊仍不回收。[R] | +| 铜块跨平台回收授权 | **统一。** `VanillaMaterialCorrections.copper()` 在两个平台都执行;两平台共同存在的 `minecraft:copper_block` 提交 9U Copper 修正成分,版本独有铜变体按物品存在性跳过。[R] | + +验证(2026-11-12): + +- 执行且通过(复核补正):`compileBothPlatforms`;两节点 `compileTestJava`;`:minecraft:spotlessCheck`;Forge 1.20.1 全量 GameTest 92/92,NeoForge 1.21.1 全量 GameTest 97/97,包含失败代整体回滚与朱砂普通所有权回归。 +- 执行但失败:节点级 `spotlessCheck` 仍报告 `HopperClientModels`、`PipeWireClientModels`、`GTIconSetBlocks`、`GTRemainingIconBlocks` 等本轮未修改文件的既有导入顺序问题;共享 `:minecraft:spotlessCheck` 已通过。 +- 执行但失败:`:core:spotlessJavaCheck` 仍报告本轮未修改的 `NutritionRemovalTest.java` 导入顺序;本轮 core 文件已按同一 Palantir 2.103.0 格式化,未改写该无关文件。 +- 尚未执行:客户端交互与 JEI/EMI 展示手工检查;没有真实第三方模组提供新增 storage block/cable tag 成员,tag 映射由静态表和现有资源加载链路覆盖。 + +[C1]: https://github.com/GregTech6CE/GregTech6/pull/374#issuecomment-6797033166 +[C2]: https://github.com/GregTech6CE/GregTech6/pull/374#issuecomment-6798836766 +[R]: https://github.com/GregTech6CE/GregTech6/pull/374#pullrequestreview-5861956940 diff --git a/docs/integration/material-refactor-05-recovery.md b/docs/integration/material-refactor-05-recovery.md index 596e9ae4d..444287ac8 100644 --- a/docs/integration/material-refactor-05-recovery.md +++ b/docs/integration/material-refactor-05-recovery.md @@ -78,7 +78,7 @@ ## PR #374 复核补正(2026-11-12) -- `ReviewedCinnabarThermalRecipes`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader` 和 `VanillaStoneMachineRecipes` 的 Melter/Smelter/石质 Shredder 写入全部进入 `RecoveryRecipePublisher`,补上材料回收族的直写旁路。 +- `SourceDustThermalRecipes`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader` 和 `VanillaStoneMachineRecipes` 的 Melter/Smelter/石质 Shredder 写入全部进入 `RecoveryRecipePublisher`,补上材料回收族的直写旁路。 - 标签代次开始前的成分状态成为可回滚检查点;overlay 失败时恢复上一代标签候选、有效成分、诊断、readiness、generation 与 composition revision,同时保持上一份成功 `MaterialPublication` 不变。 - `ThermalRecoveryOwnership` 不再包含 9114/`Cinnabar` 前缀特例,只保留 Ti/Fe 审计分数组。 - 执行且通过:双平台生产与测试源码编译、`:minecraft:spotlessCheck`、Forge 1.20.1 GameTest 92/92、NeoForge 1.21.1 GameTest 97/97。 diff --git a/minecraft/src/main/java/gregtech/client/MaterialTooltips.java b/minecraft/src/main/java/gregtech/client/MaterialTooltips.java index 09de41786..1e15d14f9 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialTooltips.java +++ b/minecraft/src/main/java/gregtech/client/MaterialTooltips.java @@ -199,10 +199,7 @@ public static void appendForeign(ItemStack stack, gregtech.engine.material.ItemC return; } GTMaterial mat = data.material(); - if (mat.getId() <= 0) { - if (flag.isAdvanced()) tooltip.add(Component.translatable("tooltip.gt6ce.composition_nonmaterial").withStyle(ChatFormatting.GRAY)); - return; - } + if (mat.getId() <= 0) return; String chemical = data.components().size() == 1 ? mat.getResolvedTooltipChemical() : ""; if (gregtech.GregTechConfig.chemicalFormulas() && chemical != null && !chemical.isEmpty()) { @@ -213,8 +210,6 @@ public static void appendForeign(ItemStack stack, gregtech.engine.material.ItemC appendFuelTooltip(mat, data.prefix(), data.amount(), tooltip); appendFlammableTooltip(mat, tooltip); } - if (!data.bulkRecoveryAllowed()) tooltip.add(Component.translatable("tooltip.gt6ce.composition_descriptive").withStyle(ChatFormatting.GRAY)); - if (gregtech.GregTechConfig.materialDetails() && flag.isAdvanced()) { tooltip.add(Component.translatable("tooltip." + GregTechIdentity.REGISTRY_NAMESPACE + ".contained_materials") diff --git a/minecraft/src/main/java/gregtech/content/material/MaterialItemCompositions.java b/minecraft/src/main/java/gregtech/content/material/MaterialItemCompositions.java index f7642c9f3..f180799f9 100644 --- a/minecraft/src/main/java/gregtech/content/material/MaterialItemCompositions.java +++ b/minecraft/src/main/java/gregtech/content/material/MaterialItemCompositions.java @@ -1,5 +1,6 @@ package gregtech.content.material; +import gregtech.api.material.GTValues; import gregtech.api.material.MaterialComponent; import gregtech.content.block.BlockMaterialWeights; import gregtech.content.block.MaterialBlockLike; @@ -12,12 +13,16 @@ import gregtech.content.machine.OriginalMachineMaterialData; import gregtech.content.registry.GTBlocks; import gregtech.content.registry.GTItems; +import gregtech.engine.fluid.PortableFluidContainerSpec; import gregtech.engine.material.ItemComposition; import gregtech.engine.material.ItemCompositionSource; import gregtech.engine.material.ItemMaterialRegistry; import gregtech.engine.material.ItemMaterialRuntimeFacts; import java.util.List; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; /** Pure item and block composition submissions shared by both loader entry points. */ @@ -29,14 +34,15 @@ public static void registerCommon() { registerMaterialItemForms(); registerBlockWeights(); registerMachineConstruction(); - gregtech.content.recipe.DiggableRecipes.registerMaterials(); - gregtech.content.recipe.RegisteredWoodSurvivalRecipes.registerMaterials(); - gregtech.content.recipe.VanillaWoodProcessingRecipes.registerMaterials(); + registerSingleItemMaterials(); + registerCapsuleCells(); + registerDiggableMaterials(); + WoodMaterialCompositions.register(); gregtech.content.registry.GTBars.registerCompositions(); gregtech.content.registry.GTWires.registerCompositions(); gregtech.content.registry.GTSignalWires.registerCompositions(); - gregtech.content.recipe.PanelMaterialRegistration.register(); - gregtech.content.recipe.TransportMaterialRegistration.register(); + PanelMaterialCompositions.register(); + TransportMaterialCompositions.register(); } public static void registerVanillaBindings() { @@ -113,4 +119,68 @@ private static void registerMachineConstruction() { .ifPresent(data -> ItemMaterialRegistry.registerDeclared(block.asItem(), data)); } } + + private static void registerDiggableMaterials() { + for (var row : gregtech.content.recipe.DiggableRecipes.packable()) { + if (row.material() == null) continue; + ItemMaterialRegistry.register(item("gt6ce:" + row.block()), null, row.material(), GTValues.U * 4); + ItemMaterialRegistry.register(item("gt6ce:" + row.ball()), null, row.material(), GTValues.U); + } + ItemMaterialRegistry.register( + item("gt6ce:turf"), null, gregtech.content.material.Materials.Peat, GTValues.U * 4); + } + + private static void registerSingleItemMaterials() { + ItemMaterialRegistry.register( + item("gt6ce:dry_bark"), null, gregtech.engine.material.GTMaterialRegistry.get("Bark"), GTValues.U / 2); + for (var row : gregtech.content.recipe.OriginalSingleItemCatalog.COMPOUNDS) { + ItemMaterialRegistry.register( + item("gt6ce:" + row.item()), + null, + gregtech.engine.material.GTMaterialRegistry.get(row.material()), + GTValues.U / 9); + } + ItemMaterialRegistry.register( + item("gt6ce:scrap_meat"), + null, + gregtech.engine.material.GTMaterialRegistry.get("MeatRaw"), + 2 * GTValues.U); + ItemMaterialRegistry.register( + item("gt6ce:raw_meat_bar"), + MaterialPrefix.ingot, + gregtech.engine.material.GTMaterialRegistry.get("MeatRaw"), + GTValues.U); + ItemMaterialRegistry.register( + item("gt6ce:cooked_meat_bar"), + MaterialPrefix.ingot, + gregtech.engine.material.GTMaterialRegistry.get("MeatCooked"), + GTValues.U); + } + + private static void registerCapsuleCells() { + for (var spec : PortableFluidContainerSpec.values()) { + if (!spec.shapeId().equals("cell")) continue; + var item = item("gt6ce:fluid_" + spec.id()); + if (ItemMaterialRegistry.base(item).isPresent()) continue; + ItemMaterialRegistry.registerDeclared( + item, + new ItemComposition( + null, + List.of(MaterialComponent.of(spec.material(), GTValues.U9)), + spec.material(), + List.of(new ItemCompositionSource( + ItemCompositionSource.Kind.EXPLICIT, + "gt6ce:capsule-cell/" + spec.id(), + "capsule-cell material", + spec.id(), + "")), + true)); + } + } + + private static Item item(String id) { + Item item = BuiltInRegistries.ITEM.get(ResourceLocation.parse(id)); + if (item == Items.AIR) throw new IllegalStateException("Missing material item " + id); + return item; + } } diff --git a/minecraft/src/main/java/gregtech/content/recipe/PanelMaterialRegistration.java b/minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java similarity index 95% rename from minecraft/src/main/java/gregtech/content/recipe/PanelMaterialRegistration.java rename to minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java index 4da7706a6..032762160 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/PanelMaterialRegistration.java +++ b/minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java @@ -1,9 +1,11 @@ /* GregTech-6 Team / Gregorius Techneticies; LGPL-3.0-or-later. * Source constructors and CR.REV bookkeeping: panel-material-source-20261006.json. */ -package gregtech.content.recipe; +package gregtech.content.material; import gregtech.api.material.*; import gregtech.content.data.MaterialPrefix; +import gregtech.content.transport.PanelCatalog; +import gregtech.content.transport.PanelMaterialRules; import gregtech.content.transport.*; import gregtech.engine.material.*; import java.util.*; @@ -12,8 +14,8 @@ import net.minecraft.world.item.*; /** Register original panel material fallbacks before recovery recipe creation. */ -public final class PanelMaterialRegistration { - private PanelMaterialRegistration() {} +public final class PanelMaterialCompositions { + private PanelMaterialCompositions() {} private static final Set RECOVERY_ITEMS = Collections.newSetFromMap(new IdentityHashMap<>()); diff --git a/minecraft/src/main/java/gregtech/content/recipe/TransportMaterialRegistration.java b/minecraft/src/main/java/gregtech/content/material/TransportMaterialCompositions.java similarity index 93% rename from minecraft/src/main/java/gregtech/content/recipe/TransportMaterialRegistration.java rename to minecraft/src/main/java/gregtech/content/material/TransportMaterialCompositions.java index 47fe18fc2..977e434af 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/TransportMaterialRegistration.java +++ b/minecraft/src/main/java/gregtech/content/material/TransportMaterialCompositions.java @@ -1,7 +1,8 @@ -package gregtech.content.recipe; +package gregtech.content.material; import gregtech.api.material.*; import gregtech.content.transport.*; +import gregtech.content.transport.TransportMaterialRules; import gregtech.content.transport.fluid.FluidTransportDefinitions; import gregtech.engine.machine.ItemPipeSpec; import gregtech.engine.material.*; @@ -11,8 +12,8 @@ import net.minecraft.world.item.*; /** Bind the actual native block items before material recovery recipes are created. */ -public final class TransportMaterialRegistration { - private TransportMaterialRegistration() {} +public final class TransportMaterialCompositions { + private TransportMaterialCompositions() {} private static final Set RECOVERY_ITEMS = Collections.newSetFromMap(new IdentityHashMap<>()); diff --git a/minecraft/src/main/java/gregtech/content/material/WoodMaterialCompositions.java b/minecraft/src/main/java/gregtech/content/material/WoodMaterialCompositions.java new file mode 100644 index 000000000..4284c552d --- /dev/null +++ b/minecraft/src/main/java/gregtech/content/material/WoodMaterialCompositions.java @@ -0,0 +1,137 @@ +package gregtech.content.material; + +import gregtech.api.material.GTValues; +import gregtech.api.material.MaterialComponent; +import gregtech.content.block.wood.WoodSpecies; +import gregtech.content.data.MaterialPrefix; +import gregtech.content.plant.WoodSlabCatalog; +import gregtech.content.recipe.NaturalWoodCraftingRows; +import gregtech.content.recipe.RegisteredWoodSurvivalRecipes; +import gregtech.content.registry.GTWoods; +import gregtech.engine.material.GTMaterialRegistry; +import gregtech.engine.material.ItemComposition; +import gregtech.engine.material.ItemCompositionSource; +import gregtech.engine.material.ItemMaterialRegistry; +import java.util.List; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; + +/** Fixed GT wood item compositions, installed before recipe families run. */ +public final class WoodMaterialCompositions { + private WoodMaterialCompositions() {} + + public static void register() { + registerNativeWoods(); + registerNaturalWoods(); + registerVanillaWoods(); + } + + private static void registerNativeWoods() { + for (String wood : WoodSlabCatalog.WOODS) { + var material = GTMaterialRegistry.get(WoodSlabCatalog.material(wood)); + ItemMaterialRegistry.register(item("gt6ce:planks_" + wood), MaterialPrefix.plate, material, GTValues.U); + ItemMaterialRegistry.register(item("gt6ce:slab_" + wood), null, material, GTValues.U / 2); + } + for (var species : WoodSpecies.values()) { + var material = GTMaterialRegistry.get(WoodSlabCatalog.material(species.id())); + var bark = GTMaterialRegistry.get(species == WoodSpecies.CINNAMON ? "Cinnamon" : "Bark"); + ItemMaterialRegistry.register( + GTWoods.log(species).asItem(), + new ItemComposition( + null, + List.of( + MaterialComponent.of(material, 8 * GTValues.U), + MaterialComponent.of(bark, GTValues.U)), + material, + List.of(new ItemCompositionSource( + ItemCompositionSource.Kind.EXPLICIT, + "gt6ce:wood-log/" + species.id(), + "GT6 WoodEntry", + species.id(), + "")), + true), + ItemCompositionSource.Kind.EXPLICIT, + "gt6ce:wood-log/" + species.id(), + "GT6 WoodEntry"); + ItemMaterialRegistry.register( + GTWoods.strippedLog(species).asItem(), null, material, 8 * GTValues.U); + } + } + + private static void registerNaturalWoods() { + for (var wood : NaturalWoodCraftingRows.SPECIES) { + var material = GTMaterialRegistry.get(wood.material()); + var bark = GTMaterialRegistry.get(wood.barkMaterial()); + var components = List.of( + MaterialComponent.of(material, 5 * GTValues.U), + MaterialComponent.of(bark, GTValues.U)); + ItemMaterialRegistry.register( + item("gt6ce:log_" + wood.kind()), + new ItemComposition( + null, + components, + material, + List.of(new ItemCompositionSource( + ItemCompositionSource.Kind.EXPLICIT, + "gt6ce:wood-log/" + wood.kind(), + "GT6 WoodEntry Log1", + wood.kind(), + "")), + true), + ItemCompositionSource.Kind.EXPLICIT, + "gt6ce:wood-log/" + wood.kind(), + "GT6 WoodEntry Log1"); + ItemMaterialRegistry.register( + item("gt6ce:planks_" + wood.kind()), MaterialPrefix.plate, material, GTValues.U); + } + } + + private static void registerVanillaWoods() { + for (String wood : new String[] { + "oak", "spruce", "birch", "jungle", "acacia", "dark_oak", "mangrove", "cherry" + }) registerVanillaWood(wood, "log", "wood"); + registerVanillaWood("crimson", "stem", "hyphae"); + registerVanillaWood("warped", "stem", "hyphae"); + } + + private static void registerVanillaWood(String wood, String... types) { + var material = GTMaterialRegistry.get(WoodSlabCatalog.material(wood)); + var bark = GTMaterialRegistry.get("Bark"); + for (String type : types) { + String raw = wood + "_" + type; + registerVanilla( + raw, + new ItemComposition( + null, + List.of( + MaterialComponent.of(material, 8 * GTValues.U), + MaterialComponent.of(bark, GTValues.U)), + material, + "GT6 WoodEntry (modern wood binding)", + true)); + registerVanilla("stripped_" + raw, new ItemComposition(null, material, 8 * GTValues.U)); + } + registerVanilla(wood + "_planks", new ItemComposition(MaterialPrefix.plate, material, GTValues.U)); + registerVanilla(wood + "_stairs", new ItemComposition(null, material, 3 * GTValues.U / 4)); + registerVanilla(wood + "_slab", new ItemComposition(null, material, GTValues.U / 2)); + } + + private static void registerVanilla(String path, ItemComposition composition) { + var item = item("minecraft:" + path); + ItemMaterialRegistry.register( + item, + composition, + ItemCompositionSource.Kind.EXPLICIT, + "gt6ce:wood-entry/" + path, + "GT6 wood material binding", + VanillaCompositionLoader.declarationId(item).orElse(null)); + } + + private static Item item(String id) { + var value = BuiltInRegistries.ITEM.get(ResourceLocation.parse(id)); + if (value == Items.AIR) throw new IllegalStateException("Missing wood material item " + id); + return value; + } +} diff --git a/minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java index 0aa379b36..2837b723a 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java @@ -54,8 +54,6 @@ public final class BathMaterialRecipes extends OriginalRecipeBatch { private static final String[] DUST_FORMS = {"dust", "dustSmall", "dustTiny"}; private static final int[] DUST_COUNTS = {1, 4, 9}; private static final long PAPER_TICKS = 16; - /** Wood-property materials the source ANY.Wood does not contain. */ - private static final Set NOT_ANY_WOOD_DUST = Set.of("PetrifiedWood"); private static final long CONVERSION_TICKS = 144; private final Set used = new HashSet<>(); @@ -74,13 +72,7 @@ public static int register() { } private void paper() { - Set sources = new LinkedHashSet<>(); - for (GTMaterial material : GTMaterialRegistry.allMaterials()) { - GTMaterial resolved = material.resolve(); - if (!resolved.isValid() || !resolved.has(MaterialProperty.WOOD)) continue; - if (NOT_ANY_WOOD_DUST.contains(resolved.getName())) continue; - sources.add(resolved); - } + Set sources = new LinkedHashSet<>(MaterialGroups.members(MaterialGroups.Wood)); for (String name : new String[] {"Bark", "Paper"}) { GTMaterial material = GTMaterialRegistry.get(name); if (material.isValid()) sources.add(material); diff --git a/minecraft/src/main/java/gregtech/content/recipe/CapsuleCellRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/CapsuleCellRecipes.java index d2f191c1f..d8771f2eb 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/CapsuleCellRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/CapsuleCellRecipes.java @@ -45,18 +45,6 @@ public static int registerRecycling() { for(var spec:PortableFluidContainerSpec.values())if(spec.shapeId().equals("cell")) { var input=new ItemStack(Mc.item(ResourceLocation.fromNamespaceAndPath("gt6ce","fluid_"+spec.id()))); var composition=ItemMaterialRegistry.base(input.getItem()).orElse(null); - if(composition==null) { - var data=new ItemComposition(null,java.util.List.of(MaterialComponent.of(spec.material(),GTValues.U9)), - spec.material(),java.util.List.of(new ItemCompositionSource( - ItemCompositionSource.Kind.EXPLICIT, - "gt6ce:capsule-cell/"+spec.id(), - "capsule-cell material", - spec.id(), - "")),true); - ItemMaterialRegistry.register(input.getItem(),data,ItemCompositionSource.Kind.EXPLICIT, - "gt6ce:capsule-cell/"+spec.id(),"PortableFluidContainerSpec"); - composition=ItemMaterialRegistry.base(input.getItem()).orElse(null); - } if(composition==null ||ItemMaterialRegistry.recoveryRejection(input)!=ItemMaterialRegistry.RecoveryRejection.ELIGIBLE ||composition.components().size()!=1 diff --git a/minecraft/src/main/java/gregtech/content/recipe/DiggableRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/DiggableRecipes.java index cb52389af..81cd19ce4 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/DiggableRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/DiggableRecipes.java @@ -1,13 +1,11 @@ package gregtech.content.recipe; import gregtech.api.material.GTMaterial; -import gregtech.api.material.GTValues; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; import gregtech.content.material.Materials; import gregtech.content.registry.GTItems; import gregtech.content.registry.GTTechnological; -import gregtech.engine.material.ItemMaterialRegistry; import gregtech.engine.recipe.Recipe; import gregtech.platform.Mc; import java.util.ArrayList; @@ -45,17 +43,6 @@ public static List entries() { return List.copyOf(ENTRIES); } - /** GT6 {@code OM.data}: five clay blocks and turf contain four units; clay balls one unit. */ - public static void registerMaterials() { - for (Variant row : PACKABLE) { - if (row.material() == null) continue; // GT6 UNUSED.Mud has no composition. - ItemMaterialRegistry.register(item(row.block()), null, row.material(), GTValues.U * 4); - ItemMaterialRegistry.register(item(row.ball()), null, row.material(), GTValues.U); - } - ItemMaterialRegistry.register(item("turf"), null, Materials.Peat, GTValues.U * 4); - // Retired diggable_* IDs resolve through registry aliases to these same material entries. - } - public static int register() { if (registered) throw new IllegalStateException("Diggable processing rows registered twice"); registered = true; diff --git a/minecraft/src/main/java/gregtech/content/recipe/ElectronicsRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/ElectronicsRecipes.java index d07551bbe..beeaaaa4c 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/ElectronicsRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/ElectronicsRecipes.java @@ -8,6 +8,7 @@ import gregtech.content.data.*; import gregtech.content.registry.*; import gregtech.content.material.Materials; +import gregtech.content.material.catalog.SourceLensMaterialFacts.Color; import net.minecraft.world.item.ItemStack; //? if >=1.21.1 { /*import net.neoforged.neoforge.fluids.FluidStack; @@ -177,7 +178,7 @@ private static void crystal(String circuit, String[] names, if (gem == null || !gem.isValid() || (group == MaterialGroups.Sapphire && gem.resolve() == Materials.Ruby.resolve())) continue; ItemStack plate = GTItems.getStack(MaterialPrefix.plateGem, gem, 1); if (plate.isEmpty()) continue; - for (var lens : SourceLensRoles.lenses(SourceLensRoles.Color.GREEN)) + for (var lens : SourceLensRecipeItems.lenses(Color.GREEN)) add(MachineRecipeMaps.LaserEngraver, new Recipe( new ItemStack[]{plate.copy(), lens}, new ItemStack[]{tech(circuit, 1)}, null, null, null, null, 64, 256, 0) @@ -189,7 +190,7 @@ private static void crystal(String circuit, String[] names, private static void engrave(String wire,String foilMaterial) { var foil = GTItems.getStack(MaterialPrefix.foil, GTMaterialRegistry.get(foilMaterial), 4); if (foil.isEmpty()) return; - for (var lens : SourceLensRoles.lenses(SourceLensRoles.Color.RED)) + for (var lens : SourceLensRecipeItems.lenses(Color.RED)) add(MachineRecipeMaps.LaserEngraver,new Recipe( new ItemStack[]{foil.copy(),lens}, new ItemStack[]{tech(wire,1)},null,null,null,null,64,16,0).withCatalystInputs(1)); diff --git a/minecraft/src/main/java/gregtech/content/recipe/GenerifierRecipeFamily.java b/minecraft/src/main/java/gregtech/content/recipe/GenerifierRecipeFamily.java index 59cc4eec0..4277bd323 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/GenerifierRecipeFamily.java +++ b/minecraft/src/main/java/gregtech/content/recipe/GenerifierRecipeFamily.java @@ -4,6 +4,7 @@ import gregtech.content.block.MaterialBlockLike; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTBlocks; import gregtech.content.registry.GTItems; import gregtech.engine.material.GTMaterialRegistry; @@ -152,7 +153,9 @@ private static ItemStack vanillaOutput(String formName, String materialName) { } private static GTMaterial target(GTMaterial material) { - int targetId = GenerifyingRules.target(material.getId()); + int targetId = MaterialFactKeys.value(material, MaterialFactKeys.GENERIFICATION_TARGET) + .map(MaterialFactKeys.GenerificationTarget::materialId) + .orElse(material.getId()); if (targetId == material.getId()) return null; GTMaterial target = GTMaterialRegistry.get(targetId); return target.isValid() ? target : null; diff --git a/minecraft/src/main/java/gregtech/content/recipe/LaserStoneRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/LaserStoneRecipes.java index 7f1219c33..7f3a99887 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/LaserStoneRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/LaserStoneRecipes.java @@ -3,6 +3,7 @@ import gregtech.content.block.stone.StoneType; import gregtech.content.block.stone.StoneVariant; import gregtech.content.data.MachineRecipeMaps; +import gregtech.content.material.catalog.SourceLensMaterialFacts.Color; import gregtech.content.recipe.generated.GeneratedRecipeResolver; import gregtech.content.registry.GTBlocks; import gregtech.engine.recipe.Recipe; @@ -14,7 +15,7 @@ /** BlockStones and Loader_Recipes_OreDict, native stone and generator engravings. */ public final class LaserStoneRecipes { - public record Entry(String family, StoneType stone, SourceLensRoles.Color color, Recipe recipe) {} + public record Entry(String family, StoneType stone, Color color, Recipe recipe) {} private static final List ENTRIES = new ArrayList<>(); private static boolean registered; @@ -25,7 +26,7 @@ public static List entries() { return Collections.unmodifiableList(ENTRIES); } - public static StoneVariant output(SourceLensRoles.Color color) { + public static StoneVariant output(Color color) { return switch (color) { case WHITE -> StoneVariant.BRICKS_CHISELED; case RED -> StoneVariant.TILES; @@ -42,29 +43,21 @@ public static int register() { if (registered) return 0; registered = true; for (var stone : StoneType.values()) - for (var color : SourceLensRoles.Color.values()) - for (var lens : SourceLensRoles.lenses(color)) { + for (var color : Color.values()) + for (var lens : SourceLensRecipeItems.lenses(color)) { var inputBlock = GTBlocks.getStone(stone, StoneVariant.SMOOTH); var outputBlock = GTBlocks.getStone(stone, output(color)); if (inputBlock == null || outputBlock == null) throw new IllegalStateException("Missing native laser stone " + stone + "/" + color); var input = new ItemStack(inputBlock); var output = new ItemStack(outputBlock); - add( - "stone", - stone, - color, - input, - lens, - output, - color == SourceLensRoles.Color.WHITE ? 64 : 16, - false); + add("stone", stone, color, input, lens, output, color == Color.WHITE ? 64 : 16, false); } - for (var lens : SourceLensRoles.lenses(SourceLensRoles.Color.WHITE)) { + for (var lens : SourceLensRecipeItems.lenses(Color.WHITE)) { add( "vanilla", null, - SourceLensRoles.Color.WHITE, + Color.WHITE, new ItemStack(Items.STONE), lens, new ItemStack(Items.CHISELED_STONE_BRICKS), @@ -83,13 +76,13 @@ private static void module(String id, ItemStack output, ItemStack lens) { var input = GeneratedRecipeResolver.resolveSpec("tech:" + id + ":1"); if (input == null || input.isEmpty()) throw new IllegalStateException("Missing source laser generator module " + id); - add("module", null, SourceLensRoles.Color.WHITE, input, lens, output, 128, true); + add("module", null, Color.WHITE, input, lens, output, 128, true); } private static void add( String family, StoneType stone, - SourceLensRoles.Color color, + Color color, ItemStack input, ItemStack lens, ItemStack output, diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialFormConversionRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialFormConversionRecipes.java index f6e08505d..015d36ad4 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MaterialFormConversionRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MaterialFormConversionRecipes.java @@ -5,6 +5,7 @@ import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; import gregtech.content.data.generated.MaterialWorkability; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.material.Materials; import gregtech.content.registry.GTBlocks; import gregtech.content.registry.GTItems; @@ -107,7 +108,9 @@ private static void compressor(GTMaterial material, boolean easy, int quality) { || has(MaterialPrefix.gemExquisite, material) || has(MaterialPrefix.gemFlawless, material) || has(MaterialPrefix.bouleGt, material); - if (!gemLike && !"Ice".equals(material.getName())) { + if (!gemLike + && MaterialFactKeys.value(material, MaterialFactKeys.COMPRESSOR_DUST_TO_GEM_PLATE) + .orElse(true)) { compressing(material, easy ? 16 : 256L * (quality + 1), MaterialPrefix.dust, 1, MaterialPrefix.plateGem, 1); } // 9 material units of plate -> 1 dense plate. plate 9, plateTriple 3, blockPlate 1 and diff --git a/minecraft/src/main/java/gregtech/content/recipe/NonOreContinuationEvidence.java b/minecraft/src/main/java/gregtech/content/recipe/NonOreContinuationEvidence.java index 204e365a6..db3866c2a 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/NonOreContinuationEvidence.java +++ b/minecraft/src/main/java/gregtech/content/recipe/NonOreContinuationEvidence.java @@ -2,6 +2,7 @@ import gregtech.api.material.*; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTItems; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.*; @@ -60,7 +61,9 @@ public static Snapshot startupSnapshot(Collection reviewed) { Set defer = Collections.newSetFromMap(new IdentityHashMap<>()); Set triggers = triggers(); for (var material : candidates) { - if (ReviewedOreInputProfile.decision(material) != ReviewedOreInputProfile.Evidence.NO) defer.add(material); + if (MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_ORE_INPUT) + .orElse(MaterialFactKeys.Decision.UNKNOWN) + != MaterialFactKeys.Decision.NO) defer.add(material); // Explicit startup request is material-wide defer, even when only one intermediate requested. if (AddonMaterials.acceptedForms().stream() .anyMatch(f -> f.materialName().equals(material.getName()) && triggers.contains(f.prefixName()))) @@ -78,7 +81,6 @@ public static Snapshot startupSnapshot(Collection reviewed) { var data = ItemMaterialRegistry.base(stack.getItem()).orElse(null); if (data != null && (data.prefix() != prefix - || !data.bulkRecoveryAllowed() || data.components().size() != 1 || data.material().resolve() != material || data.amount() != prefix.getMaterialWeight())) defer.add(material); @@ -91,7 +93,6 @@ public static Snapshot startupSnapshot(Collection reviewed) { GTMaterial material = part.material().resolve(); if (!candidates.contains(material)) continue; if (!canonicalSelf(entry.getKey(), data.prefix(), material) - || !data.bulkRecoveryAllowed() || data.components().size() != 1 || data.amount() != data.prefix().getMaterialWeight()) defer.add(material); } diff --git a/minecraft/src/main/java/gregtech/content/recipe/NonOreMacerationRows.java b/minecraft/src/main/java/gregtech/content/recipe/NonOreMacerationRows.java index 8d0c12cb5..98eabff27 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/NonOreMacerationRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/NonOreMacerationRows.java @@ -4,6 +4,7 @@ import gregtech.engine.recipe.Recipe; import gregtech.engine.recipe.RecipeMap; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import net.minecraft.world.item.ItemStack; //? if >=1.21.1 { /*import net.neoforged.neoforge.fluids.FluidStack; @@ -23,7 +24,9 @@ public static void begin(){ } public static boolean reviewed(GTMaterial material){ if(startup==null)throw new IllegalStateException("Nonore definitions not initialized"); - return ReviewedOreInputProfile.decision(material)==ReviewedOreInputProfile.Evidence.NO&&!startup.active(material); + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_ORE_INPUT) + .orElse(MaterialFactKeys.Decision.UNKNOWN)==MaterialFactKeys.Decision.NO + &&!startup.active(material); } public static void register(GTMaterial material,MaterialPrefix prefix,String producer,RecipeMap map, boolean optimize,ItemStack input,ItemStack[] outputs,long[] chances,FluidStack[] fluids,long duration,long eu){ diff --git a/minecraft/src/main/java/gregtech/content/recipe/OreFluidBindingAdapter.java b/minecraft/src/main/java/gregtech/content/recipe/OreFluidBindingAdapter.java index 1486c477c..4e082c6a7 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/OreFluidBindingAdapter.java +++ b/minecraft/src/main/java/gregtech/content/recipe/OreFluidBindingAdapter.java @@ -1,6 +1,8 @@ package gregtech.content.recipe; import gregtech.api.material.GTMaterial; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.engine.addon.AddonMaterials; +import gregtech.engine.material.GTMaterialRegistry; import gregtech.content.registry.GTFluids; import net.minecraft.core.registries.BuiltInRegistries; //? if >=1.21.1 { @@ -20,23 +22,26 @@ public static FluidStack liquid(GTMaterial material,long sourceAmount,boolean ro * Only the reviewed ID/name binding table can resolve here; never infer an arbitrary fluid alias. */ static FluidStack sourceLiquid(int sourceId,String sourceName,long sourceAmount,boolean roundUp) { - var b=ReviewedOreFluidBindings.liquid(sourceId,sourceName); - int mb=ReviewedOreFluidBindings.amount(b,sourceAmount,roundUp); + var material=GTMaterialRegistry.get(sourceId); + if(!material.isValid()||!material.getName().equals(sourceName))return FluidStack.EMPTY; + var b=MaterialFluidUnitFacts.binding(material,"liquid"); + int mb=b==null?-1:MaterialFluidUnitFacts.millibuckets( + sourceAmount,b.referenceSourceUnits(),b.referenceMillibuckets(),roundUp); if(b==null||mb<=0)return FluidStack.EMPTY; - var stack=GTFluids.stack(b.field(),mb); + var stack=GTFluids.stack(b.fluidField(),mb); if(stack==null||stack.isEmpty())return FluidStack.EMPTY; var key=BuiltInRegistries.FLUID.getKey(stack.getFluid()); - String nativePath=switch(b.field()) { + String nativePath=switch(b.fluidField()) { case "GenMolten_Wax" -> "molten_wax"; case "GenMolten_WaxBee" -> "molten_waxbee"; case "GenMolten_WaxParaffin" -> "molten_waxparaffin"; case "GenMolten_WaxPlant" -> "molten_waxplant"; case "GenLiquid_Mercury" -> "mercury"; - default -> throw new IllegalStateException("No reviewed native identity: "+b.field()); + default -> throw new IllegalStateException("No reviewed native identity: "+b.fluidField()); }; - var entry=gregtech.content.data.RegisteredFluids.get(b.field()); + var entry=gregtech.content.data.RegisteredFluids.get(b.fluidField()); if(entry==null||!(gregtech.content.data.RegisteredFluids.isBuiltInDefinition(entry) - || (b.field().equals("GenLiquid_Mercury") && ReviewedOreGeneratedFluids.mercury(entry)))||!entry.registryName().equals(b.registryPath())) + || (b.fluidField().equals("GenLiquid_Mercury") && SourceGeneratedFluidAdapter.mercury(entry)))||!entry.registryName().equals(b.registryName())) throw new IllegalStateException("Reviewed source catalog identity mismatch: "+b); if(!key.getNamespace().equals(gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE)||!key.getPath().equals(nativePath)) throw new IllegalStateException("Reviewed source fluid binding identity mismatch: "+b+" -> "+key); diff --git a/minecraft/src/main/java/gregtech/content/recipe/OreProcessingRecipeLoader.java b/minecraft/src/main/java/gregtech/content/recipe/OreProcessingRecipeLoader.java index 9c7db1077..53a4c0320 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/OreProcessingRecipeLoader.java +++ b/minecraft/src/main/java/gregtech/content/recipe/OreProcessingRecipeLoader.java @@ -6,6 +6,7 @@ import gregtech.engine.material.*; import gregtech.engine.recipe.RecipeMap; import gregtech.content.data.*; +import gregtech.content.material.MaterialFactKeys; import gregtech.bootstrap.InitializationStep; import gregtech.content.registry.GTFluids; import gregtech.content.registry.RegisteredBlock; @@ -161,8 +162,11 @@ private void registerSmelting(GTMaterial material, GTMaterial crushing, ItemStac long smeltAmount = material.getTargetSmeltingAmount(); GTMaterial smeltTarget = material.getTargetSmeltingMaterial(); if (smeltTarget == null || !smeltTarget.isValid() || smeltAmount <= 0) return; - if (!ReviewedOreSourceProfile.decision(material, ReviewedOreSourceProfile.Rule.FURNACE) - .orLegacy(material.has(MaterialProperty.MELTING))) return; + var furnace = MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_FURNACE) + .orElse(MaterialFactKeys.Decision.UNKNOWN); + if (!(furnace == MaterialFactKeys.Decision.YES + || furnace == MaterialFactKeys.Decision.UNKNOWN + && material.has(MaterialProperty.MELTING))) return; ItemStack smeltOutput = OM.dustOrIngot(smeltTarget, smeltAmount); if (smeltOutput.isEmpty()) { @@ -307,9 +311,9 @@ private void registerOreEntryRecipes(GTMaterial material, ItemStack oreInput, in } else { // Unreviewed/external/startup overrides retain original direct admission and ordering. // GT6 crusher has two guaranteed primary outputs; hammer has one. - if (ReviewedCinnabarFacts.supports(material) + if (SourceCinnabarFollowonAdapter.supports(material) && oreInput.getItem()==mat(MaterialPrefix.oreRaw,material,1).getItem()) { - SourceOreFollowonRows.rawCrusher(material,ReviewedCinnabarFacts.INSTANCE); + SourceOreFollowonRows.rawCrusher(material,SourceCinnabarFollowonAdapter.INSTANCE); } else SharedOreCrushingRows.capture(crushing, MachineRecipeMaps.Crusher, MachineRecipeMaps.Crusher.addRecipe1(true, EU_TIER, 128L * count * quality, oreInput, out, out.copy())); SharedOreCrushingRows.capture(crushing, MachineRecipeMaps.Hammer, @@ -356,9 +360,9 @@ private void processMaceration() { if (pulverizeOne(MaterialPrefix.crushedPurifiedTiny, material, 1, MaterialPrefix.dustTiny, U9)) claimed.add(MaterialPrefix.crushedPurifiedTiny); // Hand off only unclaimed shapes to the previous reviewed producer, not duplicate registrations. if (claimed.size() < SourceOreShreddingRules.shapes().size()) { - if (ReviewedCinnabarFacts.supports(material)) SourceOreFollowonRows.shredder(material,ReviewedCinnabarFacts.INSTANCE,claimed); - else if (ReviewedOreShredderFacts.supports(material)) - SourceOreFollowonRows.shredder(material, ReviewedOreShredderFacts.INSTANCE,claimed); + if (SourceCinnabarFollowonAdapter.supports(material)) SourceOreFollowonRows.shredder(material,SourceCinnabarFollowonAdapter.INSTANCE,claimed); + else if (SourceOreFollowonAdapter.supports(material)) + SourceOreFollowonRows.shredder(material, SourceOreFollowonAdapter.INSTANCE,claimed); } } } @@ -373,7 +377,7 @@ private boolean pulverizeOne(MaterialPrefix inputPref, GTMaterial material, int if (!inputPref.isValidFor(material) || input.isEmpty()) return false; ItemStack output = stackFor(outputPref, material, outAmount); if (output.isEmpty()) return false; - if (ReviewedCinnabarFacts.supports(material) || ReviewedOreShredderFacts.supports(material)) { + if (SourceCinnabarFollowonAdapter.supports(material) || SourceOreFollowonAdapter.supports(material)) { // Unsupported contexts preserve the former reviewed Crusher/follow-on split. MachineRecipeMaps.Crusher.addRecipe1(true,16,64,new long[]{CHANCE_100,CHANCE_10,CHANCE_10},input,output,ItemStack.EMPTY,ItemStack.EMPTY); } else if (NonOreMacerationRows.reviewed(material)) { @@ -402,7 +406,7 @@ private boolean pulverizeMulti(MaterialPrefix inputPref, GTMaterial material, in return false; } MachineRecipeMaps.Crusher .addRecipe1(true, EU_TIER, 32, input, multiOut); - if (!ReviewedCinnabarFacts.supports(material) && !ReviewedOreShredderFacts.supports(material)) { + if (!SourceCinnabarFollowonAdapter.supports(material) && !SourceOreFollowonAdapter.supports(material)) { var recipe = RecipeMap.make( true, new ItemStack[] {input}, @@ -491,7 +495,7 @@ private void processRecycling() { GTMaterial material = mat.resolve(); if (!material.isValid()) continue; if (material.has(MaterialProperty.ANTIMATTER)) continue; - if (ReviewedCinnabarThermalRecipes.emitIfSupported(material)) continue; + if (SourceDustThermalRecipes.emitIfSupported(material)) continue; ItemStack recyclableInput = OM.dustOrIngot(material, U); var thermal = SourceThermalNativeAdapter.inspect(material, recyclableInput, thermalSnapshot); diff --git a/minecraft/src/main/java/gregtech/content/recipe/PartRecipeLoader.java b/minecraft/src/main/java/gregtech/content/recipe/PartRecipeLoader.java index 66c2d49ae..6867a97c7 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/PartRecipeLoader.java +++ b/minecraft/src/main/java/gregtech/content/recipe/PartRecipeLoader.java @@ -217,7 +217,7 @@ private static boolean verifiedSolidBlock(ItemStack stack, GTMaterial material) || block.prefix() != prefix || block.material().resolve() != material) return false; long units = 9 * GTValues.U; var data = gregtech.engine.material.ItemMaterialRegistry.base(stack.getItem()).orElse(null); - if (data != null) return data.bulkRecoveryAllowed() && data.prefix() == null + if (data != null) return data.prefix() == null && data.components().size() == 1 && data.material().resolve() == material && data.amount() == units; // Forge has no general block composition registration; inspect the actual known block. diff --git a/minecraft/src/main/java/gregtech/content/recipe/RegisteredWoodSurvivalRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/RegisteredWoodSurvivalRecipes.java index 63a5ab97e..73abe0b38 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/RegisteredWoodSurvivalRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/RegisteredWoodSurvivalRecipes.java @@ -14,68 +14,6 @@ public final class RegisteredWoodSurvivalRecipes extends OriginalRecipeBatch { public static final RegisteredWoodSurvivalRecipes INSTANCE = new RegisteredWoodSurvivalRecipes(); - public static void registerMaterials() { - // PlankEntry binds the actual wood species, not the generic Wood fallback. Keep this - // available before recipe generation, including shaped wooden-tool material matching. - for (String wood : WoodSlabCatalog.WOODS) { - var material = material(wood); - ItemMaterialRegistry.register( - item("gt6ce:planks_" + wood, 1).getItem(), MaterialPrefix.plate, material, GTValues.U); - ItemMaterialRegistry.register(item("gt6ce:slab_" + wood, 1).getItem(), null, material, GTValues.U / 2); - } - for (var species : WoodSpecies.values()) { - var material = material(species.id()); - var bark = GTMaterialRegistry.get(species == WoodSpecies.CINNAMON ? "Cinnamon" : "Bark"); - ItemMaterialRegistry.register( - GTWoods.log(species).asItem(), - new ItemComposition( - null, - java.util.List.of( - MaterialComponent.of(material, 8 * GTValues.U), - MaterialComponent.of(bark, GTValues.U)), - material, - java.util.List.of(new ItemCompositionSource( - ItemCompositionSource.Kind.EXPLICIT, - "gt6ce:wood-log/" + species.id(), - "GT6 WoodEntry", - species.id(), - "")), - true), - ItemCompositionSource.Kind.EXPLICIT, - "gt6ce:wood-log/" + species.id(), - "GT6 WoodEntry"); - ItemMaterialRegistry.register(GTWoods.strippedLog(species).asItem(), null, material, 8 * GTValues.U); - } - for (var wood : NaturalWoodCraftingRows.SPECIES) { - var material = gregtech.engine.material.GTMaterialRegistry.get(wood.material()); - var bark = gregtech.engine.material.GTMaterialRegistry.get(wood.barkMaterial()); - long unit = gregtech.api.material.GTValues.U; - var components = java.util.List.of( - gregtech.api.material.MaterialComponent.of(material, 5 * unit), - gregtech.api.material.MaterialComponent.of(bark, unit)); - // WoodEntry upgrades the original generic 4U log to 5U wood + 1U bark, - // or 6U of the same material for rotten/mossy wood. PlankEntry contributes 1U. - gregtech.engine.material.ItemMaterialRegistry.register( - item("gt6ce:log_" + wood.kind(), 1).getItem(), - new gregtech.engine.material.ItemComposition( - null, - components, - material, - java.util.List.of(new gregtech.engine.material.ItemCompositionSource( - gregtech.engine.material.ItemCompositionSource.Kind.EXPLICIT, - "gt6ce:wood-log/" + wood.kind(), - "GT6 WoodEntry Log1", - wood.kind(), - "")), - true), - gregtech.engine.material.ItemCompositionSource.Kind.EXPLICIT, - "gt6ce:wood-log/" + wood.kind(), - "GT6 WoodEntry Log1"); - gregtech.engine.material.ItemMaterialRegistry.register( - item("gt6ce:planks_" + wood.kind(), 1).getItem(), MaterialPrefix.plate, material, unit); - } - } - public static int register() { for (var species : WoodSpecies.values()) INSTANCE.wood(species); for (String species : new String[] {"crimson", "warped"}) INSTANCE.netherWood(species); @@ -113,8 +51,6 @@ private void slabUses(String wood) { var material = gregtech.engine.material.GTMaterialRegistry.get(name); var slab = item("gt6ce:slab_" + wood, 1); pulverize(item("gt6ce:planks_" + wood, 1), wood, GTValues.U); - gregtech.engine.material.ItemMaterialRegistry.register( - slab.getItem(), null, material, gregtech.api.material.GTValues.U / 2); var dust = MortarGrindingRecipes.pulverize(material, gregtech.api.material.GTValues.U / 2); // pulverizing registers both the crusher and the shredder, as in the original helper. if (dust.isEmpty()) throw new IllegalStateException("Missing wood slab pulverization material " + name); diff --git a/minecraft/src/main/java/gregtech/content/recipe/ReviewedOreFluidBindings.java b/minecraft/src/main/java/gregtech/content/recipe/ReviewedOreFluidBindings.java deleted file mode 100644 index c98b50beb..000000000 --- a/minecraft/src/main/java/gregtech/content/recipe/ReviewedOreFluidBindings.java +++ /dev/null @@ -1,30 +0,0 @@ -package gregtech.content.recipe; -/** Bounded original liquid-unit bindings, NOT a replacement for legacy materialFluid(). - * Source Loader_Fluids132 (Petrotheum),131 (Cryotheum),205-212 (wax),618 (Hg). - * FL.createMolten1074-1077:144 mB/U. Explicit liquids may use250 or1000, never infer by flag. - */ -public final class ReviewedOreFluidBindings { - public record Binding(int materialId, String materialName, String field, String registryPath, long mbPerU) {} - - private static final Binding[] VALUES = { - new Binding(800, "Mercury", "GenLiquid_Mercury", "mercury", 144), - new Binding(8235, "Wax", "GenMolten_Wax", "molten.wax", 144), - new Binding(8236, "WaxBee", "GenMolten_WaxBee", "molten.waxbee", 144), - new Binding(8238, "WaxParaffin", "GenMolten_WaxParaffin", "molten.waxparaffin", 144), - new Binding(8239, "WaxPlant", "GenMolten_WaxPlant", "molten.waxplant", 144), - }; - - private ReviewedOreFluidBindings() {} - - public static Binding liquid(int id, String name) { - for (var row : VALUES) if (row.materialId == id && row.materialName.equals(name)) return row; - return null; // Unknown is unsupported, not a 144/1000 guess. - } - - public static int amount(Binding binding, long sourceAmount, boolean roundUp) { - return binding == null - ? -1 - : OriginalMaterialFluidUnits.millibuckets( - sourceAmount, OriginalMaterialFluidUnits.SOURCE_UNIT, binding.mbPerU, roundUp); - } -} diff --git a/minecraft/src/main/java/gregtech/content/recipe/ReviewedOreInputProfile.java b/minecraft/src/main/java/gregtech/content/recipe/ReviewedOreInputProfile.java deleted file mode 100644 index ccc5177d1..000000000 --- a/minecraft/src/main/java/gregtech/content/recipe/ReviewedOreInputProfile.java +++ /dev/null @@ -1,83 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.api.material.GTMaterial; -import gregtech.engine.addon.AddonMaterials; -import gregtech.engine.material.GTMaterialRegistry; - -/** Bounded baseline ORES-property proof. Not a universal recipe or external-form prohibition. - * 53 reviewed negatives from54 target-link candidates; Sand and all other identities UNKNOWN. - * Evidence: docs/integration/nonore-input-source-profile.json; paired declaration references and source hashes. - * Factory/group/postmutation tracing, never table absence, establishes these bounded decisions. - */ -public final class ReviewedOreInputProfile { - public enum Evidence { - YES, - NO, - UNKNOWN - } - - private ReviewedOreInputProfile() {} - - public static Evidence decision(GTMaterial material) { - if (material == null) return Evidence.UNKNOWN; - material = material.resolve(); - if (!material.isValid() || !GTMaterialRegistry.isCoreMaterial(material) || AddonMaterials.owns(material)) - return Evidence.UNKNOWN; - String name = material.getName(); - // A supported ore-form request changes this material's baseline. Defer, do not infer ORES YES. - // Otherwise allowing only the requested crushed input could strand its old purified outputs. - if (AddonMaterials.acceptedForms().stream() - .anyMatch(f -> f.materialName().equals(name) - && java.util.Set.of( - "oreRaw", - "crushed", - "crushedTiny", - "crushedPurified", - "crushedPurifiedTiny", - "crushedCentrifuged", - "crushedCentrifugedTiny") - .contains(f.prefixName()))) return Evidence.UNKNOWN; - return switch (material.getId()) { - case 8418 -> name.equals("Bamboo") ? Evidence.NO : Evidence.UNKNOWN; - case 8275 -> name.equals("Bark") ? Evidence.NO : Evidence.UNKNOWN; - case 8620 -> name.equals("Brass") ? Evidence.NO : Evidence.UNKNOWN; - case 8610 -> name.equals("Bronze") ? Evidence.NO : Evidence.UNKNOWN; - case 8501 -> name.equals("Concrete") ? Evidence.NO : Evidence.UNKNOWN; - case 8290 -> name.equals("Dreamwood") ? Evidence.NO : Evidence.UNKNOWN; - case 8751 -> name.equals("Duranium") ? Evidence.NO : Evidence.UNKNOWN; - case 8504 -> name.equals("Endstone") ? Evidence.NO : Evidence.UNKNOWN; - case 8035 -> name.equals("FerricOxyhydroxide") ? Evidence.NO : Evidence.UNKNOWN; - case 8698 -> name.equals("Fireleaf") ? Evidence.NO : Evidence.UNKNOWN; - case 9712 -> name.equals("FishRaw") ? Evidence.NO : Evidence.UNKNOWN; - case 8002 -> name.equals("Flint") ? Evidence.NO : Evidence.UNKNOWN; - case 90 -> name.equals("Fluorine") ? Evidence.NO : Evidence.UNKNOWN; - case 9175 -> name.equals("Graphene") ? Evidence.NO : Evidence.UNKNOWN; - case 8296 -> name.equals("Greatwood") ? Evidence.NO : Evidence.UNKNOWN; - case 9802 -> name.equals("Ice") ? Evidence.NO : Evidence.UNKNOWN; - case 8645 -> name.equals("IronMagnetic") ? Evidence.NO : Evidence.UNKNOWN; - case 8241 -> name.equals("Leather") ? Evidence.NO : Evidence.UNKNOWN; - case 9189 -> name.equals("Limestone") ? Evidence.NO : Evidence.UNKNOWN; - case 8289 -> name.equals("Livingwood") ? Evidence.NO : Evidence.UNKNOWN; - case 8506 -> name.equals("Marble") ? Evidence.NO : Evidence.UNKNOWN; - case 9700 -> name.equals("MeatRaw") ? Evidence.NO : Evidence.UNKNOWN; - case 8647 -> name.equals("NeodymiumMagnetic") ? Evidence.NO : Evidence.UNKNOWN; - case 8502 -> name.equals("Netherrack") ? Evidence.NO : Evidence.UNKNOWN; - case 8214 -> name.equals("Obsidian") ? Evidence.NO : Evidence.UNKNOWN; - case 8218 -> name.equals("Plastic") ? Evidence.NO : Evidence.UNKNOWN; - case 8197 -> name.equals("PVC") ? Evidence.NO : Evidence.UNKNOWN; - case 8104 -> name.equals("RedSand") ? Evidence.NO : Evidence.UNKNOWN; - case 8217 -> name.equals("Rubber") ? Evidence.NO : Evidence.UNKNOWN; - case 8297 -> name.equals("Silverwood") ? Evidence.NO : Evidence.UNKNOWN; - case 9801 -> name.equals("Snow") ? Evidence.NO : Evidence.UNKNOWN; - case 8673 -> name.equals("Steeleaf") ? Evidence.NO : Evidence.UNKNOWN; - case 8651 -> name.equals("SteelGalvanized") ? Evidence.NO : Evidence.UNKNOWN; - case 8646 -> name.equals("SteelMagnetic") ? Evidence.NO : Evidence.UNKNOWN; - case 8196 -> name.equals("Teflon") ? Evidence.NO : Evidence.UNKNOWN; - case 8752 -> name.equals("Tritanium") ? Evidence.NO : Evidence.UNKNOWN; - case 8027 -> name.equals("TungsticAcid") ? Evidence.NO : Evidence.UNKNOWN; - case 8221 -> name.equals("Wood") ? Evidence.NO : Evidence.UNKNOWN; - case 8224 -> name.equals("WoodRubber") ? Evidence.NO : Evidence.UNKNOWN; - default -> Evidence.UNKNOWN; - }; - } -} diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedMineralSteamCrackingRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedMineralSteamCrackingRows.java index 536b79d10..ea07dc02d 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedMineralSteamCrackingRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedMineralSteamCrackingRows.java @@ -31,6 +31,12 @@ public final class SharedMineralSteamCrackingRows { private static final Set OWNED = Collections.newSetFromMap(new IdentityHashMap<>()); private static final Map STATUS = new IdentityHashMap<>(); + private record SourceWax(int id, String name) {} + private static final List SOURCE_WAXES = List.of( + new SourceWax(8235, "Wax"), + new SourceWax(8236, "WaxBee"), + new SourceWax(8238, "WaxParaffin"), + new SourceWax(8239, "WaxPlant")); private static boolean initialized; private SharedMineralSteamCrackingRows() {} @@ -65,7 +71,7 @@ public static void rebuild() { var snapshot = new Snapshot(); // These are source ANY.Wax factory members, not a mineral admission whitelist. // The original source binds each to 144 mB/U; unavailable wax fluids are skipped. - var waxes = ReviewedCinnabarFacts.sourceWaxes(); + var waxes = sourceWaxes(); for (GTMaterial alias : GTMaterialRegistry.allMaterials()) { GTMaterial material = alias.resolve(); if (!seen.add(material)) continue; @@ -93,8 +99,8 @@ public static void rebuild() { if (environment.kind() == SourcePurifiedCentrifugePlan.EnvironmentKind.FLUID) { var binding = environment.binding(); // Original first rounds U/18 UP, then multiplies that result by nine. - millibuckets[index] = OriginalMaterialFluidUnits.millibuckets( - OriginalMaterialFluidUnits.SOURCE_UNIT / 18, + millibuckets[index] = gregtech.content.material.catalog.MaterialFluidUnitFacts.millibuckets( + gregtech.content.material.catalog.MaterialFluidUnitFacts.SOURCE_UNIT / 18, binding.referenceSourceUnits(), binding.referenceMillibuckets(), true); if (millibuckets[index] < 0) { statuses.put(material, "UNRESOLVED:byproduct-volume-" + index); @@ -107,8 +113,8 @@ public static void rebuild() { int count = 0; for (GTMaterial wax : waxes) for (int scale : new int[]{9, 1}) { FluidStack waxFluid = OreFluidBindingAdapter.liquid(wax, - scale == 9 ? OriginalMaterialFluidUnits.SOURCE_UNIT - : OriginalMaterialFluidUnits.SOURCE_UNIT / 9, true); + scale == 9 ? gregtech.content.material.catalog.MaterialFluidUnitFacts.SOURCE_UNIT + : gregtech.content.material.catalog.MaterialFluidUnitFacts.SOURCE_UNIT / 9, true); if (waxFluid.isEmpty()) continue; FluidStack steam = GTFluids.stack("Steam", 160 * scale); FluidStack water = GTFluids.stack("Water", scale); @@ -146,6 +152,19 @@ public static void rebuild() { } } + private static List sourceWaxes() { + var values = new ArrayList(4); + for (SourceWax source : SOURCE_WAXES) { + var material = GTMaterialRegistry.get(source.name()); + if (material.isValid() + && !gregtech.engine.addon.AddonMaterials.owns(material) + && GTMaterialRegistry.isCoreMaterial(material) + && material.resolve().getId() == source.id + && material.resolve().getName().equals(source.name)) values.add(material.resolve()); + } + return List.copyOf(values); + } + private static final class Snapshot { final SharedPurifiedCentrifugeRows.Snapshot phases = new SharedPurifiedCentrifugeRows.Snapshot(); final Map>> explicit = new IdentityHashMap<>(); diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedOilSandRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedOilSandRows.java index eda8f691c..e20a186dd 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedOilSandRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedOilSandRows.java @@ -27,7 +27,7 @@ import static gregtech.content.recipe.SourceOreCrushingAdapter.Candidate; import static gregtech.content.recipe.SourceOreCrushingAdapter.NativeKind; import static gregtech.content.recipe.SourceOreCrushingAdapter.Domain; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; +import static gregtech.content.material.MaterialFactKeys.Decision; import static gregtech.content.recipe.SourceOilSandRules.*; /** The OilSand ore-registration Centrifuge event, independent of the Crusher/Hammer handlers. diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedOreCrushingRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedOreCrushingRows.java index d54a8f861..7bb1b1c15 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedOreCrushingRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedOreCrushingRows.java @@ -50,7 +50,7 @@ static void begin() { static Candidate candidate(GTMaterial material, ItemStack input, boolean raw) { if (startup == null || sealed) throw new IllegalStateException("Crushing capture is not open"); // Preserve the already reviewed raw Cinnabar helper and its baseline Recipe identity. - if (raw && ReviewedCinnabarFacts.supports(material)) return null; + if (raw && SourceCinnabarFollowonAdapter.supports(material)) return null; return SourceOreCrushingAdapter.candidate(material, input, raw, startup); } diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedOreWashingRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedOreWashingRows.java index d5df5995e..81b78feff 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedOreWashingRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedOreWashingRows.java @@ -6,6 +6,9 @@ import gregtech.content.data.FluidCatalog; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; +import gregtech.content.material.catalog.SourceWashingMaterialFacts; import gregtech.content.registry.GTBlocks; import gregtech.content.registry.GTFluids; import gregtech.content.registry.GTItems; @@ -29,6 +32,7 @@ import java.util.*; import java.util.function.BiFunction; import static gregtech.api.material.GTValues.U; +import static gregtech.content.material.MaterialFactKeys.Decision; import static gregtech.content.recipe.SourceOreWashingRules.*; /** Original Ores Bath/water Sluice, Handlers Petrotheum and explicit Cryotheum rows. @@ -140,11 +144,11 @@ private static void ores(GTMaterial m,Snapshot s,List out){ new FluidStack[]{sluice.copy()},size.ticks(),SLUICE_POWER)); } } - for(var tag:SourceOreWashingData.Tag.values()){ + for(var tag:SourceWashingMaterialFacts.Tag.values()){ var selection=selectByproduct(m,by,candidate->s.tag(candidate,tag),candidate->s.purified(Size.TINY,candidate,1).availability()); if(!s.ready(m,"bath/"+tag,selection.availability()))continue; GTMaterial product=selection.material(); - if(tag==SourceOreWashingData.Tag.MERCURY){ + if(tag==SourceWashingMaterialFacts.Tag.MERCURY){ for(Size size:Size.values()){ var outputs=bathOutputs(m,product,size,s);if(outputs==null)continue; var mercury=s.fluid("GenLiquid_Mercury",size.mercuryMb());if(!s.fluidReady(m,"mercury/"+size,mercury))continue; @@ -153,7 +157,7 @@ private static void ores(GTMaterial m,Snapshot s,List out){ } }else{ // Loader_Recipes_Ores names Firestone first; a retired reagent material is skipped, not fatal. - String[] reagents=tag==SourceOreWashingData.Tag.PERSULFATE?new String[]{"SodiumPersulfate","PotassiumPersulfate"} + String[] reagents=tag==SourceWashingMaterialFacts.Tag.PERSULFATE?new String[]{"SodiumPersulfate","PotassiumPersulfate"} :new String[]{"Firestone","Pyrotheum","Octine"}; for(String reagentName:reagents)for(BathShape shape:bathShapes()){ String route="bath/"+tag+"/"+reagentName+"/"+shape; @@ -161,7 +165,7 @@ private static void ores(GTMaterial m,Snapshot s,List out){ if(!s.ready(m,route,reagent.availability()))continue; var outputs=bathOutputs(m,product,shape.outputSize(),s);if(outputs==null)continue; FluidStack[] steam=new FluidStack[0]; - if(tag==SourceOreWashingData.Tag.FIRESTONE){ + if(tag==SourceWashingMaterialFacts.Tag.FIRESTONE){ var fluid=s.fluid("Steam",shape.outputSize().steamMb());if(!s.fluidReady(m,route,fluid))continue;steam=new FluidStack[]{fluid}; } var input=s.input(shape.input(),m,shape.inputCount());if(!s.ready(m,route,input.availability()))continue; @@ -252,7 +256,7 @@ NativeForm output(MaterialPrefix prefix,GTMaterial m,int count){ if(direct.availability()==Availability.UNKNOWN)return direct; ItemStack canonical=GTItems.getStack(prefix,m,count); ItemStack reviewed=SourceOreOutputRows.resolvingOutputs(()->SourceOreInputForms.reviewedOreOutput(prefix,m,count)); - if(ReviewedCrushedFormGeneration.excludedBuiltin(m,prefix,canonical)){ + if(SourceCrushedFormAdapter.excludedBuiltin(m,prefix,canonical)){ // That helper returns the canonical legacy stack only for ambiguous/unsupported aliases. if(!canonical.isEmpty()&&ItemStack.matches(canonical,reviewed))return NativeForm.unknown(); return reviewed.isEmpty()?NativeForm.absent():NativeForm.present(reviewed); @@ -279,10 +283,12 @@ NativeForm blockDust(GTMaterial m,int count){ ||form.material().resolve()!=m.resolve())return NativeForm.unknown(); stack.setCount(count);return NativeForm.present(stack); } - SourceOreWashingData.Decision tag(GTMaterial m,SourceOreWashingData.Tag tag){ + Decision tag(GTMaterial m,SourceWashingMaterialFacts.Tag tag){ if(m==null||!m.isValid()||!GTMaterialRegistry.isCoreMaterial(m.resolve())||AddonMaterials.owns(m.resolve())) - return SourceOreWashingData.Decision.UNKNOWN; - return SourceOreWashingData.decision(m.getId(),m.getName(),tag); + return Decision.UNKNOWN; + var rule=MaterialFactKeys.value(m,MaterialFactKeys.SOURCE_WASHING).orElse(null); + if(rule==null)return Decision.UNKNOWN; + return rule.tags().contains(tag)?Decision.YES:Decision.NO; } FluidStack fluid(String field,int amount){return checkedFluid(field,amount,definitions,fluidLookup);} } @@ -300,14 +306,15 @@ static FluidStack checkedFluid(String field,int amount,MapFluidCatalog.DistW;case "Sluice"->FluidCatalog.Sluice; case "Steam"->FluidCatalog.Steam;default->null;}; if(field.equals("GenLiquid_Mercury")){ - if(!ReviewedOreGeneratedFluids.mercury(entry))return FluidStack.EMPTY; + if(!SourceGeneratedFluidAdapter.mercury(entry))return FluidStack.EMPTY; }else if(entry!=builtin||!FluidCatalog.isBuiltInDefinition(entry))return FluidStack.EMPTY; // Reviewed original material identities determine unit conversion; names alone do not establish it. - var binding=switch(field){case "GenLiquid_Mercury"->ReviewedOreFluidBindings.liquid(800,"Mercury"); + var binding=switch(field){case "GenLiquid_Mercury"->MaterialFluidUnitFacts.binding( + GTMaterialRegistry.get("Mercury"),"liquid"); default->null;}; boolean materialLiquid=field.equals("GenLiquid_Mercury"); - if(materialLiquid&&(binding==null||!binding.field().equals(field) - ||!binding.registryPath().equals(entry.registryName())))return FluidStack.EMPTY; + if(materialLiquid&&(binding==null||!binding.fluidField().equals(field) + ||!binding.registryName().equals(entry.registryName())))return FluidStack.EMPTY; var stack=lookup.apply(field,amount);if(stack==null||stack.isEmpty()||stack.getAmount()!=amount)return FluidStack.EMPTY; String expected="gt6ce:"+FluidCatalog.sanitizePath(entry.registryName()); if(!BuiltInRegistries.FLUID.getKey(stack.getFluid()).toString().equals(expected))return FluidStack.EMPTY; diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedAcidRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedAcidRows.java index fd8a75277..a2ad3a110 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedAcidRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedAcidRows.java @@ -5,6 +5,7 @@ import gregtech.content.data.FluidCatalog; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.content.registry.GTFluids; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.GTMaterialRegistry; @@ -23,8 +24,8 @@ import static gregtech.content.recipe.SourceOreWashingRules.Availability; import static gregtech.content.recipe.SourcePurifiedAcidData.*; import static gregtech.content.recipe.SourcePurifiedAcidRules.*; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; -import static gregtech.content.recipe.SourceRecyclingFacts.Identity; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; /** Source Ores108-159 purified acid Bath calls, independent of ordinary ore washing gates. * First admission is deliberately after existing static/imported producers. Ownership is only @@ -158,7 +159,7 @@ private static final class Resolution implements Resolver { @Override public Availability fluid(Phase phase, long amount) { var key = new SourcePurifiedAcidData.Fluid(phase, amount); var result = fluids.computeIfAbsent(key, ignored -> snapshot.fluid(phase, amount)); - if (result.availability() == Availability.UNKNOWN) problem = "/phase:" + phase.nativeField(); + if (result.availability() == Availability.UNKNOWN) problem = "/phase:" + phase.name(); return result.availability(); } } @@ -170,7 +171,7 @@ private static boolean canonical(GTMaterial material) { } private static boolean sourceIdentity(GTMaterial material) { // This table supplies identity evidence only, never thermal target/flag permissions. - return canonical(material) && (SourceRecyclingFacts.find(material.getId(), material.getName()) != null + return canonical(material) && (gregtech.content.material.MaterialFactKeys.sourceRecycling(material).isPresent() || reviewedIdentity(identity(material))); } record NativeFluid(Availability availability, FluidStack stack) { @@ -216,28 +217,34 @@ GTMaterial material(Identity identity) { return canonical(material) && identity.matches(material.getId(), material.getName()) ? material : null; } NativeFluid fluid(Phase phase, long amount) { - if (phase == null || amount <= 0 || amount > Integer.MAX_VALUE || material(phase.material()) == null) + GTMaterial material = phase == null ? null : material(phase.material()); + if (material == null || amount <= 0 || amount > Integer.MAX_VALUE) return NativeFluid.unknown(); // Water is vanilla water; it has no GT catalog entry. if (phase == Phase.WATER) return NativeFluid.present(new FluidStack(Fluids.WATER, (int) amount)); - String field = phase.nativeField(); + String nativePhase = phase.state() == State.GAS ? "gas" : "liquid"; + var binding = MaterialFluidUnitFacts.binding(material, nativePhase); + if (binding == null + || binding.referenceSourceUnits() != gregtech.api.material.GTValues.U + || binding.referenceMillibuckets() != 1000) return NativeFluid.unknown(); + String field = binding.fluidField(); var entry = fluidDefinitions.get(field); if (entry == null || !FluidCatalog.canonicalField(field).equals(field) || FluidCatalog.get(field) != entry || entry.gas() != (phase.state() == State.GAS)) return NativeFluid.unknown(); if (phase == Phase.HYDROGEN) { if (entry != FluidCatalog.Hydrogen || !FluidCatalog.isBuiltInDefinition(entry)) return NativeFluid.unknown(); - if (!phase.material().name().equals(FluidCatalog.boundMaterial(entry.registryName()))) + if (!material.getName().equals(FluidCatalog.boundMaterial(entry.registryName()))) return NativeFluid.unknown(); } else if (!FluidCatalog.isGeneratedGasLiquidDefinition(field, entry) - || !phase.material().name().equals(entry.materialKey())) return NativeFluid.unknown(); - String expectedPath = "gt6ce:" + FluidCatalog.sanitizePath(entry.registryName()); - if (!phase.registryId().equals(expectedPath)) return NativeFluid.unknown(); + || !material.getName().equals(entry.materialKey())) return NativeFluid.unknown(); + String expectedPath = "gt6ce:" + FluidCatalog.sanitizePath(binding.registryName()); + if (!binding.registryName().equals(entry.registryName())) return NativeFluid.unknown(); var stack = lookup.apply(field, (int)amount); if (stack == null || stack.isEmpty() || stack.getAmount() != amount - || !BuiltInRegistries.FLUID.getKey(stack.getFluid()).toString().equals(phase.registryId())) + || !BuiltInRegistries.FLUID.getKey(stack.getFluid()).toString().equals(expectedPath)) return NativeFluid.unknown(); if (GTFluids.entryForFluid(stack.getFluid()) != entry) return NativeFluid.unknown(); - // All eighteen source phases are positively evidenced. A missing native output holder + // All seventeen source phases are positively evidenced. A missing native output holder // is UNKNOWN too, never source ABSENT that could silently discard a vitriol/gas product. return NativeFluid.present(stack); } diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedCentrifugeRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedCentrifugeRows.java index 3741e9db4..d38046664 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedCentrifugeRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedCentrifugeRows.java @@ -6,6 +6,8 @@ import gregtech.engine.recipe.Recipe; import gregtech.engine.recipe.RecipeMap; import gregtech.content.data.*; +import gregtech.content.material.MaterialFactKeys; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.content.registry.GTItems; import gregtech.content.registry.GTFluids; import gregtech.util.OM; @@ -157,21 +159,19 @@ private boolean defaultNoneCompatible(GTMaterial m,NoPhaseBinding source){ } } - // Source DATA only, not recipe/material admission: explicit fluids and default gas registrations - // cover the six ambient positive bindings in current539 input observations. Other phases defer. private record PhaseBinding(int id,String name,String phase,String field,String nativeId,int mb,int melting,int boiling){} - private static final List PHASES=List.of( - new PhaseBinding(21,"Helium3","gas","GenGas_Helium3","gt6ce:helium3",1000,1,4), - new PhaseBinding(90,"Fluorine","gas","GenGas_Fluorine","gt6ce:fluorine",1000,53,85), - new PhaseBinding(800,"Mercury","liquid","GenLiquid_Mercury","gt6ce:mercury",144,234,629), - new PhaseBinding(9791,"Honey","liquid","Honey","gt6ce:honey",1000,273,373), - new PhaseBinding(9793,"Honeydew","liquid","Honeydew","gt6ce:honeydew",1000,273,373), - new PhaseBinding(9802,"Ice","liquid","Ice","gt6ce:ice",1000,273,373)); - private static PhaseBinding binding(GTMaterial m,String phase){for(var b:PHASES)if(b.id==m.getId()&&b.name.equals(m.getName())&&(phase==null||b.phase.equals(phase)))return b;return null;} + private static PhaseBinding binding(GTMaterial m,String phase){ + var value=MaterialFactKeys.value(m,MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_PHASE).orElse(null); + if(value==null||(phase!=null&&!value.phase().equals(phase)))return null; + var unit=MaterialFluidUnitFacts.binding(m,value.phase()); + if(unit==null)return null; + return new PhaseBinding(m.getId(),m.getName(),value.phase(),unit.fluidField(), + "gt6ce:"+unit.registryName(),(int)unit.referenceMillibuckets(),value.meltingKelvin(),value.boilingKelvin()); + } private static boolean sourceBindingOwned(PhaseBinding binding){ var entry=FluidCatalog.get(binding.field); if(entry==null||!FluidCatalog.canonicalField(binding.field).equals(binding.field))return false; - if(binding.id==800)return ReviewedOreGeneratedFluids.mercury(entry); + if(binding.id==800)return SourceGeneratedFluidAdapter.mercury(entry); if(binding.id==21||binding.id==90)return FluidCatalog.isGeneratedGasLiquidDefinition(binding.field,entry) &&binding.name.equals(entry.materialKey())&&entry.gas() &&entry.registryName().equals(binding.nativeId.substring("gt6ce:".length())); @@ -196,16 +196,11 @@ static boolean sourceNoneMaterialCompatible(NoPhaseBinding source,SourceNoneFact return source.phase.equals("gas")?!facts.properties.contains(MaterialProperty.GAS) :!facts.properties.contains(MaterialProperty.LIQUID)&&!facts.properties.contains(MaterialProperty.MOLTEN); } - private static final List DEFAULT_NONE=List.of( - new NoPhaseBinding(1120,"Copernicium","liquid",150,357), - new NoPhaseBinding(1180,"Oganesson","gas",258,263), - - new NoPhaseBinding(9110,"Celestine","liquid",275,455), - new NoPhaseBinding(9199,"DuraniumHexafluoride","liquid",216,428), - new NoPhaseBinding(9801,"Snow","liquid",273,373), - new NoPhaseBinding(9851,"OilSand","liquid",100,400), - new NoPhaseBinding(9852,"CrudeOil","liquid",100,400)); - static NoPhaseBinding defaultNone(GTMaterial m){for(var d:DEFAULT_NONE)if(d.id==m.getId()&&d.name.equals(m.getName()))return d;return null;} + static NoPhaseBinding defaultNone(GTMaterial m){ + var value=MaterialFactKeys.value(m,MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT).orElse(null); + return value==null?null:new NoPhaseBinding(m.getId(),m.getName(),value.phase(), + value.meltingKelvin(),value.boilingKelvin()); + } private static Definition legacy(GTMaterial m){ if(!m.isValid()||!MaterialPrefix.crushed.isValidFor(m)||!MaterialPrefix.crushedCentrifuged.isValidFor(m))return null; // Preserve old producer suppression decisions only in its unresolved compatibility branch. diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedThermalRecyclingRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedThermalRecyclingRows.java index 7950410ed..8f664ec2e 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedThermalRecyclingRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedThermalRecyclingRows.java @@ -6,6 +6,8 @@ import gregtech.api.material.SmeltingMaterialHelper; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; +import gregtech.content.material.catalog.SourceRecyclingMaterialFacts; import gregtech.content.registry.GTFluids; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.GTMaterialRegistry; @@ -36,7 +38,8 @@ import java.util.Map; import java.util.Set; -import static gregtech.content.recipe.SourceRecyclingFacts.*; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.catalog.SourceRecyclingMaterialFacts.*; /** * The general source {@code RecyclingProcessing} listener for every admitted recyclable item @@ -57,7 +60,8 @@ */ final class SharedThermalRecyclingRows { private static final Logger LOGGER = LogUtils.getLogger(); - private static final long SOURCE_UNIT = gregtech.content.recipe.OriginalMaterialFluidUnits.SOURCE_UNIT; + private static final long SOURCE_UNIT = + gregtech.content.material.catalog.MaterialFluidUnitFacts.SOURCE_UNIT; private static final Map> OWNED = new IdentityHashMap<>(); private static final List DEFERRED = new ArrayList<>(); private static boolean initialized; @@ -197,7 +201,7 @@ private static List candidates() { for (var entry : materialItems) { Item item = entry.getKey(); ItemComposition data = entry.getValue(); - if (data == null || !data.bulkRecoveryAllowed() || data.components().isEmpty()) continue; + if (data == null || data.components().isEmpty()) continue; MaterialPrefix prefix = data.prefix(); if (prefix != null && ownedByAuditedProducer(prefix, data)) continue; if (!allows(prefix)) continue; @@ -231,14 +235,14 @@ private static Outcome plan(Candidate candidate, SourceThermalNativeAdapter.Snap .map(component -> component.material().resolve()) .anyMatch(AddonMaterials::owns)) return planDeclared(candidate); var targetUnits = new java.util.LinkedHashMap(); - var factsByTarget = new java.util.LinkedHashMap(); + var factsByTarget = new java.util.LinkedHashMap(); double weight = 0; try { for (MaterialComponent component : candidate.components()) { GTMaterial material = component.material().resolve(); if (!valid(material)) return Outcome.deferred(Reason.UNKNOWN_SOURCE_IDENTITY); - var facts = find(material.getId(), material.getName()); - if (facts == null) return Outcome.deferred(Reason.UNKNOWN_SOURCE_FACT); + var facts = MaterialFactKeys.sourceRecycling(material).orElse(null); + if (facts == null || !facts.inputEligible()) return Outcome.deferred(Reason.UNKNOWN_SOURCE_FACT); if (snapshot.materialOverride(material, facts) != null) return Outcome.deferred(Reason.MATERIAL_OVERRIDE); weight += SourceRecyclingMath.materialWeight(material.getDensity(), component.amount(), SOURCE_UNIT); @@ -249,7 +253,7 @@ private static Outcome plan(Candidate candidate, SourceThermalNativeAdapter.Snap || facts.blacklistedSmelter() != Decision.NO || facts.targetUnitsPerU() < 0) return Outcome.deferred(Reason.UNKNOWN_SOURCE_FACT); GTMaterial target = GTMaterialRegistry.get(facts.target().name()).resolve(); - var resolvedTargetFacts = find(facts.target().id(), facts.target().name()); + var resolvedTargetFacts = MaterialFactKeys.sourceRecycling(target).orElse(null); if (!valid(target) || target.getId() != facts.target().id() || !target.getName().equals(facts.target().name()) || resolvedTargetFacts == null) return Outcome.deferred(Reason.TARGET_IDENTITY_OVERRIDE); @@ -277,7 +281,7 @@ private static Outcome plan(Candidate candidate, SourceThermalNativeAdapter.Snap var chosen = phases.get(0); int millibuckets; try { - millibuckets = gregtech.content.recipe.OriginalMaterialFluidUnits.millibuckets( + millibuckets = gregtech.content.material.catalog.MaterialFluidUnitFacts.millibuckets( chosen.targetUnits(), chosen.phase().binding().referenceMaterialUnits(), chosen.phase().binding().millibuckets(), false); } catch (ArithmeticException invalid) { @@ -351,7 +355,7 @@ private static Outcome planDeclared(Candidate candidate) { int millibuckets; long ticks; try { - millibuckets = gregtech.content.recipe.OriginalMaterialFluidUnits.millibuckets( + millibuckets = gregtech.content.material.catalog.MaterialFluidUnitFacts.millibuckets( chosen.getValue(), binding.referenceUnits(), binding.referenceMillibuckets(), @@ -386,8 +390,8 @@ private static Outcome planDeclared(Candidate candidate) { * BLACKLISTED_SMELTER flag. */ private static boolean declaredMeltable(GTMaterial material) { - var facts = find(material.getId(), material.getName()); - if (facts != null) + var facts = MaterialFactKeys.sourceRecycling(material).orElse(null); + if (facts != null && facts.inputEligible()) return facts.melting() == Decision.YES && facts.blacklistedSmelter() == Decision.NO; return AddonMaterials.owns(material); } @@ -396,14 +400,14 @@ private record PhaseCandidate( GTMaterial target, long targetUnits, ResolvedPhase phase, - SourceRecyclingFacts.Facts targetFacts) {} + SourceRecyclingMaterialFacts.Facts targetFacts) {} private record ResolvedPhase( - SourceRecyclingFacts.Binding binding, FluidStack fluid, int temperature, boolean lava) {} + SourceRecyclingMaterialFacts.Binding binding, FluidStack fluid, int temperature, boolean lava) {} /** Mirrors the audited adapter's phase proof; a target without a phase is skipped by the source. */ private static ResolvedPhase resolvePhase( - GTMaterial target, SourceRecyclingFacts.Facts facts, SourceThermalNativeAdapter.Snapshot snapshot) { + GTMaterial target, SourceRecyclingMaterialFacts.Facts facts, SourceThermalNativeAdapter.Snapshot snapshot) { Phase phase = facts.phase(); if (phase.kind() == PhaseKind.UNKNOWN || phase.kind() == PhaseKind.OPTIONAL_EXTERNAL) return null; if (phase.kind() == PhaseKind.NO_DEFAULT_PHASE) return null; diff --git a/minecraft/src/main/java/gregtech/content/recipe/SingleItemSourceRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/SingleItemSourceRecipes.java index 949321a7b..f8751ab0c 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SingleItemSourceRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SingleItemSourceRecipes.java @@ -31,8 +31,6 @@ public static int register() { if (!INSTANCE.entries().isEmpty()) throw new IllegalStateException("Single-item source recipes registered twice"); INSTANCE.compounds(); - ItemMaterialRegistry.register( - own("dry_bark", 1).getItem(), null, GTMaterialRegistry.get("Bark"), GTValues.U / 2); INSTANCE.animalParts(); INSTANCE.meat(); INSTANCE.remains(); @@ -43,8 +41,6 @@ private void compounds() { for (var row : OriginalSingleItemCatalog.COMPOUNDS) { var input = own(row.item(), 1); var material = GTMaterialRegistry.get(row.material()); - // MultiItemRandomTools: each compound contains 1/9 U and fires into one nugget. - ItemMaterialRegistry.register(input.getItem(), null, material, GTValues.U / 9); smelt(row.item(), mat(MaterialPrefix.nugget, row.material(), 1), false); var target = material.getTargetSmeltingMaterial(); var output = gregtech.util.OM.ingotOrDust(target, material.getTargetSmeltingAmount() / 9); @@ -93,9 +89,6 @@ private void animalParts() { } private void meat() { - // MultiItemFood and Loader_Recipes_Food preserve the 2U scrap-meat payload. - ItemMaterialRegistry.register( - own("scrap_meat", 1).getItem(), null, GTMaterialRegistry.get("MeatRaw"), 2 * GTValues.U); add( "scrap_meat/grind", MachineRecipeMaps.Mortar, @@ -118,8 +111,6 @@ private void meat() { for (String state : List.of("raw", "cooked")) { String material = state.equals("raw") ? "MeatRaw" : "MeatCooked"; String id = state + "_meat_bar"; - ItemMaterialRegistry.register( - own(id, 1).getItem(), MaterialPrefix.ingot, GTMaterialRegistry.get(material), GTValues.U); add( id + "/compress", MachineRecipeMaps.Compressor, diff --git a/minecraft/src/main/java/gregtech/content/recipe/ReviewedCinnabarFacts.java b/minecraft/src/main/java/gregtech/content/recipe/SourceCinnabarFollowonAdapter.java similarity index 65% rename from minecraft/src/main/java/gregtech/content/recipe/ReviewedCinnabarFacts.java rename to minecraft/src/main/java/gregtech/content/recipe/SourceCinnabarFollowonAdapter.java index eed574ea9..63afb956f 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/ReviewedCinnabarFacts.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceCinnabarFollowonAdapter.java @@ -5,6 +5,7 @@ import gregtech.api.material.*; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTItems; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.*; @@ -19,33 +20,26 @@ * Source MT3709/w3803; Ores generic loop; Handlers145-150; reviewed oracle48fe504f. * No recipe is registered here; no list removal and no item/fluid ID changes. */ -public final class ReviewedCinnabarFacts implements SourceOreFollowonRows.Facts { - public static final ReviewedCinnabarFacts INSTANCE = new ReviewedCinnabarFacts(); +public final class SourceCinnabarFollowonAdapter implements SourceOreFollowonRows.Facts { + public static final SourceCinnabarFollowonAdapter INSTANCE = new SourceCinnabarFollowonAdapter(); - private ReviewedCinnabarFacts() {} + private SourceCinnabarFollowonAdapter() {} - private record Identity(int id, String name) {} - - private static final Identity CINNABAR = new Identity(9114, "Cinnabar"); - private static final Identity[] BYPRODUCTS = { - new Identity(8333, "Redstone"), - new Identity(160, "Sulfur"), - new Identity(8341, "Glowstone"), - new Identity(340, "Selenium") - }; - - private static boolean identity(GTMaterial m, Identity i) { + private static boolean identity(GTMaterial m, MaterialFactKeys.Identity i) { return m != null && m.isValid() && !AddonMaterials.owns(m) && GTMaterialRegistry.isCoreMaterial(m.resolve()) - && m.resolve().getId() == i.id - && m.resolve().getName().equals(i.name); + && m.resolve().getId() == i.id() + && m.resolve().getName().equals(i.name()); } - private static boolean hasExternalFormProfile() { + private static boolean hasExternalFormProfile(MaterialFactKeys.CinnabarFollowonRule rule) { // This bounded adapter is not an external unifier. Defer instead of manufacturing builtin replacements. - Set names = Set.of("Cinnabar", "Redstone", "Sulfur", "Glowstone", "Selenium", "SluiceSand"); + Set names = new HashSet<>(); + names.add(rule.cinnabar().name()); + rule.byproducts().forEach(value -> names.add(value.name())); + names.add(rule.sluiceSand().name()); if (AddonMaterials.acceptedForms().stream().anyMatch(f -> names.contains(f.materialName()))) return true; for (var item : gregtech.engine.material.ItemMaterialRegistry.entries().keySet()) { String ns = BuiltInRegistries.ITEM.getKey(item).getNamespace(); @@ -56,25 +50,37 @@ private static boolean hasExternalFormProfile() { return false; } + private static MaterialFactKeys.CinnabarFollowonRule cinnabarRule() { + var material = GTMaterialRegistry.get(9114); + if (!material.isValid() + || !material.getName().equals("Cinnabar") + || !GTMaterialRegistry.isCoreMaterial(material) + || AddonMaterials.owns(material)) return null; + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON) + .orElse(null); + } + public static boolean supports(GTMaterial m) { return INSTANCE.eligible(m) == YES; } @Override public SourceOreFollowonRows.Evidence eligible(GTMaterial m) { - if (!identity(m, CINNABAR) || hasExternalFormProfile()) return UNKNOWN; + var rule = cinnabarRule(); + if (rule == null || !identity(m, rule.cinnabar()) || hasExternalFormProfile(rule)) return UNKNOWN; m = m.resolve(); if (m.has(MaterialProperty.ANTIMATTER) || m.getToolQuality() != 0 || m.getOreMultiplier() != 1 || m.getOreProcessingMultiplier() != 1 - || !identity(m.getTargetCrushingMaterial(), CINNABAR) + || !identity(m.getTargetCrushingMaterial(), rule.cinnabar()) || m.getTargetCrushingAmount() != U - || !identity(m.getTargetPulverMaterial(), CINNABAR) + || !identity(m.getTargetPulverMaterial(), rule.cinnabar()) || m.getTargetPulverAmount() != U) return UNKNOWN; var by = m.getByProducts(); - if (by.size() != BYPRODUCTS.length) return UNKNOWN; - for (int i = 0; i < by.size(); i++) if (!identity(by.get(i), BYPRODUCTS[i])) return UNKNOWN; + if (by.size() != rule.byproducts().size()) return UNKNOWN; + for (int i = 0; i < by.size(); i++) + if (!identity(by.get(i), rule.byproducts().get(i))) return UNKNOWN; return YES; // proof is this source profile, not missing flags or current generated-form presence } @@ -90,10 +96,13 @@ public SourceOreFollowonRows.Evidence pulverizingCinnabar(GTMaterial m) { @Override public SourceOreFollowonRows.Environment environment(GTMaterial m, long units) { + var rule = cinnabarRule(); + if (rule == null || rule.byproducts().size() < 3) return new SourceOreFollowonRows.Environment(UNKNOWN, null); // Baseline source DEF_ENV_TEMP293 < melting500/388/500. Never infer from missing molten fluid. - int melt = identity(m, BYPRODUCTS[0]) + int melt = identity(m, rule.byproducts().get(0)) ? 500 - : identity(m, BYPRODUCTS[1]) ? 388 : identity(m, BYPRODUCTS[2]) ? 500 : -1; + : identity(m, rule.byproducts().get(1)) ? 388 + : identity(m, rule.byproducts().get(2)) ? 500 : -1; if (melt < 0 || m.resolve().getMeltingPoint() != melt) return new SourceOreFollowonRows.Environment(UNKNOWN, null); return new SourceOreFollowonRows.Environment(YES, null); @@ -102,10 +111,12 @@ public SourceOreFollowonRows.Environment environment(GTMaterial m, long units) { @Override public ItemStack direct(MaterialPrefix p, GTMaterial m, int n) { if (m == null || n < 1) return ItemStack.EMPTY; + var rule = cinnabarRule(); + if (rule == null) return ItemStack.EMPTY; // Source-backed forms used by this bounded rule slice; allow no arbitrary legacy-only graded form. - boolean base = identity(m, CINNABAR); + boolean base = identity(m, rule.cinnabar()); boolean by = false; - for (var id : BYPRODUCTS) by |= identity(m, id); + for (var id : rule.byproducts()) by |= identity(m, id); boolean ore = p == MaterialPrefix.crushed || p == MaterialPrefix.crushedTiny || p == MaterialPrefix.crushedPurified @@ -117,7 +128,7 @@ public ItemStack direct(MaterialPrefix p, GTMaterial m, int n) { || p == MaterialPrefix.dustSmall || p == MaterialPrefix.dustDiv72; boolean grade = p == MaterialPrefix.gem || p == MaterialPrefix.gemFlawless || p == MaterialPrefix.gemExquisite; - boolean sand = identity(m, new Identity(8102, "SluiceSand")); + boolean sand = identity(m, rule.sluiceSand()); if (!((base && (ore || dust || grade || p == MaterialPrefix.oreRaw)) || (by && (ore || dust)) || (sand && dust))) return ItemStack.EMPTY; @@ -126,13 +137,11 @@ public ItemStack direct(MaterialPrefix p, GTMaterial m, int n) { @Override public ItemStack blockDust(GTMaterial m, int n) { - if (!identity(m, CINNABAR)) return ItemStack.EMPTY; + var rule = cinnabarRule(); + if (rule == null || !identity(m, rule.cinnabar())) return ItemStack.EMPTY; var block = BuiltInRegistries.BLOCK.get( ResourceLocation.parse("gt6ce:" + BlockMaterialPrefix.blockDust.getBlockId(m.resolve()))); return block == Blocks.AIR ? ItemStack.EMPTY : new ItemStack(block, n); } - public static List sourceWaxes() { - return SourceWaxMaterials.materials(); - } } diff --git a/minecraft/src/main/java/gregtech/content/recipe/ReviewedCrushedFormGeneration.java b/minecraft/src/main/java/gregtech/content/recipe/SourceCrushedFormAdapter.java similarity index 69% rename from minecraft/src/main/java/gregtech/content/recipe/ReviewedCrushedFormGeneration.java rename to minecraft/src/main/java/gregtech/content/recipe/SourceCrushedFormAdapter.java index 964fd2573..5eec76cce 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/ReviewedCrushedFormGeneration.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceCrushedFormAdapter.java @@ -2,6 +2,7 @@ import gregtech.api.material.*; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTItems; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.*; @@ -12,36 +13,17 @@ * Recipe-local only: existing registry IDs and logical prefix validity remain unchanged. * This is NOT ORES-property evidence; oreRaw, rock and dust are never excluded here. */ -public final class ReviewedCrushedFormGeneration { - private ReviewedCrushedFormGeneration() {} +public final class SourceCrushedFormAdapter { + private SourceCrushedFormAdapter() {} public static boolean sourceExcluded(GTMaterial material, MaterialPrefix prefix) { - if (material == null || !excludedPrefix(prefix)) return false; + if (material == null || prefix == null) return false; material = material.resolve(); if (!material.isValid() || !GTMaterialRegistry.isCoreMaterial(material) || AddonMaterials.owns(material)) return false; - String expected = switch (material.getId()) { - case 2220 -> "Adamantium"; - case 260 -> "Iron"; - case 140 -> "Silicon"; - case 130 -> "Aluminium"; - case 220 -> "Titanium"; - case 740 -> "Tungsten"; - case 90 -> "Fluorine"; - case 730 -> "Tantalum"; - case 410 -> "Niobium"; - default -> null; - }; - return expected != null && expected.equals(material.getName()); - } - - public static boolean excludedPrefix(MaterialPrefix prefix) { - return prefix == MaterialPrefix.crushed - || prefix == MaterialPrefix.crushedTiny - || prefix == MaterialPrefix.crushedPurified - || prefix == MaterialPrefix.crushedPurifiedTiny - || prefix == MaterialPrefix.crushedCentrifuged - || prefix == MaterialPrefix.crushedCentrifugedTiny; + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_CRUSHED_EXCLUSIONS) + .map(rule -> rule.excludes(prefix.getName())) + .orElse(false); } /** Conservative builtin ownership check. External/accepted/changed metadata are UNKNOWN. @@ -66,7 +48,6 @@ public static boolean excludedBuiltin(GTMaterial material, MaterialPrefix prefix var explicit = ItemMaterialRegistry.base(canonical.getItem()).orElse(null); if (explicit != null && (explicit.prefix() != prefix - || !explicit.bulkRecoveryAllowed() || explicit.components().size() != 1 || explicit.material().resolve() != material || explicit.amount() != prefix.getMaterialWeight())) return false; diff --git a/minecraft/src/main/java/gregtech/content/recipe/ReviewedCinnabarThermalRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/SourceDustThermalRecipes.java similarity index 96% rename from minecraft/src/main/java/gregtech/content/recipe/ReviewedCinnabarThermalRecipes.java rename to minecraft/src/main/java/gregtech/content/recipe/SourceDustThermalRecipes.java index 3853e8bd4..1a6c67838 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/ReviewedCinnabarThermalRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceDustThermalRecipes.java @@ -18,8 +18,8 @@ //?} import static gregtech.api.material.GTValues.U; /** Bounded source thermal adapter for whole dust metal and reviewed Ti/Fe dust fractions. */ -public final class ReviewedCinnabarThermalRecipes { - private ReviewedCinnabarThermalRecipes(){} +public final class SourceDustThermalRecipes { + private SourceDustThermalRecipes(){} private record MetalFraction(MaterialPrefix prefix,long amount,int millibuckets,long titaniumTicks,long ironTicks){} private static final MetalFraction[] METAL_FRACTIONS={ new MetalFraction(MaterialPrefix.dustSmall,U/4,36,129,207), @@ -34,7 +34,7 @@ public static boolean emitIfSupported(GTMaterial material){ private static boolean emitWholeDustMetal(GTMaterial material){ if(material==null||!material.isValid())return false; material=material.resolve();String field="GenMolten_"+material.getName(); - if(!ReviewedOreGeneratedFluids.wholeDustMetal(material,RegisteredFluids.get(field)))return false; + if(!SourceGeneratedFluidAdapter.wholeDustMetal(material,RegisteredFluids.get(field)))return false; var input=GTItems.getStack(MaterialPrefix.dust,material,1); // Both native registrars install an explicit self/dust/U composition for every material item. // Exact equivalent compositions are harmless; changed/mixed/unrecoverable bindings still defer. diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceExtruderRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/SourceExtruderRecipes.java index af22330d2..317101406 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceExtruderRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceExtruderRecipes.java @@ -280,7 +280,8 @@ public static int register(GTMaterial material) { // no original eligibility or low-heat permission is fabricated for them. if (profile == null) { if (!material.has(MaterialProperty.SMITHABLE)) return 0; - profile = new SourceExtrusionRules.Profile(true, false, true, "", GTValues.U); + profile = new gregtech.content.material.catalog.SourceExtrusionMaterialFacts.Profile( + true, false, true, "", GTValues.U); } if (!profile.extrudable() || profile.forgingAmount() < GTValues.U) return 0; GTMaterial target = SourceExtrusionRules.target(material, profile); diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceFurnaceNativeAdapter.java b/minecraft/src/main/java/gregtech/content/recipe/SourceFurnaceNativeAdapter.java index 293662a0a..5fc9cd338 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceFurnaceNativeAdapter.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceFurnaceNativeAdapter.java @@ -8,6 +8,7 @@ import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; import gregtech.content.data.generated.MaterialWorkability; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTBlocks; import gregtech.engine.material.MaterialFormItem; import gregtech.engine.prefix.BlockMaterialPrefix; @@ -21,7 +22,7 @@ import java.util.Map; import java.util.Optional; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; +import static gregtech.content.material.MaterialFactKeys.Decision; /** The native block branch of Loader_OreProcessing, not the oreRaw form listener. * Source permissions govern only this producer; they grant no authority to delete cooking rows. @@ -51,9 +52,12 @@ static boolean earlyFormAllowed(MaterialPrefix prefix, GTMaterial material, Item if (material == null || !material.isValid() || input == null || input.isEmpty()) return false; if (nativeForm(prefix, material, input)) return OreSourcePolicy.furnaceInput(material) && !OreSourcePolicy.usesReviewedFurnaceListener(material); - var old = ReviewedOreSourceProfile.decision(material, ReviewedOreSourceProfile.Rule.FURNACE); - return old.orLegacy(material.has(MaterialProperty.MELTING)) - && !(old == ReviewedOreSourceProfile.Decision.YES && FurnaceSmeltingRules.legacyAllows(material)); + var decision = MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_FURNACE) + .orElse(MaterialFactKeys.Decision.UNKNOWN); + return (decision == Decision.UNKNOWN + ? material.has(MaterialProperty.MELTING) + : decision == Decision.YES) + && !(decision == Decision.YES && FurnaceSmeltingRules.legacyAllows(material)); } static boolean listenerAllows(MaterialPrefix prefix, GTMaterial material, ItemStack input) { diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceGemGradeResolver.java b/minecraft/src/main/java/gregtech/content/recipe/SourceGemGradeResolver.java index 49b040807..7fb0a1c04 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceGemGradeResolver.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceGemGradeResolver.java @@ -2,6 +2,7 @@ import gregtech.api.material.GTMaterial; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTItems; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.ItemMaterialRegistry; @@ -49,10 +50,13 @@ public static ItemStack gradeOrGem( external = stack; } if (!external.isEmpty()) return external; - var decision = ReviewedSiftingGemForms.decision(material, prefix); - if (decision == ReviewedOreSourceProfile.Decision.UNKNOWN) - decision = ReviewedOreSourceProfile.decision(material, ReviewedOreSourceProfile.Rule.GRADED_GEM); - if (decision != ReviewedOreSourceProfile.Decision.NO && !canonical.isEmpty()) return canonical; + var exclusions = MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_SIFTING_EXCLUSIONS) + .orElse(new MaterialFactKeys.PrefixExclusions(java.util.Set.of())); + var decision = exclusions.excludes(prefix.getName()) + ? MaterialFactKeys.Decision.NO + : MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_GRADED_GEM) + .orElse(MaterialFactKeys.Decision.UNKNOWN); + if (decision != MaterialFactKeys.Decision.NO && !canonical.isEmpty()) return canonical; return copyAmount(ordinaryGem, fallbackCount); } diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceGeneratedFluidAdapter.java b/minecraft/src/main/java/gregtech/content/recipe/SourceGeneratedFluidAdapter.java new file mode 100644 index 000000000..b612b9187 --- /dev/null +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceGeneratedFluidAdapter.java @@ -0,0 +1,63 @@ +package gregtech.content.recipe; + +import gregtech.api.material.GTMaterial; +import gregtech.api.material.MaterialProperty; +import gregtech.content.data.FluidCatalog; +import gregtech.content.material.MaterialFactKeys; +import gregtech.engine.addon.AddonMaterials; +import gregtech.engine.material.GTMaterialRegistry; + +/** Native fingerprint checks for generated fluids declared by material facts. */ +public final class SourceGeneratedFluidAdapter { + private SourceGeneratedFluidAdapter() {} + + public static boolean mercury(FluidCatalog.FluidEntry entry) { + return checked(GTMaterialRegistry.get("Mercury"), entry, false); + } + + public static boolean wholeDustMetal(GTMaterial material, FluidCatalog.FluidEntry entry) { + return checked(material, entry, true); + } + + private static boolean checked(GTMaterial material, FluidCatalog.FluidEntry entry, boolean wholeDust) { + if (material == null || !material.isValid() || entry == null) return false; + material = material.resolve(); + if (!GTMaterialRegistry.isCoreMaterial(material) || AddonMaterials.owns(material)) return false; + var rule = MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_GENERATED_FLUID) + .flatMap(rules -> rules.rules().stream() + .filter(value -> value.wholeDustMetal() == wholeDust) + .findFirst()) + .orElse(null); + if (rule == null + || !FluidCatalog.canonicalField(rule.field()).equals(rule.field()) + || !entry.registryName().equals(rule.registryPath()) + || !material.getName().equals(entry.materialKey()) + || entry.temperature() != rule.temperature() + || entry.density() != 0 + || entry.glint() + || entry.gas()) return false; + if (wholeDust) { + var target = material.getTargetSmeltingMaterial(); + if (target == null + || target.resolve() != material + || material.getTargetSmeltingAmount() != gregtech.api.material.GTValues.U + || material.getMeltingPoint() != rule.temperature() + || material.getDensity() != rule.materialDensity() + || !material.has(MaterialProperty.MELTING) + || material.has(MaterialProperty.ANTIMATTER) + || !FluidCatalog.isGeneratedMoltenDefinition(rule.field(), entry) + || entry.textureMode() != FluidCatalog.FluidTextureMode.GENERIC_MOLTEN + || !entry.tintTexture() + || entry.viscosity() != 0 + || entry.luminosity() != 10 + || entry.flags() != FluidCatalog.FluidFlags.LIQUID) return false; + } else if (!FluidCatalog.isGeneratedGasLiquidDefinition(rule.field(), entry) + || entry.textureMode() != FluidCatalog.FluidTextureMode.DEDICATED + || entry.tintArgb() != 0 + || !entry.tintTexture() + || entry.viscosity() != 0 + || entry.luminosity() != 0 + || entry.flags() != FluidCatalog.FluidFlags.LIQUID) return false; + return true; + } +} diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceLensRecipeItems.java b/minecraft/src/main/java/gregtech/content/recipe/SourceLensRecipeItems.java new file mode 100644 index 000000000..b5cc6db12 --- /dev/null +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceLensRecipeItems.java @@ -0,0 +1,22 @@ +package gregtech.content.recipe; + +import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.catalog.SourceLensMaterialFacts.Color; +import gregtech.content.registry.GTItems; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.world.item.ItemStack; + +/** Native lens holders selected from material-owned lens roles. */ +public final class SourceLensRecipeItems { + private SourceLensRecipeItems() {} + + public static List lenses(Color color) { + var result = new ArrayList(); + for (var material : SourceLensRoles.materials(color)) { + var lens = GTItems.getStack(MaterialPrefix.lens, material, 1); + if (!lens.isEmpty()) result.add(lens); + } + return List.copyOf(result); + } +} diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceOreCrushingAdapter.java b/minecraft/src/main/java/gregtech/content/recipe/SourceOreCrushingAdapter.java index 4588ec760..2564382b0 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceOreCrushingAdapter.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceOreCrushingAdapter.java @@ -3,7 +3,9 @@ import gregtech.api.material.GTMaterial; import gregtech.api.material.MaterialProperty; import gregtech.content.block.*; +import gregtech.content.block.stone.OreHostFacts; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTBlocks; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.GTMaterialRegistry; @@ -31,8 +33,8 @@ import static gregtech.content.recipe.SharedOreWashingRows.NativeForm; import static gregtech.content.recipe.SourceOreWashingRules.Availability; import static gregtech.content.recipe.SourceOreCrushingRules.*; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; -import static gregtech.content.recipe.SourceRecyclingFacts.Identity; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; /** Native ownership and host decoding for the source ore handlers, not a global ore unifier. */ final class SourceOreCrushingAdapter { @@ -100,12 +102,12 @@ static Outcome definitions(Candidate candidate, Machine machine, Snapshot s) { // example); one row with a host-set predicate covers all of them, as the source does. var hostsByProfile = new LinkedHashMap>(); for (OreHostStone host : OreHostStone.values()) { - if (SourceOreCrushingFacts.hostDecision(host.id()) != Decision.YES) continue; - var profile = SourceOreCrushingFacts.hostProfile(host.id()); + if (OreHostFacts.hostDecision(host.id()) != Decision.YES) continue; + var profile = OreHostFacts.hostProfile(host.id()); hostsByProfile.computeIfAbsent(profile.sourcePrefix(), ignored -> new ArrayList<>()).add(host); } for (var hosts : hostsByProfile.values()) { - var profile = SourceOreCrushingFacts.hostProfile(hosts.get(0).id()); + var profile = OreHostFacts.hostProfile(hosts.get(0).id()); var gangue = s.gangueList(profile); if (gangue == null) return none(Action.LEGACY_UNSUPPORTED, "gangue-provenance:" + hosts.get(0).id()); @@ -123,7 +125,7 @@ static Outcome definitions(Candidate candidate, Machine machine, Snapshot s) { }; Recipe row = make(machine, representative, result, matches, s); if (row == null) return none(Action.DEFERRED_NO_ROW, "native-normalization"); - if (SourceOreCrushingFacts.hasBrokenSourcePair(hosts.get(0).id())) { + if (OreHostFacts.hasBrokenSourcePair(hosts.get(0).id())) { var alternatives = new ArrayList(); for (OreHostStone host : hosts) { alternatives.add(OreBlock.withStone(candidate.input(), block.stateFor(host))); @@ -143,7 +145,7 @@ static Outcome definitions(Candidate candidate, Machine machine, Snapshot s) { if (candidate.kind() == NativeKind.FIXED_STONE) { String host = s.vanillaHost(candidate.input()); if (!"none".equals(host)) { - var profile = SourceOreCrushingFacts.hostProfile(host); + var profile = OreHostFacts.hostProfile(host); Gangue fixed = profile == null ? null : s.gangue(profile); if (fixed == null) return none(Action.LEGACY_UNSUPPORTED, "stone-gangue-provenance"); gangue.add(fixed); @@ -214,10 +216,10 @@ private static ItemStack[] copies(ItemStack[] stacks) { /** Strict evidence reader, intentionally not OreHostStone.byId's unknown-to-STONE convenience. */ static HostSelection classifyHost(ItemStack stack) { HostData data = hostData(stack); - Decision host = SourceOreCrushingFacts.hostDecision(data.host()); + Decision host = OreHostFacts.hostDecision(data.host()); if (host == Decision.NO) return new HostSelection(Domain.SOURCE_NO, data.host(), data.broken()); if (!data.knownMode() || host == Decision.UNKNOWN - || data.broken() && !SourceOreCrushingFacts.hasBrokenSourcePair(data.host())) + || data.broken() && !OreHostFacts.hasBrokenSourcePair(data.host())) return new HostSelection(Domain.UNKNOWN_HOST, data.host(), data.broken()); return new HostSelection(Domain.SOURCE_PROFILE, data.host(), data.broken()); } @@ -260,7 +262,7 @@ private record FormKey(Form form, GTMaterial material) {} @Override boolean identity(GTMaterial material) { return material != null && material.isValid() && material.resolve() == material && GTMaterialRegistry.isCoreMaterial(material) && !AddonMaterials.owns(material) - && SourceOreCrushingFacts.pulverizingCinnabar(material.getId(), material.getName()) != Decision.UNKNOWN; + && MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_ORE_CRUSHING).isPresent(); } boolean context(GTMaterial material) { // OilSand's Centrifuge event does not disable these independent source handlers. @@ -314,7 +316,7 @@ private static boolean special(net.minecraft.world.level.block.Block block) { } private static boolean composition(ItemStack input, MaterialPrefix prefix, GTMaterial material, long amount, boolean optional) { var data = ItemMaterialRegistry.base(input.getItem()).orElse(null); - return data == null ? optional : data.bulkRecoveryAllowed() && data.prefix() == prefix && data.components().size() == 1 + return data == null ? optional : data.prefix() == prefix && data.components().size() == 1 && data.material().resolve() == material && data.amount() == amount; } @Override GTMaterial target(GTMaterial material) { @@ -325,22 +327,22 @@ private static boolean composition(ItemStack input, MaterialPrefix prefix, GTMat int processingMultiplier(GTMaterial material) { return material.getOreProcessingMultiplier(); } Input input(GTMaterial material, GTMaterial target) { return new Input(id(material), id(target), amount(material), oreMultiplier(material), processingMultiplier(material), - quality(material), new Bonus(SourceOreCrushingFacts.pulverizingCinnabar(material.getId(), material.getName()), + quality(material), new Bonus(crushing(material).pulverizing(), byproduct(material, 800, "Mercury"), byproduct(material, 9114, "Cinnabar"), byproduct(material, 8333, "Redstone")), - SourceOreCrushingFacts.hexorium(material.getId(), material.getName())); + crushing(material).hexorium()); } private boolean byproduct(GTMaterial material, int id, String name) { return material.getByProducts().stream().map(GTMaterial::resolve) .anyMatch(m -> identity(m) && m.getId() == id && m.getName().equals(name)); } /** Null is an unresolved gangue identity; an empty list is a source host without gangue. */ - List gangueList(SourceOreCrushingFacts.HostProfile profile) { + List gangueList(OreHostFacts.HostProfile profile) { if (!profile.hasGangue()) return List.of(); Gangue gangue = gangue(profile); return gangue == null ? null : List.of(gangue); } - Gangue gangue(SourceOreCrushingFacts.HostProfile profile) { + Gangue gangue(OreHostFacts.HostProfile profile) { GTMaterial material = profile.gangueMaterial() == null ? null : material(profile.gangueMaterial()); GTMaterial target = material == null ? null : target(material); return !identity(material) || !identity(target) ? null @@ -352,6 +354,9 @@ GTMaterial material(Identity identity) { && identity(material) ? material : null; } Availability available(Form form, Identity material, int count) { return resolve(form, material).availability(); } + private MaterialFactKeys.OreCrushingFact crushing(GTMaterial material) { + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_ORE_CRUSHING).orElseThrow(); + } ItemStack stack(Stack stack) { NativeForm resolved = resolve(stack.form(), stack.material()); if (resolved.availability() != Availability.PRESENT) return ItemStack.EMPTY; diff --git a/minecraft/src/main/java/gregtech/content/recipe/ReviewedOreShredderFacts.java b/minecraft/src/main/java/gregtech/content/recipe/SourceOreFollowonAdapter.java similarity index 77% rename from minecraft/src/main/java/gregtech/content/recipe/ReviewedOreShredderFacts.java rename to minecraft/src/main/java/gregtech/content/recipe/SourceOreFollowonAdapter.java index 060f53cb3..fbf5aa5f1 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/ReviewedOreShredderFacts.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceOreFollowonAdapter.java @@ -5,6 +5,7 @@ import gregtech.api.material.*; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTItems; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.*; @@ -16,25 +17,10 @@ * The roster is independently reviewed; Centrifuge byproducts and ambient phases do not own these rows. * No claims for foreign/unknown forms, non-self targets, other input families or other machines. */ -public final class ReviewedOreShredderFacts implements SourceOreFollowonRows.Facts { - public static final ReviewedOreShredderFacts INSTANCE = new ReviewedOreShredderFacts(); +public final class SourceOreFollowonAdapter implements SourceOreFollowonRows.Facts { + public static final SourceOreFollowonAdapter INSTANCE = new SourceOreFollowonAdapter(); - private ReviewedOreShredderFacts() {} - - private record Profile(int id, String name, int quality, boolean mortar) {} - - private static final List PROFILES = List.of( - new Profile(290, "Copper", 0, true), - new Profile(9117, "Galena", 0, true), - new Profile(8346, "NetherQuartz", 3, true), - new Profile(9111, "Chalcopyrite", 0, true), - new Profile(9145, "Pentlandite", 0, true), - new Profile(9130, "Sphalerite", 0, true), - new Profile(9132, "Tetrahedrite", 0, true), - new Profile(9125, "Pyrite", 0, true), - new Profile(280, "Nickel", 2, true), - new Profile(9116, "Cooperite", 0, true), - new Profile(9137, "YellowLimonite", 0, true)); + private SourceOreFollowonAdapter() {} private static final List INPUTS = List.of( MaterialPrefix.crushed, MaterialPrefix.crushedPurified, @@ -45,12 +31,11 @@ private record Profile(int id, String name, int quality, boolean mortar) {} private static final List OUTPUTS = List.of(MaterialPrefix.dust, MaterialPrefix.dustSmall, MaterialPrefix.dustTiny, MaterialPrefix.dustDiv72); - private static Profile profile(GTMaterial material) { + private static MaterialFactKeys.OreShredderProfile profile(GTMaterial material) { if (material == null || !material.isValid()) return null; var m = material.resolve(); if (!GTMaterialRegistry.isCoreMaterial(m) || AddonMaterials.owns(m)) return null; - for (var row : PROFILES) if (m.getId() == row.id() && m.getName().equals(row.name())) return row; - return null; + return MaterialFactKeys.value(m, MaterialFactKeys.SOURCE_ORE_SHREDDER).orElse(null); } private static boolean usedPrefix(String prefix) { @@ -58,15 +43,15 @@ private static boolean usedPrefix(String prefix) { || OUTPUTS.stream().anyMatch(p -> p.getName().equals(prefix)); } - private static boolean externalForms(Profile row) { + private static boolean externalForms(GTMaterial material) { if (AddonMaterials.acceptedForms().stream() - .anyMatch(f -> f.materialName().equals(row.name()) && usedPrefix(f.prefixName()))) return true; + .anyMatch(f -> f.materialName().equals(material.getName()) && usedPrefix(f.prefixName()))) return true; for (var item : ItemMaterialRegistry.entries().keySet()) { String namespace = BuiltInRegistries.ITEM.getKey(item).getNamespace(); if (namespace.equals("gt6ce") || namespace.equals("minecraft")) continue; var form = MaterialEquivalence.form(new ItemStack(item)); if (form != null - && form.material().resolve().getName().equals(row.name()) + && form.material().resolve().getName().equals(material.getName()) && usedPrefix(form.prefix().getName())) return true; } return false; @@ -98,7 +83,7 @@ public SourceOreFollowonRows.Evidence eligible(GTMaterial material) { || m.getToolQuality() != row.quality() || m.getTargetPulverMaterial().resolve() != m || m.getTargetPulverAmount() != U - || externalForms(row)) return UNKNOWN; + || externalForms(m)) return UNKNOWN; // MORTAR/ORES are positive source facts, not inferred from port item existence. for (var prefix : INPUTS) if (nativeForm(prefix, m, 1).isEmpty()) return UNKNOWN; for (var prefix : OUTPUTS) if (nativeForm(prefix, m, 1).isEmpty()) return UNKNOWN; diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceOreInputForms.java b/minecraft/src/main/java/gregtech/content/recipe/SourceOreInputForms.java index 5eff68953..1864bb8d7 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceOreInputForms.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceOreInputForms.java @@ -79,7 +79,7 @@ public static ItemStack reviewedOreOutput(MaterialPrefix prefix, GTMaterial mate material = material.resolve(); ItemStack canonical = gregtech.content.registry.GTItems.getStack(prefix, material, count); boolean excluded = SourceOreOutputRows.resolving() - && ReviewedCrushedFormGeneration.excludedBuiltin(material, prefix, canonical); + && SourceCrushedFormAdapter.excludedBuiltin(material, prefix, canonical); Evidence evidence = (material.getId() == 8500 && material.getName().equals("Stone")) || excluded ? Evidence.NO : Evidence.UNKNOWN; diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceOreMacerationAdapter.java b/minecraft/src/main/java/gregtech/content/recipe/SourceOreMacerationAdapter.java index f9f6d6a0a..a9a17a245 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceOreMacerationAdapter.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceOreMacerationAdapter.java @@ -1,13 +1,14 @@ package gregtech.content.recipe; +import static gregtech.content.material.MaterialFactKeys.Decision; import static gregtech.content.recipe.SharedOreWashingRows.NativeForm; import static gregtech.content.recipe.SourceOreWashingRules.Availability; -import static gregtech.content.recipe.SourceRecyclingFacts.Decision; import gregtech.api.material.GTMaterial; import gregtech.api.material.MaterialProperty; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; import gregtech.content.registry.GTItems; import gregtech.engine.addon.AddonMaterials; import gregtech.engine.material.GTMaterialRegistry; @@ -133,7 +134,6 @@ static class Snapshot { for (var part : data.components()) { GTMaterial material = part.material().resolve(); if (!namespace.equals("gt6ce") - || !data.bulkRecoveryAllowed() || data.components().size() != 1 || data.amount() != data.prefix().getMaterialWeight() || !SourceFurnaceNativeAdapter.nativeForm( @@ -158,16 +158,19 @@ boolean identity(GTMaterial material) { var resolved = material.resolve(); return GTMaterialRegistry.isCoreMaterial(resolved) && !AddonMaterials.owns(resolved) - && SourceRecyclingFacts.find(resolved.getId(), resolved.getName()) != null; + && MaterialFactKeys.sourceRecycling(resolved).isPresent(); } boolean legacyContinuation(GTMaterial material) { // Preserve all existing dormant/startup/late-activation choices, not just today's inactive subset. - return ReviewedOreInputProfile.decision(material) == ReviewedOreInputProfile.Evidence.NO; + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_ORE_INPUT) + .orElse(MaterialFactKeys.Decision.UNKNOWN) + == MaterialFactKeys.Decision.NO; } Decision mortar(GTMaterial material) { - return SourceOreMacerationFacts.mortar(material.getId(), material.getName()); + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_MACERATION) + .orElse(MaterialFactKeys.Decision.UNKNOWN); } GTMaterial target(GTMaterial material) { @@ -190,7 +193,6 @@ NativeForm direct(MaterialPrefix prefix, GTMaterial material) { if (!SourceFurnaceNativeAdapter.nativeForm(prefix, material, selected)) return NativeForm.unknown(); var data = ItemMaterialRegistry.base(selected.getItem()).orElse(null); if (data == null - || !data.bulkRecoveryAllowed() || data.prefix() != prefix || data.components().size() != 1 || data.material().resolve() != material.resolve() diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceOreOutputRows.java b/minecraft/src/main/java/gregtech/content/recipe/SourceOreOutputRows.java index b8549458c..633afd611 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceOreOutputRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceOreOutputRows.java @@ -23,7 +23,7 @@ private record Key(GTMaterial material, String producer, RecipeMap map) {} public static boolean affects(List materials) { return materials.stream() .anyMatch(material -> - ReviewedCrushedFormGeneration.sourceExcluded(material, MaterialPrefix.crushedPurifiedTiny)); + SourceCrushedFormAdapter.sourceExcluded(material, MaterialPrefix.crushedPurifiedTiny)); } public static void define(GTMaterial material, String producer, RecipeMap map, Supplier admission) { diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceThermalNativeAdapter.java b/minecraft/src/main/java/gregtech/content/recipe/SourceThermalNativeAdapter.java index cb8c6f275..9ee58ac10 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceThermalNativeAdapter.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceThermalNativeAdapter.java @@ -5,6 +5,8 @@ import gregtech.content.data.FluidCatalog; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialFactKeys; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.content.item.MaterialItem; import gregtech.content.registry.GTItems; import gregtech.content.registry.GTFluids; @@ -26,7 +28,9 @@ import java.util.*; import java.util.function.BiFunction; import static gregtech.api.material.GTValues.U; -import static gregtech.content.recipe.SourceRecyclingFacts.*; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; +import static gregtech.content.material.catalog.SourceRecyclingMaterialFacts.*; /** Shared source thermal proof for the existing OM-selected1U input and audited exact form inputs. * No registrations, material mutations, map sweeps or new global unit conventions. @@ -82,9 +86,9 @@ static Outcome inspectForm(MaterialPrefix prefix,GTMaterial raw,ItemStack select private static Outcome inspect(GTMaterial raw,ItemStack selected,Snapshot snapshot,MaterialPrefix prefix){ if(raw==null)return unsupported(Reason.UNKNOWN_SOURCE_IDENTITY); if(selected==null||selected.isEmpty())return deferred(Reason.INPUT_ABSENT); - GTMaterial material=raw.resolve();Facts source=find(material.getId(),material.getName()); + GTMaterial material=raw.resolve();Facts source=MaterialFactKeys.sourceRecycling(material).orElse(null); if(!identity(material,source==null?null:source.identity()))return unsupported(Reason.UNKNOWN_SOURCE_IDENTITY); - if(source.portDefaults()==null)return unsupported(Reason.UNKNOWN_SOURCE_FACT); // Output-only Water/Lava. + if(!source.inputEligible())return unsupported(Reason.UNKNOWN_SOURCE_FACT); Reason changed=snapshot.materialOverride(material,source); if(changed!=null)return unsupported(changed); long inputUnits=U; @@ -102,7 +106,7 @@ private static Outcome inspect(GTMaterial raw,ItemStack selected,Snapshot snapsh if(source.melting()!=Decision.YES||source.blacklistedSmelter()!=Decision.NO||source.targetUnitsPerU()<0) return unsupported(Reason.UNKNOWN_SOURCE_FACT); GTMaterial target=GTMaterialRegistry.get(source.target().name()); - Facts targetSource=find(source.target().id(),source.target().name()); + Facts targetSource=MaterialFactKeys.sourceRecycling(target).orElse(null); if(!identity(target,source.target())||targetSource==null)return unsupported(Reason.UNKNOWN_SOURCE_IDENTITY); changed=snapshot.materialOverride(target,targetSource); if(changed!=null)return unsupported(changed); @@ -153,40 +157,14 @@ private static boolean identity(GTMaterial m,Identity source){ &>MaterialRegistry.isCoreMaterial(m)&&!AddonMaterials.owns(m)&&!m.has(MaterialProperty.ANTIMATTER); } record NativeBinding(String field,String registry,FluidCatalog.FluidEntry declaration,boolean finalized) {} - private static NativeBinding declared(String field,String registry,FluidCatalog.FluidEntry declaration){ - return new NativeBinding(field,registry,declaration,false); - } - private static NativeBinding finalized(String name,FluidCatalog.FluidEntry declaration){ - return new NativeBinding("GenMolten_"+name,"molten."+name.toLowerCase(Locale.ROOT),declaration,true); - } /** Explicit native spellings are bindings, not newly registered aliases or material-name guesses. */ static NativeBinding nativeBinding(GTMaterial target,Binding source){ - NativeBinding special=switch(target.getId()){ - - case 8001->declared("Glass","glass",FluidCatalog.Glass); - case 8211->declared("Blaze","blaze",FluidCatalog.Blaze); - - case 8218->declared("Plastic","molten.plastic",FluidCatalog.Plastic); - - case 8318->declared("Ender","molten.enderpearl",FluidCatalog.Ender); - case 8333->declared("Redstone","molten.redstone",FluidCatalog.Redstone); - - - case 9810->declared("Lava","lava",FluidCatalog.Lava); - case 9883->declared("CFoam","ic2constructionfoam",FluidCatalog.CFoam); - case 8217->finalized("Rubber",FluidCatalog.Molten_Rubber); - case 8235->finalized("Wax",FluidCatalog.Molten_Wax); - case 8236->finalized("WaxBee",FluidCatalog.Molten_WaxBee); - case 8238->finalized("WaxParaffin",FluidCatalog.Molten_WaxParaffin); - case 8239->finalized("WaxPlant",FluidCatalog.Molten_WaxPlant); - case 9703->finalized("Sugar",FluidCatalog.Molten_Sugar); - case 9780->finalized("Cheese",FluidCatalog.Molten_Cheese); - case 9783->finalized("Chocolate",FluidCatalog.Molten_Chocolate); - // These original molten salts retain their established port liquid IDs, with source144/U. - case 8009,8010,8029,8033->new NativeBinding("GenLiquid_"+target.getName(),target.getName().toLowerCase(Locale.ROOT),null,false); - default->null; - }; - if(special!=null)return special; + var exact=MaterialFluidUnitFacts.binding(target,source.accessor().name().toLowerCase(Locale.ROOT)); + if(exact!=null){ + var declaration=FluidCatalog.all().get(exact.fluidField()); + return new NativeBinding(exact.fluidField(),exact.registryName(),declaration, + exact.fluidField().startsWith("GenMolten_")); + } String lower=target.getName().toLowerCase(Locale.ROOT),path=source.sourceRegistryPath(); if(path.equals("molten."+lower))return new NativeBinding("GenMolten_"+target.getName(),path,null,false); if(path.equals(lower))return new NativeBinding(FluidCatalog.canonicalField("GenLiquid_"+target.getName()),path,null,false); @@ -231,8 +209,7 @@ SourceThermalRecyclingRules.Stats stats(GTMaterial input,GTMaterial target){ return new SourceThermalRecyclingRules.Stats(input.getDensity(),target.getMeltingPoint()); } Reason materialOverride(GTMaterial material,Facts source){ - PortDefaults defaults=contextDefaults(source.identity().id(),source.identity().name()); - if(defaults==null)return Reason.UNKNOWN_SOURCE_FACT; + PortDefaults defaults=source.portDefaults(); if(material.has(MaterialProperty.MELTING)!=defaults.melting())return Reason.MATERIAL_ELIGIBILITY_OVERRIDE; var target=material.getTargetSmeltingMaterial(); if(target==null||!target.isValid())return Reason.MATERIAL_TARGET_OVERRIDE;target=target.resolve(); @@ -284,7 +261,7 @@ private long validatedUnits(GTMaterial material,ItemStack stack,Set rules.rules().stream().anyMatch(rule -> rule.wholeDustMetal())) + .orElse(false); return metal && (prefix == MaterialPrefix.dustSmall || prefix == MaterialPrefix.dustTiny diff --git a/minecraft/src/main/java/gregtech/content/recipe/TreatedWoodRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/TreatedWoodRecipes.java index 00cb725e5..0ea52db8a 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/TreatedWoodRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/TreatedWoodRecipes.java @@ -2,9 +2,9 @@ import gregtech.api.material.GTMaterial; import gregtech.api.material.GTValues; -import gregtech.api.material.MaterialProperty; import gregtech.content.block.wood.WoodSpecies; import gregtech.content.data.MachineRecipeMaps; +import gregtech.content.data.MaterialGroups; import gregtech.content.data.MaterialPrefix; import gregtech.content.registry.GTBlocks; import gregtech.content.registry.GTItems; @@ -105,8 +105,6 @@ public final class TreatedWoodRecipes extends OriginalRecipeBatch { "pipeQuadruple", "pipeNonuple" }; - /** Wood-property materials that GT6's {@code ANY.WoodUntreated} does not contain. */ - private static final Set NOT_UNTREATED_WOOD = Set.of("PetrifiedWood"); private TreatedWoodRecipes() {} @@ -131,14 +129,11 @@ public static int register() { /** Every untreated wood form GT6's Bath handler converts, scaled by the prefix's material amount. */ private void materialBath() { GTMaterial treated = GTMaterialRegistry.get("WoodTreated").resolve(); - GTMaterial polished = GTMaterialRegistry.get("WoodPolished").resolve(); // GT6 stamps one recipe per (input stack, fluid); shared items such as vanilla sticks are // reached through several wood identities and must not repeat. Set used = new HashSet<>(); - for (GTMaterial material : GTMaterialRegistry.allMaterials()) { - if (!material.isValid() || !material.has(MaterialProperty.WOOD)) continue; - if (material == treated || material == polished) continue; - if (NOT_UNTREATED_WOOD.contains(material.getName())) continue; + GTMaterial polished = GTMaterialRegistry.get("WoodPolished").resolve(); + for (GTMaterial material : MaterialGroups.members(MaterialGroups.WoodUntreated)) { for (String form : WOOD_FORM_PREFIXES) { MaterialPrefix prefix = PrefixRegistry.byName(form); if (prefix != null) diff --git a/minecraft/src/main/java/gregtech/content/recipe/VanillaRecoveryRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/VanillaRecoveryRecipes.java index 641556598..707c35f98 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/VanillaRecoveryRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/VanillaRecoveryRecipes.java @@ -36,8 +36,10 @@ public static int register() { boolean auditedMachine = originalMachine(item); boolean meatCut = gregtech.content.material.MeatItemMaterials.contains(item); if (!id.getNamespace().equals("minecraft") - && !PanelMaterialRegistration.recoveryItems().contains(item) - && !TransportMaterialRegistration.recoveryItems().contains(item) + && !gregtech.content.material.PanelMaterialCompositions.recoveryItems() + .contains(item) + && !gregtech.content.material.TransportMaterialCompositions.recoveryItems() + .contains(item) && !auditedMachine && !meatCut) continue; var stack = new ItemStack(item); diff --git a/minecraft/src/main/java/gregtech/content/recipe/VanillaWoodProcessingRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/VanillaWoodProcessingRecipes.java index 43f23940b..b92e919b4 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/VanillaWoodProcessingRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/VanillaWoodProcessingRecipes.java @@ -3,7 +3,6 @@ import gregtech.api.material.*; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; -import gregtech.content.material.VanillaCompositionLoader; import gregtech.content.plant.WoodSlabCatalog; import gregtech.engine.material.*; import net.minecraft.world.item.ItemStack; @@ -14,45 +13,6 @@ public final class VanillaWoodProcessingRecipes extends OriginalRecipeBatch { private static final String[] WOODS = { "oak", "spruce", "birch", "jungle", "acacia", "dark_oak", "mangrove", "cherry" }; - /** WoodDictionary replaces the generic vanilla item table before dependent recipes/panels. */ - public static void registerMaterials() { - for (String wood : WOODS) registerMaterials(wood, "log", "wood"); - for (String wood : new String[] {"crimson", "warped"}) registerMaterials(wood, "stem", "hyphae"); - } - - private static void registerMaterials(String wood, String... types) { - var material = RegisteredWoodSurvivalRecipes.material(wood); - var bark = GTMaterialRegistry.get("Bark"); - for (String type : types) { - String raw = wood + "_" + type; - registerWoodComposition( - raw, - new ItemComposition( - null, - java.util.List.of( - MaterialComponent.of(material, 8 * GTValues.U), - MaterialComponent.of(bark, GTValues.U)), - material, - "GT6 WoodEntry (modern wood binding)", - true)); - registerWoodComposition("stripped_" + raw, new ItemComposition(null, material, 8 * GTValues.U)); - } - registerWoodComposition(wood + "_planks", new ItemComposition(MaterialPrefix.plate, material, GTValues.U)); - registerWoodComposition(wood + "_stairs", new ItemComposition(null, material, 3 * GTValues.U / 4)); - registerWoodComposition(wood + "_slab", new ItemComposition(null, material, GTValues.U / 2)); - } - - private static void registerWoodComposition(String path, ItemComposition composition) { - var item = mc(path, 1).getItem(); - String jsonSource = VanillaCompositionLoader.declarationId(item).orElse(null); - ItemMaterialRegistry.register( - item, - composition, - ItemCompositionSource.Kind.EXPLICIT, - "gt6ce:wood-entry/" + path, - "GT6 wood material binding", - jsonSource); - } public static int register() { for (String wood : WOODS) INSTANCE.wood(wood); diff --git a/minecraft/src/main/java/gregtech/content/recipe/generated/ChemRecipeResolver.java b/minecraft/src/main/java/gregtech/content/recipe/generated/ChemRecipeResolver.java index 7357b2411..62948ce4a 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/generated/ChemRecipeResolver.java +++ b/minecraft/src/main/java/gregtech/content/recipe/generated/ChemRecipeResolver.java @@ -6,7 +6,7 @@ import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; import gregtech.content.data.MaterialPrefixes; -import gregtech.content.recipe.OriginalMaterialFluidUnits; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.content.recipe.SourceCentrifugeBlockDustInputs; import gregtech.content.recipe.SourceCentrifugeItemOutputs; import gregtech.content.recipe.SourceCentrifugeOptionalBindings; @@ -426,7 +426,7 @@ private static FluidStack fluid(ChemFluid fluid, List substitutions) thr return stack; } if (fluid instanceof ChemFluid.Water water) { - int mb = OriginalMaterialFluidUnits.millibuckets(water.units().units(), GTValues.U, 1000, + int mb = MaterialFluidUnitFacts.millibuckets(water.units().units(), GTValues.U, 1000, water.rounding() == gregtech.engine.recipe.chem.Rounding.CEIL); if (mb <= 0) throw new MissingContent("water amount " + water.units(), false); return new FluidStack(Fluids.WATER, mb); From de16ac29809aaba41089ded410a6b3d8ef115558 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Fri, 13 Nov 2026 22:30:14 +0800 Subject: [PATCH 02/17] API for material display --- .../resources/assets/gt6ce/lang/en_us.json | 20 ++ .../resources/assets/gt6ce/lang/zh_cn.json | 20 ++ docs/architecture/packages/runtime.md | 3 + docs/development/README.md | 1 + docs/development/material-process-display.md | 76 +++++ .../07-cleanup-and-acceptance.md | 13 +- .../08-material-data-api.md | 2 + .../material-system-refactor/README.md | 6 +- .../validation/checks/manual-ingame.md | 13 + docs/integration/README.md | 3 +- .../material-refactor-07-roster.md | 201 +++++++++++++ .../gregtech/client/MaterialProcessPanel.java | 263 ++++++++++++++++++ .../compat/common/MaterialProcessDisplay.java | 229 +++++++++++++++ .../compat/jei/GregTechJEIPlugin.java | 2 + .../compat/jei/MaterialProcessCategory.java | 110 ++++++++ .../material/MaterialItemCompositions.java | 34 +++ .../gametest/MaterialBaselineTests.java | 37 +++ .../registry/GTMaterialRegistration.java | 31 +-- .../content/registry/GTSpecialOreBlocks.java | 18 +- tools/README.md | 1 + tools/material/README.md | 39 +++ tools/material/audit_roster.py | 141 ++++++++++ 22 files changed, 1212 insertions(+), 51 deletions(-) create mode 100644 docs/development/material-process-display.md create mode 100644 docs/integration/material-refactor-07-roster.md create mode 100644 minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java create mode 100644 minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java create mode 100644 minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java create mode 100644 tools/material/README.md create mode 100644 tools/material/audit_roster.py diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index c9cf20738..3511327f5 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -58,6 +58,26 @@ "gt.material.Sculk": "Sculk", "material.gt6ce.redstonealloy": "Redstone Alloy", "material.gt6ce.sculk": "Sculk", + "gt6ce.jei.material_process.title": "Mineral Processing", + "gt6ce.jei.material_process.inputs": "Co-inputs / catalysts", + "gt6ce.jei.material_process.route": "Main route", + "gt6ce.jei.material_process.outputs": "Other outputs", + "gt6ce.jei.material_process.empty": "No processing steps in this result.", + "gt6ce.jei.material_process.unbound": "Processing data has not been connected yet.", + "gt6ce.jei.material_process.controls": "Step: recipe | Resource: sources / uses", + "gt6ce.jei.material_process.open_recipe": "Click the step to open its original recipe, when available.", + "gt6ce.jei.material_process.unresolved": "Unresolved relation / native constraint", + "gt6ce.jei.material_process.confirmed": "Confirmed relation", + "gt6ce.jei.material_process.chance_unknown": "Output chance: unknown", + "gt6ce.jei.material_process.more": "+%s ports (hover)", + "gt6ce.jei.material_process.links": "%s links", + "gt6ce.jei.material_process.connection": "%s → %s | %s | %s", + "gt6ce.jei.material_process.role.consumed": "Consumed co-input", + "gt6ce.jei.material_process.role.catalyst": "Catalyst (not consumed)", + "gt6ce.jei.material_process.role.presence": "Presence condition (not consumed)", + "gt6ce.jei.material_process.role.primary": "Primary output", + "gt6ce.jei.material_process.role.byproduct": "Byproduct", + "gt6ce.jei.material_process.role.unknown": "Output role: unknown", "gt6ce.jei.category.mold_chisel": "Mold Chiseling", "gt6ce.jei.mold_chisel.note": "Dark cells are chiseled out", "gt6ce.jei.mold_chisel.carved": "Chisel this cell", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index fd09c1632..a7e2547c5 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -60,6 +60,26 @@ "gt.material.Sculk": "幽匿", "material.gt6ce.redstonealloy": "红石合金", "material.gt6ce.sculk": "幽匿", + "gt6ce.jei.material_process.title": "矿物处理", + "gt6ce.jei.material_process.inputs": "共同输入/催化剂", + "gt6ce.jei.material_process.route": "主加工路线", + "gt6ce.jei.material_process.outputs": "其他产物", + "gt6ce.jei.material_process.empty": "此查询结果中没有加工步骤。", + "gt6ce.jei.material_process.unbound": "尚未接入加工数据。", + "gt6ce.jei.material_process.controls": "点击工艺:原配方|左/右击资源:来源/用途", + "gt6ce.jei.material_process.open_recipe": "点击工艺可在支持时打开原始配方。", + "gt6ce.jei.material_process.unresolved": "关系或原生约束尚未解析", + "gt6ce.jei.material_process.confirmed": "已确认的关系", + "gt6ce.jei.material_process.chance_unknown": "产出概率:未知", + "gt6ce.jei.material_process.more": "+%s 个端口(悬停查看)", + "gt6ce.jei.material_process.links": "%s 条关联", + "gt6ce.jei.material_process.connection": "%s → %s|%s|%s", + "gt6ce.jei.material_process.role.consumed": "共同输入(消耗)", + "gt6ce.jei.material_process.role.catalyst": "催化剂(不消耗)", + "gt6ce.jei.material_process.role.presence": "存在性条件(不消耗)", + "gt6ce.jei.material_process.role.primary": "主产物", + "gt6ce.jei.material_process.role.byproduct": "副产物", + "gt6ce.jei.material_process.role.unknown": "产物角色:未知", "gt6ce.jei.category.mold_chisel": "模具凿刻", "gt6ce.jei.mold_chisel.note": "深灰色格子为凿除部分", "gt6ce.jei.mold_chisel.carved": "凿除这个格子", diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index 01fc766f0..62f23ec8a 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,6 +70,8 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 +矿物处理前端由 `compat.common.MaterialProcessDisplay` 接受已完成有界查询的投影,`client.MaterialProcessPanel` 负责布局和交互,`compat.jei.MaterialProcessCategory` 接到原生槽位与索引。当前只注册未接入说明页,没有具体材料、服务端来源索引或远程同步;调用契约与预算见[展示接入](../../development/material-process-display.md)。这些类型不能成为第二套材料目录或配方事实表。 + 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 ## 验收 @@ -79,6 +81,7 @@ GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../ - 客户端只负责展示与交互入口;真实槽位、库存、权限与配方由服务端 Menu 和服务端状态决定。修改 GUI 模板后先做静态预览,再在客户端与专用服务端分别确认。 - 网络包检查方向、解码上限、执行线程、目标实体有效性与请求者权限;Mixin 检查两个节点的配置、目标签名、注入点与未命中行为。 - 可选集成沿配置与现有入口条件加载;分别验证未安装目标模组与安装匹配版本。 +- 矿物处理页按[专用场景](../../development/validation/checks/manual-ingame.md#矿物处理展示页)确认联合输入、角色、概率、折叠、显式关联与跳转;前端未接线时不记作真实来源或远程快照验收通过。 - 运输网络快照只在布局变化时失效,空闲电线/管道不执行 tick;外部 fill/drain、覆盖板、扳手、邻居变化和区块加载都必须接到失效或唤醒钩子。 - 共享 Minecraft 输入遵循 Stonecutter 条件与版本资源路径;渲染、GUI、网络与 Mixin 的结论不能用单平台结果推出另一平台。 diff --git a/docs/development/README.md b/docs/development/README.md index c90e5ea0c..063e1079c 100644 --- a/docs/development/README.md +++ b/docs/development/README.md @@ -6,6 +6,7 @@ | [文件与产物归属](repository-layout.md) | 源码、测试、工具、文档和临时材料的位置 | | [验证与验收](validation/README.md) | 改动路径路由、检查命令与结果证据 | | [碎片贴图与机器 GUI 模板](gui-templates.md) | 模板格式、素材引用和界面接入 | +| [矿物处理 JEI 展示接入](material-process-display.md) | 前端投影、分页、覆盖说明与后续跳转调用契约 | | [Issue 分类与标签](github-issue-tags.md) | 问题分类与协作约定 | 其他主题见[GT6CE 文档](../README.md),开发工具用法见[工具目录](../../tools/README.md)。 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md new file mode 100644 index 000000000..fa7077d79 --- /dev/null +++ b/docs/development/material-process-display.md @@ -0,0 +1,76 @@ +# 矿物处理 JEI 展示接入 + +本文说明[计划 08-E](material-system-refactor/08-material-data-api.md#e有界矿物处理图与消费者迁移)的前端接入契约。当前只提供展示模型、布局和 JEI 分类,默认注册一张“尚未接入加工数据”的说明页;没有连接任何具体材料、配方索引或世界生成数据。08-D 的快照发布、远程同步、core 图查询与 EMI 接入仍未实现,不能将本页当作它们已经完成的证明。 + +这是 Minecraft 实现层的客户端调用接口,随模组编译,不是独立 API JAR 的公共材料服务,也不改变 API 1.8.0。只在客户端和已安装 JEI 的路径调用分类;无 JEI 的服务端入口不得引用它。 + +## 入口与职责 + +| 类型 | 职责 | +| --- | --- | +| `gregtech.compat.common.MaterialProcessDisplay` | 已完成有界查询的展示投影、校验和分页;不读取材料目录、配方表或服务端状态 | +| `MaterialProcessDisplay.Port` | 一个原生状态敏感的资源选择器的展示,含角色、数量单位、概率与有限图标 | +| `MaterialProcessDisplay.Step` | 同一步骤的全部共同输入、全部输出、机器/环境/时间/能量/出处说明 | +| `MaterialProcessDisplay.Connection` | 调用方提供的步骤关联,包含资源引用及确认状态;支持分支、回边和自环 | +| `MaterialProcessDisplay.Page` | 每页至多两个步骤,保留全图关联、覆盖说明和绑定到同一查询结果的跳转回调 | +| `gregtech.client.MaterialProcessPanel` | 固定 280×216 的坐标、绘制、悬停与点击;不依赖 JEI/EMI | +| `gregtech.compat.jei.MaterialProcessCategory` | 原生 JEI 槽位、索引、事件和 tooltip;分类类型为 `TYPE`,标识为 `gt6ce:material_process` | + +复用现有 `DataKey` 表达展示引用,复用 `RecipeOutputChances.CERTAIN` 的万分比契约、JEI 原生槽位、分页、配方索引与运行期注册。没有另建 SPI、全局来源缓存、锁、服务端查询协议或材料事实表。未来 EMI 适配可共用展示模型与面板,不能在共用类型中引用 JEI 类。 + +## 构造契约 + +- `DataKey` 在这里是调用方签发的快照内引用,不是新的材料身份或存档 ID。`Port.resource` 必须区分材料、形态、相态和原生状态;不同 tag/unit 选择器也不能因图标相同而合并。已有 `MaterialKey`、`FormKey` 与原生匹配引用由后续适配器解析到该引用,不重新建立材料目录。 +- `Port(resource, name, icons, role, main, amount, chance, details)` 的 `amount` 必须包含原生批量及单位,如件、U 或 mB。前端只显示文本,不换算、不从栈数量推导材料量。`icons` 为有限代表,空列表表示符号资源;不展开 tag 或 unit 候选全集。使用现有 `FluidDisplayBinding.display(...)` 取得带相态/状态的流体代理物品,不创建另一套流体身份转换。 +- `Role.CONSUMED`、`CATALYST`、`PRESENCE` 只用于输入;`PRIMARY`、`BYPRODUCT`、`UNKNOWN` 只用于输出。输入不因为存在数量就自动消耗。无可靠主/副角色时用 `UNKNOWN`,不得按槽位猜测。 +- `main` 仅决定中心路线位置,每一步的输入和输出分别至多一个。它不改变角色、确定性或权威性;未指定主路线时所有端口均侧排。 +- `chance` 使用 `OptionalInt`,已知概率为 1—10000,未知为 `OptionalInt.empty()`,确定产出为 `OptionalInt.of(RecipeOutputChances.CERTAIN)`。输入概率不参与绘制。互斥/共享随机事件、未知相关性和原生状态限制必须放在 `details`;不能用边际概率声称各输出独立。世界生成权重放说明,不能当成掉落概率。 +- `Step(reference, name, inputs, outputs, details, resolved)` 保存同一步的联合输入、多输出及条件。机器、时间、能量、温度、维度、选择器、来源等通过 `details` 传入。`resolved=false` 表示原生关系/约束尚未解析,连接为虚线,工艺按钮不能打开原配方。`resolved=true` 也不承诺玩家库存可执行。 +- `Connection(source, target, resource, confirmed)` 必须指向当前结果内的两个步骤,且资源同时出现在源步骤输出和目标步骤输入中。前端不按相同物品图标补边;`confirmed=false` 保留为未确认关系。 +- 文本与图标在构造时复制,列表只读,图标访问返回副本。调用方须将传入后取得的 `Component` 及说明视为只读。禁止传 `null`、空物品栈、错误侧角色、重复步骤引用、悬空关联或非法概率;构造/分页时抛出 `IllegalArgumentException`,不把无效数据改成空结果。 + +`pages(title, steps, connections, notices, navigation)` 按调用方的既定顺序分页,不执行图遍历或自动规划。当前预算为最多 64 步、128 条关联、每步每侧 64 个端口、每端口 16 个代表图标;超限直接拒绝。调用方应在查询层按预算取得结果,并提供准确截断原因,不能先全量枚举再交给 UI 截断。 + +`notices` 必须非空,在每页页脚可见,悬停显示全部内容。调用方必须说明完整/部分覆盖、未支持族和深度/节点/端口/边预算截断;空结果也必须说明范围。默认 `unbound()` 只表示尚未接线,不能当作“该材料没有来源”。 + +## 布局与交互 + +主加工位于中线,共同输入及催化剂位于左侧,其他产物位于右侧,副产物分支使用金色。批量、单位、角色、概率和完整条件在端口及工艺 tooltip 中读取。黄色角标和虚线表示随机、未知概率或未解析关系。 + +只有显式关联连接的相邻主输出/主输入才绘制跨步骤中心箭头。其余分支、跨页关联、回边与自环以每步的关联数量和完整 tooltip 引用表示,不将非相邻步骤强行连线;循环不触发递归展开。原生状态相异但图标相同的端口仍分别显示。 + +每侧最多六个侧排图标,更多端口显示“+N 个端口”,悬停保留全部端口信息。被折叠的物品代表仍加入 JEI 原生不可见索引,保留 R/U 检索。这是布局折叠,不是数据查询截断。符号端口以问号占位并保留说明和自定义跳转,不能将其图标代表当成完整候选集合。 + +- 左击工艺调用 `Navigation.openRecipe(step.reference)`,只在 `resolved=true` 时尝试。 +- 左击资源调用 `Navigation.openForm(resource, false)` 查询来源,右击传 `true` 查询用途;回调返回 `false` 时不消费该点击,允许 JEI 原生行为继续处理。R/U 等快捷键仍由 JEI 管理。 +- `Navigation.NONE` 是不支持跳转的明确默认实现,不需要 `null` 回调。 +- 翻页、分类展示与配方检索交给 JEI;没有自建分页状态或全局 UI 实例缓存。 + +## 后续调用方式 + +在既有 JEI 注册回调中,把从同一已发布内容版本得到的展示投影传入: + +```java +var pages = MaterialProcessDisplay.pages(title, steps, connections, notices, navigation); +registration.addRecipes(MaterialProcessCategory.TYPE, pages); +``` + +这里的 `title`、`steps`、`connections`、`notices`、`navigation` 是调用方的局部变量;示例不宣称存在尚未实现的材料图查询服务。接入正式生产者时替换 `GregTechJEIPlugin.registerRecipes` 中的 `unbound()` 注册,不要同时注册占位页与正式结果。 + +`Navigation` 由内容适配器创建并捕获该次查询的会话/generation。每次跳转先检查当前版本,过期或不能解析时返回 `false`,不得跳转到新版本中“相似”的配方。不要捕获旧 `Level`/服务器实例,也不要从客户端直接扫描集成服务器表。生产者应将未来 `ProcessRef` 和实际材料形态引用映射到展示引用,适配器使用原生服务重新解析;UI 不发明第二个快照协议。 + +解析得到具体配方及其已注册分类后,可复用 JEI 的精确跳转: + +```java +runtime.getRecipesGui().showRecipes(category, List.of(recipe), List.of()); +``` + +`category` 和 `recipe` 必须来自当前有效原生引用;`RecipeViewerNavigation.open(map)` 只打开整个机器分类,不能替代这一步的精确定位。形态跳转应重新查询对应有界来源/用途,而不是按图标猜材料。 + +动态打开查询结果可复用 JEI `IRecipeManager.getRecipeCategory(TYPE)` 和 `IRecipesGui.showRecipes(category, pages, List.of())`;优先让结果仅随当前显示布局存活。若使用运行期 `addRecipes`,调用方必须负责重载、断线、换服以及旧记录和回调的释放;`hideRecipes` 只是隐藏,不能当作回收旧快照的手段。当前展示层不订阅这些生命周期,也不持有运行期结果。 + +## 验证范围 + +检查路由为 `runtime`/语言资源 `content`;双平台编译、格式、资源打包与相关 JUnit 命令见[验证入口](validation/README.md)。[游戏检查](validation/checks/manual-ingame.md#矿物处理展示页)分别覆盖两平台及后续远程接线。 + +当前没有具体材料接入,不能验收真实洗矿/合金数据、远程 generation 或原生配方跳转正确性。界面测试输入应由客户端测试调用方提供受控投影,禁止为演示把材料来源和假配方加入生产表。 diff --git a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md index c5232cee1..375bc4425 100644 --- a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md +++ b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md @@ -1,6 +1,6 @@ # 07:清理与双平台整体验收 -本计划在数据与执行路径已收敛后移除旧实现,审计无消费内容,完成用户可见行为与双平台验收。状态:内部清理已实施;[02](02-material-registration.md)—[06](06-decomposition.md) 已合入 master。07-A—D 的首轮清理已完成并通过 core 测试与双平台编译;07-E 已完成文档点名的高优先级形态定向审计,但完整注册项清单和 07-F 最终验收仍未完成;[08](08-material-data-api.md)-D—E 也尚未实施,因此不能把全部 07 标为完成。 +本计划在数据与执行路径已收敛后移除旧实现,审计无消费内容,完成用户可见行为与双平台验收。状态:内部清理与 07-E 已实施;[02](02-material-registration.md)—[06](06-decomposition.md) 已合入 master。07-A—E 的实现已完成并通过单元测试、双平台编译和双平台 GameTest;07-F 最终验收与客户端确认仍未完成;[08](08-material-data-api.md)-D—E 也尚未实施,因此不能把全部 07 标为完成。 本页原清单按 master `f096a79ee`(2026-11-12)核对源码。2026-11-13 已完成首轮内部迁移:材料事实归入 `content.material.catalog` 的类型化 process 规则,运行时消费者改经材料查询,recipe 包只保留配方模板、特殊工艺和原生适配。下文保留旧类名用于追溯删除对象;实际新入口见“本轮实施结果”。 @@ -124,7 +124,7 @@ ### 07-E 定向审计记录 -2026-11-13 使用最终双平台 GameTest 生成的 `reload-items.tsv` 与源码配方入口做了首轮定向审计。注册数是实际发布物品数,不是 Java 字符串命中数;两端完全相同,因此没有观察到版本专属缺口。 +2026-11-13 使用最终双平台 GameTest 生成的 `reload-items.tsv`、`reload-forms.tsv`、`reload-block-forms.tsv` 与源码配方入口完成全量定向审计。注册数是实际发布对象数,不是 Java 字符串命中数。最终 Forge 与 NeoForge 均为 124 个形态族、31,137 个材料物品和 3,532 个材料方块形态,逐族计数一致;完整清单、九类无静态配方来源项的证据和源码补证见[07-E 材料与形态注册项审计](../../integration/material-refactor-07-roster.md)。 | 形态 | 实际注册物品数(Forge/NeoForge) | 已确认获得途径 | 已确认消费终端 | 本轮决定 | | --- | --- | --- | --- | --- | @@ -134,7 +134,7 @@ | `gearGt`/`gearGtSmall` | 407/407 | 挤压、木材配方、坩埚模具及材料形态转换 | 旋转动力设备、齿轮箱、工作站建造、纳米制造和配方输入 | 保留;不是可批量注销的兼容形态 | | `itemCasing` | 407/407 | 挤压与材料形态转换 | Welder、石墨烯路线、电源单元和机器建造输入 | 保留;源版 `casingSmall` 别名仍有实际消费者 | -本次没有找到足以删除上述注册项的无来源、无终端证据,因此没有改变物品 ID、NBT、配方身份或存档兼容性。完整来源/用途边仍由 08-D—E 的最终处理图验收覆盖。 +审计发现 NeoForge 原先只为 16 个 `oreVanillastone` 物品提交成分,Forge 为 396 个。共享 `MaterialItemCompositions` 现在按实际 `DenseOreBlock`、`VanillaOreBlock` 和非小型 `OreBlock` 统一提交,现有注册 ID 不变,最终两边均为 396。其余 123 个形态族没有找到足以删除的无来源、无终端证据,因此全部保留;没有改变物品 ID、NBT、配方身份或存档兼容性。完整来源/用途边仍由 08-D—E 的最终处理图验收覆盖。 ### 4. 整理 tooltip 与语言 @@ -189,8 +189,8 @@ - J:`./gradlew :core:test`,core 全套 174 tests 通过;新增事实投影计数覆盖全部迁移类别。 - C:`./gradlew compileBothPlatforms`,Forge 与 NeoForge 节点均编译通过。 - F(改动范围):`-PspotlessRatchet=HEAD` 的 core 与 Minecraft 格式检查通过;`git diff --check` 与注释引用检查通过。 -- G:最终代码在全新目录 `work/material-system-refactor/07-review2-forge-20261113` 与 `07-review2-neo-20261113` 分别运行 Forge/NeoForge `runGameTestServer`,结果为 94/94 与 99/99;两节点均执行 `material_baseline`、`material_baseline_reload` 和配方发布批次。 -- B(首轮):两个平台实际发行 JAR 构建成功;最新 JAR 中未发现已删除旧类、GameTest 类、案例 TSV 或测试模板。 +- G:当前代码在全新目录 `work/material-system-refactor/07e/gametest-forge` 与 `gametest-neo` 分别运行 Forge/NeoForge `runGameTestServer`,结果为 95/95 与 100/100;两节点均执行 `material_baseline`、`material_baseline_reload`、新增矿石形态遍历和配方发布批次。 +- B(首轮、当前修复前):两个平台当时实际发行 JAR 构建成功;当前 07-E 成分修复后的发行包留待 07-F 重验。 执行但失败或阻塞: @@ -198,7 +198,6 @@ 尚未执行: -- 07-E 的完整材料/形态清单裁决;`chain`、`minecartWheels`、`billet`、两种齿轮和 `itemCasing` 的定向审计已完成。 - 07-F / 08-D—E 的有效来源/用途索引、有界处理图和远程客户端验收。 - 客户端 tooltip、JEI/EMI 展示及机器实际交互的人工验收。 @@ -223,6 +222,6 @@ | 07-E | 材料/形态去留与必要迁移 | 定向审计可先开始;删注册项必须单独提供可达性、存档和 parity 依据 | | 07-F | 全链路、处理图、远程客户端与发行包总验收 | 08-D—E 完成;按本页矩阵补齐,分别记录两个平台与未覆盖场景 | -07-A—D 无需等待 08-D—E;07-E 的定向审计也可以先开展。08 的有效来源与共享图仍是 07-F 的交付前置,不能用内部清理完成替代。每个切片的检查按实际改动路径与总计划检查集执行,不把纯文档清单的检查结果沿用为实施代码的验收结果。 +07-A—E 已完成;08 的有效来源与共享图仍是 07-F 的交付前置,不能用内部清理和 07-E 注册项清单替代。每个切片的检查按实际改动路径与总计划检查集执行,不把纯文档清单的检查结果沿用为实施代码的验收结果。 仅删除内部代码时,可回退对应小变更并恢复旧适配器;一旦删除了世界中可持久化的身份,恢复源码不等于恢复已保存的数据,必须在实施删除前选择并验证迁移/保留读取策略。测试世界使用隔离副本,不对真实服务器执行本计划。 diff --git a/docs/development/material-system-refactor/08-material-data-api.md b/docs/development/material-system-refactor/08-material-data-api.md index 5f520454f..83500b60d 100644 --- a/docs/development/material-system-refactor/08-material-data-api.md +++ b/docs/development/material-system-refactor/08-material-data-api.md @@ -109,6 +109,8 @@ ## E:有界矿物处理图与消费者迁移 +前端切片:已提供独立的 JEI 展示分类、共享展示投影和客户端布局,[调用文档](../material-process-display.md)记录预算、联合端口、显式关联、覆盖提示及跳转回调。默认仅注册未接入说明页,没有绑定具体材料。D 的来源索引、E 的 core 图查询、远程同步与 EMI 接线仍待实施,本切片不代表 D—E 完成。 + ### 步骤 1. 在 core 对 D 的关系做有界前/反向查询,保留步骤节点和端口;处理循环、共同输入、分支与明确截断原因。 diff --git a/docs/development/material-system-refactor/README.md b/docs/development/material-system-refactor/README.md index 53efba0f1..9701fbdb9 100644 --- a/docs/development/material-system-refactor/README.md +++ b/docs/development/material-system-refactor/README.md @@ -1,8 +1,8 @@ # 材料系统重构实施计划 -本组文档用于把 [issue #351](https://github.com/GregTech6CE/GregTech6/issues/351) 拆成可实施、可逐份验收的工作。01 已建立可执行基线,验收范围与已知差异见[基线报告](../../integration/material-baseline.md);02 已完成注册、目录和 08-A/B 的定义与查询切片;03 已完成属性收敛、燃料闭环、08-C 实际形态绑定和资源 tag 桥接声明;04 已完成来源化候选裁决、有效成分快照、状态查询和双平台共享安装;05 已完成成分驱动的回收计划、数量表达、主要生产端迁移和重载诊断;06 已完成类型化分解声明、计划器和双平台执行验收。07 的内部材料事实、配方/原生职责拆分、成品成分安装、tooltip 失效分支和首轮清理已完成;08-D—E、07-E 注册项去留裁决与 07-F 最终验收仍待实施。尚未实施阶段的目标接口、测试和数据集不代表当前已经存在。阅读顺序为本页、对应分计划、该计划引用的现有架构与检查文档。 +本组文档用于把 [issue #351](https://github.com/GregTech6CE/GregTech6/issues/351) 拆成可实施、可逐份验收的工作。01 已建立可执行基线,验收范围与已知差异见[基线报告](../../integration/material-baseline.md);02 已完成注册、目录和 08-A/B 的定义与查询切片;03 已完成属性收敛、燃料闭环、08-C 实际形态绑定和资源 tag 桥接声明;04 已完成来源化候选裁决、有效成分快照、状态查询和双平台共享安装;05 已完成成分驱动的回收计划、数量表达、主要生产端迁移和重载诊断;06 已完成类型化分解声明、计划器和双平台执行验收。07 的内部材料事实、配方/原生职责拆分、成品成分安装、tooltip 失效分支和 07-E 注册项去留裁决已完成;08-D—E 与 07-F 最终验收仍待实施。尚未实施阶段的目标接口、测试和数据集不代表当前已经存在。阅读顺序为本页、对应分计划、该计划引用的现有架构与检查文档。 -01—06 当前均已合入 master,本次核对点为 PR #374 合并后的 `f096a79ee`。07 的首轮内部清理已实施;[07 清单](07-cleanup-and-acceptance.md)按当前源码列出 Reviewed/Source 类中的材料事实、通用配方模板、特殊配方与原生适配的处理方式,并以朱砂和铝土矿高压釜区分职责。07 最终整体验收仍以前置 08-D—E 完成为条件。 +01—06 当前均已合入 master,本次核对点为 PR #374 合并后的 `f096a79ee`。07 的内部清理与 [07-E 注册项去留裁决](../../integration/material-refactor-07-roster.md)已实施;[07 清单](07-cleanup-and-acceptance.md)按当前源码列出 Reviewed/Source 类中的材料事实、通用配方模板、特殊配方与原生适配的处理方式,并以朱砂和铝土矿高压釜区分职责。07 最终整体验收仍以前置 08-D—E 完成为条件。 [recipe 包补充审计](07-recipe-package-audit.md)记录通用材料转换目标、挤压/研钵/洗矿能力、透镜角色、相态绑定和固定物品成分登记的迁移结果,并区分保留的特殊配方与原生适配。 @@ -85,4 +85,4 @@ | 多组件热回收、输出槽限制与无法表示的余量 | 05、06 | 逐机器核对规则,不要求所有工艺都产出全部成分 | | chain、minecartWheels 及兼容 prefix 的去留 | 07 | 同时检查实际消费端、外部声明契约和已有存档影响 | -01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收;07 已完成首轮内部清理。07-E/F、08-D—E 尚未实施。本页不替代现行架构或已接受的决策。 +01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收;07 已完成首轮内部清理和 07-E 全量材料/形态去留裁决。07-F、08-D—E 尚未实施。本页不替代现行架构或已接受的决策。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index d3066faa1..66aa705e4 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -16,6 +16,19 @@ 具体到机器、配方、流体、能源、网络与可选集成的勾选项写在对应 package 文档的验收章节里。 +## 验证原理 + +### 矿物处理展示页 + +接口与测试输入契约见[展示接入](../../material-process-display.md)。当前默认仅有未接入说明页;带数据场景由客户端测试调用方提交有界投影,不连接或硬编码生产材料。 + +1. 在 JEI 分类中打开“矿物处理”,确认未接入提示,没有虚构材料、配方与来源。分别使用中英文及不同 GUI 缩放检查边界、文字和悬停命中。 +2. 提供至少三个步骤,确认原生分页不丢步骤;共同输入、催化剂、存在性条件和多产物分别显示,量与单位、概率及条件 tooltip 完整。无主产物声明时显示未知角色。 +3. 提供符号端口、未知概率、未解析工艺和超过六个的侧排端口,确认问号、虚线、概率提示与折叠信息;折叠端口的代表仍可通过 JEI R/U 找到。 +4. 提供分支、相邻主路线、跨页边、回边和自环;只有显式关联产生跨步骤中心箭头,其余关联保留引用,不重复展开或卡死。提供两档候选规模,代表图标与查询预算不随候选笛卡尔积增长。 +5. 用记录调用的导航回调确认左右击资源的来源/用途方向、工艺精确引用及 `false` 回退。真实服务接线后再验证具体原配方、重载与换服过期引用拒绝、独立远程客户端同版本数据;当前均不能由前端测试代替。 +6. 两平台分别检查 JEI,另检查无 JEI 的专用服务端;安装 EMI 时保持现有 JEI 桥去重规则,不声称已实现 EMI 原生矿物页。 + ## 注意事项 - 使用隔离实例;EULA 由操作者自行处理;完整日志、截图与实例配置放 `work/<任务名>/`,公共记录只保留脱敏结论。 diff --git a/docs/integration/README.md b/docs/integration/README.md index 9979b78f6..f59c5dc69 100644 --- a/docs/integration/README.md +++ b/docs/integration/README.md @@ -1,6 +1,6 @@ # 集成、来源与验证结论 -本目录保存跨平台、跨模组与原 GT6 对照的长期结论,包括来源版本、单位转换、兼容条件、可复现问题及覆盖状态。目前只有模板,尚无正式报告。 +本目录保存跨平台、跨模组与原 GT6 对照的长期结论,包括来源版本、单位转换、兼容条件、可复现问题及覆盖状态。 新报告复制[验证结论模板](report-template.md),命名 `.md` 或 `-.md`,并在下方添加链接。同一主题持续更新原报告;结论与证据要求见[验证与验收](../development/validation/README.md#结果与证据),其他材料按[文档归属](../development/repository-layout.md#文档归属)存放。 @@ -11,3 +11,4 @@ - [材料重构 04:统一物品成分解析](material-refactor-04-composition.md):来源化候选、有效成分快照、状态缩放和双平台安装。 - [材料重构 05:统一回收计算与生成](material-refactor-05-recovery.md):成分驱动的回收计划、精确数量、主要生产端和重载诊断。 - [材料重构 06:统一分解](material-refactor-06-decomposition.md):规则化权限、相态与单位、纯计划、配方发布和执行验收。 +- [材料重构 07-E:材料与形态注册项审计](material-refactor-07-roster.md):124 个形态族的来源、消费者、去留决定和双平台一致性。 diff --git a/docs/integration/material-refactor-07-roster.md b/docs/integration/material-refactor-07-roster.md new file mode 100644 index 000000000..8c9b1bfbc --- /dev/null +++ b/docs/integration/material-refactor-07-roster.md @@ -0,0 +1,201 @@ +# 材料重构 07-E:材料与形态注册项去留审计 + +## 范围与状态 + +- 主题:按最终运行时注册对象审计材料身份、物品形态、方块形态、获得途径和消费者,完成 [07-E](../development/material-system-refactor/07-cleanup-and-acceptance.md#07-e-定向审计记录) 的去留裁决。 +- 状态:在下述双平台、开发环境、无外部附属内容范围内验证通过。07-F/08-D—E、客户端展示、机器手工交互和最终发行包仍未执行。 +- 源码状态:核对基线为 `525a6ecf6`;本报告包含当前工作区尚未提交的 `MaterialItemCompositions` 共享矿石成分修复与对应 GameTest。 +- 平台:Minecraft 1.20.1/Forge 47.4.20/Java 17,Minecraft 1.21.1/NeoForge 21.1.243/Java 21。 + +## 口径与结果 + +审计使用最终 GameTest 写出的 `reload-items.tsv`、`reload-forms.tsv`、`reload-block-forms.tsv`、`reload-recipes.tsv` 和 `reload-tags.tsv`,汇总由 [material 形态审计工具](../../tools/material/audit_roster.py)完成。物品数是实际存在成分快照的原生物品,方块数是实际实现材料方块契约的原生方块;两者都不是 Java 源码字符串命中数。来源和消费者计数来自最终 `RecipeMap.mRecipeList`,并展开配方里的物品 tag;手工配方、世界生成、铸币、化石和特殊行为没有统一静态表,因此按下文点名源码补证。 + +| 对象 | Forge | NeoForge | 结论 | +| --- | ---: | ---: | --- | +| 材料目录 | 815 | 815 | 相同;核心 803 个,另含 12 个测试附属材料(其中 3 个为测试流体身份) | +| 材料物品 | 31,137 | 31,137 | 124 个形态族的逐族计数相同 | +| 材料方块形态 | 3,532 | 3,532 | 13 个方块形态族的逐族计数相同 | +| 有静态配方来源的形态族 | 115 | 115 | 其余 9 族有世界生成、手工、铸币或展示来源 | +| 有静态配方输入的形态族 | 121 | 121 | `coin` 由硬币堆/铸模消费;`oreSmall` 由世界生成和采掘消费 | + +803 个核心材料身份中,734 个生成材料物品;另有 15 个有效但无物品形态的身份(8 个反物质、6 个粒子、1 个隐藏 Magic),以及 54 个 `id=-1` 的组/占位视图。`Empty` 是箭头杆、空弹壳和空玻璃管等物品使用的无效哨兵材料,属于预期身份而不是可删除注册项。12 个测试附属材料只存在于测试运行,不进入核心目录。 + +本轮没有任何材料、物品、方块、流体、NBT、配方或存档身份可依据“无来源、无终端”证明删除,因此全部保留。07-E 只修复了一处双平台成分遗漏:NeoForge 原先只为 16 个 `oreVanillastone` 物品提交成分,而 Forge 为 396 个;共享 `MaterialItemCompositions` 现在通过实际 `OreBlock`/`DenseOreBlock`/`VanillaOreBlock` 类型统一提交,注册 ID 与资源身份不变。最终两边均为 396。 + +## 无静态配方来源的九族 + +| 形态 | 获得途径 | 消费者/保留理由 | +| --- | --- | --- | +| `coin` | 铸币台压印;地牢生成硬币堆 | 硬币堆存取、掉落过期入堆、铸模和世界生成仍消费该身份 | +| `ore` | 世界生成矿石方块 | 破碎、洗矿、离心、金属与石材处理输入 | +| `oreSmall` | 小矿世界生成 | 小矿采掘/掉落终端;GT6 明确不为小矿伪造 RecipeMap 输入 | +| `oreDense` | 现有晶体/岩石矿石方块和地层生成 | 按 2U 进入矿石处理、热配方和坩埚输入 | +| `oreVanillastone` | 现有普通矿石方块身份 | 按标准矿石进入处理、熔炼和坩埚输入;本轮修复 NeoForge 缺失成分 | +| `pipeRestrictiveMedium` | 中型物品管道的手工配方 | 限制型物流路由与热回收输入 | +| `pipeRestrictiveLarge` | 大型物品管道的手工配方 | 限制型物流路由与热回收输入 | +| `pipeRestrictiveHuge` | 巨型物品管道的手工配方 | 限制型物流路由与热回收输入 | +| `unit` | 不是可获取的物理材料 | 查看器材料单位占位;挤压、熔炼和坩埚只把对应 289 个身份作为显示/配方单位,不把全部 745 个误当物理燃料 | + +## 全量形态清单 + +“来源”为静态配方输出数,“消费者”为静态配方输入数;括号内分别记录物品/方块。未列入上述九族的形态都至少同时具有实际获得路径和实际输入终端。全部决定均为保留,故本阶段没有兼容迁移、存档迁移或 parity 删除记录。 + +| 形态 | 物品 | 方块 | 来源(物品/方块) | 消费者(物品/方块) | +| --- | ---: | ---: | ---: | ---: | +| `arrowGtPlastic` | 437 | 0 | 272 / 0 | 372 / 0 | +| `arrowGtWood` | 437 | 0 | 272 / 0 | 315 / 0 | +| `billet` | 258 | 0 | 258 / 0 | 258 / 0 | +| `blockDust` | 0 | 685 | 680 / 680 | 682 / 682 | +| `blockGem` | 0 | 154 | 149 / 149 | 154 / 154 | +| `blockIngot` | 0 | 258 | 254 / 254 | 258 / 258 | +| `blockPlate` | 0 | 350 | 350 / 350 | 350 / 350 | +| `blockPlateGem` | 0 | 151 | 151 / 151 | 151 / 151 | +| `blockRaw` | 0 | 420 | 420 / 420 | 420 / 420 | +| `blockSolid` | 0 | 258 | 223 / 223 | 258 / 258 | +| `bolt` | 473 | 0 | 473 / 0 | 473 / 0 | +| `bouleGt` | 11 | 0 | 11 / 0 | 11 / 0 | +| `bulletGtLarge` | 437 | 0 | 433 / 0 | 437 / 0 | +| `bulletGtMedium` | 437 | 0 | 433 / 0 | 437 / 0 | +| `bulletGtSmall` | 437 | 0 | 433 / 0 | 437 / 0 | +| `casingMachine` | 0 | 124 | 121 / 121 | 124 / 124 | +| `casingMachineDense` | 0 | 124 | 121 / 121 | 124 / 124 | +| `casingMachineDouble` | 0 | 124 | 121 / 121 | 124 / 124 | +| `casingMachineQuadruple` | 0 | 124 | 121 / 121 | 124 / 124 | +| `chain` | 407 | 0 | 407 / 0 | 407 / 0 | +| `chunkGt` | 258 | 0 | 184 / 0 | 258 / 0 | +| `coin` | 351 | 0 | 0 / 0 | 0 / 0 | +| `crushed` | 420 | 0 | 420 / 0 | 420 / 0 | +| `crushedCentrifuged` | 420 | 0 | 420 / 0 | 420 / 0 | +| `crushedCentrifugedTiny` | 420 | 0 | 420 / 0 | 420 / 0 | +| `crushedPurified` | 420 | 0 | 420 / 0 | 420 / 0 | +| `crushedPurifiedTiny` | 420 | 0 | 420 / 0 | 420 / 0 | +| `crushedTiny` | 420 | 0 | 420 / 0 | 420 / 0 | +| `dust` | 693 | 0 | 688 / 0 | 693 / 0 | +| `dustDiv72` | 688 | 0 | 688 / 0 | 688 / 0 | +| `dustSmall` | 688 | 0 | 688 / 0 | 688 / 0 | +| `dustTiny` | 688 | 0 | 687 / 0 | 688 / 0 | +| `foil` | 258 | 0 | 217 / 0 | 258 / 0 | +| `gearGt` | 407 | 0 | 253 / 0 | 407 / 0 | +| `gearGtSmall` | 407 | 0 | 253 / 0 | 407 / 0 | +| `gem` | 164 | 0 | 153 / 0 | 164 / 0 | +| `gemChipped` | 154 | 0 | 153 / 0 | 154 / 0 | +| `gemExquisite` | 150 | 0 | 150 / 0 | 150 / 0 | +| `gemFlawed` | 153 | 0 | 153 / 0 | 153 / 0 | +| `gemFlawless` | 150 | 0 | 150 / 0 | 150 / 0 | +| `gemLegendary` | 150 | 0 | 138 / 0 | 150 / 0 | +| `ingot` | 265 | 0 | 253 / 0 | 265 / 0 | +| `ingotDouble` | 220 | 0 | 203 / 0 | 220 / 0 | +| `ingotQuadruple` | 220 | 0 | 203 / 0 | 220 / 0 | +| `ingotQuintuple` | 220 | 0 | 203 / 0 | 220 / 0 | +| `ingotTriple` | 220 | 0 | 203 / 0 | 220 / 0 | +| `itemCasing` | 407 | 0 | 407 / 0 | 407 / 0 | +| `lens` | 108 | 0 | 108 / 0 | 108 / 0 | +| `minecartWheels` | 207 | 0 | 7 / 0 | 207 / 0 | +| `nugget` | 260 | 0 | 258 / 0 | 260 / 0 | +| `ore` | 0 | 380 | 0 / 0 | 380 / 380 | +| `oreDense` | 21 | 0 | 0 / 0 | 21 / 0 | +| `oreRaw` | 420 | 0 | 420 / 0 | 420 / 0 | +| `oreSmall` | 0 | 380 | 0 / 0 | 0 / 0 | +| `oreVanillastone` | 396 | 0 | 0 / 0 | 396 / 0 | +| `pipeHuge` | 50 | 0 | 49 / 0 | 50 / 0 | +| `pipeLarge` | 50 | 0 | 49 / 0 | 50 / 0 | +| `pipeMedium` | 50 | 0 | 50 / 0 | 50 / 0 | +| `pipeNonuple` | 31 | 0 | 31 / 0 | 31 / 0 | +| `pipeQuadruple` | 31 | 0 | 31 / 0 | 31 / 0 | +| `pipeRestrictiveHuge` | 19 | 0 | 0 / 0 | 19 / 0 | +| `pipeRestrictiveLarge` | 19 | 0 | 0 / 0 | 19 / 0 | +| `pipeRestrictiveMedium` | 19 | 0 | 0 / 0 | 19 / 0 | +| `pipeSmall` | 31 | 0 | 31 / 0 | 31 / 0 | +| `pipeTiny` | 31 | 0 | 30 / 0 | 31 / 0 | +| `plate` | 377 | 0 | 375 / 0 | 377 / 0 | +| `plateCurved` | 350 | 0 | 267 / 0 | 350 / 0 | +| `plateDense` | 222 | 0 | 219 / 0 | 222 / 0 | +| `plateDouble` | 220 | 0 | 206 / 0 | 220 / 0 | +| `plateGem` | 151 | 0 | 150 / 0 | 151 / 0 | +| `plateGemTiny` | 151 | 0 | 151 / 0 | 151 / 0 | +| `plateQuadruple` | 220 | 0 | 206 / 0 | 220 / 0 | +| `plateQuintuple` | 220 | 0 | 206 / 0 | 220 / 0 | +| `plateTiny` | 351 | 0 | 351 / 0 | 351 / 0 | +| `plateTriple` | 220 | 0 | 206 / 0 | 220 / 0 | +| `railGt` | 25 | 0 | 25 / 0 | 25 / 0 | +| `ring` | 407 | 0 | 361 / 0 | 407 / 0 | +| `rockGt` | 449 | 0 | 22 / 0 | 449 / 0 | +| `rotor` | 407 | 0 | 205 / 0 | 407 / 0 | +| `round` | 383 | 0 | 231 / 0 | 383 / 0 | +| `scrapGt` | 688 | 0 | 207 / 0 | 688 / 0 | +| `screw` | 473 | 0 | 473 / 0 | 473 / 0 | +| `spring` | 407 | 0 | 209 / 0 | 407 / 0 | +| `springSmall` | 407 | 0 | 209 / 0 | 407 / 0 | +| `stick` | 475 | 0 | 473 / 0 | 475 / 0 | +| `stickLong` | 473 | 0 | 286 / 0 | 473 / 0 | +| `toolHeadArrow` | 271 | 0 | 271 / 0 | 271 / 0 | +| `toolHeadAxe` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadAxeDouble` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadBuilderwand` | 185 | 0 | 8 / 0 | 185 / 0 | +| `toolHeadBuzzSaw` | 185 | 0 | 8 / 0 | 185 / 0 | +| `toolHeadChainsaw` | 185 | 0 | 8 / 0 | 17 / 0 | +| `toolHeadChisel` | 185 | 0 | 185 / 0 | 185 / 0 | +| `toolHeadConstructionPickaxe` | 275 | 0 | 8 / 0 | 275 / 0 | +| `toolHeadDrill` | 185 | 0 | 8 / 0 | 17 / 0 | +| `toolHeadFile` | 185 | 0 | 117 / 0 | 185 / 0 | +| `toolHeadHammer` | 266 | 0 | 147 / 0 | 266 / 0 | +| `toolHeadHoe` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadPickaxe` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadPickaxeGem` | 154 | 0 | 1 / 0 | 153 / 0 | +| `toolHeadPlow` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadRawArrow` | 271 | 0 | 10 / 0 | 271 / 0 | +| `toolHeadRawAxe` | 275 | 0 | 155 / 0 | 275 / 0 | +| `toolHeadRawAxeDouble` | 275 | 0 | 8 / 0 | 275 / 0 | +| `toolHeadRawChisel` | 185 | 0 | 8 / 0 | 185 / 0 | +| `toolHeadRawHoe` | 275 | 0 | 155 / 0 | 275 / 0 | +| `toolHeadRawPickaxe` | 275 | 0 | 155 / 0 | 275 / 0 | +| `toolHeadRawPlow` | 275 | 0 | 10 / 0 | 275 / 0 | +| `toolHeadRawSaw` | 185 | 0 | 117 / 0 | 185 / 0 | +| `toolHeadRawSense` | 275 | 0 | 10 / 0 | 275 / 0 | +| `toolHeadRawShovel` | 275 | 0 | 155 / 0 | 275 / 0 | +| `toolHeadRawSpade` | 275 | 0 | 10 / 0 | 275 / 0 | +| `toolHeadRawSword` | 275 | 0 | 155 / 0 | 275 / 0 | +| `toolHeadRawUniversalSpade` | 185 | 0 | 8 / 0 | 185 / 0 | +| `toolHeadSaw` | 185 | 0 | 185 / 0 | 185 / 0 | +| `toolHeadScrewdriver` | 185 | 0 | 8 / 0 | 185 / 0 | +| `toolHeadSense` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadShovel` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadSpade` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadSword` | 275 | 0 | 275 / 0 | 275 / 0 | +| `toolHeadUniversalSpade` | 185 | 0 | 185 / 0 | 185 / 0 | +| `toolHeadWrench` | 185 | 0 | 8 / 0 | 17 / 0 | +| `unit` | 745 | 0 | 0 / 0 | 289 / 0 | +| `wireFine` | 216 | 0 | 214 / 0 | 216 / 0 | + +## 修复与回归 + +`MaterialItemCompositions.registerOreBlockComposition(Block)` 统一识别三类实际矿石方块: + +- `DenseOreBlock` → `oreDense` +- `VanillaOreBlock` → `oreVanillastone` +- 非小型 `OreBlock` → `oreVanillastone` + +共享 `registerCommon()` 遍历 `GTBlocks`,Forge 和 NeoForge 的平台图标方块注册器复用同一函数。这样平台注册位置仍由各自加载器决定,材料成分事实不再由 Forge 专属代码单独补齐。 + +新增 GameTest `oreBlocksUseTheirDeclaredMaterialForm` 遍历当前平台实际注册的所有上述矿石方块,检查其物品成分存在、形态正确且材料与方块声明一致。最终双平台快照中 `oreVanillastone` 均为 396,124 个形态族的物品和方块计数全部一致。 + +## 验证 + +执行且通过: + +- `compileBothPlatforms`:Forge 与 NeoForge 生产源码编译通过。 +- 定向 Spotless:四个改动源码文件输出 `IS CLEAN`。 +- Forge `runGameTestServer`:`All 95 required tests passed`。 +- NeoForge `runGameTestServer`:`All 100 required tests passed`。 +- 双平台最终运行时快照:124 个形态族、31,137 个材料物品、3,532 个材料方块形态,逐族计数一致;`oreVanillastone` 均为 396。 + +执行但失败或阻塞:无。 + +尚未执行: + +- 07-F 的完整来源/用途索引、有界处理图、远程客户端 tooltip/JEI/EMI 和机器手工交互。 +- 最终 Forge `distributionJar`/NeoForge `jar` 的发行包内容检查。 +- 真实外部附属材料与可选模组环境。 + +本报告证明的是 07-E 的材料/形态去留清单和本轮必要迁移,不等同于 07-F 的完整处理图验收。静态配方快照没有展开所有动态族;相关动态单位来源和消费者已在源码点名核对,但仍须由 08-D—E 的最终索引给出完整边集合。 diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java new file mode 100644 index 000000000..23fadd2d5 --- /dev/null +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java @@ -0,0 +1,263 @@ +package gregtech.client; + +import gregtech.api.addon.recipe.RecipeOutputChances; +import gregtech.compat.common.MaterialProcessDisplay.Page; +import gregtech.compat.common.MaterialProcessDisplay.Port; +import gregtech.compat.common.MaterialProcessDisplay.Role; +import gregtech.compat.common.MaterialProcessDisplay.Step; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; + +/** Viewer-independent geometry and rendering; native ingredient widgets use exactly these slot positions. */ +public final class MaterialProcessPanel { + public static final int WIDTH = 280, HEIGHT = 216; + public static final int HEADER = 30, STEP_HEIGHT = 80, FOOTER = 196; + private static final int SIDE_LIMIT = 6; + private static final int MAIN_X = 132, STEP_X = 103, STEP_WIDTH = 74; + private static final int TEXT = 0xff404040, MUTED = 0xff707070, ACCENT = 0xff537962; + + public record Slot(Port port, int x, int y, boolean output) { + public boolean contains(double mouseX, double mouseY) { + return mouseX >= x && mouseX < x + 16 && mouseY >= y && mouseY < y + 16; + } + } + + private MaterialProcessPanel() {} + + public static List slots(Step step, int row) { + var slots = new ArrayList(); + addSlots(slots, step.inputs(), row, false); + addSlots(slots, step.outputs(), row, true); + return List.copyOf(slots); + } + + private static void addSlots(List slots, List ports, int row, boolean output) { + int side = 0; + for (var port : ports) { + if (port.main()) { + slots.add(new Slot(port, MAIN_X, HEADER + row * STEP_HEIGHT + (output ? 57 : 0), output)); + } else if (side < SIDE_LIMIT) { + slots.add(new Slot( + port, + (output ? 202 : 10) + side % 3 * 23, + HEADER + row * STEP_HEIGHT + 23 + side / 3 * 24, + output)); + side++; + } + } + } + + public static void draw(Page page, GuiGraphics graphics, double mouseX, double mouseY) { + text(graphics, page.title(), 2, 1, WIDTH - 42, TEXT); + text(graphics, Component.literal(page.number() + "/" + page.total()), WIDTH - 38, 1, 38, MUTED); + text(graphics, Component.translatable("gt6ce.jei.material_process.inputs"), 5, 16, 90, MUTED); + text(graphics, Component.translatable("gt6ce.jei.material_process.route"), 103, 16, 75, ACCENT); + text(graphics, Component.translatable("gt6ce.jei.material_process.outputs"), 194, 16, 86, MUTED); + for (int row = 0; row < page.steps().size(); row++) { + var step = page.steps().get(row); + int top = HEADER + row * STEP_HEIGHT; + int color = step.resolved() ? ACCENT : MUTED; + if (step.inputs().stream().anyMatch(Port::main)) + line(graphics, MAIN_X + 8, top + 17, MAIN_X + 8, top + 26, color, !step.resolved()); + graphics.fill( + STEP_X, + top + 26, + STEP_X + STEP_WIDTH, + top + 45, + processContains(row, mouseX, mouseY) ? 0xffd6e2d9 : 0xffe7e7e7); + text(graphics, step.name(), STEP_X + 3, top + 32, STEP_WIDTH - 6, color); + var displayed = slots(step, row); + for (var slot : displayed) { + int portColor = slot.port().role() == Role.BYPRODUCT ? 0xffb68a42 : color; + boolean uncertain = !step.resolved() + || slot.output() + && (slot.port().chance().isEmpty() + || slot.port().chance().getAsInt() < RecipeOutputChances.CERTAIN); + if (slot.port().main() && slot.output()) { + arrow(graphics, MAIN_X + 8, top + 53, portColor); + line(graphics, MAIN_X + 8, top + 45, MAIN_X + 8, top + 53, portColor, uncertain); + } + if (!slot.port().main()) { + int middle = slot.output() ? 188 : 88; + line( + graphics, + slot.output() ? STEP_X + STEP_WIDTH : STEP_X - 2, + top + 35, + middle, + top + 35, + portColor, + uncertain); + line(graphics, middle, top + 35, middle, slot.y() + 8, portColor, uncertain); + line( + graphics, + middle, + slot.y() + 8, + slot.output() ? slot.x() - 2 : slot.x() + 17, + slot.y() + 8, + portColor, + uncertain); + } + } + for (var slot : displayed) { + graphics.fill(slot.x() - 1, slot.y() - 1, slot.x() + 17, slot.y() + 17, 0xffa0a0a0); + graphics.fill(slot.x(), slot.y(), slot.x() + 16, slot.y() + 16, 0xffeeeeee); + if (!slot.port().hasIcons()) + text(graphics, Component.literal("?"), slot.x() + 5, slot.y() + 4, 10, MUTED); + if (!step.resolved() + || slot.output() + && (slot.port().chance().isEmpty() + || slot.port().chance().getAsInt() < RecipeOutputChances.CERTAIN)) + graphics.fill(slot.x() + 14, slot.y() - 1, slot.x() + 17, slot.y() + 2, 0xffc79c42); + } + overflow(graphics, step.inputs(), 5, top + 68); + overflow(graphics, step.outputs(), 202, top + 68); + long links = page.connections().stream() + .filter(connection -> connection.source().equals(step.reference()) + || connection.target().equals(step.reference())) + .count(); + if (links > 0) + text( + graphics, + Component.translatable("gt6ce.jei.material_process.links", links), + 153, + top + 65, + 45, + MUTED); + if (row + 1 < page.steps().size()) { + var next = page.steps().get(row + 1); + for (var connection : page.connections()) { + if (!connection.source().equals(step.reference()) + || !connection.target().equals(next.reference())) continue; + boolean mainOutput = step.outputs().stream() + .anyMatch(port -> port.main() && port.resource().equals(connection.resource())); + boolean mainInput = next.inputs().stream() + .anyMatch(port -> port.main() && port.resource().equals(connection.resource())); + if (mainOutput && mainInput) { + boolean uncertain = !connection.confirmed() + || !step.resolved() + || !next.resolved() + || step.outputs().stream() + .filter(Port::main) + .anyMatch(port -> port.chance().isEmpty() + || port.chance().getAsInt() < RecipeOutputChances.CERTAIN); + line(graphics, MAIN_X + 8, top + 74, MAIN_X + 8, top + 77, ACCENT, uncertain); + arrow(graphics, MAIN_X + 8, top + 77, ACCENT); + } + } + } + } + if (page.steps().isEmpty()) { + var font = Minecraft.getInstance().font; + graphics.drawWordWrap( + font, Component.translatable("gt6ce.jei.material_process.empty"), 14, 66, WIDTH - 28, MUTED); + graphics.drawWordWrap(font, page.notices().get(0), 14, 90, WIDTH - 28, MUTED); + } + graphics.fill(0, FOOTER - 3, WIDTH, FOOTER - 2, 0xffb0b0b0); + text(graphics, page.notices().get(0), 2, FOOTER, WIDTH - 4, MUTED); + text(graphics, Component.translatable("gt6ce.jei.material_process.controls"), 2, FOOTER + 11, WIDTH - 4, MUTED); + } + + public static List tooltip(Page page, double mouseX, double mouseY) { + if (mouseY >= FOOTER - 3) return page.notices(); + if (mouseY < HEADER) return List.of(page.title()); + for (int row = 0; row < page.steps().size(); row++) { + var step = page.steps().get(row); + if (processContains(row, mouseX, mouseY) + || mouseX >= 153 + && mouseX < 198 + && mouseY >= HEADER + row * STEP_HEIGHT + 64 + && mouseY < HEADER + row * STEP_HEIGHT + 77) { + var lines = new ArrayList(); + lines.add(step.name()); + lines.addAll(step.details()); + if (!step.resolved()) lines.add(Component.translatable("gt6ce.jei.material_process.unresolved")); + for (var connection : page.connections()) { + if (connection.source().equals(step.reference()) + || connection.target().equals(step.reference())) + lines.add(Component.translatable( + "gt6ce.jei.material_process.connection", + connection.source().toString(), + connection.target().toString(), + connection.resource().toString(), + Component.translatable( + connection.confirmed() + ? "gt6ce.jei.material_process.confirmed" + : "gt6ce.jei.material_process.unresolved"))); + } + lines.add(Component.translatable("gt6ce.jei.material_process.open_recipe")); + return lines; + } + for (var slot : slots(step, row)) + if (slot.contains(mouseX, mouseY)) return slot.port().tooltip(); + int top = HEADER + row * STEP_HEIGHT; + if (mouseY >= top + 67 && mouseY < top + 79) { + var ports = mouseX < STEP_X ? step.inputs() : mouseX >= 194 ? step.outputs() : List.of(); + var hidden = ports.stream() + .filter(port -> !port.main()) + .skip(SIDE_LIMIT) + .toList(); + if (!hidden.isEmpty()) { + var lines = new ArrayList(); + lines.add(Component.translatable("gt6ce.jei.material_process.more", hidden.size())); + for (var port : hidden) lines.addAll(port.tooltip()); + return lines; + } + } + } + return List.of(); + } + + public static boolean click(Page page, double mouseX, double mouseY, int button) { + if (button != 0 && button != 1) return false; + for (int row = 0; row < page.steps().size(); row++) { + var step = page.steps().get(row); + if (button == 0 && step.resolved() && processContains(row, mouseX, mouseY)) + return page.navigation().openRecipe(step.reference()); + for (var slot : slots(step, row)) + if (slot.contains(mouseX, mouseY)) + return page.navigation().openForm(slot.port().resource(), button == 1); + } + return false; + } + + private static boolean processContains(int row, double mouseX, double mouseY) { + int top = HEADER + row * STEP_HEIGHT; + return mouseX >= STEP_X && mouseX < STEP_X + STEP_WIDTH && mouseY >= top + 26 && mouseY < top + 45; + } + + private static void overflow(GuiGraphics graphics, List ports, int x, int y) { + long count = ports.stream().filter(port -> !port.main()).count() - SIDE_LIMIT; + if (count > 0) + text(graphics, Component.translatable("gt6ce.jei.material_process.more", count), x, y, 76, MUTED); + } + + private static void text(GuiGraphics graphics, Component value, int x, int y, int width, int color) { + var font = Minecraft.getInstance().font; + graphics.drawString( + font, + net.minecraft.locale.Language.getInstance().getVisualOrder(font.substrByWidth(value, width)), + x, + y, + color, + false); + } + + private static void arrow(GuiGraphics graphics, int x, int y, int color) { + graphics.fill(x - 2, y, x + 3, y + 1, color); + graphics.fill(x - 1, y + 1, x + 2, y + 2, color); + graphics.fill(x, y + 2, x + 1, y + 3, color); + } + + private static void line(GuiGraphics graphics, int x1, int y1, int x2, int y2, int color, boolean dashed) { + int length = Math.max(Math.abs(x2 - x1), Math.abs(y2 - y1)); + for (int offset = 0; offset <= length; offset++) { + if (dashed && offset % 5 >= 3) continue; + int x = x1 + Integer.signum(x2 - x1) * offset; + int y = y1 + Integer.signum(y2 - y1) * offset; + graphics.fill(x, y, x + 1, y + 1, color); + } + } +} diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java new file mode 100644 index 000000000..fa751a45d --- /dev/null +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java @@ -0,0 +1,229 @@ +package gregtech.compat.common; + +import gregtech.api.addon.material.DataKey; +import gregtech.api.addon.recipe.RecipeOutputChances; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.OptionalInt; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; + +/** + * Client presentation values for an already bounded process query. This is not a source index or an execution model. + * No material catalog, native recipe enumeration, or viewer API is accessed here. + */ +public final class MaterialProcessDisplay { + public static final int STEPS_PER_PAGE = 2; + public static final int MAX_STEPS = 64; + public static final int MAX_PORTS = 64; + public static final int MAX_ICONS = 16; + public static final int MAX_CONNECTIONS = 128; + + /** Roles come from the producer; neither slot order nor quantity establishes a primary output. */ + public enum Role { + CONSUMED, + CATALYST, + PRESENCE, + PRIMARY, + BYPRODUCT, + UNKNOWN + } + + /** + * A snapshot-local resource reference, including form and native state. Icons are bounded display representatives, + * not an expansion of a tag or unit family. Empty icons describe a symbolic selector. + * Amount includes its unit; chance uses {@link RecipeOutputChances#CERTAIN}, or is explicitly unknown. + */ + public record Port( + DataKey resource, + Component name, + List icons, + Role role, + boolean main, + Component amount, + OptionalInt chance, + List details) { + public Port { + Objects.requireNonNull(resource); + name = name.copy(); + amount = amount.copy(); + Objects.requireNonNull(role); + Objects.requireNonNull(chance); + if (icons.size() > MAX_ICONS) throw new IllegalArgumentException("Too many display representatives"); + icons = icons.stream().map(ItemStack::copy).toList(); + if (icons.stream().anyMatch(ItemStack::isEmpty)) + throw new IllegalArgumentException("Use an empty icon list for symbolic resources"); + if (chance.isPresent() && (chance.getAsInt() < 1 || chance.getAsInt() > RecipeOutputChances.CERTAIN)) + throw new IllegalArgumentException("Invalid output chance"); + details = copyText(details); + } + + @Override + public List icons() { + return icons.stream().map(ItemStack::copy).toList(); + } + + public boolean hasIcons() { + return !icons.isEmpty(); + } + + public List tooltip() { + var lines = new ArrayList(); + lines.add(name); + lines.add(amount); + lines.add(Component.translatable( + "gt6ce.jei.material_process.role." + role.name().toLowerCase(java.util.Locale.ROOT))); + if (isOutput(role)) { + lines.add( + chance.isPresent() + ? Component.translatable("gt6ce.jei.chance", chance.getAsInt() / 100.0) + : Component.translatable("gt6ce.jei.material_process.chance_unknown")); + } + lines.addAll(details); + return List.copyOf(lines); + } + } + + /** Explicit edges from the producer, including branches and cycles. Unconfirmed edges are drawn dashed. */ + public record Connection(DataKey source, DataKey target, DataKey resource, boolean confirmed) { + public Connection { + Objects.requireNonNull(source); + Objects.requireNonNull(target); + Objects.requireNonNull(resource); + } + } + + /** All co-inputs and outputs belong to this one step. Main is a layout hint, separate from the output role. */ + public record Step( + DataKey reference, + Component name, + List inputs, + List outputs, + List details, + boolean resolved) { + public Step { + Objects.requireNonNull(reference); + name = name.copy(); + inputs = List.copyOf(inputs); + outputs = List.copyOf(outputs); + validatePorts(inputs, false); + validatePorts(outputs, true); + details = copyText(details); + } + } + + /** + * Bind callbacks to the same query session/generation as the page. Revalidate before resolving native references; + * return false for expired or unsupported targets. Implementations run on the client thread. + */ + public interface Navigation { + Navigation NONE = new Navigation() { + @Override + public boolean openRecipe(DataKey reference) { + return false; + } + + @Override + public boolean openForm(DataKey resource, boolean uses) { + return false; + } + }; + + boolean openRecipe(DataKey reference); + + boolean openForm(DataKey resource, boolean uses); + } + + /** Coverage and truncation reasons are always visible through the footer tooltip, including for empty queries. */ + public record Page( + Component title, + List steps, + List connections, + List notices, + int number, + int total, + Navigation navigation) { + public Page { + title = title.copy(); + steps = List.copyOf(steps); + connections = List.copyOf(connections); + notices = copyText(notices); + Objects.requireNonNull(navigation); + if (steps.size() > STEPS_PER_PAGE + || connections.size() > MAX_CONNECTIONS + || number < 1 + || total < number + || notices.isEmpty()) throw new IllegalArgumentException("Invalid process display page"); + } + } + + private MaterialProcessDisplay() {} + + /** Split a bounded, producer-ordered result without dropping steps. No graph traversal or candidate expansion. */ + public static List pages( + Component title, + List steps, + List connections, + List notices, + Navigation navigation) { + if (steps.size() > MAX_STEPS) throw new IllegalArgumentException("Process query exceeds display budget"); + if (connections.size() > MAX_CONNECTIONS) throw new IllegalArgumentException("Too many process connections"); + var references = new HashMap(); + for (var step : steps) + if (references.putIfAbsent(step.reference(), step) != null) + throw new IllegalArgumentException("Duplicate process reference"); + var uniqueConnections = new HashSet(); + for (var connection : connections) { + if (!references.containsKey(connection.source()) + || !references.containsKey(connection.target()) + || !uniqueConnections.add(connection)) + throw new IllegalArgumentException("Invalid process connection"); + if (references.get(connection.source()).outputs().stream() + .noneMatch(port -> port.resource().equals(connection.resource())) + || references.get(connection.target()).inputs().stream() + .noneMatch(port -> port.resource().equals(connection.resource()))) + throw new IllegalArgumentException("Connection does not match process ports"); + } + int total = Math.max(1, (steps.size() + STEPS_PER_PAGE - 1) / STEPS_PER_PAGE); + var pages = new ArrayList(total); + for (int index = 0; index < total; index++) { + int start = index * STEPS_PER_PAGE; + pages.add(new Page( + title, + steps.subList(start, Math.min(start + STEPS_PER_PAGE, steps.size())), + connections, + notices, + index + 1, + total, + navigation)); + } + return List.copyOf(pages); + } + + public static List unbound() { + return pages( + Component.translatable("gt6ce.jei.material_process.title"), + List.of(), + List.of(), + List.of(Component.translatable("gt6ce.jei.material_process.unbound")), + Navigation.NONE); + } + + private static boolean isOutput(Role role) { + return role == Role.PRIMARY || role == Role.BYPRODUCT || role == Role.UNKNOWN; + } + + private static void validatePorts(List ports, boolean output) { + if (ports.size() > MAX_PORTS || ports.stream().filter(Port::main).count() > 1) + throw new IllegalArgumentException("Invalid process ports"); + for (var port : ports) + if (isOutput(port.role()) != output) throw new IllegalArgumentException("Port role on wrong side"); + } + + private static List copyText(List lines) { + return lines.stream().map(line -> (Component) line.copy()).toList(); + } +} diff --git a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java index c31e5f2bf..29f4b78a8 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java @@ -94,6 +94,7 @@ public void registerCategories(IRecipeCategoryRegistration registration) { registration.addRecipeCategories(new MultiblockInfoCategory(guiHelper)); registration.addRecipeCategories(new ToolAssemblyCategory.Category(guiHelper)); registration.addRecipeCategories(new MoldChiselCategory(guiHelper)); + registration.addRecipeCategories(new MaterialProcessCategory(guiHelper)); registration.addRecipeCategories( new WorldgenInfoCategories.VeinCategory(guiHelper), new WorldgenInfoCategories.SmallOreCategory(guiHelper), @@ -182,6 +183,7 @@ public void registerRecipes(IRecipeRegistration registration) { //?} registration.addRecipes(MoldChiselCategory.TYPE, gregtech.compat.common.MoldChiselDisplay.recipes()); + registration.addRecipes(MaterialProcessCategory.TYPE, gregtech.compat.common.MaterialProcessDisplay.unbound()); var unitTags = gregtech.compat.common.MaterialUnitTagDisplay.entries(); for (var family : MaterialUnitTagCategory.FAMILIES) registration.addRecipes(MaterialUnitTagCategory.type(family), MaterialUnitTagCategory.pages(family, unitTags)); diff --git a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java new file mode 100644 index 000000000..d00c7fcd7 --- /dev/null +++ b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java @@ -0,0 +1,110 @@ +package gregtech.compat.jei; + +import gregtech.client.MaterialProcessPanel; +import gregtech.compat.common.MaterialProcessDisplay.Page; +import gregtech.compat.common.MaterialProcessDisplay.Port; +import java.util.ArrayList; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.builder.ITooltipBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.gui.inputs.IJeiGuiEventListener; +import mezz.jei.api.gui.widgets.IRecipeExtrasBuilder; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.navigation.ScreenRectangle; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; + +/** JEI adapter only; producers register bounded pages through the normal JEI recipe registration/runtime API. */ +public final class MaterialProcessCategory implements IRecipeCategory { + public static final RecipeType TYPE = RecipeType.create("gt6ce", "material_process", Page.class); + private final IDrawable icon; + + public MaterialProcessCategory(IGuiHelper helper) { + icon = helper.createDrawableItemStack(new ItemStack(Items.MAP)); + } + + @Override + public RecipeType getRecipeType() { + return TYPE; + } + + @Override + public Component getTitle() { + return Component.translatable("gt6ce.jei.material_process.title"); + } + + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public int getWidth() { + return MaterialProcessPanel.WIDTH; + } + + @Override + public int getHeight() { + return MaterialProcessPanel.HEIGHT; + } + + @Override + public void setRecipe(IRecipeLayoutBuilder builder, Page page, IFocusGroup focuses) { + for (int row = 0; row < page.steps().size(); row++) { + var step = page.steps().get(row); + var visible = MaterialProcessPanel.slots(step, row); + for (var slot : visible) { + if (!slot.port().hasIcons()) continue; + builder.addSlot(role(slot.port()), slot.x(), slot.y()) + .addItemStacks(slot.port().icons()) + .addRichTooltipCallback( + (view, tooltip) -> tooltip.addAll(slot.port().tooltip())); + } + var ports = new ArrayList(step.inputs()); + ports.addAll(step.outputs()); + for (var port : ports) + if (visible.stream().noneMatch(slot -> slot.port() == port) && port.hasIcons()) + builder.addInvisibleIngredients(role(port)).addItemStacks(port.icons()); + } + } + + private static RecipeIngredientRole role(Port port) { + return switch (port.role()) { + case CONSUMED -> RecipeIngredientRole.INPUT; + case CATALYST, PRESENCE -> RecipeIngredientRole.CATALYST; + case PRIMARY, BYPRODUCT, UNKNOWN -> RecipeIngredientRole.OUTPUT; + }; + } + + @Override + public void createRecipeExtras(IRecipeExtrasBuilder builder, Page page, IFocusGroup focuses) { + builder.addGuiEventListener(new IJeiGuiEventListener() { + @Override + public ScreenRectangle getArea() { + return new ScreenRectangle(0, 0, MaterialProcessPanel.WIDTH, MaterialProcessPanel.HEIGHT); + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + return MaterialProcessPanel.click(page, mouseX, mouseY, button); + } + }); + } + + @Override + public void draw(Page page, IRecipeSlotsView slots, GuiGraphics graphics, double mouseX, double mouseY) { + MaterialProcessPanel.draw(page, graphics, mouseX, mouseY); + } + + @Override + public void getTooltip(ITooltipBuilder tooltip, Page page, IRecipeSlotsView slots, double mouseX, double mouseY) { + tooltip.addAll(MaterialProcessPanel.tooltip(page, mouseX, mouseY)); + } +} diff --git a/minecraft/src/main/java/gregtech/content/material/MaterialItemCompositions.java b/minecraft/src/main/java/gregtech/content/material/MaterialItemCompositions.java index f180799f9..573ff56b2 100644 --- a/minecraft/src/main/java/gregtech/content/material/MaterialItemCompositions.java +++ b/minecraft/src/main/java/gregtech/content/material/MaterialItemCompositions.java @@ -3,7 +3,10 @@ import gregtech.api.material.GTValues; import gregtech.api.material.MaterialComponent; import gregtech.content.block.BlockMaterialWeights; +import gregtech.content.block.DenseOreBlock; import gregtech.content.block.MaterialBlockLike; +import gregtech.content.block.OreBlock; +import gregtech.content.block.VanillaOreBlock; import gregtech.content.block.machine.BasicMachineBlock; import gregtech.content.block.stone.GTStoneBlock; import gregtech.content.block.stone.GTStoneSlabBlock; @@ -32,6 +35,7 @@ private MaterialItemCompositions() {} public static void registerCommon() { ItemMaterialRuntimeFacts.install(ItemMaterialContentFacts.INSTANCE); registerMaterialItemForms(); + registerOwnedOreCompositions(); registerBlockWeights(); registerMachineConstruction(); registerSingleItemMaterials(); @@ -105,6 +109,36 @@ private static void registerBlockWeights() { } } + private static void registerOwnedOreCompositions() { + for (var holder : GTBlocks.allEntries()) { + if (holder.isPresent()) registerOreBlockComposition(holder.get()); + } + } + + /** + * Gives an actual ore block the same material-form identity independent of which loader-specific + * registry owns it. + */ + public static boolean registerOreBlockComposition(Block block) { + MaterialPrefix prefix; + gregtech.api.material.GTMaterial material; + if (block instanceof DenseOreBlock ore) { + prefix = MaterialPrefix.oreDense; + material = ore.material(); + } else if (block instanceof VanillaOreBlock ore) { + prefix = MaterialPrefix.oreVanillastone; + material = ore.material(); + } else if (block instanceof OreBlock ore && !ore.isSmall()) { + prefix = MaterialPrefix.oreVanillastone; + material = ore.material(); + } else { + return false; + } + if (material == null || !material.isValid()) return false; + ItemMaterialRegistry.register(block.asItem(), prefix, material); + return true; + } + private static void registerMachineConstruction() { for (Block block : BuiltInRegistries.BLOCK) { var id = BuiltInRegistries.BLOCK.getKey(block); diff --git a/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java b/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java index 144a9c15a..bedd7a7ea 100644 --- a/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java +++ b/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java @@ -11,6 +11,9 @@ import gregtech.content.block.machine.MoldBlock; import gregtech.content.block.machine.MoldItemData; import gregtech.content.block.machine.BasicMachineBlock; +import gregtech.content.block.DenseOreBlock; +import gregtech.content.block.OreBlock; +import gregtech.content.block.VanillaOreBlock; import gregtech.content.blockentity.machine.BasicMachineBlockEntity; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.data.MaterialPrefix; @@ -48,6 +51,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; //? if >=1.21.1 { /*import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.gametest.GameTestHolder; @@ -257,6 +261,39 @@ public static void registeredFormsPublishItemBlockAndFluidBindings(GameTestHelpe helper.succeed(); } + @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) + public static void oreBlocksUseTheirDeclaredMaterialForm(GameTestHelper helper) { + int checked = 0; + for (Block block : BuiltInRegistries.BLOCK) { + MaterialPrefix expected; + gregtech.api.material.GTMaterial material; + if (block instanceof DenseOreBlock ore) { + expected = MaterialPrefix.oreDense; + material = ore.material(); + } else if (block instanceof VanillaOreBlock ore) { + expected = MaterialPrefix.oreVanillastone; + material = ore.material(); + } else if (block instanceof OreBlock ore && !ore.isSmall()) { + expected = MaterialPrefix.oreVanillastone; + material = ore.material(); + } else { + continue; + } + checked++; + var item = block.asItem(); + var composition = ItemMaterialRegistry.base(item).orElse(null); + helper.assertTrue(composition != null, "missing ore composition: " + id(new ItemStack(item))); + helper.assertTrue( + composition.prefix() == expected, + "wrong ore form: " + id(new ItemStack(item)) + " -> " + composition.prefix()); + helper.assertTrue( + composition.material().resolve() == material.resolve(), + "wrong ore material: " + id(new ItemStack(item))); + } + helper.assertTrue(checked > 0, "no registered ore block was checked"); + helper.succeed(); + } + @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) public static void storageBlocksExposeCompositionAndBothAdmissions(GameTestHelper helper) { var iron = ItemMaterialRegistry.get(new ItemStack(Items.IRON_BLOCK)).orElseThrow(); diff --git a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMaterialRegistration.java b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMaterialRegistration.java index 44e4ae40c..9f38eaebf 100644 --- a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMaterialRegistration.java +++ b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMaterialRegistration.java @@ -1,9 +1,7 @@ package gregtech.content.registry; import gregtech.GregTech; -import gregtech.api.material.GTMaterial; import gregtech.api.material.GTValues; -import gregtech.content.data.MaterialPrefixes; import gregtech.content.material.MaterialItemCompositions; import gregtech.engine.material.ItemMaterialRegistry; import net.minecraft.resources.ResourceLocation; @@ -21,7 +19,6 @@ public static void registerAll() { GregTech.LOGGER.info("[{}] Registering GT platform block item materials", GregTech.NAMESPACE); MaterialItemCompositions.registerCommon(); int count = registerIconSetOres(); - count += registerOwnedOres(); count += registerPlants(); GregTech.LOGGER.info("[{}] Registered {} Forge-specific block item compositions", GregTech.NAMESPACE, count); } @@ -34,33 +31,7 @@ private static int registerIconSetOres() { if (block instanceof gregtech.content.block.BlackSandBlock sand) { ItemMaterialRegistry.register(sand.asItem(), null, sand.material(), GTValues.U * 9); count++; - } else if (block instanceof gregtech.content.block.DenseOreBlock ore) { - GTMaterial material = ore.material(); - if (material != null && material.isValid()) { - ItemMaterialRegistry.register(block.asItem(), MaterialPrefixes.oreDense.getDelegate(), material); - count++; - } - } else if (block instanceof gregtech.content.block.VanillaOreBlock ore) { - GTMaterial material = ore.material(); - if (material != null && material.isValid()) { - ItemMaterialRegistry.register( - block.asItem(), MaterialPrefixes.oreVanillastone.getDelegate(), material); - count++; - } - } - } - return count; - } - - private static int registerOwnedOres() { - int count = 0; - for (RegisteredBlock entry : GTBlocks.allEntries()) { - if (!entry.isPresent()) continue; - if (entry.get() instanceof gregtech.content.block.OreBlock ore && !ore.isSmall()) { - ItemMaterialRegistry.register( - ore.asItem(), MaterialPrefixes.oreVanillastone.getDelegate(), ore.material()); - count++; - } + } else if (MaterialItemCompositions.registerOreBlockComposition(block)) count++; } return count; } diff --git a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTSpecialOreBlocks.java b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTSpecialOreBlocks.java index ec11967a6..f68e56f29 100644 --- a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTSpecialOreBlocks.java +++ b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTSpecialOreBlocks.java @@ -1,19 +1,21 @@ package gregtech.content.registry; -import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; - import gregtech.content.block.*; import gregtech.content.data.MaterialPrefix; +import gregtech.content.material.MaterialItemCompositions; import gregtech.engine.material.ItemMaterialRegistry; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; + /** Actual original crystal/rock/vanilla ore blocks from GTIconSetBlocks; no decorative substitutes. */ public final class GTSpecialOreBlocks { private static final List> ALL = new ArrayList<>(); @@ -79,11 +81,7 @@ private static Block create(String icon) { public static void registerCompositions() { for (var holder : ALL) { - Block block = holder.get(); - if (block instanceof DenseOreBlock ore) - ItemMaterialRegistry.register(block.asItem(), MaterialPrefix.oreDense, ore.material()); - else if (block instanceof VanillaOreBlock ore) - ItemMaterialRegistry.register(block.asItem(), MaterialPrefix.oreVanillastone, ore.material()); + MaterialItemCompositions.registerOreBlockComposition(holder.get()); } ItemMaterialRegistry.register( GTItems.getStack(MaterialPrefix.plate, gregtech.content.material.generated.WoodMaterials.WoodTreated) diff --git a/tools/README.md b/tools/README.md index 32da98eeb..40269b89e 100644 --- a/tools/README.md +++ b/tools/README.md @@ -6,6 +6,7 @@ | --- | --- | | [comments/](comments/README.md) | 检查代码注释里的失效引用,并证明一次改动只碰了注释。 | | [gui/](gui/README.md) | 检查 GUI 模板、别名、图标引用与静态预览。 | +| [material/](material/README.md) | 汇总最终运行时材料物品、方块形态、获得来源和配方消费者。 | | [recipes/](recipes/README.md) | 审计数据包配方的形状、标签、电路家族、歧义与 NeoForge 覆盖。 | | [resources/](resources/README.md) | 核对模板化发行包的模型、方块状态与 PNG 完整性。 | | [validation/](validation/README.md) | 读取验证路由表,计算改动对应的检查并校验文档闭合。 | diff --git a/tools/material/README.md b/tools/material/README.md new file mode 100644 index 000000000..82b8f131d --- /dev/null +++ b/tools/material/README.md @@ -0,0 +1,39 @@ +# material:材料形态清单审计 + +`audit_roster.py` 只读 GameTest 写出的运行时快照,不启动游戏、不调用 Gradle、不修改仓库。 + +## 输入 + +传入包含以下文件的单个运行目录: + +- `reload-items.tsv` +- `reload-forms.tsv` +- `reload-block-forms.tsv` +- `reload-recipes.tsv` +- `reload-tags.tsv` + +这些文件由共享 `MaterialBaselineTests` 生成。必须使用同一次首次启动或重载代,不能混用不同运行目录。 + +## 运行 + +```bash +python3 tools/material/audit_roster.py \ + work/material-system-refactor/runtime/1.20.1/gametest-forge + +# 完整 JSON 证据放到被忽略的 work/ +python3 tools/material/audit_roster.py \ + work/material-system-refactor/runtime/1.20.1/gametest-forge \ + --json work/material-system-refactor/07e/forge.json +``` + +输出按 prefix 汇总实际物品数、材料方块数、静态配方输出/输入对象数,以及各 `RecipeMap` 的命中数。物品 tag 输入会展开为其实际成员;同一个物品如果同时是材料物品和方块形态,会分别计入两个形态族。 + +## 边界 + +- 配方计数来自 `RecipeMap.mRecipeList`,不展开所有动态族。 +- 手工配方、世界生成、铸币、化石和展示用途没有统一静态表,必须按源码或专门运行时测试补证。 +- 本脚本证明注册清单和静态配方入口的一致性,不替代完整来源/用途图、客户端展示或机器执行验收。 + +## 维护 + +快照列格式变化时同步修改 `recipe_items`、物品 prefix 读取和方块形态读取。最终清单口径变化时应同时更新 [07-E 验收报告](../../docs/integration/material-refactor-07-roster.md)。 diff --git a/tools/material/audit_roster.py b/tools/material/audit_roster.py new file mode 100644 index 000000000..33da2898c --- /dev/null +++ b/tools/material/audit_roster.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python3 +"""Summarize material forms from a fresh runtime baseline.""" + +from __future__ import annotations + +import argparse +import collections +import csv +import json +import re +from pathlib import Path + + +def recipe_items(slots: str) -> tuple[set[str], set[str], set[str]]: + inputs: set[str] = set() + outputs: set[str] = set() + input_tags: set[str] = set() + for slot in slots.split(";"): + if slot.startswith("in["): + item_match = re.search(r"=(.+?)\*(\d+):", slot) + tag_match = re.search(r":tag=(.+?):catalyst=", slot) + if item_match: + inputs.add(item_match.group(1)) + if tag_match and tag_match.group(1) != "-": + input_tags.add(tag_match.group(1)) + elif slot.startswith("out["): + item_match = re.search(r"=(.+?)\*(\d+):", slot) + if item_match: + outputs.add(item_match.group(1)) + return inputs, outputs, input_tags + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("snapshot", type=Path) + parser.add_argument("--json", type=Path) + args = parser.parse_args() + + forms: dict[str, dict[str, str]] = {} + with (args.snapshot / "reload-forms.tsv").open() as source: + for row in csv.reader(source, delimiter="\t"): + if len(row) == 5: + forms[row[0]] = {"prefix": row[1], "material": row[2], "weight": row[3], "valid": row[4]} + + items: dict[str, list[str]] = {} + with (args.snapshot / "reload-items.tsv").open() as source: + for row in csv.reader(source, delimiter="\t"): + items[row[0]] = row + + block_forms: dict[str, dict[str, str]] = {} + with (args.snapshot / "reload-block-forms.tsv").open() as source: + for row in csv.reader(source, delimiter="\t"): + if len(row) == 6: + block_forms[row[1]] = { + "block": row[0], + "prefix": row[2], + "material": row[3], + "weight": row[4], + "valid": row[5], + } + + item_prefixes = { + item: row[1] for item, row in items.items() if len(row) == 12 and row[1] != "-" + } + + tags: dict[str, set[str]] = {} + with (args.snapshot / "reload-tags.tsv").open() as source: + for row in csv.reader(source, delimiter="\t"): + if len(row) == 2 and row[0].startswith("item:"): + tags[row[0].removeprefix("item:")] = set(filter(None, row[1].split(","))) + + source_maps: dict[str, collections.Counter[str]] = collections.defaultdict(collections.Counter) + input_maps: dict[str, collections.Counter[str]] = collections.defaultdict(collections.Counter) + exact_sources: dict[str, set[str]] = collections.defaultdict(set) + exact_inputs: dict[str, set[str]] = collections.defaultdict(set) + + with (args.snapshot / "reload-recipes.tsv").open() as source: + for row in csv.reader(source, delimiter="\t"): + if len(row) < 2: + continue + recipe_map, slots = row[0], row[1] + inputs, outputs, input_tags = recipe_items(slots) + for tag in input_tags: + inputs.update(tags.get(tag, ())) + for item in outputs: + prefix = item_prefixes.get(item) + if prefix: + source_maps[prefix][recipe_map] += 1 + exact_sources[prefix].add(item) + if item in block_forms: + prefix = block_forms[item]["prefix"] + source_maps[prefix][recipe_map] += 1 + exact_sources[prefix].add(item) + for item in inputs: + prefix = item_prefixes.get(item) + if prefix: + input_maps[prefix][recipe_map] += 1 + exact_inputs[prefix].add(item) + if item in block_forms: + prefix = block_forms[item]["prefix"] + input_maps[prefix][recipe_map] += 1 + exact_inputs[prefix].add(item) + + prefix_items = collections.defaultdict(set) + for item, prefix in item_prefixes.items(): + prefix_items[prefix].add(item) + for item, form in forms.items(): + prefix_items[form["prefix"]].add(item) + + prefix_blocks = collections.defaultdict(set) + for item, form in block_forms.items(): + prefix_blocks[form["prefix"]].add(form["block"]) + + result = {} + for prefix in sorted(prefix_items.keys() | prefix_blocks.keys()): + members = prefix_items[prefix] + result[prefix] = { + "items": len(members), + "material_form_items": sum(item in forms for item in members), + "material_components": len( + {forms[item]["material"] for item in members if item in forms} + ), + "composition_items": sum(item in items for item in members), + "source_items": len(exact_sources[prefix]), + "input_items": len(exact_inputs[prefix]), + "source_maps": dict(source_maps[prefix].most_common()), + "input_maps": dict(input_maps[prefix].most_common()), + "blocks": len(prefix_blocks[prefix]), + "source_blocks": len({block for block in prefix_blocks[prefix] if block in exact_sources[prefix]}), + "input_blocks": len({block for block in prefix_blocks[prefix] if block in exact_inputs[prefix]}), + } + + rendered = json.dumps(result, ensure_ascii=False, indent=2, sort_keys=True) + "\n" + if args.json: + args.json.write_text(rendered) + else: + print(rendered, end="") + + +if __name__ == "__main__": + main() From 8722ac6291a66be0bc5a7aa3a3c9a29f4a0c61c3 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Sat, 14 Nov 2026 00:00:10 +0800 Subject: [PATCH 03/17] add material display graph --- .../engine/material/MaterialProcessGraph.java | 439 +++++++++++++ .../engine/material/MaterialViews.java | 6 + .../resources/assets/gt6ce/lang/en_us.json | 17 + .../resources/assets/gt6ce/lang/zh_cn.json | 17 + .../material/MaterialProcessGraphTest.java | 146 +++++ docs/architecture/packages/engine.md | 2 +- docs/architecture/packages/runtime.md | 2 +- docs/development/material-process-display.md | 17 +- .../07-cleanup-and-acceptance.md | 6 +- .../08-material-data-api.md | 77 ++- .../material-system-refactor/README.md | 6 +- .../material-refactor-07-roster.md | 4 +- .../gregtech/client/MachineRecipeClient.java | 9 + .../common/MaterialProcessProjection.java | 250 +++++++ .../compat/emi/GregTechEMIPlugin.java | 43 ++ .../compat/emi/MaterialProcessEmiRecipe.java | 203 ++++++ .../compat/jei/GregTechJEIPlugin.java | 47 +- .../gregtech/compat/jei/WorldgenInfoData.java | 2 +- .../content/recipe/MachineRecipeOverlay.java | 1 + .../recipe/MaterialProcessSnapshot.java | 609 ++++++++++++++++++ .../content/recipe/OvenRecipeBridge.java | 3 + .../worldgen/MaterialWorldgenFacts.java | 283 ++++++++ .../gametest/MaterialBaselineTests.java | 49 ++ 23 files changed, 2214 insertions(+), 24 deletions(-) create mode 100644 core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java create mode 100644 core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java create mode 100644 minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java create mode 100644 minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java create mode 100644 minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java create mode 100644 minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java diff --git a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java new file mode 100644 index 000000000..40d40c253 --- /dev/null +++ b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java @@ -0,0 +1,439 @@ +package gregtech.engine.material; + +import gregtech.api.addon.material.DataKey; + +import java.util.*; + +/** + * Immutable semantic process graph for one published material generation. + * + *

The graph owns no native recipe or world-generation objects. Queries traverse only their + * published ports and return bounded immutable rows for a viewer adapter to project.

+ */ +public final class MaterialProcessGraph { + /** One transaction boundary with the form, tag and active worldgen revisions used by the rows. */ + public record Snapshot( + MaterialPublication.Stamp publication, + long sessionGeneration, + long formRevision, + long tagGeneration, + long worldgenRevision) { + public Snapshot { + Objects.requireNonNull(publication); + if (sessionGeneration <= 0 || formRevision < 0 || tagGeneration < 0 || worldgenRevision < 0) + throw new IllegalArgumentException("Invalid process graph snapshot"); + } + } + + public enum Direction { + SOURCES, + USES, + BOTH + } + + public enum Role { + CONSUMED, + CATALYST, + PRESENCE, + PRIMARY, + BYPRODUCT, + UNKNOWN + } + + public enum AmountUnit { + ITEM, + MATERIAL_UNIT, + MILLIBUCKET, + UNKNOWN + } + + /** Resource identity keeps material, form, phase and native selector/state separate. */ + public record Resource(DataKey key, String material, String form, String phase, String state) { + public Resource { + Objects.requireNonNull(key); + requireText(material, "material"); + requireText(form, "form"); + requireText(phase, "phase"); + requireText(state, "state"); + } + } + + public record Amount(long value, AmountUnit unit) { + public Amount { + if (value < 0) throw new IllegalArgumentException("Negative process amount"); + Objects.requireNonNull(unit); + } + + public static Amount unknown() { + return new Amount(0, AmountUnit.UNKNOWN); + } + } + + public record Port( + Resource resource, Role role, Amount amount, OptionalInt chance, boolean main, List details) { + public Port { + Objects.requireNonNull(resource); + Objects.requireNonNull(role); + Objects.requireNonNull(amount); + Objects.requireNonNull(chance); + if (chance.isPresent() && (chance.getAsInt() < 1 || chance.getAsInt() > 10_000)) + throw new IllegalArgumentException("Invalid process chance"); + details = List.copyOf(details); + } + + public boolean output() { + return role == Role.PRIMARY || role == Role.BYPRODUCT || role == Role.UNKNOWN; + } + } + + public record Step( + DataKey reference, + String name, + List inputs, + List outputs, + List details, + boolean resolved) { + public Step { + Objects.requireNonNull(reference); + requireText(name, "process step name"); + inputs = List.copyOf(inputs); + outputs = List.copyOf(outputs); + if (inputs.stream().anyMatch(Port::output) || outputs.stream().anyMatch(port -> !port.output())) + throw new IllegalArgumentException("Port role on wrong side"); + if (inputs.stream().filter(Port::main).count() > 1 + || outputs.stream().filter(Port::main).count() > 1) + throw new IllegalArgumentException("Multiple main process ports"); + details = List.copyOf(details); + } + } + + public record Edge(DataKey source, DataKey target, DataKey resource, boolean confirmed) { + public Edge { + Objects.requireNonNull(source); + Objects.requireNonNull(target); + Objects.requireNonNull(resource); + } + } + + public record Budgets(int maxDepth, int maxSteps, int maxPortsPerSide, int maxEdges) { + public static final Budgets DEFAULT = new Budgets(8, 64, 64, 128); + + public Budgets { + if (maxDepth < 0 || maxSteps <= 0 || maxPortsPerSide <= 0 || maxEdges < 0) + throw new IllegalArgumentException("Invalid process graph budget"); + } + } + + public record Notice(String code, int omitted) { + public Notice { + requireText(code, "process notice code"); + if (omitted < 0) throw new IllegalArgumentException("Negative process notice count"); + } + } + + public record Query( + Snapshot snapshot, + DataKey root, + Direction direction, + List steps, + List edges, + List notices, + boolean truncated) { + public Query { + Objects.requireNonNull(snapshot); + Objects.requireNonNull(root); + Objects.requireNonNull(direction); + steps = List.copyOf(steps); + edges = List.copyOf(edges); + notices = List.copyOf(notices); + } + } + + private record IndexedStep(int order, Step step) {} + + private record Node(DataKey reference, int depth) {} + + private final Snapshot snapshot; + private final Map steps; + private final Map resources; + private final Map> inputs; + private final Map> outputs; + private final List notices; + + private MaterialProcessGraph(Builder builder) { + snapshot = builder.snapshot; + steps = Map.copyOf(builder.steps); + resources = Map.copyOf(builder.resources); + inputs = freezeOccurrences(builder.inputs); + outputs = freezeOccurrences(builder.outputs); + notices = List.copyOf(builder.notices); + } + + public static Builder builder(Snapshot snapshot) { + return new Builder(snapshot); + } + + public Snapshot snapshot() { + return snapshot; + } + + public List resources() { + return resources.values().stream() + .sorted(Comparator.comparing(resource -> resource.key().toString())) + .toList(); + } + + /** + * Traverse from one resource occurrence. The adjacency index is already published; this method + * never enumerates unrelated steps or expands a selector into its member matrix. + */ + public Query query(DataKey root, Direction direction, Budgets budgets) { + Objects.requireNonNull(root); + Objects.requireNonNull(direction); + Objects.requireNonNull(budgets); + if (!resources.containsKey(root)) + return new Query(snapshot, root, direction, List.of(), List.of(), notices, false); + + var queue = new ArrayDeque(); + var queued = new HashSet(); + boolean startsSources = direction != Direction.USES; + boolean startsUses = direction != Direction.SOURCES; + int omittedSteps = enqueue(root, startsSources, startsUses, 0, budgets, queue, queued); + var visited = new LinkedHashMap(); + var edges = new LinkedHashMap(); + var truncations = new LinkedHashMap(); + int omittedPorts = 0; + int omittedEdges = 0; + int omittedDepth = 0; + boolean stopped = false; + + while (!queue.isEmpty() && !stopped) { + Node node = queue.removeFirst(); + if (visited.containsKey(node.reference)) continue; + if (visited.size() >= budgets.maxSteps()) { + addNotice(truncations, "node_limit", 1); + break; + } + visited.put(node.reference, node.depth); + IndexedStep indexed = steps.get(node.reference); + if (indexed == null) continue; + if (node.depth >= budgets.maxDepth()) { + if (direction != Direction.USES) + omittedDepth += indexed.step.inputs().stream() + .limit(budgets.maxPortsPerSide()) + .map(port -> outputs.getOrDefault(port.resource().key(), List.of())) + .mapToInt(occurrences -> unseen(occurrences, visited, queued)) + .sum(); + if (direction != Direction.SOURCES) + omittedDepth += indexed.step.outputs().stream() + .limit(budgets.maxPortsPerSide()) + .map(port -> inputs.getOrDefault(port.resource().key(), List.of())) + .mapToInt(occurrences -> unseen(occurrences, visited, queued)) + .sum(); + continue; + } + + boolean expandInputs = direction != Direction.USES; + boolean expandOutputs = direction != Direction.SOURCES; + if (expandInputs) { + int available = Math.min(indexed.step.inputs().size(), budgets.maxPortsPerSide()); + omittedPorts += indexed.step.inputs().size() - available; + for (int index = 0; index < available && !stopped; index++) { + Port port = indexed.step.inputs().get(index); + for (IndexedStep source : + outputs.getOrDefault(port.resource().key(), List.of())) { + Edge edge = new Edge( + source.step.reference(), + node.reference, + port.resource().key(), + confirmed(source, indexed)); + if (edges.putIfAbsent(edge, Boolean.TRUE) == null && edges.size() > budgets.maxEdges()) { + edges.remove(edge); + omittedEdges++; + stopped = true; + break; + } + if (stopped) break; + if (!visited.containsKey(source.step.reference()) + && !queued.contains(source.step.reference())) { + if (queued.size() >= budgets.maxSteps()) { + omittedSteps++; + continue; + } + queue.addLast(new Node(source.step.reference(), node.depth + 1)); + queued.add(source.step.reference()); + } + } + } + } + if (expandOutputs && !stopped) { + int available = Math.min(indexed.step.outputs().size(), budgets.maxPortsPerSide()); + omittedPorts += indexed.step.outputs().size() - available; + for (int index = 0; index < available && !stopped; index++) { + Port port = indexed.step.outputs().get(index); + for (IndexedStep target : + inputs.getOrDefault(port.resource().key(), List.of())) { + Edge edge = new Edge( + node.reference, + target.step.reference(), + port.resource().key(), + confirmed(indexed, target)); + if (edges.putIfAbsent(edge, Boolean.TRUE) == null && edges.size() > budgets.maxEdges()) { + edges.remove(edge); + omittedEdges++; + stopped = true; + break; + } + if (stopped) break; + if (!visited.containsKey(target.step.reference()) + && !queued.contains(target.step.reference())) { + if (queued.size() >= budgets.maxSteps()) { + omittedSteps++; + continue; + } + queue.addLast(new Node(target.step.reference(), node.depth + 1)); + queued.add(target.step.reference()); + } + } + } + } + } + + addNotice(truncations, "node_limit", omittedSteps); + addNotice(truncations, "port_limit", omittedPorts); + addNotice(truncations, "edge_limit", omittedEdges); + addNotice(truncations, "depth_limit", omittedDepth); + var resultSteps = visited.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .map(entry -> boundedStep(steps.get(entry.getKey()).step, budgets.maxPortsPerSide())) + .toList(); + var resultEdges = edges.keySet().stream() + .filter(edge -> visited.containsKey(edge.source()) && visited.containsKey(edge.target())) + .toList(); + var resultNotices = new ArrayList<>(notices); + truncations.forEach((code, omitted) -> resultNotices.add(new Notice(code, omitted))); + if (resultSteps.isEmpty() + && resultNotices.stream() + .noneMatch(notice -> + notice.code().equals("no_" + direction.name().toLowerCase()))) + resultNotices.add(new Notice("no_" + direction.name().toLowerCase(), 0)); + return new Query( + snapshot, + root, + direction, + resultSteps, + resultEdges, + List.copyOf(resultNotices), + !truncations.isEmpty()); + } + + private int enqueue( + DataKey root, + boolean sources, + boolean uses, + int depth, + Budgets budgets, + ArrayDeque queue, + Set queued) { + int omitted = 0; + var starts = new LinkedHashSet(); + if (sources) starts.addAll(outputs.getOrDefault(root, List.of())); + if (uses) starts.addAll(inputs.getOrDefault(root, List.of())); + for (IndexedStep start : starts) { + if (queued.size() >= budgets.maxSteps()) { + omitted++; + continue; + } + if (queued.add(start.step.reference())) queue.addLast(new Node(start.step.reference(), depth)); + } + return omitted; + } + + private Step boundedStep(Step step, int maxPorts) { + return new Step( + step.reference(), + step.name(), + boundedPorts(step.inputs(), maxPorts), + boundedPorts(step.outputs(), maxPorts), + step.details(), + step.resolved()); + } + + private static List boundedPorts(List ports, int maxPorts) { + return ports.size() <= maxPorts ? ports : List.copyOf(ports.subList(0, maxPorts)); + } + + private static boolean confirmed(IndexedStep source, IndexedStep target) { + return source.step.resolved() && target.step.resolved(); + } + + private static int unseen(List occurrences, Map visited, Set queued) { + int count = 0; + for (IndexedStep occurrence : occurrences) + if (!visited.containsKey(occurrence.step.reference()) && !queued.contains(occurrence.step.reference())) + count++; + return count; + } + + private static void addNotice(Map notices, String code, int count) { + if (count > 0) notices.merge(code, count, Math::addExact); + } + + private static Map> freezeOccurrences(Map> source) { + var frozen = new HashMap>(source.size()); + source.forEach((key, values) -> frozen.put(key, List.copyOf(values))); + return Map.copyOf(frozen); + } + + private static void requireText(String value, String name) { + if (value == null || value.isBlank()) throw new IllegalArgumentException("Missing " + name); + } + + public static final class Builder { + private final Snapshot snapshot; + private final Map steps = new LinkedHashMap<>(); + private final Map resources = new LinkedHashMap<>(); + private final Map> inputs = new HashMap<>(); + private final Map> outputs = new HashMap<>(); + private final List notices = new ArrayList<>(); + + private Builder(Snapshot snapshot) { + this.snapshot = Objects.requireNonNull(snapshot); + } + + public Builder notice(String code, int omitted) { + notices.add(new Notice(code, omitted)); + return this; + } + + public Builder add(Step step) { + Objects.requireNonNull(step); + if (steps.containsKey(step.reference())) + throw new IllegalArgumentException("Duplicate process step " + step.reference()); + int order = steps.size(); + IndexedStep indexed = new IndexedStep(order, step); + steps.put(step.reference(), indexed); + for (Port port : step.inputs()) { + register(port.resource()); + inputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) + .add(indexed); + } + for (Port port : step.outputs()) { + register(port.resource()); + outputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) + .add(indexed); + } + return this; + } + + private void register(Resource resource) { + Resource previous = resources.putIfAbsent(resource.key(), resource); + if (previous != null && !previous.equals(resource)) + throw new IllegalArgumentException("Process resource key has conflicting identity: " + resource.key()); + } + + public MaterialProcessGraph build() { + return new MaterialProcessGraph(this); + } + } +} diff --git a/core/src/main/java/gregtech/engine/material/MaterialViews.java b/core/src/main/java/gregtech/engine/material/MaterialViews.java index c97815460..847b4595b 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialViews.java +++ b/core/src/main/java/gregtech/engine/material/MaterialViews.java @@ -23,6 +23,7 @@ private record TagDeclarationSubmission(String addonId, MaterialTagDeclaration d private record GroupSubmission(String addonId, MaterialGroupDeclaration declaration) {} private static MaterialCatalogView published; + private static long contentRevision; private static volatile MaterialFormsView formBindings = new MaterialFormsView() { public Set find(MaterialKey material) { return Set.of(); @@ -549,5 +550,10 @@ public Set find(MaterialKey material) { return immutable.getOrDefault(java.util.Objects.requireNonNull(material), Set.of()); } }; + contentRevision++; + } + + public static synchronized long contentRevision() { + return contentRevision; } } diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index 3511327f5..e80bbe65f 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -78,6 +78,23 @@ "gt6ce.jei.material_process.role.primary": "Primary output", "gt6ce.jei.material_process.role.byproduct": "Byproduct", "gt6ce.jei.material_process.role.unknown": "Output role: unknown", + "gt6ce.jei.material_process.material_title": "%s processing", + "gt6ce.jei.material_process.port_name": "%s / %s", + "gt6ce.jei.material_process.amount.items": "Amount: %s items", + "gt6ce.jei.material_process.amount.units": "Amount: %s U", + "gt6ce.jei.material_process.amount.mb": "Amount: %s mB", + "gt6ce.jei.material_process.amount.unknown": "Amount: unknown", + "gt6ce.jei.material_process.partial_unknown": "Coverage: partial; unsupported families are not shown.", + "gt6ce.jei.material_process.coverage.final_recipes": "Recipes: final published machine rows.", + "gt6ce.jei.material_process.coverage.active_worldgen": "World generation: active configuration only.", + "gt6ce.jei.material_process.coverage.dynamic_selectors": "Tag and material-unit selectors stay symbolic; candidates are not expanded.", + "gt6ce.jei.material_process.coverage.unknown_roles": "Primary and byproduct roles remain unknown when the source does not establish them.", + "gt6ce.jei.material_process.coverage.node_limit": "Depth stopped at the graph budget; %s additional steps were omitted.", + "gt6ce.jei.material_process.coverage.port_limit": "Port budget reached; %s ports were omitted.", + "gt6ce.jei.material_process.coverage.edge_limit": "Edge budget reached; %s links were omitted.", + "gt6ce.jei.material_process.no_sources": "No published source in the queried range.", + "gt6ce.jei.material_process.no_uses": "No published use in the queried range.", + "gt6ce.jei.material_process.no_both": "No connected published source or use in the queried range.", "gt6ce.jei.category.mold_chisel": "Mold Chiseling", "gt6ce.jei.mold_chisel.note": "Dark cells are chiseled out", "gt6ce.jei.mold_chisel.carved": "Chisel this cell", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index a7e2547c5..9700df728 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -80,6 +80,23 @@ "gt6ce.jei.material_process.role.primary": "主产物", "gt6ce.jei.material_process.role.byproduct": "副产物", "gt6ce.jei.material_process.role.unknown": "产物角色:未知", + "gt6ce.jei.material_process.material_title": "%s 加工", + "gt6ce.jei.material_process.port_name": "%s/%s", + "gt6ce.jei.material_process.amount.items": "数量:%s 件", + "gt6ce.jei.material_process.amount.units": "数量:%s U", + "gt6ce.jei.material_process.amount.mb": "数量:%s mB", + "gt6ce.jei.material_process.amount.unknown": "数量:未知", + "gt6ce.jei.material_process.partial_unknown": "覆盖范围:部分;未支持的族未显示。", + "gt6ce.jei.material_process.coverage.final_recipes": "配方:最终发布的机器配方行。", + "gt6ce.jei.material_process.coverage.active_worldgen": "世界生成:仅包含当前启用的配置。", + "gt6ce.jei.material_process.coverage.dynamic_selectors": "tag 与材料单位选择器保持符号形式,不展开候选全集。", + "gt6ce.jei.material_process.coverage.unknown_roles": "来源未明确主/副角色时保持未知。", + "gt6ce.jei.material_process.coverage.node_limit": "达到深度或节点预算,省略了 %s 个后续步骤。", + "gt6ce.jei.material_process.coverage.port_limit": "达到端口预算,省略了 %s 个端口。", + "gt6ce.jei.material_process.coverage.edge_limit": "达到关联预算,省略了 %s 条关联。", + "gt6ce.jei.material_process.no_sources": "查询范围内没有已发布的来源。", + "gt6ce.jei.material_process.no_uses": "查询范围内没有已发布的用途。", + "gt6ce.jei.material_process.no_both": "查询范围内没有相连的已发布来源或用途。", "gt6ce.jei.category.mold_chisel": "模具凿刻", "gt6ce.jei.mold_chisel.note": "深灰色格子为凿除部分", "gt6ce.jei.mold_chisel.carved": "凿除这个格子", diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java new file mode 100644 index 000000000..d60e6ae6d --- /dev/null +++ b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java @@ -0,0 +1,146 @@ +package gregtech.engine.material; + +import gregtech.api.addon.material.DataKey; +import gregtech.engine.material.MaterialProcessGraph.*; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.OptionalInt; + +import static org.junit.jupiter.api.Assertions.*; + +final class MaterialProcessGraphTest { + private static final Snapshot SNAPSHOT = new Snapshot(new MaterialPublication.Stamp(4, 1, 2, 3), 5, 6, 7, 8); + + @Test + void traversalKeepsCoInputsAndAllOutputsForACycle() { + DataKey ore = resource("ore"); + DataKey dust = resource("dust"); + DataKey ingot = resource("ingot"); + DataKey fluid = resource("fluid"); + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .notice("partial_dynamic", 0) + .add(step( + "wash", + List.of(port(ore, Role.CONSUMED, "ore"), port(fluid, Role.CATALYST, "fluid")), + List.of(port(dust, Role.UNKNOWN, "dust"), port(ingot, Role.UNKNOWN, "ingot")))) + .add(step( + "melt", + List.of(port(dust, Role.CONSUMED, "dust"), port(ingot, Role.CONSUMED, "ingot")), + List.of(port(ore, Role.UNKNOWN, "ore")))) + .build(); + + var result = graph.query(ore, Direction.BOTH, Budgets.DEFAULT); + + assertEquals(2, result.steps().size()); + assertEquals(3, result.edges().size()); + assertTrue(result.edges().stream().allMatch(MaterialProcessGraphTest::edgeIsConfirmed)); + assertFalse(result.truncated()); + assertTrue(result.notices().stream().anyMatch(notice -> notice.code().equals("partial_dynamic"))); + } + + @Test + void everyTraversalBudgetReportsItsOwnTruncation() { + var builder = MaterialProcessGraph.builder(SNAPSHOT); + DataKey previous = resource("r0"); + for (int index = 0; index < 8; index++) { + DataKey next = resource("r" + (index + 1)); + builder.add(step( + "s" + index, + List.of(port(previous, Role.CONSUMED, "dust")), + List.of(port(next, Role.UNKNOWN, "dust")))); + previous = next; + } + var graph = builder.build(); + + var depth = graph.query(resource("r0"), Direction.USES, new Budgets(1, 64, 64, 64)); + var nodes = graph.query(resource("r0"), Direction.USES, new Budgets(20, 3, 64, 64)); + var fan = MaterialProcessGraph.builder(SNAPSHOT) + .add(step( + "fan", + List.of(port(resource("source"), Role.CONSUMED, "source")), + List.of( + port(resource("one"), Role.UNKNOWN, "one"), + port(resource("two"), Role.UNKNOWN, "two")))) + .build(); + var ports = fan.query(resource("one"), Direction.BOTH, new Budgets(20, 64, 1, 64)); + var edges = graph.query(resource("r0"), Direction.USES, new Budgets(20, 64, 64, 0)); + + assertEquals(2, depth.steps().size()); + assertTrue(depth.truncated()); + assertTrue(depth.notices().stream().anyMatch(notice -> notice.code().equals("depth_limit"))); + assertTrue(nodes.truncated()); + assertTrue(nodes.notices().stream().anyMatch(notice -> notice.code().equals("node_limit"))); + assertEquals(1, ports.steps().get(0).outputs().size()); + assertTrue(ports.truncated()); + assertTrue(ports.notices().stream().anyMatch(notice -> notice.code().equals("port_limit"))); + assertTrue(edges.truncated()); + assertTrue(edges.notices().stream().anyMatch(notice -> notice.code().equals("edge_limit"))); + } + + @Test + void selectorExpansionStaysOutOfTheGraph() { + DataKey ore = new DataKey("gt6ce", "resource/ore"); + DataKey unit = new DataKey("gt6ce", "resource/unit"); + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(step( + "unit", + List.of(port(unit, Role.CONSUMED, "unit:gt6ce:iron_ingot")), + List.of(port(ore, Role.UNKNOWN, "concrete")))) + .build(); + + var result = graph.query(unit, Direction.USES, Budgets.DEFAULT); + + assertEquals(1, result.steps().size()); + assertTrue(result.steps().get(0).inputs().get(0).resource().state().startsWith("unit:")); + assertTrue(result.steps().get(0).inputs().get(0).amount().unit() == AmountUnit.MATERIAL_UNIT); + } + + @Test + void forwardAndReverseQueriesUseTheSamePortIndex() { + DataKey dust = resource("dust"); + DataKey ingot = resource("ingot"); + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(step( + "cast", + List.of(port(dust, Role.CONSUMED, "dust")), + List.of(port(ingot, Role.UNKNOWN, "ingot")))) + .add(step( + "melt", + List.of(port(ingot, Role.CONSUMED, "ingot")), + List.of(port(dust, Role.UNKNOWN, "dust")))) + .build(); + + var immediate = new Budgets(0, 64, 64, 128); + var sources = graph.query(dust, Direction.SOURCES, immediate); + var uses = graph.query(dust, Direction.USES, immediate); + + assertEquals(1, sources.steps().size()); + assertEquals("melt", sources.steps().get(0).name()); + assertEquals(1, uses.steps().size()); + assertEquals("cast", uses.steps().get(0).name()); + } + + private static boolean edgeIsConfirmed(MaterialProcessGraph.Edge edge) { + return edge.confirmed(); + } + + private static DataKey resource(String name) { + return new DataKey("gt6ce", "resource/" + name); + } + + private static Port port(DataKey key, Role role, String state) { + boolean output = role == Role.PRIMARY || role == Role.BYPRODUCT || role == Role.UNKNOWN; + return new Port( + new Resource(key, "Iron", "dust", "solid", state), + role, + new Amount(1, state.startsWith("unit:") ? AmountUnit.MATERIAL_UNIT : AmountUnit.ITEM), + output ? OptionalInt.of(10_000) : OptionalInt.empty(), + false, + List.of()); + } + + private static Step step(String name, List inputs, List outputs) { + return new Step(new DataKey("gt6ce", "step/" + name), name, inputs, outputs, List.of(), true); + } +} diff --git a/docs/architecture/packages/engine.md b/docs/architecture/packages/engine.md index 41868666d..352bf5ebb 100644 --- a/docs/architecture/packages/engine.md +++ b/docs/architecture/packages/engine.md @@ -11,7 +11,7 @@ | `engine` | 执行层总体说明 | `package-info.java`;不继续使用旧 internal 命名扩张实现 | | `engine.addon` | 附属声明收集、校验、物化与共享服务绑定 | `AddonCoreServices`、`AddonMaterials`、`AddonMachines`、`AddonPipes` | | `engine.definition` | 定义目录的组织与查询机制 | `DefinitionCatalog`;内容行放 content | -| `engine.material` | 材料安装、链接、附属事实冻结、最终角色、物品成分裁决、不可变视图和化学规则 | `GTMaterialRegistry`、`MaterialInfoRegistry`、`ItemCompositionResolver`、`MaterialViews` | +| `engine.material` | 材料安装、链接、附属事实冻结、最终角色、物品成分裁决、不可变视图、有界处理图和化学规则 | `GTMaterialRegistry`、`MaterialInfoRegistry`、`ItemCompositionResolver`、`MaterialViews`、`MaterialProcessGraph` | | `engine.prefix` | 材料形态/前缀的注册与解析 | `PrefixRegistry`、`BlockPrefixRegistry` | | `engine.recipe` | 配方成本、并行与输出空间拟合、燃料批次、可合成性和界面坐标等共享机制 | `MachineWorkCost`、`ParallelFit`、`FluidFuelChargeMath`;不能夹带游戏栈 | | `engine.recipe.data` | 配方文档模型、组件、解析及校验 | `MachineRecipeDocuments`、`ItemComponent`、`FluidComponent` | diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index 62f23ec8a..e1df2304a 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,7 +70,7 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理前端由 `compat.common.MaterialProcessDisplay` 接受已完成有界查询的投影,`client.MaterialProcessPanel` 负责布局和交互,`compat.jei.MaterialProcessCategory` 接到原生槽位与索引。当前只注册未接入说明页,没有具体材料、服务端来源索引或远程同步;调用契约与预算见[展示接入](../../development/material-process-display.md)。这些类型不能成为第二套材料目录或配方事实表。 +矿物处理由 `content.recipe.MaterialProcessSnapshot` 从成功发布点绑定最终机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`client.MaterialProcessPanel` 负责布局和交互,`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、索引和事件适配。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md index fa7077d79..6a5fee079 100644 --- a/docs/development/material-process-display.md +++ b/docs/development/material-process-display.md @@ -1,8 +1,8 @@ # 矿物处理 JEI 展示接入 -本文说明[计划 08-E](material-system-refactor/08-material-data-api.md#e有界矿物处理图与消费者迁移)的前端接入契约。当前只提供展示模型、布局和 JEI 分类,默认注册一张“尚未接入加工数据”的说明页;没有连接任何具体材料、配方索引或世界生成数据。08-D 的快照发布、远程同步、core 图查询与 EMI 接入仍未实现,不能将本页当作它们已经完成的证明。 +本文说明[计划 08-E](material-system-refactor/08-material-data-api.md#e有界矿物处理图与消费者迁移)的前端接入契约。生产路径现在从同一 `MaterialProcessSnapshot` 取得有界 core 图结果,并在 JEI 与 EMI 中共享 `Page` 和 `MaterialProcessPanel`。空状态 `unbound()` 只在没有成功发布快照时使用;具体机器行、世界生成、远程客户端和人工点击仍需按验证范围分别验收。 -这是 Minecraft 实现层的客户端调用接口,随模组编译,不是独立 API JAR 的公共材料服务,也不改变 API 1.8.0。只在客户端和已安装 JEI 的路径调用分类;无 JEI 的服务端入口不得引用它。 +这是 Minecraft 实现层的客户端调用接口,随模组编译,不是独立 API JAR 的公共材料服务,也不改变 API 1.8.0。分类和面板只在已安装 JEI/EMI 的客户端路径加载;无 viewer 的专用服务端入口不得引用它们。 ## 入口与职责 @@ -15,8 +15,13 @@ | `MaterialProcessDisplay.Page` | 每页至多两个步骤,保留全图关联、覆盖说明和绑定到同一查询结果的跳转回调 | | `gregtech.client.MaterialProcessPanel` | 固定 280×216 的坐标、绘制、悬停与点击;不依赖 JEI/EMI | | `gregtech.compat.jei.MaterialProcessCategory` | 原生 JEI 槽位、索引、事件和 tooltip;分类类型为 `TYPE`,标识为 `gt6ce:material_process` | +| `gregtech.compat.emi.MaterialProcessEmiRecipe` | EMI 分类、原生索引和共享面板适配;不读取材料目录或配方表 | +| `gregtech.content.recipe.MaterialProcessSnapshot` | 绑定一次完整发布、会话和世界生成 revision;索引最终机器行与符号选择器 | +| `gregtech.content.worldgen.MaterialWorldgenFacts` | 只含活动世界生成事实,不构造原生图标 | +| `gregtech.engine.material.MaterialProcessGraph` | core 有界前向/反向查询、循环终止和显式预算截断 | +| `gregtech.compat.common.MaterialProcessProjection` | 把 core 查询转成快照内 `DataKey`、有限图标和展示 `Page` | -复用现有 `DataKey` 表达展示引用,复用 `RecipeOutputChances.CERTAIN` 的万分比契约、JEI 原生槽位、分页、配方索引与运行期注册。没有另建 SPI、全局来源缓存、锁、服务端查询协议或材料事实表。未来 EMI 适配可共用展示模型与面板,不能在共用类型中引用 JEI 类。 +复用现有 `DataKey` 表达展示引用,复用 `RecipeOutputChances.CERTAIN` 的万分比契约、viewer 原生槽位、分页、配方索引与运行期注册。没有另建 SPI、全局来源缓存、锁、服务端查询协议或材料事实表。JEI 与 EMI 共用展示模型和面板,任何共用类型都不能引用具体 viewer 类。 ## 构造契约 @@ -55,7 +60,7 @@ var pages = MaterialProcessDisplay.pages(title, steps, connections, notices, nav registration.addRecipes(MaterialProcessCategory.TYPE, pages); ``` -这里的 `title`、`steps`、`connections`、`notices`、`navigation` 是调用方的局部变量;示例不宣称存在尚未实现的材料图查询服务。接入正式生产者时替换 `GregTechJEIPlugin.registerRecipes` 中的 `unbound()` 注册,不要同时注册占位页与正式结果。 +这里的 `title`、`steps`、`connections`、`notices`、`navigation` 是调用方的局部变量。生产路径由 `MaterialProcessProjection.initialPages(...)` 从当前 `MaterialProcessSnapshot` 生成这些值;`MaterialProcessDisplay.unbound()` 只用于没有成功发布快照的显式空状态,不能与正式结果同时注册。 `Navigation` 由内容适配器创建并捕获该次查询的会话/generation。每次跳转先检查当前版本,过期或不能解析时返回 `false`,不得跳转到新版本中“相似”的配方。不要捕获旧 `Level`/服务器实例,也不要从客户端直接扫描集成服务器表。生产者应将未来 `ProcessRef` 和实际材料形态引用映射到展示引用,适配器使用原生服务重新解析;UI 不发明第二个快照协议。 @@ -67,10 +72,10 @@ runtime.getRecipesGui().showRecipes(category, List.of(recipe), List.of()); `category` 和 `recipe` 必须来自当前有效原生引用;`RecipeViewerNavigation.open(map)` 只打开整个机器分类,不能替代这一步的精确定位。形态跳转应重新查询对应有界来源/用途,而不是按图标猜材料。 -动态打开查询结果可复用 JEI `IRecipeManager.getRecipeCategory(TYPE)` 和 `IRecipesGui.showRecipes(category, pages, List.of())`;优先让结果仅随当前显示布局存活。若使用运行期 `addRecipes`,调用方必须负责重载、断线、换服以及旧记录和回调的释放;`hideRecipes` 只是隐藏,不能当作回收旧快照的手段。当前展示层不订阅这些生命周期,也不持有运行期结果。 +动态打开查询结果可复用 JEI `IRecipeManager.getRecipeCategory(TYPE)` 和 `IRecipesGui.showRecipes(category, pages, List.of())`;优先让结果仅随当前显示布局存活。若使用运行期 `addRecipes`,调用方必须负责重载、断线、换服以及旧记录和回调的释放;`hideRecipes` 只是隐藏,不能当作回收旧快照的手段。`MachineRecipeClient` 在断线时清除当前快照,`MaterialProcessSnapshot.Store` 只保留当前成功代和一代前代;展示页本身不缓存材料目录或配方表。 ## 验证范围 检查路由为 `runtime`/语言资源 `content`;双平台编译、格式、资源打包与相关 JUnit 命令见[验证入口](validation/README.md)。[游戏检查](validation/checks/manual-ingame.md#矿物处理展示页)分别覆盖两平台及后续远程接线。 -当前没有具体材料接入,不能验收真实洗矿/合金数据、远程 generation 或原生配方跳转正确性。界面测试输入应由客户端测试调用方提供受控投影,禁止为演示把材料来源和假配方加入生产表。 +当前生产页覆盖最终机器配方与活动世界生成;tag/unit 选择器保持符号形式,没有可靠角色信息的输出保持未知。真实洗矿/合金、两次重载、远程 generation、JEI/EMI 精确跳转及两平台人工点击仍必须分别记录。测试不得为演示把假配方或额外材料来源写入生产表。 diff --git a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md index 375bc4425..5e90725de 100644 --- a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md +++ b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md @@ -1,6 +1,6 @@ # 07:清理与双平台整体验收 -本计划在数据与执行路径已收敛后移除旧实现,审计无消费内容,完成用户可见行为与双平台验收。状态:内部清理与 07-E 已实施;[02](02-material-registration.md)—[06](06-decomposition.md) 已合入 master。07-A—E 的实现已完成并通过单元测试、双平台编译和双平台 GameTest;07-F 最终验收与客户端确认仍未完成;[08](08-material-data-api.md)-D—E 也尚未实施,因此不能把全部 07 标为完成。 +本计划在数据与执行路径已收敛后移除旧实现,审计无消费内容,完成用户可见行为与双平台验收。状态:内部清理与 07-E 已实施;[02](02-material-registration.md)—[06](06-decomposition.md) 已合入 master。07-A—E 的实现已完成并通过单元测试、双平台编译和双平台 GameTest;[08](08-material-data-api.md)-D—E 的生产快照和图/viewer 切片现已接入。07-F 仍需执行双平台重载、远程客户端、正式 viewer 与发行包验收,因此不能把全部 07 标为完成。 本页原清单按 master `f096a79ee`(2026-11-12)核对源码。2026-11-13 已完成首轮内部迁移:材料事实归入 `content.material.catalog` 的类型化 process 规则,运行时消费者改经材料查询,recipe 包只保留配方模板、特殊工艺和原生适配。下文保留旧类名用于追溯删除对象;实际新入口见“本轮实施结果”。 @@ -120,7 +120,7 @@ 4. 对无来源或无终端项列出选择:保留并说明用途、停止生成相应配方、停止新注册并保留旧身份读取、删除。注册项删除需额外考虑旧世界中的物品/方块与流体。 5. 仅在证据和兼容方案完整后实施;材料、物品、流体的有意移除分别更新现有 parity 台账。未完成裁决的候选可以明确保留,但不能宣称审计已全部完成。 -每项至少记录:材料与形态身份、实际注册对象、获得途径、有效配方输入/输出、终端用途、公开附属契约、存档影响、去留决定和证据。没有 08-D 索引时可先对候选做定向注册/查询审计,不能把文本命中数当最终可达性,也不能声称已经覆盖全部处理图。 +每项至少记录:材料与形态身份、实际注册对象、获得途径、有效配方输入/输出、终端用途、公开附属契约、存档影响、去留决定和证据。定向注册/查询审计可定位候选,但不能把文本命中数或未执行运行期的快照当最终可达性,也不能声称已经覆盖全部处理图。 ### 07-E 定向审计记录 @@ -220,7 +220,7 @@ | 07-C | 兼容门面、死分支、旧写入和重复发布清理 | 对应消费者已迁移;公开兼容和成功/失败代语义不回归 | | 07-D | tooltip 与语言清理 | 使用现有有效成分与状态;两个客户端确认普通/高级展示 | | 07-E | 材料/形态去留与必要迁移 | 定向审计可先开始;删注册项必须单独提供可达性、存档和 parity 依据 | -| 07-F | 全链路、处理图、远程客户端与发行包总验收 | 08-D—E 完成;按本页矩阵补齐,分别记录两个平台与未覆盖场景 | +| 07-F | 全链路、处理图、远程客户端与发行包总验收 | 08-D—E 代码已接入;按本页矩阵执行两个平台、正式 viewer 与远程场景并记录未覆盖项 | 07-A—E 已完成;08 的有效来源与共享图仍是 07-F 的交付前置,不能用内部清理和 07-E 注册项清单替代。每个切片的检查按实际改动路径与总计划检查集执行,不把纯文档清单的检查结果沿用为实施代码的验收结果。 diff --git a/docs/development/material-system-refactor/08-material-data-api.md b/docs/development/material-system-refactor/08-material-data-api.md index 83500b60d..71731ff81 100644 --- a/docs/development/material-system-refactor/08-material-data-api.md +++ b/docs/development/material-system-refactor/08-material-data-api.md @@ -1,16 +1,24 @@ # 08:材料标签、形态、来源与处理图 API -本计划将独立的材料相关系统通过查询与投影纳入材料 API,保持主材料对象简洁。状态:部分实施;A(定义视图与 metadata)已完成,B 的 tag/替代组定义与查询已随 02 完成,常见形态的生产消费者迁移随 03 完成;C 的定义期规则、实际 item/block/fluid 绑定和 tag 桥接声明已随 03 完成,外部 tag 导入候选已随 04 接入统一裁决;07 的内部材料事实清理已使用这些查询入口。D—E 待实施。接口与语义权威见[设计提议 0001](../../decisions/0001-material-data-api.md),本页只维护实施顺序与独立验收。 +本计划将独立的材料相关系统通过查询与投影纳入材料 API,保持主材料对象简洁。状态:A—C 已完成;D 已从最终机器配方、有效成分、已发布形态和当前启用世界生成建立同代快照、有界来源/用途查询及客户端重建;E 已接 core 图、生产投影、JEI 和 EMI,并保留未知角色、符号选择器和预算截断。两平台运行期、远程客户端和人工 viewer 验收仍需按本页清单执行。接口与语义权威见[设计提议 0001](../../decisions/0001-material-data-api.md),本页只维护实施顺序与独立验收。 08 是贯穿原计划的集成工作,不是在 07 后重做材料系统。A 在 01 的调查基础上、02 的接口定稿前完成;B 并入 02/03,C 并入 03/04,D 随 05/06 的有效结果发布,E 在 D 后实施;最终由 07 联合验收。07 的内部事实与兼容入口清理可先进行,D—E 是其最终来源/处理图验收的前置,详见 [07 拆分](07-cleanup-and-acceptance.md#拆分与兼容处理)。 +| 切片 | 当前状态 | 已有入口或交付 | 未完成边界 | +| --- | --- | --- | --- | +| A | 已完成 | 稳定 key、不可变视图、metadata、process 扩展与宿主能力失败语义 | 无 | +| B | 已完成 | 分类 tag、替代组、包含关系与查询;`Any*` 消费者迁移 | 无 | +| C | 已完成 | 定义期 item/block/fluid 规则、实际形态绑定、tag 桥接与外部候选输入 | 外部模组运行期覆盖仍按实际安装环境验收 | +| D | 已实施 | `MaterialProcessSnapshot` 同代发布最终机器配方、活动世界生成和符号选择器;来源/用途共用一个索引 | 双平台重载、独立远程客户端与人工数据验收 | +| E | 已实施 | core 有界图、共享 Minecraft 投影、JEI/EMI 页面、精确跳转和形态来源/用途切换 | 双平台 viewer 截图、点击及未安装 viewer 场景验收 | + ## 当前入口与前置事实 - 现有 `GregTechMaterials` 已有只读材料句柄;优先增加视图和适配,不向 `GTMaterial` 追加来源列表。 - `AddonMaterialContributor` 已覆盖材料、prefix、form、组成、熔炼和世界生成声明;追加能力使用默认方法和侧向 metadata 声明,不复制 SPI。 - tag 需分别盘点 `MaterialProperty`、`MaterialRoleFlags`、`MaterialGroups`、`MaterialTagAliases`、`MaterialEquivalence` 和 `MaterialTagPack`。 - 加工来自实际 `RecipeMap`、`RecipeManager` 和动态/unit 提供者;`allRecipes()` 不是可无成本反复读取的完整静态表。 -- 世界生成来源先追踪活动矿脉、小矿、岩层及 `WorldgenInfoData`;EMI 当前也从该 JEI 包中的数据入口取信息。 +- 世界生成来源由 `MaterialWorldgenFacts` 只投影活动大矿脉、小矿、岩层和基岩矿事实;`WorldgenInfoData` 的旧 viewer 图标入口只保留兼容展示职责。 - 用户截图作为处理图信息组织目标;不把截图的具体图标连接当作待硬编码的配方表。 ## A:确定薄视图与最小公共契约 @@ -81,6 +89,24 @@ ## D:来源与用途索引、快照发布 +### 现有接入点 + +- `MaterialPublication.Stamp` 已同时记录材料定义、有效成分和配方 revision;`MachineRecipeOverlay` 只在一整代配方生产成功后发布新戳,失败代保留上一份成功戳。D 应沿用该发布边界,不再增加一套材料内容版本。 +- `ItemMaterialRegistry.compositionState()` 提供有效成分 revision、tag generation 与 readiness;`MaterialViews.publishContent(...)` 发布实际注册形态。索引只能读取已经发布的稳定结果,不能从候选或临时注册表反推。 +- `MachineRecipeOverlay` 已负责静态基线、tag 归属行、数据包删除/添加和最终炉镜像。来源与用途索引必须读取这一最终集合,不能直接遍历 `allRecipes()` 或重复实现 overlay 顺序。 +- `MaterialUnitRecipeIndex` 已按物品或形态保留有界候选与少量生成批次;D 的动态投影应复用该选择语义,不能为索引展开全部物理配方。 +- `WorldgenInfoData` 当前从活动大矿脉、小矿、岩层和基岩矿表构造信息,并把事实与 `ItemStack` 图标混在同一访问器中。D 只投影实际启用事实,图标解析留给游戏/展示适配层,旧入口在迁移期转发。 + +### 快照与引用边界 + +D 的查询结果必须绑定一个完整发布上下文:`MaterialPublication.Stamp`、server/level 会话、活动世界生成配置和任何按世界生效的开关。配方、成分、形态和世界生成事实不得分别从不同代次拼成一个结果。 + +来源与用途使用同一份有界索引:来源按目标资源查前驱,用途按已发布关系查后继。每条关系保留步骤身份、共同输入、催化剂、全部输出、批量单位、概率、原生状态限制、覆盖程度和原生配方引用。资源身份至少区分材料、形态、相态与原生状态;同一图标或物品 ID 不构成身份合并。 + +`DataKey` 只表达展示快照内的引用,不是来源索引主键或存档 ID。D 的适配器把原生步骤和资源引用投影成展示引用;跳转时先校验当前发布戳和会话,再重新解析原生配方。旧快照可以服务于尚未结束的查询或展示,但不得跨重载、换服或会话复用。 + +失败重建不得发布部分索引;查询进行中的旧成功快照可继续读取,并在消费者释放后回收。禁止无限保留历史 generation,也不得以全局缓存代替 server/level 归属。 + ### 步骤 1. 先为最终静态机器配方建立输入/输出端口投影,保留共同输入、催化剂、单位、概率和原生状态限制;选合金与洗矿各一个闭环。 @@ -91,6 +117,14 @@ 6. 提供有界来源/用途查询与原生引用解析,禁止跨快照引用混用;旧快照有界保留且保持自洽。 7. 检查现有客户端同步覆盖;复用已有事实同步,对缺失投影补充会话/generation 绑定。测试独立远程客户端路径,不依赖集成服务器共享内存。 +### 实施结果 + +- `MaterialProcessSnapshot` 在 `MachineRecipeOverlay` 成功发布后一次构建;失败重建不替换上一成功快照,旧快照只保留一代供进行中的 viewer 回调使用。 +- 机器步骤读取 overlay 完成后的 `RecipeMap.mRecipeList`,保留共同输入、催化剂、存在性条件、全部输出、物品/U/mB 批量、概率、原生状态与来源说明。 +- `MaterialWorldgenFacts` 读取当前活动配置,输出维度、高度、岩层、小矿和基岩事实;selection weight 与岩层 roll divisor 保留在说明中,不伪装成掉落概率。 +- `MaterialProcessSnapshot.Store` 在集成服务器和独立客户端分别由同步后的配方/标签重建;登录、断线、重载或换服后,旧 `DataKey` 与导航回调因快照身份变化而失效。 +- 未新增网络协议:客户端使用原版同步的 `RecipeManager`、已同步材料定义和同一 datapack 世界生成配置重建;导航再解析本代原生配方引用。 + ### 独立验收 检查集:D、F、J、A、C、G;同步或可选 viewer 接线涉及实际交互时加 M。 @@ -109,7 +143,26 @@ ## E:有界矿物处理图与消费者迁移 -前端切片:已提供独立的 JEI 展示分类、共享展示投影和客户端布局,[调用文档](../material-process-display.md)记录预算、联合端口、显式关联、覆盖提示及跳转回调。默认仅注册未接入说明页,没有绑定具体材料。D 的来源索引、E 的 core 图查询、远程同步与 EMI 接线仍待实施,本切片不代表 D—E 完成。 +已提供 core 有界语义图、共享 Minecraft 投影、与 viewer 无关的布局以及 JEI/EMI 分类。构造字段、角色、概率、分页、折叠、交互和生命周期契约统一见[矿物处理 JEI 展示接入](../material-process-display.md)。`unbound()` 现在只在没有成功发布快照时作为显式空状态,不再由正式注册路径常驻。 + +### 接入链 + +```text +D 已发布来源/用途索引 + → E core 有界语义图(步骤、端口、关联、覆盖) + → 共享 Minecraft 内容适配(形态、相态、原生配方引用、有限图标) + → MaterialProcessDisplay.Page + → JEI / EMI viewer 适配 +``` + +职责边界: + +- D 决定哪些关系存在及覆盖范围;E 决定如何在预算内查询和截断;展示层只做分页、布局、索引与交互,不读取配方表、材料目录或世界生成数据。 +- core 图先按查询预算完成遍历并返回不可变结果,再由内容适配器构造展示值。`MaterialProcessDisplay` 的 64 步、128 条关联、每步每侧 64 个端口和每端口 16 个图标是展示上限,不能代替图遍历的深度、节点、端口和边预算,也不能先枚举完整候选再截断。 +- 一个步骤保存联合输入与全部输出;主路线仅是布局提示,不得从槽位顺序推断主/副角色。未知角色、未知概率、未解析条件和部分覆盖必须继续可见,不能为了画出完整路线改写成确定边。 +- 图边只来自 D 的关系或明确确认的适配关系。显示层不得按相同图标补边,不把 tag/unit 代表图标当成候选全集,也不从显示图反向生成配方或授权。 +- 重载、断线、换服和 session 切换后,旧图、旧 `DataKey` 和旧导航回调都失效。导航适配器重新解析当前原生引用;失败时返回 `false`,不得跳转到新代次中的相似对象。 +- 材料事实投影与原生图标构造分离。`WorldgenInfoData` 的活动事实可以继续由旧 JEI/EMI 入口转发,但新图只消费同一 D 快照中的有效世界生成事实;EMI 原生页复用共享面板和图模型,共用类型不得引用 JEI 类。 ### 步骤 @@ -119,6 +172,13 @@ 4. `WorldgenInfoData` 的活动事实投影与原生图标构造分开,旧入口可暂时转发;材料来源不再要求 EMI 读取 JEI 的事实汇总类。 5. 清理被替代的来源列表和展示反推;保留完整性信息,未知工艺不画成无条件可执行的实线。 +### 实施结果 + +- `MaterialProcessGraph` 在 core 中按 `SOURCES`、`USES`、`BOTH` 遍历,限制深度、步骤、每侧端口和关联数量;循环按步骤访问集终止,稳定保留截断原因。 +- `MaterialProcessProjection` 只把已查询结果转成展示值。物品、流体、tag 和 unit 选择器保持独立引用;tag/unit 只提供有限代表,不展开候选全集。 +- JEI 与 EMI 共用 `MaterialProcessPanel` 和同一 `Page` 列表。工艺点击定位当前快照中的原生机器配方,资源左右击重新查询该快照的形态来源/用途。 +- JEI 与 EMI 的分类仅由客户端注册;`MaterialProcessSnapshot` 与 core 图不引用 viewer 类型,专用服务端可独立构建和查询。 + ### 独立验收 检查集:D、F、J、A、C、G、M;新增客户端资源或交付产物时加 B。 @@ -130,10 +190,17 @@ - 无 JEI/EMI 的专用服务端可启动、查询并重载;未加载任何客户端/可选模组类。 - 两节点及远程客户端分别记录实际验证结果,不把纯图模型测试写成截图交互已通过。 +验证分层: + +- JUnit/core:循环终止、共同输入、分支边、深度/节点/端口/边预算、截断原因、稳定排序、旧快照自洽和失败代不发布。 +- 双平台 GameTest:资源重载、数据包删除/添加、世界生成开关、tag/成分代次、无 JEI/EMI 的专用服务端查询,以及两次重载不累积旧边。 +- 独立远程客户端:只使用同步得到的同代 projection,断线、换服和旧回调拒绝;不得读取集成服务器共享内存。 +- 双平台人工游戏检查:JEI 正式材料页、精确配方跳转、形态来源/用途切换;EMI 接线完成后再单独记录,未安装 viewer 的行为也算独立场景。 + ## 交付顺序与完成条件 -每个切片都能独立交付:A 的公共模型不要求先完成全图;B/C 的查询已有直接消费者;D 先有准确的来源列表,再由 E 绘图。每步保持旧 API 可用,迁移完一个消费者后再删除其重复数据。 +每个切片都能独立交付:A 的公共模型不要求先完成全图;B/C 的查询已有直接消费者;E 的展示切片可以独立验证输入校验与布局,但只有 D 提供正式关系后才可验证真实内容。D 先有准确的来源/用途列表和快照语义,再由 E 查询并绘图。每步保持旧 API 可用,迁移完一个消费者后再删除其重复数据。 -初版完成要求 A—E 覆盖材料分类/组、形态、静态洗矿/合金/电解/离心、有效世界生成、unit 规则及两 viewer 的共享图;其他动态族允许明确列为部分覆盖,但不能写成“所有来源完整”。同步、生命周期和权限没有验证的部分不得计为通过。 +初版完成要求 A—E 覆盖材料分类/组、形态、静态洗矿/合金/电解/离心、有效世界生成、unit 规则及两 viewer 的共享图;E 的未接入说明页不计入 D—E 完成。其他动态族允许明确列为部分覆盖,但不能写成“所有来源完整”。同步、生命周期和权限没有验证的部分不得计为通过。 检查代号与命令沿用[总计划](README.md#检查的使用方式)。原始快照、性能采样与截图留 `work/material-system-refactor/`;公共契约、纯图算法和稳定样例进入对应真实测试源码集。落地后同步包索引、API 使用文档和检查文档。 diff --git a/docs/development/material-system-refactor/README.md b/docs/development/material-system-refactor/README.md index 9701fbdb9..bb8c50c92 100644 --- a/docs/development/material-system-refactor/README.md +++ b/docs/development/material-system-refactor/README.md @@ -1,8 +1,8 @@ # 材料系统重构实施计划 -本组文档用于把 [issue #351](https://github.com/GregTech6CE/GregTech6/issues/351) 拆成可实施、可逐份验收的工作。01 已建立可执行基线,验收范围与已知差异见[基线报告](../../integration/material-baseline.md);02 已完成注册、目录和 08-A/B 的定义与查询切片;03 已完成属性收敛、燃料闭环、08-C 实际形态绑定和资源 tag 桥接声明;04 已完成来源化候选裁决、有效成分快照、状态查询和双平台共享安装;05 已完成成分驱动的回收计划、数量表达、主要生产端迁移和重载诊断;06 已完成类型化分解声明、计划器和双平台执行验收。07 的内部材料事实、配方/原生职责拆分、成品成分安装、tooltip 失效分支和 07-E 注册项去留裁决已完成;08-D—E 与 07-F 最终验收仍待实施。尚未实施阶段的目标接口、测试和数据集不代表当前已经存在。阅读顺序为本页、对应分计划、该计划引用的现有架构与检查文档。 +本组文档用于把 [issue #351](https://github.com/GregTech6CE/GregTech6/issues/351) 拆成可实施、可逐份验收的工作。01 已建立可执行基线,验收范围与已知差异见[基线报告](../../integration/material-baseline.md);02 已完成注册、目录和 08-A/B 的定义与查询切片;03 已完成属性收敛、燃料闭环、08-C 实际形态绑定和资源 tag 桥接声明;04 已完成来源化候选裁决、有效成分快照、状态查询和双平台共享安装;05 已完成成分驱动的回收计划、数量表达、主要生产端迁移和重载诊断;06 已完成类型化分解声明、计划器和双平台执行验收;08-D 已发布同代来源/用途快照,08-E 已接入 core 图、生产投影、JEI 和 EMI。07 的最终整体验收仍需结合这些新入口执行双平台重载、远程客户端与人工 viewer 检查。尚未验证的运行期和平台场景不代表已经通过。阅读顺序为本页、对应分计划、该计划引用的现有架构与检查文档。 -01—06 当前均已合入 master,本次核对点为 PR #374 合并后的 `f096a79ee`。07 的内部清理与 [07-E 注册项去留裁决](../../integration/material-refactor-07-roster.md)已实施;[07 清单](07-cleanup-and-acceptance.md)按当前源码列出 Reviewed/Source 类中的材料事实、通用配方模板、特殊配方与原生适配的处理方式,并以朱砂和铝土矿高压釜区分职责。07 最终整体验收仍以前置 08-D—E 完成为条件。 +01—06 当前均已合入 master。07 的内部清理与 [07-E 注册项去留裁决](../../integration/material-refactor-07-roster.md)已实施;[07 清单](07-cleanup-and-acceptance.md)按当前源码列出 Reviewed/Source 类中的材料事实、通用配方模板、特殊配方与原生适配的处理方式,并以朱砂和铝土矿高压釜区分职责。08-D—E 的代码切片现已接入,07 最终整体验收转入运行期检查阶段。 [recipe 包补充审计](07-recipe-package-audit.md)记录通用材料转换目标、挤压/研钵/洗矿能力、透镜角色、相态绑定和固定物品成分登记的迁移结果,并区分保留的特殊配方与原生适配。 @@ -85,4 +85,4 @@ | 多组件热回收、输出槽限制与无法表示的余量 | 05、06 | 逐机器核对规则,不要求所有工艺都产出全部成分 | | chain、minecartWheels 及兼容 prefix 的去留 | 07 | 同时检查实际消费端、外部声明契约和已有存档影响 | -01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收;07 已完成首轮内部清理和 07-E 全量材料/形态去留裁决。07-F、08-D—E 尚未实施。本页不替代现行架构或已接受的决策。 +01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收;07 已完成首轮内部清理和 07-E 全量材料/形态去留裁决;08 已完成静态机器配方、活动世界生成、符号选择器和两 viewer 的共享处理图接入。07-F 仍由双平台运行期与人工验收闭合。本页不替代现行架构或已接受的决策。 diff --git a/docs/integration/material-refactor-07-roster.md b/docs/integration/material-refactor-07-roster.md index 8c9b1bfbc..66a2f3370 100644 --- a/docs/integration/material-refactor-07-roster.md +++ b/docs/integration/material-refactor-07-roster.md @@ -3,7 +3,7 @@ ## 范围与状态 - 主题:按最终运行时注册对象审计材料身份、物品形态、方块形态、获得途径和消费者,完成 [07-E](../development/material-system-refactor/07-cleanup-and-acceptance.md#07-e-定向审计记录) 的去留裁决。 -- 状态:在下述双平台、开发环境、无外部附属内容范围内验证通过。07-F/08-D—E、客户端展示、机器手工交互和最终发行包仍未执行。 +- 状态:在下述双平台、开发环境、无外部附属内容范围内验证通过。08-D—E 的生产快照与 viewer 代码切片现已接入;07-F 的双平台重载、正式客户端展示、机器手工交互和最终发行包仍未执行。 - 源码状态:核对基线为 `525a6ecf6`;本报告包含当前工作区尚未提交的 `MaterialItemCompositions` 共享矿石成分修复与对应 GameTest。 - 平台:Minecraft 1.20.1/Forge 47.4.20/Java 17,Minecraft 1.21.1/NeoForge 21.1.243/Java 21。 @@ -198,4 +198,4 @@ - 最终 Forge `distributionJar`/NeoForge `jar` 的发行包内容检查。 - 真实外部附属材料与可选模组环境。 -本报告证明的是 07-E 的材料/形态去留清单和本轮必要迁移,不等同于 07-F 的完整处理图验收。静态配方快照没有展开所有动态族;相关动态单位来源和消费者已在源码点名核对,但仍须由 08-D—E 的最终索引给出完整边集合。 +本报告证明的是 07-E 的材料/形态去留清单和本轮必要迁移,不等同于 07-F 的完整处理图验收。08-D—E 已把静态配方、活动世界生成和符号单位选择器接入同一快照,但动态族不展开为全体物理候选;完整边集合仍须按运行期清单确认覆盖范围。 diff --git a/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java b/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java index 344c4f1c5..05a5dc36a 100644 --- a/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java +++ b/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java @@ -2,6 +2,7 @@ import gregtech.engine.mod.GregTechIdentity; import gregtech.content.recipe.MachineRecipeOverlay; +import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.content.recipe.OvenRecipeBridge; import net.minecraft.client.Minecraft; import net.minecraft.world.item.crafting.RecipeManager; @@ -11,11 +12,13 @@ import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.ModList; import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent; import net.neoforged.neoforge.client.event.RecipesUpdatedEvent; import net.neoforged.neoforge.event.TagsUpdatedEvent; import net.neoforged.neoforge.server.ServerLifecycleHooks; *///?} else { import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.event.ClientPlayerNetworkEvent; import net.minecraftforge.client.event.RecipesUpdatedEvent; import net.minecraftforge.event.TagsUpdatedEvent; import net.minecraftforge.eventbus.api.EventPriority; @@ -39,6 +42,12 @@ public static void recipes(RecipesUpdatedEvent event) { apply(event.getRecipeManager()); } + /** A viewer callback must not survive a disconnect even if the next recipe sync is delayed. */ + @SubscribeEvent + public static void logout(ClientPlayerNetworkEvent.LoggingOut event) { + MaterialProcessSnapshot.Store.clear(MaterialProcessSnapshot.Store.current()); + } + /** On login the server sends recipes before tags, so tag inputs only expand once the tags arrive. */ /** Tag inputs only expand against the tags the server sent, which can arrive after the recipes. */ diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java new file mode 100644 index 000000000..c8e7643b1 --- /dev/null +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java @@ -0,0 +1,250 @@ +package gregtech.compat.common; + +import gregtech.api.addon.material.DataKey; +import gregtech.api.addon.material.MaterialCatalogView; +import gregtech.api.addon.material.MaterialKey; +import gregtech.api.addon.material.MaterialView; +import gregtech.content.recipe.MaterialProcessSnapshot; +import gregtech.engine.material.MaterialProcessGraph; +import gregtech.engine.material.MaterialProcessGraph.AmountUnit; +import gregtech.engine.material.MaterialProcessGraph.Budgets; +import gregtech.engine.material.MaterialProcessGraph.Direction; +import gregtech.engine.material.MaterialProcessGraph.Notice; +import gregtech.engine.material.MaterialProcessGraph.Port; +import gregtech.engine.material.MaterialProcessGraph.Query; +import gregtech.engine.material.MaterialProcessGraph.Resource; +import gregtech.engine.material.MaterialProcessGraph.Step; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Optional; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.material.Fluid; +//? if >=1.21.1 { +/*import net.neoforged.neoforge.fluids.FluidStack; +*///?} else { +import net.minecraftforge.fluids.FluidStack; +//?} + +/** Converts one already bounded semantic query into native viewer values. */ +public final class MaterialProcessProjection { + private static final Budgets INITIAL_BUDGET = new Budgets(4, 10, 64, 128); + + private MaterialProcessProjection() {} + + public static List initialPages( + MaterialProcessSnapshot snapshot, MaterialProcessDisplay.Navigation navigation) { + var pages = new ArrayList(); + for (MaterialProcessSnapshot.Root root : snapshot.roots()) { + var rootPages = pages(snapshot, root.resource(), Direction.BOTH, INITIAL_BUDGET, navigation); + pages.addAll(rootPages); + } + return pages.isEmpty() ? MaterialProcessDisplay.unbound() : List.copyOf(pages); + } + + public static List pages( + MaterialProcessSnapshot snapshot, + DataKey root, + Direction direction, + MaterialProcessDisplay.Navigation navigation) { + return pages(snapshot, root, direction, Budgets.DEFAULT, navigation); + } + + private static List pages( + MaterialProcessSnapshot snapshot, + DataKey root, + Direction direction, + Budgets budgets, + MaterialProcessDisplay.Navigation navigation) { + Query query = snapshot.query(root, direction, budgets); + var steps = query.steps().stream().map(MaterialProcessProjection::step).toList(); + var connections = query.edges().stream() + .map(edge -> new MaterialProcessDisplay.Connection( + edge.source(), edge.target(), edge.resource(), edge.confirmed())) + .toList(); + var notices = query.notices().stream().map(MaterialProcessProjection::notice).toList(); + if (notices.isEmpty()) notices = List.of(Component.translatable("gt6ce.jei.material_process.partial_unknown")); + Component title = title(query.root(), snapshot.resource(query.root()).orElse(null)); + return MaterialProcessDisplay.pages(title, steps, connections, notices, navigation); + } + + private static MaterialProcessDisplay.Step step(Step step) { + return new MaterialProcessDisplay.Step( + step.reference(), + Component.literal(step.name()), + step.inputs().stream().map(MaterialProcessProjection::port).toList(), + step.outputs().stream().map(MaterialProcessProjection::port).toList(), + step.details().stream().map(MaterialProcessProjection::literal).toList(), + step.resolved()); + } + + private static MaterialProcessDisplay.Port port(Port port) { + return new MaterialProcessDisplay.Port( + port.resource().key(), + name(port.resource()), + icons(port.resource()), + role(port.role()), + port.main(), + amount(port.amount().value(), port.amount().unit()), + port.chance(), + port.details().stream().map(MaterialProcessProjection::literal).toList()); + } + + private static Component title(DataKey root, Resource resource) { + String material = resource == null ? pathMaterial(root) : resource.material(); + return Component.translatable("gt6ce.jei.material_process.material_title", materialName(material)); + } + + private static String pathMaterial(DataKey key) { + String[] path = key.path().split("/"); + return path.length > 2 ? path[2].replace('_', ' ') : "unknown"; + } + + private static Component name(Resource resource) { + String form = switch (resource.form()) { + case "ore" -> "ore"; + case "oreRaw" -> "raw"; + case "crushed" -> "crushed"; + case "unit" -> "unit"; + case "fluid" -> resource.phase(); + default -> resource.form(); + }; + return Component.translatable( + "gt6ce.jei.material_process.port_name", materialName(resource.material()), form); + } + + private static Component materialName(String material) { + MaterialCatalogView catalog; + try { + catalog = gregtech.engine.material.MaterialViews.catalog(); + } catch (IllegalStateException notReady) { + return Component.literal(material); + } + Optional view = catalog.find(new MaterialKey(material)); + if (view.isEmpty()) return Component.literal(material); + return Component.translatable(view.get().info().translationKey()); + } + + private static Component literal(String value) { + return Component.literal(value); + } + + private static List icons(Resource resource) { + var icons = new LinkedHashSet(); + String state = resource.state(); + if (state.startsWith("item:")) { + String id = state.substring("item:".length()); + int suffix = id.indexOf('#'); + if (suffix >= 0) id = id.substring(0, suffix); + item(id).ifPresent(item -> icons.add(new ItemStack(item))); + } else if (state.startsWith("unit:")) { + String alternatives = state.substring("unit:".length()); + int separator = alternatives.indexOf('|'); + if (separator >= 0) alternatives = alternatives.substring(separator + 1); + for (String value : alternatives.split(",")) { + if (icons.size() >= MaterialProcessDisplay.MAX_ICONS) break; + item(value).ifPresent(item -> icons.add(new ItemStack(item))); + } + } else if (state.startsWith("tag:")) { + ResourceLocation tag = ResourceLocation.tryParse(state.substring("tag:".length())); + if (tag != null) { + if (resource.form().equals("fluid")) { + var key = + net.minecraft.tags.TagKey.create(net.minecraft.core.registries.Registries.FLUID, tag); + for (var holder : BuiltInRegistries.FLUID.getTagOrEmpty(key)) { + if (icons.size() >= MaterialProcessDisplay.MAX_ICONS) break; + if (holder.value() == net.minecraft.world.level.material.Fluids.EMPTY) continue; + ItemStack display = fluidDisplay(new FluidStack(holder.value(), 1000)); + if (!display.isEmpty()) icons.add(display); + } + } else { + var key = net.minecraft.tags.TagKey.create(net.minecraft.core.registries.Registries.ITEM, tag); + for (var holder : BuiltInRegistries.ITEM.getTagOrEmpty(key)) { + if (icons.size() >= MaterialProcessDisplay.MAX_ICONS) break; + icons.add(new ItemStack(holder.value())); + } + } + } + } else if (state.startsWith("fluid:")) { + String value = state.substring("fluid:".length()); + int suffix = value.indexOf('#'); + if (suffix >= 0) value = value.substring(0, suffix); + ResourceLocation id = ResourceLocation.tryParse(value); + if (id != null) { + Fluid fluid = BuiltInRegistries.FLUID.get(id); + if (fluid != net.minecraft.world.level.material.Fluids.EMPTY) { + ItemStack display = fluidDisplay(new FluidStack(fluid, 1000)); + if (!display.isEmpty()) icons.add(display); + } + } + } + return List.copyOf(icons); + } + + private static Optional item(String id) { + ResourceLocation location = ResourceLocation.tryParse(id); + if (location == null) return Optional.empty(); + Item item = BuiltInRegistries.ITEM.get(location); + return item == net.minecraft.world.item.Items.AIR ? Optional.empty() : Optional.of(item); + } + +//? if >=1.21.1 { + /*private static ItemStack fluidDisplay(FluidStack stack) { + var lookup = gregtech.engine.fluid.FluidDisplayBinding.currentLookup(); + return lookup == null ? ItemStack.EMPTY : gregtech.engine.fluid.FluidDisplayBinding.display(lookup, stack); + } +*///?} else { + private static ItemStack fluidDisplay(FluidStack stack) { + return gregtech.engine.fluid.FluidDisplayBinding.display(stack); + } +//?} + + private static MaterialProcessDisplay.Role role(MaterialProcessGraph.Role role) { + return switch (role) { + case CONSUMED -> MaterialProcessDisplay.Role.CONSUMED; + case CATALYST -> MaterialProcessDisplay.Role.CATALYST; + case PRESENCE -> MaterialProcessDisplay.Role.PRESENCE; + case PRIMARY -> MaterialProcessDisplay.Role.PRIMARY; + case BYPRODUCT -> MaterialProcessDisplay.Role.BYPRODUCT; + case UNKNOWN -> MaterialProcessDisplay.Role.UNKNOWN; + }; + } + + private static Component amount(long value, AmountUnit unit) { + return switch (unit) { + case ITEM -> Component.translatable("gt6ce.jei.material_process.amount.items", value); + case MATERIAL_UNIT -> Component.translatable("gt6ce.jei.material_process.amount.units", value); + case MILLIBUCKET -> Component.translatable("gt6ce.jei.material_process.amount.mb", value); + case UNKNOWN -> Component.translatable("gt6ce.jei.material_process.amount.unknown"); + }; + } + + private static Component notice(Notice notice) { + return switch (notice.code()) { + case "coverage_final_recipes" -> + Component.translatable("gt6ce.jei.material_process.coverage.final_recipes"); + case "coverage_active_worldgen" -> + Component.translatable("gt6ce.jei.material_process.coverage.active_worldgen"); + case "partial_dynamic_selectors" -> + Component.translatable("gt6ce.jei.material_process.coverage.dynamic_selectors"); + case "partial_unknown_roles" -> + Component.translatable("gt6ce.jei.material_process.coverage.unknown_roles"); + case "node_limit" -> + Component.translatable("gt6ce.jei.material_process.coverage.node_limit", notice.omitted()); + case "port_limit" -> + Component.translatable("gt6ce.jei.material_process.coverage.port_limit", notice.omitted()); + case "edge_limit" -> + Component.translatable("gt6ce.jei.material_process.coverage.edge_limit", notice.omitted()); + case "depth_limit" -> + Component.translatable("gt6ce.jei.material_process.coverage.node_limit", notice.omitted()); + case "no_sources" -> Component.translatable("gt6ce.jei.material_process.no_sources"); + case "no_uses" -> Component.translatable("gt6ce.jei.material_process.no_uses"); + case "no_both" -> Component.translatable("gt6ce.jei.material_process.no_both"); + default -> Component.literal(notice.code()); + }; + } +} diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index 63385ac1f..829624de2 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -8,6 +8,7 @@ import dev.emi.emi.api.stack.EmiStack; import gregtech.compat.jei.RecipeMachines; import gregtech.content.item.GTToolItem; +import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.engine.recipe.RecipeMap; import java.util.Locale; import net.minecraft.network.chat.Component; @@ -36,6 +37,11 @@ public static int overlayGeneration() { @Override public void register(EmiRegistry registry) { + var processSnapshot = MaterialProcessSnapshot.Store.current(); + var processNavigation = new ProcessNavigation(processSnapshot); + MaterialProcessEmiRecipe.register( + registry, + gregtech.compat.common.MaterialProcessProjection.initialPages(processSnapshot, processNavigation)); gregtech.client.gui.RecipeViewerNavigation.registerEmi(map -> { var id = ResourceLocation.fromNamespaceAndPath("gt6ce", map.mNameInternal.toLowerCase(Locale.ROOT)); var manager = dev.emi.emi.api.EmiApi.getRecipeManager(); @@ -161,4 +167,41 @@ private static boolean repairedGtTool(EmiRecipe recipe) { } return false; } + + private static final class ProcessNavigation implements gregtech.compat.common.MaterialProcessDisplay.Navigation { + private final MaterialProcessSnapshot snapshot; + + private ProcessNavigation(MaterialProcessSnapshot snapshot) { + this.snapshot = snapshot; + } + + @Override + public boolean openRecipe(gregtech.api.addon.material.DataKey reference) { + if (!MaterialProcessSnapshot.Store.current(snapshot)) return false; + var nativeRecipe = snapshot.recipe(reference); + if (nativeRecipe.isEmpty()) return false; + var row = nativeRecipe.get(); + var id = ResourceLocation.fromNamespaceAndPath( + "gt6ce", "/machine/" + row.map().mNameInternal.toLowerCase(Locale.ROOT) + "/" + row.index()); + var recipe = dev.emi.emi.api.EmiApi.getRecipeManager().getRecipe(id); + if (recipe == null) return false; + dev.emi.emi.api.EmiApi.displayRecipe(recipe); + return true; + } + + @Override + public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { + if (!MaterialProcessSnapshot.Store.current(snapshot)) return false; + var pages = gregtech.compat.common.MaterialProcessProjection.pages( + snapshot, + resource, + uses + ? gregtech.engine.material.MaterialProcessGraph.Direction.USES + : gregtech.engine.material.MaterialProcessGraph.Direction.SOURCES, + this); + if (pages.isEmpty()) return false; + dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe(pages.get(0))); + return true; + } + } } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java new file mode 100644 index 000000000..cdf9adab5 --- /dev/null +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java @@ -0,0 +1,203 @@ +package gregtech.compat.emi; + +import dev.emi.emi.api.EmiRegistry; +import dev.emi.emi.api.recipe.EmiRecipe; +import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.stack.EmiIngredient; +import dev.emi.emi.api.stack.EmiStack; +import dev.emi.emi.api.widget.Bounds; +import dev.emi.emi.api.widget.SlotWidget; +import dev.emi.emi.api.widget.WidgetHolder; +import gregtech.client.MaterialProcessPanel; +import gregtech.compat.common.MaterialProcessDisplay; +import gregtech.compat.common.RecipeViewerIcons; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +/** EMI page adapter over the same bounded process display used by JEI. */ +public final class MaterialProcessEmiRecipe implements EmiRecipe { + private static final EmiRecipeCategory CATEGORY = + new EmiRecipeCategory( + ResourceLocation.fromNamespaceAndPath("gt6ce", "material_process"), + EmiStack.of(RecipeViewerIcons.item("ore_iridium"))) { + @Override + public Component getName() { + return Component.translatable("gt6ce.jei.material_process.title"); + } + }; + + private final MaterialProcessDisplay.Page page; + private final ResourceLocation id; + private final List inputs; + private final List catalysts; + private final List outputs; + + public MaterialProcessEmiRecipe(MaterialProcessDisplay.Page page) { + this.page = page; + id = ResourceLocation.fromNamespaceAndPath( + "gt6ce", + "/material_process/" + + Integer.toUnsignedString(page.title().getString().hashCode(), 36) + + "/" + page.number() + + "/" + + page.steps().stream() + .map(step -> step.reference().toString()) + .findFirst() + .orElse("empty") + .hashCode()); + var inputs = new ArrayList(); + var catalysts = new ArrayList(); + var outputs = new ArrayList(); + for (var step : page.steps()) { + for (var port : step.inputs()) add(port, inputs, catalysts, outputs); + for (var port : step.outputs()) add(port, inputs, catalysts, outputs); + } + this.inputs = List.copyOf(inputs); + this.catalysts = List.copyOf(catalysts); + this.outputs = List.copyOf(outputs); + } + + private static void add( + MaterialProcessDisplay.Port port, + List inputs, + List catalysts, + List outputs) { + if (!port.hasIcons()) return; + var stacks = stacks(port); + var ingredient = EmiIngredient.of(stacks); + switch (port.role()) { + case CONSUMED -> inputs.add(ingredient); + case CATALYST, PRESENCE -> catalysts.add(ingredient); + case PRIMARY, BYPRODUCT, UNKNOWN -> outputs.addAll(stacks); + } + } + + private static List stacks(MaterialProcessDisplay.Port port) { + return port.icons().stream() + .map(EmiStack::of) + .map(stack -> port.chance().isPresent() + ? stack.setChance(port.chance().getAsInt() / 10_000F) + : stack) + .toList(); + } + + public static void register(EmiRegistry registry, List pages) { + registry.addCategory(CATEGORY); + for (var page : pages) registry.addRecipe(new MaterialProcessEmiRecipe(page)); + } + + public static EmiRecipeCategory category() { + return CATEGORY; + } + + @Override + public EmiRecipeCategory getCategory() { + return CATEGORY; + } + + @Override + public ResourceLocation getId() { + return id; + } + + @Override + public List getInputs() { + return inputs; + } + + @Override + public List getCatalysts() { + return catalysts; + } + + @Override + public List getOutputs() { + return outputs; + } + + @Override + public boolean supportsRecipeTree() { + return false; + } + + @Override + public boolean hideCraftable() { + return true; + } + + @Override + public int getDisplayWidth() { + return MaterialProcessPanel.WIDTH; + } + + @Override + public int getDisplayHeight() { + return MaterialProcessPanel.HEIGHT; + } + + @Override + public void addWidgets(WidgetHolder widgets) { + for (int row = 0; row < page.steps().size(); row++) { + var step = page.steps().get(row); + for (var slot : MaterialProcessPanel.slots(step, row)) { + var port = slot.port(); + if (!port.hasIcons()) continue; + var ingredient = EmiIngredient.of(stacks(port)); + var widget = widgets.add(new PortSlot(ingredient, slot.x(), slot.y(), page, port)); + if (!slot.output()) + widget.catalyst(port.role() == MaterialProcessDisplay.Role.CATALYST + || port.role() == MaterialProcessDisplay.Role.PRESENCE); + } + } + widgets.add(new EmiInteractiveWidget() { + @Override + public Bounds getBounds() { + return new Bounds(0, 0, MaterialProcessPanel.WIDTH, MaterialProcessPanel.HEIGHT); + } + + @Override + public void render(GuiGraphics graphics, int x, int y, float delta) { + EmiWidgetInput.rendered(this, graphics); + MaterialProcessPanel.draw(page, graphics, x, y); + } + + @Override + public boolean mouseClicked(int x, int y, int button) { + return MaterialProcessPanel.click(page, x, y, button); + } + + @Override + public List getTooltip(int x, int y) { + return MaterialProcessPanel.tooltip(page, x, y).stream() + .map(line -> ClientTooltipComponent.create(line.getVisualOrderText())) + .toList(); + } + }); + } + + private static final class PortSlot extends SlotWidget { + private final MaterialProcessDisplay.Page page; + private final MaterialProcessDisplay.Port port; + + private PortSlot( + EmiIngredient stack, int x, int y, MaterialProcessDisplay.Page page, MaterialProcessDisplay.Port port) { + super(stack, x, y); + this.page = page; + this.port = port; + drawBack(false); + for (Component line : port.tooltip()) appendTooltip(line); + } + + @Override + public boolean mouseClicked(int mouseX, int mouseY, int button) { + if ((button == 0 || button == 1) + && getBounds().contains(mouseX, mouseY) + && page.navigation().openForm(port.resource(), button == 1)) return true; + return super.mouseClicked(mouseX, mouseY, button); + } + } +} diff --git a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java index 29f4b78a8..4bb6cce30 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java @@ -1,5 +1,6 @@ package gregtech.compat.jei; +import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.engine.recipe.Recipe; import gregtech.engine.recipe.RecipeMap; import gregtech.platform.Mc; @@ -26,7 +27,12 @@ */ @JeiPlugin public final class GregTechJEIPlugin implements IModPlugin { + private mezz.jei.api.runtime.IJeiRuntime runtime; + private MaterialProcessSnapshot processSnapshot; + private MaterialProcessCategory processCategory; + @Override public void onRuntimeAvailable(mezz.jei.api.runtime.IJeiRuntime runtime) { + this.runtime = runtime; gregtech.client.gui.RecipeViewerNavigation.registerJei(map -> { if (!categories.containsKey(map)) return false; runtime.getRecipesGui().showTypes(java.util.List.of(RecipeMapCategory.recipeType(map))); @@ -39,6 +45,8 @@ public final class GregTechJEIPlugin implements IModPlugin { } @Override public void onRuntimeUnavailable() { + runtime = null; + processSnapshot = null; gregtech.client.gui.RecipeViewerNavigation.clearJei(); } @@ -94,7 +102,8 @@ public void registerCategories(IRecipeCategoryRegistration registration) { registration.addRecipeCategories(new MultiblockInfoCategory(guiHelper)); registration.addRecipeCategories(new ToolAssemblyCategory.Category(guiHelper)); registration.addRecipeCategories(new MoldChiselCategory(guiHelper)); - registration.addRecipeCategories(new MaterialProcessCategory(guiHelper)); + processCategory = new MaterialProcessCategory(guiHelper); + registration.addRecipeCategories(processCategory); registration.addRecipeCategories( new WorldgenInfoCategories.VeinCategory(guiHelper), new WorldgenInfoCategories.SmallOreCategory(guiHelper), @@ -183,7 +192,10 @@ public void registerRecipes(IRecipeRegistration registration) { //?} registration.addRecipes(MoldChiselCategory.TYPE, gregtech.compat.common.MoldChiselDisplay.recipes()); - registration.addRecipes(MaterialProcessCategory.TYPE, gregtech.compat.common.MaterialProcessDisplay.unbound()); + processSnapshot = MaterialProcessSnapshot.Store.current(); + var processNavigation = new ProcessNavigation(processSnapshot); + registration.addRecipes(MaterialProcessCategory.TYPE, + gregtech.compat.common.MaterialProcessProjection.initialPages(processSnapshot, processNavigation)); var unitTags = gregtech.compat.common.MaterialUnitTagDisplay.entries(); for (var family : MaterialUnitTagCategory.FAMILIES) registration.addRecipes(MaterialUnitTagCategory.type(family), MaterialUnitTagCategory.pages(family, unitTags)); @@ -222,4 +234,35 @@ private ItemStack iconFor(RecipeMap map) { } return new ItemStack(Items.ANVIL); } + + private final class ProcessNavigation implements gregtech.compat.common.MaterialProcessDisplay.Navigation { + private final MaterialProcessSnapshot snapshot; + + private ProcessNavigation(MaterialProcessSnapshot snapshot) { + this.snapshot = snapshot; + } + + @Override + public boolean openRecipe(gregtech.api.addon.material.DataKey reference) { + if (runtime == null || !MaterialProcessSnapshot.Store.current(snapshot)) return false; + var nativeRecipe = snapshot.recipe(reference); + if (nativeRecipe.isEmpty()) return false; + var row = nativeRecipe.get(); + var category = categories.get(row.map()); + if (category == null) return false; + runtime.getRecipesGui().showRecipes(category, List.of(row.recipe()), List.of()); + return true; + } + + @Override + public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { + if (runtime == null || !MaterialProcessSnapshot.Store.current(snapshot)) return false; + var direction = uses + ? gregtech.engine.material.MaterialProcessGraph.Direction.USES + : gregtech.engine.material.MaterialProcessGraph.Direction.SOURCES; + var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, resource, direction, this); + runtime.getRecipesGui().showRecipes(processCategory, pages, List.of()); + return true; + } + } } diff --git a/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoData.java b/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoData.java index 92dfe578d..e2325c11d 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoData.java +++ b/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoData.java @@ -16,7 +16,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -/** Actual world generation catalogs, independent of optional recipe browsers. */ +/** Legacy icon-bearing worldgen viewer projection; process facts come from {@code MaterialWorldgenFacts}. */ public class WorldgenInfoData { protected WorldgenInfoData() {} diff --git a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java index 7f387eead..e309e98d9 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java @@ -170,6 +170,7 @@ private static Result applyGeneration(RecipeManager manager, long current) { if (generation != current) return lastResult; lastPublication = MaterialPublication.platformGenerationPublished( ItemMaterialRegistry.compositionRevision(), current); + MaterialProcessSnapshot.Store.publish(lastPublication, current); lastResult = new Result(tally.removed, tally.added, tally.rejected, restoreMillis, baselineRows(), false, false); applications++; if (!overlayDumped) { diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java new file mode 100644 index 000000000..39185591b --- /dev/null +++ b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java @@ -0,0 +1,609 @@ +package gregtech.content.recipe; + +import com.mojang.logging.LogUtils; +import gregtech.api.addon.material.DataKey; +import gregtech.api.addon.recipe.RecipeOutputChances; +import gregtech.api.material.GTMaterial; +import gregtech.content.data.RegisteredFluids; +import gregtech.content.registry.GTFluids; +import gregtech.content.worldgen.MaterialWorldgenFacts; +import gregtech.engine.fluid.FluidVisualPolicy; +import gregtech.engine.material.GTMaterialRegistry; +import gregtech.engine.material.ItemComposition; +import gregtech.engine.material.ItemMaterialRegistry; +import gregtech.engine.material.MaterialEquivalence; +import gregtech.engine.material.MaterialProcessGraph; +import gregtech.engine.material.MaterialProcessGraph.Amount; +import gregtech.engine.material.MaterialProcessGraph.AmountUnit; +import gregtech.engine.material.MaterialProcessGraph.Budgets; +import gregtech.engine.material.MaterialProcessGraph.Direction; +import gregtech.engine.material.MaterialProcessGraph.Notice; +import gregtech.engine.material.MaterialProcessGraph.Port; +import gregtech.engine.material.MaterialProcessGraph.Query; +import gregtech.engine.material.MaterialProcessGraph.Resource; +import gregtech.engine.material.MaterialProcessGraph.Role; +import gregtech.engine.material.MaterialProcessGraph.Step; +import gregtech.engine.material.MaterialPublication; +import gregtech.engine.recipe.Recipe; +import gregtech.engine.recipe.RecipeMap; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.ItemStack; +//? if >=1.21.1 { +/*import net.neoforged.neoforge.fluids.FluidStack; +*///?} else { +import net.minecraftforge.fluids.FluidStack; +//?} +import org.slf4j.Logger; + +/** + * One complete material process generation projected from the final machine maps and active + * world generation facts. Native recipe objects stay behind opaque step references. + */ +public final class MaterialProcessSnapshot { + private static final Logger LOGGER = LogUtils.getLogger(); + private static final char[] HEX = "0123456789abcdef".toCharArray(); + private static final MaterialProcessSnapshot EMPTY = empty(); + + public record NativeRecipe(RecipeMap map, Recipe recipe, int index) { + public NativeRecipe { + Objects.requireNonNull(map); + Objects.requireNonNull(recipe); + if (index < 0) throw new IllegalArgumentException("Invalid native recipe index"); + } + } + + public record NativeWorldgen(MaterialWorldgenFacts.Fact fact) { + public NativeWorldgen { + Objects.requireNonNull(fact); + } + } + + public record Root(String material, String form, DataKey resource) { + public Root { + if (material == null || material.isBlank() || form == null || form.isBlank()) + throw new IllegalArgumentException("Invalid material process root"); + Objects.requireNonNull(resource); + } + } + + private static final List COVERAGE = List.of( + new Notice("coverage_final_recipes", 0), + new Notice("coverage_active_worldgen", 0), + new Notice("partial_dynamic_selectors", 0), + new Notice("partial_unknown_roles", 0)); + + private record Bucket(List steps, Map roots) {} + + private final MaterialProcessGraph.Snapshot snapshot; + private final Map buckets; + private final List roots; + private final Map nativeRecipes; + private final Map worldgen; + private final Map graphs = new ConcurrentHashMap<>(); + + private MaterialProcessSnapshot( + MaterialProcessGraph.Snapshot snapshot, + Map buckets, + List roots, + Map nativeRecipes, + Map worldgen) { + this.snapshot = snapshot; + this.buckets = Map.copyOf(buckets); + this.roots = List.copyOf(roots); + this.nativeRecipes = Map.copyOf(nativeRecipes); + this.worldgen = Map.copyOf(worldgen); + } + + public MaterialProcessGraph.Snapshot snapshot() { + return snapshot; + } + + public List roots() { + return roots; + } + + public Optional resource(DataKey key) { + for (Bucket bucket : buckets.values()) { + for (Resource resource : bucket.roots.values()) + if (resource.key().equals(key)) return Optional.of(resource); + } + return Optional.empty(); + } + + public Query query(DataKey root, Direction direction, Budgets budgets) { + Optional resource = resource(root); + if (resource.isEmpty()) return new Query(snapshot, root, direction, List.of(), List.of(), COVERAGE, false); + return graph(resource.get().material()).query(root, direction, budgets); + } + + public Optional recipe(DataKey reference) { + return Optional.ofNullable(nativeRecipes.get(reference)); + } + + public Optional worldgen(DataKey reference) { + return Optional.ofNullable(worldgen.get(reference)); + } + + public boolean samePublication(MaterialPublication.Stamp publication) { + return snapshot.publication().equals(publication); + } + + private MaterialProcessGraph graph(String material) { + return graphs.computeIfAbsent(material, key -> { + Bucket bucket = buckets.get(key); + var builder = MaterialProcessGraph.builder(snapshot); + COVERAGE.forEach(notice -> builder.notice(notice.code(), notice.omitted())); + if (bucket != null) bucket.steps.forEach(builder::add); + return builder.build(); + }); + } + + private static MaterialProcessSnapshot empty() { + var stamp = MaterialPublication.current(); + return new MaterialProcessSnapshot( + new MaterialProcessGraph.Snapshot(stamp, 1, 0, 0, 0), + Map.of(), + List.of(), + Map.of(), + Map.of()); + } + + static MaterialProcessSnapshot build( + MaterialPublication.Stamp publication, + long sessionGeneration, + MaterialWorldgenFacts.Snapshot worldgenFacts) { + Objects.requireNonNull(publication); + Objects.requireNonNull(worldgenFacts); + var graphSnapshot = new MaterialProcessGraph.Snapshot( + publication, + sessionGeneration, + gregtech.engine.material.MaterialViews.contentRevision(), + ItemMaterialRegistry.compositionState().tagGeneration(), + worldgenFacts.revision()); + var mutable = new LinkedHashMap(); + var nativeRecipes = new LinkedHashMap(); + var nativeWorldgen = new LinkedHashMap(); + for (RecipeMap map : RecipeMap.RECIPE_MAP_LIST) { + var rows = new ArrayList(map.mRecipeList); + for (int index = 0; index < rows.size(); index++) { + Recipe recipe = rows.get(index); + if (!recipe.mEnabled || recipe.mHidden) continue; + if (recipe.mFakeRecipe && !hasMaterialUnitInput(recipe)) continue; + var built = recipeStep(map, recipe, index, publication.revision(), sessionGeneration); + if (built == null) continue; + addStep(mutable, built.step, built.materials); + nativeRecipes.put(built.step.reference(), new NativeRecipe(map, recipe, index)); + } + } + for (MaterialWorldgenFacts.Fact fact : worldgenFacts.facts()) { + var built = worldgenStep(fact, publication.revision(), sessionGeneration); + addStep(mutable, built.step, built.materials); + nativeWorldgen.put(built.step.reference(), new NativeWorldgen(fact)); + } + var buckets = new LinkedHashMap(); + mutable.forEach((material, bucket) -> buckets.put(material, bucket.freeze())); + var roots = buckets.entrySet().stream() + .map(entry -> bestRoot(entry.getKey(), entry.getValue().roots)) + .sorted(Comparator.comparing(Root::material, String.CASE_INSENSITIVE_ORDER)) + .toList(); + return new MaterialProcessSnapshot( + graphSnapshot, buckets, roots, nativeRecipes, nativeWorldgen); + } + + private static BuiltStep recipeStep( + RecipeMap map, Recipe recipe, int index, long publication, long session) { + var inputs = new ArrayList(); + var outputs = new ArrayList(); + var materials = new LinkedHashSet(); + boolean mainInput = false; + for (int input = 0; input < recipe.mInputs.length; input++) { + ItemStack stack = recipe.mInputs[input]; + if (stack == null || stack.isEmpty()) continue; + Port port = itemPort(stack, recipe, input, false, !mainInput); + if (port == null) continue; + inputs.add(port); + materials.add(port.resource().material()); + mainInput |= port.main(); + } + for (int input = 0; input < recipe.mFluidInputs.length; input++) { + FluidStack stack = recipe.mFluidInputs[input]; + if (stack == null || stack.isEmpty()) continue; + Port port = fluidPort(stack, recipe, input, false, !mainInput); + if (port == null) continue; + inputs.add(port); + materials.add(port.resource().material()); + mainInput |= port.main(); + } + boolean mainOutput = false; + for (int output = 0; output < recipe.mOutputs.length; output++) { + ItemStack stack = recipe.mOutputs[output]; + if (stack == null || stack.isEmpty()) continue; + Port port = itemPort(stack, recipe, output, true, !mainOutput); + if (port == null) continue; + outputs.add(port); + materials.add(port.resource().material()); + mainOutput |= port.main(); + } + for (int output = 0; output < recipe.mFluidOutputs.length; output++) { + FluidStack stack = recipe.mFluidOutputs[output]; + if (stack == null || stack.isEmpty()) continue; + Port port = fluidPort(stack, recipe, output, true, !mainOutput); + if (port == null) continue; + outputs.add(port); + materials.add(port.resource().material()); + mainOutput |= port.main(); + } + if (materials.isEmpty()) return null; + String mapPath = path(map.mNameInternal); + DataKey reference = new DataKey( + "gt6ce", + "process/machine/" + mapPath + "/" + index + "/" + Long.toUnsignedString(publication, 36) + + "/" + Long.toUnsignedString(session, 36)); + var details = new ArrayList(); + details.add("map: " + map.mNameInternal); + details.add("duration: " + recipe.mDuration + " ticks"); + details.add("energy: " + recipe.mEUt + " EU/t"); + if (!recipe.mSource.isBlank()) details.add("source: " + recipe.mSource); + if (recipe.mFakeRecipe) details.add("symbolic unit template"); + if (recipe.mExactItemInputs) details.add("exact item-state matching"); + if (recipe.mExplicitCatalystsOnly) details.add("only explicit catalysts are retained"); + if (recipe.mNeedsEmptyOutput) details.add("empty output slots required"); + if (recipe.mRequiresEmptyContainerInputs) details.add("empty container inputs required"); + var special = gregtech.engine.recipe.RecipeSpecialItems.display(recipe.mSpecialItems); + if (!special.isEmpty()) + details.add("special catalysts: " + special.stream() + .limit(8) + .map(ItemStack::getItem) + .map(BuiltInRegistries.ITEM::getKey) + .map(ResourceLocation::toString) + .toList()); + return new BuiltStep( + new Step(reference, map.mNameInternal, inputs, outputs, details, true), materials); + } + + private static Port itemPort( + ItemStack stack, Recipe recipe, int index, boolean output, boolean mainCandidate) { + String prefix; + GTMaterial material; + String state; + Amount amount; + Recipe.MaterialInputDisplay display = recipe.materialInputDisplay(index); + TagKey tag = recipe.itemTag(index); + String nativeSuffix = itemStateSuffix(stack); + if (!output && display != null) { + var representative = material(stack); + if (representative == null) return null; + material = representative; + prefix = "unit"; + var alternatives = display.alternatives().stream() + .filter(candidate -> !candidate.isEmpty()) + .map(ItemStack::getItem) + .map(BuiltInRegistries.ITEM::getKey) + .distinct() + .map(ResourceLocation::toString) + .sorted() + .limit(8) + .toList(); + state = "unit:" + (tag == null ? "" : "tag=" + tag.location() + "|") + + (alternatives.isEmpty() ? display.rounding().name() : String.join(",", alternatives)); + amount = new Amount(display.amount(), AmountUnit.MATERIAL_UNIT); + } else { + var equivalent = MaterialEquivalence.form(stack); + if (equivalent == null) return null; + material = equivalent.material().resolve(); + if (!material.isValid()) return null; + prefix = equivalent.prefix().getName(); + state = tag == null + ? "item:" + BuiltInRegistries.ITEM.getKey(stack.getItem()) + nativeSuffix + : "tag:" + tag.location(); + amount = new Amount(stack.getCount(), AmountUnit.ITEM); + } + OptionalInt chance; + if (output) { + chance = OptionalInt.of(recipe.getOutputChance(index)); + } else { + chance = OptionalInt.empty(); + } + Role role; + if (output) role = Role.UNKNOWN; + else if (recipe.isCatalystInput(index)) role = Role.CATALYST; + else role = Role.CONSUMED; + var details = new ArrayList(); + if (tag != null) details.add("item tag: " + tag.location()); + if (tag == null && !nativeSuffix.isEmpty()) details.add("native stack data is present"); + if (!output && recipe.hasItemInputGuard(index)) details.add("native item-input guard"); + if (!output && recipe.hasSameItemInputPredicate(index)) details.add("native item-state predicate"); + if (!output && recipe.viewerInputNote(index).length() > 0) + details.add(recipe.viewerInputNote(index)); + return new Port( + itemResource(material, prefix, state), role, amount, chance, mainCandidate, details); + } + + private static Port fluidPort( + FluidStack stack, Recipe recipe, int index, boolean output, boolean mainCandidate) { + RegisteredFluids.FluidEntry entry = GTFluids.entryForFluid(stack.getFluid()); + GTMaterial material = entry == null ? null : FluidVisualPolicy.material(entry).resolve(); + if (material == null || !material.isValid()) return null; + TagKey tag = recipe.fluidTag(index); + String nativeSuffix = fluidStateSuffix(stack); + String state = tag == null + ? "fluid:" + BuiltInRegistries.FLUID.getKey(stack.getFluid()) + nativeSuffix + : "tag:" + tag.location(); + String phase = entry != null && entry.gas() ? "gas" : "liquid"; + Role role; + if (output) role = Role.UNKNOWN; + else if (recipe.isCatalystFluidInput(index)) role = Role.CATALYST; + else if (recipe.isPresenceFluidInput(index)) role = Role.PRESENCE; + else role = Role.CONSUMED; + var details = new ArrayList(); + if (tag != null) details.add("fluid tag: " + tag.location()); + if (tag == null && !nativeSuffix.isEmpty()) details.add("native fluid data is present"); + return new Port( + new Resource( + resourceKey("fluid", material, "fluid", phase, state), + material.getName(), + "fluid", + phase, + state), + role, + new Amount(stack.getAmount(), AmountUnit.MILLIBUCKET), + output ? OptionalInt.of(RecipeOutputChances.CERTAIN) : OptionalInt.empty(), + mainCandidate, + details); + } + + private static BuiltStep worldgenStep( + MaterialWorldgenFacts.Fact fact, long publication, long session) { + var merged = new LinkedHashMap(); + var materials = new LinkedHashSet(); + for (MaterialWorldgenFacts.Ore ore : fact.ores()) { + Resource resource = itemResource(ore.material(), "ore", ore.itemState()); + var details = new ArrayList<>(ore.details()); + details.add("dimension: " + fact.dimension()); + details.add("height: " + ore.minY() + ".." + ore.maxY()); + if (ore.chanceDivisor() > 0) details.add("native roll divisor: " + ore.chanceDivisor()); + Port port = new Port( + resource, + Role.UNKNOWN, + new Amount(Math.max(1, ore.amount()), AmountUnit.ITEM), + OptionalInt.empty(), + merged.isEmpty(), + details); + Port previous = merged.putIfAbsent(resource.key(), port); + if (previous != null) { + var combined = new ArrayList<>(previous.details()); + combined.addAll(port.details()); + merged.put( + resource.key(), + new Port( + resource, + previous.role(), + new Amount( + Math.max(previous.amount().value(), port.amount().value()), + previous.amount().unit()), + previous.chance(), + previous.main(), + combined)); + } + materials.add(ore.material().getName()); + } + if (materials.isEmpty()) return null; + DataKey reference = new DataKey( + "gt6ce", + "process/worldgen/" + path(fact.id()) + "/" + Long.toUnsignedString(publication, 36) + "/" + + Long.toUnsignedString(session, 36)); + var details = new ArrayList(); + details.add("worldgen: " + fact.name()); + details.add("kind: " + fact.kind().name().toLowerCase(Locale.ROOT)); + details.add("dimension: " + fact.dimension()); + details.add("height: " + fact.minY() + ".." + fact.maxY()); + if (fact.weight() > 0) { + details.add("selection weight: " + fact.weight()); + if (fact.totalWeight() > 0) details.add("total selection weight: " + fact.totalWeight()); + } + return new BuiltStep( + new Step(reference, fact.name(), List.of(), List.copyOf(merged.values()), details, true), + materials); + } + + private static Resource itemResource(GTMaterial material, String prefix, String state) { + return new Resource( + resourceKey("item", material, prefix, "solid", state), + material.resolve().getName(), + prefix, + "solid", + state); + } + + private static DataKey resourceKey( + String kind, GTMaterial material, String form, String phase, String state) { + return new DataKey( + "gt6ce", + "resource/" + kind + "/" + path(material.resolve().getName()) + "/" + path(form) + "/" + + path(phase) + "/" + path(state) + "/" + Integer.toUnsignedString(state.hashCode(), 36)); + } + + private static GTMaterial material(ItemStack stack) { + Optional composition = ItemMaterialRegistry.get(stack); + if (composition.isEmpty()) return null; + var row = composition.get(); + if (row.components().size() != 1) return null; + return row.components().get(0).material().resolve(); + } + + private static boolean hasMaterialUnitInput(Recipe recipe) { + for (int index = 0; index < recipe.mInputs.length; index++) + if (recipe.materialInputDisplay(index) != null) return true; + return false; + } + + private static void addStep( + Map buckets, Step step, Set materials) { + for (String material : materials) { + var bucket = buckets.computeIfAbsent(material, ignored -> new MutableBucket()); + bucket.steps.putIfAbsent(step.reference(), step); + for (Port port : step.inputs()) + if (port.resource().material().equals(material)) + bucket.resource(port.resource()); + for (Port port : step.outputs()) + if (port.resource().material().equals(material)) + bucket.resource(port.resource()); + } + } + + private static Root bestRoot(String material, Map resources) { + Resource best = null; + int bestRank = Integer.MAX_VALUE; + for (Resource resource : resources.values()) { + int rank = rootRank(resource.form()); + if (best == null + || rank < bestRank + || (rank == bestRank + && resource.key().toString().compareTo(best.key().toString()) < 0)) { + best = resource; + bestRank = rank; + } + } + return new Root(material, best.form(), best.key()); + } + + private static int rootRank(String form) { + return switch (form) { + case "ore" -> 0; + case "oreRaw" -> 1; + case "crushed" -> 2; + case "dust" -> 3; + case "fluid" -> 6; + default -> 4; + }; + } + + private static String path(String value) { + String path = value.toLowerCase(Locale.ROOT) + .replace(':', '/') + .replace(',', '/') + .replaceAll("[^a-z0-9/._-]", "_"); + return path.isBlank() ? "unknown" : path; + } + + private static String itemStateSuffix(ItemStack stack) { + var suffix = new StringBuilder(); + if (stack.isDamaged()) suffix.append("#damaged").append(stack.getDamageValue()); +//? if >=1.21.1 { + /*if (!stack.getComponentsPatch().isEmpty()) + suffix.append("#components").append(fingerprint(stack.getComponentsPatch().toString())); +*///?} else { + if (stack.hasTag()) suffix.append("#tag").append(fingerprint(stack.getTag().toString())); +//?} + return suffix.toString(); + } + + private static String fluidStateSuffix(FluidStack stack) { +//? if >=1.21.1 { + /*return stack.getComponentsPatch().isEmpty() + ? "" + : "#components" + fingerprint(stack.getComponentsPatch().toString()); +*///?} else { + return stack.hasTag() ? "#tag" + fingerprint(stack.getTag().toString()) : ""; +//?} + } + + private static String fingerprint(String value) { + try { + byte[] digest = MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8)); + var hex = new StringBuilder(16); + for (int index = 0; index < 8; index++) { + int bits = digest[index] & 0xff; + hex.append(HEX[bits >>> 4]).append(HEX[bits & 0x0f]); + } + return hex.toString(); + } catch (NoSuchAlgorithmException impossible) { + throw new IllegalStateException("SHA-256 is unavailable", impossible); + } + } + + private record BuiltStep(Step step, Set materials) { + private BuiltStep { + materials = Set.copyOf(materials); + } + } + + private static final class MutableBucket { + private final LinkedHashMap steps = new LinkedHashMap<>(); + private final LinkedHashMap roots = new LinkedHashMap<>(); + + private void resource(Resource resource) { + roots.putIfAbsent(resource.key().toString(), resource); + } + + private Bucket freeze() { + return new Bucket(List.copyOf(steps.values()), Map.copyOf(roots)); + } + } + + /** Bounded current/previous publication retained for in-flight viewer callbacks. */ + public static final class Store { + private static volatile MaterialProcessSnapshot current = EMPTY; + private static volatile MaterialProcessSnapshot previous; + + private Store() {} + + public static MaterialProcessSnapshot current() { + return current; + } + + public static boolean current(MaterialProcessSnapshot snapshot) { + return current == snapshot; + } + + public static synchronized MaterialProcessSnapshot publish( + MaterialPublication.Stamp publication, long sessionGeneration) { + try { + long started = System.nanoTime(); + var worldgen = MaterialWorldgenFacts.capture(); + MaterialProcessSnapshot built = + MaterialProcessSnapshot.build(publication, sessionGeneration, worldgen); + previous = current; + current = built; + LOGGER.info( + "[gregtech] Material process snapshot {} published with {} material roots, " + + "{} recipe refs in {} ms", + publication.revision(), + built.roots.size(), + built.nativeRecipes.size(), + (System.nanoTime() - started) / 1_000_000L); + return built; + } catch (RuntimeException failure) { + LOGGER.error( + "[gregtech] Material process snapshot {} rebuild failed; retaining revision {}", + publication.revision(), + current.snapshot.publication().revision(), + failure); + return current; + } + } + + public static synchronized void clear(MaterialProcessSnapshot expected) { + if (current != expected) return; + current = EMPTY; + previous = null; + } + } +} diff --git a/minecraft/src/main/java/gregtech/content/recipe/OvenRecipeBridge.java b/minecraft/src/main/java/gregtech/content/recipe/OvenRecipeBridge.java index 80dd68538..43bf225a2 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/OvenRecipeBridge.java +++ b/minecraft/src/main/java/gregtech/content/recipe/OvenRecipeBridge.java @@ -173,6 +173,9 @@ && hasPublishedCookingReplacement(firstInput(recipe)) + " (NEVER_FURNACE materials yield scrap instead); {} material rows dropped; {} GT" + " furnace rows added to the vanilla furnace.", mirrored, unsmelted, dropped, fuelled); gregtech.content.recipe.MachineRecipeOverlay.reapplyFurnace(manager); + MaterialProcessSnapshot.Store.publish( + gregtech.content.recipe.MachineRecipeOverlay.lastPublication(), + gregtech.content.recipe.MachineRecipeOverlay.generation()); } /** diff --git a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java new file mode 100644 index 000000000..a6a49ea29 --- /dev/null +++ b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java @@ -0,0 +1,283 @@ +package gregtech.content.worldgen; + +import gregtech.api.addon.worldgen.OreVeinDeclaration; +import gregtech.api.addon.worldgen.SmallOreDeclaration; +import gregtech.api.material.GTMaterial; +import gregtech.engine.material.GTMaterialRegistry; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; + +/** Fact-only world-generation projection used by the material process snapshot. */ +public final class MaterialWorldgenFacts { + public enum Kind { + LARGE_VEIN, + SMALL_ORE, + STONE_LAYER, + BEDROCK + } + + public record Ore( + GTMaterial material, + String itemState, + int minY, + int maxY, + int amount, + int chanceDivisor, + List details) { + public Ore { + itemState = requireState(itemState); + details = List.copyOf(details); + } + } + + public record Fact( + String id, + String name, + Kind kind, + String dimension, + int minY, + int maxY, + int weight, + int totalWeight, + List ores) { + public Fact { + if (id == null || id.isBlank() || name == null || name.isBlank() || kind == null) + throw new IllegalArgumentException("Invalid worldgen process fact"); + dimension = dimension == null || dimension.isBlank() ? "unknown" : dimension; + ores = List.copyOf(ores); + } + } + + public static final class Snapshot { + private final List facts; + private final long revision; + + private Snapshot(List facts) { + this.facts = List.copyOf(facts); + long hash = 1_125_899_906_842_589L; + for (Fact fact : facts) + hash = 31 * hash + + (((long) (fact.id.hashCode() * 31 + + fact.dimension.hashCode() + + fact.minY + + fact.maxY + + fact.ores.hashCode())) + ^ (hash >>> 32)); + revision = hash & Long.MAX_VALUE; + } + + public List facts() { + return facts; + } + + public long revision() { + return revision; + } + } + + private MaterialWorldgenFacts() {} + + public static Snapshot capture() { + var facts = new ArrayList(); + appendLargeVeins(facts); + appendSmallOres(facts); + appendStoneLayers(facts); + appendBedrock(facts); + return new Snapshot(facts); + } + + private static void appendLargeVeins(List facts) { + var dimensions = new LinkedHashSet(); + dimensions.add(OreVeinDeclaration.OVERWORLD); + dimensions.add(OreVeinDeclaration.END); + dimensions.addAll(AddonOreVeins.veinDimensions()); + for (String dimension : dimensions) { + var veins = GTOreVeins.activeVeins(dimension); + boolean remapped = OreVeinDeclaration.OVERWORLD.equals(dimension); + int totalWeight = OreVeinDeclaration.END.equals(dimension) + ? GTOreVeins.endSelectionWeight(veins) + : veins.stream().mapToInt(GTOreVeins.OreVein::weight).sum(); + for (GTOreVeins.OreVein vein : veins) { + int minY = remapped ? GTWorldgenScale.remapY(vein.minY()) : vein.minY(); + int maxY = remapped ? GTWorldgenScale.remapY(vein.maxY()) : vein.maxY(); + var ores = new ArrayList(); + addVeinOre(ores, vein.top(), minY, maxY, "top"); + addVeinOre(ores, vein.bottom(), minY, maxY, "bottom"); + addVeinOre(ores, vein.between(), minY, maxY, "between"); + addVeinOre(ores, vein.spread(), minY, maxY, "spread"); + facts.add(new Fact( + "large/" + dimension + "/" + vein.name(), + vein.name(), + Kind.LARGE_VEIN, + dimension, + minY, + maxY, + vein.weight(), + totalWeight, + ores)); + } + } + } + + private static void addVeinOre(List out, GTMaterial material, int minY, int maxY, String layer) { + if (material == null || !material.resolve().isValid()) return; + out.add(new Ore( + material.resolve(), + itemState(oreItem(material.resolve())), + minY, + maxY, + 1, + 0, + List.of("vein layer: " + layer))); + } + + private static void appendSmallOres(List facts) { + var dimensions = new LinkedHashSet(); + dimensions.add(SmallOreDeclaration.OVERWORLD); + dimensions.add(SmallOreDeclaration.NETHER); + dimensions.add(SmallOreDeclaration.END); + dimensions.addAll(AddonOreVeins.smallOreDimensions()); + for (String dimension : dimensions) { + boolean remapped = SmallOreDeclaration.OVERWORLD.equals(dimension); + for (GTOreVeins.SmallOre ore : GTOreVeins.activeSmallOres(dimension)) { + GTMaterial material = ore.material().resolve(); + if (!material.isValid()) continue; + int minY = remapped ? GTWorldgenScale.remapY(ore.minY()) : ore.minY(); + int maxY = remapped ? GTWorldgenScale.remapY(ore.maxY()) : ore.maxY(); + facts.add(new Fact( + "small/" + dimension + "/" + ore.name(), + ore.name(), + Kind.SMALL_ORE, + dimension, + minY, + maxY, + 0, + 0, + List.of(new Ore( + material, + itemState(smallOreItem(material)), + minY, + maxY, + ore.amount(), + 0, + List.of("blocks per chunk"))))); + } + } + } + + private static void appendStoneLayers(List facts) { + if (!GTWorldgenDefaults.STONE_LAYERS) return; + var layers = new ArrayList(); + layers.addAll(GTStoneLayersGen.LAYERS); + for (GTStoneLayersGen.ContactDef contact : GTStoneLayersGen.CONTACTS) { + layers.add(new GTStoneLayersGen.LayerDef( + null, null, contact.materialA() + "/" + contact.materialB(), false, contact.ores())); + if (contact.bothSides()) { + layers.add(new GTStoneLayersGen.LayerDef( + null, null, contact.materialB() + "/" + contact.materialA(), false, contact.ores())); + } + } + int sequence = 0; + for (GTStoneLayersGen.LayerDef layer : layers) { + int layerIndex = sequence++; + var ores = new ArrayList(); + for (GTStoneLayersGen.OreDef definition : layer.ores()) { + var rule = StoneLayerOreRules.rule(definition); + if (!StoneLayerOrePlacement.enabled(rule)) continue; + GTMaterial material = GTMaterialRegistry.get(definition.material()); + if (material == null || !material.resolve().isValid()) continue; + material = material.resolve(); + int min = Math.max(GTWorldgenScale.WORLD_FLOOR + 1, GTWorldgenScale.stoneLayerOreMinY(definition)); + if (layer.noDeep()) min = Math.max(min, GTWorldgenScale.remapY(24)); + int max = Math.min(GTWorldgenScale.BAND_TOP - 1, GTWorldgenScale.remapY(definition.maxY())); + if (min > max) continue; + ores.add(new Ore( + material, + itemState(explicitItem(material, rule)), + min, + max, + 1, + Math.max(1, definition.chanceDiv()), + rule.biomes().isEmpty() + ? List.of("stone-layer roll") + : List.of("stone-layer roll; biomes: " + rule.biomes()))); + } + if (ores.isEmpty()) continue; + int minY = ores.stream().mapToInt(Ore::minY).min().orElse(0); + int maxY = ores.stream().mapToInt(Ore::maxY).max().orElse(0); + facts.add(new Fact( + "stratum/" + layerIndex + "/" + layer.material(), + layer.material(), + Kind.STONE_LAYER, + "minecraft:overworld", + minY, + maxY, + 0, + 0, + ores)); + } + } + + private static void appendBedrock(List facts) { + appendBedrock(facts, GTBedrockOres.OVERWORLD, "minecraft:overworld"); + appendBedrock(facts, GTBedrockOres.NETHER, "minecraft:the_nether"); + } + + private static void appendBedrock(List facts, List rows, String dimension) { + for (GTBedrockOres.BedrockOre row : rows) { + GTMaterial material = row.material().resolve(); + if (!material.isValid()) continue; + facts.add(new Fact( + "bedrock/" + dimension + "/" + row.name(), + row.name(), + Kind.BEDROCK, + dimension, + GTWorldgenScale.WORLD_FLOOR, + GTWorldgenScale.WORLD_FLOOR + 2, + row.chance(), + 0, + List.of(new Ore( + material, + itemState(oreItem(material)), + GTWorldgenScale.WORLD_FLOOR, + GTWorldgenScale.WORLD_FLOOR + 2, + 1, + 0, + List.of("bedrock rarity: " + row.chance()))))); + } + } + + private static Item explicitItem(GTMaterial material, StoneLayerOreRules.Rule rule) { + var state = StoneLayerOrePlacement.explicitState(rule); + return state == null ? oreItem(material) : state.getBlock().asItem(); + } + + private static Item oreItem(GTMaterial material) { + String path = + material.getName().replaceAll("([a-z0-9])([A-Z])", "$1_$2").toLowerCase(Locale.ROOT); + Item item = BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath("gt6ce", "ore_" + path)); + return item == Items.AIR ? Items.STONE : item; + } + + private static Item smallOreItem(GTMaterial material) { + String path = + material.getName().replaceAll("([a-z0-9])([A-Z])", "$1_$2").toLowerCase(Locale.ROOT); + Item item = BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath("gt6ce", "ore_small_" + path)); + return item == Items.AIR ? oreItem(material) : item; + } + + private static String itemState(Item item) { + return "item:" + BuiltInRegistries.ITEM.getKey(item); + } + + private static String requireState(String state) { + if (state == null || state.isBlank()) throw new IllegalArgumentException("Missing worldgen item state"); + return state; + } +} diff --git a/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java b/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java index bedd7a7ea..034e82d1f 100644 --- a/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java +++ b/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java @@ -21,9 +21,11 @@ import gregtech.content.material.Materials; import gregtech.content.recipe.CraftingMaterialForms; import gregtech.content.recipe.MachineRecipeOverlay; +import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.content.recipe.MaterialRecoveryRules; import gregtech.content.registry.GTItems; import gregtech.content.registry.GTTechnological; +import gregtech.content.worldgen.MaterialWorldgenFacts; import gregtech.engine.fluid.PortableFluidContainerSpec; import gregtech.engine.machine.crucible.CrucibleItemInput; import gregtech.engine.material.ItemComposition; @@ -884,6 +886,50 @@ public static void realResourceReloadDoesNotAccumulateRules(GameTestHelper helpe awaitReload(helper, applications, compositionRevision, compositions, before, sample); } + @GameTest(template = "test_empty", batch = "material_baseline_reload", timeoutTicks = 600) + public static void materialProcessSnapshotIsBoundedAndCurrent(GameTestHelper helper) { + var snapshot = MaterialProcessSnapshot.Store.current(); + var worldgen = MaterialWorldgenFacts.capture(); + helper.assertTrue( + snapshot.samePublication(MachineRecipeOverlay.lastPublication()), + "process graph uses the successful material publication"); + helper.assertTrue( + snapshot.snapshot().worldgenRevision() == worldgen.revision(), + "process graph binds the active worldgen fact revision"); + helper.assertFalse(worldgen.facts().isEmpty(), "active worldgen facts are present"); + helper.assertTrue( + worldgen.revision() == MaterialWorldgenFacts.capture().revision(), + "worldgen fact revision is stable"); + helper.assertTrue( + worldgen.facts().stream() + .allMatch(fact -> !fact.ores().isEmpty() + && fact.minY() <= fact.maxY() + && fact.ores().stream().allMatch(ore -> ore.minY() <= ore.maxY())), + "worldgen facts retain bounded, ordered native heights"); + helper.assertFalse(snapshot.roots().isEmpty(), "process graph exposes published material roots"); + var budgets = gregtech.engine.material.MaterialProcessGraph.Budgets.DEFAULT; + for (var root : snapshot.roots().stream().limit(24).toList()) { + var first = snapshot.query( + root.resource(), gregtech.engine.material.MaterialProcessGraph.Direction.BOTH, budgets); + var second = snapshot.query( + root.resource(), gregtech.engine.material.MaterialProcessGraph.Direction.BOTH, budgets); + helper.assertTrue(first.steps().size() <= budgets.maxSteps(), "step budget is enforced"); + helper.assertTrue(first.edges().size() <= budgets.maxEdges(), "edge budget is enforced"); + helper.assertFalse(first.notices().isEmpty(), "coverage is always reported"); + helper.assertTrue(first.steps().equals(second.steps()), "repeated queries have stable steps"); + helper.assertTrue(first.edges().equals(second.edges()), "repeated queries have stable edges"); + var references = first.steps().stream() + .map(gregtech.engine.material.MaterialProcessGraph.Step::reference) + .collect(java.util.stream.Collectors.toSet()); + helper.assertTrue( + first.edges().stream() + .allMatch(edge -> references.contains(edge.source()) + && references.contains(edge.target())), + "every edge endpoint belongs to the bounded query result"); + } + helper.succeed(); + } + private static void awaitReload( GameTestHelper helper, int applications, @@ -919,6 +965,9 @@ private static void awaitReload( MachineRecipeOverlay.lastPublication().compositionRevision() == ItemMaterialRegistry.compositionRevision(), "the publication stamp names the composition snapshot used by the recipe overlay"); + helper.assertTrue( + MaterialProcessSnapshot.Store.current().samePublication(MachineRecipeOverlay.lastPublication()), + "the process graph republished with the successful recipe generation"); helper.assertTrue( compositions.equals(compositionSnapshot()), "repeat reload preserves effective composition membership and values"); From 7c924900bd9cf764e9219e05e67127b983c8f9e7 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Sat, 14 Nov 2026 01:24:14 +0800 Subject: [PATCH 04/17] bugfix --- .../engine/material/MaterialProcessGraph.java | 41 ++-- .../resources/assets/gt6ce/lang/en_us.json | 1 + .../resources/assets/gt6ce/lang/zh_cn.json | 1 + .../material/MaterialProcessGraphTest.java | 39 ++++ docs/architecture/packages/runtime.md | 2 +- docs/decisions/0001-material-data-api.md | 4 +- docs/development/material-process-display.md | 4 +- .../08-material-data-api.md | 12 +- .../development/validation/checks/gametest.md | 2 + .../validation/checks/manual-ingame.md | 17 +- docs/integration/README.md | 2 + docs/integration/material-process-snapshot.md | 53 +++++ .../gregtech/client/MachineRecipeClient.java | 4 +- .../common/MaterialProcessProjection.java | 2 +- .../compat/emi/GregTechEMIPlugin.java | 2 +- .../compat/emi/MaterialProcessEmiRecipe.java | 27 ++- .../content/recipe/MachineRecipeOverlay.java | 1 - .../recipe/MaterialProcessSnapshot.java | 193 ++++++++++++++---- .../content/recipe/OvenRecipeBridge.java | 3 - .../content/recipe/RecipePublication.java | 10 +- .../worldgen/MaterialWorldgenFacts.java | 79 ++++--- .../recipe/MaterialProcessSnapshotTests.java | 112 ++++++++++ 22 files changed, 493 insertions(+), 118 deletions(-) create mode 100644 docs/integration/material-process-snapshot.md create mode 100644 minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java diff --git a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java index 40d40c253..f75cea793 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java +++ b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java @@ -1,7 +1,6 @@ package gregtech.engine.material; import gregtech.api.addon.material.DataKey; - import java.util.*; /** @@ -217,6 +216,8 @@ public Query query(DataKey root, Direction direction, Budgets budgets) { visited.put(node.reference, node.depth); IndexedStep indexed = steps.get(node.reference); if (indexed == null) continue; + omittedPorts += Math.max(0, indexed.step.inputs().size() - budgets.maxPortsPerSide()); + omittedPorts += Math.max(0, indexed.step.outputs().size() - budgets.maxPortsPerSide()); if (node.depth >= budgets.maxDepth()) { if (direction != Direction.USES) omittedDepth += indexed.step.inputs().stream() @@ -237,7 +238,6 @@ public Query query(DataKey root, Direction direction, Budgets budgets) { boolean expandOutputs = direction != Direction.SOURCES; if (expandInputs) { int available = Math.min(indexed.step.inputs().size(), budgets.maxPortsPerSide()); - omittedPorts += indexed.step.inputs().size() - available; for (int index = 0; index < available && !stopped; index++) { Port port = indexed.step.inputs().get(index); for (IndexedStep source : @@ -268,7 +268,6 @@ public Query query(DataKey root, Direction direction, Budgets budgets) { } if (expandOutputs && !stopped) { int available = Math.min(indexed.step.outputs().size(), budgets.maxPortsPerSide()); - omittedPorts += indexed.step.outputs().size() - available; for (int index = 0; index < available && !stopped; index++) { Port port = indexed.step.outputs().get(index); for (IndexedStep target : @@ -307,8 +306,14 @@ public Query query(DataKey root, Direction direction, Budgets budgets) { .sorted(Map.Entry.comparingByValue()) .map(entry -> boundedStep(steps.get(entry.getKey()).step, budgets.maxPortsPerSide())) .toList(); + var retained = new HashMap(); + resultSteps.forEach(step -> retained.put(step.reference(), step)); var resultEdges = edges.keySet().stream() .filter(edge -> visited.containsKey(edge.source()) && visited.containsKey(edge.target())) + .filter(edge -> retained.get(edge.source()).outputs().stream() + .anyMatch(port -> port.resource().key().equals(edge.resource()))) + .filter(edge -> retained.get(edge.target()).inputs().stream() + .anyMatch(port -> port.resource().key().equals(edge.resource()))) .toList(); var resultNotices = new ArrayList<>(notices); truncations.forEach((code, omitted) -> resultNotices.add(new Notice(code, omitted))); @@ -336,15 +341,17 @@ private int enqueue( ArrayDeque queue, Set queued) { int omitted = 0; - var starts = new LinkedHashSet(); - if (sources) starts.addAll(outputs.getOrDefault(root, List.of())); - if (uses) starts.addAll(inputs.getOrDefault(root, List.of())); - for (IndexedStep start : starts) { - if (queued.size() >= budgets.maxSteps()) { - omitted++; - continue; + for (List starts : List.of( + sources ? outputs.getOrDefault(root, List.of()) : List.of(), + uses ? inputs.getOrDefault(root, List.of()) : List.of())) { + for (int index = 0; index < starts.size(); index++) { + if (queued.size() >= budgets.maxSteps()) { + omitted += starts.size() - index; + break; + } + IndexedStep start = starts.get(index); + if (queued.add(start.step.reference())) queue.addLast(new Node(start.step.reference(), depth)); } - if (queued.add(start.step.reference())) queue.addLast(new Node(start.step.reference(), depth)); } return omitted; } @@ -413,15 +420,19 @@ public Builder add(Step step) { int order = steps.size(); IndexedStep indexed = new IndexedStep(order, step); steps.put(step.reference(), indexed); + var inputResources = new HashSet(); for (Port port : step.inputs()) { register(port.resource()); - inputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) - .add(indexed); + if (inputResources.add(port.resource().key())) + inputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) + .add(indexed); } + var outputResources = new HashSet(); for (Port port : step.outputs()) { register(port.resource()); - outputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) - .add(indexed); + if (outputResources.add(port.resource().key())) + outputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) + .add(indexed); } return this; } diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index e80bbe65f..dfe175033 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -79,6 +79,7 @@ "gt6ce.jei.material_process.role.byproduct": "Byproduct", "gt6ce.jei.material_process.role.unknown": "Output role: unknown", "gt6ce.jei.material_process.material_title": "%s processing", + "gt6ce.jei.material_process.page_controls": "Page counter: left-click for next page, right-click for previous page.", "gt6ce.jei.material_process.port_name": "%s / %s", "gt6ce.jei.material_process.amount.items": "Amount: %s items", "gt6ce.jei.material_process.amount.units": "Amount: %s U", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index 9700df728..30343f9dc 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -81,6 +81,7 @@ "gt6ce.jei.material_process.role.byproduct": "副产物", "gt6ce.jei.material_process.role.unknown": "产物角色:未知", "gt6ce.jei.material_process.material_title": "%s 加工", + "gt6ce.jei.material_process.page_controls": "点击页码:左键下一页,右键上一页。", "gt6ce.jei.material_process.port_name": "%s/%s", "gt6ce.jei.material_process.amount.items": "数量:%s 件", "gt6ce.jei.material_process.amount.units": "数量:%s U", diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java index d60e6ae6d..2ce42dec3 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java @@ -125,6 +125,45 @@ private static boolean edgeIsConfirmed(MaterialProcessGraph.Edge edge) { return edge.confirmed(); } + @Test + void portsTruncatedAtTheDepthBoundaryStillReportPartialCoverage() { + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(step( + "split", + List.of(port(resource("ore"), Role.CONSUMED, "ore")), + List.of( + port(resource("one"), Role.UNKNOWN, "dust"), + port(resource("two"), Role.UNKNOWN, "dust")))) + .build(); + for (Direction direction : Direction.values()) { + DataKey root = direction == Direction.USES ? resource("ore") : resource("one"); + var result = graph.query(root, direction, new Budgets(0, 8, 1, 8)); + assertTrue(result.truncated()); + assertTrue( + result.notices().stream().anyMatch(notice -> notice.code().equals("port_limit"))); + } + } + + @Test + void edgesNeverReferToPortsDiscardedByTheBudget() { + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(step( + "split", + List.of(port(resource("ore"), Role.CONSUMED, "ore")), + List.of( + port(resource("one"), Role.UNKNOWN, "dust"), + port(resource("two"), Role.UNKNOWN, "dust")))) + .add(step( + "use", + List.of(port(resource("two"), Role.CONSUMED, "dust")), + List.of(port(resource("end"), Role.UNKNOWN, "dust")))) + .build(); + var result = graph.query(resource("two"), Direction.BOTH, new Budgets(4, 8, 1, 8)); + assertEquals(2, result.steps().size()); + assertTrue(result.edges().isEmpty()); + assertTrue(result.truncated()); + } + private static DataKey resource(String name) { return new DataKey("gt6ce", "resource/" + name); } diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index e1df2304a..fb82e5cfb 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,7 +70,7 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理由 `content.recipe.MaterialProcessSnapshot` 从成功发布点绑定最终机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`client.MaterialProcessPanel` 负责布局和交互,`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、索引和事件适配。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 +矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`client.MaterialProcessPanel` 负责布局和交互,`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、索引和事件适配。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 diff --git a/docs/decisions/0001-material-data-api.md b/docs/decisions/0001-material-data-api.md index 5979076a8..8ec89a513 100644 --- a/docs/decisions/0001-material-data-api.md +++ b/docs/decisions/0001-material-data-api.md @@ -1,10 +1,10 @@ # 0001:材料数据 API 与加工关系视图 -- 状态:部分实施;A(薄视图与 metadata)已完成,B 的 tag/替代组定义与查询随计划 02 完成,C 的形态规则、实际资源绑定与 tag 桥接声明随计划 03 完成;D—E 仍待实施。 +- 状态:部分实施;A(薄视图与 metadata)已完成,B 的 tag/替代组定义与查询随计划 02 完成,C 的形态规则、实际资源绑定与 tag 桥接声明随计划 03 完成;D—E 的内部快照、core 图和 JEI/EMI 接入已实施,运行期与远程/人工验收尚未闭合。 - 日期、作者、关联任务:2026-11-07,材料系统重构设计;关联 [#351](https://github.com/GregTech6CE/GregTech6/issues/351) 与材料标签、形态、获取途径和处理图整合需求。 - 替代/被替代关系:无;补充[材料重构计划](../development/material-system-refactor/README.md),不替代现行 API 契约。 -本文确定数据边界、查询接口和扩展方式。分步实现与验证见[计划 08](../development/material-system-refactor/08-material-data-api.md)。A—C 的视图、metadata、分类与形态内容快照已经发布;来源和处理图接口仍是后续设计轮廓。 +本文确定数据边界、查询接口和扩展方式。分步实现与验证见[计划 08](../development/material-system-refactor/08-material-data-api.md)。A—C 的视图、metadata、分类与形态内容快照已经发布;来源和处理图已有模组实现层入口,尚未作为独立 API JAR 的公共服务发布;下文未落地的公共接口仍为设计轮廓。 ## 背景与约束 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md index 6a5fee079..7e3f645cb 100644 --- a/docs/development/material-process-display.md +++ b/docs/development/material-process-display.md @@ -40,7 +40,7 @@ ## 布局与交互 -主加工位于中线,共同输入及催化剂位于左侧,其他产物位于右侧,副产物分支使用金色。批量、单位、角色、概率和完整条件在端口及工艺 tooltip 中读取。黄色角标和虚线表示随机、未知概率或未解析关系。 +主加工位于中线,共同原料及流体条件位于左侧,物品模具、工具等辅助条件留在步骤说明与原配方中,其他产物位于右侧,副产物分支使用金色。批量、单位、角色、概率和完整条件在端口及工艺 tooltip 中读取。黄色角标和虚线表示随机、未知概率或未解析关系。 只有显式关联连接的相邻主输出/主输入才绘制跨步骤中心箭头。其余分支、跨页关联、回边与自环以每步的关联数量和完整 tooltip 引用表示,不将非相邻步骤强行连线;循环不触发递归展开。原生状态相异但图标相同的端口仍分别显示。 @@ -49,7 +49,7 @@ - 左击工艺调用 `Navigation.openRecipe(step.reference)`,只在 `resolved=true` 时尝试。 - 左击资源调用 `Navigation.openForm(resource, false)` 查询来源,右击传 `true` 查询用途;回调返回 `false` 时不消费该点击,允许 JEI 原生行为继续处理。R/U 等快捷键仍由 JEI 管理。 - `Navigation.NONE` 是不支持跳转的明确默认实现,不需要 `null` 回调。 -- 翻页、分类展示与配方检索交给 JEI;没有自建分页状态或全局 UI 实例缓存。 +- JEI 使用原生分页;EMI 的初始分类也使用原生分页。EMI 动态来源/用途查询保留全部 `Page`,点击右上角页码前后翻页,不把后续步骤截成第一页。没有全局 UI 实例缓存。 ## 后续调用方式 diff --git a/docs/development/material-system-refactor/08-material-data-api.md b/docs/development/material-system-refactor/08-material-data-api.md index 71731ff81..812e67c83 100644 --- a/docs/development/material-system-refactor/08-material-data-api.md +++ b/docs/development/material-system-refactor/08-material-data-api.md @@ -1,6 +1,6 @@ # 08:材料标签、形态、来源与处理图 API -本计划将独立的材料相关系统通过查询与投影纳入材料 API,保持主材料对象简洁。状态:A—C 已完成;D 已从最终机器配方、有效成分、已发布形态和当前启用世界生成建立同代快照、有界来源/用途查询及客户端重建;E 已接 core 图、生产投影、JEI 和 EMI,并保留未知角色、符号选择器和预算截断。两平台运行期、远程客户端和人工 viewer 验收仍需按本页清单执行。接口与语义权威见[设计提议 0001](../../decisions/0001-material-data-api.md),本页只维护实施顺序与独立验收。 +本计划将独立的材料相关系统通过查询与投影纳入材料 API,保持主材料对象简洁。状态:A—C 已完成;D 已从最终机器配方、有效成分、已发布形态和当前启用世界生成建立同代快照、有界来源/用途查询及客户端重建;E 已接 core 图、生产投影、JEI 和 EMI,并保留未知角色、符号选择器和预算截断。本计划尚未完成最终验收;两平台运行期、远程客户端和人工 viewer 验收仍需按本页清单执行。接口与语义权威见[设计提议 0001](../../decisions/0001-material-data-api.md),本页只维护实施顺序与独立验收。 08 是贯穿原计划的集成工作,不是在 07 后重做材料系统。A 在 01 的调查基础上、02 的接口定稿前完成;B 并入 02/03,C 并入 03/04,D 随 05/06 的有效结果发布,E 在 D 后实施;最终由 07 联合验收。07 的内部事实与兼容入口清理可先进行,D—E 是其最终来源/处理图验收的前置,详见 [07 拆分](07-cleanup-and-acceptance.md#拆分与兼容处理)。 @@ -101,6 +101,8 @@ D 的查询结果必须绑定一个完整发布上下文:`MaterialPublication.Stamp`、server/level 会话、活动世界生成配置和任何按世界生效的开关。配方、成分、形态和世界生成事实不得分别从不同代次拼成一个结果。 +总览对模具、工具等辅助物品只保留步骤条件与原配方跳转,不展开其获取路线;普通消耗原料和产物不得因缺少材料形态而静默省略。 + 来源与用途使用同一份有界索引:来源按目标资源查前驱,用途按已发布关系查后继。每条关系保留步骤身份、共同输入、催化剂、全部输出、批量单位、概率、原生状态限制、覆盖程度和原生配方引用。资源身份至少区分材料、形态、相态与原生状态;同一图标或物品 ID 不构成身份合并。 `DataKey` 只表达展示快照内的引用,不是来源索引主键或存档 ID。D 的适配器把原生步骤和资源引用投影成展示引用;跳转时先校验当前发布戳和会话,再重新解析原生配方。旧快照可以服务于尚未结束的查询或展示,但不得跨重载、换服或会话复用。 @@ -119,8 +121,8 @@ D 的查询结果必须绑定一个完整发布上下文:`MaterialPublication. ### 实施结果 -- `MaterialProcessSnapshot` 在 `MachineRecipeOverlay` 成功发布后一次构建;失败重建不替换上一成功快照,旧快照只保留一代供进行中的 viewer 回调使用。 -- 机器步骤读取 overlay 完成后的 `RecipeMap.mRecipeList`,保留共同输入、催化剂、存在性条件、全部输出、物品/U/mB 批量、概率、原生状态与来源说明。 +- `MaterialProcessSnapshot` 在服务端 `RecipePublication` 最终提交后构建,独立客户端在 overlay 与炉镜像完成后构建;同代、同形态/tag/世界生成 revision 复用索引;失败重建不替换上一成功快照,旧快照只保留一代供进行中的 viewer 回调使用。 +- 机器步骤读取 overlay 完成后的 `RecipeMap.mRecipeList`,保留共同原料、存在性条件、全部输出、物品/U/mB 批量、概率、原生状态与来源说明。模具、工具等物品催化剂保留在步骤说明和原配方中,不扩展为总览资源路线;未分类的普通物品/流体仍保留原生端口。 - `MaterialWorldgenFacts` 读取当前活动配置,输出维度、高度、岩层、小矿和基岩事实;selection weight 与岩层 roll divisor 保留在说明中,不伪装成掉落概率。 - `MaterialProcessSnapshot.Store` 在集成服务器和独立客户端分别由同步后的配方/标签重建;登录、断线、重载或换服后,旧 `DataKey` 与导航回调因快照身份变化而失效。 - 未新增网络协议:客户端使用原版同步的 `RecipeManager`、已同步材料定义和同一 datapack 世界生成配置重建;导航再解析本代原生配方引用。 @@ -174,7 +176,7 @@ D 已发布来源/用途索引 ### 实施结果 -- `MaterialProcessGraph` 在 core 中按 `SOURCES`、`USES`、`BOTH` 遍历,限制深度、步骤、每侧端口和关联数量;循环按步骤访问集终止,稳定保留截断原因。 +- `MaterialProcessGraph` 在 core 中按 `SOURCES`、`USES`、`BOTH` 遍历,使用跨材料共享索引,限制深度、步骤、每侧端口和关联数量;循环按步骤访问集终止,稳定保留截断原因。 - `MaterialProcessProjection` 只把已查询结果转成展示值。物品、流体、tag 和 unit 选择器保持独立引用;tag/unit 只提供有限代表,不展开候选全集。 - JEI 与 EMI 共用 `MaterialProcessPanel` 和同一 `Page` 列表。工艺点击定位当前快照中的原生机器配方,资源左右击重新查询该快照的形态来源/用途。 - JEI 与 EMI 的分类仅由客户端注册;`MaterialProcessSnapshot` 与 core 图不引用 viewer 类型,专用服务端可独立构建和查询。 @@ -197,6 +199,8 @@ D 已发布来源/用途索引 - 独立远程客户端:只使用同步得到的同代 projection,断线、换服和旧回调拒绝;不得读取集成服务器共享内存。 - 双平台人工游戏检查:JEI 正式材料页、精确配方跳转、形态来源/用途切换;EMI 接线完成后再单独记录,未安装 viewer 的行为也算独立场景。 +实现核对、回归命令和未覆盖场景见[材料处理快照与共享图验证](../../integration/material-process-snapshot.md)。 + ## 交付顺序与完成条件 每个切片都能独立交付:A 的公共模型不要求先完成全图;B/C 的查询已有直接消费者;E 的展示切片可以独立验证输入校验与布局,但只有 D 提供正式关系后才可验证真实内容。D 先有准确的来源/用途列表和快照语义,再由 E 查询并绘图。每步保持旧 API 可用,迁移完一个消费者后再删除其重复数据。 diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index 5561a08b9..040f1d906 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -36,6 +36,8 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe ### 配方回归案例表 +材料处理的 `MaterialProcessSnapshotTests` 验证输入 tag 不污染输出、跨材料路线、世界生成形态与完整 revision、普通共同原料、辅助工具说明、过期资源拒绝和同代索引复用;`material_process` 批次不写生产配方。 + 材料领域的 `MaterialBaselineTests` 验证存储块的成分与两类准入、72U 附魔金苹果的规划和实际回收输出、复合钻头、耐久缩放、容器与有形状铸模、压模机模具、固体/流体分解及 test-source 材料 SPI。`material_baseline_reload` 为仅含一个测试的独立批次,等待两次真实资源重载;拥有规则数和固定样例必须稳定。原始投影写入根目录 `work/material-system-refactor/runtime//<运行目录>/`。已知错误行为明确标为观察,不能当作正确性依据;字段、复现与未覆盖范围见[材料基线报告](../../../integration/material-baseline.md)。 `decompositionRespectsFormsAndExactFluidIdentities` 通过测试 SPI 声明 dust-only、blockDust-only、liquid-only 和 gas-only 分解,检查形态限制、流体输入不会错误抑制允许的固体兜底、本体完整 ID、附属完整 ID/旧裸路径、外部原版流体 ID、未知及非法 ID,以及附属流体输出的身份和数量。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 66aa705e4..c599e83e6 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -20,14 +20,15 @@ ### 矿物处理展示页 -接口与测试输入契约见[展示接入](../../material-process-display.md)。当前默认仅有未接入说明页;带数据场景由客户端测试调用方提交有界投影,不连接或硬编码生产材料。 - -1. 在 JEI 分类中打开“矿物处理”,确认未接入提示,没有虚构材料、配方与来源。分别使用中英文及不同 GUI 缩放检查边界、文字和悬停命中。 -2. 提供至少三个步骤,确认原生分页不丢步骤;共同输入、催化剂、存在性条件和多产物分别显示,量与单位、概率及条件 tooltip 完整。无主产物声明时显示未知角色。 -3. 提供符号端口、未知概率、未解析工艺和超过六个的侧排端口,确认问号、虚线、概率提示与折叠信息;折叠端口的代表仍可通过 JEI R/U 找到。 -4. 提供分支、相邻主路线、跨页边、回边和自环;只有显式关联产生跨步骤中心箭头,其余关联保留引用,不重复展开或卡死。提供两档候选规模,代表图标与查询预算不随候选笛卡尔积增长。 -5. 用记录调用的导航回调确认左右击资源的来源/用途方向、工艺精确引用及 `false` 回退。真实服务接线后再验证具体原配方、重载与换服过期引用拒绝、独立远程客户端同版本数据;当前均不能由前端测试代替。 -6. 两平台分别检查 JEI,另检查无 JEI 的专用服务端;安装 EMI 时保持现有 JEI 桥去重规则,不声称已实现 EMI 原生矿物页。 +接口与测试输入契约见[展示接入](../../material-process-display.md)。生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用同一图和面板;没有成功快照时才显示未接入说明。 + +1. 在 JEI 或 EMI 中打开“矿物处理”,用真实 ore/raw/crushed 材料确认来源和加工步骤。分别使用中英文及不同 GUI 缩放检查边界、文字和悬停命中。 +2. 用洗矿、合金和电解/离心检查共同原料、全部产物、量与单位、随机副产物和条件 tooltip。模具、工具等辅助物品保留在步骤说明和原配方中,不展开为总览路线;未知材料形态的普通原料仍须显示原生引用。 +3. 检查符号端口、未知概率、未解析工艺和超过六个的侧排端口;确认问号、虚线、概率提示与折叠信息。折叠端口的代表仍可通过 viewer 原生检索找到。 +4. 检查分支、跨材料步骤、跨页边、回边和自环;只有显式关联产生跨步骤中心箭头。两档候选规模下,代表图标与查询预算不随候选笛卡尔积增长。 +5. 左右击资源分别查询来源/用途,左击工艺精确打开原配方。EMI 动态查询超过两步时,左右击右上角页码确认所有页面都可到达。连续重载两次后重新打开页面,确认配方增删同步生效、旧引用拒绝,断线/换服不沿用旧回调。 +6. 两平台分别检查 JEI-only、EMI-only 和双装环境。双装继续采用既有 JEI 桥去重规则,以 EMI 原生矿物页为入口;不能把 JEI 中被去重的页面算作内容丢失。 +7. 另验无 viewer 的专用服务端与独立远程客户端;远程图必须来自同代同步事实,不能用集成服务器共享静态表证明同步正确。当前未记录的远程、截图和点击场景均为未验证。 ## 注意事项 diff --git a/docs/integration/README.md b/docs/integration/README.md index f59c5dc69..fa3eae2ba 100644 --- a/docs/integration/README.md +++ b/docs/integration/README.md @@ -12,3 +12,5 @@ - [材料重构 05:统一回收计算与生成](material-refactor-05-recovery.md):成分驱动的回收计划、精确数量、主要生产端和重载诊断。 - [材料重构 06:统一分解](material-refactor-06-decomposition.md):规则化权限、相态与单位、纯计划、配方发布和执行验收。 - [材料重构 07-E:材料与形态注册项审计](material-refactor-07-roster.md):124 个形态族的来源、消费者、去留决定和双平台一致性。 + +- [材料处理快照与共享图验证](material-process-snapshot.md):发布时点、端口身份、跨材料查询、预算和 viewer 接入的回归范围与剩余验收。 diff --git a/docs/integration/material-process-snapshot.md b/docs/integration/material-process-snapshot.md new file mode 100644 index 000000000..e59ee2426 --- /dev/null +++ b/docs/integration/material-process-snapshot.md @@ -0,0 +1,53 @@ +# 材料处理快照与共享图验证 + +## 范围与状态 + +本页记录材料来源/用途快照、core 图及 viewer 投影的代码核对与回归方法。状态:部分验证;不能据此把[计划 08](../development/material-system-refactor/08-material-data-api.md)整体标为完成。 + +源码依据:`de16ac298`、`8722ac629` 与其上的工作区修复。此次仅调整展示索引、发布时机、查询预算和展示交互;没有修改机器执行配方、材料成分、注册 ID、存档或网络协议。公共 API 版本保持 1.8.0。 + +## 已确认问题与处理 + +| 问题 | 影响与处理 | +| --- | --- | +| overlay 与炉桥接各自构建快照 | 中间行集被提前发布并重复消耗构建时间。服务端改在 `RecipePublication` 提交后发布,独立客户端在 overlay/炉镜像后发布;完整上下文未变时复用索引。失败 overlay 不替换成功快照。 | +| 输入 tag 被用于同槽号输出 | 物品或流体输出会变成输入 tag 的代表。输出只读取自身原生身份,输入的 tag、unit 和取整规则保持独立。 | +| 世界生成物品使用驼峰转下划线名称,查找失败回退石头 | 与实际生成器的小写注册名不符,会把矿物来源画成石头。按实际注册名查找;未注册矿物不作为有效生成来源。 | +| 世界生成端口写死 `ore` | 与注册物品的 `oreVanillastone`、`oreDense` 等形态无法连接。改从原生物品解析真实形态,小矿单独保留身份;优先选择普通矿物而非小矿作为总览根。 | +| 世界生成 revision 漏字段并使用含材料对象的哈希 | 权重或种类改变不能使 revision 改变,跨 JVM 的对象哈希也不表达相同事实。按完整事实字段及稳定材料名计算 revision。 | +| 仅在根材料分桶内遍历 | 分解、合金和副产物进入另一材料后路线停止。改为一个跨材料索引,查询仍受同一深度、步骤、端口和边预算限制。 | +| 预算裁剪后仍输出关联 | 关联可能指向已裁掉的端口,导致展示构造拒绝整个查询。返回边只引用保留下来的端口;深度边界和非展开侧的端口裁剪也报告部分覆盖。根候选不先复制全集再截断。 | +| 资源 `DataKey` 可跨快照复用 | 新代查询可能接受旧资源。资源引用加入每次构建的作用域,原生导航仍校验当前快照;服务器停止和客户端断线清理 Store。 | +| 普通无形态原料/产物被静默跳过 | 保留原生物品/流体端口及未分类说明,不把单一图标推断成某种材料;带额外原生条件的输入不与无条件资源合并。 | +| EMI 动态查询只显示第一页 | 来源/用途查询保存全部页,左右击右上角页码切换;初始分类继续使用原生分页。 | +| 文档状态矛盾与两节点导入顺序错误 | 更新设计状态、人工验收步骤及包入口;修复 Spotless 报告的导入顺序。 | + +模具、工具等辅助物品不扩展为总览资源路线,其数量、状态引用与原配方保留在步骤说明/原生配方中。这与普通消耗原料不能静默消失是两种情况。图不会因为工具没有材料成分而虚构一条工具生产链。 + +JEI 与 EMI 同装时,JEI 提前返回是已有桥接去重约定;本模组的 EMI 原生处理页已经注册。不能仅据 JEI 分支为空认定两 viewer 同装丢失处理页。实际双装交互仍须单独人工确认。 + +## 复现与检查 + +从仓库根目录运行: + +```bash +./gradlew format -PspotlessRatchet=de16ac298^ +./gradlew :core:test --tests gregtech.engine.material.MaterialProcessGraphTest spotlessCheck -PspotlessRatchet=de16ac298^ compileBothPlatforms :minecraft:1.20.1-forge:compileTestJava :minecraft:1.21.1-neoforge:compileTestJava +python tools/validation/route.py check +python tools/comments/check_comment_refs.py --diff HEAD +git diff --check +./gradlew :minecraft:1.20.1-forge:runGameTestServer -PgameTestHeap=4g -PgameTestDirectory=../../../work/material-process-review/gametest-forge +./gradlew :minecraft:1.21.1-neoforge:runGameTestServer -PgameTestHeap=4g -PgameTestDirectory=../../../work/material-process-review/gametest-neoforge +``` + +`MaterialProcessGraphTest` 包含循环、共同输入、前反向查询、各项预算、深度边界的端口截断及裁剪后的边合法性。`MaterialProcessSnapshotTests` 使用未发布到生产 Store 的小型原生行集,验证跨材料链、世界生成形态、普通共同原料、工具说明、物品/流体输出身份及快照引用隔离;另检查世界生成 revision 与相同上下文的索引复用。现有 `MaterialBaselineTests` 覆盖真实两次资源重载及成功发布戳。 + +原始日志位于本机忽略目录 `work/material-process-review/`,不随仓库提交。GameTest 用例数、平台与最终结果见下文;Gradle 退出成功不能代替游戏测试统计。 + +## 验证结果与剩余事项 + +- 执行且通过:材料图 JUnit 6 项,最近两次提交范围内的格式检查,双平台生产/测试源码编译,路由与注释检查、`git diff --check`。 +- 执行但失败或阻塞:首轮运行暴露工作区修复中的静态初始化顺序问题;随后一轮发现新增复用测试的前置上下文不一致,均已修正。最终 GameTest 结果待核对。 +- 尚未执行:独立远程客户端、JEI-only/EMI-only/双装点击及截图、无 viewer 的独立服务端、附属差异与世界生成开关矩阵;发行包检查待执行。 + +08 的 A—C 已有定义与形态入口;D—E 已有内部来源/用途快照、符号选择器和共享图代码,但尚不能标为全部验收完成。tag/unit 保持符号投影,不能声称枚举了全部动态工艺或完整可执行路线;本轮不新增公共 API 服务或网络同步协议。远程同代数据、断线/换服、实际 viewer 分页与精确跳转仍需要按[人工检查](../development/validation/checks/manual-ingame.md#矿物处理展示页)记录实际结果。局部图模型通过不能替代这些场景。 diff --git a/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java b/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java index 05a5dc36a..211dec2e8 100644 --- a/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java +++ b/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java @@ -61,11 +61,13 @@ public static void tags(TagsUpdatedEvent event) { private static void apply(RecipeManager recipes) { // Integrated server and client share the static maps. The server pass already applied them. if (ServerLifecycleHooks.getCurrentServer() != null) return; - MachineRecipeOverlay.apply(recipes); + if (MachineRecipeOverlay.apply(recipes).failed()) return; // A dedicated client also needs the furnace bridge: the machine-visible oven rows only // exist after it runs, and the synced recipe list alone does not recreate them locally. var connection = Minecraft.getInstance().getConnection(); if (connection != null) OvenRecipeBridge.apply(recipes, connection.registryAccess()); + MaterialProcessSnapshot.Store.publish( + MachineRecipeOverlay.lastPublication(), MachineRecipeOverlay.generation()); // The row set is final now; build on the task queue so the sync thread is not blocked. // A newer tag update supersedes this pass and its queued build. long generation = MachineRecipeOverlay.generation(); diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java index c8e7643b1..c80393783 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java @@ -143,7 +143,7 @@ private static List icons(Resource resource) { item(id).ifPresent(item -> icons.add(new ItemStack(item))); } else if (state.startsWith("unit:")) { String alternatives = state.substring("unit:".length()); - int separator = alternatives.indexOf('|'); + int separator = alternatives.lastIndexOf('|'); if (separator >= 0) alternatives = alternatives.substring(separator + 1); for (String value : alternatives.split(",")) { if (icons.size() >= MaterialProcessDisplay.MAX_ICONS) break; diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index 829624de2..c7c197bfa 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -200,7 +200,7 @@ public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean us : gregtech.engine.material.MaterialProcessGraph.Direction.SOURCES, this); if (pages.isEmpty()) return false; - dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe(pages.get(0))); + dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe(pages)); return true; } } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java index cdf9adab5..0b2d09ab9 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java @@ -31,13 +31,25 @@ public Component getName() { }; private final MaterialProcessDisplay.Page page; + private final List queryPages; + private final int queryPage; private final ResourceLocation id; private final List inputs; private final List catalysts; private final List outputs; public MaterialProcessEmiRecipe(MaterialProcessDisplay.Page page) { - this.page = page; + this(List.of(page), 0); + } + + public MaterialProcessEmiRecipe(List pages) { + this(pages, 0); + } + + private MaterialProcessEmiRecipe(List pages, int index) { + queryPages = List.copyOf(pages); + queryPage = index; + this.page = queryPages.get(index); id = ResourceLocation.fromNamespaceAndPath( "gt6ce", "/material_process/" @@ -167,11 +179,20 @@ public void render(GuiGraphics graphics, int x, int y, float delta) { @Override public boolean mouseClicked(int x, int y, int button) { + if (queryPages.size() > 1 && pageCounterContains(x, y) && (button == 0 || button == 1)) { + int next = Math.floorMod(queryPage + (button == 0 ? 1 : -1), queryPages.size()); + dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe(queryPages, next)); + return true; + } return MaterialProcessPanel.click(page, x, y, button); } @Override public List getTooltip(int x, int y) { + if (queryPages.size() > 1 && pageCounterContains(x, y)) + return List.of(ClientTooltipComponent.create( + Component.translatable("gt6ce.jei.material_process.page_controls") + .getVisualOrderText())); return MaterialProcessPanel.tooltip(page, x, y).stream() .map(line -> ClientTooltipComponent.create(line.getVisualOrderText())) .toList(); @@ -179,6 +200,10 @@ public List getTooltip(int x, int y) { }); } + private static boolean pageCounterContains(int x, int y) { + return x >= MaterialProcessPanel.WIDTH - 38 && x < MaterialProcessPanel.WIDTH && y >= 0 && y < 12; + } + private static final class PortSlot extends SlotWidget { private final MaterialProcessDisplay.Page page; private final MaterialProcessDisplay.Port port; diff --git a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java index e309e98d9..7f387eead 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java @@ -170,7 +170,6 @@ private static Result applyGeneration(RecipeManager manager, long current) { if (generation != current) return lastResult; lastPublication = MaterialPublication.platformGenerationPublished( ItemMaterialRegistry.compositionRevision(), current); - MaterialProcessSnapshot.Store.publish(lastPublication, current); lastResult = new Result(tally.removed, tally.added, tally.rejected, restoreMillis, baselineRows(), false, false); applications++; if (!overlayDumped) { diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java index 39185591b..bc34355a4 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java @@ -4,6 +4,7 @@ import gregtech.api.addon.material.DataKey; import gregtech.api.addon.recipe.RecipeOutputChances; import gregtech.api.material.GTMaterial; +import gregtech.content.block.OreBlock; import gregtech.content.data.RegisteredFluids; import gregtech.content.registry.GTFluids; import gregtech.content.worldgen.MaterialWorldgenFacts; @@ -40,10 +41,11 @@ import java.util.Optional; import java.util.OptionalInt; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicLong; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; +import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; //? if >=1.21.1 { /*import net.neoforged.neoforge.fluids.FluidStack; @@ -59,7 +61,7 @@ public final class MaterialProcessSnapshot { private static final Logger LOGGER = LogUtils.getLogger(); private static final char[] HEX = "0123456789abcdef".toCharArray(); - private static final MaterialProcessSnapshot EMPTY = empty(); + private static final AtomicLong RESOURCE_GENERATIONS = new AtomicLong(); public record NativeRecipe(RecipeMap map, Recipe recipe, int index) { public NativeRecipe { @@ -88,15 +90,16 @@ public record Root(String material, String form, DataKey resource) { new Notice("coverage_active_worldgen", 0), new Notice("partial_dynamic_selectors", 0), new Notice("partial_unknown_roles", 0)); + private static final MaterialProcessSnapshot EMPTY = empty(); private record Bucket(List steps, Map roots) {} private final MaterialProcessGraph.Snapshot snapshot; - private final Map buckets; + private final Map resources; + private final MaterialProcessGraph graph; private final List roots; private final Map nativeRecipes; private final Map worldgen; - private final Map graphs = new ConcurrentHashMap<>(); private MaterialProcessSnapshot( MaterialProcessGraph.Snapshot snapshot, @@ -105,7 +108,18 @@ private MaterialProcessSnapshot( Map nativeRecipes, Map worldgen) { this.snapshot = snapshot; - this.buckets = Map.copyOf(buckets); + var resources = new LinkedHashMap(); + var steps = new LinkedHashMap(); + buckets.values().forEach(bucket -> bucket.steps.forEach(step -> steps.putIfAbsent(step.reference(), step))); + var builder = MaterialProcessGraph.builder(snapshot); + COVERAGE.forEach(notice -> builder.notice(notice.code(), notice.omitted())); + for (Step step : steps.values()) { + builder.add(step); + step.inputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); + step.outputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); + } + this.resources = Map.copyOf(resources); + this.graph = builder.build(); this.roots = List.copyOf(roots); this.nativeRecipes = Map.copyOf(nativeRecipes); this.worldgen = Map.copyOf(worldgen); @@ -120,17 +134,13 @@ public List roots() { } public Optional resource(DataKey key) { - for (Bucket bucket : buckets.values()) { - for (Resource resource : bucket.roots.values()) - if (resource.key().equals(key)) return Optional.of(resource); - } - return Optional.empty(); + return Optional.ofNullable(resources.get(key)); } public Query query(DataKey root, Direction direction, Budgets budgets) { Optional resource = resource(root); if (resource.isEmpty()) return new Query(snapshot, root, direction, List.of(), List.of(), COVERAGE, false); - return graph(resource.get().material()).query(root, direction, budgets); + return graph.query(root, direction, budgets); } public Optional recipe(DataKey reference) { @@ -145,16 +155,6 @@ public boolean samePublication(MaterialPublication.Stamp publication) { return snapshot.publication().equals(publication); } - private MaterialProcessGraph graph(String material) { - return graphs.computeIfAbsent(material, key -> { - Bucket bucket = buckets.get(key); - var builder = MaterialProcessGraph.builder(snapshot); - COVERAGE.forEach(notice -> builder.notice(notice.code(), notice.omitted())); - if (bucket != null) bucket.steps.forEach(builder::add); - return builder.build(); - }); - } - private static MaterialProcessSnapshot empty() { var stamp = MaterialPublication.current(); return new MaterialProcessSnapshot( @@ -169,8 +169,17 @@ static MaterialProcessSnapshot build( MaterialPublication.Stamp publication, long sessionGeneration, MaterialWorldgenFacts.Snapshot worldgenFacts) { + return build(publication, sessionGeneration, worldgenFacts, RecipeMap.RECIPE_MAP_LIST); + } + + static MaterialProcessSnapshot build( + MaterialPublication.Stamp publication, + long sessionGeneration, + MaterialWorldgenFacts.Snapshot worldgenFacts, + Iterable maps) { Objects.requireNonNull(publication); Objects.requireNonNull(worldgenFacts); + long resourceGeneration = RESOURCE_GENERATIONS.incrementAndGet(); var graphSnapshot = new MaterialProcessGraph.Snapshot( publication, sessionGeneration, @@ -180,7 +189,7 @@ static MaterialProcessSnapshot build( var mutable = new LinkedHashMap(); var nativeRecipes = new LinkedHashMap(); var nativeWorldgen = new LinkedHashMap(); - for (RecipeMap map : RecipeMap.RECIPE_MAP_LIST) { + for (RecipeMap map : maps) { var rows = new ArrayList(map.mRecipeList); for (int index = 0; index < rows.size(); index++) { Recipe recipe = rows.get(index); @@ -188,12 +197,15 @@ static MaterialProcessSnapshot build( if (recipe.mFakeRecipe && !hasMaterialUnitInput(recipe)) continue; var built = recipeStep(map, recipe, index, publication.revision(), sessionGeneration); if (built == null) continue; + built = scoped(built, publication.revision(), resourceGeneration); addStep(mutable, built.step, built.materials); nativeRecipes.put(built.step.reference(), new NativeRecipe(map, recipe, index)); } } for (MaterialWorldgenFacts.Fact fact : worldgenFacts.facts()) { var built = worldgenStep(fact, publication.revision(), sessionGeneration); + if (built == null) continue; + built = scoped(built, publication.revision(), resourceGeneration); addStep(mutable, built.step, built.materials); nativeWorldgen.put(built.step.reference(), new NativeWorldgen(fact)); } @@ -212,14 +224,21 @@ private static BuiltStep recipeStep( var inputs = new ArrayList(); var outputs = new ArrayList(); var materials = new LinkedHashSet(); + var auxiliaryInputs = new ArrayList(); + String nativeStep = path(map.mNameInternal) + "/" + index; boolean mainInput = false; for (int input = 0; input < recipe.mInputs.length; input++) { ItemStack stack = recipe.mInputs[input]; if (stack == null || stack.isEmpty()) continue; - Port port = itemPort(stack, recipe, input, false, !mainInput); + if (recipe.isCatalystInput(input)) { + auxiliaryInputs.add("auxiliary catalyst: " + BuiltInRegistries.ITEM.getKey(stack.getItem()) + + itemStateSuffix(stack) + " x" + stack.getCount()); + continue; + } + Port port = itemPort(stack, recipe, input, false, !mainInput, nativeStep); if (port == null) continue; inputs.add(port); - materials.add(port.resource().material()); + addMaterial(materials, port); mainInput |= port.main(); } for (int input = 0; input < recipe.mFluidInputs.length; input++) { @@ -228,17 +247,17 @@ private static BuiltStep recipeStep( Port port = fluidPort(stack, recipe, input, false, !mainInput); if (port == null) continue; inputs.add(port); - materials.add(port.resource().material()); + addMaterial(materials, port); mainInput |= port.main(); } boolean mainOutput = false; for (int output = 0; output < recipe.mOutputs.length; output++) { ItemStack stack = recipe.mOutputs[output]; if (stack == null || stack.isEmpty()) continue; - Port port = itemPort(stack, recipe, output, true, !mainOutput); + Port port = itemPort(stack, recipe, output, true, !mainOutput, nativeStep); if (port == null) continue; outputs.add(port); - materials.add(port.resource().material()); + addMaterial(materials, port); mainOutput |= port.main(); } for (int output = 0; output < recipe.mFluidOutputs.length; output++) { @@ -247,7 +266,7 @@ private static BuiltStep recipeStep( Port port = fluidPort(stack, recipe, output, true, !mainOutput); if (port == null) continue; outputs.add(port); - materials.add(port.resource().material()); + addMaterial(materials, port); mainOutput |= port.main(); } if (materials.isEmpty()) return null; @@ -257,6 +276,7 @@ private static BuiltStep recipeStep( "process/machine/" + mapPath + "/" + index + "/" + Long.toUnsignedString(publication, 36) + "/" + Long.toUnsignedString(session, 36)); var details = new ArrayList(); + details.addAll(auxiliaryInputs); details.add("map: " + map.mNameInternal); details.add("duration: " + recipe.mDuration + " ticks"); details.add("energy: " + recipe.mEUt + " EU/t"); @@ -279,17 +299,17 @@ private static BuiltStep recipeStep( } private static Port itemPort( - ItemStack stack, Recipe recipe, int index, boolean output, boolean mainCandidate) { + ItemStack stack, Recipe recipe, int index, boolean output, boolean mainCandidate, String nativeStep) { String prefix; GTMaterial material; String state; Amount amount; Recipe.MaterialInputDisplay display = recipe.materialInputDisplay(index); - TagKey tag = recipe.itemTag(index); + TagKey tag = output ? null : recipe.itemTag(index); String nativeSuffix = itemStateSuffix(stack); if (!output && display != null) { var representative = material(stack); - if (representative == null) return null; + if (representative == null) return nativeItemPort(stack, recipe, index, output, mainCandidate, nativeStep); material = representative; prefix = "unit"; var alternatives = display.alternatives().stream() @@ -298,15 +318,16 @@ private static Port itemPort( .map(BuiltInRegistries.ITEM::getKey) .distinct() .map(ResourceLocation::toString) - .sorted() .limit(8) + .sorted() .toList(); - state = "unit:" + (tag == null ? "" : "tag=" + tag.location() + "|") - + (alternatives.isEmpty() ? display.rounding().name() : String.join(",", alternatives)); + tag = display.tag() == null ? tag : display.tag(); + state = "unit:" + "rounding=" + display.rounding().name() + "|" + + (tag == null ? "" : "tag=" + tag.location() + "|") + String.join(",", alternatives); amount = new Amount(display.amount(), AmountUnit.MATERIAL_UNIT); } else { var equivalent = MaterialEquivalence.form(stack); - if (equivalent == null) return null; + if (equivalent == null) return nativeItemPort(stack, recipe, index, output, mainCandidate, nativeStep); material = equivalent.material().resolve(); if (!material.isValid()) return null; prefix = equivalent.prefix().getName(); @@ -333,15 +354,16 @@ private static Port itemPort( if (!output && recipe.viewerInputNote(index).length() > 0) details.add(recipe.viewerInputNote(index)); return new Port( - itemResource(material, prefix, state), role, amount, chance, mainCandidate, details); + itemSelector(itemResource(material, prefix, state), recipe, index, output, nativeStep), + role, amount, chance, mainCandidate, details); } private static Port fluidPort( FluidStack stack, Recipe recipe, int index, boolean output, boolean mainCandidate) { RegisteredFluids.FluidEntry entry = GTFluids.entryForFluid(stack.getFluid()); GTMaterial material = entry == null ? null : FluidVisualPolicy.material(entry).resolve(); - if (material == null || !material.isValid()) return null; - TagKey tag = recipe.fluidTag(index); + if (material != null && !material.isValid()) material = null; + TagKey tag = output ? null : recipe.fluidTag(index); String nativeSuffix = fluidStateSuffix(stack); String state = tag == null ? "fluid:" + BuiltInRegistries.FLUID.getKey(stack.getFluid()) + nativeSuffix @@ -357,8 +379,8 @@ private static Port fluidPort( if (tag == null && !nativeSuffix.isEmpty()) details.add("native fluid data is present"); return new Port( new Resource( - resourceKey("fluid", material, "fluid", phase, state), - material.getName(), + material == null ? nativeResourceKey("fluid", state) : resourceKey("fluid", material, "fluid", phase, state), + material == null ? "unknown" : material.getName(), "fluid", phase, state), @@ -374,7 +396,7 @@ private static BuiltStep worldgenStep( var merged = new LinkedHashMap(); var materials = new LinkedHashSet(); for (MaterialWorldgenFacts.Ore ore : fact.ores()) { - Resource resource = itemResource(ore.material(), "ore", ore.itemState()); + Resource resource = worldgenResource(ore); var details = new ArrayList<>(ore.details()); details.add("dimension: " + fact.dimension()); details.add("height: " + ore.minY() + ".." + ore.maxY()); @@ -432,6 +454,84 @@ private static Resource itemResource(GTMaterial material, String prefix, String state); } + private static void addMaterial(Set materials, Port port) { + if (!port.resource().material().equals("unknown")) materials.add(port.resource().material()); + } + + private static Port nativeItemPort( + ItemStack stack, Recipe recipe, int index, boolean output, boolean main, String nativeStep) { + GTMaterial material = material(stack); + String state = "item:" + BuiltInRegistries.ITEM.getKey(stack.getItem()) + itemStateSuffix(stack); + String form = "item"; + if (stack.getItem() instanceof BlockItem block + && block.getBlock() instanceof OreBlock ore) { + material = ore.material().resolve(); + form = ore.isSmall() ? "oreSmall" : "oreVanillastone"; + } + var tag = output ? null : recipe.itemTag(index); + if (tag != null) state = "tag:" + tag.location(); + Resource resource = material == null + ? new Resource( + nativeResourceKey("item", state), + "unknown", "item", "solid", state) + : itemResource(material, form, state); + var details = new ArrayList(); + details.add("native item: " + BuiltInRegistries.ITEM.getKey(stack.getItem())); + details.add("material form is not classified; see the original recipe for matching conditions"); + if (!output && recipe.hasItemInputGuard(index)) details.add("native item-input guard"); + if (!output && recipe.hasSameItemInputPredicate(index)) details.add("native item-state predicate"); + if (!output && !recipe.viewerInputNote(index).isEmpty()) details.add(recipe.viewerInputNote(index)); + return new Port(itemSelector(resource, recipe, index, output, nativeStep), output ? Role.UNKNOWN : Role.CONSUMED, + new Amount(stack.getCount(), AmountUnit.ITEM), + output ? OptionalInt.of(recipe.getOutputChance(index)) : OptionalInt.empty(), main, details); + } + + private static Resource itemSelector(Resource resource, Recipe recipe, int index, boolean output, String nativeStep) { + if (output || recipe.materialInputDisplay(index) == null + && !recipe.hasItemInputGuard(index) && !recipe.hasSameItemInputPredicate(index)) return resource; + var key = new DataKey(resource.key().namespace(), resource.key().path() + "/selector/" + nativeStep + "/" + index); + return new Resource(key, resource.material(), resource.form(), resource.phase(), resource.state()); + } + + private static DataKey nativeResourceKey(String kind, String state) { + return new DataKey("gt6ce", "resource/native/" + kind + "/" + path(state) + "/" + + Integer.toUnsignedString(state.hashCode(), 36)); + } + + private static Resource worldgenResource(MaterialWorldgenFacts.Ore ore) { + String state = ore.itemState(); + if (state.startsWith("item:")) { + ResourceLocation id = ResourceLocation.tryParse(state.substring("item:".length())); + if (id != null) { + var form = MaterialEquivalence.form(new ItemStack(BuiltInRegistries.ITEM.get(id))); + if (form != null && form.material().resolve() == ore.material().resolve()) + return itemResource(ore.material(), form.prefix().getName(), state); + var item = BuiltInRegistries.ITEM.get(id); + if (item instanceof BlockItem block + && block.getBlock() instanceof OreBlock nativeOre + && nativeOre.material().resolve() == ore.material().resolve()) + return itemResource(ore.material(), nativeOre.isSmall() ? "oreSmall" : "oreVanillastone", state); + } + } + return itemResource(ore.material(), "worldgen", state); + } + + private static BuiltStep scoped(BuiltStep built, long publication, long session) { + Step step = built.step; + return new BuiltStep(new Step(step.reference(), step.name(), + step.inputs().stream().map(port -> scoped(port, publication, session)).toList(), + step.outputs().stream().map(port -> scoped(port, publication, session)).toList(), + step.details(), step.resolved()), built.materials); + } + + private static Port scoped(Port port, long publication, long session) { + Resource resource = port.resource(); + var key = new DataKey(resource.key().namespace(), resource.key().path() + "/generation/" + + Long.toUnsignedString(publication, 36) + "/" + Long.toUnsignedString(session, 36)); + return new Port(new Resource(key, resource.material(), resource.form(), resource.phase(), resource.state()), + port.role(), port.amount(), port.chance(), port.main(), port.details()); + } + private static DataKey resourceKey( String kind, GTMaterial material, String form, String phase, String state) { return new DataKey( @@ -486,10 +586,11 @@ private static Root bestRoot(String material, Map resources) { private static int rootRank(String form) { return switch (form) { - case "ore" -> 0; - case "oreRaw" -> 1; + case "ore", "oreVanillastone" -> 0; + case "oreRaw", "oreDense" -> 1; case "crushed" -> 2; case "dust" -> 3; + case "oreSmall" -> 5; case "fluid" -> 6; default -> 4; }; @@ -575,9 +676,15 @@ public static boolean current(MaterialProcessSnapshot snapshot) { public static synchronized MaterialProcessSnapshot publish( MaterialPublication.Stamp publication, long sessionGeneration) { + if (sessionGeneration <= 0 || MachineRecipeOverlay.lastResult().failed()) return current; try { long started = System.nanoTime(); var worldgen = MaterialWorldgenFacts.capture(); + if (current.samePublication(publication) + && current.snapshot.sessionGeneration() == sessionGeneration + && current.snapshot.formRevision() == gregtech.engine.material.MaterialViews.contentRevision() + && current.snapshot.tagGeneration() == ItemMaterialRegistry.compositionState().tagGeneration() + && current.snapshot.worldgenRevision() == worldgen.revision()) return current; MaterialProcessSnapshot built = MaterialProcessSnapshot.build(publication, sessionGeneration, worldgen); previous = current; diff --git a/minecraft/src/main/java/gregtech/content/recipe/OvenRecipeBridge.java b/minecraft/src/main/java/gregtech/content/recipe/OvenRecipeBridge.java index 43bf225a2..80dd68538 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/OvenRecipeBridge.java +++ b/minecraft/src/main/java/gregtech/content/recipe/OvenRecipeBridge.java @@ -173,9 +173,6 @@ && hasPublishedCookingReplacement(firstInput(recipe)) + " (NEVER_FURNACE materials yield scrap instead); {} material rows dropped; {} GT" + " furnace rows added to the vanilla furnace.", mirrored, unsmelted, dropped, fuelled); gregtech.content.recipe.MachineRecipeOverlay.reapplyFurnace(manager); - MaterialProcessSnapshot.Store.publish( - gregtech.content.recipe.MachineRecipeOverlay.lastPublication(), - gregtech.content.recipe.MachineRecipeOverlay.generation()); } /** diff --git a/minecraft/src/main/java/gregtech/content/recipe/RecipePublication.java b/minecraft/src/main/java/gregtech/content/recipe/RecipePublication.java index eccb0871b..a566d743d 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/RecipePublication.java +++ b/minecraft/src/main/java/gregtech/content/recipe/RecipePublication.java @@ -44,7 +44,11 @@ public static void publish(MinecraftServer server) { RecipeManager manager = server.getRecipeManager(); Collection current = manager.getRecipes(); var applied = APPLIED.get(manager); - if (applied != null && applied.size() == current.size() && applied.containsAll(current)) return; + if (applied != null && applied.size() == current.size() && applied.containsAll(current)) { + MaterialProcessSnapshot.Store.publish( + MachineRecipeOverlay.lastPublication(), MachineRecipeOverlay.generation()); + return; + } RegistryAccess access = server.registryAccess(); //? if >=1.21.1 { /*var working = new RecipeManager(access); @@ -57,6 +61,9 @@ public static void publish(MinecraftServer server) { OvenRecipeBridge.apply(working, access); dedup(working, access); manager.replaceRecipes(working.getRecipes()); + if (!MachineRecipeOverlay.lastResult().failed()) + MaterialProcessSnapshot.Store.publish( + MachineRecipeOverlay.lastPublication(), MachineRecipeOverlay.generation()); //? if >=1.21.1 { /*ShapelessRecipeTooltipIndex.rebuild(manager, access); *///?} else { @@ -98,6 +105,7 @@ private static void dedup(RecipeManager manager, RegistryAccess access) { /** Drops the generation snapshot after the server stops; the next world starts fresh. */ public static void clear() { + MaterialProcessSnapshot.Store.clear(MaterialProcessSnapshot.Store.current()); APPLIED.clear(); } } diff --git a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java index a6a49ea29..6a377b065 100644 --- a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java +++ b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java @@ -58,20 +58,39 @@ public static final class Snapshot { private final List facts; private final long revision; - private Snapshot(List facts) { + public Snapshot(List facts) { this.facts = List.copyOf(facts); long hash = 1_125_899_906_842_589L; - for (Fact fact : facts) - hash = 31 * hash - + (((long) (fact.id.hashCode() * 31 - + fact.dimension.hashCode() - + fact.minY - + fact.maxY - + fact.ores.hashCode())) - ^ (hash >>> 32)); + for (Fact fact : facts) { + hash = hash(hash, fact.id()); + hash = hash(hash, fact.name()); + hash = hash(hash, fact.kind().name()); + hash = hash(hash, fact.dimension()); + hash = hash(hash, Integer.toString(fact.minY())); + hash = hash(hash, Integer.toString(fact.maxY())); + hash = hash(hash, Integer.toString(fact.weight())); + hash = hash(hash, Integer.toString(fact.totalWeight())); + hash = hash(hash, Integer.toString(fact.ores().size())); + for (Ore ore : fact.ores()) { + hash = hash(hash, ore.material().resolve().getName()); + hash = hash(hash, ore.itemState()); + hash = hash(hash, Integer.toString(ore.minY())); + hash = hash(hash, Integer.toString(ore.maxY())); + hash = hash(hash, Integer.toString(ore.amount())); + hash = hash(hash, Integer.toString(ore.chanceDivisor())); + hash = hash(hash, Integer.toString(ore.details().size())); + for (String detail : ore.details()) hash = hash(hash, detail); + } + } revision = hash & Long.MAX_VALUE; } + private static long hash(long hash, String value) { + hash = 31 * hash + value.length(); + for (int index = 0; index < value.length(); index++) hash = 31 * hash + value.charAt(index); + return hash; + } + public List facts() { return facts; } @@ -111,6 +130,7 @@ private static void appendLargeVeins(List facts) { addVeinOre(ores, vein.bottom(), minY, maxY, "bottom"); addVeinOre(ores, vein.between(), minY, maxY, "between"); addVeinOre(ores, vein.spread(), minY, maxY, "spread"); + if (ores.isEmpty()) continue; facts.add(new Fact( "large/" + dimension + "/" + vein.name(), vein.name(), @@ -127,14 +147,9 @@ private static void appendLargeVeins(List facts) { private static void addVeinOre(List out, GTMaterial material, int minY, int maxY, String layer) { if (material == null || !material.resolve().isValid()) return; - out.add(new Ore( - material.resolve(), - itemState(oreItem(material.resolve())), - minY, - maxY, - 1, - 0, - List.of("vein layer: " + layer))); + Item item = oreItem(material.resolve()); + if (item == Items.AIR) return; + out.add(new Ore(material.resolve(), itemState(item), minY, maxY, 1, 0, List.of("vein layer: " + layer))); } private static void appendSmallOres(List facts) { @@ -148,6 +163,8 @@ private static void appendSmallOres(List facts) { for (GTOreVeins.SmallOre ore : GTOreVeins.activeSmallOres(dimension)) { GTMaterial material = ore.material().resolve(); if (!material.isValid()) continue; + Item item = smallOreItem(material); + if (item == Items.AIR) continue; int minY = remapped ? GTWorldgenScale.remapY(ore.minY()) : ore.minY(); int maxY = remapped ? GTWorldgenScale.remapY(ore.maxY()) : ore.maxY(); facts.add(new Fact( @@ -160,13 +177,7 @@ private static void appendSmallOres(List facts) { 0, 0, List.of(new Ore( - material, - itemState(smallOreItem(material)), - minY, - maxY, - ore.amount(), - 0, - List.of("blocks per chunk"))))); + material, itemState(item), minY, maxY, ore.amount(), 0, List.of("blocks per chunk"))))); } } } @@ -197,9 +208,11 @@ private static void appendStoneLayers(List facts) { if (layer.noDeep()) min = Math.max(min, GTWorldgenScale.remapY(24)); int max = Math.min(GTWorldgenScale.BAND_TOP - 1, GTWorldgenScale.remapY(definition.maxY())); if (min > max) continue; + Item item = explicitItem(material, rule); + if (item == Items.AIR) continue; ores.add(new Ore( material, - itemState(explicitItem(material, rule)), + itemState(item), min, max, 1, @@ -233,6 +246,8 @@ private static void appendBedrock(List facts, List facts, List=1.21.1 { +/*import net.neoforged.neoforge.fluids.FluidStack; +import net.neoforged.neoforge.gametest.GameTestHolder; +import net.neoforged.neoforge.gametest.PrefixGameTestTemplate; +*///?} else { +import net.minecraftforge.gametest.GameTestHolder; +import net.minecraftforge.gametest.PrefixGameTestTemplate; +import net.minecraftforge.fluids.FluidStack; +//?} + +@GameTestHolder("gt6ce") +@PrefixGameTestTemplate(false) +public final class MaterialProcessSnapshotTests { + private MaterialProcessSnapshotTests() {} + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void nativeProjectionKeepsOutputsAndCrossMaterialRoutes(GameTestHelper helper) { + var first = row(new ItemStack[] {new ItemStack(Items.IRON_NUGGET), new ItemStack(Items.PAPER), + new ItemStack(Items.STICK)}, Items.COPPER_INGOT).withCatalystInputs(2); + var second = row(new ItemStack[] {new ItemStack(Items.COPPER_INGOT)}, Items.GOLD_INGOT); + var third = row(new ItemStack[] {new ItemStack(Items.GOLD_INGOT)}, Items.DIAMOND); + var tagged = new Recipe(new ItemStack[] {new ItemStack(Items.GOLD_INGOT)}, + new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, null, null, + new FluidStack[] {new FluidStack(Fluids.WATER, 1000)}, + new FluidStack[] {new FluidStack(Fluids.LAVA, 1000)}, 20, 16, 0) + .withItemTagInput(0, ResourceLocation.fromNamespaceAndPath("c", "ingots/gold")) + .withFluidTagInput(0, ResourceLocation.fromNamespaceAndPath("c", "water")); + var map = new RecipeMap(new ArrayList<>(List.of(first, second, third, tagged)), + "gt.test.process.snapshot", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, + false, false, false, false); + RecipeMap.unregister(map); + var ores = List.of(new Ore(Materials.Iron, "item:minecraft:iron_nugget", 0, 20, 1, 0, List.of())); + var facts = new MaterialWorldgenFacts.Snapshot(List.of( + new Fact("test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 1, ores))); + var snapshot = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, facts, List.of(map)); + var root = snapshot.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); + var query = snapshot.query(root.resource(), Direction.BOTH, Budgets.DEFAULT); + helper.assertTrue(query.steps().size() == 4, "route traverses other materials and the native worldgen form"); + var firstStep = query.steps().stream().filter(step -> snapshot.recipe(step.reference()) + .map(nativeRow -> nativeRow.recipe() == first).orElse(false)).findFirst().orElseThrow(); + helper.assertTrue(firstStep.inputs().size() == 2, "ordinary co-input survives; auxiliary tool stays in details"); + helper.assertTrue(firstStep.inputs().stream().anyMatch(port -> port.resource().state().equals("item:minecraft:paper")), + "unclassified ordinary input keeps its native identity"); + helper.assertTrue(firstStep.details().stream().anyMatch(detail -> detail.contains("minecraft:stick")), + "auxiliary catalyst is available in recipe details"); + var taggedStep = snapshot.roots().stream() + .flatMap(value -> snapshot.query(value.resource(), Direction.BOTH, Budgets.DEFAULT).steps().stream()) + .filter(step -> snapshot.recipe(step.reference()) + .map(nativeRow -> nativeRow.recipe() == tagged).orElse(false)).findFirst().orElseThrow(); + helper.assertTrue(taggedStep.outputs().get(0).resource().state().equals("item:minecraft:iron_ingot"), + "input tag never changes the output identity"); + helper.assertTrue(taggedStep.outputs().stream().anyMatch(port -> port.resource().state().equals("fluid:minecraft:lava")), + "fluid input tag never changes the fluid output identity"); + var replacement = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, facts, List.of(map)); + helper.assertTrue(replacement.query(root.resource(), Direction.BOTH, Budgets.DEFAULT).steps().isEmpty(), + "resource references cannot cross snapshots even with the same stamp"); + helper.assertTrue(snapshot.query(root.resource(), Direction.BOTH, Budgets.DEFAULT).equals(query), + "old query remains self-consistent"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void worldgenRevisionIncludesSelectionAndKind(GameTestHelper helper) { + var ores = List.of(new Ore(Materials.Iron, "item:minecraft:iron_nugget", 0, 20, 1, 0, List.of())); + var baseline = new Fact("test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 10, ores); + long revision = new MaterialWorldgenFacts.Snapshot(List.of(baseline)).revision(); + for (Fact changed : List.of( + new Fact("test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 2, 10, ores), + new Fact("test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 20, ores), + new Fact("test", "test", Kind.BEDROCK, "minecraft:overworld", 0, 20, 1, 10, ores), + new Fact("test", "renamed", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 10, ores))) { + helper.assertTrue(new MaterialWorldgenFacts.Snapshot(List.of(changed)).revision() != revision, + "each changed worldgen field changes the revision"); + } + var activeFacts = MaterialWorldgenFacts.capture(); + helper.assertFalse(activeFacts.facts().isEmpty(), "active worldgen facts are projected"); + helper.assertFalse(activeFacts.facts().stream().flatMap(fact -> fact.ores().stream()) + .anyMatch(ore -> ore.itemState().equals("item:minecraft:stone") + || ore.itemState().equals("item:minecraft:air")), + "missing ore registrations never turn into stone or air sources"); + var current = MaterialProcessSnapshot.Store.publish(MachineRecipeOverlay.lastPublication(), + MachineRecipeOverlay.generation()); + helper.assertTrue(current.samePublication(MachineRecipeOverlay.lastPublication()), + "snapshot follows the last successful publication"); + helper.assertTrue(MaterialProcessSnapshot.Store.publish(MachineRecipeOverlay.lastPublication(), + MachineRecipeOverlay.generation()) == current, "unchanged publication reuses its index"); + helper.succeed(); + } + + private static Recipe row(ItemStack[] inputs, net.minecraft.world.item.Item output) { + return new Recipe(inputs, new ItemStack[] {new ItemStack(output)}, null, null, null, null, 20, 16, 0); + } +} From b2784d818f260f4f7cf955ea4bb4e52c6cc8768e Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Sat, 14 Nov 2026 15:00:34 +0800 Subject: [PATCH 05/17] optimize GUI --- AGENTS.md | 2 +- api/common/build.gradle | 2 +- .../gregtech/api/addon/GregTechAddons.java | 4 +- .../addon/material/MaterialCatalogView.java | 4 + .../api/addon/material/MaterialInfoTool.java | 5 + .../addon/material/SpecialProcessMethod.java | 34 ++ .../addon/material/SpecialProcessValue.java | 72 +++ .../addon/material/SpecialProcessesView.java | 25 + .../api/addon/material/package-info.java | 2 +- .../api/addon/GregTechAddonsTest.java | 6 +- .../material/SpecialProcessValueTest.java | 72 +++ .../api/contracts/MaterialViewContracts.java | 15 +- core/AGENTS.md | 2 +- .../content/material/MaterialDefinitions.java | 1 + .../recipe/SourcePurifiedAcidRules.java | 218 ------- ...dAcidData.java => SpecialProcessData.java} | 105 +--- .../recipe/SpecialProcessMaterialFacts.java | 240 ++++++++ .../content/recipe/SpecialProcessMethods.java | 45 ++ .../engine/material/GTMaterialRegistry.java | 2 +- .../engine/material/MaterialInfoRegistry.java | 62 ++ .../engine/material/MaterialProcessGraph.java | 109 ++++ .../engine/material/MaterialViews.java | 32 ++ .../resources/assets/gt6ce/lang/en_us.json | 25 +- .../resources/assets/gt6ce/lang/zh_cn.json | 25 +- .../content/material/MaterialCatalogTest.java | 30 +- .../material/MaterialProcessGraphTest.java | 46 +- docs/ADDON_API.zh-CN.md | 31 +- docs/architecture/packages/api.md | 2 +- docs/architecture/packages/runtime.md | 4 +- docs/decisions/0001-material-data-api.md | 13 +- docs/development/README.md | 3 +- docs/development/material-process-display.md | 91 +-- docs/development/material-process-layout.md | 158 ++++++ .../07-cleanup-and-acceptance.md | 2 +- .../07-recipe-package-audit.md | 6 +- .../08-material-data-api.md | 10 +- .../material-system-refactor/README.md | 2 +- .../validation/checks/manual-ingame.md | 17 +- docs/integration/material-process-snapshot.md | 14 +- minecraft/AGENTS.md | 2 +- .../client/MaterialProcessArrows.java | 24 + .../gregtech/client/MaterialProcessPanel.java | 491 +++++++++------- .../compat/common/MaterialProcessDisplay.java | 178 +++++- .../common/MaterialProcessOverview.java | 537 ++++++++++++++++++ .../common/MaterialProcessProjection.java | 147 ++++- .../compat/common/RecipeViewerIcons.java | 17 + .../compat/emi/EmiInteractiveWidget.java | 4 + .../gregtech/compat/emi/EmiWidgetInput.java | 12 + .../compat/emi/GregTechEMIPlugin.java | 32 +- .../compat/emi/MaterialProcessEmiRecipe.java | 116 ++-- .../compat/emi/MaterialProcessEmiStacks.java | 21 + .../compat/jei/GregTechJEIPlugin.java | 29 +- .../compat/jei/MaterialProcessCategory.java | 52 +- .../content/data/MaterialTagPack.java | 47 ++ .../recipe/ExternalOreRecipeLifecycle.java | 2 +- .../content/recipe/MachineRecipeOverlay.java | 7 +- .../recipe/MaterialProcessSnapshot.java | 27 +- .../recipe/OreProcessingRecipeLoader.java | 2 +- .../recipe/SharedPurifiedAcidRows.java | 252 -------- .../recipe/SharedSpecialProcessRows.java | 340 +++++++++++ .../recipe/generated/GTOreRecipes.java | 2 +- .../java/gregtech/engine/recipe/Recipe.java | 11 + .../recipe/MaterialProcessSnapshotTests.java | 312 ++++++++++ 63 files changed, 3144 insertions(+), 1058 deletions(-) create mode 100644 api/common/src/main/java/gregtech/api/addon/material/SpecialProcessMethod.java create mode 100644 api/common/src/main/java/gregtech/api/addon/material/SpecialProcessValue.java create mode 100644 api/common/src/main/java/gregtech/api/addon/material/SpecialProcessesView.java create mode 100644 api/common/src/test/java/gregtech/api/addon/material/SpecialProcessValueTest.java delete mode 100644 core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidRules.java rename core/src/main/java/gregtech/content/recipe/{SourcePurifiedAcidData.java => SpecialProcessData.java} (63%) create mode 100644 core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java create mode 100644 core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java create mode 100644 docs/development/material-process-layout.md create mode 100644 minecraft/src/main/java/gregtech/client/MaterialProcessArrows.java create mode 100644 minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java create mode 100644 minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiStacks.java delete mode 100644 minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedAcidRows.java create mode 100644 minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java diff --git a/AGENTS.md b/AGENTS.md index f4d82f955..48a14ebf0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,7 +13,7 @@ ## 项目事实 - GT6CE 是现代 Minecraft 的 GregTech 6 移植工程。模组 ID 与命名以现有 `GregTechIdentity` 和加载器元数据为准,不要顺手改名。 -- `api/`:内联自 GregTech6API 的源码(锁定 a9c879176,基线 API 1.2.0;当前 API 1.8.0);`common/` 提供 Java 17 公共契约,`minecraft/` 提供按版本编译的游戏 API。修改公共签名时直接在本仓库 `api/` 内更新,并在提交信息中记录 API 版本变化。 +- `api/`:内联自 GregTech6API 的源码(锁定 a9c879176,基线 API 1.2.0;当前 API 1.9.0);`common/` 提供 Java 17 公共契约,`minecraft/` 提供按版本编译的游戏 API。修改公共签名时直接在本仓库 `api/` 内更新,并在提交信息中记录 API 版本变化。 - `core/`:Java 17 的平台无关内容定义、计算和共享资源,依赖公共 API;不得引入 Minecraft、Forge、NeoForge、客户端或可选模组类型。 - `minecraft/src/`:两版本共享的 Minecraft 代码与 Stonecutter 输入。 - `minecraft/versions/1.20.1-forge/src/`:Forge 版本源码及资源,Java 17。 diff --git a/api/common/build.gradle b/api/common/build.gradle index 5e4e3829a..c75f8b51b 100644 --- a/api/common/build.gradle +++ b/api/common/build.gradle @@ -20,7 +20,7 @@ tasks.named('test') { } group = 'gregtech' -version = '1.8.0' +version = '1.9.0' base { archivesName = 'gt6ce-api' } java { diff --git a/api/common/src/main/java/gregtech/api/addon/GregTechAddons.java b/api/common/src/main/java/gregtech/api/addon/GregTechAddons.java index fc432cce3..06869bd91 100644 --- a/api/common/src/main/java/gregtech/api/addon/GregTechAddons.java +++ b/api/common/src/main/java/gregtech/api/addon/GregTechAddons.java @@ -14,11 +14,11 @@ */ public final class GregTechAddons { private static final int API_MAJOR = 1; - private static final int API_MINOR = 8; + private static final int API_MINOR = 9; /** * Monotonic version code of the independent API artifact: {@code major * 1000 + minor}. - * The current 1.8 release reports 1008. Development builds still need a matching SDK and host + * The current 1.9 release reports 1009. Development builds still need a matching SDK and host * runtime; this number alone does not check the installed mod or Minecraft version. * *

Not a compile-time constant. A {@code static final} primitive set to a literal is copied into diff --git a/api/common/src/main/java/gregtech/api/addon/material/MaterialCatalogView.java b/api/common/src/main/java/gregtech/api/addon/material/MaterialCatalogView.java index d7745f0f8..f97d2e15e 100644 --- a/api/common/src/main/java/gregtech/api/addon/material/MaterialCatalogView.java +++ b/api/common/src/main/java/gregtech/api/addon/material/MaterialCatalogView.java @@ -27,4 +27,8 @@ default MaterialFormsView formBindings() { default MaterialProcessesView processes() { throw new UnsupportedOperationException("This material catalog does not expose process views"); } + /** Immutable special-process method declarations captured with this definition view. */ + default SpecialProcessesView specialProcesses() { + throw new UnsupportedOperationException("This material catalog does not expose special processes"); + } } diff --git a/api/common/src/main/java/gregtech/api/addon/material/MaterialInfoTool.java b/api/common/src/main/java/gregtech/api/addon/material/MaterialInfoTool.java index 15ec22cbb..45dd1caab 100644 --- a/api/common/src/main/java/gregtech/api/addon/material/MaterialInfoTool.java +++ b/api/common/src/main/java/gregtech/api/addon/material/MaterialInfoTool.java @@ -171,6 +171,11 @@ public interface Registrar { Registrar registerGroup(MaterialGroupDeclaration declaration); + /** Declares one special process method; target and reagent rules use its typed process key. */ + default Registrar registerSpecialProcess(SpecialProcessMethod method) { + throw new UnsupportedOperationException("This material info host does not expose special processes"); + } + /** * Registers a typed process rule. The rule value must be treated as immutable after this call. */ diff --git a/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessMethod.java b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessMethod.java new file mode 100644 index 000000000..46fe1caca --- /dev/null +++ b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessMethod.java @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ + +package gregtech.api.addon.material; + +import java.util.Objects; + +/** + * One special process method. Target and reagent materials attach {@link SpecialProcessValue} + * rules through the same {@link MaterialProcessKey}. + */ +public record SpecialProcessMethod( + MaterialProcessKey process, + String recipeMap, + String displayNameKey) { + public SpecialProcessMethod { + Objects.requireNonNull(process, "process"); + if (process.type() != SpecialProcessValue.class) + throw new IllegalArgumentException("Special process method has the wrong process value type"); + if (recipeMap == null || recipeMap.isBlank()) + throw new IllegalArgumentException("Special process method has no recipe map"); + if (displayNameKey == null || displayNameKey.isBlank()) + throw new IllegalArgumentException("Special process method has no display name key"); + } + + /** Material classification tag assigned to every processable material. */ + public DataKey targetTag() { + return new DataKey(process.id().namespace(), process.id().path() + "/target"); + } + + /** Material classification tag assigned to every processing reagent. */ + public DataKey reagentTag() { + return new DataKey(process.id().namespace(), process.id().path() + "/reagent"); + } +} diff --git a/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessValue.java b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessValue.java new file mode 100644 index 000000000..ede56dd3c --- /dev/null +++ b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessValue.java @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ + +package gregtech.api.addon.material; + +import java.util.List; +import java.util.Objects; + +/** + * A target or reagent rule for one declared special process method. Values are caller-owned and + * must be treated as immutable after registration. + */ +public sealed interface SpecialProcessValue permits SpecialProcessValue.Target, SpecialProcessValue.Reagent { + /** + * One processable material's recipe plan. The process rule's form set names accepted inputs; + * {@link #inputCounts()} supplies the exact item count for every accepted form. + */ + record Target( + java.util.Map inputCounts, + List itemOutputs, + List fluidOutputs, + long reagentAmount, + long duration, + long euPerTick) + implements SpecialProcessValue { + public Target { + inputCounts = java.util.Map.copyOf(inputCounts); + if (inputCounts.isEmpty()) throw new IllegalArgumentException("Special process target has no input form"); + for (var entry : inputCounts.entrySet()) { + Objects.requireNonNull(entry.getKey(), "input form"); + if (entry.getValue() == null || entry.getValue() < 1) + throw new IllegalArgumentException("Invalid special process input count"); + } + itemOutputs = List.copyOf(itemOutputs); + fluidOutputs = List.copyOf(fluidOutputs); + if (itemOutputs.isEmpty() && fluidOutputs.isEmpty()) + throw new IllegalArgumentException("Special process target has no output"); + if (reagentAmount < 1 || duration < 1 || euPerTick < 0) + throw new IllegalArgumentException("Invalid special process target quantities"); + } + } + + /** Marks one reagent material and its accepted forms through the enclosing process rule. */ + record Reagent() implements SpecialProcessValue {} + + /** One output material and ordered form alternatives. The first available form wins. */ + record ItemOutput(MaterialKey material, List forms, int chance) { + public ItemOutput { + Objects.requireNonNull(material, "output material"); + forms = List.copyOf(forms); + if (forms.isEmpty()) throw new IllegalArgumentException("Item output has no form"); + if (chance < 1 || chance > 10_000) throw new IllegalArgumentException("Invalid output chance"); + } + } + + /** One certain fluid output and ordered phase/form alternatives. */ + record FluidOutput(MaterialKey material, List forms, int millibuckets) { + public FluidOutput { + Objects.requireNonNull(material, "output material"); + forms = List.copyOf(forms); + if (forms.isEmpty() || millibuckets < 1) + throw new IllegalArgumentException("Invalid fluid output"); + } + } + + /** A form and the concrete item count or millibucket amount emitted in that form. */ + record FormCount(FormKey form, int count) { + public FormCount { + Objects.requireNonNull(form, "form"); + if (count < 1) throw new IllegalArgumentException("Form count must be positive"); + } + } +} diff --git a/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessesView.java b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessesView.java new file mode 100644 index 000000000..d4754d418 --- /dev/null +++ b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessesView.java @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ + +package gregtech.api.addon.material; + +import java.util.List; +import java.util.Optional; + +/** Immutable special-process method declarations from the current material publication. */ +public interface SpecialProcessesView { + SpecialProcessesView NONE = new SpecialProcessesView() { + @Override + public List methods() { + return List.of(); + } + + @Override + public Optional find(DataKey id) { + return Optional.empty(); + } + }; + + List methods(); + + Optional find(DataKey id); +} diff --git a/api/common/src/main/java/gregtech/api/addon/material/package-info.java b/api/common/src/main/java/gregtech/api/addon/material/package-info.java index 10bf43484..7a9cfb1d5 100644 --- a/api/common/src/main/java/gregtech/api/addon/material/package-info.java +++ b/api/common/src/main/java/gregtech/api/addon/material/package-info.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-3.0-or-later */ -/** Addon material, prefix, composition, metadata, tag, group and process declarations. */ +/** Addon material, prefix, composition, metadata, tag, group, process and special-process declarations. */ @NullMarked package gregtech.api.addon.material; diff --git a/api/common/src/test/java/gregtech/api/addon/GregTechAddonsTest.java b/api/common/src/test/java/gregtech/api/addon/GregTechAddonsTest.java index 4a7cac89f..f7872734a 100644 --- a/api/common/src/test/java/gregtech/api/addon/GregTechAddonsTest.java +++ b/api/common/src/test/java/gregtech/api/addon/GregTechAddonsTest.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.function.Consumer; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; class GregTechAddonsTest { private static final GregTechAddon.Context CONTEXT = new GregTechAddon.Context("forge", "1.20.1"); @@ -23,8 +23,8 @@ void reset() { void apiVersionCodeMatchesTheMajorAndMinorParts() { assertEquals(GregTechAddons.apiMajor() * 1000 + GregTechAddons.apiMinor(), GregTechAddons.apiVersion()); assertEquals(1, GregTechAddons.apiMajor()); - assertEquals(8, GregTechAddons.apiMinor()); - assertEquals(1008, GregTechAddons.apiVersion()); + assertEquals(9, GregTechAddons.apiMinor()); + assertEquals(1009, GregTechAddons.apiVersion()); } @Test diff --git a/api/common/src/test/java/gregtech/api/addon/material/SpecialProcessValueTest.java b/api/common/src/test/java/gregtech/api/addon/material/SpecialProcessValueTest.java new file mode 100644 index 000000000..fa76227b9 --- /dev/null +++ b/api/common/src/test/java/gregtech/api/addon/material/SpecialProcessValueTest.java @@ -0,0 +1,72 @@ +package gregtech.api.addon.material; + +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class SpecialProcessValueTest { + @Test + void methodDerivesStableMaterialTags() { + var method = new SpecialProcessMethod( + MaterialProcessKey.multiple( + new DataKey("example", "special_process/wash"), SpecialProcessValue.class), + "gt.recipe.bath", + "example.special_process.wash"); + + assertEquals(new DataKey("example", "special_process/wash/target"), method.targetTag()); + assertEquals(new DataKey("example", "special_process/wash/reagent"), method.reagentTag()); + } + + @Test + void targetRejectsIncompleteRecipePlans() { + var output = new SpecialProcessValue.ItemOutput( + new MaterialKey("Iron"), + List.of(new SpecialProcessValue.FormCount(new FormKey("dust"), 1)), + 10_000); + + assertThrows( + IllegalArgumentException.class, + () -> new SpecialProcessValue.Target( + Map.of(), List.of(output), List.of(), 1, 1, 0)); + assertThrows( + IllegalArgumentException.class, + () -> new SpecialProcessValue.Target( + Map.of(new FormKey("dust"), 1), List.of(), List.of(), 1, 1, 0)); + } + + @Test + void unsupportedCatalogFailsExplicitly() { + MaterialCatalogView catalog = new MaterialCatalogView() { + @Override + public long revision() { + return 0; + } + + @Override + public Optional resolve(String name) { + return Optional.empty(); + } + + @Override + public MaterialTagsView tags() { + throw new UnsupportedOperationException(); + } + + @Override + public Optional find(MaterialKey key) { + return Optional.empty(); + } + + @Override + public List materials() { + return List.of(); + } + }; + + assertThrows(UnsupportedOperationException.class, catalog::specialProcesses); + } +} diff --git a/api/common/src/test/java/gregtech/api/contracts/MaterialViewContracts.java b/api/common/src/test/java/gregtech/api/contracts/MaterialViewContracts.java index b64a0fba8..5049cb645 100644 --- a/api/common/src/test/java/gregtech/api/contracts/MaterialViewContracts.java +++ b/api/common/src/test/java/gregtech/api/contracts/MaterialViewContracts.java @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-3.0-or-later */ package gregtech.api.contracts; -import gregtech.api.addon.material.*; import java.util.List; /** Only the delivered API JAR participates in this consumer. */ @@ -41,6 +40,20 @@ public List> processes() { || contributor.materialGroups().size() != 1 || contributor.processes().size() != 1) throw new AssertionError("tag, group and process SPI"); + var specialKey = MaterialProcessKey.multiple( + new DataKey("consumer", "special_process/wash"), SpecialProcessValue.class); + var method = new SpecialProcessMethod(specialKey, "gt.recipe.bath", "consumer.special.wash"); + var target = new SpecialProcessValue.Target( + java.util.Map.of(new FormKey("dust"), 1), + List.of(new SpecialProcessValue.ItemOutput( + key, List.of(new SpecialProcessValue.FormCount(new FormKey("dust"), 1)), 10_000)), + List.of(), + 1, + 1, + 0); + if (!method.targetTag().equals(new DataKey("consumer", "special_process/wash/target")) + || !(target.itemOutputs().get(0).material().equals(key))) + throw new AssertionError("special process contract"); try { GregTechMaterials.catalog(); throw new AssertionError("unbound host must fail"); } catch (IllegalStateException expected) { } } diff --git a/core/AGENTS.md b/core/AGENTS.md index 7e87d0e5d..669f77fca 100644 --- a/core/AGENTS.md +++ b/core/AGENTS.md @@ -2,7 +2,7 @@ 先遵守[根指南](../AGENTS.md),再读[架构边界](../docs/architecture/README.md)。这里使用 Java 17,独立于游戏和加载器。 -- `gregtech.api` 由仓库内 `api/common/` 提供(内联自 GregTech6API a9c879176,基线 API 1.2.0;当前 API 1.8.0),core 通过 `:api` 使用;不要在 core 中重新建立同包副本,参见 [API 指南](../docs/architecture/packages/api.md)。 +- `gregtech.api` 由仓库内 `api/common/` 提供(内联自 GregTech6API a9c879176,基线 API 1.2.0;当前 API 1.9.0),core 通过 `:api` 使用;不要在 core 中重新建立同包副本,参见 [API 指南](../docs/architecture/packages/api.md)。 - `gregtech.content`:材料、配方、布局、参数和内容目录,表达“有什么”,参见 [content 指南](../docs/architecture/packages/content.md)。 - `gregtech.engine`:计算、状态、解析、查询和执行机制,表达“怎么工作”,参见 [engine 指南](../docs/architecture/packages/engine.md)。 - `gregtech.bootstrap`:共享初始化步骤契约;加载器装配属于 Minecraft 层。 diff --git a/core/src/main/java/gregtech/content/material/MaterialDefinitions.java b/core/src/main/java/gregtech/content/material/MaterialDefinitions.java index eb0da9fcd..3bb5cb948 100644 --- a/core/src/main/java/gregtech/content/material/MaterialDefinitions.java +++ b/core/src/main/java/gregtech/content/material/MaterialDefinitions.java @@ -38,6 +38,7 @@ private static List collect() { result.replaceAll(SourceRecyclingMaterialFacts::apply); result.replaceAll(SourceOreCrushingMaterialFacts::apply); result.replaceAll(PurifiedCentrifugeMaterialFacts::apply); + result.replaceAll(gregtech.content.recipe.SpecialProcessMaterialFacts::apply); result.replaceAll(MaterialDefinitions::attachDecomposition); DecompositionMaterials.validateConsumed(result); result.sort(Comparator.comparing(MaterialDefinition.Declaration::name)); diff --git a/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidRules.java b/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidRules.java deleted file mode 100644 index 93fe42c5a..000000000 --- a/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidRules.java +++ /dev/null @@ -1,218 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.content.data.MaterialPrefix; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import static gregtech.content.material.MaterialFactKeys.Decision; -import static gregtech.content.material.MaterialFactKeys.Identity; -import static gregtech.content.recipe.SourceOreWashingRules.Availability; -import static gregtech.content.recipe.SourcePurifiedAcidData.*; - -/** - * Purified-acid Bath algorithms from GT6 3703e40308c8c030763fd6297dea8b210d2a77b1, - * Loader_Recipes_Ores 108-159. Native identity/phase proof and registration are separate. - * No ordinary washing eligibility, target conversion or purified/refined dust fallback applies. - * Missing outputs retain source positions (Recipe 895); unknown context is not source absence. - */ -public final class SourcePurifiedAcidRules { - private SourcePurifiedAcidRules() {} - - public enum Shape { - WHOLE(MaterialPrefix.crushedPurified, 1), - TINY(MaterialPrefix.crushedPurifiedTiny, 9); - private final MaterialPrefix prefix; - private final int count; - - Shape(MaterialPrefix prefix, int count) { - this.prefix = prefix; - this.count = count; - } - - public MaterialPrefix prefix() { - return prefix; - } - - public int count() { - return count; - } - } - - public enum Status { - ROW, - NO_ROW, - UNSUPPORTED - } - - public record Item(MaterialPrefix prefix, Identity material, int count) {} - /** Null item preserves a known absent source output at its original chance position. */ - public record Slot(Item item, long chance) {} - - public record Candidate(Family family, Identity material, Shape shape) {} - - public record Result( - Status status, - Item input, - List outputs, - List fluidInputs, - List fluidOutputs, - String reason) { - public Result { - outputs = List.copyOf(outputs); - fluidInputs = List.copyOf(fluidInputs); - fluidOutputs = List.copyOf(fluidOutputs); - } - - public int ticks() { - return 256; - } - - public int power() { - return 0; - } - - public boolean optimize() { - return true; - } - } - - public interface Resolver { - /** Exact direct form and quantity, without purified/refined fallback or target conversion. */ - Availability item(MaterialPrefix prefix, Identity material, int count); - /** Source absence differs from unavailable native binding: these 17 source phases exist, - * so an unproved/replaced/missing native holder must be UNKNOWN, not silently discarded. */ - Availability fluid(Phase phase, long millibuckets); - } - /** Exact source order: family, literal member order, whole then tiny. Dynamic array follows. */ - public static List fixedCandidates() { - var result = new ArrayList(); - for (var family : families()) - for (var member : family.members()) - for (var shape : Shape.values()) result.add(new Candidate(family, member, shape)); - return List.copyOf(result); - } - - public static Decision fixedMembership(Family family, Identity material) { - if (family == null || !families().contains(family) || !reviewedIdentity(material)) return Decision.UNKNOWN; - return family.members().contains(material) ? Decision.YES : Decision.NO; - } - /** Direct list only: no identity/self shortcut, chemical decomposition or nested byproducts. - * Null/unresolved list entries cannot prove absence. Native provenance is still external. */ - public static Decision directManganeseMembership(List directByproducts) { - if (directByproducts == null) return Decision.UNKNOWN; - if (directByproducts.contains(MNO2)) return Decision.YES; - return directByproducts.stream().anyMatch(Objects::isNull) ? Decision.UNKNOWN : Decision.NO; - } - /** Only the dynamic loop uses this gate. A positive-default list is not permission evidence; - * a proven live core input newly acquiring direct MnO2 membership remains eligible. */ - public static Decision manganeseSelector(boolean validMaterial, boolean antimatter, Decision directContainsMno2) { - if (!validMaterial || antimatter) return Decision.NO; - return directContainsMno2 == null ? Decision.UNKNOWN : directContainsMno2; - } - - public static Result fixedPlan(Family family, Identity material, Shape shape, Resolver resolver) { - Decision member = fixedMembership(family, material); - if (member != Decision.YES) - return empty(member == Decision.NO ? Status.NO_ROW : Status.UNSUPPORTED, "fixed source membership"); - if (shape == null || resolver == null) return empty(Status.UNSUPPORTED, "missing shape/resolver"); - Identity tail = switch (family.tail()) { - case SELF -> material; - case PLATINUM_GROUP_SLUDGE -> PGS; - case GRAPHITE -> GRAPHITE; - }; - int count = family.tail() == Tail.PLATINUM_GROUP_SLUDGE ? 8 : 2; - var slots = new ArrayList(); - slots.add(new Slot(new Item(MaterialPrefix.crushedCentrifuged, material, 1), 10000)); - for (int i = 0; i < 5; i++) - slots.add(new Slot(new Item(MaterialPrefix.crushedCentrifugedTiny, tail, count), 5000)); - return resolve( - new Item(shape.prefix(), material, shape.count()), - slots, - family.fluidInput(), - family.fluidOutputs(), - resolver, - false); - } - - public static Result manganesePlan(Identity material, Shape shape, Decision sourceSelector, Resolver resolver) { - if (sourceSelector != Decision.YES) - return empty(sourceSelector == Decision.NO ? Status.NO_ROW : Status.UNSUPPORTED, "dynamic source selector"); - if (material == null || shape == null || resolver == null) - return empty(Status.UNSUPPORTED, "missing dynamic context"); - // OM.dust(MnCl2, 3U/2) is resolved below, not substituted with a fixed generated dust row. - var slots = List.of( - new Slot(new Item(MaterialPrefix.crushedCentrifuged, material, 1), 10000), new Slot(null, 10000)); - return resolve( - new Item(shape.prefix(), material, shape.count()), - slots, - new Fluid(Phase.HYDROCHLORICACID, 4000), - List.of(new Fluid(Phase.WATER, 3000), new Fluid(Phase.CHLORINE, 1000)), - resolver, - true); - } - - private static Result resolve( - Item input, - List desired, - Fluid fluidInput, - List desiredFluids, - Resolver resolver, - boolean manganese) { - Availability itemInput = Objects.requireNonNull(resolver.item(input.prefix(), input.material(), input.count())); - if (itemInput != Availability.PRESENT) - return empty( - itemInput == Availability.ABSENT ? Status.NO_ROW : Status.UNSUPPORTED, - "selected input shape unavailable"); - Availability acid = Objects.requireNonNull(resolver.fluid(fluidInput.phase(), fluidInput.millibuckets())); - if (acid != Availability.PRESENT) - return empty(acid == Availability.ABSENT ? Status.NO_ROW : Status.UNSUPPORTED, "input acid unavailable"); - var slots = new ArrayList(); - for (var desiredSlot : desired) { - Item item = desiredSlot.item(); - if (item == null) { - slots.add(desiredSlot); - continue; - } - Availability found = Objects.requireNonNull(resolver.item(item.prefix(), item.material(), item.count())); - if (found == Availability.UNKNOWN) return empty(Status.UNSUPPORTED, "unknown direct output form"); - slots.add(new Slot(found == Availability.PRESENT ? item : null, desiredSlot.chance())); - } - if (manganese) { - Choice dust = manganeseDust(resolver); - if (dust.availability() == Availability.UNKNOWN) - return empty(Status.UNSUPPORTED, "unknown MnCl2 dust form"); - slots.set(1, new Slot(dust.item(), 10000)); - } - var fluidOutputs = new ArrayList(); - for (var fluid : desiredFluids) { - Availability found = Objects.requireNonNull(resolver.fluid(fluid.phase(), fluid.millibuckets())); - if (found == Availability.UNKNOWN) return empty(Status.UNSUPPORTED, "unknown output phase binding"); - if (found == Availability.PRESENT) fluidOutputs.add(fluid); // source removes all null fluids - } - if (slots.stream().noneMatch(s -> s.item() != null) && fluidOutputs.isEmpty()) - return empty(Status.NO_ROW, "Bath needs at least one output"); - return new Result(Status.ROW, input, slots, List.of(fluidInput), fluidOutputs, "source purified-acid row"); - } - - private record Choice(Availability availability, Item item) {} - - private static Choice manganeseDust(Resolver resolver) { - // OM 460-466: 1.5U is below 72U and not whole-divisible. Prefer small6, then floor - // to tiny13; the final 108 div72 stack is source bindStack-clamped to 64. - for (var item : List.of( - new Item(MaterialPrefix.dustSmall, MNCL2, 6), - new Item(MaterialPrefix.dustTiny, MNCL2, 13), - new Item(MaterialPrefix.dustDiv72, MNCL2, 64))) { - Availability found = Objects.requireNonNull(resolver.item(item.prefix(), item.material(), item.count())); - if (found == Availability.UNKNOWN) return new Choice(found, null); - if (found == Availability.PRESENT) return new Choice(found, item); - } - return new Choice(Availability.ABSENT, null); - } - - private static Result empty(Status status, String reason) { - return new Result(status, null, List.of(), List.of(), List.of(), reason); - } -} diff --git a/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java similarity index 63% rename from core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java rename to core/src/main/java/gregtech/content/recipe/SpecialProcessData.java index 1cda035e0..9a0635e13 100644 --- a/core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java @@ -11,8 +11,8 @@ * Phase evidence: MT 1007/1020-1028/1047/1164/1169-1177/1188, * OreDictMaterial 313/1285/1294-1303, Loader_Fluids 657-662 and FL 1071-1080/1121-1125. */ -public final class SourcePurifiedAcidData { - private SourcePurifiedAcidData() {} +public final class SpecialProcessData { + private SpecialProcessData() {} public enum State { LIQUID, @@ -69,13 +69,6 @@ public record Family( fluidOutputs = List.copyOf(fluidOutputs); } } - /** Audited default regression observations ONLY, not a live selector permission whitelist. */ - public record ManganeseDefault(Identity material, List byproducts, int sourceLine) { - public ManganeseDefault { - byproducts = List.copyOf(byproducts); - } - } - public static final Identity MNO2 = id(9126, "Pyrolusite"), MNCL2 = id(8031, "ManganeseChloride"), PGS = id(8103, "PlatinumGroupSludge"), @@ -204,104 +197,10 @@ public record ManganeseDefault(Identity material, List byproducts, int f(Phase.HYDROGENFLUORIDE, 500), List.of(), Tail.GRAPHITE)); - // MT .ores declarations supply these complete ordered lists. The original dynamic loop - // traverses MATERIAL_ARRAY in ID order (OreDictMaterial 326), after all fixed families. - private static final List MANGANESE_DEFAULTS = List.of( - new ManganeseDefault( - id(250, "Manganese"), - List.of(id(9126, "Pyrolusite"), id(9104, "Hematite"), id(9113, "Chromite")), - 3062), - new ManganeseDefault( - id(8016, "MagnesiumCarbonate"), List.of(id(9115, "Cobaltite"), id(9126, "Pyrolusite")), 3251), - new ManganeseDefault( - id(9104, "Hematite"), - List.of( - id(9120, "Ilmenite"), - id(9004, "GraniticMineralSand"), - id(9126, "Pyrolusite"), - id(8455, "ClayRed")), - 3033), - new ManganeseDefault( - id(9113, "Chromite"), - List.of( - id(9126, "Pyrolusite"), - id(9104, "Hematite"), - id(8016, "MagnesiumCarbonate"), - id(9210, "Bromargyrite")), - 3060), - new ManganeseDefault( - id(9120, "Ilmenite"), - List.of( - id(9192, "Rutile"), - id(9104, "Hematite"), - id(8016, "MagnesiumCarbonate"), - id(9126, "Pyrolusite")), - 3031), - new ManganeseDefault( - id(9128, "Scheelite"), - List.of(id(9126, "Pyrolusite"), id(9123, "Molybdenite"), id(9107, "Calcite")), - 3181), - new ManganeseDefault( - id(9133, "Tungstate"), - List.of(id(9126, "Pyrolusite"), id(470, "Silver"), id(8029, "LithiumChloride")), - 3180), - new ManganeseDefault( - id(9148, "Tantalite"), - List.of(id(9246, "Columbite"), id(9247, "Coltan"), id(9126, "Pyrolusite"), id(9120, "Ilmenite")), - 3065), - new ManganeseDefault( - id(9164, "Wollastonite"), - List.of(id(9104, "Hematite"), id(8016, "MagnesiumCarbonate"), id(9126, "Pyrolusite")), - 3153), - new ManganeseDefault( - id(9210, "Bromargyrite"), - List.of(id(9126, "Pyrolusite"), id(470, "Silver"), id(9113, "Chromite"), id(9211, "Smithsonite")), - 3061), - new ManganeseDefault( - id(9246, "Columbite"), - List.of(id(9148, "Tantalite"), id(9247, "Coltan"), id(9126, "Pyrolusite"), id(9120, "Ilmenite")), - 3064), - new ManganeseDefault( - id(9247, "Coltan"), - List.of(id(9246, "Columbite"), id(9148, "Tantalite"), id(9126, "Pyrolusite"), id(9120, "Ilmenite")), - 3066)); - public static List families() { return FAMILIES; } - public static List manganeseDefaults() { - return MANGANESE_DEFAULTS; - } - - public static Family family(int sourceLine) { - return FAMILIES.stream() - .filter(f -> f.sourceLine() == sourceLine) - .findFirst() - .orElse(null); - } - - public static ManganeseDefault manganeseDefault(int id, String name) { - return MANGANESE_DEFAULTS.stream() - .filter(f -> f.material().matches(id, name)) - .findFirst() - .orElse(null); - } - /** Diagnostic/default-regression comparison only. False must not block a proven live core - * direct MnO2 membership; the source selector reads live byproducts rather than this table. */ - public static boolean matchesManganeseDefault(int id, String name, List liveByproducts) { - var d = manganeseDefault(id, name); - return d != null && d.byproducts().equals(liveByproducts); - } - - public static boolean reviewedIdentity(Identity material) { - if (material == null) return false; - return java.util.Arrays.stream(Phase.values()) - .anyMatch(phase -> phase.material().equals(material)) - || FAMILIES.stream().anyMatch(f -> f.members().contains(material)) - || MANGANESE_DEFAULTS.stream().anyMatch(d -> d.material().equals(material)); - } - private static Identity id(int id, String name) { return new Identity(id, name); } diff --git a/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java new file mode 100644 index 000000000..bae310fb0 --- /dev/null +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java @@ -0,0 +1,240 @@ +package gregtech.content.recipe; + +import gregtech.api.addon.material.*; +import gregtech.engine.material.MaterialDefinition; +import gregtech.engine.material.MaterialInfoDefinition; + +import java.util.*; + +import static gregtech.content.recipe.SpecialProcessData.Phase; +import static gregtech.content.recipe.SpecialProcessData.Tail; + +/** Attaches built-in purified-acid methods as ordinary typed material process rules. */ +public final class SpecialProcessMaterialFacts { + private static final FormKey PURIFIED = form("crushedPurified"); + private static final FormKey PURIFIED_TINY = form("crushedPurifiedTiny"); + private static final FormKey CENTRIFUGED = form("crushedCentrifuged"); + private static final FormKey CENTRIFUGED_TINY = form("crushedCentrifugedTiny"); + private static final Map INPUT_COUNTS = Map.of(PURIFIED, 1, PURIFIED_TINY, 9); + + private SpecialProcessMaterialFacts() {} + + public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { + var processes = new LinkedHashMap<>(declaration.info().processes().rules()); + attachReagents(declaration.name(), processes); + attachFixedTargets(declaration, processes); + attachStaticAquaRegiaTargets(declaration.name(), processes); + attachManganeseTarget(declaration, processes); + if (processes.equals(declaration.info().processes().rules())) return declaration; + var info = declaration.info(); + return new MaterialDefinition.Declaration( + declaration.material(), + new MaterialInfoDefinition( + info.tooling(), + info.composition(), + info.relations(), + new MaterialInfoDefinition.Processes(processes))); + } + + private static void attachReagents( + String name, + Map, List>> processes) { + if (name.equals("SulfuricAcid")) reagent(processes, SpecialProcessMethods.SULFURIC_ACID_LEACHING, "liquid"); + if (name.equals("AquaRegia")) reagent(processes, SpecialProcessMethods.AQUA_REGIA_LEACHING, "liquid"); + if (name.equals("HydrogenFluoride")) + reagent(processes, SpecialProcessMethods.HYDROFLUORIC_ACID_LEACHING, "gas"); + if (name.equals("HydrochloricAcid")) + reagent(processes, SpecialProcessMethods.HYDROCHLORIC_ACID_MANGANESE_LEACHING, "gas"); + } + + private static void attachFixedTargets( + MaterialDefinition.Declaration declaration, + Map, List>> processes) { + for (var family : SpecialProcessData.families()) { + var member = family.members().stream() + .filter(identity -> identity.matches(declaration.material().id(), declaration.name())) + .findFirst() + .orElse(null); + if (member == null) continue; + var method = method(family.fluidInput().phase()); + if (method == null) continue; + processes.computeIfAbsent(method, ignored -> new ArrayList<>()) + .add(new MaterialProcessRule<>( + INPUT_COUNTS.keySet(), + fixedTarget(new MaterialKey(declaration.name()), family))); + } + } + + private static SpecialProcessValue.Target fixedTarget(MaterialKey target, SpecialProcessData.Family family) { + var itemOutputs = new ArrayList(); + itemOutputs.add(new SpecialProcessValue.ItemOutput( + target, List.of(new SpecialProcessValue.FormCount(CENTRIFUGED, 1)), 10_000)); + MaterialKey tail = switch (family.tail()) { + case SELF -> target; + case PLATINUM_GROUP_SLUDGE -> new MaterialKey(SpecialProcessData.PGS.name()); + case GRAPHITE -> new MaterialKey(SpecialProcessData.GRAPHITE.name()); + }; + int tailCount = family.tail() == Tail.PLATINUM_GROUP_SLUDGE ? 8 : 2; + for (int index = 0; index < 5; index++) + itemOutputs.add(new SpecialProcessValue.ItemOutput( + tail, List.of(new SpecialProcessValue.FormCount(CENTRIFUGED_TINY, tailCount)), 5_000)); + return new SpecialProcessValue.Target( + INPUT_COUNTS, + itemOutputs, + family.fluidOutputs().stream().map(SpecialProcessMaterialFacts::fluidOutput).toList(), + family.fluidInput().millibuckets(), + 256, + 0); + } + + private static void attachManganeseTarget( + MaterialDefinition.Declaration declaration, + Map, List>> processes) { + var material = declaration.material(); + if (material.properties().contains(gregtech.api.material.MaterialProperty.ANTIMATTER)) return; + boolean mnDioxideByproduct = declaration.info() + .processes() + .find(MaterialProcessKeys.ORE_PROCESSING).stream() + .map(MaterialProcessRule::value) + .anyMatch(rule -> rule.byproducts().stream() + .anyMatch(byproduct -> byproduct.name().equals("Pyrolusite"))); + if (!mnDioxideByproduct) return; + var target = new SpecialProcessValue.Target( + INPUT_COUNTS, + List.of( + new SpecialProcessValue.ItemOutput( + new MaterialKey(declaration.name()), + List.of(new SpecialProcessValue.FormCount(CENTRIFUGED, 1)), + 10_000), + new SpecialProcessValue.ItemOutput( + new MaterialKey(SpecialProcessData.MNCL2.name()), + List.of( + new SpecialProcessValue.FormCount(form("dustSmall"), 6), + new SpecialProcessValue.FormCount(form("dustTiny"), 13), + new SpecialProcessValue.FormCount(form("dustDiv72"), 64)), + 10_000)), + List.of( + new SpecialProcessValue.FluidOutput( + new MaterialKey("Water"), List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("Chlorine"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 1_000)), + 4_000, + 256, + 0); + processes.computeIfAbsent( + SpecialProcessMethods.HYDROCHLORIC_ACID_MANGANESE_LEACHING, + ignored -> new ArrayList<>()) + .add(new MaterialProcessRule<>(INPUT_COUNTS.keySet(), target)); + } + + private static void attachStaticAquaRegiaTargets( + String name, + Map, List>> processes) { + SpecialProcessValue.Target target = switch (name) { + case "Gold" -> aquaRegiaTarget( + "Gold", + "Copper", + new SpecialProcessValue.FluidOutput( + new MaterialKey("ChloroauricAcid"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("NitrogenMonoxide"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 1_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("Water"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + 6_500); + case "Copper" -> aquaRegiaTarget( + "Copper", + "Cobalt", + new SpecialProcessValue.FluidOutput( + new MaterialKey("ChloroauricAcid"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("NitrogenMonoxide"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 1_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("Water"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + 6_500); + case "Tin", "Cassiterite" -> aquaRegiaTarget( + name, + "Zinc", + new SpecialProcessValue.FluidOutput( + new MaterialKey("StannicChloride"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 2_500), + new SpecialProcessValue.FluidOutput( + new MaterialKey("HydrochloricAcid"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 4_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("NitrogenDioxide"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 3_000), + 13_000); + default -> null; + }; + if (target == null) return; + processes.computeIfAbsent(SpecialProcessMethods.AQUA_REGIA_LEACHING, ignored -> new ArrayList<>()) + .add(new MaterialProcessRule<>(INPUT_COUNTS.keySet(), target)); + } + + private static SpecialProcessValue.Target aquaRegiaTarget( + String target, + String byproduct, + SpecialProcessValue.FluidOutput first, + SpecialProcessValue.FluidOutput second, + SpecialProcessValue.FluidOutput third, + int acid) { + var items = new ArrayList(); + items.add(new SpecialProcessValue.ItemOutput( + new MaterialKey(target), List.of(new SpecialProcessValue.FormCount(CENTRIFUGED, 1)), 10_000)); + for (int index = 0; index < 5; index++) + items.add(new SpecialProcessValue.ItemOutput( + new MaterialKey(byproduct), + List.of(new SpecialProcessValue.FormCount(CENTRIFUGED_TINY, 2)), + 5_000)); + return new SpecialProcessValue.Target( + INPUT_COUNTS, items, List.of(first, second, third), acid, 256, 0); + } + + private static SpecialProcessValue.FluidOutput fluidOutput(SpecialProcessData.Fluid fluid) { + FormKey outputForm = form(fluid.phase().state() == SpecialProcessData.State.GAS ? "gas" : "liquid"); + return new SpecialProcessValue.FluidOutput( + new MaterialKey(fluid.phase().material().name()), + List.of(new SpecialProcessValue.FormCount(outputForm, 1)), + Math.toIntExact(fluid.millibuckets())); + } + + private static MaterialProcessKey method(Phase phase) { + return switch (phase) { + case SULFURICACID -> SpecialProcessMethods.SULFURIC_ACID_LEACHING; + case AQUAREGIA -> SpecialProcessMethods.AQUA_REGIA_LEACHING; + case HYDROGENFLUORIDE -> SpecialProcessMethods.HYDROFLUORIC_ACID_LEACHING; + case HYDROCHLORICACID -> SpecialProcessMethods.HYDROCHLORIC_ACID_MANGANESE_LEACHING; + default -> null; + }; + } + + private static void reagent( + Map, List>> processes, + MaterialProcessKey method, + String form) { + processes.computeIfAbsent(method, ignored -> new ArrayList<>()) + .add(new MaterialProcessRule<>(Set.of(form(form)), new SpecialProcessValue.Reagent())); + } + + private static FormKey form(String name) { + return new FormKey(name); + } +} diff --git a/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java new file mode 100644 index 000000000..51f9f541f --- /dev/null +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java @@ -0,0 +1,45 @@ +package gregtech.content.recipe; + +import gregtech.api.addon.material.DataKey; +import gregtech.api.addon.material.MaterialProcessKey; +import gregtech.api.addon.material.SpecialProcessMethod; +import gregtech.api.addon.material.SpecialProcessValue; +import gregtech.engine.material.MaterialInfoRegistry; +import java.util.List; + +/** Built-in special process methods and their stable target/reagent process keys. */ +public final class SpecialProcessMethods { + public static final MaterialProcessKey SULFURIC_ACID_LEACHING = process( + "sulfuric_acid_leaching"); + public static final MaterialProcessKey AQUA_REGIA_LEACHING = process("aqua_regia_leaching"); + public static final MaterialProcessKey HYDROFLUORIC_ACID_LEACHING = process( + "hydrofluoric_acid_leaching"); + public static final MaterialProcessKey HYDROCHLORIC_ACID_MANGANESE_LEACHING = process( + "hydrochloric_acid_manganese_leaching"); + + private static final List METHODS = List.of( + method(SULFURIC_ACID_LEACHING), + method(AQUA_REGIA_LEACHING), + method(HYDROFLUORIC_ACID_LEACHING), + method(HYDROCHLORIC_ACID_MANGANESE_LEACHING)); + + private SpecialProcessMethods() {} + + public static List methods() { + return METHODS; + } + + public static void install() { + for (var method : METHODS) MaterialInfoRegistry.installBuiltinSpecialProcess(method); + } + + private static SpecialProcessMethod method(MaterialProcessKey process) { + return new SpecialProcessMethod( + process, "gt.recipe.bath", "gt6ce.special_process." + process.id().path().replace('/', '.')); + } + + private static MaterialProcessKey process(String path) { + return MaterialProcessKey.multiple( + new DataKey("gt6ce", "special_process/" + path), SpecialProcessValue.class); + } +} diff --git a/core/src/main/java/gregtech/engine/material/GTMaterialRegistry.java b/core/src/main/java/gregtech/engine/material/GTMaterialRegistry.java index 195ed582f..056d01ed5 100644 --- a/core/src/main/java/gregtech/engine/material/GTMaterialRegistry.java +++ b/core/src/main/java/gregtech/engine/material/GTMaterialRegistry.java @@ -8,7 +8,6 @@ import gregtech.content.material.MaterialDefinitions; import gregtech.engine.addon.AddonCoreServices; import gregtech.engine.addon.AddonMaterials; - import java.util.*; import java.util.function.BiConsumer; @@ -229,6 +228,7 @@ public static synchronized void init() { definitionsOpen = false; } MaterialInfoRegistry.resolveAddonRegistrations(); + gregtech.content.recipe.SpecialProcessMethods.install(); MaterialInfoRegistry.closeRegistrations(); phase = RegistrationPhase.LINKS; MaterialLinker.validate(MaterialDefinitions.declarations(), BY_NAME::get); diff --git a/core/src/main/java/gregtech/engine/material/MaterialInfoRegistry.java b/core/src/main/java/gregtech/engine/material/MaterialInfoRegistry.java index c6e13b92a..d87719f64 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialInfoRegistry.java +++ b/core/src/main/java/gregtech/engine/material/MaterialInfoRegistry.java @@ -26,6 +26,8 @@ private MaterialInfoRegistry() {} private static final List ADDON_TAG_DECLARATIONS = new ArrayList<>(); private static final List ADDON_GROUPS = new ArrayList<>(); private static final List ADDON_PROCESSES = new ArrayList<>(); + private static final List ADDON_SPECIAL_PROCESSES = new ArrayList<>(); + private static final Map SPECIAL_PROCESSES = new LinkedHashMap<>(); private static boolean registrationsClosed; private static volatile Snapshot snapshot; @@ -50,6 +52,8 @@ public record GroupSubmission(String addonId, MaterialGroupDeclaration declarati public record ProcessSubmission( String addonId, MaterialKey material, MaterialProcessKey process, MaterialProcessRule rule) {} + public record SpecialProcessSubmission(String addonId, SpecialProcessMethod method) {} + private record ToolSubmission(String addonId, MaterialKey material, MaterialToolProfile profile) {} private record CompositionSubmission(String addonId, MaterialKey material, MaterialComposition composition) {} @@ -122,6 +126,7 @@ static void freeze() { mergeAddonProcesses(); normalizeLinkedFlags(); validateProcesses(); + validateSpecialProcesses(); validateLinkedToolRegistrations(); var published = new LinkedHashMap(); MATERIALS.forEach((key, info) -> published.put(key, info.freeze())); @@ -180,6 +185,42 @@ private static void validateProcesses() { })); } + private static void validateSpecialProcesses() { + for (var submission : ADDON_SPECIAL_PROCESSES) + installSpecialProcess(new SpecialProcessSubmission(submission.addonId(), submission.method())); + for (var entry : MATERIALS.entrySet()) { + for (var ruleEntry : entry.getValue().processes.entrySet()) { + var method = SPECIAL_PROCESSES.get(ruleEntry.getKey().id()); + boolean special = + ruleEntry.getValue().stream().anyMatch(rule -> rule.value() instanceof SpecialProcessValue); + if (!special) continue; + if (method == null || !method.process().equals(ruleEntry.getKey())) + throw new IllegalArgumentException("Missing special process method " + + ruleEntry.getKey().id()); + for (var rule : ruleEntry.getValue()) { + if (rule.value() instanceof SpecialProcessValue.Target target) { + if (!target.inputCounts().keySet().equals(rule.forms())) + throw new IllegalArgumentException( + "Special process target forms do not match rule forms for " + + entry.getKey().name() + " in " + + method.process().id()); + } else if (!(rule.value() instanceof SpecialProcessValue.Reagent)) { + throw new IllegalArgumentException("Invalid special process value for " + + entry.getKey().name()); + } + } + } + } + } + + private static void installSpecialProcess(SpecialProcessSubmission submission) { + var method = submission.method(); + requireNamespace(submission.addonId(), method.process().id()); + if (SPECIAL_PROCESSES.putIfAbsent(method.process().id(), method) != null) + throw new IllegalArgumentException( + "Duplicate special process method " + method.process().id()); + } + private static void normalizeLinkedFlags() { for (var entry : MATERIALS.entrySet()) { GTMaterial material = GTMaterialRegistry.get(entry.getKey().name()); @@ -309,6 +350,18 @@ static List groupSubmissions() { return List.copyOf(ADDON_GROUPS); } + public static List specialProcesses() { + return List.copyOf(SPECIAL_PROCESSES.values()); + } + + /** Installs a built-in method declaration before the special-process registry closes. */ + public static void installBuiltinSpecialProcess(SpecialProcessMethod method) { + if (snapshot != null) throw new IllegalStateException("Material auxiliary registrations are frozen"); + if (SPECIAL_PROCESSES.putIfAbsent(method.process().id(), method) != null) + throw new IllegalArgumentException( + "Duplicate special process method " + method.process().id()); + } + private static Set normalizeProcessForms( String source, MaterialProcessKey process, Set sourceForms) { if (sourceForms.isEmpty()) return sourceForms; @@ -622,6 +675,15 @@ public MaterialInfoTool.Registrar registerGroup(MaterialGroupDeclaration declara return this; } + @Override + public MaterialInfoTool.Registrar registerSpecialProcess(SpecialProcessMethod method) { + requireOpen(); + Objects.requireNonNull(method); + requireNamespace(addonId, method.process().id()); + ADDON_SPECIAL_PROCESSES.add(new SpecialProcessSubmission(addonId, method)); + return this; + } + @Override public MaterialInfoTool.Registrar registerProcess( MaterialKey material, MaterialProcessKey process, MaterialProcessRule rule) { diff --git a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java index f75cea793..7125cd85a 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java +++ b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java @@ -91,6 +91,7 @@ public record Step( List inputs, List outputs, List details, + Optional specialProcess, boolean resolved) { public Step { Objects.requireNonNull(reference); @@ -103,6 +104,17 @@ public record Step( || outputs.stream().filter(Port::main).count() > 1) throw new IllegalArgumentException("Multiple main process ports"); details = List.copyOf(details); + Objects.requireNonNull(specialProcess); + } + + public Step( + DataKey reference, + String name, + List inputs, + List outputs, + List details, + boolean resolved) { + this(reference, name, inputs, outputs, details, Optional.empty(), resolved); } } @@ -155,6 +167,7 @@ private record Node(DataKey reference, int depth) {} private final Snapshot snapshot; private final Map steps; private final Map resources; + private final Map> resourcesByMaterial; private final Map> inputs; private final Map> outputs; private final List notices; @@ -163,6 +176,19 @@ private MaterialProcessGraph(Builder builder) { snapshot = builder.snapshot; steps = Map.copyOf(builder.steps); resources = Map.copyOf(builder.resources); + var byMaterial = new HashMap>(); + resources + .values() + .forEach(resource -> byMaterial + .computeIfAbsent(resource.material(), ignored -> new ArrayList<>()) + .add(resource)); + var frozenByMaterial = new HashMap>(byMaterial.size()); + byMaterial.forEach((material, values) -> frozenByMaterial.put( + material, + values.stream() + .sorted(Comparator.comparing(resource -> resource.key().toString())) + .toList())); + resourcesByMaterial = Map.copyOf(frozenByMaterial); inputs = freezeOccurrences(builder.inputs); outputs = freezeOccurrences(builder.outputs); notices = List.copyOf(builder.notices); @@ -332,6 +358,88 @@ public Query query(DataKey root, Direction direction, Budgets budgets) { !truncations.isEmpty()); } + /** + * Return every step directly adjacent to any form of the root's material. Unlike {@link #query}, this + * does not recurse through another material, so a common reagent cannot pull unrelated downstream chains + * into the page. Internal form conversions, immediate sources and immediate uses share this one result. + */ + public Query queryMaterial(DataKey root, Budgets budgets) { + Objects.requireNonNull(root); + Objects.requireNonNull(budgets); + Resource rootResource = resources.get(root); + if (rootResource == null) + return new Query(snapshot, root, Direction.BOTH, List.of(), List.of(), notices, false); + + var selected = new java.util.TreeSet(Comparator.comparingInt(IndexedStep::order)); + List materialResources = rootResource.material().equals("unknown") + ? List.of(rootResource) + : resourcesByMaterial.getOrDefault(rootResource.material(), List.of()); + for (Resource resource : materialResources) { + selected.addAll(inputs.getOrDefault(resource.key(), List.of())); + selected.addAll(outputs.getOrDefault(resource.key(), List.of())); + } + var retained = new ArrayList(Math.min(selected.size(), budgets.maxSteps())); + int omittedSteps = 0; + for (IndexedStep indexed : selected) { + if (retained.size() >= budgets.maxSteps()) { + omittedSteps++; + continue; + } + retained.add(indexed); + } + + int omittedPorts = 0; + for (IndexedStep indexed : retained) { + omittedPorts += Math.max(0, indexed.step.inputs().size() - budgets.maxPortsPerSide()); + omittedPorts += Math.max(0, indexed.step.outputs().size() - budgets.maxPortsPerSide()); + } + var resultSteps = retained.stream() + .map(indexed -> boundedStep(indexed.step, budgets.maxPortsPerSide())) + .toList(); + var retainedByReference = new HashMap(); + resultSteps.forEach(step -> retainedByReference.put(step.reference(), step)); + + var resultEdges = new LinkedHashSet(); + int omittedEdges = 0; + for (IndexedStep source : retained) { + for (Port port : source.step.outputs()) { + if (!port.resource().material().equals(rootResource.material())) continue; + for (IndexedStep target : inputs.getOrDefault(port.resource().key(), List.of())) { + if (!retainedByReference.containsKey(target.step.reference())) continue; + Edge edge = new Edge( + source.step.reference(), + target.step.reference(), + port.resource().key(), + confirmed(source, target)); + if (resultEdges.contains(edge)) continue; + if (resultEdges.size() >= budgets.maxEdges()) { + omittedEdges++; + continue; + } + resultEdges.add(edge); + } + } + } + + var truncations = new LinkedHashMap(); + addNotice(truncations, "node_limit", omittedSteps); + addNotice(truncations, "port_limit", omittedPorts); + addNotice(truncations, "edge_limit", omittedEdges); + var resultNotices = new ArrayList<>(notices); + truncations.forEach((code, omitted) -> resultNotices.add(new Notice(code, omitted))); + if (resultSteps.isEmpty() + && resultNotices.stream().noneMatch(notice -> notice.code().equals("no_both"))) + resultNotices.add(new Notice("no_both", 0)); + return new Query( + snapshot, + root, + Direction.BOTH, + resultSteps, + List.copyOf(resultEdges), + List.copyOf(resultNotices), + !truncations.isEmpty()); + } + private int enqueue( DataKey root, boolean sources, @@ -363,6 +471,7 @@ private Step boundedStep(Step step, int maxPorts) { boundedPorts(step.inputs(), maxPorts), boundedPorts(step.outputs(), maxPorts), step.details(), + step.specialProcess(), step.resolved()); } diff --git a/core/src/main/java/gregtech/engine/material/MaterialViews.java b/core/src/main/java/gregtech/engine/material/MaterialViews.java index 847b4595b..35afb5222 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialViews.java +++ b/core/src/main/java/gregtech/engine/material/MaterialViews.java @@ -37,6 +37,9 @@ static void publish() { var origins = new LinkedHashMap(); var directTagMembers = new LinkedHashMap>(); var tagFacts = new LinkedHashMap(); + var specialProcessMethods = new LinkedHashMap(); + for (var method : MaterialInfoRegistry.specialProcesses()) + specialProcessMethods.put(method.process().id(), method); for (GTMaterial material : GTMaterialRegistry.sortedMaterials()) { if (material.resolve() != material) continue; var definition = MaterialDefinitions.find(material.getName()); @@ -56,6 +59,22 @@ static void publish() { tagFacts.putIfAbsent(key, new TagFacts("gt6ce", Set.of())); } var key = new MaterialKey(material.getName()); + MaterialInfoRegistry.processesForPublication(key).rules().forEach((process, rules) -> { + var method = specialProcessMethods.get(process.id()); + if (method == null || !method.process().equals(process)) return; + for (var rule : rules) { + DataKey tag = rule.value() instanceof SpecialProcessValue.Target + ? method.targetTag() + : rule.value() instanceof SpecialProcessValue.Reagent ? method.reagentTag() : null; + if (tag == null) continue; + builder.tag(tag); + var owner = method.process().id().namespace(); + var previous = tagFacts.putIfAbsent(tag, new TagFacts(owner, Set.of())); + if (previous != null && !previous.owner().equals(owner)) + throw new IllegalArgumentException( + "Special process tag " + tag + " conflicts with owner " + previous.owner()); + } + }); builders.put(key, builder); properties.put(key, new LinkedHashMap<>()); for (var property : builder.build().keys()) types.put(property.id(), property.type()); @@ -385,6 +404,15 @@ public Optional group(MaterialGroupKey key) { return Optional.ofNullable(groups.get(java.util.Objects.requireNonNull(key))); } }; + var specialProcesses = new SpecialProcessesView() { + public List methods() { + return List.copyOf(specialProcessMethods.values()); + } + + public Optional find(DataKey id) { + return Optional.ofNullable(specialProcessMethods.get(java.util.Objects.requireNonNull(id))); + } + }; var indexed = Map.copyOf(materials); var ordered = List.copyOf(materials.values()); var aliases = new LinkedHashMap(); @@ -426,6 +454,10 @@ public MaterialFormsView formBindings() { public MaterialProcessesView processes() { return processView; } + + public SpecialProcessesView specialProcesses() { + return specialProcesses; + } }; } diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index dfe175033..c184f6191 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -59,12 +59,28 @@ "material.gt6ce.redstonealloy": "Redstone Alloy", "material.gt6ce.sculk": "Sculk", "gt6ce.jei.material_process.title": "Mineral Processing", - "gt6ce.jei.material_process.inputs": "Co-inputs / catalysts", - "gt6ce.jei.material_process.route": "Main route", - "gt6ce.jei.material_process.outputs": "Other outputs", + "gt6ce.jei.material_process.section.sources": "Sources", + "gt6ce.jei.material_process.section.internal": "Conversions", + "gt6ce.jei.material_process.section.uses": "Uses", + "gt6ce.jei.material_process.cluster": "%s x%s", + "gt6ce.jei.material_process.group_count": "This group contains %s steps.", + "gt6ce.jei.material_process.group_expand": "Left-click to expand.", + "gt6ce.jei.material_process.group_collapse": "Left-click to collapse.", + "gt6ce.special_process.sulfuric_acid_leaching": "Sulfuric Acid Leaching", + "gt6ce.special_process.aqua_regia_leaching": "Aqua Regia Leaching", + "gt6ce.special_process.hydrofluoric_acid_leaching": "Hydrofluoric Acid Leaching", + "gt6ce.special_process.hydrochloric_acid_manganese_leaching": "Hydrochloric Acid Manganese Leaching", + "gt6ce.jei.material_process.pan": "Drag empty space to pan freely | Scroll to zoom at the pointer", + "gt6ce.jei.material_process.reset": "R", + "gt6ce.jei.material_process.zoom_hint": "Scroll to zoom at the pointer, or click − / +.", + "gt6ce.jei.material_process.resource_hint": "Left-click: recipes | Right-click: uses. Hover the machine for amounts and extra ingredients.", + "gt6ce.jei.material_process.variants": "%s recipes share this route", + "gt6ce.jei.material_process.copy": "Local display copy of this resource (↗); related copies highlight together.", + "gt6ce.jei.material_process.return": "Return flow (↩); this is not an additional source.", + "gt6ce.jei.material_process.reset_hint": "Restore readable scale and center on the material route.", "gt6ce.jei.material_process.empty": "No processing steps in this result.", "gt6ce.jei.material_process.unbound": "Processing data has not been connected yet.", - "gt6ce.jei.material_process.controls": "Step: recipe | Resource: sources / uses", + "gt6ce.jei.material_process.controls": "Left-click step: recipe | Click resource: sources / uses", "gt6ce.jei.material_process.open_recipe": "Click the step to open its original recipe, when available.", "gt6ce.jei.material_process.unresolved": "Unresolved relation / native constraint", "gt6ce.jei.material_process.confirmed": "Confirmed relation", @@ -79,7 +95,6 @@ "gt6ce.jei.material_process.role.byproduct": "Byproduct", "gt6ce.jei.material_process.role.unknown": "Output role: unknown", "gt6ce.jei.material_process.material_title": "%s processing", - "gt6ce.jei.material_process.page_controls": "Page counter: left-click for next page, right-click for previous page.", "gt6ce.jei.material_process.port_name": "%s / %s", "gt6ce.jei.material_process.amount.items": "Amount: %s items", "gt6ce.jei.material_process.amount.units": "Amount: %s U", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index 30343f9dc..f31f23868 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -61,12 +61,28 @@ "material.gt6ce.redstonealloy": "红石合金", "material.gt6ce.sculk": "幽匿", "gt6ce.jei.material_process.title": "矿物处理", - "gt6ce.jei.material_process.inputs": "共同输入/催化剂", - "gt6ce.jei.material_process.route": "主加工路线", - "gt6ce.jei.material_process.outputs": "其他产物", + "gt6ce.jei.material_process.section.sources": "来源", + "gt6ce.jei.material_process.section.internal": "内部转换", + "gt6ce.jei.material_process.section.uses": "去向", + "gt6ce.jei.material_process.cluster": "%s ×%s", + "gt6ce.jei.material_process.group_count": "本组包含 %s 个步骤。", + "gt6ce.jei.material_process.group_expand": "左击展开。", + "gt6ce.jei.material_process.group_collapse": "左击折叠。", + "gt6ce.special_process.sulfuric_acid_leaching": "硫酸浸出", + "gt6ce.special_process.aqua_regia_leaching": "王水浸出", + "gt6ce.special_process.hydrofluoric_acid_leaching": "氢氟酸浸出", + "gt6ce.special_process.hydrochloric_acid_manganese_leaching": "盐酸锰矿浸出", + "gt6ce.jei.material_process.pan": "拖拽空白区域自由平移|滚轮以鼠标为中心缩放", + "gt6ce.jei.material_process.reset": "复位", + "gt6ce.jei.material_process.zoom_hint": "滚轮以鼠标为中心缩放;也可点击 −/+。", + "gt6ce.jei.material_process.resource_hint": "左击:配方|右击:用途;数量与额外物品请悬停机器查看。", + "gt6ce.jei.material_process.variants": "此路线包含 %s 个配方", + "gt6ce.jei.material_process.copy": "此资源的局部展示副本(↗);悬停同步突出其他副本。", + "gt6ce.jei.material_process.return": "回流(↩);不表示新增来源。", + "gt6ce.jei.material_process.reset_hint": "恢复可读比例并定位到本材料的路线。", "gt6ce.jei.material_process.empty": "此查询结果中没有加工步骤。", "gt6ce.jei.material_process.unbound": "尚未接入加工数据。", - "gt6ce.jei.material_process.controls": "点击工艺:原配方|左/右击资源:来源/用途", + "gt6ce.jei.material_process.controls": "左击工艺:原配方|左/右击资源:来源/用途", "gt6ce.jei.material_process.open_recipe": "点击工艺可在支持时打开原始配方。", "gt6ce.jei.material_process.unresolved": "关系或原生约束尚未解析", "gt6ce.jei.material_process.confirmed": "已确认的关系", @@ -81,7 +97,6 @@ "gt6ce.jei.material_process.role.byproduct": "副产物", "gt6ce.jei.material_process.role.unknown": "产物角色:未知", "gt6ce.jei.material_process.material_title": "%s 加工", - "gt6ce.jei.material_process.page_controls": "点击页码:左键下一页,右键上一页。", "gt6ce.jei.material_process.port_name": "%s/%s", "gt6ce.jei.material_process.amount.items": "数量:%s 件", "gt6ce.jei.material_process.amount.units": "数量:%s U", diff --git a/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java b/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java index efb1b4321..0cf350bd8 100644 --- a/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java +++ b/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java @@ -36,6 +36,11 @@ void reviewedRecipeFactsAreFullyProjectedIntoMaterialDeclarations() { assertEquals(7, processCount(declarations, MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT)); assertEquals(2, processCount(declarations, MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY)); assertEquals(1, processCount(declarations, MaterialFactKeys.COMPRESSOR_DUST_TO_GEM_PLATE)); + assertEquals(14, processCount(declarations, gregtech.content.recipe.SpecialProcessMethods.AQUA_REGIA_LEACHING)); + assertTrue(processCount( + declarations, + gregtech.content.recipe.SpecialProcessMethods.HYDROCHLORIC_ACID_MANGANESE_LEACHING) + > 1); } @Test @@ -70,11 +75,31 @@ void standaloneMaterialsAndDeviceCatalogsResolveWithoutLegacyMods() { .findSingle(new MaterialKey("AquaRegia"), MaterialFactKeys.MATERIAL_FLUID_UNIT) .orElseThrow() .value(); + assertTrue(GregTechMaterials.catalog() + .specialProcesses() + .find(new gregtech.api.addon.material.DataKey("gt6ce", "special_process/aqua_regia_leaching")) + .isPresent()); + assertTrue( + processes + .find( + new MaterialKey("Gold"), + gregtech.content.recipe.SpecialProcessMethods.AQUA_REGIA_LEACHING) + .stream() + .anyMatch(rule -> + rule.value() instanceof gregtech.api.addon.material.SpecialProcessValue.Target)); + assertTrue( + processes + .find( + new MaterialKey("AquaRegia"), + gregtech.content.recipe.SpecialProcessMethods.AQUA_REGIA_LEACHING) + .stream() + .anyMatch(rule -> + rule.value() instanceof gregtech.api.addon.material.SpecialProcessValue.Reagent)); assertTrue(aquaRegia.units().stream() .anyMatch(unit -> unit.phase().equals("liquid") && unit.fluidField().equals("GenLiquid_AquaRegia") && unit.referenceMillibuckets() == 1000)); - for (var phase : gregtech.content.recipe.SourcePurifiedAcidData.Phase.values()) { + for (var phase : gregtech.content.recipe.SpecialProcessData.Phase.values()) { var units = processes .findSingle(new MaterialKey(phase.material().name()), MaterialFactKeys.MATERIAL_FLUID_UNIT) .orElseThrow(() -> new AssertionError("Missing acid fluid units: " + phase)) @@ -313,8 +338,7 @@ private static long processCount( java.util.List declarations, gregtech.api.addon.material.MaterialProcessKey key) { return declarations.stream() - .filter(declaration -> - declaration.info().processes().findSingle(key).isPresent()) + .filter(declaration -> !declaration.info().processes().find(key).isEmpty()) .count(); } } diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java index 2ce42dec3..35ba8644b 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java @@ -121,6 +121,46 @@ void forwardAndReverseQueriesUseTheSamePortIndex() { assertEquals("cast", uses.steps().get(0).name()); } + @Test + void materialQueryKeepsEveryDirectFormAndStopsAtAnotherMaterial() { + DataKey ore = new DataKey("gt6ce", "resource/iron/ore"); + DataKey crushed = new DataKey("gt6ce", "resource/iron/crushed"); + DataKey dust = new DataKey("gt6ce", "resource/iron/dust"); + DataKey sourceMaterial = new DataKey("gt6ce", "resource/copper/ore"); + DataKey productMaterial = new DataKey("gt6ce", "resource/copper/ingot"); + DataKey farther = new DataKey("gt6ce", "resource/gold/ingot"); + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(step( + "source", + List.of(port(sourceMaterial, Role.CONSUMED, "copper ore", "Copper")), + List.of(port(ore, Role.UNKNOWN, "iron ore", "Iron")))) + .add(step( + "crush", + List.of(port(ore, Role.CONSUMED, "iron ore", "Iron")), + List.of(port(crushed, Role.UNKNOWN, "iron crushed", "Iron")))) + .add(step( + "grind", + List.of(port(crushed, Role.CONSUMED, "iron crushed", "Iron")), + List.of(port(dust, Role.UNKNOWN, "iron dust", "Iron")))) + .add(step( + "use", + List.of(port(dust, Role.CONSUMED, "iron dust", "Iron")), + List.of(port(productMaterial, Role.UNKNOWN, "copper ingot", "Copper")))) + .add(step( + "transitive", + List.of(port(productMaterial, Role.CONSUMED, "copper ingot", "Copper")), + List.of(port(farther, Role.UNKNOWN, "gold ingot", "Gold")))) + .build(); + + var result = graph.queryMaterial(ore, new Budgets(0, 64, 64, 128)); + + assertEquals( + List.of("source", "crush", "grind", "use"), + result.steps().stream().map(Step::name).toList()); + assertEquals(3, result.edges().size()); + assertFalse(result.truncated()); + } + private static boolean edgeIsConfirmed(MaterialProcessGraph.Edge edge) { return edge.confirmed(); } @@ -169,9 +209,13 @@ private static DataKey resource(String name) { } private static Port port(DataKey key, Role role, String state) { + return port(key, role, state, "Iron"); + } + + private static Port port(DataKey key, Role role, String state, String material) { boolean output = role == Role.PRIMARY || role == Role.BYPRODUCT || role == Role.UNKNOWN; return new Port( - new Resource(key, "Iron", "dust", "solid", state), + new Resource(key, material, "dust", "solid", state), role, new Amount(1, state.startsWith("unit:") ? AmountUnit.MATERIAL_UNIT : AmountUnit.ITEM), output ? OptionalInt.of(10_000) : OptionalInt.empty(), diff --git a/docs/ADDON_API.zh-CN.md b/docs/ADDON_API.zh-CN.md index 37b1fab8c..0ca16d590 100644 --- a/docs/ADDON_API.zh-CN.md +++ b/docs/ADDON_API.zh-CN.md @@ -55,12 +55,40 @@ ## API 版本 -当前分支使用 API `1.8.0`,与模组版本独立;以 [api/common/build.gradle](../api/common/build.gradle) 为准。`GregTechAddons.apiVersion()` 返回 `major * 1000 + minor`,1.8 为 `1008`,不能据此推断某个模组构建兼容。修改内联 API 时同步构建配置与 `GregTechAddons` 的版本。 +当前分支使用 API `1.9.0`,与模组版本独立;以 [api/common/build.gradle](../api/common/build.gradle) 为准。`GregTechAddons.apiVersion()` 返回 `major * 1000 + minor`,1.9 为 `1009`,不能据此推断某个模组构建兼容。修改内联 API 时同步构建配置与 `GregTechAddons` 的版本。 宿主专用的 `StructureGrid` 与 `RecipeMapSpec` 不属于附属契约:它们分别位于 `gregtech.content.multiblock` 与 `gregtech.content.recipe`,编码内置多方块几何和配方表,附属不应依赖。 公共 API 的契约检查、SDK 与平台检查见[验证与验收](development/validation/README.md)。移动到 API 包的可变模型或内部辅助类不自动获得长期兼容保证。 +## 特殊处理方法(API 1.9) + +`SpecialProcessMethod` 复用现有 `MaterialProcessKey` 作为 method ID,并把目标材料和辅料规则放在同一张 typed process 表中: + +```java +var key = MaterialProcessKey.multiple( + new DataKey("example", "special_process/wash"), SpecialProcessValue.class); +var method = new SpecialProcessMethod(key, "gt.recipe.bath", "example.special_process.wash"); + +registrar.registerSpecialProcess(method); +registrar.registerProcess(materialA, key, new MaterialProcessRule<>( + Set.of(new FormKey("crushedPurified")), + new SpecialProcessValue.Target( + Map.of(new FormKey("crushedPurified"), 1), + List.of(new SpecialProcessValue.ItemOutput( + materialB, + List.of(new SpecialProcessValue.FormCount(new FormKey("crushedCentrifuged"), 1)), + 10_000)), + List.of(), + 1_000, + 200, + 16))); +registrar.registerProcess(reagent, key, new MaterialProcessRule<>( + Set.of(new FormKey("liquid")), new SpecialProcessValue.Reagent())); +``` + +Target 的 `inputCounts` 键必须与 `MaterialProcessRule.forms()` 完全一致。`reagentAmount` 对物品规则表示数量,对液体/气体规则表示 mB。方法发布后,`MaterialCatalogView.specialProcesses()` 暴露方法声明,材料目录的 `processes()` 暴露 target/reagent 规则;宿主同时推导 method target/reagent 材料 tag,并按声明表单生成物品/流体 tag。材料图只折叠带 method ID 的配方。 + ## 机器配方数据包(API 1.7) `gt6ce:machine` 向已有机器配方表追加或覆盖行,`gt6ce:machine_removal` 删除行。数据包路径按目标版本的配方目录(`data//recipes/`,1.21.1 为单数 `recipe/`)。处理顺序固定:恢复基线、重建标签与生成行、应用移除、最后应用追加;移除只能匹配基线和生成行,追加看到的是最终静态集合。同一行的显式 `priority` 决定查找优先级,较高者优先,相同值保持发布顺序。 @@ -136,6 +164,7 @@ String json = MachineRecipeDocuments.canonical(document); // 不含 "type",写 - `MachineRecipeType.ADDITION`/`REMOVAL` 与 `MachineRecipeFields` 提供类型 ID 和字段名常量,避免附属复制字符串。 - 1.7 起这些类型不再位于 `gregtech.engine.recipe.data`;依赖旧内部包名的附属需要迁移到公开包。运行时可用 `GregTechAddons.apiVersion() >= 1007` 做特性判断。 - 1.8 新增 `MaterialProcessKeys.DECOMPOSITION` 与 `MaterialDecompositionRule`;附属可通过自身材料的 `MaterialInfoTool` 流程提交液体/气体换算、路线和固体兜底。该 typed rule 是唯一权限权威;旧 `MaterialDeclaration.centrifuge()`/`electrolyzer()` shortcut 已弃用,仅在不存在 typed rule 时生成默认兼容规则。运行时可用 `GregTechAddons.apiVersion() >= 1008` 做特性判断。 +- 1.9 新增 `SpecialProcessMethod`、`SpecialProcessValue` 与 `SpecialProcessesView`。一个 method 使用现有 `MaterialProcessKey` 把 `Target` 规则挂到可处理材料、把 `Reagent` 规则挂到辅料材料;宿主据此生成配方、折叠材料图并派生 target/reagent 标签。运行时可用 `GregTechAddons.apiVersion() >= 1009` 做特性判断。 ### 让附属自己的数据包配方进入 overlay diff --git a/docs/architecture/packages/api.md b/docs/architecture/packages/api.md index 40789998b..3410ebd14 100644 --- a/docs/architecture/packages/api.md +++ b/docs/architecture/packages/api.md @@ -10,7 +10,7 @@ | --- | --- | --- | | `api` | API 包的总体契约说明 | `package-info.java` | | `api.addon` | 附属发现、身份、生命周期、命名限制与 SPI | `GregTechAddon`、`GregTechAddons`、`AddonRuntime`;声明失败应有上下文 | -| `api.addon.material` | 材料、前缀、成分、形态、类型化 metadata、分类 tag、替代组和分解声明 | `MaterialDeclaration`、`MaterialMetadata`、`MaterialTagDeclaration`、`MaterialGroupDeclaration`、`MaterialDecompositionRule`、`GregTechMaterials` | +| `api.addon.material` | 材料、前缀、成分、形态、类型化 metadata、分类 tag、替代组、分解和特殊处理声明 | `MaterialDeclaration`、`MaterialMetadata`、`MaterialTagDeclaration`、`MaterialGroupDeclaration`、`MaterialDecompositionRule`、`SpecialProcessMethod`、`SpecialProcessValue`、`GregTechMaterials` | | `api.addon.machine` | 机器、行为、部件、布局及参数声明 | `AddonMachine.withStructure` 显式绑定;`MultiblockMachine`、`BehaviorMachine`、`LayoutPart`、`AddonMachineContributor` | | `api.addon.recipe` | 配方表、坩埚反应、模具、保留输入与概率声明,以及 `gt6ce:machine` 数据包文档 | `RecipeMachine`、`CrucibleReactionDeclaration`、`RecipeOutputChances`、`MachineRecipeDocument`、`MachineRecipeDocuments`、`MachineRecipeDocumentType` | | `api.addon.pipe` | 附属物品/流体管道的定义 | `ItemPipeDeclaration`、`FluidPipeDeclaration` | diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index fb82e5cfb..32c33bf95 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,7 +70,7 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`client.MaterialProcessPanel` 负责布局和交互,`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、索引和事件适配。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 +矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责原生端口实例、拓扑层级、连续链、局部副本和排线,`client.MaterialProcessPanel` 负责可读视口、副本/回流标记与原生交互;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、索引和事件适配。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 @@ -81,7 +81,7 @@ GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../ - 客户端只负责展示与交互入口;真实槽位、库存、权限与配方由服务端 Menu 和服务端状态决定。修改 GUI 模板后先做静态预览,再在客户端与专用服务端分别确认。 - 网络包检查方向、解码上限、执行线程、目标实体有效性与请求者权限;Mixin 检查两个节点的配置、目标签名、注入点与未命中行为。 - 可选集成沿配置与现有入口条件加载;分别验证未安装目标模组与安装匹配版本。 -- 矿物处理页按[专用场景](../../development/validation/checks/manual-ingame.md#矿物处理展示页)确认联合输入、角色、概率、折叠、显式关联与跳转;前端未接线时不记作真实来源或远程快照验收通过。 +- 矿物处理页按[专用场景](../../development/validation/checks/manual-ingame.md#矿物处理展示页)确认联合输入、角色、概率、端口副本、显式关联与跳转;前端未接线时不记作真实来源或远程快照验收通过。 - 运输网络快照只在布局变化时失效,空闲电线/管道不执行 tick;外部 fill/drain、覆盖板、扳手、邻居变化和区块加载都必须接到失效或唤醒钩子。 - 共享 Minecraft 输入遵循 Stonecutter 条件与版本资源路径;渲染、GUI、网络与 Mixin 的结论不能用单平台结果推出另一平台。 diff --git a/docs/decisions/0001-material-data-api.md b/docs/decisions/0001-material-data-api.md index 8ec89a513..d5ea01a58 100644 --- a/docs/decisions/0001-material-data-api.md +++ b/docs/decisions/0001-material-data-api.md @@ -170,6 +170,17 @@ public interface MaterialDataSnapshot { **关系以步骤为中心,是多输入、多输出的关系。** 合金必须保留 Copper 与 Tin 同时作为输入;清洗剂、选择器和催化剂也保留角色。不能画成“有 Copper 就能获得 Bronze”的无条件单边。 +#### 4.1 特殊处理方法 + +特殊处理不新增跨材料目标大表,而是复用 typed process: + +- `SpecialProcessMethod` 绑定一个 `MaterialProcessKey`、配方表和展示键。 +- 可处理材料在同一 key 上注册 `SpecialProcessValue.Target`;Target 保存输入表单计数、物品/流体产物、概率、辅料量、时长和能耗。 +- 辅料材料在同一 key 上注册 `SpecialProcessValue.Reagent`;其表单由普通 `MaterialProcessRule.forms()` 表达。 +- 宿主生成配方后把 method ID 写入最终 `Recipe`;材料图只按该 ID 折叠步骤。没有 method ID 的配方平铺,不按步骤名猜测。 +- target/reagent 材料 tag 从 typed rules 派生;资源 tag 再根据规则表单生成,避免标签与配方双写。 +- 同一配方匹配多个 method 时视为声明冲突;静默选择会让不同内容顺序改变路线含义。 + ### 5. 各来源的发布方式 1. **普通配方**:从最终有效 `RecipeMap`、原版 `RecipeManager` 及必要的输入约束投影。保留数据包替换、删除、启用状态;来源索引不再次计算产物。 @@ -243,7 +254,7 @@ metadata 使用 builder 挂分类、类型化属性与 flag,不继续给 `Mate `GregTechMaterials.Material` 的现有查询方法不强加新的抽象方法给旧实现者;新视图通过适配器和新增入口提供。宿主服务能力增加时采用显式能力协商或默认“不支持”,不能默认返回空图误报完整覆盖。旧主机与新 API 组合的失败方式纳入契约测试。 -当前 API 版本为 1.8.0。A/B 使用默认 SPI 方法和新增只读类型,旧宿主通过显式“不支持”失败,既有声明实现者保持源码兼容。API 1.5 的 `MaterialProcessKey`/`MaterialProcessesView` 允许附属用自己的 namespace 声明处理规则;API 1.6 的 `MaterialInfoTool` 将工具、组成、形态、tag 和 process 注册为按 `MaterialKey` 关联的独立域索引。API 1.7 提供详细 `MaterialFormRule`、运行期 `MaterialFormsView`、显式统一物品绑定和 item/block/fluid 分离的实际形态查询,同时保留材料组的成员与包含查询。API 1.8 通过 `MaterialProcessKeys.DECOMPOSITION` 承载单一类型化分解规则;该规则是路线唯一权威,旧离心/电解 feature 只提供弃用兼容输入。旧 `GTMaterial` 工艺访问器和旧组 re-registration 访问器暂时保留并标记弃用,READY 后只转发冻结快照。新增查询身份不改 NBT、原生注册 ID、配方单位或已有材料名。 +当前 API 版本为 1.9.0。A/B 使用默认 SPI 方法和新增只读类型,旧宿主通过显式“不支持”失败,既有声明实现者保持源码兼容。API 1.5 的 `MaterialProcessKey`/`MaterialProcessesView` 允许附属用自己的 namespace 声明处理规则;API 1.6 的 `MaterialInfoTool` 将工具、组成、形态、tag 和 process 注册为按 `MaterialKey` 关联的独立域索引。API 1.7 提供详细 `MaterialFormRule`、运行期 `MaterialFormsView`、显式统一物品绑定和 item/block/fluid 分离的实际形态查询,同时保留材料组的成员与包含查询。API 1.8 通过 `MaterialProcessKeys.DECOMPOSITION` 承载单一类型化分解规则;该规则是路线唯一权威,旧离心/电解 feature 只提供弃用兼容输入。API 1.9 用一个 `SpecialProcessMethod` 绑定 `MaterialProcessKey`、配方表和展示键;同一 key 下的 `Target`/`Reagent` 规则分别挂在可处理材料和辅料材料上,宿主生成配方并派生标签。材料图只能按该 method 身份折叠,普通配方不参与名称推断。旧 `GTMaterial` 工艺访问器和旧组 re-registration 访问器暂时保留并标记弃用,READY 后只转发冻结快照。新增查询身份不改 NBT、原生注册 ID、配方单位或已有材料名。 ## 影响、落地与验证 diff --git a/docs/development/README.md b/docs/development/README.md index 063e1079c..de8dc3c84 100644 --- a/docs/development/README.md +++ b/docs/development/README.md @@ -6,7 +6,8 @@ | [文件与产物归属](repository-layout.md) | 源码、测试、工具、文档和临时材料的位置 | | [验证与验收](validation/README.md) | 改动路径路由、检查命令与结果证据 | | [碎片贴图与机器 GUI 模板](gui-templates.md) | 模板格式、素材引用和界面接入 | -| [矿物处理 JEI 展示接入](material-process-display.md) | 前端投影、分页、覆盖说明与后续跳转调用契约 | +| [矿物处理图展示接入](material-process-display.md) | 前端投影、三区分区、平移、工艺组、覆盖说明与后续跳转调用契约 | +| [配方总览图布局设计](material-process-layout.md) | 待实施的拓扑分层、连续链对齐、资源局部副本、排线与验收标准 | | [Issue 分类与标签](github-issue-tags.md) | 问题分类与协作约定 | 其他主题见[GT6CE 文档](../README.md),开发工具用法见[工具目录](../../tools/README.md)。 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md index 7e3f645cb..942b84dd8 100644 --- a/docs/development/material-process-display.md +++ b/docs/development/material-process-display.md @@ -1,76 +1,91 @@ -# 矿物处理 JEI 展示接入 +# 矿物处理图展示接入 -本文说明[计划 08-E](material-system-refactor/08-material-data-api.md#e有界矿物处理图与消费者迁移)的前端接入契约。生产路径现在从同一 `MaterialProcessSnapshot` 取得有界 core 图结果,并在 JEI 与 EMI 中共享 `Page` 和 `MaterialProcessPanel`。空状态 `unbound()` 只在没有成功发布快照时使用;具体机器行、世界生成、远程客户端和人工点击仍需按验证范围分别验收。 +本文说明[计划 08-E](material-system-refactor/08-material-data-api.md#e有界矿物处理图与消费者迁移)的前端接入契约。生产路径从同一 `MaterialProcessSnapshot` 取得一种材料全部形态的直接关系,并在 JEI 与 EMI 中共享单页可缩放、自由平移图和 `MaterialProcessPanel`。空状态 `unbound()` 只在没有成功发布快照时使用;具体机器行、世界生成、远程客户端和人工交互仍需按验证范围分别验收。 -这是 Minecraft 实现层的客户端调用接口,随模组编译,不是独立 API JAR 的公共材料服务,也不改变 API 1.8.0。分类和面板只在已安装 JEI/EMI 的客户端路径加载;无 viewer 的专用服务端入口不得引用它们。 +这是 Minecraft 实现层的客户端调用接口,随模组编译;方法声明来自 API 1.9.0,但本页面本身不是独立 API JAR 的公共材料服务。分类和面板只在已安装 JEI/EMI 的客户端路径加载;无 viewer 的专用服务端入口不得引用它们。 + +拓扑分层与资源局部副本的设计依据见[配方总览图布局设计](material-process-layout.md)。当前实现按原生依赖排布;辅料、工具、存在条件及额外副产物不作为额外图节点;`+` 只列可靠辅料名称,完整约束通过普通配方查询查看。 ## 入口与职责 | 类型 | 职责 | | --- | --- | -| `gregtech.compat.common.MaterialProcessDisplay` | 已完成有界查询的展示投影、校验和分页;不读取材料目录、配方表或服务端状态 | +| `gregtech.compat.common.MaterialProcessDisplay` | 已完成有界查询的展示投影和校验;不读取材料目录、配方表或服务端状态 | | `MaterialProcessDisplay.Port` | 一个原生状态敏感的资源选择器的展示,含角色、数量单位、概率与有限图标 | -| `MaterialProcessDisplay.Step` | 同一步骤的全部共同输入、全部输出、机器/环境/时间/能量/出处说明 | +| `MaterialProcessDisplay.Step` | 同一步骤的全部共同输入、全部输出、机器/环境/时间/能量/出处说明,以及可选的 special-process method 身份 | | `MaterialProcessDisplay.Connection` | 调用方提供的步骤关联,包含资源引用及确认状态;支持分支、回边和自环 | -| `MaterialProcessDisplay.Page` | 每页至多两个步骤,保留全图关联、覆盖说明和绑定到同一查询结果的跳转回调 | -| `gregtech.client.MaterialProcessPanel` | 固定 280×216 的坐标、绘制、悬停与点击;不依赖 JEI/EMI | -| `gregtech.compat.jei.MaterialProcessCategory` | 原生 JEI 槽位、索引、事件和 tooltip;分类类型为 `TYPE`,标识为 `gt6ce:material_process` | -| `gregtech.compat.emi.MaterialProcessEmiRecipe` | EMI 分类、原生索引和共享面板适配;不读取材料目录或配方表 | +| `MaterialProcessDisplay.Page` | 一种材料的全部已查询步骤、全图关联、覆盖说明和绑定到同一查询结果的跳转回调;页面不按步骤拆页 | +| `gregtech.compat.common.MaterialProcessOverview` | 按显示身份合并重复路线与资源,保留原始步骤/端口,计算依赖层级、连续链及排线路径 | +| `gregtech.client.MaterialProcessPanel` | 固定 280×216 视口内的拓扑图、副本/回流标记、可读缩放、双向平移、同步悬停高亮、名称提示与普通来源/用途查询;不依赖 JEI/EMI | +| `gregtech.compat.jei.MaterialProcessCategory` | JEI 不可见检索索引、拖拽/滚轮事件和 tooltip;分类类型为 `TYPE`,标识为 `gt6ce:material_process` | +| `gregtech.compat.emi.MaterialProcessEmiRecipe` | EMI 索引、拖拽/滚轮事件和共享面板适配;不读取材料目录或配方表 | | `gregtech.content.recipe.MaterialProcessSnapshot` | 绑定一次完整发布、会话和世界生成 revision;索引最终机器行与符号选择器 | | `gregtech.content.worldgen.MaterialWorldgenFacts` | 只含活动世界生成事实,不构造原生图标 | -| `gregtech.engine.material.MaterialProcessGraph` | core 有界前向/反向查询、循环终止和显式预算截断 | +| `gregtech.engine.material.MaterialProcessGraph` | core 有界递归查询、材料页直连查询、循环终止和显式预算截断 | | `gregtech.compat.common.MaterialProcessProjection` | 把 core 查询转成快照内 `DataKey`、有限图标和展示 `Page` | -复用现有 `DataKey` 表达展示引用,复用 `RecipeOutputChances.CERTAIN` 的万分比契约、viewer 原生槽位、分页、配方索引与运行期注册。没有另建 SPI、全局来源缓存、锁、服务端查询协议或材料事实表。JEI 与 EMI 共用展示模型和面板,任何共用类型都不能引用具体 viewer 类。 +复用现有 `DataKey` 表达展示引用,复用 `RecipeOutputChances.CERTAIN` 的万分比契约、viewer 检索索引、配方索引与运行期注册。没有另建 SPI、全局来源缓存、锁、服务端查询协议或材料事实表。JEI 与 EMI 共用展示模型和面板,任何共用类型都不能引用具体 viewer 类。 ## 构造契约 -- `DataKey` 在这里是调用方签发的快照内引用,不是新的材料身份或存档 ID。`Port.resource` 必须区分材料、形态、相态和原生状态;不同 tag/unit 选择器也不能因图标相同而合并。已有 `MaterialKey`、`FormKey` 与原生匹配引用由后续适配器解析到该引用,不重新建立材料目录。 -- `Port(resource, name, icons, role, main, amount, chance, details)` 的 `amount` 必须包含原生批量及单位,如件、U 或 mB。前端只显示文本,不换算、不从栈数量推导材料量。`icons` 为有限代表,空列表表示符号资源;不展开 tag 或 unit 候选全集。使用现有 `FluidDisplayBinding.display(...)` 取得带相态/状态的流体代理物品,不创建另一套流体身份转换。 +- `DataKey` 在这里是调用方签发的快照内引用,不是新的材料身份或存档 ID。`Port.resource` 必须区分材料、形态、相态和原生状态;不同 tag/unit 选择器的原生引用保持独立。`Port.identity` 另作展示共享键:完整原生状态或规范选择器描述不包含查询代号及配方专属 selector 后缀;有原生图标时按实际显示代表的完整物品/流体状态识别相关展示实例;多候选 selector 可以与该代表同步高亮,并在总览共享一个资源节点,但原始候选集、消耗量和 guard 仍属于各原生步骤,不声称 selector 与具体物品可互换。不同 NBT/数据组件状态不得仅因图标相同而合并。已有 `MaterialKey`、`FormKey` 与原生匹配引用由后续适配器解析到该引用,不重新建立材料目录。 +- `Port` 的 `amount` 必须包含原生批量及单位,如件、U 或 mB。`quantity` 是生产者同时提供的紧凑图标角标(件数、省略为 1 的件数、U、mB 或未知标记),前端不解析 `amount` 文本、不换算、不从图标栈数量推导材料量。旧构造方法默认不显示数量角标。紧凑总览不在名称提示中显示数量与概率,完整值保留在原始步骤并通过 viewer 普通配方查询查看,避免共享资源节点承担多个不同配方的批量。`icons` 为有限代表,空列表表示符号资源;不展开 tag 或 unit 候选全集。使用现有 `FluidDisplayBinding.display(...)` 取得带相态/状态的流体代理物品,不创建另一套流体身份转换。 - `Role.CONSUMED`、`CATALYST`、`PRESENCE` 只用于输入;`PRIMARY`、`BYPRODUCT`、`UNKNOWN` 只用于输出。输入不因为存在数量就自动消耗。无可靠主/副角色时用 `UNKNOWN`,不得按槽位猜测。 -- `main` 仅决定中心路线位置,每一步的输入和输出分别至多一个。它不改变角色、确定性或权威性;未指定主路线时所有端口均侧排。 +- `main` 是生产者提供的路线提示,每一步的输入和输出分别至多一个。总览显示本材料在该侧的全部消耗输入或产物;该侧没有本材料时,用 `main` 或稳定端口顺序选一个外部主输入/产物。工具、存在条件及其余辅料/额外副产物留在 `+` 中。这不改变原始角色,也不声称一个可见输入就是完整配方。 - `chance` 使用 `OptionalInt`,已知概率为 1—10000,未知为 `OptionalInt.empty()`,确定产出为 `OptionalInt.of(RecipeOutputChances.CERTAIN)`。输入概率不参与绘制。互斥/共享随机事件、未知相关性和原生状态限制必须放在 `details`;不能用边际概率声称各输出独立。世界生成权重放说明,不能当成掉落概率。 -- `Step(reference, name, inputs, outputs, details, resolved)` 保存同一步的联合输入、多输出及条件。机器、时间、能量、温度、维度、选择器、来源等通过 `details` 传入。`resolved=false` 表示原生关系/约束尚未解析,连接为虚线,工艺按钮不能打开原配方。`resolved=true` 也不承诺玩家库存可执行。 +- `Step` 保存同一步的联合输入、多输出及条件。`icon` 是生产者提供的代表机器图标,访问时返回副本;没有可靠机器代表时使用空图标,面板显示问号。`worldGenerated` 由快照的真实世界生成引用设置,不根据空输入、图标或引用字符串猜测;兼容构造方法默认为 `false`。活动世界生成步骤使用镐作为采集符号。普通机器工序复用 EMI 分类的 `RecipeMachines` 索引与 `RecipeViewerIcons.category(...)`,包括锤子等工具类图标;不再只遍历基础机器。机器、时间、能量、温度、维度、选择器、来源等通过 `details` 传入。`resolved=false` 表示原生关系/约束尚未解析,连接为虚线;显示图标仍可执行普通来源/用途查询。`resolved=true` 也不承诺玩家库存可执行。 - `Connection(source, target, resource, confirmed)` 必须指向当前结果内的两个步骤,且资源同时出现在源步骤输出和目标步骤输入中。前端不按相同物品图标补边;`confirmed=false` 保留为未确认关系。 -- 文本与图标在构造时复制,列表只读,图标访问返回副本。调用方须将传入后取得的 `Component` 及说明视为只读。禁止传 `null`、空物品栈、错误侧角色、重复步骤引用、悬空关联或非法概率;构造/分页时抛出 `IllegalArgumentException`,不把无效数据改成空结果。 +- 文本与图标在构造时复制,列表只读,图标访问返回副本。调用方须将传入后取得的 `Component` 及说明视为只读。禁止传 `null`、空物品栈、错误侧角色、重复步骤引用、悬空关联或非法概率;构造/校验时抛出 `IllegalArgumentException`,不把无效数据改成空结果。 -`pages(title, steps, connections, notices, navigation)` 按调用方的既定顺序分页,不执行图遍历或自动规划。当前预算为最多 64 步、128 条关联、每步每侧 64 个端口、每端口 16 个代表图标;超限直接拒绝。调用方应在查询层按预算取得结果,并提供准确截断原因,不能先全量枚举再交给 UI 截断。 +`pages(title, material, steps, connections, notices, navigation)` 生成一张材料页,不执行图遍历、自动规划或步骤分页。当前展示上限为 512 步、4096 条关联、每步每侧 128 个端口、每端口 16 个代表图标;超限直接拒绝。调用方应在查询层按预算取得结果,并提供准确截断原因,不能先全量枚举再交给 UI 截断。 -`notices` 必须非空,在每页页脚可见,悬停显示全部内容。调用方必须说明完整/部分覆盖、未支持族和深度/节点/端口/边预算截断;空结果也必须说明范围。默认 `unbound()` 只表示尚未接线,不能当作“该材料没有来源”。 +`notices` 必须非空,通过页脚的 `i` 提示入口悬停显示全部内容。调用方必须说明完整/部分覆盖、未支持族和节点/端口/边预算截断;空结果也必须说明范围。默认 `unbound()` 只表示尚未接线,不能当作“该材料没有来源”。 ## 布局与交互 -主加工位于中线,共同原料及流体条件位于左侧,物品模具、工具等辅助条件留在步骤说明与原配方中,其他产物位于右侧,副产物分支使用金色。批量、单位、角色、概率和完整条件在端口及工艺 tooltip 中读取。黄色角标和虚线表示随机、未知概率或未解析关系。 +生产查询使用 `MaterialProcessGraph.queryMaterial(...)`:先展开根材料的 ore、raw、crushed、dust、fluid 等全部已发布形态,再收集与任一形态直接相邻的步骤,不沿另一材料的产物继续递归。因此同一材料页同时包含: + +- “来源”:实际消耗非本材料、产出本材料且不消耗本材料的配方,以及明确来自世界生成的本材料。 +- “内部转换”:实际消耗并产出本材料形态的步骤;洗矿等含辅料和副产物的转换仍归这里。 +- “去向”:实际消耗本材料、产出其他材料且不再产出本材料的配方。 + +分类只使用 `CONSUMED` 输入。仅作为催化剂或存在条件出现的本材料不能建立加工流向;无输入但没有世界生成标记的步骤不能据此声称是来源。没有满足上述条件的步骤不纳入这三个材料转换分类,不能把“不是来源”直接当成去向。 + +分类保留为材料流向的语义说明,不决定节点准入或位置,也不绘制分割线。未分类、纯符号、无输入或无输出的合法步骤仍保留原始引用。图按**机器图标的完整物品状态+可见输入身份集合+可见输出身份集合**合并外观相同的路线;数量、条件、辅料、特殊工艺 method 或不同原生引用不再强制复制一条外观相同的路线。无图标工序没有可靠外观身份,仍按引用区分。 + +合并只作用于总览:`Node.steps` 保留全部原生步骤;每条可见边的 `endpoints()` 保留全部 `Endpoint(step, output, index, port)`。原生配方、选择器约束、数量、概率与 viewer 检索索引不合并或删除。此图不用于推断配方执行等价性。 + +同一 `Port.identity` 在整图优先共享一个资源节点,即使来自不同 selector 或快照资源引用;不同完整 NBT/组件状态仍分开。点击只查询当前显示物品/流体的普通来源或用途,不再把一个节点绑定到任意一条原生配方。`Connection` 仍原样保留,不因展示共享新增逻辑关联。 + +依赖图按稳定引用遍历,解除反馈边的前向层级约束后计算 DAG 层级;纯环与自环保留方向和标记。相邻层、低连接度且连续较长的路线优先对齐。等长分支按资源家族集中排序,再按邻近节点重心分配行;不因连接度大于阈值就拆散公共物品。非主链边跨越超过三层、纵向距离超过 192 单位、穿过中间节点或属于反馈边时,将该端口改为机器附近的局部资源副本,再重新排布。每个可见端口最多拆出一个副本,连续主链和邻近分支仍共享资源。 + +常规悬停只显示实际物品/机器名称;无原生图标时使用符号名称。机器右上角 `+` 的独立悬停区域显示合并配方数和去重后的辅料名称,最多列出十二项;完整配方信息通过 viewer 普通查询查看。局部副本与回流仍有 `↗`/`↩` 标记,相关资源与边同步高亮。 -只有显式关联连接的相邻主输出/主输入才绘制跨步骤中心箭头。其余分支、跨页关联、回边与自环以每步的关联数量和完整 tooltip 引用表示,不将非相邻步骤强行连线;循环不触发递归展开。原生状态相异但图标相同的端口仍分别显示。 +所有可见连接统一使用单段直线,分支直接斜向相连,不再混用正交折线。输入侧只连线,输出侧保留箭头,连续链为 `材料—机器→产出`。回流使用带 `↩` 标记的局部副本,不在画布顶部预留回流通道;副本之间不额外连线。线宽、虚线间距及箭头与节点使用同一画布变换,随缩放同比变化。布局在首次打开页面创建面板时完成;EMI 注册索引时不提前排布全部材料,缩放、平移和悬停不重新排图。 -每侧最多六个侧排图标,更多端口显示“+N 个端口”,悬停保留全部端口信息。被折叠的物品代表仍加入 JEI 原生不可见索引,保留 R/U 检索。这是布局折叠,不是数据查询截断。符号端口以问号占位并保留说明和自定义跳转,不能将其图标代表当成完整候选集合。 +`MaterialProcessProjection` 从同一快照的原生配方复制物品栈和流体状态。含指纹的状态字符串不是序列化数据,不能去掉指纹后新建无数据物品代替;无法恢复时保留无图标符号。EMI 的流体索引、查询和悬停提供器通过 `MaterialProcessEmiStacks` 将代理显示物品还原为真实流体键和数据,而非索引代理物品本身。物品则保留完整 NBT/组件。悬停及点击使用当前实际显示的代表,而原生索引保留全部有限代表;有可用真实图标时优先使用,不让另一条无图标引用遮蔽它。同显示身份可以有多个带标记的局部实例;实例复制不改变原始 selector 或原生索引。 -- 左击工艺调用 `Navigation.openRecipe(step.reference)`,只在 `resolved=true` 时尝试。 -- 左击资源调用 `Navigation.openForm(resource, false)` 查询来源,右击传 `true` 查询用途;回调返回 `false` 时不消费该点击,允许 JEI 原生行为继续处理。R/U 等快捷键仍由 JEI 管理。 -- `Navigation.NONE` 是不支持跳转的明确默认实现,不需要 `null` 回调。 -- JEI 使用原生分页;EMI 的初始分类也使用原生分页。EMI 动态来源/用途查询保留全部 `Page`,点击右上角页码前后翻页,不把后续步骤截成第一页。没有全局 UI 实例缓存。 +拖拽空白区域向任意方向平移,滚轮围绕鼠标缩放,顶部 `−/+` 围绕视口中心缩放,“复位”采用 `max(0.75, min(1, 整图适配比例))`;超出视口时定位本材料的代表链,小图适配视口。滚轮仍可主动缩小查看全图。裁剪边界先通过 viewer 当前渲染矩阵转换为绝对 GUI 坐标;悬停、点击和 EMI 原生 ingredient provider 共同使用实际渲染矩阵及画布逆变换。页脚 `i` 提供覆盖及截断说明。 + +- 机器和资源均使用普通来源/用途查询:左击查来源,右击查用途。机器调用 `Navigation.openStack(icon, uses)`,资源通过 `openPort` 的默认方法将当前代表传给 `openStack`,不再精确跳转某条配方。 +- 左/右击资源通过 `Navigation.openPort(port, uses)` 打开 viewer 原生配方/用途查询;EMI 的悬停 ingredient provider 同样提供真实物品或流体句柄,以支持原生快捷键。`openForm` 保留为显式打开另一材料总览的接口,不再作为生产页资源点击时重新打开总览的路径。 +- `Navigation.NONE` 明确表示不支持跳转。具体回调先核对同一快照是否仍有效;无法解析时返回 `false`。 +- 一个材料仍只注册一个 `Page`,局部副本只影响展示,没有删除原配方或另建执行模型。 ## 后续调用方式 在既有 JEI 注册回调中,把从同一已发布内容版本得到的展示投影传入: ```java -var pages = MaterialProcessDisplay.pages(title, steps, connections, notices, navigation); +var pages = MaterialProcessDisplay.pages(title, material, steps, connections, notices, navigation); registration.addRecipes(MaterialProcessCategory.TYPE, pages); ``` -这里的 `title`、`steps`、`connections`、`notices`、`navigation` 是调用方的局部变量。生产路径由 `MaterialProcessProjection.initialPages(...)` 从当前 `MaterialProcessSnapshot` 生成这些值;`MaterialProcessDisplay.unbound()` 只用于没有成功发布快照的显式空状态,不能与正式结果同时注册。 +这里的 `title`、`material`、`steps`、`connections`、`notices`、`navigation` 是调用方的局部变量。生产路径由 `MaterialProcessProjection.initialPages(...)` 从当前 `MaterialProcessSnapshot` 生成这些值;`MaterialProcessDisplay.unbound()` 只用于没有成功发布快照的显式空状态,不能与正式结果同时注册。 `Navigation` 由内容适配器创建并捕获该次查询的会话/generation。每次跳转先检查当前版本,过期或不能解析时返回 `false`,不得跳转到新版本中“相似”的配方。不要捕获旧 `Level`/服务器实例,也不要从客户端直接扫描集成服务器表。生产者应将未来 `ProcessRef` 和实际材料形态引用映射到展示引用,适配器使用原生服务重新解析;UI 不发明第二个快照协议。 -解析得到具体配方及其已注册分类后,可复用 JEI 的精确跳转: - -```java -runtime.getRecipesGui().showRecipes(category, List.of(recipe), List.of()); -``` - -`category` 和 `recipe` 必须来自当前有效原生引用;`RecipeViewerNavigation.open(map)` 只打开整个机器分类,不能替代这一步的精确定位。形态跳转应重新查询对应有界来源/用途,而不是按图标猜材料。 +`openStack` 必须通过 viewer 原生的物品/流体 focus 查询来源或用途。EMI 使用 `EmiApi.displayRecipes`/`displayUses`;JEI 使用 OUTPUT/INPUT focus。机器图标也加入 EMI ingredient provider,R/U 与鼠标采用同一个普通查询目标。普通查询保留完整原生状态,不解析某个 `Step.reference` 来选择精确配方。 动态打开查询结果可复用 JEI `IRecipeManager.getRecipeCategory(TYPE)` 和 `IRecipesGui.showRecipes(category, pages, List.of())`;优先让结果仅随当前显示布局存活。若使用运行期 `addRecipes`,调用方必须负责重载、断线、换服以及旧记录和回调的释放;`hideRecipes` 只是隐藏,不能当作回收旧快照的手段。`MachineRecipeClient` 在断线时清除当前快照,`MaterialProcessSnapshot.Store` 只保留当前成功代和一代前代;展示页本身不缓存材料目录或配方表。 @@ -78,4 +93,10 @@ runtime.getRecipesGui().showRecipes(category, List.of(recipe), List.of()); 检查路由为 `runtime`/语言资源 `content`;双平台编译、格式、资源打包与相关 JUnit 命令见[验证入口](validation/README.md)。[游戏检查](validation/checks/manual-ingame.md#矿物处理展示页)分别覆盖两平台及后续远程接线。 -当前生产页覆盖最终机器配方与活动世界生成;tag/unit 选择器保持符号形式,没有可靠角色信息的输出保持未知。真实洗矿/合金、两次重载、远程 generation、JEI/EMI 精确跳转及两平台人工点击仍必须分别记录。测试不得为演示把假配方或额外材料来源写入生产表。 +当前生产页覆盖最终机器配方与活动世界生成;tag/unit 选择器保持符号形式,没有可靠角色信息的输出保持未知。真实洗矿/合金、两次重载、远程 generation、JEI/EMI 普通来源/用途查询及两平台人工点击仍必须分别记录。测试不得为演示把假配方或额外材料来源写入生产表。 + +## 特殊工艺所有权 + +API 用 `SpecialProcessMethod` 绑定现有 typed process key、配方表和展示键。可处理材料注册 `SpecialProcessValue.Target`,辅料材料注册同一 key 下的 `SpecialProcessValue.Reagent`;宿主按 target 的表单计数、产物、概率、辅料量和反应参数生成配方,并把 method ID 写入最终 `Recipe`。已有手工 Bath 行也必须通过同一 target/reagent 规则匹配并获得 method ID,不能仅凭步骤名折叠。 + +每个 Target/Reagent 规则还会派生对应材料标签。`MaterialTagPack` 根据规则表单生成物品/流体标签,供过滤器和自动化脚本使用;分类标签和配方 method ID 共用声明,不维护第二份手写名单。 diff --git a/docs/development/material-process-layout.md b/docs/development/material-process-layout.md new file mode 100644 index 000000000..cc56f418a --- /dev/null +++ b/docs/development/material-process-layout.md @@ -0,0 +1,158 @@ +# 配方总览图:拓扑分层与资源局部副本 + +本文定义配方总览图的目标呈现方式、布局步骤和验收条件,供后续实现使用。**已接入拓扑分层、连续链、局部副本与共享面板,游戏内外观及性能尚待验收**。当前接口、查询范围、资源身份与跳转契约以[展示接入](material-process-display.md)为准;本文不另建配方事实、公共 API 或查询协议。 + +## 目标与边界 + +图标、工序节点和有向箭头是主要阅读方式。玩家打开页面后直接看到已查询的加工步骤、主材料输入和输出,无需先选工艺区、展开目录或翻配方列表。悬停用于补充数值和条件,普通来源/用途查询用于进一步查看详情。 + +布局只依赖输入输出、资源身份、端口角色及已提供的关联。附属增加处理方式时,只要满足现有展示契约,就应自动参与排布;不得要求它先归入“机械加工”“热处理”等人工工艺区。现有来源、内部转换、去向可保留为说明信息,不再决定图的分区、节点准入或位置。 + +规模增大时增加画布面积,利用现有平移与缩放浏览。默认构图优先保证物品和箭头可辨认,不强制把整图缩到一个小视口。该方案接受资源图标重复和较长画布,以减少交叉、长连线与额外查找操作。 + +范围仍是当前有界查询返回的 `Page`。布局不递归补查其他材料、不扫描配方表、不把“图中没有来源”解释为不可获得,也不把潜在路线解释为玩家库存可执行的生产计划。 + +## 图形规则 + +| 对象 | 呈现 | 语义 | +| --- | --- | --- | +| 资源 | 真实物品/流体图标,必要的短名称 | 对应一个具体端口的显示代表;保留原生状态与选择器约束 | +| 工序 | 机器图标或统一的工序符号 | 外观相同的路线可共享工序;全部原生 `Step` 保留,辅料不画入图中 | +| 输入连线 | 资源 — 工序 | 实际消耗的主材料输入,不画箭头;辅料和工具通过 `+` 查看 | +| 输出箭头 | 工序 → 资源 | 对应可见原生输出;主材料多输出在工序附近分支,额外副产物通过 `+` 查看 | +| 资源局部副本 | 相同资源图标及 `↗` 标记 | 同一资源在另一个使用位置的展示实例,不新增资源或配方 | +| 回流 | 局部资源副本及 `↩` 标记 | 返回已有资源的循环关系;方向不因布局反转 | +| 未确认关系 | 虚线及不确定性提示 | 沿用 `confirmed`/`resolved` 的含义,不能只因是回流就标成未确认 | + +辅料、催化剂、存在条件和额外副产物不作为图节点,也不扩展它们的生产路线。它们保留在原始 `Step`,由机器右上角 `+`、tooltip 和原配方展示数量、消耗语义和说明。该侧有本材料时显示本材料的全部消耗输入/产物;没有本材料时优先用 `main`,否则稳定选择一个非副产物的外部主端口。此选择仅压缩图面,不改变原始角色。 + +普通连续加工链表现为 `A—机器→B—机器→C`。同机器图标、同主输入和主输出的多个配方共享一个工序,辅料本身不画入图中。 + +工序名称、材料名称和图标外观均不参与工艺分类。多步链的布局不要求识别“粉碎”“蒸煮”等特定名称。 + +## 事实图与展示实例分离 + +实现中应分开以下对象;名称仅用于描述内部职责,不要求新增同名公共类型: + +| 对象 | 必须保存的信息 | +| --- | --- | +| 逻辑步骤 | `Step.reference`、全部原始端口、条件、原生配方引用和解析状态 | +| 逻辑关联 | 原始 `Connection` 及其资源、源步骤、目标步骤、确认状态 | +| 端口关联 | 步骤、输入/输出侧、端口位置、角色,以及该端口的原始 `Port` | +| 资源展示实例 | 独立的实例键、展示共享键、对应的端口关联、是否副本及实例位置 | +| 工序展示实例 | 对应全部原始步骤引用及位置;视觉重复的路线共享实例 | +| 展示连线 | 对应的端口关联/逻辑关联、实例端点、直线端点、回流与确认状态 | + +`Port.resource` 是快照内引用,`Port.identity` 是现有契约定义的展示共享键。展示共享不授权 selector 与显示代表互换,也不授权不同原生状态互换。不能从相同 `identity`、同名图标或图上路径推导新的 `Connection`。 + +每条可见输入连线/输出箭头都必须能追溯到原始步骤端口;跨步骤关联仍以调用方提供且通过校验的 `Connection` 为准。图上复用显示代表时,需要保留各端口的候选集与约束,不得将多个 selector 的候选并成一份,总览共享只表示显示代表相同,不构成原生配方可执行或选择器可互换的依据。 + +副本实例键应由稳定的资源引用、所属步骤、侧别与端口位置派生,不能仅使用屏幕坐标或本轮遍历序号。所有实例都保留对应端口的原生导航数据。共享节点和副本按实际显示物品/流体执行普通来源/用途查询,不再挑选某一条配方精确跳转。全部原始端口仍留在实例和边的反查数据中。 + +数量、单位、概率和条件属于步骤及其端口,不属于共享资源节点。图面可在对应端口旁放紧凑角标;完整值仍由该步骤的 tooltip 与原配方提供,不解析展示文本来重建执行规则。 + +## 展示去重与原生事实分离 + +外观相同的路线按机器图标完整状态、可见输入身份集合和可见输出身份集合合并。不同 `Step.reference`、辅料、数量、条件或 method 仍保存于原始步骤,但不再要求总览重复显示相同图形。未知图标没有可靠外观键,不能只因同为问号就合并。 + +所有原生步骤、端口、选择器、单位、概率及关联原样保留,合并边可以反查全部原始端口;它不改变配方注册项或 viewer 索引,也不声称执行等价。原生配方重复采集仍需在事实产生处处理,不能通过视觉合并掩盖数据问题。 + +相同 `Port.identity` 在全图优先共享一个资源节点,原生资源引用不同不再强制拆开。高连接度本身不触发复制,仅明显跨越多层且偏离主链的长连接才使用局部副本。统计区分原生配方数、显示路线数及资源副本数。 + +## 自动布局流程 + +### 保留完整端口,构造主材料图 + +从当前 `Page` 保留完整端口及原生引用,构造可见主材料资源—工序二部图,消耗输入指向工序,产物从工序引出。输出角色未知时保留 `UNKNOWN`,不按槽位或名称补猜。`Port.main` 只作为可见外部主端口和排布提示,其余端口留在 `+`;不能改变原始主副产物语义。 + +所有合法的已查询步骤都参与展示,不再因为无法归入 `Section` 或缺少可选的主 A/B 而跳过。世界生成仅使用真实 `worldGenerated` 标记;无输入、无生产者或无图标均不能被猜成世界生成。缺少查询范围外的来源时保留符号/范围提示,不补造生产配方。 + +### 处理循环并确定横向层级 + +在可见消耗流、输出及显式步骤关联中按稳定引用检测反馈边,排除工具和存在条件的非消耗连接。当前实现用迭代深度优先遍历解除回环约束,再对前向 DAG 确定层级;反馈边只退出前向层级约束,逻辑方向及事实关联继续保留。 + +前向图中,工序位置应晚于其参与排布的共同输入,产物位置应晚于工序。层数来自依赖关系,不来自工序类型。纯循环且没有外部入口时,用稳定引用选择布局锚点,不把这个锚点显示成“原料来源”。 + +浏览器草图用简化的最早生产层估计展示效果;生产实现必须覆盖无外部入口的环、自环、多个生产者及未解析端口,不能直接照搬草图中有限的合成数据假设。层级只表示阅读位置,不代表可达性、执行先后保证或最短生产方案。 + +### 识别连续链段并对齐 + +在已有层级上,优先连接相邻层、较低连接度且端口关系明确的前后节点。可靠的 `main` 提示可以提高对应连接的排布优先级;没有提示时使用拓扑评分与稳定键作为回退。 + +将适合连续阅读的链段尽量放在同一水平线上,外观不同的替代路线及分叉就近排列。交汇点不能无条件合并所有相邻链段,否则一个公共原料会把全图重新拉成一个大团。这里的链段只用于坐标分配,不生成带工艺名称的分区,不删除原始步骤,也不要求玩家进入链段后才能阅读。 + +排序可使用有限轮次的前后向重心调整;随后按实际节点包围盒压紧和避让。优化顺序为:不遮挡节点与文字、减少交叉、保持连续链水平、缩短连线,再减少画布面积。相同快照输入顺序变化时,稳定引用应保证结果可重复;悬停和高亮不得触发布局。 + +### 选择资源局部副本 + +对造成明显扇入/扇出、跨多个层级、跨链长连接或回流拥挤的可见资源,在具体工序的输入侧或输出侧建立局部副本。可见产物与主输入均可采用该机制,不按工序名称或资源名单特判;隐藏辅料不参与复制。 + +当前副本选择处理非主链且跨越超过三层、纵向相距超过 192 单位、会穿过中间节点或属于反馈边的连接,不按节点连接度直接拆副本。每轮拆分后重新排布,直到其余连接可以直接绘制;独立端口副本不再拆分。阈值仍需根据真实图调优。优先保留连续主链的直接连接及邻近分支的共享节点,避免无差别复制所有资源后把图拆成互不相连的配方小块。 + +副本应满足: + +1. 图标、名称与明确的副本标记可直接识别,不要求点击才知道它是什么。 +2. 同一资源的实例保留原始端口反查关系;悬停时可同步突出其余同身份实例及相关箭头。 +3. 同名但不同 NBT/组件、相态或选择器约束的对象不因副本机制混为一体。 +4. 以局部副本表达回流时仍标记 `↩`,不能看起来像凭空新增了一种外部供料。 +5. 不为副本之间补画虚构的物料运输/加工箭头;标记表达展示引用,不表示新增配方。 + +### 端口排线与箭头 + +所有连接统一使用单段直线;连续链保持水平,分支使用斜线,不混入正交折线。输入侧只画线,输出侧才画箭头。输入和输出分别分配固定侧的端口位置,当前同侧可见端口仍共用节点侧面锚点,密集多端口场景尚需游戏内确认并进一步调整。跨层边若会穿过中间节点,改用机器附近的资源副本。 + +回流和自环使用带 `↩` 标记的局部资源副本,保留真实输入/输出方向,不画跨越全图的回路,也不为回流预留顶部空白。没有节点的交叉处不画连接圆点,不同资源不能共用一段看似混料的总线;同一资源需要共线时,也应保留各工序的独立端口归属。 + +连线、虚线间距、箭头与图标使用同一画布缩放和平移变换,缩小时线宽和箭头同比缩小,不保持固定屏幕尺寸。箭头不能压住物品图标、数量角标或名称。回流使用副本标记,未确认关系使用虚线;催化剂/存在条件留在详情中,不画入图表。 + +## 视口与交互 + +打开页面即绘制全部已查询步骤及可见主端口;完整端口仍保存在数据和各工序详情中。默认不出现工艺区选择器、步骤列表分页或必须展开的分组。常用浏览仍是看图、平移和缩放;副本标记在未悬停时也可见。 + +初始缩放与复位采用可读性下限:小图可适配视口,大图保持可读比例并定位根材料的代表链附近。可用 `max(可读缩放下限, min(1, 整图适配比例))` 作为初始策略;具体下限根据游戏 GUI 缩放、物品尺寸及字体实际验证。若保留整图鸟瞰,应为显式操作,不能每次打开都自动把节点缩到难以辨认。 + +沿用现有资源左/右击查询、机器和资源左/右击普通来源/用途查询与 EMI ingredient provider。高亮优先使用悬停,不能直接照搬草图的点选锁定而占用这些原生点击动作。常规图标提示只显示名称;只有 `+` 区域显示合并配方数与去重辅料名,不提供右击切换隐藏变体。 + +所有副本的绘制、命中、tooltip、点击和原生 ingredient provider 使用同一展示实例及相同视口变换。未解析关系仍保留说明与关系提示;资源副本不绕过快照 generation 校验。 + +## 接入现有实现 + +| 入口 | 当前职责 | +| --- | --- | +| `MaterialProcessSnapshot` / `MaterialProcessGraph` | 继续作为事实与有界查询来源;图布局不额外枚举数据。重复采集如需修复,单独定位事实来源 | +| `MaterialProcessProjection` / `MaterialProcessDisplay` | 保留完整原生步骤、端口及确认关联,不以图标推断关系;副本实例属于布局结果,不成为新的 `DataKey` 或配方事实 | +| `MaterialProcessOverview` | 按原生端口和已提供关联计算依赖层级、连续链、副本与路径;保留原始端口反查 | +| `MaterialProcessPanel` / `MaterialProcessArrows` | 消费布局结果,绘制主材料图、副本和回流;调整默认缩放与复位,统一实例命中和裁剪 | +| JEI / EMI 适配器 | 继续复用同一模型与面板;资源副本仍使用具体原生状态查询,索引不随实例数重复注册 | + +此表是现有入口的改造范围,不新增包职责或规定新的公共类。纯拓扑计算应与渲染 API 解耦,以便自动验证;无需为此次展示改造修改材料注册、存档、原生配方单位或附属处理方式注册要求。 + +布局按快照/页面、视口相关尺寸及字体尺寸缓存。平移、缩放和悬停不能每帧重算全图;重载或 generation 变化时释放旧实例和回调。渲染时可以做视口裁剪,但所有已查询节点仍须存在于布局中,不能把离屏节点当作删除或截断。 + +当前 `MaterialProcessDisplay` 接受最多 512 步、4096 条关联、每步每侧 128 个端口、每端口 16 个图标。这些是现行输入边界;752 步的浏览器演示只是界面压力样例,不证明生产页可接收该输入,也不构成提高上限的决定。 + +副本最多恢复到每个可见原始端口一个实例,资源实例总数不超过可见端口数;工序数不超过原始步骤数。该内部成本界限不删除步骤或原始端口,辅料和副产物仍留在工序详情。查询已截断时继续显示准确的覆盖提示,不显示“完整生产链”。 + +## 验证与实施顺序 + +自动验证覆盖原生引用、层级/循环、连续链、局部副本和排线,随后在共享面板中检查原生交互与可读缩放。只有真实样例证明需要时再调副本阈值,避免以某个工艺名称增加布局特判。 + +| 场景 | 必须满足的结果 | +| --- | --- | +| 八步链、多种替代配方 | 连续路线可直接沿箭头读;全部原始步骤保留,外观相同路线只显示一次 | +| 多输入、多输出、概率与未知角色 | 所有端口属于正确工序,隐藏辅料和副产物仍可在普通配方查询中查看,概率和约束不被共享节点覆盖 | +| 高连接度原料与副产物 | 优先共享同一资源,只有明显长连接才使用副本,标记可见;统计能区分事实数与实例数 | +| 未分类的新处理方式 | 仅提供合法输入输出即可排布;改名、换语言或新增 method 不要求增加分区规则 | +| 回收环、自环、无外部入口的环 | 布局终止,无伪造来源;反馈边及副本仍保留原始方向和回流标记 | +| 相同图标,不同原生状态或 selector | 原始约束与导航目标保留,不产生伪关联或任意替换 | +| 同名机器、同 A/B,条件或辅料不同 | 总览合并相同外观,保留所有原始步骤;图标点击执行普通来源/用途查询 | +| 纯符号资源、未知来源、未确认连接 | 保留节点与范围说明,不猜世界生成,不把回流等同于未确认 | +| 百步及接近现行上限的图 | 节点/文字不重叠,箭头不穿节点;保持可读比例,布局成本有界 | +| 相同快照打乱输入顺序 | 布局稳定;每个输入输出均能反查到原始端口 | +| 缩放、平移、GUI 缩放与重载 | 命中和图标一致,旧快照无法跳转,无离屏误删 | + +拓扑自动检查应验证:每个原始步骤均能反查对应路线实例、所有可见端口可反查,隐藏端口保留在详情、布局不新增逻辑关联、副本可反查、包围盒不相交、前向边满足层级、反馈关系保持,以及相同输入的确定性。截图与性能记录应包括逻辑节点/关联数、副本数、布局耗时、画布尺寸、GUI 缩放和实际可读比例;不能只以编译通过判定可读性。 + +实现后的检查命令按[验证入口](validation/README.md)路由选择。人工检查覆盖 Forge/NeoForge、JEI-only/EMI-only/双装、无 viewer 专用服务端及远程客户端;使用[矿物处理展示页检查](validation/checks/manual-ingame.md#矿物处理展示页)并在实现时同步其旧分区、共享唯一节点和辅料变体切换预期。测试数据只放在已接入的测试位置,不写入生产配方表。 + +当前拓扑、确定性、副本、循环与交互坐标可由自动检查验证;真实材料图、游戏内小视口、两平台 viewer 交互和运行性能均尚未按本设计人工验收。完成接入时同步[展示接入](material-process-display.md)的现行行为说明与相关检查文档;不得提前把本文的目标行为写成已经实现。 diff --git a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md index 5e90725de..905cad7e3 100644 --- a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md +++ b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md @@ -16,7 +16,7 @@ | `SourceExtrusionRules.DATA` | `SourceExtrusionMaterialFacts` | `SourceExtruderRecipes`、`MaterialPrefix`、`MaterialPrefixes` | 挤压能力、锻造目标和可锻性归入材料事实;数量计算与配方向 recipe 门面保留 | | `SourceOreMacerationFacts`、`SourceOreWashingData`、`SourceOreCrushingFacts` | `SourceMacerationMaterialFacts`、`SourceWashingMaterialFacts`、`SourceOreCrushingMaterialFacts`、`OreHostFacts` | 研钵、洗矿、Crusher/Hammer、OilSand | 材料能力与宿主岩石事实分开;Hexorium 产物策略仍留 recipe | | `SourceLensRoles.ROLES` | `SourceLensMaterialFacts` | `ElectronicsRecipes`、`LaserStoneRecipes` | 透镜颜色角色进入材料 process;原生物品解析留在 `SourceLensRecipeItems` | -| `OriginalMaterialFluidUnits`、`SourcePurifiedAcidData.Phase` 的绑定字段、`PurifiedCentrifugeMaterialFacts` 的重复流体字段 | `MaterialFluidUnitFacts` | 分解、酸洗、离心、热回收、洗矿、化学解析 | 流体身份、相态和单位只由 `MATERIAL_FLUID_UNIT` 提供;配方枚举保留材料选择与工艺配比,不再保存第二份原生字段/单位 | +| `OriginalMaterialFluidUnits`、`SpecialProcessData.Phase` 的绑定字段、`PurifiedCentrifugeMaterialFacts` 的重复流体字段 | `MaterialFluidUnitFacts` | 分解、酸洗、离心、热回收、洗矿、化学解析 | 流体身份、相态和单位只由 `MATERIAL_FLUID_UNIT` 提供;API 1.9 的 target/reagent typed rules 保留材料选择与工艺配比,不再保存第二份原生字段/单位 | | `PanelMaterialRegistration`、`TransportMaterialRegistration` | `PanelMaterialCompositions`、`TransportMaterialCompositions` | `MaterialItemCompositions`、`VanillaRecoveryRecipes` | 固定成分安装不再由 recipe 生产类承担 | | `RegisteredWoodSurvivalRecipes.registerMaterials()`、`VanillaWoodProcessingRecipes.registerMaterials()`、`DiggableRecipes.registerMaterials()`、单物品与空胶囊写入 | `WoodMaterialCompositions`、`MaterialItemCompositions` | 木材、黏土、食物条、化合物和空胶囊回收 | 固定成分在配方发布前显式登记;配方类只发布配方 | | `MaterialTooltips.appendForeign()` 的失效回收分支 | 04 有效成分快照 | 普通/高级 tooltip | 删除 `composition_nonmaterial`、`composition_descriptive` 及其语言键 | diff --git a/docs/development/material-system-refactor/07-recipe-package-audit.md b/docs/development/material-system-refactor/07-recipe-package-audit.md index a393ae1e2..eefc36694 100644 --- a/docs/development/material-system-refactor/07-recipe-package-audit.md +++ b/docs/development/material-system-refactor/07-recipe-package-audit.md @@ -31,7 +31,7 @@ | Minecraft [SharedPurifiedCentrifugeRows](../../../minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedCentrifugeRows.java) | 六条相态记录与七条显式无默认相态记录 | 已迁入 `PurifiedCentrifugeMaterialFacts` 的两个材料 process;原生注册字段/所有权、离心槽位、概率、重载发布和兼容分支仍留 recipe | | [MaterialFluidUnitFacts](../../../core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java) 与 core `engine.recipe.chem.MaterialFluidBinding` | 材料相态/单位/流体身份绑定,后者从材料视图和流体目录建立索引 | 绑定事实进入 `MATERIAL_FLUID_UNIT` process;`UnitConversion` 只保留换算机制 | | Minecraft [SourceThermalNativeAdapter](../../../minecraft/src/main/java/gregtech/content/recipe/SourceThermalNativeAdapter.java) 的 `nativeBinding()` | Glass、Blaze、Plastic、Ender、Redstone、Lava、CFoam、蜡及熔盐等原生字段/ID | 精确字段和单位从 `MaterialFluidUnitFacts` 查询;特殊原生持有检查与配方适配仍在游戏侧 | -| core [SourcePurifiedAcidData](../../../core/src/main/java/gregtech/content/recipe/SourcePurifiedAcidData.java) | 酸洗 `Phase` 的材料选择;`MANGANESE_DEFAULTS` 中重复的材料副产物快照 | `Phase` 的原生字段、相态和 1000 mB/U 已归入 `MaterialFluidUnitFacts`,recipe 只保留材料选择器。酸洗 `FAMILIES` 的共同反应物、配比和尾产物继续保留。`manganeseDefaults()`/`matchesManganeseDefault()` 未找到外部调用,但 `reviewedIdentity()` 仍使用默认表确认身份,不能把整表当死测试数据删除;先拆出仍生效的身份范围,再决定默认快照是否进入测试 | +| core [SpecialProcessData](../../../core/src/main/java/gregtech/content/recipe/SpecialProcessData.java) 与 `SpecialProcessMaterialFacts` | 酸洗 `Phase` 的材料选择、固定 target/reagent 规则和动态锰规则 | `Phase` 的原生字段、相态和 1000 mB/U 归入 `MaterialFluidUnitFacts`;酸洗材料列表、共同反应物、配比和尾产物通过 API 1.9 的 `SpecialProcessValue.Target/Reagent` 挂到 typed process。旧 `SourcePurifiedAcidData`、`SourcePurifiedAcidRules` 与 `SharedPurifiedAcidRows` 已删除 | | core [SourceRollingWireRules](../../../core/src/main/java/gregtech/content/recipe/SourceRollingWireRules.java) 的 `physicalWire()` | Netherite/Naquadah 的额外线材族准入 | 已迁入 `SOURCE_ADDITIONAL_WIRE_FAMILY`;轧制/拉丝模板、工时与实际线材族注册仍留 recipe | | Minecraft [MaterialFormConversionRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/MaterialFormConversionRecipes.java) 的 `compressor()` | Ice 的 `dust → plateGem` 排除 | 已迁入 `COMPRESSOR_DUST_TO_GEM_PLATE`,与筛矿高级宝石限制保持独立;装箱、拆箱、压缩模板仍留 recipe | | core `OreHostFacts` 的 `HOSTS`/`BROKEN_SOURCE_PAIRS` | 宿主岩石、矿石 prefix、4U 脉石和破碎矿块表示关系;`SourceOilSandRules` 也消费 | 已位于石材内容声明;原生 host ID 解析和机器对脉石的产出策略仍留 recipe;不写入矿物化学组成 | @@ -56,7 +56,7 @@ | 对象 | 保留原因与边界 | | --- | --- | -| `GTChemRecipes` 的铝土矿高压釜、`SourcePurifiedAcidData.FAMILIES`/`SourcePurifiedAcidRules` | 明确反应物、流体、比例和产物的特殊化学工艺;共用材料不等于材料属性。仅抽离重复身份/单位绑定 | +| `GTChemRecipes` 的铝土矿高压釜、`SpecialProcessData` 的 fixed families | 明确反应物、流体、比例和产物的特殊化学工艺;共用材料不等于材料属性。target/reagent 规则进入 API 1.9,重复身份/单位绑定仍由材料目录提供 | | `SourceAlloyRecipes`、`SourceOilSandRules`、`SourceOreSiftingRules.specialRows()`、`SourceOreMagneticRules.blockRows()` | 显式合金、油砂事件、特殊筛矿和固定磁选路线;输入/输出/概率就是配方内容,不因含材料名单而整体材料化 | | `TechnologyIngredients.PISTON_METALS`、`craftingRedstone()` | 工艺局部的原料替代集合和形态选择。可以声明为配方专用组,不能由此推导全局“可做所有机械零件”能力,也不能合并不同语义的 `Any*` 组 | | `PolarizerMaterialRecipes` 的材料对、`BathMaterialRecipes` 的材料转化与流体、`UtilityProcessingRecipes` 的木材提取产率 | 当前表达具体工艺的输入/输出或用量;应保留为配方关系。若以后确认为跨消费者的通用 target,可另行收敛声明,不能仅凭材料名称硬编码认定应全局化 | @@ -66,7 +66,7 @@ ## 五、实施顺序与验收补充 1. 通用目标、挤压、透镜、研钵、洗矿、相态单位和固定成分写入已完成迁移。 -2. `MaterialWorkability`、`SourceLatheMaterialProfiles`、`SourcePurifiedAcidData` 等混合对象仍需在 07-E 定向审计中逐字段裁决去留;没有足够来源时保留并记录缺口。 +2. `MaterialWorkability`、`SourceLatheMaterialProfiles` 等混合对象仍需在 07-E 定向审计中逐字段裁决去留;特殊处理系列已迁移到 API 1.9,不再保留酸洗专用声明 API。 3. 对局部工艺例外继续按“材料加工声明”或“显式配方声明”裁决;不能用全局 flag 扩大效果。 源码中的数量注释也需要核实:`SourceOreMacerationFacts` 注释写 589 个正例/997 个身份,实际集合为 588 个正例加 408 个负例;`SourceOreWashingData` 注释中的 59/159 等口径与实际 142 个身份行、54 个含正例 tag 的身份不一致。酸洗相态迁移时确认实际枚举为 17 个,旧注释的 18 已修正。 diff --git a/docs/development/material-system-refactor/08-material-data-api.md b/docs/development/material-system-refactor/08-material-data-api.md index 812e67c83..128ad0c8e 100644 --- a/docs/development/material-system-refactor/08-material-data-api.md +++ b/docs/development/material-system-refactor/08-material-data-api.md @@ -64,7 +64,7 @@ ## C:形态视图与资源 tag 桥接 -状态:已实施本轮内容快照范围。API 1.7 将定义期规则扩展为 item/block/fluid,发布运行期实际绑定并把显式统一物品纳入实际表示;当前 API 1.8 继续提供同一形态快照契约。规则资源与兼容资源保持区分。平台注册后发布内容快照与资源 tag 桥接声明,外部 tag 成员仍作为 04 的低优先级候选输入。 +状态:已实施本轮内容快照范围。API 1.7 将定义期规则扩展为 item/block/fluid,发布运行期实际绑定并把显式统一物品纳入实际表示;当前 API 1.9 继续提供同一形态快照契约,并增加 cross-material special process 方法、target/reagent 规则和派生标签。规则资源与兼容资源保持区分。平台注册后发布内容快照与资源 tag 桥接声明,外部 tag 成员仍作为 04 的低优先级候选输入。 2026-11-11 审查闭合:外部 tag generation 通过统一候选裁决后立即刷新公开形态绑定;冲突项在导入阶段带物品 ID 和声明差异记录。Forge 与 NeoForge 的审计探针均观察到新增 tag 表示进入 `formBindings()`,撤销后退出。 @@ -145,7 +145,7 @@ D 的查询结果必须绑定一个完整发布上下文:`MaterialPublication. ## E:有界矿物处理图与消费者迁移 -已提供 core 有界语义图、共享 Minecraft 投影、与 viewer 无关的布局以及 JEI/EMI 分类。构造字段、角色、概率、分页、折叠、交互和生命周期契约统一见[矿物处理 JEI 展示接入](../material-process-display.md)。`unbound()` 现在只在没有成功发布快照时作为显式空状态,不再由正式注册路径常驻。 +已提供 core 有界语义图、材料页直连查询、共享 Minecraft 投影、与 viewer 无关的可平移布局以及 JEI/EMI 分类。构造字段、角色、概率、三区分区、工艺组折叠、交互和生命周期契约统一见[矿物处理图展示接入](../material-process-display.md)。`unbound()` 现在只在没有成功发布快照时作为显式空状态,不再由正式注册路径常驻。 ### 接入链 @@ -159,7 +159,7 @@ D 已发布来源/用途索引 职责边界: -- D 决定哪些关系存在及覆盖范围;E 决定如何在预算内查询和截断;展示层只做分页、布局、索引与交互,不读取配方表、材料目录或世界生成数据。 +- D 决定哪些关系存在及覆盖范围;E 决定如何在预算内查询和截断;展示层只做分区、平移、工艺组折叠、索引与交互,不读取配方表、材料目录或世界生成数据。 - core 图先按查询预算完成遍历并返回不可变结果,再由内容适配器构造展示值。`MaterialProcessDisplay` 的 64 步、128 条关联、每步每侧 64 个端口和每端口 16 个图标是展示上限,不能代替图遍历的深度、节点、端口和边预算,也不能先枚举完整候选再截断。 - 一个步骤保存联合输入与全部输出;主路线仅是布局提示,不得从槽位顺序推断主/副角色。未知角色、未知概率、未解析条件和部分覆盖必须继续可见,不能为了画出完整路线改写成确定边。 - 图边只来自 D 的关系或明确确认的适配关系。显示层不得按相同图标补边,不把 tag/unit 代表图标当成候选全集,也不从显示图反向生成配方或授权。 @@ -176,9 +176,11 @@ D 已发布来源/用途索引 ### 实施结果 -- `MaterialProcessGraph` 在 core 中按 `SOURCES`、`USES`、`BOTH` 遍历,使用跨材料共享索引,限制深度、步骤、每侧端口和关联数量;循环按步骤访问集终止,稳定保留截断原因。 +- `MaterialProcessGraph` 在 core 中保留 `SOURCES`、`USES`、`BOTH` 递归遍历,并新增材料级直连查询:覆盖该材料全部形态的直接步骤,但不沿另一材料继续递归,限制步骤、每侧端口和关联数量;循环按步骤访问集终止,稳定保留截断原因。 - `MaterialProcessProjection` 只把已查询结果转成展示值。物品、流体、tag 和 unit 选择器保持独立引用;tag/unit 只提供有限代表,不展开候选全集。 +- API 1.9 增加 `SpecialProcessMethod`/`SpecialProcessValue`:辅料与目标材料使用同一 typed process key,`Target` 提供配方计划,`Reagent` 标记辅料输入。`SharedSpecialProcessRows` 生成并标记最终配方,`MaterialTagPack` 从相同规则派生 target/reagent 资源 tag。旧 `SourcePurifiedAcidData`、`SourcePurifiedAcidRules` 与 `SharedPurifiedAcidRows` 已删除。 - JEI 与 EMI 共用 `MaterialProcessPanel` 和同一 `Page` 列表。工艺点击定位当前快照中的原生机器配方,资源左右击重新查询该快照的形态来源/用途。 +- `MaterialProcessPanel` 只折叠携带 method ID 的步骤;原先按步骤名达到阈值折叠的规则已删除,普通配方直接平铺。 - JEI 与 EMI 的分类仅由客户端注册;`MaterialProcessSnapshot` 与 core 图不引用 viewer 类型,专用服务端可独立构建和查询。 ### 独立验收 diff --git a/docs/development/material-system-refactor/README.md b/docs/development/material-system-refactor/README.md index bb8c50c92..02ff7ec92 100644 --- a/docs/development/material-system-refactor/README.md +++ b/docs/development/material-system-refactor/README.md @@ -85,4 +85,4 @@ | 多组件热回收、输出槽限制与无法表示的余量 | 05、06 | 逐机器核对规则,不要求所有工艺都产出全部成分 | | chain、minecartWheels 及兼容 prefix 的去留 | 07 | 同时检查实际消费端、外部声明契约和已有存档影响 | -01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收;07 已完成首轮内部清理和 07-E 全量材料/形态去留裁决;08 已完成静态机器配方、活动世界生成、符号选择器和两 viewer 的共享处理图接入。07-F 仍由双平台运行期与人工验收闭合。本页不替代现行架构或已接受的决策。 +01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收;07 已完成首轮内部清理和 07-E 全量材料/形态去留裁决;08 已完成静态机器配方、活动世界生成、符号选择器和两 viewer 的共享处理图接入,并通过 API 1.9 接入纯化酸 target/reagent 规则与通用特殊工艺 producer。07-F 仍由双平台运行期与人工验收闭合。本页不替代现行架构或已接受的决策。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index c599e83e6..31282ef29 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -22,13 +22,16 @@ 接口与测试输入契约见[展示接入](../../material-process-display.md)。生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用同一图和面板;没有成功快照时才显示未接入说明。 -1. 在 JEI 或 EMI 中打开“矿物处理”,用真实 ore/raw/crushed 材料确认来源和加工步骤。分别使用中英文及不同 GUI 缩放检查边界、文字和悬停命中。 -2. 用洗矿、合金和电解/离心检查共同原料、全部产物、量与单位、随机副产物和条件 tooltip。模具、工具等辅助物品保留在步骤说明和原配方中,不展开为总览路线;未知材料形态的普通原料仍须显示原生引用。 -3. 检查符号端口、未知概率、未解析工艺和超过六个的侧排端口;确认问号、虚线、概率提示与折叠信息。折叠端口的代表仍可通过 viewer 原生检索找到。 -4. 检查分支、跨材料步骤、跨页边、回边和自环;只有显式关联产生跨步骤中心箭头。两档候选规模下,代表图标与查询预算不随候选笛卡尔积增长。 -5. 左右击资源分别查询来源/用途,左击工艺精确打开原配方。EMI 动态查询超过两步时,左右击右上角页码确认所有页面都可到达。连续重载两次后重新打开页面,确认配方增删同步生效、旧引用拒绝,断线/换服不沿用旧回调。 -6. 两平台分别检查 JEI-only、EMI-only 和双装环境。双装继续采用既有 JEI 桥去重规则,以 EMI 原生矿物页为入口;不能把 JEI 中被去重的页面算作内容丢失。 -7. 另验无 viewer 的专用服务端与独立远程客户端;远程图必须来自同代同步事实,不能用集成服务器共享静态表证明同步正确。当前未记录的远程、截图和点击场景均为未验证。 +1. 在 JEI/EMI 中打开真实材料的“矿物处理”。页面应直接显示依赖图,没有分类分栏。连续链水平向右,替代路线和分叉就近分行;未分类步骤、无外部入口环及自环不能消失。不同 GUI 缩放下右侧、底部裁剪正确。 +2. 切割机三种润滑剂相同主物品/机器图标/产物时只显示一条路线,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。物品和机器均左击普通来源、右击普通用途,不精确锁定原配方;常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。数量、概率、时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 +3. 资源局部副本带 `↗`,回流带 `↩`,悬停同步突出相关实例和箭头。相同显示代表跨 selector 共享节点,不同 NBT/组件状态分开;同图标不能补造跨步骤关联。连接均为单段直线,分支斜向相连,输入无箭头、输出有箭头;遮挡图标的长边和回流改用局部副本,没有顶部回流通道。确认关系不因循环改为虚线。 +4. 对带 NBT/组件物品与真实流体,逐个副本检查左/右击、R/U、tooltip 和 EMI ingredient provider;流体代理应查询实际流体。各节点使用实际显示的完整物品/流体状态查询,无法恢复时保留符号,不用无数据假栈。 +5. 来源/内部转换/去向仅在工序 tooltip 说明;“本材料+辅料 → 本材料其他形态+副产物”仍属内部转换。工具、存在条件及额外辅料/副产物均不扩展生产路线。主材料的多输入、多输出分支仍保留。 +6. 大图初始和复位保持至少 75% 可读比例并定位代表链;小图适配视口。滚轮围绕鼠标缩放,顶部 `−/+` 缩放;空白处左右、上下拖动有效。在 100%、25% 和约 8% 比例下确认线宽、虚线间距及箭头与图标同比缩小,不出现盖住整图的固定尺寸箭头。缩放和平移后,图标、`+`、tooltip、点击及 EMI 悬停命中一致。 +7. 连续重载两次后确认配方增删同步、旧引用拒绝跳转;断线/换服不沿用回调。布局副本数不改变配方数量或原生 viewer 索引;方法标签只来自 API target/reagent 声明。 +8. 两平台分别检查 JEI-only、EMI-only 和双装环境,双装沿既有去重规则。另验无 viewer 的专用服务端与独立远程客户端;未实际执行的场景不能用编译或集成服务器静态表代替。 + +`MaterialProcessSnapshotTests` 中的 `presentationPreservesNativeItemState`、`overviewGroupsVisibleRoutesAndHidesAuxiliaries`、`overviewAlignsChainsAndPreservesFeedback`、`overviewSharesHubsWithoutInventingConnections` 和 `overviewKeepsDenseEdgesLocal` 覆盖原生状态、锤子分类图标、辅料隐藏、原始步骤保留、外观去重、公共资源集中、连续链、顺序稳定、循环、副本、密集图直线避让和关联保留。编译这些测试不代表已运行 GameTest;箭头外观、真实 EMI 查询和鼠标手感仍需人工确认。 ## 注意事项 diff --git a/docs/integration/material-process-snapshot.md b/docs/integration/material-process-snapshot.md index e59ee2426..954bb1bd4 100644 --- a/docs/integration/material-process-snapshot.md +++ b/docs/integration/material-process-snapshot.md @@ -4,7 +4,7 @@ 本页记录材料来源/用途快照、core 图及 viewer 投影的代码核对与回归方法。状态:部分验证;不能据此把[计划 08](../development/material-system-refactor/08-material-data-api.md)整体标为完成。 -源码依据:`de16ac298`、`8722ac629` 与其上的工作区修复。此次仅调整展示索引、发布时机、查询预算和展示交互;没有修改机器执行配方、材料成分、注册 ID、存档或网络协议。公共 API 版本保持 1.8.0。 +源码依据:`de16ac298`、`8722ac629` 与其上的工作区修复。当前实现增加 API 1.9 的 cross-material special-process 声明、target/reagent typed rules、派生标签、通用配方 producer 和 method-aware 展示折叠;没有修改注册 ID、存档或网络协议。 ## 已确认问题与处理 @@ -18,8 +18,10 @@ | 仅在根材料分桶内遍历 | 分解、合金和副产物进入另一材料后路线停止。改为一个跨材料索引,查询仍受同一深度、步骤、端口和边预算限制。 | | 预算裁剪后仍输出关联 | 关联可能指向已裁掉的端口,导致展示构造拒绝整个查询。返回边只引用保留下来的端口;深度边界和非展开侧的端口裁剪也报告部分覆盖。根候选不先复制全集再截断。 | | 资源 `DataKey` 可跨快照复用 | 新代查询可能接受旧资源。资源引用加入每次构建的作用域,原生导航仍校验当前快照;服务器停止和客户端断线清理 Store。 | +| 特殊系列依赖名称与手写生成器 | API 1.9 用 `SpecialProcessMethod` + `MaterialProcessKey` 声明目标材料、辅料、配方表和展示名。Target 规则生成配方并携带 method ID;手工旧行也按同一规则匹配。材料图只折叠带 method ID 的步骤。 | +| target/reagent 标签与配方声明双写 | target/reagent 材料 tag 从 typed process 规则派生,item/fluid tag 再按规则表单生成,避免维护第二份名单。 | | 普通无形态原料/产物被静默跳过 | 保留原生物品/流体端口及未分类说明,不把单一图标推断成某种材料;带额外原生条件的输入不与无条件资源合并。 | -| EMI 动态查询只显示第一页 | 来源/用途查询保存全部页,左右击右上角页码切换;初始分类继续使用原生分页。 | +| EMI 动态查询只显示第一页 | 来源/用途查询改为一种材料一张页;JEI 与 EMI 共用可平移图,不再按两个步骤拆页或维护配方级页码。 | | 文档状态矛盾与两节点导入顺序错误 | 更新设计状态、人工验收步骤及包入口;修复 Spotless 报告的导入顺序。 | 模具、工具等辅助物品不扩展为总览资源路线,其数量、状态引用与原配方保留在步骤说明/原生配方中。这与普通消耗原料不能静默消失是两种情况。图不会因为工具没有材料成分而虚构一条工具生产链。 @@ -46,8 +48,8 @@ git diff --check ## 验证结果与剩余事项 -- 执行且通过:材料图 JUnit 6 项,最近两次提交范围内的格式检查,双平台生产/测试源码编译,路由与注释检查、`git diff --check`。 -- 执行但失败或阻塞:首轮运行暴露工作区修复中的静态初始化顺序问题;随后一轮发现新增复用测试的前置上下文不一致,均已修正。最终 GameTest 结果待核对。 -- 尚未执行:独立远程客户端、JEI-only/EMI-only/双装点击及截图、无 viewer 的独立服务端、附属差异与世界生成开关矩阵;发行包检查待执行。 +- 执行且通过:`MaterialProcessGraphTest` 7 项;API `SpecialProcessValueTest` 与 `apiContracts`;材料页单测覆盖全部形态直连、跨区边和停止于另一材料。GameTest 从实际加载的物品/流体标签系统确认王水 target tag 只含声明的 purified 形态,reagent tag 只含王水液体。Spotless、双平台生产/测试源码编译、双平台发行包组装、Forge 99 项 GameTest、NeoForge 104 项 GameTest、资源 JSON 与发行 JAR 检查、路由和注释检查均通过。 +- 执行但失败或阻塞:无。 +- 尚未执行:独立远程客户端、JEI-only/EMI-only/双装实际拖拽、工艺组展开与截图、无 viewer 的独立客户端、附属差异与世界生成开关矩阵。 -08 的 A—C 已有定义与形态入口;D—E 已有内部来源/用途快照、符号选择器和共享图代码,但尚不能标为全部验收完成。tag/unit 保持符号投影,不能声称枚举了全部动态工艺或完整可执行路线;本轮不新增公共 API 服务或网络同步协议。远程同代数据、断线/换服、实际 viewer 分页与精确跳转仍需要按[人工检查](../development/validation/checks/manual-ingame.md#矿物处理展示页)记录实际结果。局部图模型通过不能替代这些场景。 +08 的 A—C 已有定义与形态入口;D—E 已有内部来源/用途快照、符号选择器、共享材料页图和 API 1.9 的显式特殊工艺所有权。tag/unit 仍保持符号投影,不能声称枚举了全部动态工艺或完整可执行路线;本轮不新增网络同步协议。远程同代数据、断线/换服、实际 viewer 拖拽/折叠与精确跳转仍需要按[人工检查](../development/validation/checks/manual-ingame.md#矿物处理展示页)记录实际结果。局部图模型通过不能替代这些场景。 diff --git a/minecraft/AGENTS.md b/minecraft/AGENTS.md index 3f58638d7..a99c2fa74 100644 --- a/minecraft/AGENTS.md +++ b/minecraft/AGENTS.md @@ -3,7 +3,7 @@ 先遵守[根指南](../AGENTS.md),按任务读[运行时包](../docs/architecture/packages/runtime.md)、[平台适配](../docs/architecture/packages/platforms.md)和[跨版本指南](../docs/architecture/versions.md)。 - 共享输入在本目录 `src/`;版本输入在 `versions//src/`。同名包不代表文件可放任意源码目录。 -- 公开游戏 API 位于仓库内 `api/minecraft/src/main/`(内联自 GregTech6API a9c879176,基线 API 1.2.0;当前 API 1.8.0),由 `:api-platform:` 编译;本目录只依赖其输出,不再维护 `src/api` 副本。 +- 公开游戏 API 位于仓库内 `api/minecraft/src/main/`(内联自 GregTech6API a9c879176,基线 API 1.2.0;当前 API 1.9.0),由 `:api-platform:` 编译;本目录只依赖其输出,不再维护 `src/api` 副本。 - 当前 Stonecutter 活动节点为 `1.20.1-forge`。保留条件标记,尽量用小范围条件分支处理差异;整类差异才考虑版本节点实现。 - `versions/*/build/generated/stonecutter/` 是生成结果,只读检查,不手工修复。新增同名类前检查共享输入和两节点,避免重复类。 - 渲染、模型、屏幕及客户端事件留在 `gregtech.client` 和明确的客户端初始化路径,公用静态初始化不引用客户端类型。 diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessArrows.java b/minecraft/src/main/java/gregtech/client/MaterialProcessArrows.java new file mode 100644 index 000000000..fffcd228e --- /dev/null +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessArrows.java @@ -0,0 +1,24 @@ +package gregtech.client; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.RenderType; + +/** Filled geometry avoids the disconnected bars produced by a rotated pixel-chevron head. */ +public final class MaterialProcessArrows { + private MaterialProcessArrows() {} + + public static void head(GuiGraphics graphics, int color) { + var vertices = graphics.bufferSource().getBuffer(RenderType.gui()); + var matrix = graphics.pose().last().pose(); + float[][] points = {{0, 0}, {-4, -2.2f}, {-4, 2.2f}, {-4, 2.2f}}; + for (float[] point : points) { +//? if >=1.21.1 { + /*vertices.addVertex(matrix, point[0], point[1], 0) + .setColor((color >> 16) & 255, (color >> 8) & 255, color & 255, (color >>> 24) & 255); +*///?} else { + vertices.vertex(matrix, point[0], point[1], 0) + .color((color >> 16) & 255, (color >> 8) & 255, color & 255, (color >>> 24) & 255).endVertex(); +//?} + } + } +} diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java index 23fadd2d5..4e188dd3a 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java @@ -1,237 +1,291 @@ package gregtech.client; -import gregtech.api.addon.recipe.RecipeOutputChances; +import com.mojang.math.Axis; import gregtech.compat.common.MaterialProcessDisplay.Page; -import gregtech.compat.common.MaterialProcessDisplay.Port; -import gregtech.compat.common.MaterialProcessDisplay.Role; -import gregtech.compat.common.MaterialProcessDisplay.Step; +import gregtech.compat.common.MaterialProcessOverview; +import gregtech.compat.common.MaterialProcessOverview.Node; +import gregtech.compat.jei.PreviewViewport; import java.util.ArrayList; import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; -/** Viewer-independent geometry and rendering; native ingredient widgets use exactly these slot positions. */ +/** A readable viewport onto the cached topology layout and its native port instances. */ public final class MaterialProcessPanel { public static final int WIDTH = 280, HEIGHT = 216; - public static final int HEADER = 30, STEP_HEIGHT = 80, FOOTER = 196; - private static final int SIDE_LIMIT = 6; - private static final int MAIN_X = 132, STEP_X = 103, STEP_WIDTH = 74; - private static final int TEXT = 0xff404040, MUTED = 0xff707070, ACCENT = 0xff537962; + private static final int BODY_TOP = 17, FOOTER = 203; + private static final int TEXT = 0xff383838, MUTED = 0xff777777, GOLD = 0xffffcc44; + private static final double MIN_ZOOM = 0.0001, MAX_ZOOM = 3; + private final Page page; + private final MaterialProcessOverview overview; + private double zoom, panX, panY; - public record Slot(Port port, int x, int y, boolean output) { - public boolean contains(double mouseX, double mouseY) { - return mouseX >= x && mouseX < x + 16 && mouseY >= y && mouseY < y + 16; + public MaterialProcessPanel(Page page) { + this.page = page; + overview = new MaterialProcessOverview(page); + fit(); + } + + public void draw(GuiGraphics graphics, double mouseX, double mouseY) { + graphics.fill(0, 0, WIDTH, HEIGHT, 0xffc6c6c6); + text(graphics, page.title(), 4, 2, WIDTH - 122, TEXT); + text(graphics, Component.literal("−"), WIDTH - 114, 2, 12, TEXT); + text( + graphics, + Component.literal(java.math.BigDecimal.valueOf(zoom * 100) + .setScale(zoom < 0.01 ? 2 : 0, java.math.RoundingMode.HALF_UP) + .stripTrailingZeros() + .toPlainString() + + "%"), + WIDTH - 98, + 2, + 33, + MUTED); + text(graphics, Component.literal("+"), WIDTH - 61, 2, 12, TEXT); + text(graphics, Component.translatable("gt6ce.jei.material_process.reset"), WIDTH - 28, 2, 26, MUTED); + graphics.flush(); + var viewport = PreviewViewport.screenBounds(graphics.pose().last().pose(), 0, BODY_TOP, WIDTH, FOOTER); + graphics.enableScissor(viewport.left(), viewport.top(), viewport.right(), viewport.bottom()); + Node hovered = hit(mouseX, mouseY); + try { + graphics.pose().pushPose(); + try { + graphics.pose().translate(panX, BODY_TOP + panY, 0); + graphics.pose().scale((float) zoom, (float) zoom, 1); + drawEdges(graphics, hovered); + for (Node node : overview.nodes()) { + if (!visible(node)) continue; + if (related(node, hovered)) + graphics.fill(node.x - 10, node.y - 10, node.x + 11, node.y + 11, 0xffe5e5e5); + ItemStack icon = node.machine() + ? selected(node).icon() + : node.port().icons().stream().findFirst().orElse(ItemStack.EMPTY); + if (icon.isEmpty()) text(graphics, Component.literal("?"), node.x - 3, node.y - 4, 10, MUTED); + else graphics.renderItem(icon, node.x - 8, node.y - 8); + if (node.machine() && node.extra()) smallText(graphics, "+", node.x + 9, node.y - 12, GOLD, false); + if (!node.machine() && (node.copy || node.returning)) + smallText(graphics, node.returning ? "↩" : "↗", node.x + 8, node.y - 12, MUTED, false); + } + } finally { + graphics.pose().popPose(); + } + } finally { + graphics.flush(); + graphics.disableScissor(); } + if (overview.nodes().isEmpty()) + graphics.drawWordWrap( + Minecraft.getInstance().font, + Component.translatable("gt6ce.jei.material_process.empty"), + 12, + BODY_TOP + 28, + WIDTH - 24, + MUTED); + text(graphics, Component.literal("i"), 4, FOOTER + 3, 12, MUTED); } - private MaterialProcessPanel() {} + private gregtech.compat.common.MaterialProcessDisplay.Step selected(Node node) { + return node.steps.get(0); + } - public static List slots(Step step, int row) { - var slots = new ArrayList(); - addSlots(slots, step.inputs(), row, false); - addSlots(slots, step.outputs(), row, true); - return List.copyOf(slots); + private static boolean related(Node node, Node hovered) { + return node == hovered + || hovered != null + && !node.machine() + && !hovered.machine() + && node.port().identity().equals(hovered.port().identity()); } - private static void addSlots(List slots, List ports, int row, boolean output) { - int side = 0; - for (var port : ports) { - if (port.main()) { - slots.add(new Slot(port, MAIN_X, HEADER + row * STEP_HEIGHT + (output ? 57 : 0), output)); - } else if (side < SIDE_LIMIT) { - slots.add(new Slot( - port, - (output ? 202 : 10) + side % 3 * 23, - HEADER + row * STEP_HEIGHT + 23 + side / 3 * 24, - output)); - side++; - } - } + private boolean visible(Node node) { + return node.x + 12 >= worldX(0) + && node.x - 12 <= worldX(WIDTH) + && node.y + 12 >= worldY(BODY_TOP) + && node.y - 14 <= worldY(FOOTER); } - public static void draw(Page page, GuiGraphics graphics, double mouseX, double mouseY) { - text(graphics, page.title(), 2, 1, WIDTH - 42, TEXT); - text(graphics, Component.literal(page.number() + "/" + page.total()), WIDTH - 38, 1, 38, MUTED); - text(graphics, Component.translatable("gt6ce.jei.material_process.inputs"), 5, 16, 90, MUTED); - text(graphics, Component.translatable("gt6ce.jei.material_process.route"), 103, 16, 75, ACCENT); - text(graphics, Component.translatable("gt6ce.jei.material_process.outputs"), 194, 16, 86, MUTED); - for (int row = 0; row < page.steps().size(); row++) { - var step = page.steps().get(row); - int top = HEADER + row * STEP_HEIGHT; - int color = step.resolved() ? ACCENT : MUTED; - if (step.inputs().stream().anyMatch(Port::main)) - line(graphics, MAIN_X + 8, top + 17, MAIN_X + 8, top + 26, color, !step.resolved()); - graphics.fill( - STEP_X, - top + 26, - STEP_X + STEP_WIDTH, - top + 45, - processContains(row, mouseX, mouseY) ? 0xffd6e2d9 : 0xffe7e7e7); - text(graphics, step.name(), STEP_X + 3, top + 32, STEP_WIDTH - 6, color); - var displayed = slots(step, row); - for (var slot : displayed) { - int portColor = slot.port().role() == Role.BYPRODUCT ? 0xffb68a42 : color; - boolean uncertain = !step.resolved() - || slot.output() - && (slot.port().chance().isEmpty() - || slot.port().chance().getAsInt() < RecipeOutputChances.CERTAIN); - if (slot.port().main() && slot.output()) { - arrow(graphics, MAIN_X + 8, top + 53, portColor); - line(graphics, MAIN_X + 8, top + 45, MAIN_X + 8, top + 53, portColor, uncertain); - } - if (!slot.port().main()) { - int middle = slot.output() ? 188 : 88; - line( - graphics, - slot.output() ? STEP_X + STEP_WIDTH : STEP_X - 2, - top + 35, - middle, - top + 35, - portColor, - uncertain); - line(graphics, middle, top + 35, middle, slot.y() + 8, portColor, uncertain); - line( - graphics, - middle, - slot.y() + 8, - slot.output() ? slot.x() - 2 : slot.x() + 17, - slot.y() + 8, - portColor, - uncertain); - } - } - for (var slot : displayed) { - graphics.fill(slot.x() - 1, slot.y() - 1, slot.x() + 17, slot.y() + 17, 0xffa0a0a0); - graphics.fill(slot.x(), slot.y(), slot.x() + 16, slot.y() + 16, 0xffeeeeee); - if (!slot.port().hasIcons()) - text(graphics, Component.literal("?"), slot.x() + 5, slot.y() + 4, 10, MUTED); - if (!step.resolved() - || slot.output() - && (slot.port().chance().isEmpty() - || slot.port().chance().getAsInt() < RecipeOutputChances.CERTAIN)) - graphics.fill(slot.x() + 14, slot.y() - 1, slot.x() + 17, slot.y() + 2, 0xffc79c42); - } - overflow(graphics, step.inputs(), 5, top + 68); - overflow(graphics, step.outputs(), 202, top + 68); - long links = page.connections().stream() - .filter(connection -> connection.source().equals(step.reference()) - || connection.target().equals(step.reference())) - .count(); - if (links > 0) - text( - graphics, - Component.translatable("gt6ce.jei.material_process.links", links), - 153, - top + 65, - 45, - MUTED); - if (row + 1 < page.steps().size()) { - var next = page.steps().get(row + 1); - for (var connection : page.connections()) { - if (!connection.source().equals(step.reference()) - || !connection.target().equals(next.reference())) continue; - boolean mainOutput = step.outputs().stream() - .anyMatch(port -> port.main() && port.resource().equals(connection.resource())); - boolean mainInput = next.inputs().stream() - .anyMatch(port -> port.main() && port.resource().equals(connection.resource())); - if (mainOutput && mainInput) { - boolean uncertain = !connection.confirmed() - || !step.resolved() - || !next.resolved() - || step.outputs().stream() - .filter(Port::main) - .anyMatch(port -> port.chance().isEmpty() - || port.chance().getAsInt() < RecipeOutputChances.CERTAIN); - line(graphics, MAIN_X + 8, top + 74, MAIN_X + 8, top + 77, ACCENT, uncertain); - arrow(graphics, MAIN_X + 8, top + 77, ACCENT); - } - } - } + private Node hit(double mouseX, double mouseY) { + if (mouseX < 0 || mouseX >= WIDTH || mouseY < BODY_TOP || mouseY >= FOOTER) return null; + double x = worldX(mouseX), y = worldY(mouseY); + for (Node node : overview.nodes()) + if (x >= node.x - 10 && x <= node.x + 13 && y >= node.y - 14 && y <= node.y + 11) return node; + return null; + } + + public List stacksAt(double mouseX, double mouseY) { + Node node = hit(mouseX, mouseY); + if (node == null) return List.of(); + if (node.machine()) + return selected(node).icon().isEmpty() + ? List.of() + : List.of(selected(node).icon()); + return node.port().hasIcons() ? List.of(node.port().icons().get(0)) : List.of(); + } + + public List tooltip(double mouseX, double mouseY) { + if (mouseY < BODY_TOP && mouseX >= WIDTH - 118) + return List.of(Component.translatable( + mouseX >= WIDTH - 29 + ? "gt6ce.jei.material_process.reset_hint" + : "gt6ce.jei.material_process.zoom_hint")); + if (mouseY >= FOOTER) { + var lines = new ArrayList<>(page.notices()); + lines.add(Component.translatable("gt6ce.jei.material_process.pan")); + return List.copyOf(lines); } - if (page.steps().isEmpty()) { - var font = Minecraft.getInstance().font; - graphics.drawWordWrap( - font, Component.translatable("gt6ce.jei.material_process.empty"), 14, 66, WIDTH - 28, MUTED); - graphics.drawWordWrap(font, page.notices().get(0), 14, 90, WIDTH - 28, MUTED); + Node node = hit(mouseX, mouseY); + if (node == null) return List.of(); + ItemStack icon = node.machine() + ? selected(node).icon() + : node.port().icons().stream().findFirst().orElse(ItemStack.EMPTY); + Component name = icon.isEmpty() + ? (node.machine() ? selected(node).name() : node.port().name()) + : icon.getHoverName(); + if (!node.machine() || !node.extra() || worldX(mouseX) < node.x + 6 || worldY(mouseY) > node.y - 6) + return List.of(name); + var lines = new ArrayList(); + lines.add(name); + if (node.steps.size() > 1) + lines.add(Component.translatable("gt6ce.jei.material_process.variants", node.steps.size())); + var names = new java.util.LinkedHashMap(); + for (var port : node.auxiliaries) { + Component label = port.hasIcons() ? port.icons().get(0).getHoverName() : port.name(); + names.putIfAbsent(label.getString(), label); } - graphics.fill(0, FOOTER - 3, WIDTH, FOOTER - 2, 0xffb0b0b0); - text(graphics, page.notices().get(0), 2, FOOTER, WIDTH - 4, MUTED); - text(graphics, Component.translatable("gt6ce.jei.material_process.controls"), 2, FOOTER + 11, WIDTH - 4, MUTED); + lines.addAll(names.values().stream().limit(12).toList()); + if (names.size() > 12) lines.add(Component.literal("…")); + return List.copyOf(lines); } - public static List tooltip(Page page, double mouseX, double mouseY) { - if (mouseY >= FOOTER - 3) return page.notices(); - if (mouseY < HEADER) return List.of(page.title()); - for (int row = 0; row < page.steps().size(); row++) { - var step = page.steps().get(row); - if (processContains(row, mouseX, mouseY) - || mouseX >= 153 - && mouseX < 198 - && mouseY >= HEADER + row * STEP_HEIGHT + 64 - && mouseY < HEADER + row * STEP_HEIGHT + 77) { - var lines = new ArrayList(); - lines.add(step.name()); - lines.addAll(step.details()); - if (!step.resolved()) lines.add(Component.translatable("gt6ce.jei.material_process.unresolved")); - for (var connection : page.connections()) { - if (connection.source().equals(step.reference()) - || connection.target().equals(step.reference())) - lines.add(Component.translatable( - "gt6ce.jei.material_process.connection", - connection.source().toString(), - connection.target().toString(), - connection.resource().toString(), - Component.translatable( - connection.confirmed() - ? "gt6ce.jei.material_process.confirmed" - : "gt6ce.jei.material_process.unresolved"))); - } - lines.add(Component.translatable("gt6ce.jei.material_process.open_recipe")); - return lines; + public boolean click(double mouseX, double mouseY, int button) { + if (button != 0 && button != 1) return false; + if (button == 0 && mouseY >= 0 && mouseY < 14) { + if (mouseX >= WIDTH - 29 && mouseX < WIDTH) { + fit(); + return true; } - for (var slot : slots(step, row)) - if (slot.contains(mouseX, mouseY)) return slot.port().tooltip(); - int top = HEADER + row * STEP_HEIGHT; - if (mouseY >= top + 67 && mouseY < top + 79) { - var ports = mouseX < STEP_X ? step.inputs() : mouseX >= 194 ? step.outputs() : List.of(); - var hidden = ports.stream() - .filter(port -> !port.main()) - .skip(SIDE_LIMIT) - .toList(); - if (!hidden.isEmpty()) { - var lines = new ArrayList(); - lines.add(Component.translatable("gt6ce.jei.material_process.more", hidden.size())); - for (var port : hidden) lines.addAll(port.tooltip()); - return lines; - } + if (mouseX >= WIDTH - 118 && mouseX < WIDTH - 101) { + zoomAt(WIDTH / 2.0, (BODY_TOP + FOOTER) / 2.0, zoom / 1.25); + return true; + } + if (mouseX >= WIDTH - 65 && mouseX < WIDTH - 46) { + zoomAt(WIDTH / 2.0, (BODY_TOP + FOOTER) / 2.0, zoom * 1.25); + return true; } } - return List.of(); + Node node = hit(mouseX, mouseY); + if (node == null) return false; + if (!node.machine()) return page.navigation().openPort(node.port(), button == 1); + return page.navigation().openStack(selected(node).icon(), button == 1); } - public static boolean click(Page page, double mouseX, double mouseY, int button) { + public boolean press(double mouseX, double mouseY, int button) { + return (button == 0 || button == 1) + && mouseX >= 0 + && mouseX < WIDTH + && mouseY >= BODY_TOP + && mouseY < FOOTER + && hit(mouseX, mouseY) == null; + } + + public boolean drag(int button, double dx, double dy) { if (button != 0 && button != 1) return false; - for (int row = 0; row < page.steps().size(); row++) { - var step = page.steps().get(row); - if (button == 0 && step.resolved() && processContains(row, mouseX, mouseY)) - return page.navigation().openRecipe(step.reference()); - for (var slot : slots(step, row)) - if (slot.contains(mouseX, mouseY)) - return page.navigation().openForm(slot.port().resource(), button == 1); + panX += dx; + panY += dy; + return true; + } + + public boolean scroll(double mouseX, double mouseY, double delta) { + if (mouseX < 0 || mouseX >= WIDTH || mouseY < BODY_TOP || mouseY >= FOOTER || delta == 0) return false; + zoomAt(mouseX, mouseY, zoom * Math.pow(1.15, Math.max(-8, Math.min(8, delta)))); + return true; + } + + private double worldX(double x) { + return (x - panX) / zoom; + } + + private double worldY(double y) { + return (y - BODY_TOP - panY) / zoom; + } + + private void zoomAt(double x, double y, double requested) { + double wx = worldX(x), wy = worldY(y); + zoom = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, requested)); + panX = x - wx * zoom; + panY = y - BODY_TOP - wy * zoom; + } + + private void fit() { + zoom = Math.max( + 0.75, + Math.min( + 1, + Math.min( + (WIDTH - 12.0) / Math.max(1, overview.width()), + (FOOTER - BODY_TOP - 12.0) / Math.max(1, overview.height())))); + if (overview.width() * zoom <= WIDTH && overview.height() * zoom <= FOOTER - BODY_TOP) { + panX = (WIDTH - overview.width() * zoom) / 2; + panY = (FOOTER - BODY_TOP - overview.height() * zoom) / 2; + } else { + Node anchor = overview.anchor(); + panX = WIDTH / 3.0 - (anchor == null ? 0 : anchor.x) * zoom; + panY = (FOOTER - BODY_TOP) / 2.0 - (anchor == null ? 0 : anchor.y) * zoom; } - return false; } - private static boolean processContains(int row, double mouseX, double mouseY) { - int top = HEADER + row * STEP_HEIGHT; - return mouseX >= STEP_X && mouseX < STEP_X + STEP_WIDTH && mouseY >= top + 26 && mouseY < top + 45; + private void drawEdges(GuiGraphics graphics, Node hovered) { + for (var edge : overview.edges()) { + int color = related(edge.from(), hovered) || related(edge.to(), hovered) ? 0xff986c26 : TEXT; + var path = edge.path(); + for (int index = 1; index < path.size(); index++) { + var from = path.get(index - 1); + var to = path.get(index); + segment( + graphics, + from.x(), + from.y(), + to.x(), + to.y(), + !edge.confirmed(), + edge.endpoint().output() && index == path.size() - 1, + color); + } + } } - private static void overflow(GuiGraphics graphics, List ports, int x, int y) { - long count = ports.stream().filter(port -> !port.main()).count() - SIDE_LIMIT; - if (count > 0) - text(graphics, Component.translatable("gt6ce.jei.material_process.more", count), x, y, 76, MUTED); + private void segment( + GuiGraphics graphics, + double sx, + double sy, + double tx, + double ty, + boolean dashed, + boolean arrow, + int color) { + stroke(graphics, sx, sy, tx, ty, color, dashed); + if (!arrow || tx < worldX(0) || tx >= worldX(WIDTH) || ty < worldY(BODY_TOP) || ty >= worldY(FOOTER)) return; + double angle = Math.atan2(ty - sy, tx - sx); + graphics.pose().pushPose(); + try { + graphics.pose().translate(tx, ty, 0); + graphics.pose().mulPose(Axis.ZP.rotationDegrees((float) Math.toDegrees(angle))); + MaterialProcessArrows.head(graphics, color); + } finally { + graphics.pose().popPose(); + } + } + + private static void smallText(GuiGraphics graphics, String value, int x, int y, int color, boolean right) { + if (value.isEmpty()) return; + var font = Minecraft.getInstance().font; + float scale = Math.min(0.65F, 22F / Math.max(1, font.width(value))); + graphics.pose().pushPose(); + graphics.pose().translate(x, y, 200); + graphics.pose().scale(scale, scale, 1); + graphics.drawString(font, value, right ? -font.width(value) : 0, 0, color, true); + graphics.pose().popPose(); } private static void text(GuiGraphics graphics, Component value, int x, int y, int width, int color) { @@ -245,19 +299,32 @@ private static void text(GuiGraphics graphics, Component value, int x, int y, in false); } - private static void arrow(GuiGraphics graphics, int x, int y, int color) { - graphics.fill(x - 2, y, x + 3, y + 1, color); - graphics.fill(x - 1, y + 1, x + 2, y + 2, color); - graphics.fill(x, y + 2, x + 1, y + 3, color); - } - - private static void line(GuiGraphics graphics, int x1, int y1, int x2, int y2, int color, boolean dashed) { - int length = Math.max(Math.abs(x2 - x1), Math.abs(y2 - y1)); - for (int offset = 0; offset <= length; offset++) { - if (dashed && offset % 5 >= 3) continue; - int x = x1 + Integer.signum(x2 - x1) * offset; - int y = y1 + Integer.signum(y2 - y1) * offset; - graphics.fill(x, y, x + 1, y + 1, color); + private void stroke(GuiGraphics graphics, double x1, double y1, double x2, double y2, int color, boolean dashed) { + double dx = x2 - x1, dy = y2 - y1, from = 0, to = 1; + double[] p = {-dx, dx, -dy, dy}, + q = {x1 - worldX(-1), worldX(WIDTH + 1) - x1, y1 - worldY(BODY_TOP - 1), worldY(FOOTER + 1) - y1}; + for (int side = 0; side < 4; side++) { + if (p[side] == 0) { + if (q[side] < 0) return; + } else { + double ratio = q[side] / p[side]; + if (p[side] < 0) from = Math.max(from, ratio); + else to = Math.min(to, ratio); + if (from > to) return; + } + } + double length = Math.hypot(dx, dy), visible = (to - from) * length; + if (visible < 0.1) return; + graphics.pose().pushPose(); + try { + graphics.pose().translate(x1 + from * dx, y1 + from * dy, 0); + graphics.pose().mulPose(Axis.ZP.rotationDegrees((float) Math.toDegrees(Math.atan2(dy, dx)))); + if (!dashed) graphics.fill(0, 0, (int) Math.ceil(visible), 1, color); + else + for (int x = 0; x < visible; x += 6) + graphics.fill(x, 0, Math.min(x + 3, (int) Math.ceil(visible)), 1, color); + } finally { + graphics.pose().popPose(); } } } diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java index fa751a45d..307bc9d5f 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java @@ -16,11 +16,10 @@ * No material catalog, native recipe enumeration, or viewer API is accessed here. */ public final class MaterialProcessDisplay { - public static final int STEPS_PER_PAGE = 2; - public static final int MAX_STEPS = 64; - public static final int MAX_PORTS = 64; + public static final int MAX_STEPS = 512; + public static final int MAX_PORTS = 128; public static final int MAX_ICONS = 16; - public static final int MAX_CONNECTIONS = 128; + public static final int MAX_CONNECTIONS = 4096; /** Roles come from the producer; neither slot order nor quantity establishes a primary output. */ public enum Role { @@ -35,21 +34,29 @@ public enum Role { /** * A snapshot-local resource reference, including form and native state. Icons are bounded display representatives, * not an expansion of a tag or unit family. Empty icons describe a symbolic selector. - * Amount includes its unit; chance uses {@link RecipeOutputChances#CERTAIN}, or is explicitly unknown. + * Amount includes its unit; quantity is the producer-supplied compact badge, never parsed from amount. + * Chance uses {@link RecipeOutputChances#CERTAIN}, or is explicitly unknown. */ public record Port( DataKey resource, + String material, Component name, List icons, Role role, boolean main, Component amount, + Component quantity, OptionalInt chance, - List details) { + List details, + String identity) { public Port { Objects.requireNonNull(resource); + Objects.requireNonNull(identity); + if (material == null || material.isBlank()) + throw new IllegalArgumentException("Missing process port material"); name = name.copy(); amount = amount.copy(); + quantity = quantity.copy(); Objects.requireNonNull(role); Objects.requireNonNull(chance); if (icons.size() > MAX_ICONS) throw new IllegalArgumentException("Too many display representatives"); @@ -61,6 +68,33 @@ public record Port( details = copyText(details); } + public Port( + DataKey resource, + String material, + Component name, + List icons, + Role role, + boolean main, + Component amount, + Component quantity, + OptionalInt chance, + List details) { + this(resource, material, name, icons, role, main, amount, quantity, chance, details, resource.toString()); + } + + public Port( + DataKey resource, + String material, + Component name, + List icons, + Role role, + boolean main, + Component amount, + OptionalInt chance, + List details) { + this(resource, material, name, icons, role, main, amount, Component.empty(), chance, details); + } + @Override public List icons() { return icons.stream().map(ItemStack::copy).toList(); @@ -100,18 +134,112 @@ public record Connection(DataKey source, DataKey target, DataKey resource, boole public record Step( DataKey reference, Component name, + ItemStack icon, List inputs, List outputs, List details, - boolean resolved) { + java.util.Optional specialProcess, + boolean resolved, + boolean worldGenerated) { public Step { Objects.requireNonNull(reference); name = name.copy(); + icon = icon.copy(); inputs = List.copyOf(inputs); outputs = List.copyOf(outputs); validatePorts(inputs, false); validatePorts(outputs, true); details = copyText(details); + Objects.requireNonNull(specialProcess); + } + + @Override + public ItemStack icon() { + return icon.copy(); + } + + public Step( + DataKey reference, + Component name, + ItemStack icon, + List inputs, + List outputs, + List details, + java.util.Optional specialProcess, + boolean resolved) { + this(reference, name, icon, inputs, outputs, details, specialProcess, resolved, false); + } + + public Step( + DataKey reference, + Component name, + List inputs, + List outputs, + List details, + java.util.Optional specialProcess, + boolean resolved) { + this(reference, name, ItemStack.EMPTY, inputs, outputs, details, specialProcess, resolved, false); + } + + public Step( + DataKey reference, + Component name, + List inputs, + List outputs, + List details, + boolean resolved) { + this( + reference, + name, + ItemStack.EMPTY, + inputs, + outputs, + details, + java.util.Optional.empty(), + resolved, + false); + } + } + + /** Categories describe consumed material flow; catalysts and presence conditions cannot establish it. */ + public enum Section { + SOURCES("gt6ce.jei.material_process.section.sources"), + INTERNAL("gt6ce.jei.material_process.section.internal"), + USES("gt6ce.jei.material_process.section.uses"); + + private final String label; + + Section(String label) { + this.label = label; + } + + public Component label() { + return Component.translatable(label); + } + } + + public static java.util.Optional

section(Step step, String material) { + boolean input = step.inputs().stream() + .anyMatch( + port -> port.role() == Role.CONSUMED && port.material().equals(material)); + boolean output = + step.outputs().stream().anyMatch(port -> port.material().equals(material)); + if (input && output) return java.util.Optional.of(Section.INTERNAL); + boolean otherInput = step.inputs().stream() + .anyMatch( + port -> port.role() == Role.CONSUMED && !port.material().equals(material)); + if (output && !input && (step.worldGenerated() || otherInput)) return java.util.Optional.of(Section.SOURCES); + boolean otherOutput = + step.outputs().stream().anyMatch(port -> !port.material().equals(material)); + if (input && !output && otherOutput) return java.util.Optional.of(Section.USES); + return java.util.Optional.empty(); + } + + /** Stable method identity plus its translated display name. */ + public record SpecialProcess(DataKey id, Component name) { + public SpecialProcess { + Objects.requireNonNull(id); + name = name.copy(); } } @@ -121,18 +249,19 @@ public record Step( */ public interface Navigation { Navigation NONE = new Navigation() { - @Override - public boolean openRecipe(DataKey reference) { - return false; - } - @Override public boolean openForm(DataKey resource, boolean uses) { return false; } }; - boolean openRecipe(DataKey reference); + default boolean openPort(Port port, boolean uses) { + return port.hasIcons() && openStack(port.icons().get(0), uses); + } + + default boolean openStack(ItemStack stack, boolean uses) { + return false; + } boolean openForm(DataKey resource, boolean uses); } @@ -140,6 +269,7 @@ public boolean openForm(DataKey resource, boolean uses) { /** Coverage and truncation reasons are always visible through the footer tooltip, including for empty queries. */ public record Page( Component title, + String material, List steps, List connections, List notices, @@ -148,11 +278,12 @@ public record Page( Navigation navigation) { public Page { title = title.copy(); + if (material == null) throw new IllegalArgumentException("Missing process page material"); steps = List.copyOf(steps); connections = List.copyOf(connections); notices = copyText(notices); Objects.requireNonNull(navigation); - if (steps.size() > STEPS_PER_PAGE + if (steps.size() > MAX_STEPS || connections.size() > MAX_CONNECTIONS || number < 1 || total < number @@ -162,9 +293,10 @@ public record Page( private MaterialProcessDisplay() {} - /** Split a bounded, producer-ordered result without dropping steps. No graph traversal or candidate expansion. */ + /** Build one material page without dropping steps. Panning belongs to the viewer, not to data paging. */ public static List pages( Component title, + String material, List steps, List connections, List notices, @@ -187,25 +319,13 @@ public static List pages( .noneMatch(port -> port.resource().equals(connection.resource()))) throw new IllegalArgumentException("Connection does not match process ports"); } - int total = Math.max(1, (steps.size() + STEPS_PER_PAGE - 1) / STEPS_PER_PAGE); - var pages = new ArrayList(total); - for (int index = 0; index < total; index++) { - int start = index * STEPS_PER_PAGE; - pages.add(new Page( - title, - steps.subList(start, Math.min(start + STEPS_PER_PAGE, steps.size())), - connections, - notices, - index + 1, - total, - navigation)); - } - return List.copyOf(pages); + return List.of(new Page(title, material, steps, connections, notices, 1, 1, navigation)); } public static List unbound() { return pages( Component.translatable("gt6ce.jei.material_process.title"), + "", List.of(), List.of(), List.of(Component.translatable("gt6ce.jei.material_process.unbound")), diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java new file mode 100644 index 000000000..d4cec6ac1 --- /dev/null +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java @@ -0,0 +1,537 @@ +package gregtech.compat.common; + +import gregtech.api.addon.material.DataKey; +import gregtech.compat.common.MaterialProcessDisplay.Connection; +import gregtech.compat.common.MaterialProcessDisplay.Page; +import gregtech.compat.common.MaterialProcessDisplay.Port; +import gregtech.compat.common.MaterialProcessDisplay.Role; +import gregtech.compat.common.MaterialProcessDisplay.Section; +import gregtech.compat.common.MaterialProcessDisplay.Step; +import gregtech.engine.stack.StackCompat; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import net.minecraft.world.item.ItemStack; + +/** A bounded layout of native steps; resource copies never introduce recipe facts. */ +public final class MaterialProcessOverview { + /** The original port, including its side and slot, survives sharing and local copying. */ + public record Endpoint(Step step, boolean output, int index, Port port) { + public String key() { + return step.reference() + (output ? ":out:" : ":in:") + index + ":" + port.resource(); + } + } + + public static final class Node { + public final String key; + public final Section section; + public final List endpoints = new ArrayList<>(); + public final List steps = new ArrayList<>(); + public int x, y, layer; + public boolean copy, returning; + private boolean feedbackCopy; + + private Node(String key, Section section) { + this.key = key; + this.section = section; + } + + public boolean machine() { + return !steps.isEmpty(); + } + + public Port port() { + return endpoints.get(0).port(); + } + + public boolean extra() { + return steps.size() > 1 + || !auxiliaries.isEmpty() + || steps.stream() + .anyMatch(step -> java.util.stream.Stream.concat( + step.inputs().stream(), step.outputs().stream()) + .anyMatch(port -> port.icons().size() > 1)); + } + + public final List auxiliaries = new ArrayList<>(); + } + + public record Point(int x, int y) {} + + public static final class Edge { + private Node from, to; + private final Endpoint endpoint; + private final List endpoints = new ArrayList<>(); + private boolean confirmed; + private boolean feedback; + private List path = List.of(); + + private Edge(Node from, Node to, Endpoint endpoint) { + this.from = from; + this.to = to; + this.endpoint = endpoint; + endpoints.add(endpoint); + confirmed = endpoint.step().resolved(); + } + + public Node from() { + return from; + } + + public Node to() { + return to; + } + + public Endpoint endpoint() { + return endpoint; + } + + public List endpoints() { + return List.copyOf(endpoints); + } + + public boolean confirmed() { + return confirmed; + } + + public boolean feedback() { + return feedback; + } + + public List path() { + return path; + } + } + + private static final class IconKey { + private final ItemStack icon; + + private IconKey(ItemStack icon) { + this.icon = icon; + } + + @Override + public boolean equals(Object other) { + return other instanceof IconKey key && StackCompat.sameItem(icon, key.icon); + } + + @Override + public int hashCode() { + return icon.getItem().hashCode(); + } + } + + private record RouteKey(IconKey icon, String fallback, List inputs, List outputs) {} + + private record EdgeKey(Node from, Node to) {} + + private record SideKey(DataKey step, DataKey resource) {} + + private record Arc(Node from, Node to, int distance, Edge edge, Connection connection) {} + + private record Occupancy(BitSet positive, BitSet negative) { + private Occupancy() { + this(new BitSet(), new BitSet()); + } + + private void add(int lane) { + (lane >= 0 ? positive : negative).set(lane >= 0 ? lane : -lane - 1); + } + + private int above(int center) { + if (center >= 0) return positive.nextClearBit(center); + int negativeIndex = negative.previousClearBit(-center - 1); + return negativeIndex >= 0 ? -negativeIndex - 1 : positive.nextClearBit(0); + } + + private int below(int center) { + if (center < 0) return -negative.nextClearBit(-center - 1) - 1; + int positiveIndex = positive.previousClearBit(center); + return positiveIndex >= 0 ? positiveIndex : -negative.nextClearBit(0) - 1; + } + } + + private final List nodes = new ArrayList<>(); + private final List edges = new ArrayList<>(); + private final List connections; + private final Map machines = new LinkedHashMap<>(); + private final Set inputs = new HashSet<>(), outputs = new HashSet<>(); + private final Map next = new HashMap<>(), previous = new HashMap<>(); + private final Set feedback = new HashSet<>(); + private int width, height; + private Node anchor; + + public MaterialProcessOverview(Page page) { + connections = page.connections().stream() + .sorted(Comparator.comparing( + connection -> connection.source() + ":" + connection.target() + ":" + connection.resource())) + .toList(); + var resources = new LinkedHashMap(); + var routes = new LinkedHashMap(); + var wires = new LinkedHashMap(); + for (Step step : page.steps().stream() + .sorted(Comparator.comparing(value -> value.reference().toString())) + .toList()) { + List visibleInputs = visible(step.inputs(), page.material(), false); + List visibleOutputs = visible(step.outputs(), page.material(), true); + ItemStack icon = step.icon(); + var key = new RouteKey( + new IconKey(icon), + icon.isEmpty() ? step.reference().toString() : "", + identities(visibleInputs), + identities(visibleOutputs)); + Node machine = routes.computeIfAbsent(key, ignored -> { + var node = new Node( + "step:" + step.reference(), + MaterialProcessDisplay.section(step, page.material()).orElse(null)); + nodes.add(node); + return node; + }); + machine.steps.add(step); + machines.put(step.reference(), machine); + for (boolean output : List.of(false, true)) { + List ports = output ? step.outputs() : step.inputs(); + List visible = output ? visibleOutputs : visibleInputs; + for (int index = 0; index < ports.size(); index++) { + Port port = ports.get(index); + if (!visible.contains(port)) { + machine.auxiliaries.add(port); + continue; + } + var endpoint = new Endpoint(step, output, index, port); + (output ? outputs : inputs).add(new SideKey(step.reference(), port.resource())); + Node resource = resources.computeIfAbsent(port.identity(), identity -> { + var node = new Node("resource:" + identity, null); + nodes.add(node); + return node; + }); + if (port.hasIcons() + && !resource.endpoints.isEmpty() + && !resource.port().hasIcons()) resource.endpoints.add(0, endpoint); + else resource.endpoints.add(endpoint); + Node from = output ? machine : resource, to = output ? resource : machine; + Edge edge = wires.get(new EdgeKey(from, to)); + if (edge == null) { + edge = new Edge(from, to, endpoint); + wires.put(new EdgeKey(from, to), edge); + edges.add(edge); + } else { + edge.endpoints.add(endpoint); + edge.confirmed &= step.resolved(); + } + } + } + } + Set uncertain = new HashSet<>(); + for (Connection connection : connections) + if (!connection.confirmed()) uncertain.add(connection.target() + ":" + connection.resource()); + for (Edge edge : edges) + if (edge.endpoints.stream() + .anyMatch(endpoint -> !endpoint.output() + && uncertain.contains(endpoint.step().reference() + ":" + + endpoint.port().resource()))) edge.confirmed = false; + layout(); + // Each pass detaches at least one shared port; copies themselves are never split again. + while (splitLongEdges()) layout(); + Map counts = new HashMap<>(); + for (Node node : nodes) if (!node.machine()) counts.merge(node.port().identity(), 1, Integer::sum); + for (Node node : nodes) + if (!node.machine()) node.copy = counts.get(node.port().identity()) > 1; + route(); + anchor = nodes.stream() + .filter(node -> !node.machine() && node.port().material().equals(page.material())) + .min(Comparator.comparingInt(node -> -chainLength(node)).thenComparing(node -> node.key)) + .orElse(nodes.isEmpty() ? null : nodes.get(0)); + } + + public List nodes() { + return List.copyOf(nodes); + } + + public List edges() { + return List.copyOf(edges); + } + + public List connections() { + return connections; + } + + public Node anchor() { + return anchor; + } + + public int width() { + return width; + } + + public int height() { + return height; + } + + private static List visible(List ports, String material, boolean output) { + List candidates = ports.stream() + .filter(port -> output || port.role() == Role.CONSUMED) + .toList(); + List local = candidates.stream() + .filter(port -> port.material().equals(material)) + .toList(); + if (!local.isEmpty()) return local; + // Foreign co-inputs and tools stay in the + details. The main hint never changes port roles. + return candidates.stream() + .filter(Port::main) + .findFirst() + .or(() -> candidates.stream() + .filter(port -> !output || port.role() != Role.BYPRODUCT) + .findFirst()) + .map(List::of) + .orElse(List.of()); + } + + private static List identities(List ports) { + return ports.stream().map(Port::identity).distinct().sorted().toList(); + } + + private Node resource(Edge edge) { + return edge.from.machine() ? edge.to : edge.from; + } + + private void split(Edge edge) { + Node original = resource(edge); + Node local = new Node("copy:" + edge.endpoint.key(), null); + local.feedbackCopy = edge.feedback || original.returning; + local.endpoints.addAll(edge.endpoints); + nodes.add(local); + original.endpoints.removeAll(edge.endpoints); + if (edge.from == original) edge.from = local; + else edge.to = local; + } + + private boolean splitLongEdges() { + boolean changed = false; + var counts = new HashMap(); + for (Edge edge : edges) counts.merge(resource(edge), 1, Integer::sum); + var columns = new HashMap>(); + for (Node node : nodes) + columns.computeIfAbsent(node.layer, ignored -> new java.util.TreeMap<>()) + .put(node.y, node); + for (Edge edge : edges) { + Node resource = resource(edge); + if (counts.get(resource) < 2 || next.get(edge.from) == edge.to) continue; + if (!edge.feedback + && edge.to.layer - edge.from.layer <= 3 + && Math.abs(edge.to.y - edge.from.y) <= 192 + && !crossesNode(edge, columns)) continue; + split(edge); + counts.merge(resource, -1, Integer::sum); + changed = true; + } + return changed; + } + + private static boolean crossesNode(Edge edge, Map> columns) { + double sx = edge.from.x + 12, tx = edge.to.x - 12; + if (tx <= sx) return true; + double slope = (edge.to.y - edge.from.y) / (tx - sx); + for (int layer = edge.from.layer + 1; layer < edge.to.layer; layer++) { + var column = columns.get(layer); + if (column == null) continue; + double y = edge.from.y + (24 + layer * 52 - sx) * slope; + double margin = 14 + 12 * Math.abs(slope); + var candidate = column.ceilingEntry((int) Math.ceil(y - margin)); + if (candidate != null && candidate.getKey() <= y + margin) return true; + } + return false; + } + + private List arcs() { + var result = new ArrayList(); + for (Edge edge : edges) result.add(new Arc(edge.from, edge.to, 1, edge, null)); + // Supplied associations constrain layers even when a local copy replaces the long visible wire. + for (Connection connection : connections) { + if (!outputs.contains(new SideKey(connection.source(), connection.resource())) + || !inputs.contains(new SideKey(connection.target(), connection.resource()))) continue; + Node source = machines.get(connection.source()), target = machines.get(connection.target()); + if (source != null && target != null) result.add(new Arc(source, target, 2, null, connection)); + } + result.sort(Comparator.comparing((Arc arc) -> arc.from.key) + .thenComparing(arc -> arc.to.key) + .thenComparing(arc -> + arc.connection == null ? "" : arc.connection.resource().toString())); + return result; + } + + private void layout() { + next.clear(); + previous.clear(); + feedback.clear(); + List arcs = arcs(); + var outgoing = new HashMap>(); + var indegree = new HashMap(); + for (Node node : nodes) { + node.layer = 0; + node.returning = node.feedbackCopy; + } + for (Edge edge : edges) edge.feedback = false; + for (Arc arc : arcs) { + outgoing.computeIfAbsent(arc.from, ignored -> new ArrayList<>()).add(arc); + indegree.merge(arc.to, 1, Integer::sum); + } + // Iterative DFS cuts only feedback constraints, including pure cycles and self loops. + var state = new HashMap(); + record Frame(Node node, java.util.Iterator iterator) {} + var roots = new ArrayList<>(nodes); + roots.sort(Comparator.comparingInt(node -> indegree.getOrDefault(node, 0) == 0 ? 0 : 1) + .thenComparing(node -> node.key)); + for (Node root : roots) { + if (state.containsKey(root)) continue; + var stack = new ArrayDeque(); + state.put(root, 1); + stack.push(new Frame(root, outgoing.getOrDefault(root, List.of()).iterator())); + while (!stack.isEmpty()) { + Frame frame = stack.peek(); + if (!frame.iterator.hasNext()) { + state.put(frame.node, 2); + stack.pop(); + continue; + } + Arc arc = frame.iterator.next(); + if (state.getOrDefault(arc.to, 0) == 1) { + feedback.add(arc); + indegree.merge(arc.to, -1, Integer::sum); + if (arc.edge != null) { + arc.edge.feedback = true; + resource(arc.edge).returning = true; + } else + for (Edge edge : edges) + if (edge.endpoint.step().reference().equals(arc.connection.target()) + && edge.endpoint.port().resource().equals(arc.connection.resource())) + resource(edge).returning = true; + } else if (!state.containsKey(arc.to)) { + state.put(arc.to, 1); + stack.push(new Frame( + arc.to, outgoing.getOrDefault(arc.to, List.of()).iterator())); + } + } + } + var ready = new java.util.PriorityQueue(Comparator.comparing(node -> node.key)); + for (Node node : roots) if (indegree.getOrDefault(node, 0) == 0) ready.add(node); + while (!ready.isEmpty()) { + Node node = ready.remove(); + for (Arc arc : outgoing.getOrDefault(node, List.of())) + if (!feedback.contains(arc)) { + arc.to.layer = Math.max(arc.to.layer, node.layer + arc.distance); + if (indegree.merge(arc.to, -1, Integer::sum) == 0) ready.add(arc.to); + } + } + var nearestConsumer = new HashMap(); + for (Edge edge : edges) + if (!edge.endpoint.output()) nearestConsumer.merge(edge.from, edge.to.layer - 1, Math::min); + for (Node node : nodes) + if (!node.machine() && node.endpoints.stream().noneMatch(Endpoint::output)) + node.layer = Math.max(0, nearestConsumer.getOrDefault(node, node.layer)); + var degree = new HashMap(); + var neighbors = new HashMap>(); + for (Edge edge : edges) { + degree.merge(edge.from, 1, Integer::sum); + degree.merge(edge.to, 1, Integer::sum); + neighbors.computeIfAbsent(edge.from, ignored -> new ArrayList<>()).add(edge.to); + neighbors.computeIfAbsent(edge.to, ignored -> new ArrayList<>()).add(edge.from); + } + var ordered = new ArrayList<>(edges); + var before = new HashMap(); + var after = new HashMap(); + var forwards = edges.stream() + .filter(edge -> !edge.feedback && edge.to.layer > edge.from.layer) + .sorted(Comparator.comparingInt(edge -> edge.from.layer)) + .toList(); + for (Edge edge : forwards) before.merge(edge.to, before.getOrDefault(edge.from, 0) + 1, Math::max); + for (int index = forwards.size() - 1; index >= 0; index--) { + Edge edge = forwards.get(index); + after.merge(edge.from, after.getOrDefault(edge.to, 0) + 1, Math::max); + } + ordered.sort(Comparator.comparingInt(edge -> degree.get(edge.from) + degree.get(edge.to)) + .thenComparing(edge -> !edge.endpoint.port().main()) + .thenComparingInt(edge -> -before.getOrDefault(edge.from, 0) - after.getOrDefault(edge.to, 0)) + .thenComparing(edge -> edge.endpoint.key())); + for (Edge edge : ordered) + if (!edge.feedback + && edge.to.layer == edge.from.layer + 1 + && !next.containsKey(edge.from) + && !previous.containsKey(edge.to)) { + next.put(edge.from, edge.to); + previous.put(edge.to, edge.from); + } + var starts = nodes.stream() + .filter(node -> !previous.containsKey(node)) + .sorted(Comparator.comparingInt(node -> -chainLength(node)) + .thenComparingInt(node -> node.layer) + .thenComparing(node -> family(node, neighbors)) + .thenComparing(node -> node.key)) + .toList(); + var lanes = new HashMap(); + var occupied = new HashMap(); + for (Node start : starts) { + var chain = new ArrayList(); + for (Node node = start; node != null; node = next.get(node)) chain.add(node); + Set members = new HashSet<>(chain); + double center = chain.stream() + .flatMap(node -> neighbors.getOrDefault(node, List.of()).stream()) + .filter(node -> !members.contains(node)) + .filter(lanes::containsKey) + .mapToInt(lanes::get) + .average() + .orElse(0); + int first = start.layer, last = chain.get(chain.size() - 1).layer, desired = (int) Math.round(center); + var blocked = new Occupancy(); + for (int layer = first; layer <= last; layer++) { + Occupancy values = occupied.get(layer); + if (values != null) { + blocked.positive.or(values.positive); + blocked.negative.or(values.negative); + } + } + int above = blocked.above(desired), below = blocked.below(desired); + int lane = above - desired <= desired - below ? above : below; + for (int layer = first; layer <= last; layer++) + occupied.computeIfAbsent(layer, ignored -> new Occupancy()).add(lane); + for (Node node : chain) lanes.put(node, lane); + } + int minimum = lanes.values().stream().mapToInt(Integer::intValue).min().orElse(0); + for (Node node : nodes) { + node.x = 24 + node.layer * 52; + node.y = 24 + (lanes.get(node) - minimum) * 32; + } + } + + private static String family(Node start, Map> neighbors) { + if (!start.machine()) return start.port().identity(); + return neighbors.getOrDefault(start, List.of()).stream() + .filter(node -> !node.machine()) + .map(node -> node.port().identity()) + .sorted() + .findFirst() + .orElse(start.key); + } + + private int chainLength(Node start) { + int count = 0; + for (Node node = start; node != null; node = next.get(node)) count++; + return count; + } + + private void route() { + for (Edge edge : edges) { + Node from = edge.from, to = edge.to; + edge.path = List.of(new Point(from.x + 12, from.y), new Point(to.x - 12, to.y)); + } + width = nodes.stream().mapToInt(node -> node.x + 24).max().orElse(48); + height = nodes.stream().mapToInt(node -> node.y + 24).max().orElse(48); + } +} diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java index c80393783..484b5a086 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java @@ -8,7 +8,6 @@ import gregtech.engine.material.MaterialProcessGraph; import gregtech.engine.material.MaterialProcessGraph.AmountUnit; import gregtech.engine.material.MaterialProcessGraph.Budgets; -import gregtech.engine.material.MaterialProcessGraph.Direction; import gregtech.engine.material.MaterialProcessGraph.Notice; import gregtech.engine.material.MaterialProcessGraph.Port; import gregtech.engine.material.MaterialProcessGraph.Query; @@ -32,15 +31,18 @@ /** Converts one already bounded semantic query into native viewer values. */ public final class MaterialProcessProjection { - private static final Budgets INITIAL_BUDGET = new Budgets(4, 10, 64, 128); + private static final Budgets MATERIAL_PAGE_BUDGET = + new Budgets(0, MaterialProcessDisplay.MAX_STEPS, MaterialProcessDisplay.MAX_PORTS, + MaterialProcessDisplay.MAX_CONNECTIONS); private MaterialProcessProjection() {} public static List initialPages( MaterialProcessSnapshot snapshot, MaterialProcessDisplay.Navigation navigation) { var pages = new ArrayList(); + var workstations = RecipeViewerIcons.categories(); for (MaterialProcessSnapshot.Root root : snapshot.roots()) { - var rootPages = pages(snapshot, root.resource(), Direction.BOTH, INITIAL_BUDGET, navigation); + var rootPages = pages(snapshot, root.resource(), MATERIAL_PAGE_BUDGET, navigation, workstations); pages.addAll(rootPages); } return pages.isEmpty() ? MaterialProcessDisplay.unbound() : List.copyOf(pages); @@ -49,49 +51,87 @@ public static List initialPages( public static List pages( MaterialProcessSnapshot snapshot, DataKey root, - Direction direction, MaterialProcessDisplay.Navigation navigation) { - return pages(snapshot, root, direction, Budgets.DEFAULT, navigation); + return pages(snapshot, root, MATERIAL_PAGE_BUDGET, navigation, RecipeViewerIcons.categories()); } private static List pages( MaterialProcessSnapshot snapshot, DataKey root, - Direction direction, Budgets budgets, - MaterialProcessDisplay.Navigation navigation) { - Query query = snapshot.query(root, direction, budgets); - var steps = query.steps().stream().map(MaterialProcessProjection::step).toList(); + MaterialProcessDisplay.Navigation navigation, + java.util.Map workstations) { + Query query = snapshot.queryMaterial(root, budgets); + var steps = query.steps().stream().map(step -> step(snapshot, step, workstations)).toList(); var connections = query.edges().stream() .map(edge -> new MaterialProcessDisplay.Connection( edge.source(), edge.target(), edge.resource(), edge.confirmed())) .toList(); var notices = query.notices().stream().map(MaterialProcessProjection::notice).toList(); if (notices.isEmpty()) notices = List.of(Component.translatable("gt6ce.jei.material_process.partial_unknown")); - Component title = title(query.root(), snapshot.resource(query.root()).orElse(null)); - return MaterialProcessDisplay.pages(title, steps, connections, notices, navigation); + Resource resource = snapshot.resource(query.root()).orElse(null); + Component title = title(query.root(), resource); + String material = resource == null ? "" : resource.material(); + return MaterialProcessDisplay.pages(title, material, steps, connections, notices, navigation); } - private static MaterialProcessDisplay.Step step(Step step) { + private static MaterialProcessDisplay.Step step(MaterialProcessSnapshot snapshot, Step step, + java.util.Map workstations) { + Optional specialProcess = step.specialProcess() + .flatMap(id -> specialMethod(id).map(method -> new MaterialProcessDisplay.SpecialProcess( + id, Component.translatable(method.displayNameKey())))); return new MaterialProcessDisplay.Step( step.reference(), Component.literal(step.name()), - step.inputs().stream().map(MaterialProcessProjection::port).toList(), - step.outputs().stream().map(MaterialProcessProjection::port).toList(), + snapshot.recipe(step.reference()) + .map(recipe -> workstations.getOrDefault(recipe.map(), new ItemStack(net.minecraft.world.item.Items.ANVIL))) + .orElseGet(() -> snapshot.worldgen(step.reference()).isPresent() + ? new ItemStack(net.minecraft.world.item.Items.IRON_PICKAXE) : ItemStack.EMPTY), + step.inputs().stream().map(port -> port(port, snapshot.recipe(step.reference()).orElse(null))).toList(), + step.outputs().stream().map(port -> port(port, snapshot.recipe(step.reference()).orElse(null))).toList(), step.details().stream().map(MaterialProcessProjection::literal).toList(), - step.resolved()); + specialProcess, + step.resolved(), + snapshot.worldgen(step.reference()).isPresent()); + } + + private static Optional specialMethod( + DataKey id) { + MaterialCatalogView catalog; + try { + catalog = gregtech.engine.material.MaterialViews.catalog(); + } catch (IllegalStateException notReady) { + return Optional.empty(); + } + return catalog.specialProcesses().find(id); } - private static MaterialProcessDisplay.Port port(Port port) { + private static MaterialProcessDisplay.Port port(Port port, MaterialProcessSnapshot.NativeRecipe nativeRecipe) { + List icons = nativeIcons(port.resource(), nativeRecipe); + String identity = port.resource().state(); + if (!icons.isEmpty()) { + ItemStack representative = icons.get(0); + if (gregtech.engine.fluid.FluidDisplayBinding.hasPayload(representative)) { +//? if >=1.21.1 { + /*var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolveCurrent(representative); +*///?} else { + var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolve(representative); +//?} + if (!fluid.isEmpty()) identity = MaterialProcessSnapshot.fluidDisplayState(fluid); + } else identity = MaterialProcessSnapshot.itemDisplayState(representative); + } return new MaterialProcessDisplay.Port( port.resource().key(), + port.resource().material(), name(port.resource()), - icons(port.resource()), + icons, role(port.role()), port.main(), amount(port.amount().value(), port.amount().unit()), + quantity(port.amount().value(), port.amount().unit()), port.chance(), - port.details().stream().map(MaterialProcessProjection::literal).toList()); + port.details().stream().map(MaterialProcessProjection::literal).toList(), + identity); } private static Component title(DataKey root, Resource resource) { @@ -133,6 +173,68 @@ private static Component literal(String value) { return Component.literal(value); } + private static List nativeIcons(Resource resource, MaterialProcessSnapshot.NativeRecipe row) { + String state = resource.state(); + if (row != null) { + var recipe = row.recipe(); + if (state.startsWith("tag:")) { + String tag = state.substring("tag:".length()); + if (resource.form().equals("fluid")) { + for (int index = 0; index < recipe.mFluidInputs.length; index++) { + var key = recipe.fluidTag(index); + var stack = recipe.mFluidInputs[index]; + if (key != null && key.location().toString().equals(tag) && stack != null && !stack.isEmpty() + && MaterialProcessSnapshot.fluidDisplayState(stack).contains("#")) { + var display = fluidDisplay(stack); + return display.isEmpty() ? List.of() : List.of(display); + } + } + } else { + for (int index = 0; index < recipe.mInputs.length; index++) { + var key = recipe.itemTag(index); + var stack = recipe.mInputs[index]; + if (key != null && key.location().toString().equals(tag) && stack != null && !stack.isEmpty() + && MaterialProcessSnapshot.itemDisplayState(stack).contains("#")) + return List.of(stack.copyWithCount(1)); + } + } + } + if (state.startsWith("fluid:")) { + for (FluidStack stack : java.util.stream.Stream.concat( + java.util.Arrays.stream(recipe.mFluidInputs), java.util.Arrays.stream(recipe.mFluidOutputs)).toList()) + if (stack != null && !stack.isEmpty() && MaterialProcessSnapshot.fluidDisplayState(stack).equals(state)) { + ItemStack display = fluidDisplay(stack); + return display.isEmpty() ? List.of() : List.of(display); + } + } + if (state.startsWith("item:") || state.startsWith("unit:")) { + var candidates = new ArrayList(); + candidates.addAll(java.util.Arrays.asList(recipe.mInputs)); + candidates.addAll(java.util.Arrays.asList(recipe.mOutputs)); + if (state.startsWith("unit:")) + for (int index = 0; index < recipe.mInputs.length; index++) { + var display = recipe.materialInputDisplay(index); + if (display != null) candidates.addAll(display.alternatives()); + } + var result = new ArrayList(); + for (ItemStack stack : candidates) { + if (stack == null || stack.isEmpty()) continue; + boolean matches = state.startsWith("item:") ? MaterialProcessSnapshot.itemDisplayState(stack).equals(state) + : java.util.Arrays.asList(state.substring(state.lastIndexOf('|') + 1).split(",")) + .contains(BuiltInRegistries.ITEM.getKey(stack.getItem()).toString()); + if (matches && result.stream().noneMatch(existing -> gregtech.engine.stack.StackCompat.sameItem(existing, stack))) { + result.add(stack.copyWithCount(1)); + if (result.size() >= MaterialProcessDisplay.MAX_ICONS) break; + } + } + if (!result.isEmpty()) return List.copyOf(result); + } + } + // A fingerprint is not a serialized stack. Never replace a stateful value with an untagged look-alike. + if ((state.startsWith("item:") || state.startsWith("fluid:")) && state.contains("#")) return List.of(); + return icons(resource); + } + private static List icons(Resource resource) { var icons = new LinkedHashSet(); String state = resource.state(); @@ -214,6 +316,15 @@ private static MaterialProcessDisplay.Role role(MaterialProcessGraph.Role role) }; } + private static Component quantity(long value, AmountUnit unit) { + return Component.literal(switch (unit) { + case ITEM -> value == 1 ? "" : Long.toString(value); + case MATERIAL_UNIT -> value + "U"; + case MILLIBUCKET -> value + "mB"; + case UNKNOWN -> "?"; + }); + } + private static Component amount(long value, AmountUnit unit) { return switch (unit) { case ITEM -> Component.translatable("gt6ce.jei.material_process.amount.items", value); diff --git a/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java b/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java index 535fca442..82c14d459 100644 --- a/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java +++ b/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java @@ -36,6 +36,23 @@ public static ItemStack bedrockOre() { return stack; } + /** Use the same category identity for the process graph and the native viewer. */ + public static ItemStack category(RecipeMap map, java.util.Map> machines) { + ItemStack preferred = map(map); + if (!preferred.isEmpty()) return preferred; + var workstations = machines.getOrDefault(map, java.util.List.of()); + return workstations.isEmpty() + ? new ItemStack(net.minecraft.world.item.Items.ANVIL) + : workstations.get(0).copy(); + } + + public static java.util.Map categories() { + var machines = gregtech.compat.jei.RecipeMachines.collect(); + var icons = new java.util.HashMap(); + for (RecipeMap map : RecipeMap.RECIPE_MAP_LIST) icons.put(map, category(map, machines)); + return icons; + } + public static ItemStack map(RecipeMap map) { if (map == MachineRecipeMaps.ByProductList) return GTItems.getStack(MaterialPrefix.dust, GTMaterialRegistry.get("Platinum")); diff --git a/minecraft/src/main/java/gregtech/compat/emi/EmiInteractiveWidget.java b/minecraft/src/main/java/gregtech/compat/emi/EmiInteractiveWidget.java index 40d8f44a4..3f6dadc8a 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/EmiInteractiveWidget.java +++ b/minecraft/src/main/java/gregtech/compat/emi/EmiInteractiveWidget.java @@ -4,6 +4,10 @@ /** Optional input surface; native screen events supply drag/scroll absent from EMI's Widget API. */ public abstract class EmiInteractiveWidget extends Widget { + public dev.emi.emi.api.stack.EmiIngredient ingredientAt(double x, double y) { + return dev.emi.emi.api.stack.EmiStack.EMPTY; + } + public boolean pressed(double x, double y, int button) { return false; } diff --git a/minecraft/src/main/java/gregtech/compat/emi/EmiWidgetInput.java b/minecraft/src/main/java/gregtech/compat/emi/EmiWidgetInput.java index 9ea780f85..09d11b31c 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/EmiWidgetInput.java +++ b/minecraft/src/main/java/gregtech/compat/emi/EmiWidgetInput.java @@ -59,6 +59,18 @@ public static void rendered(EmiInteractiveWidget widget, GuiGraphics graphics) { new org.joml.Matrix4f(graphics.pose().last().pose()).invert())); } + public static dev.emi.emi.api.stack.EmiStackInteraction stackAt(Screen screen, double x, double y) { + if (screen != frameScreen) return dev.emi.emi.api.stack.EmiStackInteraction.EMPTY; + for (int index = surfaces.size() - 1; index >= 0; index--) { + var surface = surfaces.get(index); + if (!surface.contains(x, y)) continue; + var local = surface.local(x, y); + var ingredient = surface.widget().ingredientAt(local.x(), local.y()); + if (!ingredient.isEmpty()) return new dev.emi.emi.api.stack.EmiStackInteraction(ingredient); + } + return dev.emi.emi.api.stack.EmiStackInteraction.EMPTY; + } + public static boolean pressed(Screen screen, double x, double y, int button) { clearCapture(); if (screen != frameScreen) return false; diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index c7c197bfa..45b65a996 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -14,7 +14,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; /** Native EMI integration: machine maps are independent of the vanilla RecipeManager and JEI. */ @EmiEntrypoint @@ -63,6 +62,7 @@ public void register(EmiRegistry registry) { }); gregtech.engine.fluid.FluidContainerDisplayBinding.invalidate(); FluidScreenStackProvider.register(registry); + registry.addGenericStackProvider(EmiWidgetInput::stackAt); WoodenBucketLookupRecipe.register(registry); FormConversionEmiRecipe.register(registry); registry.addRecipeHandler( @@ -102,9 +102,7 @@ public void register(EmiRegistry registry) { || map.mRecipeList.stream().noneMatch(r -> r.mEnabled && !r.mHidden) && !map.hasDynamicEnumeration()) continue; var workstations = machines.getOrDefault(map, java.util.List.of()); - ItemStack icon = workstations.isEmpty() ? new ItemStack(Items.ANVIL) : workstations.get(0); - var preferred = gregtech.compat.common.RecipeViewerIcons.map(map); - if (!preferred.isEmpty()) icon = preferred; + ItemStack icon = gregtech.compat.common.RecipeViewerIcons.category(map, machines); var id = ResourceLocation.fromNamespaceAndPath("gt6ce", map.mNameInternal.toLowerCase(Locale.ROOT)); var category = new EmiRecipeCategory(id, EmiStack.of(icon)) { @Override @@ -176,31 +174,21 @@ private ProcessNavigation(MaterialProcessSnapshot snapshot) { } @Override - public boolean openRecipe(gregtech.api.addon.material.DataKey reference) { - if (!MaterialProcessSnapshot.Store.current(snapshot)) return false; - var nativeRecipe = snapshot.recipe(reference); - if (nativeRecipe.isEmpty()) return false; - var row = nativeRecipe.get(); - var id = ResourceLocation.fromNamespaceAndPath( - "gt6ce", "/machine/" + row.map().mNameInternal.toLowerCase(Locale.ROOT) + "/" + row.index()); - var recipe = dev.emi.emi.api.EmiApi.getRecipeManager().getRecipe(id); - if (recipe == null) return false; - dev.emi.emi.api.EmiApi.displayRecipe(recipe); + public boolean openStack(ItemStack icon, boolean uses) { + if (!MaterialProcessSnapshot.Store.current(snapshot) || icon.isEmpty()) return false; + var stack = MaterialProcessEmiStacks.of(icon); + if (stack.isEmpty()) return false; + if (uses) dev.emi.emi.api.EmiApi.displayUses(stack); + else dev.emi.emi.api.EmiApi.displayRecipes(stack); return true; } @Override public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { if (!MaterialProcessSnapshot.Store.current(snapshot)) return false; - var pages = gregtech.compat.common.MaterialProcessProjection.pages( - snapshot, - resource, - uses - ? gregtech.engine.material.MaterialProcessGraph.Direction.USES - : gregtech.engine.material.MaterialProcessGraph.Direction.SOURCES, - this); + var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, resource, this); if (pages.isEmpty()) return false; - dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe(pages)); + dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe(pages.get(0))); return true; } } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java index 0b2d09ab9..c92c110c3 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java @@ -6,19 +6,19 @@ import dev.emi.emi.api.stack.EmiIngredient; import dev.emi.emi.api.stack.EmiStack; import dev.emi.emi.api.widget.Bounds; -import dev.emi.emi.api.widget.SlotWidget; import dev.emi.emi.api.widget.WidgetHolder; import gregtech.client.MaterialProcessPanel; import gregtech.compat.common.MaterialProcessDisplay; import gregtech.compat.common.RecipeViewerIcons; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; -/** EMI page adapter over the same bounded process display used by JEI. */ +/** EMI adapter over the same single-page, pannable process graph used by JEI. */ public final class MaterialProcessEmiRecipe implements EmiRecipe { private static final EmiRecipeCategory CATEGORY = new EmiRecipeCategory( @@ -31,36 +31,15 @@ public Component getName() { }; private final MaterialProcessDisplay.Page page; - private final List queryPages; - private final int queryPage; + private MaterialProcessPanel panel; private final ResourceLocation id; private final List inputs; private final List catalysts; private final List outputs; public MaterialProcessEmiRecipe(MaterialProcessDisplay.Page page) { - this(List.of(page), 0); - } - - public MaterialProcessEmiRecipe(List pages) { - this(pages, 0); - } - - private MaterialProcessEmiRecipe(List pages, int index) { - queryPages = List.copyOf(pages); - queryPage = index; - this.page = queryPages.get(index); - id = ResourceLocation.fromNamespaceAndPath( - "gt6ce", - "/material_process/" - + Integer.toUnsignedString(page.title().getString().hashCode(), 36) - + "/" + page.number() - + "/" - + page.steps().stream() - .map(step -> step.reference().toString()) - .findFirst() - .orElse("empty") - .hashCode()); + this.page = page; + id = ResourceLocation.fromNamespaceAndPath("gt6ce", "/material_process/" + path(page.material())); var inputs = new ArrayList(); var catalysts = new ArrayList(); var outputs = new ArrayList(); @@ -73,6 +52,11 @@ private MaterialProcessEmiRecipe(List pages, int in this.outputs = List.copyOf(outputs); } + private static String path(String material) { + String path = material.toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9/._-]", "_"); + return path.isBlank() ? "unbound" : path; + } + private static void add( MaterialProcessDisplay.Port port, List inputs, @@ -90,7 +74,8 @@ private static void add( private static List stacks(MaterialProcessDisplay.Port port) { return port.icons().stream() - .map(EmiStack::of) + .map(MaterialProcessEmiStacks::of) + .filter(stack -> !stack.isEmpty()) .map(stack -> port.chance().isPresent() ? stack.setChance(port.chance().getAsInt() / 10_000F) : stack) @@ -153,18 +138,7 @@ public int getDisplayHeight() { @Override public void addWidgets(WidgetHolder widgets) { - for (int row = 0; row < page.steps().size(); row++) { - var step = page.steps().get(row); - for (var slot : MaterialProcessPanel.slots(step, row)) { - var port = slot.port(); - if (!port.hasIcons()) continue; - var ingredient = EmiIngredient.of(stacks(port)); - var widget = widgets.add(new PortSlot(ingredient, slot.x(), slot.y(), page, port)); - if (!slot.output()) - widget.catalyst(port.role() == MaterialProcessDisplay.Role.CATALYST - || port.role() == MaterialProcessDisplay.Role.PRESENCE); - } - } + if (panel == null) panel = new MaterialProcessPanel(page); widgets.add(new EmiInteractiveWidget() { @Override public Bounds getBounds() { @@ -174,55 +148,43 @@ public Bounds getBounds() { @Override public void render(GuiGraphics graphics, int x, int y, float delta) { EmiWidgetInput.rendered(this, graphics); - MaterialProcessPanel.draw(page, graphics, x, y); + panel.draw(graphics, x, y); + } + + @Override + public EmiIngredient ingredientAt(double x, double y) { + return EmiIngredient.of(panel.stacksAt(x, y).stream() + .map(MaterialProcessEmiStacks::of) + .filter(stack -> !stack.isEmpty()) + .toList()); } @Override public boolean mouseClicked(int x, int y, int button) { - if (queryPages.size() > 1 && pageCounterContains(x, y) && (button == 0 || button == 1)) { - int next = Math.floorMod(queryPage + (button == 0 ? 1 : -1), queryPages.size()); - dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe(queryPages, next)); - return true; - } - return MaterialProcessPanel.click(page, x, y, button); + return panel.click(x, y, button); + } + + @Override + public boolean pressed(double x, double y, int button) { + return panel.press(x, y, button); + } + + @Override + public boolean dragged(int button, double dx, double dy) { + return panel.drag(button, dx, dy); + } + + @Override + public boolean scrolled(double x, double y, double delta) { + return panel.scroll(x, y, delta); } @Override public List getTooltip(int x, int y) { - if (queryPages.size() > 1 && pageCounterContains(x, y)) - return List.of(ClientTooltipComponent.create( - Component.translatable("gt6ce.jei.material_process.page_controls") - .getVisualOrderText())); - return MaterialProcessPanel.tooltip(page, x, y).stream() + return panel.tooltip(x, y).stream() .map(line -> ClientTooltipComponent.create(line.getVisualOrderText())) .toList(); } }); } - - private static boolean pageCounterContains(int x, int y) { - return x >= MaterialProcessPanel.WIDTH - 38 && x < MaterialProcessPanel.WIDTH && y >= 0 && y < 12; - } - - private static final class PortSlot extends SlotWidget { - private final MaterialProcessDisplay.Page page; - private final MaterialProcessDisplay.Port port; - - private PortSlot( - EmiIngredient stack, int x, int y, MaterialProcessDisplay.Page page, MaterialProcessDisplay.Port port) { - super(stack, x, y); - this.page = page; - this.port = port; - drawBack(false); - for (Component line : port.tooltip()) appendTooltip(line); - } - - @Override - public boolean mouseClicked(int mouseX, int mouseY, int button) { - if ((button == 0 || button == 1) - && getBounds().contains(mouseX, mouseY) - && page.navigation().openForm(port.resource(), button == 1)) return true; - return super.mouseClicked(mouseX, mouseY, button); - } - } } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiStacks.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiStacks.java new file mode 100644 index 000000000..5c9d22a8b --- /dev/null +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiStacks.java @@ -0,0 +1,21 @@ +package gregtech.compat.emi; + +import dev.emi.emi.api.stack.EmiStack; +import gregtech.engine.fluid.FluidDisplayBinding; +import net.minecraft.world.item.ItemStack; + +/** The overview's display item is never the lookup handle for a native fluid. */ +public final class MaterialProcessEmiStacks { + private MaterialProcessEmiStacks() {} + + public static EmiStack of(ItemStack icon) { + if (!FluidDisplayBinding.hasPayload(icon)) return EmiStack.of(icon); +//? if >=1.21.1 { + /*var fluid = FluidDisplayBinding.resolveCurrent(icon); + return fluid.isEmpty() ? EmiStack.EMPTY : EmiStack.of(fluid.getFluid(), fluid.getComponentsPatch(), 1); +*///?} else { + var fluid = FluidDisplayBinding.resolve(icon); + return fluid.isEmpty() ? EmiStack.EMPTY : EmiStack.of(fluid.getFluid(), fluid.getTag(), 1); +//?} + } +} diff --git a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java index 4bb6cce30..198da84f4 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java @@ -243,24 +243,29 @@ private ProcessNavigation(MaterialProcessSnapshot snapshot) { } @Override - public boolean openRecipe(gregtech.api.addon.material.DataKey reference) { - if (runtime == null || !MaterialProcessSnapshot.Store.current(snapshot)) return false; - var nativeRecipe = snapshot.recipe(reference); - if (nativeRecipe.isEmpty()) return false; - var row = nativeRecipe.get(); - var category = categories.get(row.map()); - if (category == null) return false; - runtime.getRecipesGui().showRecipes(category, List.of(row.recipe()), List.of()); + public boolean openStack(ItemStack stack, boolean uses) { + if (runtime == null || !MaterialProcessSnapshot.Store.current(snapshot) || stack.isEmpty()) return false; + var role = uses ? mezz.jei.api.recipe.RecipeIngredientRole.INPUT : mezz.jei.api.recipe.RecipeIngredientRole.OUTPUT; + var factory = runtime.getJeiHelpers().getFocusFactory(); + var focuses = new ArrayList>(); + if (gregtech.engine.fluid.FluidDisplayBinding.hasPayload(stack)) { +//? if >=1.21.1 { + /*var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolveCurrent(stack); + if (!fluid.isEmpty()) focuses.add(factory.createFocus(role, mezz.jei.api.neoforge.NeoForgeTypes.FLUID_STACK, fluid)); +*///?} else { + var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolve(stack); + if (!fluid.isEmpty()) focuses.add(factory.createFocus(role, mezz.jei.api.forge.ForgeTypes.FLUID_STACK, fluid)); +//?} + } else focuses.add(factory.createFocus(role, mezz.jei.api.constants.VanillaTypes.ITEM_STACK, stack)); + if (focuses.isEmpty()) return false; + runtime.getRecipesGui().show(focuses); return true; } @Override public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { if (runtime == null || !MaterialProcessSnapshot.Store.current(snapshot)) return false; - var direction = uses - ? gregtech.engine.material.MaterialProcessGraph.Direction.USES - : gregtech.engine.material.MaterialProcessGraph.Direction.SOURCES; - var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, resource, direction, this); + var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, resource, this); runtime.getRecipesGui().showRecipes(processCategory, pages, List.of()); return true; } diff --git a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java index d00c7fcd7..80033a35b 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java +++ b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java @@ -3,7 +3,8 @@ import gregtech.client.MaterialProcessPanel; import gregtech.compat.common.MaterialProcessDisplay.Page; import gregtech.compat.common.MaterialProcessDisplay.Port; -import java.util.ArrayList; +import java.util.IdentityHashMap; +import java.util.Map; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.builder.ITooltipBuilder; import mezz.jei.api.gui.drawable.IDrawable; @@ -25,6 +26,7 @@ public final class MaterialProcessCategory implements IRecipeCategory { public static final RecipeType TYPE = RecipeType.create("gt6ce", "material_process", Page.class); private final IDrawable icon; + private final Map views = new IdentityHashMap<>(); public MaterialProcessCategory(IGuiHelper helper) { icon = helper.createDrawableItemStack(new ItemStack(Items.MAP)); @@ -57,20 +59,12 @@ public int getHeight() { @Override public void setRecipe(IRecipeLayoutBuilder builder, Page page, IFocusGroup focuses) { - for (int row = 0; row < page.steps().size(); row++) { - var step = page.steps().get(row); - var visible = MaterialProcessPanel.slots(step, row); - for (var slot : visible) { - if (!slot.port().hasIcons()) continue; - builder.addSlot(role(slot.port()), slot.x(), slot.y()) - .addItemStacks(slot.port().icons()) - .addRichTooltipCallback( - (view, tooltip) -> tooltip.addAll(slot.port().tooltip())); - } - var ports = new ArrayList(step.inputs()); - ports.addAll(step.outputs()); - for (var port : ports) - if (visible.stream().noneMatch(slot -> slot.port() == port) && port.hasIcons()) + for (var step : page.steps()) { + for (var port : step.inputs()) + if (port.hasIcons()) + builder.addInvisibleIngredients(role(port)).addItemStacks(port.icons()); + for (var port : step.outputs()) + if (port.hasIcons()) builder.addInvisibleIngredients(role(port)).addItemStacks(port.icons()); } } @@ -85,6 +79,7 @@ private static RecipeIngredientRole role(Port port) { @Override public void createRecipeExtras(IRecipeExtrasBuilder builder, Page page, IFocusGroup focuses) { + var panel = view(page); builder.addGuiEventListener(new IJeiGuiEventListener() { @Override public ScreenRectangle getArea() { @@ -93,18 +88,39 @@ public ScreenRectangle getArea() { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - return MaterialProcessPanel.click(page, mouseX, mouseY, button); + return panel.click(mouseX, mouseY, button) || panel.press(mouseX, mouseY, button); + } + + @Override + public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) { + return panel.drag(button, dragX, dragY); } + +//? if >=1.21.1 { + /*@Override + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + return panel.scroll(mouseX, mouseY, scrollY); + } +*///?} else { + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double delta) { + return panel.scroll(mouseX, mouseY, delta); + } +//?} }); } @Override public void draw(Page page, IRecipeSlotsView slots, GuiGraphics graphics, double mouseX, double mouseY) { - MaterialProcessPanel.draw(page, graphics, mouseX, mouseY); + view(page).draw(graphics, mouseX, mouseY); } @Override public void getTooltip(ITooltipBuilder tooltip, Page page, IRecipeSlotsView slots, double mouseX, double mouseY) { - tooltip.addAll(MaterialProcessPanel.tooltip(page, mouseX, mouseY)); + tooltip.addAll(view(page).tooltip(mouseX, mouseY)); + } + + private MaterialProcessPanel view(Page page) { + return views.computeIfAbsent(page, MaterialProcessPanel::new); } } diff --git a/minecraft/src/main/java/gregtech/content/data/MaterialTagPack.java b/minecraft/src/main/java/gregtech/content/data/MaterialTagPack.java index 1949f2825..2618c335c 100644 --- a/minecraft/src/main/java/gregtech/content/data/MaterialTagPack.java +++ b/minecraft/src/main/java/gregtech/content/data/MaterialTagPack.java @@ -4,6 +4,7 @@ import gregtech.engine.material.MaterialEquivalence; import gregtech.engine.material.VanillaUnificationDefinitions; import gregtech.content.block.MaterialBlockLike; +import gregtech.content.registry.GTFluids; import gregtech.platform.Mc; //? if >=1.21.1 { /*import gregtech.platform.neoforge.fluid.FluidDisplayItem;import net.minecraft.network.chat.Component; @@ -385,6 +386,16 @@ private synchronized Map data() { tag.addAll(values); tag.addAll(blocksByMaterial.getOrDefault(name,Set.of())); }); + for (var fluid : GTFluids.entries().entrySet()) { + String bound = fluid.getValue().materialKey(); + if (bound == null) bound = RegisteredFluids.boundMaterial(fluid.getValue().registryName()); + if (bound == null) continue; + var material = gregtech.engine.material.GTMaterialRegistry.get(bound); + if (material == null || !material.isValid()) continue; + add(tags, "gt6ce", "fluids", "fluid/" + MaterialEquivalence.materialName(material.resolve()), + fluid.getKey().toString()); + } + addSpecialProcessTags(tags); // Wood form tags for the wooden-pipe recipes (GT6's OD.plankAnyWood / OD.beamWood): vanilla // planks and slabs join through nested tag references, the port's own species are listed. // The beam identity is the modern stripped log, so vanilla stripped logs join it as well. @@ -537,6 +548,42 @@ private static void addMaterial(Map> target,gregtech.api.mate if(material==null||!material.isValid())return; target.computeIfAbsent(MaterialEquivalence.materialName(material),k->new TreeSet<>()).add(value); } + + private static void addSpecialProcessTags(Map> tags) { + var catalog = gregtech.engine.material.MaterialViews.catalog(); + for (var method : catalog.specialProcesses().methods()) { + for (var material : catalog.materials()) { + for (var rule : catalog.processes().find(material.key(), method.process())) { + String tagPath = rule.value() instanceof gregtech.api.addon.material.SpecialProcessValue.Target + ? method.targetTag().path() + : rule.value() instanceof gregtech.api.addon.material.SpecialProcessValue.Reagent + ? method.reagentTag().path() + : null; + if (tagPath == null) continue; + String materialName = gregtech.engine.material.MaterialEquivalence.materialName( + gregtech.engine.material.GTMaterialRegistry.get(material.key().name()).resolve()); + if (rule.forms().isEmpty()) { + add(tags, method.process().id().namespace(), "items", tagPath, + "#gt6ce:material/" + materialName); + add(tags, method.process().id().namespace(), "fluids", tagPath, + "#gt6ce:fluid/" + materialName); + continue; + } + for (var form : rule.forms()) { + if (Set.of("liquid", "gas", "molten").contains(form.name())) { + add(tags, method.process().id().namespace(), "fluids", tagPath, + "#gt6ce:fluid/" + materialName); + } else { + var prefix = gregtech.engine.prefix.PrefixRegistry.byName(form.name()); + if (prefix != null) + add(tags, method.process().id().namespace(), "items", tagPath, + "#gt6ce:" + prefix.getRegistryName() + "/" + materialName); + } + } + } + } + } + } private static void add(Map> tags,String ns,String kind,String path,String value) { //? if >=1.21.1 { /*// 1.21 registries use singular resource directories. Historical callers still diff --git a/minecraft/src/main/java/gregtech/content/recipe/ExternalOreRecipeLifecycle.java b/minecraft/src/main/java/gregtech/content/recipe/ExternalOreRecipeLifecycle.java index c03164858..0155fcc60 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/ExternalOreRecipeLifecycle.java +++ b/minecraft/src/main/java/gregtech/content/recipe/ExternalOreRecipeLifecycle.java @@ -35,7 +35,7 @@ public static void stopped(ServerStoppedEvent event) { SharedOreSiftingRows.clear(); SharedOreCrushingRows.clear(); SharedOilSandRows.clear(); - SharedPurifiedAcidRows.clear(); + SharedSpecialProcessRows.clear(); SharedThermalInputRows.clear(); SharedThermalRecyclingRows.clear(); MoltenMetalUnitRecipes.clear(); diff --git a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java index 7f387eead..87816aefa 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java @@ -144,7 +144,7 @@ private static Result applyGeneration(RecipeManager manager, long current) { SharedOreCrushingRows.rebuild(); SharedOilSandRows.rebuild(); // New purified-acid calls do not displace the earlier imported/static Bath producers. - SharedPurifiedAcidRows.rebuild(); + SharedSpecialProcessRows.rebuild(); MoltenMetalUnitRecipes.begin(); SharedThermalInputRows.rebuild(); SharedThermalRecyclingRows.rebuild(); @@ -161,6 +161,7 @@ private static Result applyGeneration(RecipeManager manager, long current) { long removeMillis = (System.nanoTime() - removeStarted) / 1_000_000L; var installStarted = System.nanoTime(); for (var marker : markers) if (marker.addition() != null) install(marker.id(), marker.addition(), tally); + SharedSpecialProcessRows.annotateCurrent(); long installMillis = (System.nanoTime() - installStarted) / 1_000_000L; rememberFurnaceChanges(furnaceBefore); LOGGER.info("[gregtech] Machine recipe overlay baseline {} rows, restore {} ms, producers {} ms, moved {}, " @@ -195,7 +196,7 @@ private static void recover(ItemMaterialRegistry.TagGenerationCheckpoint checkpo SharedOreSiftingRows.clear(); SharedOreCrushingRows.clear(); SharedOilSandRows.clear(); - SharedPurifiedAcidRows.clear(); + SharedSpecialProcessRows.clear(); SharedThermalInputRows.clear(); SharedThermalRecyclingRows.clear(); MoltenMetalUnitRecipes.clear(); @@ -289,7 +290,7 @@ private static void ensureBaseline() { exclude.addAll(SharedOreSiftingRows.owned()); exclude.addAll(SharedOreCrushingRows.baselineExcluded()); exclude.addAll(SharedOilSandRows.baselineExcluded()); - exclude.addAll(SharedPurifiedAcidRows.owned()); + exclude.addAll(SharedSpecialProcessRows.owned()); exclude.addAll(SharedThermalInputRows.owned()); exclude.addAll(SharedThermalRecyclingRows.owned()); // Maps created after the first reload still get one baseline. A captured map keeps its first snapshot. diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java index bc34355a4..42a4d36a5 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java @@ -143,6 +143,12 @@ public Query query(DataKey root, Direction direction, Budgets budgets) { return graph.query(root, direction, budgets); } + public Query queryMaterial(DataKey root, Budgets budgets) { + if (resource(root).isEmpty()) + return new Query(snapshot, root, Direction.BOTH, List.of(), List.of(), COVERAGE, false); + return graph.queryMaterial(root, budgets); + } + public Optional recipe(DataKey reference) { return Optional.ofNullable(nativeRecipes.get(reference)); } @@ -295,7 +301,15 @@ private static BuiltStep recipeStep( .map(ResourceLocation::toString) .toList()); return new BuiltStep( - new Step(reference, map.mNameInternal, inputs, outputs, details, true), materials); + new Step( + reference, + map.mNameInternal, + inputs, + outputs, + details, + Optional.ofNullable(recipe.specialProcess()), + true), + materials); } private static Port itemPort( @@ -521,7 +535,7 @@ private static BuiltStep scoped(BuiltStep built, long publication, long session) return new BuiltStep(new Step(step.reference(), step.name(), step.inputs().stream().map(port -> scoped(port, publication, session)).toList(), step.outputs().stream().map(port -> scoped(port, publication, session)).toList(), - step.details(), step.resolved()), built.materials); + step.details(), step.specialProcess(), step.resolved()), built.materials); } private static Port scoped(Port port, long publication, long session) { @@ -604,6 +618,15 @@ private static String path(String value) { return path.isBlank() ? "unknown" : path; } + /** State-sensitive display identity, independent of query scopes and per-recipe selectors. */ + public static String itemDisplayState(ItemStack stack) { + return "item:" + BuiltInRegistries.ITEM.getKey(stack.getItem()) + itemStateSuffix(stack); + } + + public static String fluidDisplayState(FluidStack stack) { + return "fluid:" + BuiltInRegistries.FLUID.getKey(stack.getFluid()) + fluidStateSuffix(stack); + } + private static String itemStateSuffix(ItemStack stack) { var suffix = new StringBuilder(); if (stack.isDamaged()) suffix.append("#damaged").append(stack.getDamageValue()); diff --git a/minecraft/src/main/java/gregtech/content/recipe/OreProcessingRecipeLoader.java b/minecraft/src/main/java/gregtech/content/recipe/OreProcessingRecipeLoader.java index 53a4c0320..583ffe1fb 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/OreProcessingRecipeLoader.java +++ b/minecraft/src/main/java/gregtech/content/recipe/OreProcessingRecipeLoader.java @@ -69,7 +69,7 @@ public void run() { SharedPurifiedCentrifugeRows.initialize(); SharedOreMagneticRows.initialize(); SharedOreSiftingRows.initialize(); - SharedPurifiedAcidRows.initialize(); + SharedSpecialProcessRows.initialize(); SharedThermalInputRows.initialize(); SharedThermalRecyclingRows.initialize(); SharedMineralSteamCrackingRows.initialize(); diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedAcidRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedAcidRows.java deleted file mode 100644 index a2ad3a110..000000000 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedAcidRows.java +++ /dev/null @@ -1,252 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.api.material.GTMaterial; -import gregtech.api.material.MaterialProperty; -import gregtech.content.data.FluidCatalog; -import gregtech.content.data.MachineRecipeMaps; -import gregtech.content.data.MaterialPrefix; -import gregtech.content.material.catalog.MaterialFluidUnitFacts; -import gregtech.content.registry.GTFluids; -import gregtech.engine.addon.AddonMaterials; -import gregtech.engine.material.GTMaterialRegistry; -import gregtech.engine.recipe.Recipe; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.material.Fluids; -//? if >=1.21.1 { -/*import net.neoforged.neoforge.fluids.FluidStack; -*///?} else { -import net.minecraftforge.fluids.FluidStack; -//?} -import java.util.*; -import java.util.function.BiFunction; -import static gregtech.content.recipe.SharedOreWashingRows.NativeForm; -import static gregtech.content.recipe.SourceOreWashingRules.Availability; -import static gregtech.content.recipe.SourcePurifiedAcidData.*; -import static gregtech.content.recipe.SourcePurifiedAcidRules.*; -import static gregtech.content.material.MaterialFactKeys.Decision; -import static gregtech.content.material.MaterialFactKeys.Identity; - -/** Source Ores108-159 purified acid Bath calls, independent of ordinary ore washing gates. - * First admission is deliberately after existing static/imported producers. Ownership is only - * the object returned by ordinary addRecipe; no legacy signatures or unrelated rows are removed. - */ -public final class SharedPurifiedAcidRows { - private SharedPurifiedAcidRows() {} - private static final Set OWNED = Collections.newSetFromMap(new IdentityHashMap<>()); - private static final List DEFERRED = new ArrayList<>(); - private static final List ADMISSIONS = new ArrayList<>(); - private static List materials = List.of(); - private static boolean initialized; - - public record Deferred(String material, String producer, String reason) {} - public record Admission(String material, String producer, Shape shape, boolean accepted) {} - public static Set owned() { - var result = Collections.newSetFromMap(new IdentityHashMap()); - result.addAll(OWNED); return Collections.unmodifiableSet(result); - } - public static List deferred() { return List.copyOf(DEFERRED); } - public static List admissions() { return List.copyOf(ADMISSIONS); } - - /** Capture only the bounded source identity scope, not dynamic byproduct membership or forms. */ - public static void initialize() { - if (initialized) throw new IllegalStateException("Purified acid rows initialized twice"); - initialized = true; - Set seen = Collections.newSetFromMap(new IdentityHashMap<>()); - var selected = new ArrayList(); - for (var value : GTMaterialRegistry.allMaterials()) { - GTMaterial material = value.resolve(); - if (sourceIdentity(material) && seen.add(material)) selected.add(material); - } - selected.sort(Comparator.comparingInt(GTMaterial::getId)); - materials = List.copyOf(selected); - // No early rebuild: the existing ten imported acid calls and foreign producers retain - // their normal priority before the first overlay admits this new producer. - } - private static void clearOwned() { - OWNED.forEach(MachineRecipeMaps.Bath::unlink); OWNED.clear(); - } - /** Keep initialized identities for a subsequent server in the same JVM. */ - public static void clear() { clearOwned(); DEFERRED.clear(); ADMISSIONS.clear(); } - public static void rebuild() { - if (!initialized) return; - var snapshot = new Snapshot(); - var planned = definitions(materials, snapshot); - clearOwned(); DEFERRED.clear(); DEFERRED.addAll(snapshot.deferred); ADMISSIONS.clear(); - try { - for (var definition : planned) { - Recipe accepted = definition.admit(); - ADMISSIONS.add(new Admission(definition.material().name(), definition.producer(), - definition.shape(), accepted != null)); - if (accepted != null) OWNED.add(accepted); - } - } catch (RuntimeException | Error failure) { clear(); throw failure; } - } - - record Definition(Identity material, String producer, Shape shape, Result result, ItemStack input, - ItemStack[] outputs, FluidStack[] fluidInputs, FluidStack[] fluidOutputs) { - Recipe admit() { - // RecipeMap removes EMPTY fluids; unresolved source-positive phases must never reach it. - if (input.isEmpty() || fluidInputs.length != 1) return null; - for (var fluid : fluidInputs) if (fluid == null || fluid.isEmpty()) return null; - for (var fluid : fluidOutputs) if (fluid == null || fluid.isEmpty()) return null; - long[] chances = result.outputs().stream().mapToLong(Slot::chance).toArray(); - return MachineRecipeMaps.Bath.addRecipe(result.optimize(), new ItemStack[]{input.copy()}, - Arrays.stream(outputs).map(ItemStack::copy).toArray(ItemStack[]::new), null, chances, - Arrays.stream(fluidInputs).map(FluidStack::copy).toArray(FluidStack[]::new), - Arrays.stream(fluidOutputs).map(FluidStack::copy).toArray(FluidStack[]::new), - result.ticks(), result.power(), 0); - } - } - - static List definitions(Collection selected, Snapshot snapshot) { - var out = new ArrayList(); - var candidates = new ArrayList(); - Set seen = Collections.newSetFromMap(new IdentityHashMap<>()); - for (var material : selected) if (material != null && seen.add(material)) candidates.add(material); - // Literal family/member/shape order is significant; fixed families precede the dynamic loop. - for (var candidate : fixedCandidates()) for (var material : candidates) { - if (!candidate.material().matches(material.getId(), material.getName())) continue; - String producer = "fixed/" + candidate.family().sourceLine(); - if (!snapshot.context(material)) { - snapshot.note(material, producer, "unverified-source-material/" + candidate.shape()); continue; - } - var resolution = new Resolution(snapshot); - var result = fixedPlan(candidate.family(), candidate.material(), candidate.shape(), resolution); - add(material, producer, candidate.shape(), result, resolution, snapshot, out); - } - candidates.sort(Comparator.comparingInt(GTMaterial::getId)); - for (var material : candidates) { - Decision selector = snapshot.dynamicDecision(material); - if (selector == Decision.NO) continue; - for (var shape : Shape.values()) { - var resolution = new Resolution(snapshot); - var result = manganesePlan(identity(material), shape, selector, resolution); - add(material, "manganese", shape, result, resolution, snapshot, out); - } - } - return List.copyOf(out); - } - private static void add(GTMaterial material, String producer, Shape shape, Result result, - Resolution resolution, Snapshot snapshot, List out) { - if (result.status() != Status.ROW) { - if (result.status() == Status.UNSUPPORTED) - snapshot.note(material, producer, shape + ":" + result.reason() + resolution.problem); - return; - } - ItemStack[] outputs = result.outputs().stream().map(slot -> slot.item() == null - ? ItemStack.EMPTY : resolution.items.get(slot.item()).stack().copy()).toArray(ItemStack[]::new); - FluidStack[] inputs = result.fluidInputs().stream().map(fluid -> resolution.fluids.get(fluid).stack().copy()) - .toArray(FluidStack[]::new); - FluidStack[] fluids = result.fluidOutputs().stream().map(fluid -> resolution.fluids.get(fluid).stack().copy()) - .toArray(FluidStack[]::new); - out.add(new Definition(identity(material), producer, shape, result, - resolution.items.get(result.input()).stack().copy(), outputs, inputs, fluids)); - } - /** Cache exactly the objects proved during one plan; do not re-resolve an output after planning. */ - private static final class Resolution implements Resolver { - final Snapshot snapshot; - final Map items = new HashMap<>(); - final Map fluids = new HashMap<>(); - String problem = ""; - Resolution(Snapshot snapshot) { this.snapshot = snapshot; } - @Override public Availability item(MaterialPrefix prefix, Identity material, int count) { - var key = new SourcePurifiedAcidRules.Item(prefix, material, count); - var result = items.computeIfAbsent(key, ignored -> snapshot.item(prefix, material, count)); - if (result.availability() == Availability.UNKNOWN) problem = "/form:" + material.name() + "/" + prefix.getName(); - return result.availability(); - } - @Override public Availability fluid(Phase phase, long amount) { - var key = new SourcePurifiedAcidData.Fluid(phase, amount); - var result = fluids.computeIfAbsent(key, ignored -> snapshot.fluid(phase, amount)); - if (result.availability() == Availability.UNKNOWN) problem = "/phase:" + phase.name(); - return result.availability(); - } - } - private static Identity identity(GTMaterial material) { return new Identity(material.getId(), material.getName()); } - private static boolean canonical(GTMaterial material) { - return material != null && material.isValid() && material.resolve() == material - && GTMaterialRegistry.get(material.getName()).resolve() == material - && GTMaterialRegistry.isCoreMaterial(material) && !AddonMaterials.owns(material); - } - private static boolean sourceIdentity(GTMaterial material) { - // This table supplies identity evidence only, never thermal target/flag permissions. - return canonical(material) && (gregtech.content.material.MaterialFactKeys.sourceRecycling(material).isPresent() - || reviewedIdentity(identity(material))); - } - record NativeFluid(Availability availability, FluidStack stack) { - static NativeFluid unknown() { return new NativeFluid(Availability.UNKNOWN, FluidStack.EMPTY); } - static NativeFluid present(FluidStack stack) { return new NativeFluid(Availability.PRESENT, stack.copy()); } - } - static class Snapshot { - final List deferred = new ArrayList<>(); - private final SharedOreWashingRows.Snapshot forms = new SharedOreWashingRows.Snapshot(); - private final Map fluidDefinitions; - private final BiFunction lookup; - Snapshot() { this(FluidCatalog.all(), GTFluids::stack); } - Snapshot(Map definitions, BiFunction lookup) { - this.fluidDefinitions = Map.copyOf(definitions); this.lookup = lookup; - } - void note(GTMaterial material, String producer, String reason) { - deferred.add(new Deferred(material.getName(), producer, reason)); - } - boolean context(GTMaterial material) { return sourceIdentity(material); } - boolean anti(GTMaterial material) { return material.has(MaterialProperty.ANTIMATTER); } - List directByproducts(GTMaterial material) { - var result = new ArrayList(); - for (var byproduct : material.getByProducts()) { - GTMaterial value = byproduct == null ? null : byproduct.resolve(); - result.add(sourceIdentity(value) ? identity(value) : null); - } - return Collections.unmodifiableList(result); - } - Decision dynamicDecision(GTMaterial material) { - if (!context(material)) return Decision.UNKNOWN; - if (anti(material)) return Decision.NO; - return manganeseSelector(material.isValid(), false, directManganeseMembership(directByproducts(material))); - } - NativeForm item(MaterialPrefix prefix, Identity identity, int count) { - GTMaterial material = material(identity); - if (material == null) return NativeForm.unknown(); - // Direct forms only: no ORES/generation gate, continuation policy, or OM main fallback. - return forms.direct(prefix, material, count); - } - GTMaterial material(Identity identity) { - if (identity == null) return null; - GTMaterial material = GTMaterialRegistry.get(identity.name()).resolve(); - return canonical(material) && identity.matches(material.getId(), material.getName()) ? material : null; - } - NativeFluid fluid(Phase phase, long amount) { - GTMaterial material = phase == null ? null : material(phase.material()); - if (material == null || amount <= 0 || amount > Integer.MAX_VALUE) - return NativeFluid.unknown(); - // Water is vanilla water; it has no GT catalog entry. - if (phase == Phase.WATER) return NativeFluid.present(new FluidStack(Fluids.WATER, (int) amount)); - String nativePhase = phase.state() == State.GAS ? "gas" : "liquid"; - var binding = MaterialFluidUnitFacts.binding(material, nativePhase); - if (binding == null - || binding.referenceSourceUnits() != gregtech.api.material.GTValues.U - || binding.referenceMillibuckets() != 1000) return NativeFluid.unknown(); - String field = binding.fluidField(); - var entry = fluidDefinitions.get(field); - if (entry == null || !FluidCatalog.canonicalField(field).equals(field) || FluidCatalog.get(field) != entry - || entry.gas() != (phase.state() == State.GAS)) return NativeFluid.unknown(); - if (phase == Phase.HYDROGEN) { - if (entry != FluidCatalog.Hydrogen || !FluidCatalog.isBuiltInDefinition(entry)) return NativeFluid.unknown(); - if (!material.getName().equals(FluidCatalog.boundMaterial(entry.registryName()))) - return NativeFluid.unknown(); - } else if (!FluidCatalog.isGeneratedGasLiquidDefinition(field, entry) - || !material.getName().equals(entry.materialKey())) return NativeFluid.unknown(); - String expectedPath = "gt6ce:" + FluidCatalog.sanitizePath(binding.registryName()); - if (!binding.registryName().equals(entry.registryName())) return NativeFluid.unknown(); - var stack = lookup.apply(field, (int)amount); - if (stack == null || stack.isEmpty() || stack.getAmount() != amount - || !BuiltInRegistries.FLUID.getKey(stack.getFluid()).toString().equals(expectedPath)) - return NativeFluid.unknown(); - if (GTFluids.entryForFluid(stack.getFluid()) != entry) return NativeFluid.unknown(); - // All seventeen source phases are positively evidenced. A missing native output holder - // is UNKNOWN too, never source ABSENT that could silently discard a vitriol/gas product. - return NativeFluid.present(stack); - } - } -} diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java new file mode 100644 index 000000000..5c777bdab --- /dev/null +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java @@ -0,0 +1,340 @@ +package gregtech.content.recipe; + +import static gregtech.content.recipe.SharedOreWashingRows.NativeForm; +import static gregtech.content.recipe.SourceOreWashingRules.Availability; + +import gregtech.api.addon.material.FormKey; +import gregtech.api.addon.material.MaterialKey; +import gregtech.api.addon.material.MaterialProcessKey; +import gregtech.api.addon.material.SpecialProcessMethod; +import gregtech.api.addon.material.SpecialProcessValue; +import gregtech.api.material.GTValues; +import gregtech.content.data.FluidCatalog; +import gregtech.content.material.catalog.MaterialFluidUnitFacts; +import gregtech.content.registry.GTFluids; +import gregtech.engine.material.MaterialEquivalence; +import gregtech.engine.material.GTMaterialRegistry; +import gregtech.engine.material.MaterialViews; +import gregtech.engine.prefix.PrefixRegistry; +import gregtech.engine.recipe.Recipe; +import gregtech.engine.recipe.RecipeMap; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.IdentityHashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.material.Fluids; +//? if >=1.21.1 { +/*import net.neoforged.neoforge.fluids.FluidStack; +*///?} else { +import net.minecraftforge.fluids.FluidStack; +//?} + +/** Generic producer for declarative special-process targets and reagents. */ +public final class SharedSpecialProcessRows { + private static final Set OWNED = Collections.newSetFromMap(new IdentityHashMap<>()); + private static boolean initialized; + + private SharedSpecialProcessRows() {} + + public static void initialize() { + initialized = true; + } + + public static void clear() { + OWNED.forEach(recipe -> RecipeMap.RECIPE_MAP_LIST.forEach(map -> { + map.unlink(recipe); + })); + OWNED.clear(); + RecipeMap.RECIPE_MAP_LIST.forEach(map -> map.mRecipeList.forEach(recipe -> recipe.withSpecialProcess(null))); + } + + public static Set owned() { + var result = Collections.newSetFromMap(new IdentityHashMap()); + result.addAll(OWNED); + return Collections.unmodifiableSet(result); + } + + public static void rebuild() { + if (!initialized) return; + clear(); + var catalog = MaterialViews.catalog(); + var methods = methodRules(catalog); + var resolver = new Resolver(); + for (var methodRules : methods) { + var method = methodRules.method(); + RecipeMap map = RecipeMap.RECIPE_MAP_LIST.stream() + .filter(candidate -> candidate.mNameInternal.equals(method.recipeMap())) + .findFirst() + .orElse(null); + if (map == null) + throw new IllegalArgumentException( + "Special process " + method.process().id() + " names unknown recipe map " + method.recipeMap()); + if (methodRules.reagents().isEmpty()) continue; + for (var target : methodRules.targets()) { + for (var inputEntry : target.inputCounts().entrySet().stream() + .sorted(Map.Entry.comparingByKey(Comparator.comparing(FormKey::name))) + .toList()) { + for (var reagent : methodRules.reagents()) { + var built = build( + target.material(), inputEntry.getKey(), inputEntry.getValue(), target.plan(), + reagent, resolver); + if (built == null) continue; + Recipe accepted = map.addRecipe(built); + if (accepted != null) { + accepted.withSpecialProcess(method.process().id()); + OWNED.add(accepted); + } + } + } + } + } + annotateExistingRows(methods); + } + + /** Marks rows installed after static/addon producers, including datapack recipe documents. */ + public static void annotateCurrent() { + if (!initialized) return; + annotateExistingRows(methodRules(MaterialViews.catalog())); + } + + private static void annotateExistingRows(List methods) { + var byMap = methods.stream() + .collect(java.util.stream.Collectors.groupingBy( + rules -> rules.method().recipeMap(), LinkedHashMap::new, java.util.stream.Collectors.toList())); + for (var map : RecipeMap.RECIPE_MAP_LIST) { + var candidates = byMap.getOrDefault(map.mNameInternal, List.of()); + if (candidates.isEmpty()) continue; + for (var recipe : map.mRecipeList) { + var matches = candidates.stream().filter(rules -> matches(recipe, rules)).toList(); + if (matches.size() > 1) + throw new IllegalArgumentException("Recipe belongs to multiple special process methods in " + + map.mNameInternal); + if (matches.size() == 1) + recipe.withSpecialProcess(matches.get(0).method().process().id()); + } + } + } + + private static boolean matches(Recipe recipe, MethodRules rules) { + boolean target = false; + boolean reagent = false; + for (var selector : rules.targets()) { + for (var input : selector.inputCounts().entrySet()) { + if (containsItem(recipe, selector.material(), input.getKey(), input.getValue())) { + target = true; + break; + } + } + } + for (var selector : rules.reagents()) { + for (var form : selector.forms()) + if (containsInput(recipe, selector.material(), form)) { + reagent = true; + break; + } + } + return target && reagent; + } + + private static boolean containsInput(Recipe recipe, MaterialKey material, FormKey form) { + return isFluid(form) + ? java.util.Arrays.stream(recipe.mFluidInputs) + .anyMatch(stack -> sameFluidMaterial(stack, material, form)) + : java.util.Arrays.stream(recipe.mInputs).anyMatch(stack -> sameItemForm(stack, material, form)); + } + + private static boolean containsItem(Recipe recipe, MaterialKey material, FormKey form, int count) { + return java.util.Arrays.stream(recipe.mInputs) + .anyMatch(stack -> stack != null + && !stack.isEmpty() + && stack.getCount() == count + && sameItemForm(stack, material, form)); + } + + private static boolean sameItemForm(ItemStack stack, MaterialKey material, FormKey form) { + if (stack == null || stack.isEmpty()) return false; + var equivalent = MaterialEquivalence.form(stack); + return equivalent != null + && equivalent.material().resolve().getName().equals(material.name()) + && equivalent.prefix().getName().equals(form.name()); + } + + private static boolean sameFluidMaterial(FluidStack stack, MaterialKey material, FormKey form) { + if (stack == null || stack.isEmpty() || !isFluid(form)) return false; + var entry = GTFluids.entryForFluid(stack.getFluid()); + if (entry == null) return false; + var value = gregtech.engine.fluid.FluidVisualPolicy.material(entry).resolve(); + return value.isValid() && value.getName().equals(material.name()) && entry.gas() == form.name().equals("gas"); + } + + private static Recipe build( + MaterialKey target, + FormKey inputForm, + int inputCount, + SpecialProcessValue.Target plan, + ReagentSelector reagent, + Resolver resolver) { + ItemStack input = resolver.item(target, inputForm, inputCount); + if (input.isEmpty()) return null; + var itemInputs = new ArrayList(); + itemInputs.add(input); + var fluidInputs = new ArrayList(); + if (!addReagent(reagent, plan.reagentAmount(), itemInputs, fluidInputs, resolver)) return null; + + var itemOutputs = new ArrayList(); + var chances = new ArrayList(); + for (var output : plan.itemOutputs()) { + ItemStack stack = firstItem(output, resolver); + if (stack.isEmpty()) continue; + itemOutputs.add(stack); + chances.add((long) output.chance()); + } + var fluidOutputs = new ArrayList(); + for (var output : plan.fluidOutputs()) { + FluidStack stack = firstFluid(output, resolver); + if (!stack.isEmpty()) fluidOutputs.add(stack); + } + if (itemOutputs.isEmpty() && fluidOutputs.isEmpty()) return null; + return new Recipe( + itemInputs.toArray(ItemStack[]::new), + itemOutputs.toArray(ItemStack[]::new), + null, + chances.stream().mapToLong(Long::longValue).toArray(), + fluidInputs.toArray(FluidStack[]::new), + fluidOutputs.toArray(FluidStack[]::new), + plan.duration(), + plan.euPerTick(), + 0); + } + + private static boolean addReagent( + ReagentSelector reagent, + long amount, + List itemInputs, + List fluidInputs, + Resolver resolver) { + for (var form : reagent.forms().stream() + .sorted(Comparator.comparing(FormKey::name)) + .toList()) { + if (isFluid(form)) { + FluidStack fluid = resolver.fluid(reagent.material(), form, amount); + if (!fluid.isEmpty()) { + fluidInputs.add(fluid); + return true; + } + } else { + if (amount > Integer.MAX_VALUE) return false; + ItemStack stack = resolver.item(reagent.material(), form, Math.toIntExact(amount)); + if (!stack.isEmpty()) { + itemInputs.add(stack); + return true; + } + } + } + return false; + } + + private static ItemStack firstItem(SpecialProcessValue.ItemOutput output, Resolver resolver) { + for (var candidate : output.forms()) { + ItemStack stack = resolver.item(output.material(), candidate.form(), candidate.count()); + if (!stack.isEmpty()) return stack; + } + return ItemStack.EMPTY; + } + + private static FluidStack firstFluid(SpecialProcessValue.FluidOutput output, Resolver resolver) { + for (var candidate : output.forms()) { + if (!isFluid(candidate.form())) continue; + FluidStack stack = resolver.fluid(output.material(), candidate.form(), output.millibuckets()); + if (!stack.isEmpty()) return stack; + } + return FluidStack.EMPTY; + } + + private static boolean isFluid(FormKey form) { + return form.name().equals("liquid") || form.name().equals("gas") || form.name().equals("molten"); + } + + private record TargetSelector(MaterialKey material, Map inputCounts, SpecialProcessValue.Target plan) {} + + private record ReagentSelector(MaterialKey material, Set forms) {} + + private record MethodRules( + SpecialProcessMethod method, List targets, List reagents) {} + + private static List methodRules(gregtech.api.addon.material.MaterialCatalogView catalog) { + var targets = new LinkedHashMap, List>(); + var reagents = new LinkedHashMap, List>(); + for (var material : catalog.materials()) { + for (var key : catalog.processes().keys(material.key())) { + for (var rule : catalog.processes().find(material.key(), key)) { + if (rule.value() instanceof SpecialProcessValue.Target plan) { + targets.computeIfAbsent(key, ignored -> new ArrayList<>()) + .add(new TargetSelector(material.key(), plan.inputCounts(), plan)); + } else if (rule.value() instanceof SpecialProcessValue.Reagent) { + reagents.computeIfAbsent(key, ignored -> new ArrayList<>()) + .add(new ReagentSelector(material.key(), rule.forms())); + } + } + } + } + return catalog.specialProcesses().methods().stream() + .map(method -> new MethodRules( + method, + List.copyOf(targets.getOrDefault(method.process(), List.of())), + List.copyOf(reagents.getOrDefault(method.process(), List.of())))) + .toList(); + } + + private record ItemKey(MaterialKey material, FormKey form, int count) {} + + private record FluidKey(MaterialKey material, FormKey form, long amount) {} + + private static final class Resolver { + private final SharedOreWashingRows.Snapshot forms = new SharedOreWashingRows.Snapshot(); + private final Map items = new HashMap<>(); + private final Map fluids = new HashMap<>(); + + private ItemStack item(MaterialKey materialKey, FormKey form, int count) { + var key = new ItemKey(materialKey, form, count); + return items.computeIfAbsent(key, ignored -> resolveItem(materialKey, form, count)).copy(); + } + + private FluidStack fluid(MaterialKey materialKey, FormKey form, long amount) { + var key = new FluidKey(materialKey, form, amount); + FluidStack value = fluids.computeIfAbsent(key, ignored -> resolveFluid(materialKey, form, amount)); + return value.copy(); + } + + private ItemStack resolveItem(MaterialKey materialKey, FormKey form, int count) { + if (isFluid(form) || count < 1) return ItemStack.EMPTY; + var material = GTMaterialRegistry.get(materialKey.name()).resolve(); + var prefix = PrefixRegistry.byName(form.name()); + if (material == null || !material.isValid() || prefix == null) return ItemStack.EMPTY; + NativeForm nativeForm = forms.direct(prefix, material, count); + return nativeForm.availability() == Availability.PRESENT ? nativeForm.stack().copy() : ItemStack.EMPTY; + } + + private FluidStack resolveFluid(MaterialKey materialKey, FormKey form, long amount) { + if (!isFluid(form) || amount < 1 || amount > Integer.MAX_VALUE) return FluidStack.EMPTY; + if (materialKey.name().equals("Water")) return new FluidStack(Fluids.WATER, (int) amount); + var material = GTMaterialRegistry.get(materialKey.name()).resolve(); + if (material == null || !material.isValid()) return FluidStack.EMPTY; + var binding = MaterialFluidUnitFacts.binding(material, form.name()); + if (binding == null + || binding.referenceSourceUnits() != GTValues.U + || binding.referenceMillibuckets() != 1000) return FluidStack.EMPTY; + var entry = FluidCatalog.get(binding.fluidField()); + if (entry == null || entry.gas() != form.name().equals("gas")) return FluidStack.EMPTY; + FluidStack stack = GTFluids.stack(binding.fluidField(), (int) amount); + if (stack == null || stack.isEmpty() || stack.getAmount() != amount) return FluidStack.EMPTY; + return stack; + } + } +} diff --git a/minecraft/src/main/java/gregtech/content/recipe/generated/GTOreRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/generated/GTOreRecipes.java index 82a715003..aca269e3a 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/generated/GTOreRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/generated/GTOreRecipes.java @@ -38,7 +38,7 @@ public static void register(boolean easyU235Extraction) { ChemRecipeResolver.exclude(SOURCE + "owned", "magnetic-separator block dust and purified sifter rows are owned by their reviewed producers"); ChemRecipeResolver.exclude(SOURCE + "108-159", - "the purified-acid vitriol loops are owned by SharedPurifiedAcidRows"); + "the purified-acid vitriol loops are owned by SharedSpecialProcessRows"); ChemRecipeResolver.exclude(SOURCE + "54-57/174-190", "bedrock, moon and end rows need retired materials; Cryotheum/Pyrotheum loops need retired fluids"); ChemRecipeResolver.exclude(SOURCE + "63", diff --git a/minecraft/src/main/java/gregtech/engine/recipe/Recipe.java b/minecraft/src/main/java/gregtech/engine/recipe/Recipe.java index 5a52627f4..c5dcd76b4 100644 --- a/minecraft/src/main/java/gregtech/engine/recipe/Recipe.java +++ b/minecraft/src/main/java/gregtech/engine/recipe/Recipe.java @@ -14,6 +14,7 @@ * and fluids, processing duration, energy cost, and output chances.

*/ public class Recipe { + private gregtech.api.addon.material.DataKey specialProcess; private static final ItemStack[] NO_ITEMS = new ItemStack[0]; private static final FluidStack[] NO_FLUIDS = new FluidStack[0]; private static final long[] NO_CHANCES = new long[0]; @@ -143,6 +144,16 @@ public enum Scope { */ public String mSource = ""; + /** Explicit special-process method ownership; ordinary rows stay null. */ + public Recipe withSpecialProcess(gregtech.api.addon.material.DataKey process) { + specialProcess = process; + return this; + } + + public gregtech.api.addon.material.DataKey specialProcess() { + return specialProcess; + } + /** * Map-assigned publication order. Used only as the deterministic tie-breaker between rows of * equal priority, replacing the accidental ordering of the backing collection. diff --git a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java index 117e20299..e59c91fb1 100644 --- a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java +++ b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java @@ -1,19 +1,25 @@ package gregtech.content.recipe; import gregtech.content.material.Materials; +import gregtech.content.registry.GTFluids; import gregtech.content.worldgen.MaterialWorldgenFacts; import gregtech.content.worldgen.MaterialWorldgenFacts.Fact; import gregtech.content.worldgen.MaterialWorldgenFacts.Kind; import gregtech.content.worldgen.MaterialWorldgenFacts.Ore; import gregtech.engine.material.MaterialProcessGraph.*; +import gregtech.engine.material.MaterialEquivalence; import gregtech.engine.material.MaterialPublication; +import gregtech.engine.material.MaterialViews; import gregtech.engine.recipe.Recipe; import gregtech.engine.recipe.RecipeMap; import java.util.ArrayList; import java.util.List; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.material.Fluids; @@ -32,6 +38,235 @@ public final class MaterialProcessSnapshotTests { private MaterialProcessSnapshotTests() {} + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void presentationPreservesNativeItemState(GameTestHelper helper) { + var input = new ItemStack(Items.IRON_INGOT); + var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(input); + data.putString("process_test", "stateful_input"); + gregtech.content.data.UsbDataMedia.store(input, data); + var recipe = row(new ItemStack[] {input}, Items.COPPER_INGOT); + var map = new RecipeMap(new ArrayList<>(List.of(recipe)), + "gt.test.process.presentation", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, + false, false, false, false); + RecipeMap.unregister(map); + var snapshot = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of(map)); + var root = snapshot.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); + var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, root.resource(), + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE); + var displayInput = pages.get(0).steps().get(0).inputs().get(0); + helper.assertTrue(gregtech.engine.stack.StackCompat.sameItem(displayInput.icons().get(0), input), + "presentation keeps the native item data instead of reconstructing an untagged icon"); + helper.assertTrue(displayInput.identity().equals(MaterialProcessSnapshot.itemDisplayState(input)), + "display identity preserves native state independently of snapshot references"); + var hammer = gregtech.compat.jei.RecipeMachines.collect().get(gregtech.content.data.MachineRecipeMaps.Hammer); + var hammerIcon = gregtech.compat.common.RecipeViewerIcons.categories().get(gregtech.content.data.MachineRecipeMaps.Hammer); + helper.assertTrue(hammer != null && !hammer.isEmpty() && hammerIcon != null && !hammerIcon.isEmpty() + && gregtech.engine.stack.StackCompat.sameItem(hammer.get(0), hammerIcon), + "hammer processes reuse the native viewer category icon instead of a partial workstation lookup"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewGroupsVisibleRoutesAndHidesAuxiliaries(GameTestHelper helper) { + var steps = new ArrayList(); + for (int variant = 0; variant < 3; variant++) { + var input = displayPort("selector_" + variant, "Copper", Items.COPPER_INGOT, false); + var lubricant = displayPort("lubricant_" + variant, "Other", Items.WATER_BUCKET, false); + var output = displayPort("output_" + variant, "Copper", Items.COPPER_BLOCK, true); + steps.add(new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "cutting_" + variant), + net.minecraft.network.chat.Component.literal("cutter"), new ItemStack(Items.STONECUTTER), + List.of(input, lubricant), List.of(output), List.of(), java.util.Optional.empty(), true)); + } + var page = gregtech.compat.common.MaterialProcessDisplay.pages( + net.minecraft.network.chat.Component.literal("Copper"), "Copper", steps, List.of(), + List.of(net.minecraft.network.chat.Component.literal("test")), + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); + var overview = new gregtech.compat.common.MaterialProcessOverview(page); + helper.assertTrue(overview.nodes().size() == 3 && overview.edges().size() == 2, + "visually identical A-machine-B routes merge across native selectors"); + var machine = overview.nodes().stream().filter(node -> node.machine()).findFirst().orElseThrow(); + helper.assertTrue(machine.steps.size() == 3 && machine.extra(), + "every original recipe survives behind one route and its plus marker"); + helper.assertTrue(overview.edges().stream().allMatch(edge -> edge.endpoints().size() == 3), + "merged wires retain all original port associations"); + helper.assertTrue(overview.nodes().stream().filter(node -> !node.machine()) + .noneMatch(node -> node.port().material().equals("Other") || node.copy), + "auxiliaries stay hidden and identical resources remain shared"); + helper.succeed(); + } + + private static gregtech.compat.common.MaterialProcessDisplay.Port displayPort( + String reference, String material, net.minecraft.world.item.Item item, boolean output) { + var name = net.minecraft.network.chat.Component.literal(reference); + var icon = new ItemStack(item); + return new gregtech.compat.common.MaterialProcessDisplay.Port( + new gregtech.api.addon.material.DataKey("test", reference), material, name, List.of(icon), + output ? gregtech.compat.common.MaterialProcessDisplay.Role.UNKNOWN + : gregtech.compat.common.MaterialProcessDisplay.Role.CONSUMED, + false, name, name, java.util.OptionalInt.of(10000), List.of(), MaterialProcessSnapshot.itemDisplayState(icon)); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewAlignsChainsAndPreservesFeedback(GameTestHelper helper) { + var steps = new ArrayList(); + var links = new ArrayList(); + for (int index = 0; index < 8; index++) { + steps.add(layoutStep("chain_" + index, "form_" + index, "form_" + (index + 1))); + if (index > 0) links.add(layoutConnection("chain_" + (index - 1), "chain_" + index, "form_" + index)); + } + var chain = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, links)); + helper.assertTrue(chain.nodes().size() == 17 && chain.nodes().stream().map(node -> node.y).distinct().count() == 1, + "eight native steps align as one continuous chain"); + var positions = layoutPositions(chain); + java.util.Collections.reverse(steps); + java.util.Collections.reverse(links); + helper.assertTrue(positions.equals(layoutPositions(new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, links)))), + "stable references make layout independent of input order"); + var loop = new gregtech.compat.common.MaterialProcessOverview(layoutPage( + List.of(layoutStep("loop_a", "loop_x", "loop_y"), layoutStep("loop_b", "loop_y", "loop_x"), + layoutStep("self", "self_form", "self_form")), + List.of(layoutConnection("loop_a", "loop_b", "loop_y"), layoutConnection("loop_b", "loop_a", "loop_x"), + layoutConnection("self", "self", "self_form")))); + helper.assertTrue(loop.nodes().stream().filter(node -> node.machine()).count() == 3, + "pure loops and self loops retain every native step"); + helper.assertTrue(loop.nodes().stream().anyMatch(node -> node.returning) + && loop.edges().stream().allMatch(edge -> edge.confirmed()), + "feedback is marked independently of confirmation"); + for (var edge : loop.edges()) { + helper.assertTrue(edge.feedback() || edge.to().layer > edge.from().layer, + "forward edges obey dependency layers"); + var ports = edge.endpoint().output() ? edge.endpoint().step().outputs() : edge.endpoint().step().inputs(); + helper.assertTrue(ports.get(edge.endpoint().index()) == edge.endpoint().port(), + "every visible arrow retains its exact original endpoint"); + } + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewSharesHubsWithoutInventingConnections(GameTestHelper helper) { + var steps = new ArrayList(); + var links = new ArrayList(); + steps.add(layoutStep("producer", "ore", "hub")); + for (int index = 0; index < 8; index++) { + steps.add(layoutStep("branch_" + index, "hub", "product_" + index)); + if (index != 7) links.add(layoutConnection("producer", "branch_" + index, "hub")); + } + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, links)); + helper.assertTrue(graph.connections().equals(links.stream().sorted(java.util.Comparator.comparing(connection -> + connection.source() + ":" + connection.target() + ":" + connection.resource())).toList()), + "layout retains only the supplied cross-step associations"); + helper.assertTrue(graph.nodes().stream().filter(node -> !node.machine() && node.port().resource().path().equals("hub")).count() == 1 + && graph.nodes().stream().noneMatch(node -> node.copy), + "busy resources stay shared instead of scattering copies across branches"); + for (var node : graph.nodes()) if (!node.machine() && node.endpoints.size() == 1) { + helper.assertTrue(node.endpoints.size() == 1, "each local copy owns its native endpoint"); + var endpoint = node.endpoints.get(0); + var machine = graph.nodes().stream().filter(candidate -> candidate.machine() + && candidate.steps.get(0).reference().equals(endpoint.step().reference())).findFirst().orElseThrow(); + helper.assertTrue(Math.abs(node.layer - machine.layer) == 1, + "local copies stay next to their consuming or producing machine"); + } + var left = layoutStep("left", "left_input", "left_output"); + var right = layoutStep("right", "right_input", "right_output"); + var withAuxiliary = List.of(new gregtech.compat.common.MaterialProcessDisplay.Step(left.reference(), left.name(), left.icon(), + left.inputs(), List.of(left.outputs().get(0), displayPort("water", "Other", Items.WATER_BUCKET, true)), + List.of(), java.util.Optional.empty(), true), + new gregtech.compat.common.MaterialProcessDisplay.Step(right.reference(), right.name(), right.icon(), + List.of(right.inputs().get(0), displayPort("water", "Other", Items.WATER_BUCKET, false)), right.outputs(), + List.of(), java.util.Optional.empty(), true)); + var noLink = new gregtech.compat.common.MaterialProcessOverview(layoutPage(withAuxiliary, List.of())); + var auxiliaryLink = new gregtech.compat.common.MaterialProcessOverview(layoutPage(withAuxiliary, + List.of(layoutConnection("left", "right", "water")))); + helper.assertTrue(layoutPositions(noLink).equals(layoutPositions(auxiliaryLink)), + "hidden auxiliary ports do not add layout dependencies or resources"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewKeepsDenseEdgesLocal(GameTestHelper helper) { + var random = new java.util.Random(42); + var steps = new ArrayList(); + for (int index = 0; index < 96; index++) + steps.add(layoutStep("dense_" + index, "form_" + random.nextInt(40), "form_" + random.nextInt(40))); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); + helper.assertTrue( + graph.nodes().stream() + .filter(node -> node.machine()) + .mapToInt(node -> node.steps.size()) + .sum() + == steps.size(), + "local copies retain all native steps"); + helper.assertTrue(graph.nodes().stream().anyMatch(node -> node.copy && node.returning), + "dense feedback uses marked local resources"); + helper.assertTrue(graph.nodes().stream().mapToInt(node -> node.y).min().orElseThrow() == 24, + "feedback does not reserve empty lanes above the graph"); + for (var edge : graph.edges()) { + helper.assertTrue(edge.path().size() == 2 && edge.to().layer > edge.from().layer, + "every visible connection is a single forward segment"); + for (var endpoint : edge.endpoints()) + helper.assertTrue( + (endpoint.output() ? endpoint.step().outputs() : endpoint.step().inputs()) + .get(endpoint.index()) + == endpoint.port(), + "copied and shared connections retain exact native ports"); + var from = edge.path().get(0); + var to = edge.path().get(1); + double slope = (double) (to.y() - from.y()) / (to.x() - from.x()); + for (var node : graph.nodes()) { + if (node.layer <= edge.from().layer || node.layer >= edge.to().layer) continue; + double leftY = from.y() + (node.x - 12 - from.x()) * slope; + double rightY = from.y() + (node.x + 12 - from.x()) * slope; + helper.assertTrue( + Math.max(leftY, rightY) < node.y - 14 || Math.min(leftY, rightY) > node.y + 14, + "direct connections avoid intermediate icons and markers"); + } + } + java.util.Collections.shuffle(steps, random); + helper.assertTrue( + layoutPositions(graph) + .equals(layoutPositions(new gregtech.compat.common.MaterialProcessOverview( + layoutPage(steps, List.of())))), + "dense cyclic layouts are stable when input order changes"); + helper.assertTrue(graph.connections().isEmpty(), "local copies do not invent logical associations"); + helper.succeed(); + } + + private static gregtech.compat.common.MaterialProcessDisplay.Step layoutStep(String id, String input, String output) { + return new gregtech.compat.common.MaterialProcessDisplay.Step(new gregtech.api.addon.material.DataKey("test", id), + net.minecraft.network.chat.Component.literal(id), new ItemStack(Items.STONECUTTER), + List.of(layoutPort(input, false)), + List.of(layoutPort(output, true)), List.of(), java.util.Optional.empty(), true); + } + + private static gregtech.compat.common.MaterialProcessDisplay.Port layoutPort(String reference, boolean output) { + var name = net.minecraft.network.chat.Component.literal(reference); + return new gregtech.compat.common.MaterialProcessDisplay.Port(new gregtech.api.addon.material.DataKey("test", reference), + "Copper", name, List.of(), output ? gregtech.compat.common.MaterialProcessDisplay.Role.UNKNOWN + : gregtech.compat.common.MaterialProcessDisplay.Role.CONSUMED, + false, name, name, java.util.OptionalInt.of(10000), List.of(), reference); + } + + private static gregtech.compat.common.MaterialProcessDisplay.Connection layoutConnection(String source, String target, String resource) { + return new gregtech.compat.common.MaterialProcessDisplay.Connection(new gregtech.api.addon.material.DataKey("test", source), + new gregtech.api.addon.material.DataKey("test", target), new gregtech.api.addon.material.DataKey("test", resource), true); + } + + private static gregtech.compat.common.MaterialProcessDisplay.Page layoutPage( + List steps, + List connections) { + return gregtech.compat.common.MaterialProcessDisplay.pages(net.minecraft.network.chat.Component.literal("Copper"), "Copper", + steps, connections, List.of(net.minecraft.network.chat.Component.literal("test")), + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); + } + + private static java.util.Map layoutPositions(gregtech.compat.common.MaterialProcessOverview graph) { + var result = new java.util.TreeMap(); + for (var node : graph.nodes()) result.put(node.key, node.x + ":" + node.y); + return result; + } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) public static void nativeProjectionKeepsOutputsAndCrossMaterialRoutes(GameTestHelper helper) { var first = row(new ItemStack[] {new ItemStack(Items.IRON_NUGGET), new ItemStack(Items.PAPER), @@ -106,6 +341,83 @@ public static void worldgenRevisionIncludesSelectionAndKind(GameTestHelper helpe helper.succeed(); } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void specialProcessRulesDriveTagsAndRecipeOwnership(GameTestHelper helper) { + var catalog = MaterialViews.catalog(); + var gold = new gregtech.api.addon.material.MaterialKey("Gold"); + var aquaRegia = new gregtech.api.addon.material.MaterialKey("AquaRegia"); + helper.assertTrue( + catalog.specialProcesses() + .find(SpecialProcessMethods.AQUA_REGIA_LEACHING.id()) + .isPresent(), + "aqua regia method is published"); + helper.assertTrue( + catalog.tags().contains(gold, new gregtech.api.addon.material.DataKey( + "gt6ce", "special_process/aqua_regia_leaching/target")), + "target tag is derived from the target rule"); + helper.assertTrue( + catalog.tags().contains(aquaRegia, new gregtech.api.addon.material.DataKey( + "gt6ce", "special_process/aqua_regia_leaching/reagent")), + "reagent tag is derived from the reagent rule"); + var method = catalog.specialProcesses() + .find(SpecialProcessMethods.AQUA_REGIA_LEACHING.id()) + .orElseThrow(); + var targetItemTag = TagKey.create( + Registries.ITEM, + ResourceLocation.fromNamespaceAndPath( + method.targetTag().namespace(), method.targetTag().path())); + var targetItems = BuiltInRegistries.ITEM.getTag(targetItemTag).orElseThrow(); + helper.assertFalse(targetItems.size() == 0, "target item resource tag has members"); + for (var holder : targetItems) { + var form = MaterialEquivalence.form(new ItemStack(holder.value())); + helper.assertTrue( + form != null + && (form.prefix().getName().equals("crushedPurified") + || form.prefix().getName().equals("crushedPurifiedTiny")), + "target item tag only contains declared purified forms"); + } + var reagentFluidTag = TagKey.create( + Registries.FLUID, + ResourceLocation.fromNamespaceAndPath( + method.reagentTag().namespace(), method.reagentTag().path())); + var reagentFluids = BuiltInRegistries.FLUID.getTag(reagentFluidTag).orElseThrow(); + helper.assertFalse(reagentFluids.size() == 0, "reagent fluid resource tag has members"); + for (var holder : reagentFluids) { + var entry = GTFluids.entryForFluid(holder.value()); + helper.assertTrue(entry != null, "reagent tag member has a fluid entry"); + if (entry == null) continue; + var material = gregtech.engine.fluid.FluidVisualPolicy.material(entry).resolve(); + helper.assertTrue( + material != null + && material.isValid() + && material.getName().equals("AquaRegia") + && !entry.gas(), + "reagent fluid tag only contains declared aqua regia liquid"); + } + var bath = RecipeMap.RECIPE_MAP_LIST.stream() + .filter(map -> map.mNameInternal.equals("gt.recipe.bath")) + .findFirst() + .orElseThrow(); + helper.assertTrue( + bath.mRecipeList.stream() + .anyMatch(recipe -> SpecialProcessMethods.AQUA_REGIA_LEACHING + .id() + .equals(recipe.specialProcess())), + "at least one Bath row is owned by the API method"); + var snapshot = MaterialProcessSnapshot.Store.current(); + var root = snapshot.roots().stream() + .filter(value -> value.material().equals("Gold")) + .findFirst() + .orElseThrow(); + var query = snapshot.queryMaterial(root.resource(), new Budgets(0, 512, 128, 4096)); + helper.assertTrue( + query.steps().stream().anyMatch(step -> step.specialProcess() + .filter(id -> id.equals(SpecialProcessMethods.AQUA_REGIA_LEACHING.id())) + .isPresent()), + "published aqua regia rows retain method ownership"); + helper.succeed(); + } + private static Recipe row(ItemStack[] inputs, net.minecraft.world.item.Item output) { return new Recipe(inputs, new ItemStack[] {new ItemStack(output)}, null, null, null, null, 20, 16, 0); } From d864d0664af936986140041c08868a9a63206102 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Sat, 14 Nov 2026 21:38:23 +0800 Subject: [PATCH 06/17] optimize GUI --- .../engine/material/MaterialProcessGraph.java | 27 +- .../resources/assets/gt6ce/lang/en_us.json | 1 + .../resources/assets/gt6ce/lang/zh_cn.json | 1 + .../material/MaterialProcessGraphTest.java | 40 ++ docs/architecture/packages/engine.md | 2 + docs/architecture/packages/runtime.md | 2 +- docs/development/material-process-display.md | 24 +- docs/development/material-process-layout.md | 28 +- docs/development/validation/checks/format.md | 2 + .../development/validation/checks/gametest.md | 2 +- .../validation/checks/manual-ingame.md | 10 +- .../gregtech/client/MaterialProcessPanel.java | 86 ++- .../compat/common/MaterialProcessDisplay.java | 22 +- .../common/MaterialProcessOverview.java | 571 +++++++++++++++--- .../common/MaterialProcessProjection.java | 5 +- .../compat/emi/GregTechEMIPlugin.java | 9 +- .../compat/emi/MaterialProcessEmiRecipe.java | 43 +- .../compat/jei/GregTechJEIPlugin.java | 5 + .../recipe/MaterialProcessSnapshot.java | 11 +- .../recipe/MaterialProcessSnapshotTests.java | 241 +++++++- 20 files changed, 968 insertions(+), 164 deletions(-) diff --git a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java index 7125cd85a..3a426725a 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java +++ b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java @@ -160,7 +160,7 @@ public record Query( } } - private record IndexedStep(int order, Step step) {} + private record IndexedStep(int order, Step step, boolean genericRecovery) {} private record Node(DataKey reference, int depth) {} @@ -248,7 +248,7 @@ public Query query(DataKey root, Direction direction, Budgets budgets) { if (direction != Direction.USES) omittedDepth += indexed.step.inputs().stream() .limit(budgets.maxPortsPerSide()) - .map(port -> outputs.getOrDefault(port.resource().key(), List.of())) + .map(port -> sources(port.resource().key())) .mapToInt(occurrences -> unseen(occurrences, visited, queued)) .sum(); if (direction != Direction.SOURCES) @@ -266,8 +266,7 @@ public Query query(DataKey root, Direction direction, Budgets budgets) { int available = Math.min(indexed.step.inputs().size(), budgets.maxPortsPerSide()); for (int index = 0; index < available && !stopped; index++) { Port port = indexed.step.inputs().get(index); - for (IndexedStep source : - outputs.getOrDefault(port.resource().key(), List.of())) { + for (IndexedStep source : sources(port.resource().key())) { Edge edge = new Edge( source.step.reference(), node.reference, @@ -370,13 +369,14 @@ public Query queryMaterial(DataKey root, Budgets budgets) { if (rootResource == null) return new Query(snapshot, root, Direction.BOTH, List.of(), List.of(), notices, false); - var selected = new java.util.TreeSet(Comparator.comparingInt(IndexedStep::order)); + var selected = new java.util.TreeSet( + Comparator.comparing(IndexedStep::genericRecovery).thenComparingInt(IndexedStep::order)); List materialResources = rootResource.material().equals("unknown") ? List.of(rootResource) : resourcesByMaterial.getOrDefault(rootResource.material(), List.of()); for (Resource resource : materialResources) { selected.addAll(inputs.getOrDefault(resource.key(), List.of())); - selected.addAll(outputs.getOrDefault(resource.key(), List.of())); + selected.addAll(sources(resource.key())); } var retained = new ArrayList(Math.min(selected.size(), budgets.maxSteps())); int omittedSteps = 0; @@ -450,7 +450,7 @@ private int enqueue( Set queued) { int omitted = 0; for (List starts : List.of( - sources ? outputs.getOrDefault(root, List.of()) : List.of(), + sources ? sources(root) : List.of(), uses ? inputs.getOrDefault(root, List.of()) : List.of())) { for (int index = 0; index < starts.size(); index++) { if (queued.size() >= budgets.maxSteps()) { @@ -475,6 +475,12 @@ private Step boundedStep(Step step, int maxPorts) { step.resolved()); } + private List sources(DataKey resource) { + return outputs.getOrDefault(resource, List.of()).stream() + .filter(indexed -> !indexed.genericRecovery()) + .toList(); + } + private static List boundedPorts(List ports, int maxPorts) { return ports.size() <= maxPorts ? ports : List.copyOf(ports.subList(0, maxPorts)); } @@ -523,11 +529,16 @@ public Builder notice(String code, int omitted) { } public Builder add(Step step) { + return add(step, false); + } + + /** Generic recovery remains a use of its input, without advertising every reclaimable item as a source. */ + public Builder add(Step step, boolean genericRecovery) { Objects.requireNonNull(step); if (steps.containsKey(step.reference())) throw new IllegalArgumentException("Duplicate process step " + step.reference()); int order = steps.size(); - IndexedStep indexed = new IndexedStep(order, step); + IndexedStep indexed = new IndexedStep(order, step, genericRecovery); steps.put(step.reference(), indexed); var inputResources = new HashSet(); for (Port port : step.inputs()) { diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index c184f6191..58f8485a4 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -61,6 +61,7 @@ "gt6ce.jei.material_process.title": "Mineral Processing", "gt6ce.jei.material_process.section.sources": "Sources", "gt6ce.jei.material_process.section.internal": "Conversions", + "gt6ce.jei.material_process.section.recovery": "Recovery", "gt6ce.jei.material_process.section.uses": "Uses", "gt6ce.jei.material_process.cluster": "%s x%s", "gt6ce.jei.material_process.group_count": "This group contains %s steps.", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index f31f23868..d559b104f 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -63,6 +63,7 @@ "gt6ce.jei.material_process.title": "矿物处理", "gt6ce.jei.material_process.section.sources": "来源", "gt6ce.jei.material_process.section.internal": "内部转换", + "gt6ce.jei.material_process.section.recovery": "回收", "gt6ce.jei.material_process.section.uses": "去向", "gt6ce.jei.material_process.cluster": "%s ×%s", "gt6ce.jei.material_process.group_count": "本组包含 %s 个步骤。", diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java index 35ba8644b..163a9e187 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java @@ -208,6 +208,46 @@ private static DataKey resource(String name) { return new DataKey("gt6ce", "resource/" + name); } + @Test + void genericRecoveryIsAnInputUseAndDoesNotSpendTheSourceBudget() { + var iron = resource("iron"); + var copper = resource("copper"); + var dust = resource("iron_dust"); + var reclaim = step( + "reclaim", + List.of(port(copper, Role.CONSUMED, "copper", "Copper")), + List.of(port(dust, Role.UNKNOWN, "dust", "Iron"))); + var internal = step( + "internal_recovery", + List.of(port(iron, Role.CONSUMED, "iron")), + List.of(port(dust, Role.UNKNOWN, "dust"))); + var source = step( + "ordinary_source", + List.of(port(copper, Role.CONSUMED, "copper", "Copper")), + List.of(port(iron, Role.UNKNOWN, "iron"))); + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(reclaim, true) + .add(internal, true) + .add(source) + .build(); + var material = graph.queryMaterial(dust, new Budgets(0, 2, 16, 16)); + assertEquals(List.of(source, internal), material.steps()); + assertEquals( + List.of(source), + graph.queryMaterial(dust, new Budgets(0, 1, 16, 16)).steps()); + assertFalse(material.truncated()); + assertTrue(graph.query(dust, Direction.SOURCES, Budgets.DEFAULT).steps().isEmpty()); + assertEquals( + List.of(reclaim), + graph.query(copper, Direction.USES, new Budgets(0, 1, 16, 16)).steps()); + assertEquals( + List.of(source), + graph.query(iron, Direction.SOURCES, Budgets.DEFAULT).steps()); + assertEquals( + List.of(internal), + graph.query(iron, Direction.USES, new Budgets(0, 8, 16, 16)).steps()); + } + private static Port port(DataKey key, Role role, String state) { return port(key, role, state, "Iron"); } diff --git a/docs/architecture/packages/engine.md b/docs/architecture/packages/engine.md index 352bf5ebb..740847a0a 100644 --- a/docs/architecture/packages/engine.md +++ b/docs/architecture/packages/engine.md @@ -70,6 +70,8 @@ `MultiblockMenus` 将已成型结构部件的普通右键交给主控现有菜单;库存、流体和菜单同步仍属于主控。`StructureWatchIndex.formedController` 读取成功匹配的非空气单元,包含普通方块和实际匹配的重复层,不重新扫描结构;没有唯一归属的共享普通壁板不自动选主控。`MultiblockMenuAccess` 为每次开窗保存点击位置,距离按该部件计算,并持续检查主控身份、结构成型和部件归属。覆盖板、工具、液体容器和潜行交互优先;没有 GUI 的主控不生成新菜单。 +`MaterialProcessGraph.Builder.add(step, genericRecovery)` 接收宿主核对回收归属及配方表后的判定,GENERIC 发布优先级本身不足以区分砧加工和回收:通用回收只作为输入用途进入材料页,不占用来源检索预算,不由机器名或物品形态推断。原始端口仍保留,原生配方注册不受此展示索引影响。 + ## 验收 - 核心规则优先在 core 验证,世界适配还需双平台编译与相关游戏场景。 diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index 32c33bf95..0f3978b9a 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,7 +70,7 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责原生端口实例、拓扑层级、连续链、局部副本和排线,`client.MaterialProcessPanel` 负责可读视口、副本/回流标记与原生交互;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、索引和事件适配。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 +矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责按机器/首产物合并相似路线、原生端口实例、可见拓扑层级、连续链、局部副本、输入/产物网格、独立路线紧凑排布、端口产量角标和排线,`client.MaterialProcessPanel` 负责可读视口、副本/回流标记与原生交互;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、索引和事件适配。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md index 942b84dd8..b41465af8 100644 --- a/docs/development/material-process-display.md +++ b/docs/development/material-process-display.md @@ -4,7 +4,7 @@ 这是 Minecraft 实现层的客户端调用接口,随模组编译;方法声明来自 API 1.9.0,但本页面本身不是独立 API JAR 的公共材料服务。分类和面板只在已安装 JEI/EMI 的客户端路径加载;无 viewer 的专用服务端入口不得引用它们。 -拓扑分层与资源局部副本的设计依据见[配方总览图布局设计](material-process-layout.md)。当前实现按原生依赖排布;辅料、工具、存在条件及额外副产物不作为额外图节点;`+` 只列可靠辅料名称,完整约束通过普通配方查询查看。 +拓扑分层与资源局部副本的设计依据见[配方总览图布局设计](material-process-layout.md)。当前实现按可见依赖排布;来源、材料内部转换、回收、去向在同一画布中按顺序排列,只为有内容的区域保留标题和分割线;辅料、工具、存在条件及额外副产物不作为额外图节点;`+` 只列可靠辅料名称,完整约束通过普通配方查询查看。 ## 入口与职责 @@ -29,11 +29,11 @@ ## 构造契约 - `DataKey` 在这里是调用方签发的快照内引用,不是新的材料身份或存档 ID。`Port.resource` 必须区分材料、形态、相态和原生状态;不同 tag/unit 选择器的原生引用保持独立。`Port.identity` 另作展示共享键:完整原生状态或规范选择器描述不包含查询代号及配方专属 selector 后缀;有原生图标时按实际显示代表的完整物品/流体状态识别相关展示实例;多候选 selector 可以与该代表同步高亮,并在总览共享一个资源节点,但原始候选集、消耗量和 guard 仍属于各原生步骤,不声称 selector 与具体物品可互换。不同 NBT/数据组件状态不得仅因图标相同而合并。已有 `MaterialKey`、`FormKey` 与原生匹配引用由后续适配器解析到该引用,不重新建立材料目录。 -- `Port` 的 `amount` 必须包含原生批量及单位,如件、U 或 mB。`quantity` 是生产者同时提供的紧凑图标角标(件数、省略为 1 的件数、U、mB 或未知标记),前端不解析 `amount` 文本、不换算、不从图标栈数量推导材料量。旧构造方法默认不显示数量角标。紧凑总览不在名称提示中显示数量与概率,完整值保留在原始步骤并通过 viewer 普通配方查询查看,避免共享资源节点承担多个不同配方的批量。`icons` 为有限代表,空列表表示符号资源;不展开 tag 或 unit 候选全集。使用现有 `FluidDisplayBinding.display(...)` 取得带相态/状态的流体代理物品,不创建另一套流体身份转换。 +- `Port` 的 `amount` 必须包含原生批量及单位,如件、U 或 mB。`quantity` 是生产者同时提供的紧凑图标角标(件数、省略为 1 的件数、U、mB 或未知标记),前端不解析 `amount` 文本、不换算、不从图标栈数量推导材料量。旧构造方法默认不显示数量角标。资源图标右下角显示非 1 件数量或带单位的量,左上角显示非必然产出的百分比,未知概率显示 `?%`。共享资源优先采用产出端口的值;同一外观路线的多个产出批量不同时以 `/` 分隔,超过三个不同值用省略号,tooltip 列出原生批量与概率,不取其中一个覆盖其他值。输入概率不绘制,原生批量不从图标栈数量推导。`icons` 为有限代表,空列表表示符号资源;不展开 tag 或 unit 候选全集。使用现有 `FluidDisplayBinding.display(...)` 取得带相态/状态的流体代理物品,不创建另一套流体身份转换。 - `Role.CONSUMED`、`CATALYST`、`PRESENCE` 只用于输入;`PRIMARY`、`BYPRODUCT`、`UNKNOWN` 只用于输出。输入不因为存在数量就自动消耗。无可靠主/副角色时用 `UNKNOWN`,不得按槽位猜测。 - `main` 是生产者提供的路线提示,每一步的输入和输出分别至多一个。总览显示本材料在该侧的全部消耗输入或产物;该侧没有本材料时,用 `main` 或稳定端口顺序选一个外部主输入/产物。工具、存在条件及其余辅料/额外副产物留在 `+` 中。这不改变原始角色,也不声称一个可见输入就是完整配方。 - `chance` 使用 `OptionalInt`,已知概率为 1—10000,未知为 `OptionalInt.empty()`,确定产出为 `OptionalInt.of(RecipeOutputChances.CERTAIN)`。输入概率不参与绘制。互斥/共享随机事件、未知相关性和原生状态限制必须放在 `details`;不能用边际概率声称各输出独立。世界生成权重放说明,不能当成掉落概率。 -- `Step` 保存同一步的联合输入、多输出及条件。`icon` 是生产者提供的代表机器图标,访问时返回副本;没有可靠机器代表时使用空图标,面板显示问号。`worldGenerated` 由快照的真实世界生成引用设置,不根据空输入、图标或引用字符串猜测;兼容构造方法默认为 `false`。活动世界生成步骤使用镐作为采集符号。普通机器工序复用 EMI 分类的 `RecipeMachines` 索引与 `RecipeViewerIcons.category(...)`,包括锤子等工具类图标;不再只遍历基础机器。机器、时间、能量、温度、维度、选择器、来源等通过 `details` 传入。`resolved=false` 表示原生关系/约束尚未解析,连接为虚线;显示图标仍可执行普通来源/用途查询。`resolved=true` 也不承诺玩家库存可执行。 +- `Step` 保存同一步的联合输入、多输出及条件;`genericRecovery` 来自宿主同时核对回收归属与配方表的判定,兼容构造方法默认为 `false`。`icon` 是生产者提供的代表机器图标,访问时返回副本;没有可靠机器代表时使用空图标,面板显示问号。`worldGenerated` 由快照的真实世界生成引用设置,不根据空输入、图标或引用字符串猜测;兼容构造方法默认为 `false`。活动世界生成步骤使用镐作为采集符号。普通机器工序复用 EMI 分类的 `RecipeMachines` 索引与 `RecipeViewerIcons.category(...)`,包括锤子等工具类图标;不再只遍历基础机器。机器、时间、能量、温度、维度、选择器、来源等通过 `details` 传入。`resolved=false` 表示原生关系/约束尚未解析,连接为虚线;显示图标仍可执行普通来源/用途查询。`resolved=true` 也不承诺玩家库存可执行。 - `Connection(source, target, resource, confirmed)` 必须指向当前结果内的两个步骤,且资源同时出现在源步骤输出和目标步骤输入中。前端不按相同物品图标补边;`confirmed=false` 保留为未确认关系。 - 文本与图标在构造时复制,列表只读,图标访问返回副本。调用方须将传入后取得的 `Component` 及说明视为只读。禁止传 `null`、空物品栈、错误侧角色、重复步骤引用、悬空关联或非法概率;构造/校验时抛出 `IllegalArgumentException`,不把无效数据改成空结果。 @@ -51,15 +51,19 @@ 分类只使用 `CONSUMED` 输入。仅作为催化剂或存在条件出现的本材料不能建立加工流向;无输入但没有世界生成标记的步骤不能据此声称是来源。没有满足上述条件的步骤不纳入这三个材料转换分类,不能把“不是来源”直接当成去向。 -分类保留为材料流向的语义说明,不决定节点准入或位置,也不绘制分割线。未分类、纯符号、无输入或无输出的合法步骤仍保留原始引用。图按**机器图标的完整物品状态+可见输入身份集合+可见输出身份集合**合并外观相同的路线;数量、条件、辅料、特殊工艺 method 或不同原生引用不再强制复制一条外观相同的路线。无图标工序没有可靠外观身份,仍按引用区分。 +通用回收统一由 `MaterialProcessSnapshot.NativeRecipe.genericRecovery()` 判定:配方必须具有 GENERIC 归属,且属于 `MachineRecipeMaps.Shredder`、`Melter` 或 `Smelter`。GENERIC 本身只是配方发布时的兜底优先级,砧敲碎等普通加工也使用它,不能单独作为回收标记。快照索引和展示投影共用此判定,再传给 core 的 `Builder.add(step, genericRecovery)`;不按翻译名称、诊断来源或粉末外观猜测。来源查询不收集通用回收行,材料页只在对应输入材料中把它作为用途保留,且在节点预算之前过滤;预算不足时先保留显式加工,再保留通用回收,仍报告准确截断;普通显式配方的来源关系不变。回收产物在机器旁使用带 `↩` 的独立展示实例,不反向约束主生产链。原始端口、逻辑关联和 viewer 原配方均保留。 + +分类按消费输入、产出和真实 worldGenerated 标记决定横向区域:其他材料转入本材料(含世界生成/泉)、本材料内部形态转换、本材料转为其他材料;通用回收独立归入内部转换之后、去向之前的回收区。这些区域共用一张画布、平移、缩放和标题;空区域不占宽度,有内容的相邻区域之间绘制分割线。未能可靠分类的合法步骤放入内部区,不据名称猜测,也不丢弃。未分类、纯符号、无输入或无输出的合法步骤仍保留原始引用。图按**机器图标的完整物品状态+首个可见输出身份+通用回收标记**直接合并相似路线;没有可见输出时才比较输入身份集合;次要输出不同的变体共用机器,其输出分支取可见端口的并集,并保留各自原生归属;数量、条件、辅料、特殊工艺 method 或不同原生引用不再强制复制一条外观相同的路线。无图标工序没有可靠外观身份,仍按引用区分。 + +相同机器和首产物的路线直接共用机器,不再以输入形态数、次要产物、概率、批量或隐藏辅料作为拆分条件。不同输入形态排列为三列网格;原生配方的联合输入仍完整保留。此处的共用表示可选路线,不能据此把各格输入解释为一次执行需要同时消耗,也不能把变体输出并集解释为一次执行同时产出。未知图标仍按原生引用区分。 合并只作用于总览:`Node.steps` 保留全部原生步骤;每条可见边的 `endpoints()` 保留全部 `Endpoint(step, output, index, port)`。原生配方、选择器约束、数量、概率与 viewer 检索索引不合并或删除。此图不用于推断配方执行等价性。 同一 `Port.identity` 在整图优先共享一个资源节点,即使来自不同 selector 或快照资源引用;不同完整 NBT/组件状态仍分开。点击只查询当前显示物品/流体的普通来源或用途,不再把一个节点绑定到任意一条原生配方。`Connection` 仍原样保留,不因展示共享新增逻辑关联。 -依赖图按稳定引用遍历,解除反馈边的前向层级约束后计算 DAG 层级;纯环与自环保留方向和标记。相邻层、低连接度且连续较长的路线优先对齐。等长分支按资源家族集中排序,再按邻近节点重心分配行;不因连接度大于阈值就拆散公共物品。非主链边跨越超过三层、纵向距离超过 192 单位、穿过中间节点或属于反馈边时,将该端口改为机器附近的局部资源副本,再重新排布。每个可见端口最多拆出一个副本,连续主链和邻近分支仍共享资源。 +各区分别排布可见依赖并横向拼接,跨区重复材料使用带标记的实例,不用长线穿过分割线;原始跨区 Connection 仍保留并可反查。区内依赖图按稳定引用遍历,解除反馈边的前向层级约束后计算 DAG 层级;纯环与自环保留方向和标记。相邻层优先按原生端口顺序对齐首个可见输出和首个可见输入,再参考连接度和链长;该排布优先级不会把未知角色改成 PRIMARY。同一机器的多个本材料产物按端口顺序紧挨排成至多三列的网格,输入替代形态使用相同网格;必要时为共享端口创建可反查的局部实例。网格与机器共用一根输入线或输出箭头,每个物品格仍独立命中、查询和显示角标。链段和网格按整体包围盒预留矩形空间后一起排布,并做四轮邻接重心排序,减少交叉;不因连接度大于阈值就拆散公共物品。边跨越超过三层、纵向距离超过 128 单位、穿过中间节点或属于反馈边时,将该端口改为机器附近的局部资源副本,再重新排布。次要输出离机器超过两行时也使用局部副本,避免副产物远离所属配方。每个可见端口最多拆出一个副本,短距离连续主链和邻近分支仍共享资源。建立局部副本后只按可见边计算层级,保留的逻辑 Connection 不再预留远处的隐形依赖列。互不相连的路线按各自网格宽度压紧横向列和空行,再按矩形尺寸就近排列成多列,避免短配方被最长链或其他路线的网格宽度撑开。 -常规悬停只显示实际物品/机器名称;无原生图标时使用符号名称。机器右上角 `+` 的独立悬停区域显示合并配方数和去重后的辅料名称,最多列出十二项;完整配方信息通过 viewer 普通查询查看。局部副本与回流仍有 `↗`/`↩` 标记,相关资源与边同步高亮。 +共享面板的常规悬停只显示实际物品/机器名称;EMI 节点使用原生槽位 tooltip;无原生图标时使用符号名称。机器右上角 `+` 的独立悬停区域显示合并配方数和去重后的辅料名称,最多列出十二项;完整配方信息通过 viewer 普通查询查看。局部副本与回流仍有 `↗`/`↩` 标记,相关资源与边同步高亮。 所有可见连接统一使用单段直线,分支直接斜向相连,不再混用正交折线。输入侧只连线,输出侧保留箭头,连续链为 `材料—机器→产出`。回流使用带 `↩` 标记的局部副本,不在画布顶部预留回流通道;副本之间不额外连线。线宽、虚线间距及箭头与节点使用同一画布变换,随缩放同比变化。布局在首次打开页面创建面板时完成;EMI 注册索引时不提前排布全部材料,缩放、平移和悬停不重新排图。 @@ -67,9 +71,9 @@ 拖拽空白区域向任意方向平移,滚轮围绕鼠标缩放,顶部 `−/+` 围绕视口中心缩放,“复位”采用 `max(0.75, min(1, 整图适配比例))`;超出视口时定位本材料的代表链,小图适配视口。滚轮仍可主动缩小查看全图。裁剪边界先通过 viewer 当前渲染矩阵转换为绝对 GUI 坐标;悬停、点击和 EMI 原生 ingredient provider 共同使用实际渲染矩阵及画布逆变换。页脚 `i` 提供覆盖及截断说明。 -- 机器和资源均使用普通来源/用途查询:左击查来源,右击查用途。机器调用 `Navigation.openStack(icon, uses)`,资源通过 `openPort` 的默认方法将当前代表传给 `openStack`,不再精确跳转某条配方。 -- 左/右击资源通过 `Navigation.openPort(port, uses)` 打开 viewer 原生配方/用途查询;EMI 的悬停 ingredient provider 同样提供真实物品或流体句柄,以支持原生快捷键。`openForm` 保留为显式打开另一材料总览的接口,不再作为生产页资源点击时重新打开总览的路径。 -- `Navigation.NONE` 明确表示不支持跳转。具体回调先核对同一快照是否仍有效;无法解析时返回 `false`。 +- EMI 的机器和资源直接接入原生 `SlotWidget`,槽位边界跟随画布变换并裁剪到视口;点击、释放、拖动物品、收藏、R/U 及自定义按键绑定由 EMI 处理。面板只处理缩放按钮与画布平移,不硬编码鼠标键打开来源/用途。 +- JEI 沿用 `Navigation.openStack`/`openPort` 的原生 focus 查询;EMI 原生槽位同样使用真实物品或流体句柄。`openForm` 保留为显式打开另一材料总览的接口,不再作为生产页资源点击时重新打开总览的路径。 +- `Navigation.valid()` 校验当前 generation;EMI 过期槽位返回空 ingredient,JEI 跳转回调继续拒绝过期引用。`Navigation.NONE` 不提供程序化跳转。 - 一个材料仍只注册一个 `Page`,局部副本只影响展示,没有删除原配方或另建执行模型。 ## 后续调用方式 @@ -85,7 +89,7 @@ registration.addRecipes(MaterialProcessCategory.TYPE, pages); `Navigation` 由内容适配器创建并捕获该次查询的会话/generation。每次跳转先检查当前版本,过期或不能解析时返回 `false`,不得跳转到新版本中“相似”的配方。不要捕获旧 `Level`/服务器实例,也不要从客户端直接扫描集成服务器表。生产者应将未来 `ProcessRef` 和实际材料形态引用映射到展示引用,适配器使用原生服务重新解析;UI 不发明第二个快照协议。 -`openStack` 必须通过 viewer 原生的物品/流体 focus 查询来源或用途。EMI 使用 `EmiApi.displayRecipes`/`displayUses`;JEI 使用 OUTPUT/INPUT focus。机器图标也加入 EMI ingredient provider,R/U 与鼠标采用同一个普通查询目标。普通查询保留完整原生状态,不解析某个 `Step.reference` 来选择精确配方。 +JEI 的 `openStack` 使用 OUTPUT/INPUT focus。EMI 不再实现总览的 `openStack` 点击分派,而由原生 `SlotWidget` 统一处理机器与物品的鼠标、键盘和拖拽行为。普通查询保留完整原生状态,不解析某个 `Step.reference` 来选择精确配方。 动态打开查询结果可复用 JEI `IRecipeManager.getRecipeCategory(TYPE)` 和 `IRecipesGui.showRecipes(category, pages, List.of())`;优先让结果仅随当前显示布局存活。若使用运行期 `addRecipes`,调用方必须负责重载、断线、换服以及旧记录和回调的释放;`hideRecipes` 只是隐藏,不能当作回收旧快照的手段。`MachineRecipeClient` 在断线时清除当前快照,`MaterialProcessSnapshot.Store` 只保留当前成功代和一代前代;展示页本身不缓存材料目录或配方表。 diff --git a/docs/development/material-process-layout.md b/docs/development/material-process-layout.md index cc56f418a..65c83dac3 100644 --- a/docs/development/material-process-layout.md +++ b/docs/development/material-process-layout.md @@ -6,7 +6,7 @@ 图标、工序节点和有向箭头是主要阅读方式。玩家打开页面后直接看到已查询的加工步骤、主材料输入和输出,无需先选工艺区、展开目录或翻配方列表。悬停用于补充数值和条件,普通来源/用途查询用于进一步查看详情。 -布局只依赖输入输出、资源身份、端口角色及已提供的关联。附属增加处理方式时,只要满足现有展示契约,就应自动参与排布;不得要求它先归入“机械加工”“热处理”等人工工艺区。现有来源、内部转换、去向可保留为说明信息,不再决定图的分区、节点准入或位置。 +布局只依赖输入输出、资源身份、端口角色及已提供的关联。附属增加处理方式时,只要满足现有展示契约,就应自动参与排布;不得要求它先归入“机械加工”“热处理”等人工工艺区。来源、内部转换、回收、去向按实际消费输入、产出与结构化回收归属分类,按此顺序排列在同一画布上,并在有内容的相邻区域之间以竖向分割线区分,空区域不占空间;这不是按机器名划分的人工工艺目录。世界生成和泉沿真实 worldGenerated 标记进入来源区,通用回收进入内部转换之后的独立回收区。未能可靠分类的合法步骤在内部区保留,不影响准入。 规模增大时增加画布面积,利用现有平移与缩放浏览。默认构图优先保证物品和箭头可辨认,不强制把整图缩到一个小视口。该方案接受资源图标重复和较长画布,以减少交叉、长连线与额外查找操作。 @@ -26,9 +26,11 @@ 辅料、催化剂、存在条件和额外副产物不作为图节点,也不扩展它们的生产路线。它们保留在原始 `Step`,由机器右上角 `+`、tooltip 和原配方展示数量、消耗语义和说明。该侧有本材料时显示本材料的全部消耗输入/产物;没有本材料时优先用 `main`,否则稳定选择一个非副产物的外部主端口。此选择仅压缩图面,不改变原始角色。 -普通连续加工链表现为 `A—机器→B—机器→C`。同机器图标、同主输入和主输出的多个配方共享一个工序,辅料本身不画入图中。 +非 1 件数量或带单位的量显示在格子右下角,非必然产出的概率显示在左上角;未知概率显示 `?%`。共享资源优先使用生产端口的角标;不同批量保留紧凑多值或省略号及 tooltip,不能用某一变体冒充所有配方。 -工序名称、材料名称和图标外观均不参与工艺分类。多步链的布局不要求识别“粉碎”“蒸煮”等特定名称。 +普通连续加工链表现为 `A—机器→B—机器→C`。同机器图标、同首个可见产物的多个配方共享一个工序,不同输入形态在旁边合成网格;辅料本身不画入图中。 + +工序名称和图标外观均不参与工艺分类;只比较端口材料与根材料的实际身份及结构化回收标记。多步链的布局不要求识别“粉碎”“蒸煮”等特定名称。 ## 事实图与展示实例分离 @@ -53,11 +55,11 @@ ## 展示去重与原生事实分离 -外观相同的路线按机器图标完整状态、可见输入身份集合和可见输出身份集合合并。不同 `Step.reference`、辅料、数量、条件或 method 仍保存于原始步骤,但不再要求总览重复显示相同图形。未知图标没有可靠外观键,不能只因同为问号就合并。 +相似路线按机器图标完整状态、首个可见输出身份和通用回收标记直接合并,没有可见输出时才比较输入身份集合。次要输出存在差异的变体共用机器,并保留全部可见输出分支及其原生归属;它不表示这些分支会在同一次执行中同时产出。不同 `Step.reference`、辅料、数量、条件或 method 仍保存于原始步骤,但不再要求总览重复显示相同图形。未知图标没有可靠外观键,不能只因同为问号就合并。 所有原生步骤、端口、选择器、单位、概率及关联原样保留,合并边可以反查全部原始端口;它不改变配方注册项或 viewer 索引,也不声称执行等价。原生配方重复采集仍需在事实产生处处理,不能通过视觉合并掩盖数据问题。 -相同 `Port.identity` 在全图优先共享一个资源节点,原生资源引用不同不再强制拆开。高连接度本身不触发复制,仅明显跨越多层且偏离主链的长连接才使用局部副本。统计区分原生配方数、显示路线数及资源副本数。 +相同 `Port.identity` 在同一区内优先共享一个资源节点,跨区保留带副本标记的材料实例,原生资源引用不同不再强制拆开。高连接度本身不触发复制,仅明显跨越多层且偏离主链的长连接才使用局部副本。统计区分原生配方数、显示路线数及资源副本数。 ## 自动布局流程 @@ -69,25 +71,25 @@ ### 处理循环并确定横向层级 -在可见消耗流、输出及显式步骤关联中按稳定引用检测反馈边,排除工具和存在条件的非消耗连接。当前实现用迭代深度优先遍历解除回环约束,再对前向 DAG 确定层级;反馈边只退出前向层级约束,逻辑方向及事实关联继续保留。 +在可见消耗流与输出中按稳定引用检测反馈边,排除工具和存在条件的非消耗连接。通用回收由快照统一核对 GENERIC 归属与研磨/熔化回收配方表,不能把同样使用 GENERIC 发布优先级的砧敲碎当成回收,判定入口见[展示接入](material-process-display.md#布局与交互):它作为输入材料的用途保留,不作为目标粉末的来源;输出采用机器旁的回流实例,输出关联不向主生产链施加前向层级约束。其余步骤用迭代深度优先遍历解除回环约束,再对前向 DAG 确定层级;反馈边只退出前向层级约束,逻辑方向及事实关联继续保留。 -前向图中,工序位置应晚于其参与排布的共同输入,产物位置应晚于工序。层数来自依赖关系,不来自工序类型。纯循环且没有外部入口时,用稳定引用选择布局锚点,不把这个锚点显示成“原料来源”。 +前向图中,工序位置应晚于其参与排布的共同输入,产物位置应晚于工序。每个区域内部的层数来自依赖关系,不来自工序类型;有内容的区域最后按来源、内部、回收、去向拼接,区域间不绘制长线,原始关联仍保留在反查数据中。纯循环且没有外部入口时,用稳定引用选择布局锚点,不把这个锚点显示成“原料来源”。 浏览器草图用简化的最早生产层估计展示效果;生产实现必须覆盖无外部入口的环、自环、多个生产者及未解析端口,不能直接照搬草图中有限的合成数据假设。层级只表示阅读位置,不代表可达性、执行先后保证或最短生产方案。 ### 识别连续链段并对齐 -在已有层级上,优先连接相邻层、较低连接度且端口关系明确的前后节点。可靠的 `main` 提示可以提高对应连接的排布优先级;没有提示时使用拓扑评分与稳定键作为回退。 +在已有层级上,首个可见输入与首个可见输出优先参与水平链对齐,顺序来自原生端口索引,再参考连接度、链长和稳定引用。原生首产物只获得排布优先级,不改变 UNKNOWN/PRIMARY 等事实角色。次要产物不会夺取该机器的主链位置。 将适合连续阅读的链段尽量放在同一水平线上,外观不同的替代路线及分叉就近排列。交汇点不能无条件合并所有相邻链段,否则一个公共原料会把全图重新拉成一个大团。这里的链段只用于坐标分配,不生成带工艺名称的分区,不删除原始步骤,也不要求玩家进入链段后才能阅读。 -排序可使用有限轮次的前后向重心调整;随后按实际节点包围盒压紧和避让。优化顺序为:不遮挡节点与文字、减少交叉、保持连续链水平、缩短连线,再减少画布面积。相同快照输入顺序变化时,稳定引用应保证结果可重复;悬停和高亮不得触发布局。 +同一机器的本材料多产物按原生端口顺序紧邻排成至多三列、自动换行的物品栏网格,共用一根输出箭头。同机器图标和首产物的替代路线共用机器,不要求输入形态数、次要产物、概率或隐藏辅料相同;输入形态使用相同的网格与一根输入线。共享资源必要时采用局部实例;格子仍保留原生端口、独立导航和角标。链和网格按整块矩形预留空间后一起分配位置,并进行四轮邻接重心排序;随后按实际节点包围盒压紧和避让。局部副本只受可见边约束,原始 Connection 保留用于反查与确认状态,不再占据隐形依赖列。独立连通块使用各自的列宽、移除空行,再按矩形尺寸紧凑排列成多列;不同路线不会共用最长链和最宽网格的占位。优化顺序为:不遮挡节点与文字、减少交叉、保持连续链水平、缩短连线,再减少画布面积。相同快照输入顺序变化时,稳定引用应保证结果可重复;悬停和高亮不得触发布局。 ### 选择资源局部副本 对造成明显扇入/扇出、跨多个层级、跨链长连接或回流拥挤的可见资源,在具体工序的输入侧或输出侧建立局部副本。可见产物与主输入均可采用该机制,不按工序名称或资源名单特判;隐藏辅料不参与复制。 -当前副本选择处理非主链且跨越超过三层、纵向相距超过 192 单位、会穿过中间节点或属于反馈边的连接,不按节点连接度直接拆副本。每轮拆分后重新排布,直到其余连接可以直接绘制;独立端口副本不再拆分。阈值仍需根据真实图调优。优先保留连续主链的直接连接及邻近分支的共享节点,避免无差别复制所有资源后把图拆成互不相连的配方小块。 +当前副本选择处理跨越超过三层、纵向相距超过 128 单位、会穿过中间节点或属于反馈边的连接,以及偏离机器超过两行的次要输出,不按节点连接度直接拆副本。每轮拆分后重新排布,直到其余连接可以直接绘制;独立端口副本不再拆分。阈值仍需根据真实图调优。优先保留连续主链的直接连接及邻近分支的共享节点,避免无差别复制所有资源后把图拆成互不相连的配方小块。 副本应满足: @@ -99,7 +101,7 @@ ### 端口排线与箭头 -所有连接统一使用单段直线;连续链保持水平,分支使用斜线,不混入正交折线。输入侧只画线,输出侧才画箭头。输入和输出分别分配固定侧的端口位置,当前同侧可见端口仍共用节点侧面锚点,密集多端口场景尚需游戏内确认并进一步调整。跨层边若会穿过中间节点,改用机器附近的资源副本。 +所有连接统一使用单段直线;连续链保持水平,分支使用斜线,不混入正交折线。输入侧只画线,输出侧才画箭头。输入和输出分别分配固定侧的端口位置,网格按整体侧边中点分配锚点,重复端口连线只绘制一次,悬停任一关联格均能高亮共享线;单个物品仍按自身侧边连接。密集多端口场景尚需游戏内确认。跨层边若会穿过中间节点,改用机器附近的资源副本。 回流和自环使用带 `↩` 标记的局部资源副本,保留真实输入/输出方向,不画跨越全图的回路,也不为回流预留顶部空白。没有节点的交叉处不画连接圆点,不同资源不能共用一段看似混料的总线;同一资源需要共线时,也应保留各工序的独立端口归属。 @@ -107,11 +109,11 @@ ## 视口与交互 -打开页面即绘制全部已查询步骤及可见主端口;完整端口仍保存在数据和各工序详情中。默认不出现工艺区选择器、步骤列表分页或必须展开的分组。常用浏览仍是看图、平移和缩放;副本标记在未悬停时也可见。 +打开页面即绘制全部已查询步骤及可见主端口;完整端口仍保存在数据和各工序详情中。有内容的区域同时存在于同一画布,不需要工艺区选择器、步骤列表分页或展开操作。有内容的分区标题及分割线随画布一起缩放和平移,空分区不分配空间。常用浏览仍是看图、平移和缩放;副本标记在未悬停时也可见。 初始缩放与复位采用可读性下限:小图可适配视口,大图保持可读比例并定位根材料的代表链附近。可用 `max(可读缩放下限, min(1, 整图适配比例))` 作为初始策略;具体下限根据游戏 GUI 缩放、物品尺寸及字体实际验证。若保留整图鸟瞰,应为显式操作,不能每次打开都自动把节点缩到难以辨认。 -沿用现有资源左/右击查询、机器和资源左/右击普通来源/用途查询与 EMI ingredient provider。高亮优先使用悬停,不能直接照搬草图的点选锁定而占用这些原生点击动作。常规图标提示只显示名称;只有 `+` 区域显示合并配方数与去重辅料名,不提供右击切换隐藏变体。 +沿用现有资源左/右击查询、机器和资源左/右击普通来源/用途查询与 EMI ingredient provider。高亮优先使用悬停,不能直接照搬草图的点选锁定而占用这些原生点击动作。EMI 图标使用原生槽位与 tooltip,鼠标、释放、快捷键、收藏及物品拖拽沿用 EMI 绑定;共享面板及 JEI 的常规图标提示只显示名称;只有 `+` 区域显示合并配方数与去重辅料名,不提供右击切换隐藏变体。 所有副本的绘制、命中、tooltip、点击和原生 ingredient provider 使用同一展示实例及相同视口变换。未解析关系仍保留说明与关系提示;资源副本不绕过快照 generation 校验。 diff --git a/docs/development/validation/checks/format.md b/docs/development/validation/checks/format.md index f8316220b..5a23ba893 100644 --- a/docs/development/validation/checks/format.md +++ b/docs/development/validation/checks/format.md @@ -16,6 +16,8 @@ Spotless 使用 Palantir Java Format 检查 Java 源码格式:4 空格缩进 `:api` 与 `:api-platform` 当前未接入 Spotless。修改这两层时仍要按现有文件风格书写,但不能把 `spotlessCheck` 通过解读为这两层已格式化;补齐接入属于单独的构建改动。 +存在 `origin/master` 时默认检查相对它的改动,缺失时检查已接入的源码;`-PspotlessRatchet=HEAD` 使用现有构建参数,仅检查当前工作区相对 HEAD 的改动,适合隔离分支上既有的无关格式问题。此范围通过不能代替默认全分支检查,默认检查的失败仍须单独报告。 + Spotless 排除 `**/generated/**` 与包含 Stonecutter `//?` 标记的共享文件;后两者由节点级处理。不要直接对生成副本套用格式任务。 ## 注意事项 diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index 040f1d906..bd5c71d3d 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -36,7 +36,7 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe ### 配方回归案例表 -材料处理的 `MaterialProcessSnapshotTests` 验证输入 tag 不污染输出、跨材料路线、世界生成形态与完整 revision、普通共同原料、辅助工具说明、过期资源拒绝和同代索引复用;`material_process` 批次不写生产配方。 +材料处理的 `MaterialProcessSnapshotTests` 验证输入 tag 不污染输出、跨材料路线、世界生成形态与完整 revision、普通共同原料、辅助工具说明、相似路线跨辅料/概率/输入形态合并、砧加工与研磨/熔化回收的分类、局部副本无隐形依赖占位、独立路线紧凑排布、过期资源拒绝和同代索引复用;`material_process` 批次不写生产配方。 材料领域的 `MaterialBaselineTests` 验证存储块的成分与两类准入、72U 附魔金苹果的规划和实际回收输出、复合钻头、耐久缩放、容器与有形状铸模、压模机模具、固体/流体分解及 test-source 材料 SPI。`material_baseline_reload` 为仅含一个测试的独立批次,等待两次真实资源重载;拥有规则数和固定样例必须稳定。原始投影写入根目录 `work/material-system-refactor/runtime//<运行目录>/`。已知错误行为明确标为观察,不能当作正确性依据;字段、复现与未覆盖范围见[材料基线报告](../../../integration/material-baseline.md)。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 31282ef29..8d422d3b8 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -22,16 +22,16 @@ 接口与测试输入契约见[展示接入](../../material-process-display.md)。生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用同一图和面板;没有成功快照时才显示未接入说明。 -1. 在 JEI/EMI 中打开真实材料的“矿物处理”。页面应直接显示依赖图,没有分类分栏。连续链水平向右,替代路线和分叉就近分行;未分类步骤、无外部入口环及自环不能消失。不同 GUI 缩放下右侧、底部裁剪正确。 -2. 切割机三种润滑剂相同主物品/机器图标/产物时只显示一条路线,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。物品和机器均左击普通来源、右击普通用途,不精确锁定原配方;常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。数量、概率、时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 +1. 在 JEI/EMI 中打开真实材料的“矿物处理”。页面应直接显示同一张画布上有内容的来源/内部转换/回收/去向区域、区标题与相邻区域分割线,空区域不留占位;世界生成和泉进入来源区;无切换或分页。连续链水平向右,替代路线和分叉就近分行;未分类步骤、无外部入口环及自环不能消失。不同 GUI 缩放下右侧、底部裁剪正确。 +2. 切割机三种润滑剂相同主物品/机器图标/首产物时只显示一条路线,次要输出不同也应共用机器、保留各分支,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。EMI 物品和机器使用原生槽位,确认自定义来源/用途绑定、点击释放、R/U、收藏及拖动物品均与普通 EMI 槽位一致,不精确锁定原配方;JEI 沿用普通来源/用途 focus;EMI 使用原生 tooltip,JEI 常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。非 1 件产量、U/mB 和非必然概率在图标上可见,精度保留至原生百分比;确定的 1 件产出不加数量/概率角标,未知概率显示 `?%`。共享资源采用生产端口的量,多个变体的不同量显示多值/省略号并可悬停查看;时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 3. 资源局部副本带 `↗`,回流带 `↩`,悬停同步突出相关实例和箭头。相同显示代表跨 selector 共享节点,不同 NBT/组件状态分开;同图标不能补造跨步骤关联。连接均为单段直线,分支斜向相连,输入无箭头、输出有箭头;遮挡图标的长边和回流改用局部副本,没有顶部回流通道。确认关系不因循环改为虚线。 4. 对带 NBT/组件物品与真实流体,逐个副本检查左/右击、R/U、tooltip 和 EMI ingredient provider;流体代理应查询实际流体。各节点使用实际显示的完整物品/流体状态查询,无法恢复时保留符号,不用无数据假栈。 -5. 来源/内部转换/去向仅在工序 tooltip 说明;“本材料+辅料 → 本材料其他形态+副产物”仍属内部转换。工具、存在条件及额外辅料/副产物均不扩展生产路线。主材料的多输入、多输出分支仍保留。 -6. 大图初始和复位保持至少 75% 可读比例并定位代表链;小图适配视口。滚轮围绕鼠标缩放,顶部 `−/+` 缩放;空白处左右、上下拖动有效。在 100%、25% 和约 8% 比例下确认线宽、虚线间距及箭头与图标同比缩小,不出现盖住整图的固定尺寸箭头。缩放和平移后,图标、`+`、tooltip、点击及 EMI 悬停命中一致。 +5. 来源/内部转换/回收/去向决定横向分区,不依据机器名称分组;“本材料+辅料 → 本材料其他形态+副产物”仍属内部转换。工具、存在条件及额外辅料/副产物均不扩展生产路线。主材料的多输入、多输出分支仍保留。相同机器和首产物的替代形态应折叠为三列网格,共用一根输入线;用多种木材产树皮的路线确认辅料、输入形态数、次要产物、批量和概率不同也会合并,差异可在普通配方查询中查看。透镜或螺栓加工等本材料多输出按端口顺序紧邻排成至多三列网格,共用输出箭头;共享资源也不能把产物挤到其他配方之外。逐格验证原生查询、悬停和 EMI 命中;同一组矩形内部不能插入其他路线的节点或连线。通用研磨/熔化回收配方同时核对 GENERIC 归属及 Shredder/Melter/Smelter 配方表,砧敲碎等普通加工不得进入回收区或被从材料来源中隐藏;回收途径在内部转换后、去向前的独立回收区展示,不能因产出少量粉末就铺成粉末来源;显式来源配方仍应存在。 +6. 独立路线应紧凑排列成多列,局部副本不在远处预留依赖列,短配方也不被其他路线的宽网格撑开。大图初始和复位保持至少 75% 可读比例并定位代表链;小图适配视口。滚轮围绕鼠标缩放,顶部 `−/+` 缩放;空白处左右、上下拖动有效。在 100%、25% 和约 8% 比例下确认线宽、虚线间距及箭头与图标同比缩小,不出现盖住整图的固定尺寸箭头。缩放和平移后,图标、`+`、tooltip、点击及 EMI 悬停命中一致。 7. 连续重载两次后确认配方增删同步、旧引用拒绝跳转;断线/换服不沿用回调。布局副本数不改变配方数量或原生 viewer 索引;方法标签只来自 API target/reagent 声明。 8. 两平台分别检查 JEI-only、EMI-only 和双装环境,双装沿既有去重规则。另验无 viewer 的专用服务端与独立远程客户端;未实际执行的场景不能用编译或集成服务器静态表代替。 -`MaterialProcessSnapshotTests` 中的 `presentationPreservesNativeItemState`、`overviewGroupsVisibleRoutesAndHidesAuxiliaries`、`overviewAlignsChainsAndPreservesFeedback`、`overviewSharesHubsWithoutInventingConnections` 和 `overviewKeepsDenseEdgesLocal` 覆盖原生状态、锤子分类图标、辅料隐藏、原始步骤保留、外观去重、公共资源集中、连续链、顺序稳定、循环、副本、密集图直线避让和关联保留。编译这些测试不代表已运行 GameTest;箭头外观、真实 EMI 查询和鼠标手感仍需人工确认。 +`MaterialProcessSnapshotTests` 中的 `presentationPreservesNativeItemState`、`overviewGroupsVisibleRoutesAndHidesAuxiliaries`、`overviewAlignsChainsAndPreservesFeedback`、`overviewSharesHubsWithoutInventingConnections` 、`overviewKeepsDenseEdgesLocal`、`overviewKeepsFirstOutputAndVariantsTogether` 、`recoveryOwnershipAndMachineKindDriveOverviewClassification` 和 `overviewSeparatesSourcesConversionsAndUses`、`overviewFoldsAlternativeInputsAndKeepsProductGridsLocal`、`overviewShowsPortYieldsAndOrdersRecoveryAfterConversions`、`overviewFoldsSimilarRoutesAcrossNativeRecipeDifferences` 和 `overviewPacksLocalRoutesWithoutInvisibleDependencies` 覆盖原生状态、锤子分类图标、辅料隐藏、原始步骤保留、外观去重、公共资源集中、连续链、顺序稳定、循环、副本、密集图直线避让和关联保留。编译这些测试不代表已运行 GameTest;箭头外观、真实 EMI 查询和鼠标手感仍需人工确认。 ## 注意事项 diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java index 4e188dd3a..b68c68eff 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java @@ -54,7 +54,18 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { try { graphics.pose().translate(panX, BODY_TOP + panY, 0); graphics.pose().scale((float) zoom, (float) zoom, 1); + for (var band : overview.bands()) { + graphics.fill(band.left() + 2, 2, band.right() - 2, 24, 0xffb8b8b8); + text(graphics, band.section().label(), band.left() + 6, 8, band.right() - band.left() - 12, TEXT); + if (band.left() > 0) graphics.fill(band.left(), 2, band.left() + 1, overview.height(), 0xff999999); + } drawEdges(graphics, hovered); + for (var grid : overview.grids()) { + graphics.fill(grid.left(), grid.top(), grid.right(), grid.bottom(), 0xff777777); + for (int y = grid.top(); y < grid.bottom(); y += 24) + for (int x = grid.left(); x < grid.right(); x += 24) + graphics.fill(x + 1, y + 1, x + 23, y + 23, 0xffb0b0b0); + } for (Node node : overview.nodes()) { if (!visible(node)) continue; if (related(node, hovered)) @@ -64,6 +75,10 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { : node.port().icons().stream().findFirst().orElse(ItemStack.EMPTY); if (icon.isEmpty()) text(graphics, Component.literal("?"), node.x - 3, node.y - 4, 10, MUTED); else graphics.renderItem(icon, node.x - 8, node.y - 8); + if (!node.machine()) { + smallText(graphics, node.quantityBadge(), node.x + 10, node.y + 3, 0xffffffff, true); + smallText(graphics, node.chanceBadge(), node.x - 10, node.y - 10, GOLD, false); + } if (node.machine() && node.extra()) smallText(graphics, "+", node.x + 9, node.y - 12, GOLD, false); if (!node.machine() && (node.copy || node.returning)) smallText(graphics, node.returning ? "↩" : "↗", node.x + 8, node.y - 12, MUTED, false); @@ -109,13 +124,29 @@ private Node hit(double mouseX, double mouseY) { if (mouseX < 0 || mouseX >= WIDTH || mouseY < BODY_TOP || mouseY >= FOOTER) return null; double x = worldX(mouseX), y = worldY(mouseY); for (Node node : overview.nodes()) - if (x >= node.x - 10 && x <= node.x + 13 && y >= node.y - 14 && y <= node.y + 11) return node; + if (x >= node.x - 11 && x < node.x + 12 && y >= node.y - 12 && y < node.y + 12) return node; return null; } public List stacksAt(double mouseX, double mouseY) { Node node = hit(mouseX, mouseY); - if (node == null) return List.of(); + return node == null ? List.of() : stacks(node); + } + + public List nodes() { + return overview.nodes(); + } + + public PreviewViewport.Bounds bounds(Node node) { + return new PreviewViewport.Bounds( + (int) Math.max(0, Math.floor(panX + (node.x - 11) * zoom)), + (int) Math.max(BODY_TOP, Math.floor(BODY_TOP + panY + (node.y - 12) * zoom)), + (int) Math.min(WIDTH, Math.ceil(panX + (node.x + 12) * zoom)), + (int) Math.min(FOOTER, Math.ceil(BODY_TOP + panY + (node.y + 12) * zoom))); + } + + public List stacks(Node node) { + if (!page.navigation().valid()) return List.of(); if (node.machine()) return selected(node).icon().isEmpty() ? List.of() @@ -142,8 +173,23 @@ public List tooltip(double mouseX, double mouseY) { Component name = icon.isEmpty() ? (node.machine() ? selected(node).name() : node.port().name()) : icon.getHoverName(); - if (!node.machine() || !node.extra() || worldX(mouseX) < node.x + 6 || worldY(mouseY) > node.y - 6) - return List.of(name); + if (!node.machine()) { + List> variants = node.badgePorts().stream() + .map(port -> List.of( + port.amount(), + port.chance().isPresent() + ? Component.translatable( + "gt6ce.jei.chance", port.chance().getAsInt() / 100.0) + : Component.translatable("gt6ce.jei.material_process.chance_unknown"))) + .distinct() + .toList(); + if (variants.size() <= 1) return List.of(name); + var lines = new ArrayList(); + lines.add(name); + variants.forEach(lines::addAll); + return List.copyOf(lines); + } + if (!node.extra() || worldX(mouseX) < node.x + 6 || worldY(mouseY) > node.y - 6) return List.of(name); var lines = new ArrayList(); lines.add(name); if (node.steps.size() > 1) @@ -159,6 +205,15 @@ public List tooltip(double mouseX, double mouseY) { } public boolean click(double mouseX, double mouseY, int button) { + if (clickControls(mouseX, mouseY, button)) return true; + if (button != 0 && button != 1) return false; + Node node = hit(mouseX, mouseY); + if (node == null) return false; + if (!node.machine()) return page.navigation().openPort(node.port(), button == 1); + return page.navigation().openStack(selected(node).icon(), button == 1); + } + + public boolean clickControls(double mouseX, double mouseY, int button) { if (button != 0 && button != 1) return false; if (button == 0 && mouseY >= 0 && mouseY < 14) { if (mouseX >= WIDTH - 29 && mouseX < WIDTH) { @@ -174,10 +229,7 @@ public boolean click(double mouseX, double mouseY, int button) { return true; } } - Node node = hit(mouseX, mouseY); - if (node == null) return false; - if (!node.machine()) return page.navigation().openPort(node.port(), button == 1); - return page.navigation().openStack(selected(node).icon(), button == 1); + return false; } public boolean press(double mouseX, double mouseY, int button) { @@ -236,9 +288,17 @@ private void fit() { } private void drawEdges(GuiGraphics graphics, Node hovered) { - for (var edge : overview.edges()) { - int color = related(edge.from(), hovered) || related(edge.to(), hovered) ? 0xff986c26 : TEXT; - var path = edge.path(); + record Wire(List path, boolean output) {} + var wires = new java.util.LinkedHashMap>(); + for (var edge : overview.edges()) + wires.computeIfAbsent(new Wire(edge.path(), edge.endpoint().output()), ignored -> new ArrayList<>()) + .add(edge); + for (var entry : wires.entrySet()) { + boolean highlighted = entry.getValue().stream() + .anyMatch(edge -> related(edge.from(), hovered) || related(edge.to(), hovered)); + boolean confirmed = entry.getValue().stream().allMatch(MaterialProcessOverview.Edge::confirmed); + int color = highlighted ? 0xff986c26 : TEXT; + var path = entry.getKey().path(); for (int index = 1; index < path.size(); index++) { var from = path.get(index - 1); var to = path.get(index); @@ -248,8 +308,8 @@ private void drawEdges(GuiGraphics graphics, Node hovered) { from.y(), to.x(), to.y(), - !edge.confirmed(), - edge.endpoint().output() && index == path.size() - 1, + !confirmed, + entry.getKey().output() && index == path.size() - 1, color); } } diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java index 307bc9d5f..ccadaecaf 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java @@ -140,7 +140,8 @@ public record Step( List details, java.util.Optional specialProcess, boolean resolved, - boolean worldGenerated) { + boolean worldGenerated, + boolean genericRecovery) { public Step { Objects.requireNonNull(reference); name = name.copy(); @@ -158,6 +159,19 @@ public ItemStack icon() { return icon.copy(); } + public Step( + DataKey reference, + Component name, + ItemStack icon, + List inputs, + List outputs, + List details, + java.util.Optional specialProcess, + boolean resolved, + boolean worldGenerated) { + this(reference, name, icon, inputs, outputs, details, specialProcess, resolved, worldGenerated, false); + } + public Step( DataKey reference, Component name, @@ -205,6 +219,7 @@ public Step( public enum Section { SOURCES("gt6ce.jei.material_process.section.sources"), INTERNAL("gt6ce.jei.material_process.section.internal"), + RECOVERY("gt6ce.jei.material_process.section.recovery"), USES("gt6ce.jei.material_process.section.uses"); private final String label; @@ -219,6 +234,7 @@ public Component label() { } public static java.util.Optional
section(Step step, String material) { + if (step.genericRecovery()) return java.util.Optional.of(Section.RECOVERY); boolean input = step.inputs().stream() .anyMatch( port -> port.role() == Role.CONSUMED && port.material().equals(material)); @@ -248,6 +264,10 @@ public record SpecialProcess(DataKey id, Component name) { * return false for expired or unsupported targets. Implementations run on the client thread. */ public interface Navigation { + default boolean valid() { + return true; + } + Navigation NONE = new Navigation() { @Override public boolean openForm(DataKey resource, boolean uses) { diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java index d4cec6ac1..7e1aa25a2 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java @@ -36,6 +36,7 @@ public static final class Node { public final List steps = new ArrayList<>(); public int x, y, layer; public boolean copy, returning; + private Grid grid; private boolean feedbackCopy; private Node(String key, Section section) { @@ -51,6 +52,43 @@ public Port port() { return endpoints.get(0).port(); } + /** Producers determine the badge on a shared resource; consumption amounts stay on native ports. */ + public List badgePorts() { + boolean produced = endpoints.stream().anyMatch(Endpoint::output); + return endpoints.stream() + .filter(endpoint -> endpoint.output() == produced) + .map(Endpoint::port) + .toList(); + } + + public String quantityBadge() { + List values = badgePorts().stream() + .map(port -> port.quantity().getString()) + .distinct() + .sorted() + .toList(); + if (values.size() == 1) return values.get(0); + if (values.size() > 3) return "…"; + return String.join( + "/", + values.stream().map(value -> value.isEmpty() ? "1" : value).toList()); + } + + public String chanceBadge() { + if (endpoints.stream().noneMatch(Endpoint::output)) return ""; + List values = badgePorts().stream() + .map(port -> port.chance().isPresent() + ? java.math.BigDecimal.valueOf(port.chance().getAsInt(), 2) + .stripTrailingZeros() + .toPlainString() + + "%" + : "?%") + .distinct() + .sorted() + .toList(); + return values.equals(List.of("100%")) ? "" : values.size() > 3 ? "…%" : String.join("/", values); + } + public boolean extra() { return steps.size() > 1 || !auxiliaries.isEmpty() @@ -63,6 +101,38 @@ public boolean extra() { public final List auxiliaries = new ArrayList<>(); } + /** One inventory-like display box; each cell retains its own native ports and navigation. */ + public static final class Grid { + public final List members; + private final Node root; + + private Grid(List members) { + this.members = List.copyOf(members); + root = members.get(0); + members.forEach(node -> node.grid = this); + } + + public int left() { + return root.x - 12; + } + + public int right() { + return left() + Math.min(3, members.size()) * 24; + } + + public int top() { + return root.y - 12; + } + + public int bottom() { + return top() + ((members.size() + 2) / 3) * 24; + } + + public int centerY() { + return (top() + bottom()) / 2; + } + } + public record Point(int x, int y) {} public static final class Edge { @@ -128,13 +198,11 @@ public int hashCode() { } } - private record RouteKey(IconKey icon, String fallback, List inputs, List outputs) {} + private record RouteKey(IconKey icon, String fallback, List inputs, String output, boolean recovery) {} private record EdgeKey(Node from, Node to) {} - private record SideKey(DataKey step, DataKey resource) {} - - private record Arc(Node from, Node to, int distance, Edge edge, Connection connection) {} + private record Arc(Node from, Node to, Edge edge) {} private record Occupancy(BitSet positive, BitSet negative) { private Occupancy() { @@ -145,34 +213,37 @@ private void add(int lane) { (lane >= 0 ? positive : negative).set(lane >= 0 ? lane : -lane - 1); } - private int above(int center) { - if (center >= 0) return positive.nextClearBit(center); - int negativeIndex = negative.previousClearBit(-center - 1); - return negativeIndex >= 0 ? -negativeIndex - 1 : positive.nextClearBit(0); - } - - private int below(int center) { - if (center < 0) return -negative.nextClearBit(-center - 1) - 1; - int positiveIndex = positive.previousClearBit(center); - return positiveIndex >= 0 ? positiveIndex : -negative.nextClearBit(0) - 1; + private boolean contains(int lane) { + return (lane >= 0 ? positive : negative).get(lane >= 0 ? lane : -lane - 1); } } private final List nodes = new ArrayList<>(); private final List edges = new ArrayList<>(); + private final List grids = new ArrayList<>(); + + public record Band(Section section, int left, int right) {} + + private final List bands = new ArrayList<>(); private final List connections; - private final Map machines = new LinkedHashMap<>(); - private final Set inputs = new HashSet<>(), outputs = new HashSet<>(); private final Map next = new HashMap<>(), previous = new HashMap<>(); private final Set feedback = new HashSet<>(); private int width, height; private Node anchor; public MaterialProcessOverview(Page page) { + this(page, true); + } + + private MaterialProcessOverview(Page page, boolean partition) { connections = page.connections().stream() .sorted(Comparator.comparing( connection -> connection.source() + ":" + connection.target() + ":" + connection.resource())) .toList(); + if (partition && !page.steps().isEmpty()) { + partition(page); + return; + } var resources = new LinkedHashMap(); var routes = new LinkedHashMap(); var wires = new LinkedHashMap(); @@ -182,11 +253,13 @@ public MaterialProcessOverview(Page page) { List visibleInputs = visible(step.inputs(), page.material(), false); List visibleOutputs = visible(step.outputs(), page.material(), true); ItemStack icon = step.icon(); + // Similar routes share a machine and primary product; native recipe differences stay in the details. var key = new RouteKey( new IconKey(icon), icon.isEmpty() ? step.reference().toString() : "", - identities(visibleInputs), - identities(visibleOutputs)); + visibleOutputs.isEmpty() ? identities(visibleInputs) : List.of(), + visibleOutputs.isEmpty() ? "" : visibleOutputs.get(0).identity(), + step.genericRecovery()); Node machine = routes.computeIfAbsent(key, ignored -> { var node = new Node( "step:" + step.reference(), @@ -195,7 +268,6 @@ public MaterialProcessOverview(Page page) { return node; }); machine.steps.add(step); - machines.put(step.reference(), machine); for (boolean output : List.of(false, true)) { List ports = output ? step.outputs() : step.inputs(); List visible = output ? visibleOutputs : visibleInputs; @@ -206,9 +278,13 @@ public MaterialProcessOverview(Page page) { continue; } var endpoint = new Endpoint(step, output, index, port); - (output ? outputs : inputs).add(new SideKey(step.reference(), port.resource())); - Node resource = resources.computeIfAbsent(port.identity(), identity -> { - var node = new Node("resource:" + identity, null); + machine.endpoints.add(endpoint); + String instance = output && step.genericRecovery() + ? "recovery:" + machine.key + ":" + port.identity() + : "resource:" + port.identity(); + Node resource = resources.computeIfAbsent(instance, identity -> { + var node = new Node(identity, null); + node.feedbackCopy = output && step.genericRecovery(); nodes.add(node); return node; }); @@ -229,15 +305,10 @@ public MaterialProcessOverview(Page page) { } } } - Set uncertain = new HashSet<>(); - for (Connection connection : connections) - if (!connection.confirmed()) uncertain.add(connection.target() + ":" + connection.resource()); - for (Edge edge : edges) - if (edge.endpoints.stream() - .anyMatch(endpoint -> !endpoint.output() - && uncertain.contains(endpoint.step().reference() + ":" - + endpoint.port().resource()))) edge.confirmed = false; + applyConfirmation(); + // Detect returns before detaching shared resources into inventory grids. layout(); + if (localizeGrids()) layout(); // Each pass detaches at least one shared port; copies themselves are never split again. while (splitLongEdges()) layout(); Map counts = new HashMap<>(); @@ -255,6 +326,167 @@ public List nodes() { return List.copyOf(nodes); } + public List bands() { + return List.copyOf(bands); + } + + public List grids() { + return List.copyOf(grids); + } + + private Map> producers() { + var result = new HashMap>(); + for (Edge edge : edges) + if (edge.endpoint.output()) + result.computeIfAbsent(edge.to, ignored -> new HashSet<>()).add(edge.from); + return result; + } + + private Map> machineEdges() { + var result = new HashMap>(); + for (Edge edge : edges) + result.computeIfAbsent(edge.endpoint.output() ? edge.from : edge.to, ignored -> new ArrayList<>()) + .add(edge); + return result; + } + + private boolean localizeGrids() { + boolean changed = false; + var producers = producers(); + var machineEdges = machineEdges(); + var counts = new HashMap(); + for (Edge edge : edges) counts.merge(resource(edge), 1, Integer::sum); + for (Node machine : List.copyOf(nodes)) { + if (!machine.machine()) continue; + for (boolean output : List.of(false, true)) { + List side = machineEdges.getOrDefault(machine, List.of()).stream() + .filter(edge -> edge.endpoint.output() == output) + .toList(); + if (side.size() < 2) continue; + for (Edge edge : side) { + Node resource = resource(edge); + if (counts.get(resource) < 2) continue; + // Keep a product's downstream chain when this is its only visible producer. + if (output && producers.getOrDefault(resource, Set.of()).size() == 1) continue; + split(edge); + counts.merge(resource, -1, Integer::sum); + changed = true; + } + } + } + return changed; + } + + private Node representative(Node node) { + return node.grid == null ? node : node.grid.root; + } + + private int rows(Node node) { + return node.grid == null ? 1 : (node.grid.members.size() + 2) / 3; + } + + private void buildGrids(Map degree) { + var producers = producers(); + var machineEdges = machineEdges(); + grids.clear(); + nodes.forEach(node -> node.grid = null); + for (Node machine : nodes) { + if (!machine.machine()) continue; + for (boolean output : List.of(false, true)) { + List members = machineEdges.getOrDefault(machine, List.of()).stream() + .filter(edge -> edge.endpoint.output() == output && !edge.feedback) + .map(this::resource) + .filter(node -> degree.get(node) == 1 + || output + && node.layer == machine.layer + 1 + && producers + .getOrDefault(node, Set.of()) + .size() + == 1) + .sorted(Comparator.comparingInt( + (Node node) -> node.endpoints.get(0).index()) + .thenComparing(node -> node.key)) + .toList(); + if (members.size() > 1) grids.add(new Grid(members)); + } + } + } + + private void applyConfirmation() { + Set uncertain = new HashSet<>(); + for (Connection connection : connections) + if (!connection.confirmed()) uncertain.add(connection.target() + ":" + connection.resource()); + for (Edge edge : edges) + if (edge.endpoints.stream() + .anyMatch(endpoint -> !endpoint.output() + && uncertain.contains(endpoint.step().reference() + ":" + + endpoint.port().resource()))) edge.confirmed = false; + } + + private void partition(Page page) { + int offset = 0; + for (Section section : Section.values()) { + List steps = page.steps().stream() + .filter(step -> MaterialProcessDisplay.section(step, page.material()) + .orElse(Section.INTERNAL) + == section) + .toList(); + if (steps.isEmpty()) continue; + Set references = new HashSet<>(); + steps.forEach(step -> references.add(step.reference())); + var local = new Page( + page.title(), + page.material(), + steps, + connections.stream() + .filter(connection -> references.contains(connection.source()) + && references.contains(connection.target())) + .toList(), + page.notices(), + 1, + 1, + page.navigation()); + var graph = new MaterialProcessOverview(local, false); + var copies = new HashMap(); + for (Node original : graph.nodes) { + var node = new Node("band:" + section.name() + ":" + original.key, original.section); + node.endpoints.addAll(original.endpoints); + node.steps.addAll(original.steps); + node.auxiliaries.addAll(original.auxiliaries); + node.x = original.x + offset; + node.y = original.y + 28; + node.layer = original.layer + offset / 52; + node.returning = original.returning; + node.copy = original.copy; + copies.put(original, node); + nodes.add(node); + } + for (Grid original : graph.grids) + grids.add(new Grid(original.members.stream().map(copies::get).toList())); + for (Edge original : graph.edges) { + var edge = new Edge(copies.get(original.from), copies.get(original.to), original.endpoint); + edge.endpoints.clear(); + edge.endpoints.addAll(original.endpoints); + edge.confirmed = original.confirmed; + edge.feedback = original.feedback; + edges.add(edge); + } + graph.next.forEach((from, to) -> next.put(copies.get(from), copies.get(to))); + if (graph.anchor != null && (anchor == null || section == Section.INTERNAL)) + anchor = copies.get(graph.anchor); + int bandWidth = Math.max(72, graph.width); + bands.add(new Band(section, offset, offset + bandWidth)); + offset += bandWidth; + } + var instances = new HashMap(); + for (Node node : nodes) if (!node.machine()) instances.merge(node.port().identity(), 1, Integer::sum); + for (Node node : nodes) + if (!node.machine()) node.copy |= instances.get(node.port().identity()) > 1; + applyConfirmation(); + route(); + width = offset; + } + public List edges() { return List.copyOf(edges); } @@ -305,7 +537,7 @@ private Node resource(Edge edge) { private void split(Edge edge) { Node original = resource(edge); Node local = new Node("copy:" + edge.endpoint.key(), null); - local.feedbackCopy = edge.feedback || original.returning; + local.feedbackCopy = edge.feedback || original.returning || original.feedbackCopy; local.endpoints.addAll(edge.endpoints); nodes.add(local); original.endpoints.removeAll(edge.endpoints); @@ -313,20 +545,35 @@ private void split(Edge edge) { else edge.to = local; } + private static boolean primary(Edge edge) { + Node machine = edge.from.machine() ? edge.from : edge.to; + int first = machine.endpoints.stream() + .filter(endpoint -> endpoint.output() == edge.endpoint.output()) + .filter(endpoint -> endpoint.step() == edge.endpoint.step()) + .mapToInt(Endpoint::index) + .min() + .orElse(edge.endpoint.index()); + return edge.endpoint.index() == first; + } + private boolean splitLongEdges() { boolean changed = false; var counts = new HashMap(); for (Edge edge : edges) counts.merge(resource(edge), 1, Integer::sum); - var columns = new HashMap>(); + var columns = new java.util.TreeMap>(); for (Node node : nodes) - columns.computeIfAbsent(node.layer, ignored -> new java.util.TreeMap<>()) + columns.computeIfAbsent(node.x, ignored -> new java.util.TreeMap<>()) .put(node.y, node); for (Edge edge : edges) { Node resource = resource(edge); - if (counts.get(resource) < 2 || next.get(edge.from) == edge.to) continue; + if (counts.get(resource) < 2) continue; + int fromY = edge.from.grid == null ? edge.from.y : edge.from.grid.centerY(); + int toY = edge.to.grid == null ? edge.to.y : edge.to.grid.centerY(); + int distanceY = Math.abs(toY - fromY); if (!edge.feedback && edge.to.layer - edge.from.layer <= 3 - && Math.abs(edge.to.y - edge.from.y) <= 192 + && distanceY <= 128 + && (!edge.endpoint.output() || primary(edge) || distanceY <= 64) && !crossesNode(edge, columns)) continue; split(edge); counts.merge(resource, -1, Integer::sum); @@ -335,35 +582,34 @@ private boolean splitLongEdges() { return changed; } - private static boolean crossesNode(Edge edge, Map> columns) { - double sx = edge.from.x + 12, tx = edge.to.x - 12; + private boolean crossesNode( + Edge edge, java.util.NavigableMap> columns) { + Node from = representative(edge.from), to = representative(edge.to); + double sx = from.grid == null ? from.x + 12 : from.grid.right(); + double tx = to.grid == null ? to.x - 12 : to.grid.left(); + double sy = from.grid == null ? from.y : from.grid.centerY(); + double ty = to.grid == null ? to.y : to.grid.centerY(); if (tx <= sx) return true; - double slope = (edge.to.y - edge.from.y) / (tx - sx); - for (int layer = edge.from.layer + 1; layer < edge.to.layer; layer++) { - var column = columns.get(layer); - if (column == null) continue; - double y = edge.from.y + (24 + layer * 52 - sx) * slope; - double margin = 14 + 12 * Math.abs(slope); - var candidate = column.ceilingEntry((int) Math.ceil(y - margin)); - if (candidate != null && candidate.getKey() <= y + margin) return true; + for (var column : + columns.subMap((int) sx - 12, true, (int) tx + 12, true).entrySet()) { + double left = Math.max(sx, column.getKey() - 12), right = Math.min(tx, column.getKey() + 12); + if (left > right) continue; + double ly = sy + (ty - sy) * (left - sx) / (tx - sx); + double ry = sy + (ty - sy) * (right - sx) / (tx - sx); + int low = (int) Math.ceil(Math.min(ly, ry) - 14), high = (int) Math.floor(Math.max(ly, ry) + 14); + for (Node node : column.getValue().subMap(low, true, high, true).values()) + if (representative(node) != from && representative(node) != to) return true; } return false; } private List arcs() { var result = new ArrayList(); - for (Edge edge : edges) result.add(new Arc(edge.from, edge.to, 1, edge, null)); - // Supplied associations constrain layers even when a local copy replaces the long visible wire. - for (Connection connection : connections) { - if (!outputs.contains(new SideKey(connection.source(), connection.resource())) - || !inputs.contains(new SideKey(connection.target(), connection.resource()))) continue; - Node source = machines.get(connection.source()), target = machines.get(connection.target()); - if (source != null && target != null) result.add(new Arc(source, target, 2, null, connection)); - } + // A local copy ends the visible dependency; retained facts must not reserve invisible columns. + for (Edge edge : edges) result.add(new Arc(edge.from, edge.to, edge)); result.sort(Comparator.comparing((Arc arc) -> arc.from.key) .thenComparing(arc -> arc.to.key) - .thenComparing(arc -> - arc.connection == null ? "" : arc.connection.resource().toString())); + .thenComparing(arc -> arc.edge.endpoint.key())); return result; } @@ -405,14 +651,8 @@ record Frame(Node node, java.util.Iterator iterator) {} if (state.getOrDefault(arc.to, 0) == 1) { feedback.add(arc); indegree.merge(arc.to, -1, Integer::sum); - if (arc.edge != null) { - arc.edge.feedback = true; - resource(arc.edge).returning = true; - } else - for (Edge edge : edges) - if (edge.endpoint.step().reference().equals(arc.connection.target()) - && edge.endpoint.port().resource().equals(arc.connection.resource())) - resource(edge).returning = true; + arc.edge.feedback = true; + resource(arc.edge).returning = true; } else if (!state.containsKey(arc.to)) { state.put(arc.to, 1); stack.push(new Frame( @@ -426,7 +666,7 @@ record Frame(Node node, java.util.Iterator iterator) {} Node node = ready.remove(); for (Arc arc : outgoing.getOrDefault(node, List.of())) if (!feedback.contains(arc)) { - arc.to.layer = Math.max(arc.to.layer, node.layer + arc.distance); + arc.to.layer = Math.max(arc.to.layer, node.layer + 1); if (indegree.merge(arc.to, -1, Integer::sum) == 0) ready.add(arc.to); } } @@ -444,6 +684,13 @@ record Frame(Node node, java.util.Iterator iterator) {} neighbors.computeIfAbsent(edge.from, ignored -> new ArrayList<>()).add(edge.to); neighbors.computeIfAbsent(edge.to, ignored -> new ArrayList<>()).add(edge.from); } + buildGrids(degree); + for (Grid grid : grids) + for (Node member : grid.members) + if (member != grid.root) + neighbors + .computeIfAbsent(grid.root, ignored -> new ArrayList<>()) + .addAll(neighbors.getOrDefault(member, List.of())); var ordered = new ArrayList<>(edges); var before = new HashMap(); var after = new HashMap(); @@ -456,13 +703,17 @@ record Frame(Node node, java.util.Iterator iterator) {} Edge edge = forwards.get(index); after.merge(edge.from, after.getOrDefault(edge.to, 0) + 1, Math::max); } - ordered.sort(Comparator.comparingInt(edge -> degree.get(edge.from) + degree.get(edge.to)) - .thenComparing(edge -> !edge.endpoint.port().main()) + ordered.sort(Comparator.comparingInt(edge -> primary(edge) ? 0 : 1) + .thenComparingInt(edge -> edge.endpoint.index()) + .thenComparingInt(edge -> degree.get(edge.from) + degree.get(edge.to)) .thenComparingInt(edge -> -before.getOrDefault(edge.from, 0) - after.getOrDefault(edge.to, 0)) .thenComparing(edge -> edge.endpoint.key())); for (Edge edge : ordered) if (!edge.feedback + && primary(edge) && edge.to.layer == edge.from.layer + 1 + && representative(edge.from) == edge.from + && representative(edge.to) == edge.to && !next.containsKey(edge.from) && !previous.containsKey(edge.to)) { next.put(edge.from, edge.to); @@ -470,44 +721,179 @@ record Frame(Node node, java.util.Iterator iterator) {} } var starts = nodes.stream() .filter(node -> !previous.containsKey(node)) + .filter(node -> representative(node) == node) .sorted(Comparator.comparingInt(node -> -chainLength(node)) .thenComparingInt(node -> node.layer) .thenComparing(node -> family(node, neighbors)) .thenComparing(node -> node.key)) .toList(); var lanes = new HashMap(); - var occupied = new HashMap(); + var chains = new ArrayList>(); for (Node start : starts) { var chain = new ArrayList(); for (Node node = start; node != null; node = next.get(node)) chain.add(node); - Set members = new HashSet<>(chain); - double center = chain.stream() - .flatMap(node -> neighbors.getOrDefault(node, List.of()).stream()) - .filter(node -> !members.contains(node)) - .filter(lanes::containsKey) - .mapToInt(lanes::get) - .average() - .orElse(0); - int first = start.layer, last = chain.get(chain.size() - 1).layer, desired = (int) Math.round(center); - var blocked = new Occupancy(); - for (int layer = first; layer <= last; layer++) { - Occupancy values = occupied.get(layer); - if (values != null) { - blocked.positive.or(values.positive); - blocked.negative.or(values.negative); + chains.add(chain); + } + var chainRows = new HashMap(); + for (List chain : chains) { + int size = chain.stream().mapToInt(this::rows).max().orElse(1); + chain.forEach(node -> chainRows.put(node, size)); + } + var order = new ArrayList(); + for (int index = 0; index < chains.size(); index++) order.add(index); + for (int pass = 0; pass < 4; pass++) { + var prior = new HashMap<>(lanes); + if (pass > 0) + order.sort(Comparator.comparingDouble(index -> chains.get(index).stream() + .flatMap(node -> neighbors.getOrDefault(node, List.of()).stream()) + .filter(prior::containsKey) + .mapToInt(prior::get) + .average() + .orElse(0)) + .thenComparingInt(Integer::intValue)); + lanes.clear(); + var occupied = new HashMap(); + for (int index : order) { + List chain = chains.get(index); + double center = chain.stream() + .flatMap(node -> neighbors.getOrDefault(node, List.of()).stream()) + .filter(node -> !chain.contains(node)) + .filter(node -> lanes.containsKey(node) || prior.containsKey(node)) + .mapToInt(node -> lanes.containsKey(node) ? lanes.get(node) : prior.get(node)) + .average() + .orElse(0); + var cells = new HashMap>(); + int first = chain.stream().mapToInt(node -> node.layer).min().orElse(0); + int last = chain.stream().mapToInt(node -> node.layer).max().orElse(first); + int blockRows = chain.stream().mapToInt(this::rows).max().orElse(1); + // Reserve the whole recipe block, including the space between its icons. + for (int layer = first; layer <= last; layer++) + for (int row = 0; row < blockRows; row++) + cells.computeIfAbsent(layer, ignored -> new HashSet<>()).add(row); + int desired = (int) Math.round(center), lane = desired; + for (int distance = 0; ; distance++) { + if (fits(cells, occupied, desired + distance)) { + lane = desired + distance; + break; + } + if (fits(cells, occupied, desired - distance)) { + lane = desired - distance; + break; + } } + for (var cell : cells.entrySet()) + for (int offset : cell.getValue()) + occupied.computeIfAbsent(cell.getKey(), ignored -> new Occupancy()) + .add(lane + offset); + for (Node node : chain) lanes.put(node, lane); } - int above = blocked.above(desired), below = blocked.below(desired); - int lane = above - desired <= desired - below ? above : below; - for (int layer = first; layer <= last; layer++) - occupied.computeIfAbsent(layer, ignored -> new Occupancy()).add(lane); - for (Node node : chain) lanes.put(node, lane); } int minimum = lanes.values().stream().mapToInt(Integer::intValue).min().orElse(0); for (Node node : nodes) { - node.x = 24 + node.layer * 52; - node.y = 24 + (lanes.get(node) - minimum) * 32; + Node root = representative(node); + int index = node.grid == null ? 0 : node.grid.members.indexOf(node); + node.y = 24 + (lanes.get(root) - minimum) * 32 + (chainRows.get(root) - rows(root)) * 12 + index / 3 * 24; + } + packComponents(); + } + + private record Block(List members, int width, int height) {} + + private record Shelf(int top, int height, int right) {} + + private void packComponents() { + var neighbors = new HashMap>(); + for (Edge edge : edges) { + neighbors.computeIfAbsent(edge.from, ignored -> new ArrayList<>()).add(edge.to); + neighbors.computeIfAbsent(edge.to, ignored -> new ArrayList<>()).add(edge.from); + } + var visited = new HashSet(); + var blocks = new ArrayList(); + for (Node start : nodes) { + if (!visited.add(start)) continue; + var members = new ArrayList(); + var queue = new ArrayDeque(); + queue.add(start); + while (!queue.isEmpty()) { + Node node = queue.removeFirst(); + members.add(node); + for (Node neighbor : neighbors.getOrDefault(node, List.of())) + if (visited.add(neighbor)) queue.addLast(neighbor); + } + var widths = new java.util.TreeMap(); + for (Node node : members) { + Node root = representative(node); + int size = root.grid == null ? 24 : Math.min(3, root.grid.members.size()) * 24; + widths.merge(root.layer, size, Math::max); + } + var positions = new HashMap(); + int x = 12; + for (var column : widths.entrySet()) { + positions.put(column.getKey(), x); + x += column.getValue() + 20; + } + // Remove empty strips without changing a grid's cell spacing or a chain's alignment. + var intervals = members.stream() + .map(node -> new int[] {node.y - 14, node.y + 14}) + .sorted(Comparator.comparingInt(interval -> interval[0])) + .toList(); + var shifts = new java.util.TreeMap(); + int bottom = intervals.get(0)[0], removed = 0; + for (int[] interval : intervals) { + removed += Math.max(0, interval[0] - bottom - 4); + shifts.put(interval[0], removed); + bottom = Math.max(bottom, interval[1]); + } + for (Node node : members) { + Node root = representative(node); + int index = node.grid == null ? 0 : node.grid.members.indexOf(node); + node.x = positions.get(root.layer) + index % 3 * 24; + node.y -= shifts.floorEntry(node.y).getValue(); + } + int top = members.stream().mapToInt(node -> node.y - 14).min().orElseThrow(); + int width = members.stream().mapToInt(node -> node.x + 12).max().orElseThrow(); + int height = members.stream().mapToInt(node -> node.y + 14).max().orElseThrow() - top; + members.forEach(node -> node.y -= top); + blocks.add(new Block(members, width, height)); + } + blocks.sort(Comparator.comparingInt(block -> -block.height) + .thenComparingInt(block -> -block.width) + .thenComparing(block -> block.members.get(0).key)); + long area = blocks.stream() + .mapToLong(block -> (long) (block.width + 16) * (block.height + 16)) + .sum(); + int target = Math.max(blocks.stream().mapToInt(Block::width).max().orElse(0), (int) Math.ceil(Math.sqrt(area))); + var shelves = new ArrayList(); + int bottom = 10; + for (Block block : blocks) { + int selected = -1; + for (int index = 0; index < shelves.size(); index++) { + Shelf shelf = shelves.get(index); + if (block.height <= shelf.height && shelf.right + block.width <= target) { + selected = index; + break; + } + } + if (selected < 0) { + selected = shelves.size(); + shelves.add(new Shelf(bottom, block.height, 0)); + bottom += block.height + 16; + } + Shelf shelf = shelves.get(selected); + block.members.forEach(node -> { + node.x += shelf.right + 12; + node.y += shelf.top; + }); + shelves.set(selected, new Shelf(shelf.top, shelf.height, shelf.right + block.width + 16)); + } + } + + private static boolean fits(Map> cells, Map occupied, int lane) { + for (var cell : cells.entrySet()) { + Occupancy values = occupied.get(cell.getKey()); + if (values != null) for (int offset : cell.getValue()) if (values.contains(lane + offset)) return false; } + return true; } private static String family(Node start, Map> neighbors) { @@ -529,7 +915,12 @@ private int chainLength(Node start) { private void route() { for (Edge edge : edges) { Node from = edge.from, to = edge.to; - edge.path = List.of(new Point(from.x + 12, from.y), new Point(to.x - 12, to.y)); + edge.path = List.of( + new Point( + from.grid == null ? from.x + 12 : from.grid.right(), + from.grid == null ? from.y : from.grid.centerY()), + new Point( + to.grid == null ? to.x - 12 : to.grid.left(), to.grid == null ? to.y : to.grid.centerY())); } width = nodes.stream().mapToInt(node -> node.x + 24).max().orElse(48); height = nodes.stream().mapToInt(node -> node.y + 24).max().orElse(48); diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java index 484b5a086..0e6ca022b 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java @@ -92,7 +92,10 @@ private static MaterialProcessDisplay.Step step(MaterialProcessSnapshot snapshot step.details().stream().map(MaterialProcessProjection::literal).toList(), specialProcess, step.resolved(), - snapshot.worldgen(step.reference()).isPresent()); + snapshot.worldgen(step.reference()).isPresent(), + snapshot.recipe(step.reference()) + .map(MaterialProcessSnapshot.NativeRecipe::genericRecovery) + .orElse(false)); } private static Optional specialMethod( diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index 45b65a996..2151edf65 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -174,13 +174,8 @@ private ProcessNavigation(MaterialProcessSnapshot snapshot) { } @Override - public boolean openStack(ItemStack icon, boolean uses) { - if (!MaterialProcessSnapshot.Store.current(snapshot) || icon.isEmpty()) return false; - var stack = MaterialProcessEmiStacks.of(icon); - if (stack.isEmpty()) return false; - if (uses) dev.emi.emi.api.EmiApi.displayUses(stack); - else dev.emi.emi.api.EmiApi.displayRecipes(stack); - return true; + public boolean valid() { + return MaterialProcessSnapshot.Store.current(snapshot); } @Override diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java index c92c110c3..bdf557ae2 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java @@ -151,17 +151,9 @@ public void render(GuiGraphics graphics, int x, int y, float delta) { panel.draw(graphics, x, y); } - @Override - public EmiIngredient ingredientAt(double x, double y) { - return EmiIngredient.of(panel.stacksAt(x, y).stream() - .map(MaterialProcessEmiStacks::of) - .filter(stack -> !stack.isEmpty()) - .toList()); - } - @Override public boolean mouseClicked(int x, int y, int button) { - return panel.click(x, y, button); + return panel.clickControls(x, y, button); } @Override @@ -186,5 +178,38 @@ public List getTooltip(int x, int y) { .toList(); } }); + for (var node : panel.nodes()) { + var icons = panel.stacks(node); + if (icons.isEmpty()) continue; + widgets.add(new dev.emi.emi.api.widget.SlotWidget(MaterialProcessEmiStacks.of(icons.get(0)), 0, 0) { + @Override + public Bounds getBounds() { + var bounds = panel.bounds(node); + return new Bounds( + bounds.left(), + bounds.top(), + Math.max(0, bounds.right() - bounds.left()), + Math.max(0, bounds.bottom() - bounds.top())); + } + + @Override + public EmiIngredient getStack() { + return page.navigation().valid() ? super.getStack() : EmiStack.EMPTY; + } + + @Override + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {} + + @Override + public List getTooltip(int x, int y) { + var details = panel.tooltip(x, y); + return details.size() > 1 + ? details.stream() + .map(line -> ClientTooltipComponent.create(line.getVisualOrderText())) + .toList() + : super.getTooltip(x, y); + } + }); + } } } diff --git a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java index 198da84f4..e224e070e 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java @@ -242,6 +242,11 @@ private ProcessNavigation(MaterialProcessSnapshot snapshot) { this.snapshot = snapshot; } + @Override + public boolean valid() { + return MaterialProcessSnapshot.Store.current(snapshot); + } + @Override public boolean openStack(ItemStack stack, boolean uses) { if (runtime == null || !MaterialProcessSnapshot.Store.current(snapshot) || stack.isEmpty()) return false; diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java index 42a4d36a5..411a59ddf 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java @@ -69,6 +69,14 @@ public record NativeRecipe(RecipeMap map, Recipe recipe, int index) { Objects.requireNonNull(recipe); if (index < 0) throw new IllegalArgumentException("Invalid native recipe index"); } + + /** Publication fallback ownership also covers ordinary processing such as anvil crushing. */ + public boolean genericRecovery() { + return RecoveryRecipePublisher.generic(recipe) + && (map == gregtech.content.data.MachineRecipeMaps.Shredder + || map == gregtech.content.data.MachineRecipeMaps.Melter + || map == gregtech.content.data.MachineRecipeMaps.Smelter); + } } public record NativeWorldgen(MaterialWorldgenFacts.Fact fact) { @@ -114,7 +122,8 @@ private MaterialProcessSnapshot( var builder = MaterialProcessGraph.builder(snapshot); COVERAGE.forEach(notice -> builder.notice(notice.code(), notice.omitted())); for (Step step : steps.values()) { - builder.add(step); + NativeRecipe nativeRecipe = nativeRecipes.get(step.reference()); + builder.add(step, nativeRecipe != null && nativeRecipe.genericRecovery()); step.inputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); step.outputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); } diff --git a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java index e59c91fb1..39b25c921 100644 --- a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java +++ b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java @@ -97,6 +97,44 @@ public static void overviewGroupsVisibleRoutesAndHidesAuxiliaries(GameTestHelper helper.succeed(); } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewFoldsSimilarRoutesAcrossNativeRecipeDifferences(GameTestHelper helper) { + var alternatives = new ArrayList(); + for (int index = 0; index < 4; index++) { + var output = layoutPort("bark", true); + var variableOutput = new gregtech.compat.common.MaterialProcessDisplay.Port( + output.resource(), output.material(), output.name(), output.icons(), output.role(), false, + output.amount(), net.minecraft.network.chat.Component.literal(Integer.toString(index + 1)), + java.util.OptionalInt.of(2500 * (index + 1)), output.details(), output.identity()); + var inputs = new ArrayList<>(List.of(layoutPort("wood_" + index, false), + displayPort("lubricant_" + index, "Other", index % 2 == 0 ? Items.WATER_BUCKET : Items.LAVA_BUCKET, false))); + if (index == 1) inputs.add(layoutPort("extra_wood", false)); + alternatives.add(new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "wood_" + index), + net.minecraft.network.chat.Component.literal("cutter"), new ItemStack(Items.STONECUTTER), inputs, + index == 3 ? List.of(variableOutput, layoutPort("wood_dust", true)) : List.of(variableOutput), + List.of(), java.util.Optional.empty(), true)); + } + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(alternatives, List.of())); + var machines = graph.nodes().stream().filter(node -> node.machine()).toList(); + helper.assertTrue(machines.size() == 1 && machines.get(0).steps.size() == 4, + "similar wood routes fold despite different input sets, auxiliaries, yields and probabilities"); + helper.assertTrue(graph.grids().stream().anyMatch(grid -> grid.members.size() == 5) + && graph.grids().stream().anyMatch(grid -> grid.members.size() == 2), + "alternative inputs and variant products remain visible beside the shared machine"); + helper.assertTrue(graph.nodes().stream().filter(node -> !node.machine()) + .anyMatch(node -> node.port().identity().equals("bark") && node.chanceBadge().equals("…%")), + "a shared product preserves the different native probabilities"); + for (var step : alternatives) for (boolean output : List.of(false, true)) { + var ports = output ? step.outputs() : step.inputs(); + for (var port : ports) helper.assertTrue( + machines.get(0).endpoints.stream().anyMatch(endpoint -> endpoint.step() == step && endpoint.port() == port) + || machines.get(0).auxiliaries.contains(port), + "every original port survives visual folding"); + } + helper.succeed(); + } + private static gregtech.compat.common.MaterialProcessDisplay.Port displayPort( String reference, String material, net.minecraft.world.item.Item item, boolean output) { var name = net.minecraft.network.chat.Component.literal(reference); @@ -200,7 +238,7 @@ public static void overviewKeepsDenseEdgesLocal(GameTestHelper helper) { "local copies retain all native steps"); helper.assertTrue(graph.nodes().stream().anyMatch(node -> node.copy && node.returning), "dense feedback uses marked local resources"); - helper.assertTrue(graph.nodes().stream().mapToInt(node -> node.y).min().orElseThrow() == 24, + helper.assertTrue(graph.nodes().stream().mapToInt(node -> node.y).min().orElseThrow() == 52, "feedback does not reserve empty lanes above the graph"); for (var edge : graph.edges()) { helper.assertTrue(edge.path().size() == 2 && edge.to().layer > edge.from().layer, @@ -213,11 +251,12 @@ public static void overviewKeepsDenseEdgesLocal(GameTestHelper helper) { "copied and shared connections retain exact native ports"); var from = edge.path().get(0); var to = edge.path().get(1); + helper.assertTrue(to.x() > from.x(), "visible routes read from left to right"); double slope = (double) (to.y() - from.y()) / (to.x() - from.x()); for (var node : graph.nodes()) { - if (node.layer <= edge.from().layer || node.layer >= edge.to().layer) continue; - double leftY = from.y() + (node.x - 12 - from.x()) * slope; - double rightY = from.y() + (node.x + 12 - from.x()) * slope; + if (node == edge.from() || node == edge.to() || node.x + 12 <= from.x() || node.x - 12 >= to.x()) continue; + double leftY = from.y() + (Math.max(node.x - 12, from.x()) - from.x()) * slope; + double rightY = from.y() + (Math.min(node.x + 12, to.x()) - from.x()) * slope; helper.assertTrue( Math.max(leftY, rightY) < node.y - 14 || Math.min(leftY, rightY) > node.y + 14, "direct connections avoid intermediate icons and markers"); @@ -233,6 +272,200 @@ public static void overviewKeepsDenseEdgesLocal(GameTestHelper helper) { helper.succeed(); } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewPacksLocalRoutesWithoutInvisibleDependencies(GameTestHelper helper) { + var random = new java.util.Random(42); + var steps = new ArrayList(); + var links = new ArrayList(); + for (int index = 0; index < 100; index++) + steps.add(layoutStep("packed_" + index, "form_" + random.nextInt(40), "form_" + random.nextInt(40))); + for (var source : steps) for (var target : steps) + if (source.outputs().get(0).resource().equals(target.inputs().get(0).resource())) + links.add(new gregtech.compat.common.MaterialProcessDisplay.Connection(source.reference(), target.reference(), + source.outputs().get(0).resource(), true)); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, links)); + var local = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); + helper.assertTrue(layoutPositions(graph).equals(layoutPositions(local)) && graph.connections().size() == links.size(), + "retained native associations do not stretch copies into invisible dependency columns"); + helper.assertTrue(graph.width() < 1000 && graph.height() < 1000, + "dense local recipe blocks use a compact canvas"); + var islands = new ArrayList(); + for (int index = 0; index < 24; index++) islands.add(layoutStep("island_" + index, "input_" + index, "output_" + index)); + var packed = new gregtech.compat.common.MaterialProcessOverview(layoutPage(islands, List.of())); + helper.assertTrue(packed.width() < 600 && packed.height() < 600 + && packed.nodes().stream().filter(node -> node.machine()).count() == 24, + "independent routes fill adjacent shelves while retaining every route"); + for (var first : graph.nodes()) for (var second : graph.nodes()) + if (first != second) helper.assertTrue(Math.abs(first.x - second.x) >= 24 || Math.abs(first.y - second.y) >= 24, + "packing keeps resource and machine boxes separate"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewKeepsFirstOutputAndVariantsTogether(GameTestHelper helper) { + var base = layoutStep("lens", "gem", "lens"); + var steps = new ArrayList(); + for (int index = 0; index < 2; index++) + steps.add(new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "lens_" + index), base.name(), base.icon(), + base.inputs(), List.of(base.outputs().get(0), layoutPort("a_dust_" + index, true)), + List.of(), java.util.Optional.empty(), true)); + for (int index = 0; index < 12; index++) + steps.add(layoutStep("other_" + index, "gem", "other_output_" + index)); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); + var machine = graph.nodes().stream().filter(node -> node.machine() && node.steps.size() == 2) + .findFirst().orElseThrow(); + var outputs = graph.edges().stream().filter(edge -> edge.from() == machine).toList(); + helper.assertTrue(outputs.size() == 3, "variants share a machine while retaining their distinct outputs"); + var grid = graph.grids().stream().filter(value -> value.members.contains(outputs.get(0).to())).findFirst().orElseThrow(); + helper.assertTrue(grid.members.size() == 3 && grid.members.stream().allMatch(node -> node.y == machine.y), + "variant products occupy adjacent cells inside their recipe block"); + helper.assertTrue(outputs.stream().map(edge -> edge.path()).distinct().count() == 1, + "one output arrow connects the machine to the whole product grid"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void recoveryOwnershipAndMachineKindDriveOverviewClassification(GameTestHelper helper) { + var foreign = RecoveryRecipePublisher.generic(row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, + Items.COPPER_INGOT), "test-recycling"); + var local = RecoveryRecipePublisher.generic(row(new ItemStack[] {new ItemStack(Items.COPPER_INGOT)}, + Items.IRON_INGOT), "test-recycling"); + var ordinary = row(new ItemStack[] {new ItemStack(Items.GOLD_INGOT)}, Items.COPPER_INGOT); + for (var recoveryMap : List.of(gregtech.content.data.MachineRecipeMaps.Shredder, + gregtech.content.data.MachineRecipeMaps.Melter, gregtech.content.data.MachineRecipeMaps.Smelter)) + helper.assertTrue(new MaterialProcessSnapshot.NativeRecipe(recoveryMap, local, 0).genericRecovery(), + "generic grinding and melting routes are recovery"); + helper.assertTrue(!new MaterialProcessSnapshot.NativeRecipe(gregtech.content.data.MachineRecipeMaps.Anvil, local, 0).genericRecovery() + && !new MaterialProcessSnapshot.NativeRecipe(gregtech.content.data.MachineRecipeMaps.Shredder, ordinary, 0).genericRecovery(), + "anvil fallback ownership and ordinary shredder recipes do not imply recovery"); + var map = new RecipeMap(new ArrayList<>(List.of(foreign, local, ordinary)), + "gt.test.process.recovery", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, + false, false, false, false); + RecipeMap.unregister(map); + var snapshot = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of(map)); + var root = snapshot.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); + var query = snapshot.queryMaterial(root.resource(), new Budgets(0, 8, 16, 16)); + helper.assertTrue(query.steps().size() == 3, + "fallback ownership on an ordinary process does not hide its material sources"); + var page = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, root.resource(), + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); + helper.assertTrue(page.steps().stream().noneMatch(value -> value.genericRecovery()), + "projection and source indexing use the same recovery classification"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewSeparatesSourcesConversionsAndUses(GameTestHelper helper) { + var source = new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "source"), + net.minecraft.network.chat.Component.literal("source"), new ItemStack(Items.STONECUTTER), + List.of(displayPort("foreign", "Other", Items.IRON_INGOT, false)), List.of(layoutPort("ore", true)), + List.of(), java.util.Optional.empty(), true); + var use = new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "use"), + net.minecraft.network.chat.Component.literal("use"), new ItemStack(Items.STONECUTTER), + List.of(layoutPort("dust", false)), List.of(displayPort("foreign_product", "Other", Items.GOLD_INGOT, true)), + List.of(), java.util.Optional.empty(), true); + var uncertain = layoutConnection("source", "convert", "ore"); + var links = List.of(new gregtech.compat.common.MaterialProcessDisplay.Connection( + uncertain.source(), uncertain.target(), uncertain.resource(), false), + layoutConnection("convert", "use", "dust")); + var graph = new gregtech.compat.common.MaterialProcessOverview( + layoutPage(List.of(use, layoutStep("convert", "ore", "dust"), source), links)); + helper.assertTrue(graph.bands().size() == 3 && graph.connections().size() == 2, + "one overview preserves all associations and only allocates populated bands"); + helper.assertTrue(graph.edges().stream().filter(edge -> !edge.endpoint().output() + && edge.endpoint().step().reference().equals(uncertain.target())).noneMatch(edge -> edge.confirmed()), + "cross-band associations retain their uncertainty after local layout"); + for (var node : graph.nodes()) if (node.machine()) { + var band = graph.bands().stream().filter(value -> value.section() == node.section).findFirst().orElseThrow(); + helper.assertTrue(node.x >= band.left() && node.x < band.right(), + "machines stay in their semantic source, conversion or use band"); + } + helper.assertTrue(graph.nodes().stream().filter(node -> !node.machine() + && (node.port().identity().equals("ore") || node.port().identity().equals("dust"))) + .allMatch(node -> node.copy), + "boundary material instances carry copy markers instead of crossing separators with long wires"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewFoldsAlternativeInputsAndKeepsProductGridsLocal(GameTestHelper helper) { + var alternatives = new ArrayList(); + for (int index = 0; index < 13; index++) alternatives.add(layoutStep("smelt_" + index, "form_" + index, "molten")); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(alternatives, List.of())); + var grid = graph.grids().get(0); + helper.assertTrue(grid.members.size() == 13 && grid.right() - grid.left() == 72 + && grid.bottom() - grid.top() == 120, + "thirteen alternative inputs occupy a three-column, five-row inventory"); + helper.assertTrue(graph.nodes().stream().filter(node -> node.machine()).count() == 1 + && graph.nodes().stream().filter(node -> node.machine()).findFirst().orElseThrow().steps.size() == 13, + "alternative forms share one machine while retaining all native recipes"); + helper.assertTrue(graph.edges().stream().filter(edge -> !edge.endpoint().output()).map(edge -> edge.path()).distinct().count() == 1, + "all input cells connect through one trunk"); + var yields = new ArrayList(); + for (int count : List.of(2, 4)) { + var nativeStep = layoutStep("yield_" + count, "form_" + count, "molten"); + var nativePort = nativeStep.outputs().get(0); + var port = new gregtech.compat.common.MaterialProcessDisplay.Port(nativePort.resource(), nativePort.material(), nativePort.name(), + nativePort.icons(), nativePort.role(), false, net.minecraft.network.chat.Component.literal(count + " items"), + net.minecraft.network.chat.Component.literal(Integer.toString(count)), nativePort.chance(), nativePort.details(), nativePort.identity()); + yields.add(new gregtech.compat.common.MaterialProcessDisplay.Step(nativeStep.reference(), nativeStep.name(), nativeStep.icon(), + nativeStep.inputs(), List.of(port), List.of(), java.util.Optional.empty(), true)); + } + var yieldGraph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(yields, List.of())); + helper.assertTrue(yieldGraph.grids().size() == 1 && yieldGraph.nodes().stream().anyMatch(node -> !node.machine() && node.quantityBadge().equals("2/4")), + "different batch yields do not prevent form folding or overwrite each other's quantities"); + var positions = layoutPositions(graph); + java.util.Collections.reverse(alternatives); + helper.assertTrue(positions.equals(layoutPositions(new gregtech.compat.common.MaterialProcessOverview(layoutPage(alternatives, List.of())))), + "folded grids do not depend on snapshot order"); + var base = layoutStep("bolt", "bolt", "small_dust"); + var bolt = new gregtech.compat.common.MaterialProcessDisplay.Step(base.reference(), base.name(), base.icon(), base.inputs(), + List.of(base.outputs().get(0), layoutPort("tiny_dust", true)), List.of(), java.util.Optional.empty(), true); + var products = new gregtech.compat.common.MaterialProcessOverview(layoutPage( + List.of(bolt, layoutStep("small_source", "ore", "small_dust"), layoutStep("tiny_use", "tiny_dust", "ingot")), List.of())); + helper.assertTrue(products.grids().stream().anyMatch(value -> value.members.size() == 2 + && value.members.stream().map(node -> node.port().identity()).collect(java.util.stream.Collectors.toSet()) + .equals(java.util.Set.of("small_dust", "tiny_dust"))), + "a bolt's two products stay adjacent even when one has other producers and the other has consumers"); + var manyOutputs = new ArrayList(); + for (int index = 0; index < 128; index++) manyOutputs.add(layoutPort("many_" + index, true)); + var many = new gregtech.compat.common.MaterialProcessDisplay.Step(base.reference(), base.name(), base.icon(), base.inputs(), + manyOutputs, List.of(), java.util.Optional.empty(), true); + var large = new gregtech.compat.common.MaterialProcessOverview(layoutPage( + List.of(many, layoutStep("consume", "many_0", "result")), List.of())); + helper.assertTrue(large.grids().stream().anyMatch(value -> value.members.size() == 128), + "long-edge detection uses the grid anchor instead of detaching a tall grid's first cell"); + for (var edge : products.edges()) for (var endpoint : edge.endpoints()) + helper.assertTrue((endpoint.output() ? endpoint.step().outputs() : endpoint.step().inputs()).get(endpoint.index()) == endpoint.port(), + "grid cells and shared trunks retain exact native endpoint ownership"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewShowsPortYieldsAndOrdersRecoveryAfterConversions(GameTestHelper helper) { + var base = layoutPort("dust", true); + var output = new gregtech.compat.common.MaterialProcessDisplay.Port(base.resource(), base.material(), base.name(), base.icons(), base.role(), + base.main(), net.minecraft.network.chat.Component.literal("2 items"), net.minecraft.network.chat.Component.literal("2"), + java.util.OptionalInt.of(1111), base.details(), base.identity()); + var step = layoutStep("grind", "bolt", "dust"); + var recovery = new gregtech.compat.common.MaterialProcessDisplay.Step(step.reference(), step.name(), step.icon(), step.inputs(), + List.of(output), List.of(), java.util.Optional.empty(), true, false, true); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(recovery), List.of())); + var product = graph.nodes().stream().filter(node -> !node.machine() && node.endpoints.stream().anyMatch(endpoint -> endpoint.output())) + .findFirst().orElseThrow(); + helper.assertTrue(product.quantityBadge().equals("2") && product.chanceBadge().equals("11.11%"), + "quantity and basis-point probability are rendered without reconstructing them from icon counts"); + helper.assertTrue(graph.bands().stream().map(value -> value.section()).toList().equals(List.of( + gregtech.compat.common.MaterialProcessDisplay.Section.RECOVERY)), + "a recovery-only page does not reserve space for three empty bands"); + helper.assertTrue(product.returning, "recovery products retain their return marker"); + helper.succeed(); + } + private static gregtech.compat.common.MaterialProcessDisplay.Step layoutStep(String id, String input, String output) { return new gregtech.compat.common.MaterialProcessDisplay.Step(new gregtech.api.addon.material.DataKey("test", id), net.minecraft.network.chat.Component.literal(id), new ItemStack(Items.STONECUTTER), From a4cf0da334425b41d550922a9fb69d1088439ba6 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Sun, 15 Nov 2026 14:42:30 +0800 Subject: [PATCH 07/17] optimize GUI --- .../resources/assets/gt6ce/lang/en_us.json | 6 +- .../resources/assets/gt6ce/lang/zh_cn.json | 6 +- docs/architecture/packages/runtime.md | 2 +- docs/development/material-process-display.md | 20 +- docs/development/material-process-layout.md | 6 +- .../development/validation/checks/gametest.md | 2 +- .../validation/checks/manual-ingame.md | 6 +- .../gregtech/client/MaterialProcessPanel.java | 204 ++++++++++++------ .../client/MaterialProcessScreen.java | 115 ++++++++++ .../compat/common/MaterialProcessDisplay.java | 8 + .../common/MaterialProcessOverview.java | 92 ++++++++ .../compat/emi/GregTechEMIPlugin.java | 18 ++ .../compat/emi/MaterialProcessEmiRecipe.java | 37 +++- .../compat/jei/GregTechJEIPlugin.java | 47 ++++ .../compat/jei/MaterialProcessCategory.java | 46 +++- .../mixin/EmiMaterialProcessFocusMixin.java | 33 +++ .../recipe/MaterialProcessSnapshotTests.java | 82 +++++++ .../src/main/resources/gregtech.mixins.json | 1 + .../resources/gregtech-neoforge.mixins.json | 93 ++++---- 19 files changed, 679 insertions(+), 145 deletions(-) create mode 100644 minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java create mode 100644 minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index 58f8485a4..01190237b 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -71,14 +71,16 @@ "gt6ce.special_process.aqua_regia_leaching": "Aqua Regia Leaching", "gt6ce.special_process.hydrofluoric_acid_leaching": "Hydrofluoric Acid Leaching", "gt6ce.special_process.hydrochloric_acid_manganese_leaching": "Hydrochloric Acid Manganese Leaching", - "gt6ce.jei.material_process.pan": "Drag empty space to pan freely | Scroll to zoom at the pointer", + "gt6ce.jei.material_process.pan": "Hover to highlight matching items | Drag to pan | Scroll to zoom at the pointer", "gt6ce.jei.material_process.reset": "R", "gt6ce.jei.material_process.zoom_hint": "Scroll to zoom at the pointer, or click − / +.", "gt6ce.jei.material_process.resource_hint": "Left-click: recipes | Right-click: uses. Hover the machine for amounts and extra ingredients.", "gt6ce.jei.material_process.variants": "%s recipes share this route", "gt6ce.jei.material_process.copy": "Local display copy of this resource (↗); related copies highlight together.", "gt6ce.jei.material_process.return": "Return flow (↩); this is not an additional source.", - "gt6ce.jei.material_process.reset_hint": "Restore readable scale and center on the material route.", + "gt6ce.jei.material_process.fullscreen": "Open full-screen material overview", + "gt6ce.jei.material_process.exit_fullscreen": "Return to the recipe viewer", + "gt6ce.jei.material_process.reset_hint": "Restore 100% zoom and center on the queried resource.", "gt6ce.jei.material_process.empty": "No processing steps in this result.", "gt6ce.jei.material_process.unbound": "Processing data has not been connected yet.", "gt6ce.jei.material_process.controls": "Left-click step: recipe | Click resource: sources / uses", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index d559b104f..3c35feb18 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -73,14 +73,16 @@ "gt6ce.special_process.aqua_regia_leaching": "王水浸出", "gt6ce.special_process.hydrofluoric_acid_leaching": "氢氟酸浸出", "gt6ce.special_process.hydrochloric_acid_manganese_leaching": "盐酸锰矿浸出", - "gt6ce.jei.material_process.pan": "拖拽空白区域自由平移|滚轮以鼠标为中心缩放", + "gt6ce.jei.material_process.pan": "悬停高亮相同物品|拖拽空白区域平移|滚轮以鼠标为中心缩放", "gt6ce.jei.material_process.reset": "复位", "gt6ce.jei.material_process.zoom_hint": "滚轮以鼠标为中心缩放;也可点击 −/+。", "gt6ce.jei.material_process.resource_hint": "左击:配方|右击:用途;数量与额外物品请悬停机器查看。", "gt6ce.jei.material_process.variants": "此路线包含 %s 个配方", "gt6ce.jei.material_process.copy": "此资源的局部展示副本(↗);悬停同步突出其他副本。", "gt6ce.jei.material_process.return": "回流(↩);不表示新增来源。", - "gt6ce.jei.material_process.reset_hint": "恢复可读比例并定位到本材料的路线。", + "gt6ce.jei.material_process.fullscreen": "全屏浏览材料总览", + "gt6ce.jei.material_process.exit_fullscreen": "返回配方查看器", + "gt6ce.jei.material_process.reset_hint": "恢复 100% 缩放并居中显示查询的物品或流体。", "gt6ce.jei.material_process.empty": "此查询结果中没有加工步骤。", "gt6ce.jei.material_process.unbound": "尚未接入加工数据。", "gt6ce.jei.material_process.controls": "左击工艺:原配方|左/右击资源:来源/用途", diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index 0f3978b9a..83a6d8142 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,7 +70,7 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责按机器/首产物合并相似路线、原生端口实例、可见拓扑层级、连续链、局部副本、输入/产物网格、独立路线紧凑排布、端口产量角标和排线,`client.MaterialProcessPanel` 负责可读视口、副本/回流标记与原生交互;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、索引和事件适配。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 +矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责按机器/首产物合并相似路线、原生端口实例、可见拓扑层级、连续链、局部副本、输入/产物网格、独立路线紧凑排布、端口产量角标、排线、配方浅色边界及同物品匹配,`client.MaterialProcessPanel` 负责带绿色目标外框的 100% 查询聚焦、窗口自适应视口、副本/回流标记与原生交互;`client.MaterialProcessScreen` 承载全屏浏览与返回原查看器;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、仅限页面材料的索引和事件适配;EMI 查询目标由客户端可选的 `EmiMaterialProcessFocusMixin` 传入。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md index b41465af8..7365cde1c 100644 --- a/docs/development/material-process-display.md +++ b/docs/development/material-process-display.md @@ -16,7 +16,8 @@ | `MaterialProcessDisplay.Connection` | 调用方提供的步骤关联,包含资源引用及确认状态;支持分支、回边和自环 | | `MaterialProcessDisplay.Page` | 一种材料的全部已查询步骤、全图关联、覆盖说明和绑定到同一查询结果的跳转回调;页面不按步骤拆页 | | `gregtech.compat.common.MaterialProcessOverview` | 按显示身份合并重复路线与资源,保留原始步骤/端口,计算依赖层级、连续链及排线路径 | -| `gregtech.client.MaterialProcessPanel` | 固定 280×216 视口内的拓扑图、副本/回流标记、可读缩放、双向平移、同步悬停高亮、名称提示与普通来源/用途查询;不依赖 JEI/EMI | +| `gregtech.client.MaterialProcessPanel` | 窗口自适应视口内的拓扑图、查询目标绿色外框、同物品悬停、配方浅色边框、平移缩放与普通来源/用途查询;不依赖 JEI/EMI | +| `gregtech.client.MaterialProcessScreen` | 全窗口浏览,共用面板、相机和查询目标;退出返回原查看器,窗口变化保留中心世界坐标 | | `gregtech.compat.jei.MaterialProcessCategory` | JEI 不可见检索索引、拖拽/滚轮事件和 tooltip;分类类型为 `TYPE`,标识为 `gt6ce:material_process` | | `gregtech.compat.emi.MaterialProcessEmiRecipe` | EMI 索引、拖拽/滚轮事件和共享面板适配;不读取材料目录或配方表 | | `gregtech.content.recipe.MaterialProcessSnapshot` | 绑定一次完整发布、会话和世界生成 revision;索引最终机器行与符号选择器 | @@ -63,18 +64,27 @@ 各区分别排布可见依赖并横向拼接,跨区重复材料使用带标记的实例,不用长线穿过分割线;原始跨区 Connection 仍保留并可反查。区内依赖图按稳定引用遍历,解除反馈边的前向层级约束后计算 DAG 层级;纯环与自环保留方向和标记。相邻层优先按原生端口顺序对齐首个可见输出和首个可见输入,再参考连接度和链长;该排布优先级不会把未知角色改成 PRIMARY。同一机器的多个本材料产物按端口顺序紧挨排成至多三列的网格,输入替代形态使用相同网格;必要时为共享端口创建可反查的局部实例。网格与机器共用一根输入线或输出箭头,每个物品格仍独立命中、查询和显示角标。链段和网格按整体包围盒预留矩形空间后一起排布,并做四轮邻接重心排序,减少交叉;不因连接度大于阈值就拆散公共物品。边跨越超过三层、纵向距离超过 128 单位、穿过中间节点或属于反馈边时,将该端口改为机器附近的局部资源副本,再重新排布。次要输出离机器超过两行时也使用局部副本,避免副产物远离所属配方。每个可见端口最多拆出一个副本,短距离连续主链和邻近分支仍共享资源。建立局部副本后只按可见边计算层级,保留的逻辑 Connection 不再预留远处的隐形依赖列。互不相连的路线按各自网格宽度压紧横向列和空行,再按矩形尺寸就近排列成多列,避免短配方被最长链或其他路线的网格宽度撑开。 -共享面板的常规悬停只显示实际物品/机器名称;EMI 节点使用原生槽位 tooltip;无原生图标时使用符号名称。机器右上角 `+` 的独立悬停区域显示合并配方数和去重后的辅料名称,最多列出十二项;完整配方信息通过 viewer 普通查询查看。局部副本与回流仍有 `↗`/`↩` 标记,相关资源与边同步高亮。 +共享面板的常规悬停只显示实际物品/机器名称;EMI 节点使用原生槽位 tooltip;无原生图标时使用符号名称。机器右上角 `+` 的独立悬停区域显示合并配方数和去重后的辅料名称,最多列出十二项;完整配方信息通过 viewer 普通查询查看。局部副本与回流仍有 `↗`/`↩` 标记,相同物品实例同步悬停高亮,连线不随悬停变色。 所有可见连接统一使用单段直线,分支直接斜向相连,不再混用正交折线。输入侧只连线,输出侧保留箭头,连续链为 `材料—机器→产出`。回流使用带 `↩` 标记的局部副本,不在画布顶部预留回流通道;副本之间不额外连线。线宽、虚线间距及箭头与节点使用同一画布变换,随缩放同比变化。布局在首次打开页面创建面板时完成;EMI 注册索引时不提前排布全部材料,缩放、平移和悬停不重新排图。 `MaterialProcessProjection` 从同一快照的原生配方复制物品栈和流体状态。含指纹的状态字符串不是序列化数据,不能去掉指纹后新建无数据物品代替;无法恢复时保留无图标符号。EMI 的流体索引、查询和悬停提供器通过 `MaterialProcessEmiStacks` 将代理显示物品还原为真实流体键和数据,而非索引代理物品本身。物品则保留完整 NBT/组件。悬停及点击使用当前实际显示的代表,而原生索引保留全部有限代表;有可用真实图标时优先使用,不让另一条无图标引用遮蔽它。同显示身份可以有多个带标记的局部实例;实例复制不改变原始 selector 或原生索引。 -拖拽空白区域向任意方向平移,滚轮围绕鼠标缩放,顶部 `−/+` 围绕视口中心缩放,“复位”采用 `max(0.75, min(1, 整图适配比例))`;超出视口时定位本材料的代表链,小图适配视口。滚轮仍可主动缩小查看全图。裁剪边界先通过 viewer 当前渲染矩阵转换为绝对 GUI 坐标;悬停、点击和 EMI 原生 ingredient provider 共同使用实际渲染矩阵及画布逆变换。页脚 `i` 提供覆盖及截断说明。 +查询打开及“复位”均采用 100% 缩放,将查询物品/流体的可见节点放在视口中心;没有匹配目标时定位本材料的代表链。JEI 从当前 `IFocusGroup` 取得完整物品/流体状态,EMI 通过仅限客户端、可选目标的 `EmiMaterialProcessFocusMixin` 在 `EmiApi.setPages` 构造页面前取得查询 ingredient;两个节点均注册该 Mixin,EMI 未安装时由 `@Pseudo` 跳过。每次新查询重新定位,不沿用上次的缩放和平移;当前查询因窗口改变或全屏切换重新排版时保留视图。 -- EMI 的机器和资源直接接入原生 `SlotWidget`,槽位边界跟随画布变换并裁剪到视口;点击、释放、拖动物品、收藏、R/U 及自定义按键绑定由 EMI 处理。面板只处理缩放按钮与画布平移,不硬编码鼠标键打开来源/用途。 +悬停只突出同一物品的展示实例,不向输入、输出或连线传播;机器图标也按真实物品匹配。物品保留完整 NBT/组件,流体按完整显示身份同步局部副本。匹配结果只在悬停目标变化时更新。查询选中的可见节点持续带淡绿色双线外框,移开鼠标后仍可识别;没有匹配查询目标时只定位代表链,不给它添加查询标记。 + +每条显示配方用浅色边框包围机器及可归属的局部端口;共享端口归属最近机器,边框扩展时不得框入其他路线的节点。该边界只服务阅读,不复制配方或改变原始端口。边框与布局一起缓存,不因平移或缩放重算。 + +嵌入视口根据窗口的 GUI 尺寸伸缩,EMI 再采用 WidgetHolder 实际允许的宽高;绘制、裁剪、原生槽位、控制按钮和命中使用相同的实时尺寸。右上角的全屏按钮打开 `MaterialProcessScreen`,在窗口内展开画布;Esc 或同一按钮返回原查看器。缩放与视口中心的世界坐标在尺寸变化前后保持一致,原生物品/流体提供器在全屏仍生效。JEI 全屏通过 GUI handler 提供查询,EMI 通过 stack provider 提供查询;EMI 发起原生查询前先恢复其原屏幕,满足 `EmiApi.setPages` 的屏幕类型要求。 + +拖拽空白区域向任意方向平移,滚轮围绕鼠标缩放,顶部 `−/+` 围绕视口中心缩放;仍可主动缩小查看全图。裁剪边界先通过 viewer 当前渲染矩阵转换为绝对 GUI 坐标;悬停、点击和 EMI 原生 ingredient provider 共同使用实际渲染矩阵及画布逆变换。页脚 `i` 提供覆盖及截断说明。 + +- EMI 的机器和资源直接接入原生 `SlotWidget`,槽位边界跟随画布变换并裁剪到视口;点击、释放、拖动物品、收藏、R/U 及自定义按键绑定由 EMI 处理。嵌入面板只处理缩放、全屏按钮与画布平移;全屏通过原生提供器及导航回调打开来源/用途。 - JEI 沿用 `Navigation.openStack`/`openPort` 的原生 focus 查询;EMI 原生槽位同样使用真实物品或流体句柄。`openForm` 保留为显式打开另一材料总览的接口,不再作为生产页资源点击时重新打开总览的路径。 - `Navigation.valid()` 校验当前 generation;EMI 过期槽位返回空 ingredient,JEI 跳转回调继续拒绝过期引用。`Navigation.NONE` 不提供程序化跳转。 - 一个材料仍只注册一个 `Page`,局部副本只影响展示,没有删除原配方或另建执行模型。 +- JEI 与 EMI 均从 `Page.indexedPorts()` 建立检索索引,只收录 `Port.material` 等于页面材料且有原生图标的端口。外来主输入、辅料、催化剂及副产物仍保留在原始步骤中,不使该材料页出现在它们的查询结果里;端口角色与有限候选集保持原样。两种 viewer 均用真实流体句柄索引流体。 ## 后续调用方式 @@ -89,7 +99,7 @@ registration.addRecipes(MaterialProcessCategory.TYPE, pages); `Navigation` 由内容适配器创建并捕获该次查询的会话/generation。每次跳转先检查当前版本,过期或不能解析时返回 `false`,不得跳转到新版本中“相似”的配方。不要捕获旧 `Level`/服务器实例,也不要从客户端直接扫描集成服务器表。生产者应将未来 `ProcessRef` 和实际材料形态引用映射到展示引用,适配器使用原生服务重新解析;UI 不发明第二个快照协议。 -JEI 的 `openStack` 使用 OUTPUT/INPUT focus。EMI 不再实现总览的 `openStack` 点击分派,而由原生 `SlotWidget` 统一处理机器与物品的鼠标、键盘和拖拽行为。普通查询保留完整原生状态,不解析某个 `Step.reference` 来选择精确配方。 +JEI 的 `openStack` 使用 OUTPUT/INPUT focus。EMI 嵌入面板由原生 `SlotWidget` 处理机器与物品的鼠标、键盘和拖拽;全屏通过 stack provider 和 `Navigation.openStack` 接入同一原生查询。普通查询保留完整原生状态,不解析某个 `Step.reference` 来选择精确配方。 动态打开查询结果可复用 JEI `IRecipeManager.getRecipeCategory(TYPE)` 和 `IRecipesGui.showRecipes(category, pages, List.of())`;优先让结果仅随当前显示布局存活。若使用运行期 `addRecipes`,调用方必须负责重载、断线、换服以及旧记录和回调的释放;`hideRecipes` 只是隐藏,不能当作回收旧快照的手段。`MachineRecipeClient` 在断线时清除当前快照,`MaterialProcessSnapshot.Store` 只保留当前成功代和一代前代;展示页本身不缓存材料目录或配方表。 diff --git a/docs/development/material-process-layout.md b/docs/development/material-process-layout.md index 65c83dac3..785309233 100644 --- a/docs/development/material-process-layout.md +++ b/docs/development/material-process-layout.md @@ -101,7 +101,7 @@ ### 端口排线与箭头 -所有连接统一使用单段直线;连续链保持水平,分支使用斜线,不混入正交折线。输入侧只画线,输出侧才画箭头。输入和输出分别分配固定侧的端口位置,网格按整体侧边中点分配锚点,重复端口连线只绘制一次,悬停任一关联格均能高亮共享线;单个物品仍按自身侧边连接。密集多端口场景尚需游戏内确认。跨层边若会穿过中间节点,改用机器附近的资源副本。 +所有连接统一使用单段直线;连续链保持水平,分支使用斜线,不混入正交折线。输入侧只画线,输出侧才画箭头。输入和输出分别分配固定侧的端口位置,网格按整体侧边中点分配锚点,重复端口连线只绘制一次,悬停仅突出同物品实例,不改变共享线颜色;单个物品仍按自身侧边连接。密集多端口场景尚需游戏内确认。跨层边若会穿过中间节点,改用机器附近的资源副本。 回流和自环使用带 `↩` 标记的局部资源副本,保留真实输入/输出方向,不画跨越全图的回路,也不为回流预留顶部空白。没有节点的交叉处不画连接圆点,不同资源不能共用一段看似混料的总线;同一资源需要共线时,也应保留各工序的独立端口归属。 @@ -111,9 +111,9 @@ 打开页面即绘制全部已查询步骤及可见主端口;完整端口仍保存在数据和各工序详情中。有内容的区域同时存在于同一画布,不需要工艺区选择器、步骤列表分页或展开操作。有内容的分区标题及分割线随画布一起缩放和平移,空分区不分配空间。常用浏览仍是看图、平移和缩放;副本标记在未悬停时也可见。 -初始缩放与复位采用可读性下限:小图可适配视口,大图保持可读比例并定位根材料的代表链附近。可用 `max(可读缩放下限, min(1, 整图适配比例))` 作为初始策略;具体下限根据游戏 GUI 缩放、物品尺寸及字体实际验证。若保留整图鸟瞰,应为显式操作,不能每次打开都自动把节点缩到难以辨认。 +初始缩放与复位均为 100%,查询目标的可见节点居中并持续带淡绿色外框;没有查询目标时定位根材料的代表链。新查询即使复用缓存布局,也重新设置目标和视口。嵌入视口随窗口和查看器可用尺寸变化,全屏按钮打开窗口内完整画布,Esc 或按钮返回原查看器;尺寸变化保留缩放和中心世界坐标。整图鸟瞰通过主动缩小完成。 -沿用现有资源左/右击查询、机器和资源左/右击普通来源/用途查询与 EMI ingredient provider。高亮优先使用悬停,不能直接照搬草图的点选锁定而占用这些原生点击动作。EMI 图标使用原生槽位与 tooltip,鼠标、释放、快捷键、收藏及物品拖拽沿用 EMI 绑定;共享面板及 JEI 的常规图标提示只显示名称;只有 `+` 区域显示合并配方数与去重辅料名,不提供右击切换隐藏变体。 +沿用现有资源与机器的普通来源/用途查询和 EMI ingredient provider。悬停只突出相同物品的可见实例,保留完整原生状态;不传播到产线或连线。查询目标持续带淡绿色外框。每条配方增加浅色边界,局部端口归属最近机器,扩展边框时避开其他路线的节点;共享资源与原始配方事实保持不变。EMI 嵌入图标使用原生槽位,鼠标、释放、快捷键、收藏及物品拖拽沿用 EMI 绑定;全屏接入原生 stack provider 与导航回调。普通 tooltip 只显示名称,`+` 区域显示合并配方数与去重辅料名。 所有副本的绘制、命中、tooltip、点击和原生 ingredient provider 使用同一展示实例及相同视口变换。未解析关系仍保留说明与关系提示;资源副本不绕过快照 generation 校验。 diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index bd5c71d3d..685c952c8 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -36,7 +36,7 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe ### 配方回归案例表 -材料处理的 `MaterialProcessSnapshotTests` 验证输入 tag 不污染输出、跨材料路线、世界生成形态与完整 revision、普通共同原料、辅助工具说明、相似路线跨辅料/概率/输入形态合并、砧加工与研磨/熔化回收的分类、局部副本无隐形依赖占位、独立路线紧凑排布、过期资源拒绝和同代索引复用;`material_process` 批次不写生产配方。 +材料处理的 `MaterialProcessSnapshotTests` 验证输入 tag 不污染输出、跨材料路线、世界生成形态与完整 revision、普通共同原料、辅助工具说明、相似路线跨辅料/概率/输入形态合并、砧加工与研磨/熔化回收的分类、局部副本无隐形依赖占位、独立路线紧凑排布、仅限页面材料的查询索引、完整原生状态的聚焦目标、同物品悬停的原生状态区分与跨分区副本匹配、局部配方边框不框入相邻机器、过期资源拒绝和同代索引复用;`material_process` 批次不写生产配方。 材料领域的 `MaterialBaselineTests` 验证存储块的成分与两类准入、72U 附魔金苹果的规划和实际回收输出、复合钻头、耐久缩放、容器与有形状铸模、压模机模具、固体/流体分解及 test-source 材料 SPI。`material_baseline_reload` 为仅含一个测试的独立批次,等待两次真实资源重载;拥有规则数和固定样例必须稳定。原始投影写入根目录 `work/material-system-refactor/runtime//<运行目录>/`。已知错误行为明确标为观察,不能当作正确性依据;字段、复现与未覆盖范围见[材料基线报告](../../../integration/material-baseline.md)。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 8d422d3b8..29e8c9c47 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -24,10 +24,10 @@ 1. 在 JEI/EMI 中打开真实材料的“矿物处理”。页面应直接显示同一张画布上有内容的来源/内部转换/回收/去向区域、区标题与相邻区域分割线,空区域不留占位;世界生成和泉进入来源区;无切换或分页。连续链水平向右,替代路线和分叉就近分行;未分类步骤、无外部入口环及自环不能消失。不同 GUI 缩放下右侧、底部裁剪正确。 2. 切割机三种润滑剂相同主物品/机器图标/首产物时只显示一条路线,次要输出不同也应共用机器、保留各分支,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。EMI 物品和机器使用原生槽位,确认自定义来源/用途绑定、点击释放、R/U、收藏及拖动物品均与普通 EMI 槽位一致,不精确锁定原配方;JEI 沿用普通来源/用途 focus;EMI 使用原生 tooltip,JEI 常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。非 1 件产量、U/mB 和非必然概率在图标上可见,精度保留至原生百分比;确定的 1 件产出不加数量/概率角标,未知概率显示 `?%`。共享资源采用生产端口的量,多个变体的不同量显示多值/省略号并可悬停查看;时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 -3. 资源局部副本带 `↗`,回流带 `↩`,悬停同步突出相关实例和箭头。相同显示代表跨 selector 共享节点,不同 NBT/组件状态分开;同图标不能补造跨步骤关联。连接均为单段直线,分支斜向相连,输入无箭头、输出有箭头;遮挡图标的长边和回流改用局部副本,没有顶部回流通道。确认关系不因循环改为虚线。 +3. 资源局部副本带 `↗`,回流带 `↩`。悬停只突出相同物品的全部实例,机器图标也按真实物品匹配;其他资源、机器和连线均不跟随高亮,移到空白清除。不同 NBT/组件状态分开,流体副本按完整显示身份匹配。查询目标持续显示淡绿色外框,移开鼠标后仍保留。每条配方有较浅外框,独立小配方容易区分,共享端口与网格不能使边框包住相邻机器。连接为单段直线,分支斜连,输入无箭头、输出有箭头;回流不占顶部通道,确认关系不因循环改为虚线。 4. 对带 NBT/组件物品与真实流体,逐个副本检查左/右击、R/U、tooltip 和 EMI ingredient provider;流体代理应查询实际流体。各节点使用实际显示的完整物品/流体状态查询,无法恢复时保留符号,不用无数据假栈。 5. 来源/内部转换/回收/去向决定横向分区,不依据机器名称分组;“本材料+辅料 → 本材料其他形态+副产物”仍属内部转换。工具、存在条件及额外辅料/副产物均不扩展生产路线。主材料的多输入、多输出分支仍保留。相同机器和首产物的替代形态应折叠为三列网格,共用一根输入线;用多种木材产树皮的路线确认辅料、输入形态数、次要产物、批量和概率不同也会合并,差异可在普通配方查询中查看。透镜或螺栓加工等本材料多输出按端口顺序紧邻排成至多三列网格,共用输出箭头;共享资源也不能把产物挤到其他配方之外。逐格验证原生查询、悬停和 EMI 命中;同一组矩形内部不能插入其他路线的节点或连线。通用研磨/熔化回收配方同时核对 GENERIC 归属及 Shredder/Melter/Smelter 配方表,砧敲碎等普通加工不得进入回收区或被从材料来源中隐藏;回收途径在内部转换后、去向前的独立回收区展示,不能因产出少量粉末就铺成粉末来源;显式来源配方仍应存在。 -6. 独立路线应紧凑排列成多列,局部副本不在远处预留依赖列,短配方也不被其他路线的宽网格撑开。大图初始和复位保持至少 75% 可读比例并定位代表链;小图适配视口。滚轮围绕鼠标缩放,顶部 `−/+` 缩放;空白处左右、上下拖动有效。在 100%、25% 和约 8% 比例下确认线宽、虚线间距及箭头与图标同比缩小,不出现盖住整图的固定尺寸箭头。缩放和平移后,图标、`+`、tooltip、点击及 EMI 悬停命中一致。 +6. 独立路线应紧凑排列成多列,局部副本不在远处预留依赖列,短配方也不被其他路线的宽网格撑开。分别查询原料、粉末、锭、零件与真实流体,材料总览只匹配页面所属材料,不能因另一材料配方使用了该物品作辅料、催化剂或外来副产物而出现。每次查询打开与复位均为 100%,查询的具体物品/流体节点位于视口中心;无目标时定位代表链。先平移、缩放再查询另一形态及同一形态,确认缓存视图也会重新定位;不同 NBT/组件状态分别确认。滚轮围绕鼠标缩放,顶部 `−/+` 缩放;空白处左右、上下拖动有效。在 100%、25% 和约 8% 比例下确认线宽、虚线间距及箭头与图标同比缩小,不出现盖住整图的固定尺寸箭头。缩放和平移后,图标、`+`、tooltip、点击及 EMI 悬停命中一致。 调整窗口尺寸及 GUI 缩放后,视口、按钮、裁剪与原生命中应一起变化;右上角全屏按钮展开到窗口,Esc 或按钮返回原查看器。全屏、返回及窗口变化均保留中心世界坐标和缩放;验证全屏中的 JEI/EMI 来源/用途、快捷键、收藏及拖拽,流体仍查询真实流体。 7. 连续重载两次后确认配方增删同步、旧引用拒绝跳转;断线/换服不沿用回调。布局副本数不改变配方数量或原生 viewer 索引;方法标签只来自 API target/reagent 声明。 8. 两平台分别检查 JEI-only、EMI-only 和双装环境,双装沿既有去重规则。另验无 viewer 的专用服务端与独立远程客户端;未实际执行的场景不能用编译或集成服务器静态表代替。 @@ -35,6 +35,8 @@ ## 注意事项 +`overviewIndexesOnlyItsOwnMaterialAndFindsNativeFocus`、`overviewMatchesItemsAcrossCopiesAndKeepsRecipesSeparate` 与 `overviewFramesRecipesWithoutEnclosingTheirNeighbors` 覆盖查询索引、原生状态目标、同物品副本匹配及配方边框边界;不代替目标绿色外框、动态视口、全屏往返、两平台 `EmiApi.setPages` Mixin 命中与真实查看器的鼠标/键盘验收。 + - 使用隔离实例;EULA 由操作者自行处理;完整日志、截图与实例配置放 `work/<任务名>/`,公共记录只保留脱敏结论。 - 记录提交或源码状态、JDK、Minecraft 与加载器版本、GT6CE 构建、依赖模组及版本、配置差异。 - 每条场景写清前置条件与操作、预期、实际、判定和平台;判定使用“未验证 / 部分验证 / 验证通过 / 已知失败”。 diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java index b68c68eff..1c9d810af 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java @@ -2,11 +2,14 @@ import com.mojang.math.Axis; import gregtech.compat.common.MaterialProcessDisplay.Page; +import gregtech.compat.common.MaterialProcessDisplay.Port; import gregtech.compat.common.MaterialProcessOverview; import gregtech.compat.common.MaterialProcessOverview.Node; import gregtech.compat.jei.PreviewViewport; import java.util.ArrayList; import java.util.List; +import java.util.Set; +import java.util.function.Predicate; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; @@ -15,23 +18,95 @@ /** A readable viewport onto the cached topology layout and its native port instances. */ public final class MaterialProcessPanel { public static final int WIDTH = 280, HEIGHT = 216; - private static final int BODY_TOP = 17, FOOTER = 203; + private static final int BODY_TOP = 17; private static final int TEXT = 0xff383838, MUTED = 0xff777777, GOLD = 0xffffcc44; private static final double MIN_ZOOM = 0.0001, MAX_ZOOM = 3; private final Page page; private final MaterialProcessOverview overview; + private Node focused, hovered; + private Set highlight = Set.of(); + private int width = WIDTH, height = HEIGHT; + private boolean fullscreen; private double zoom, panX, panY; public MaterialProcessPanel(Page page) { this.page = page; overview = new MaterialProcessOverview(page); - fit(); + resetView(); + } + + public void focus(Predicate matches) { + focused = overview.find(matches); + resetView(); + } + + public static int preferredWidth() { + return Math.max(200, Minecraft.getInstance().getWindow().getGuiScaledWidth() - 160); + } + + public static int preferredHeight() { + return Math.max(80, Minecraft.getInstance().getWindow().getGuiScaledHeight() - 110); + } + + public int width() { + return width; + } + + public int height() { + return height; + } + + private int footer() { + return height - 13; + } + + /** Resizing keeps the same world point at the center, including when entering or leaving fullscreen. */ + public void resize(int width, int height) { + int nextWidth = Math.max(160, width), nextHeight = Math.max(64, height); + panX += (nextWidth - this.width) / 2.0; + panY += (nextHeight - this.height) / 2.0; + this.width = nextWidth; + this.height = nextHeight; + } + + void fullscreen(boolean fullscreen) { + this.fullscreen = fullscreen; + } + + Component title() { + return page.title(); + } + + public PreviewViewport.Bounds boundsAt(double x, double y) { + Node node = hit(x, y); + return node == null ? new PreviewViewport.Bounds(0, 0, 0, 0) : bounds(node); + } + + private void drawFullscreenButton(GuiGraphics graphics) { + int x = width - 16, y = 3; + for (int dx : new int[] {0, 8}) + for (int dy : new int[] {0, 8}) { + graphics.fill(x + dx, y + dy, x + dx + 4, y + dy + 1, TEXT); + graphics.fill( + x + dx + (dx == 0 ? 0 : 3), + y + (dy == 0 ? 0 : dy - 3), + x + dx + (dx == 0 ? 1 : 4), + y + (dy == 0 ? 4 : dy + 1), + TEXT); + } + } + + private static void outline(GuiGraphics graphics, int left, int top, int right, int bottom, int color) { + graphics.fill(left, top, right, top + 1, color); + graphics.fill(left, bottom - 1, right, bottom, color); + graphics.fill(left, top, left + 1, bottom, color); + graphics.fill(right - 1, top, right, bottom, color); } public void draw(GuiGraphics graphics, double mouseX, double mouseY) { - graphics.fill(0, 0, WIDTH, HEIGHT, 0xffc6c6c6); - text(graphics, page.title(), 4, 2, WIDTH - 122, TEXT); - text(graphics, Component.literal("−"), WIDTH - 114, 2, 12, TEXT); + graphics.fill(0, 0, width, height, 0xffc6c6c6); + text(graphics, page.title(), 4, 2, width - 148, TEXT); + text(graphics, Component.literal("−"), width - 138, 2, 12, TEXT); text( graphics, Component.literal(java.math.BigDecimal.valueOf(zoom * 100) @@ -39,16 +114,21 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { .stripTrailingZeros() .toPlainString() + "%"), - WIDTH - 98, + width - 120, 2, 33, MUTED); - text(graphics, Component.literal("+"), WIDTH - 61, 2, 12, TEXT); - text(graphics, Component.translatable("gt6ce.jei.material_process.reset"), WIDTH - 28, 2, 26, MUTED); + text(graphics, Component.literal("+"), width - 82, 2, 12, TEXT); + text(graphics, Component.translatable("gt6ce.jei.material_process.reset"), width - 58, 2, 35, MUTED); + drawFullscreenButton(graphics); graphics.flush(); - var viewport = PreviewViewport.screenBounds(graphics.pose().last().pose(), 0, BODY_TOP, WIDTH, FOOTER); + var viewport = PreviewViewport.screenBounds(graphics.pose().last().pose(), 0, BODY_TOP, width, footer()); graphics.enableScissor(viewport.left(), viewport.top(), viewport.right(), viewport.bottom()); - Node hovered = hit(mouseX, mouseY); + Node hit = hit(mouseX, mouseY); + if (hit != hovered) { + hovered = hit; + highlight = overview.matchingNodes(hovered); + } try { graphics.pose().pushPose(); try { @@ -59,7 +139,11 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { text(graphics, band.section().label(), band.left() + 6, 8, band.right() - band.left() - 12, TEXT); if (band.left() > 0) graphics.fill(band.left(), 2, band.left() + 1, overview.height(), 0xff999999); } - drawEdges(graphics, hovered); + for (var frame : overview.frames()) { + graphics.fill(frame.left(), frame.top(), frame.right(), frame.bottom(), 0xffcacaca); + outline(graphics, frame.left(), frame.top(), frame.right(), frame.bottom(), 0xffe4e4e4); + } + drawEdges(graphics); for (var grid : overview.grids()) { graphics.fill(grid.left(), grid.top(), grid.right(), grid.bottom(), 0xff777777); for (int y = grid.top(); y < grid.bottom(); y += 24) @@ -68,8 +152,12 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { } for (Node node : overview.nodes()) { if (!visible(node)) continue; - if (related(node, hovered)) - graphics.fill(node.x - 10, node.y - 10, node.x + 11, node.y + 11, 0xffe5e5e5); + if (highlight.contains(node)) + graphics.fill(node.x - 11, node.y - 11, node.x + 12, node.y + 12, 0xffe4e4e4); + if (node == focused) { + outline(graphics, node.x - 13, node.y - 13, node.x + 14, node.y + 14, 0xffa7dba0); + outline(graphics, node.x - 12, node.y - 12, node.x + 13, node.y + 13, 0xffbce7b6); + } ItemStack icon = node.machine() ? selected(node).icon() : node.port().icons().stream().findFirst().orElse(ItemStack.EMPTY); @@ -96,32 +184,24 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { Component.translatable("gt6ce.jei.material_process.empty"), 12, BODY_TOP + 28, - WIDTH - 24, + width - 24, MUTED); - text(graphics, Component.literal("i"), 4, FOOTER + 3, 12, MUTED); + text(graphics, Component.literal("i"), 4, footer() + 3, 12, MUTED); } private gregtech.compat.common.MaterialProcessDisplay.Step selected(Node node) { return node.steps.get(0); } - private static boolean related(Node node, Node hovered) { - return node == hovered - || hovered != null - && !node.machine() - && !hovered.machine() - && node.port().identity().equals(hovered.port().identity()); - } - private boolean visible(Node node) { return node.x + 12 >= worldX(0) - && node.x - 12 <= worldX(WIDTH) + && node.x - 12 <= worldX(width) && node.y + 12 >= worldY(BODY_TOP) - && node.y - 14 <= worldY(FOOTER); + && node.y - 14 <= worldY(footer()); } private Node hit(double mouseX, double mouseY) { - if (mouseX < 0 || mouseX >= WIDTH || mouseY < BODY_TOP || mouseY >= FOOTER) return null; + if (mouseX < 0 || mouseX >= width || mouseY < BODY_TOP || mouseY >= footer()) return null; double x = worldX(mouseX), y = worldY(mouseY); for (Node node : overview.nodes()) if (x >= node.x - 11 && x < node.x + 12 && y >= node.y - 12 && y < node.y + 12) return node; @@ -141,8 +221,8 @@ public PreviewViewport.Bounds bounds(Node node) { return new PreviewViewport.Bounds( (int) Math.max(0, Math.floor(panX + (node.x - 11) * zoom)), (int) Math.max(BODY_TOP, Math.floor(BODY_TOP + panY + (node.y - 12) * zoom)), - (int) Math.min(WIDTH, Math.ceil(panX + (node.x + 12) * zoom)), - (int) Math.min(FOOTER, Math.ceil(BODY_TOP + panY + (node.y + 12) * zoom))); + (int) Math.min(width, Math.ceil(panX + (node.x + 12) * zoom)), + (int) Math.min(footer(), Math.ceil(BODY_TOP + panY + (node.y + 12) * zoom))); } public List stacks(Node node) { @@ -155,12 +235,16 @@ public List stacks(Node node) { } public List tooltip(double mouseX, double mouseY) { - if (mouseY < BODY_TOP && mouseX >= WIDTH - 118) + if (mouseY >= 0 && mouseY < BODY_TOP && mouseX >= width - 144) return List.of(Component.translatable( - mouseX >= WIDTH - 29 - ? "gt6ce.jei.material_process.reset_hint" - : "gt6ce.jei.material_process.zoom_hint")); - if (mouseY >= FOOTER) { + mouseX >= width - 20 + ? fullscreen + ? "gt6ce.jei.material_process.exit_fullscreen" + : "gt6ce.jei.material_process.fullscreen" + : mouseX >= width - 63 + ? "gt6ce.jei.material_process.reset_hint" + : "gt6ce.jei.material_process.zoom_hint")); + if (mouseY >= footer()) { var lines = new ArrayList<>(page.notices()); lines.add(Component.translatable("gt6ce.jei.material_process.pan")); return List.copyOf(lines); @@ -216,16 +300,20 @@ public boolean click(double mouseX, double mouseY, int button) { public boolean clickControls(double mouseX, double mouseY, int button) { if (button != 0 && button != 1) return false; if (button == 0 && mouseY >= 0 && mouseY < 14) { - if (mouseX >= WIDTH - 29 && mouseX < WIDTH) { - fit(); + if (mouseX >= width - 20 && mouseX < width) { + MaterialProcessScreen.toggle(this); + return true; + } + if (mouseX >= width - 63 && mouseX < width - 22) { + resetView(); return true; } - if (mouseX >= WIDTH - 118 && mouseX < WIDTH - 101) { - zoomAt(WIDTH / 2.0, (BODY_TOP + FOOTER) / 2.0, zoom / 1.25); + if (mouseX >= width - 144 && mouseX < width - 123) { + zoomAt(width / 2.0, (BODY_TOP + footer()) / 2.0, zoom / 1.25); return true; } - if (mouseX >= WIDTH - 65 && mouseX < WIDTH - 46) { - zoomAt(WIDTH / 2.0, (BODY_TOP + FOOTER) / 2.0, zoom * 1.25); + if (mouseX >= width - 87 && mouseX < width - 65) { + zoomAt(width / 2.0, (BODY_TOP + footer()) / 2.0, zoom * 1.25); return true; } } @@ -235,9 +323,9 @@ public boolean clickControls(double mouseX, double mouseY, int button) { public boolean press(double mouseX, double mouseY, int button) { return (button == 0 || button == 1) && mouseX >= 0 - && mouseX < WIDTH + && mouseX < width && mouseY >= BODY_TOP - && mouseY < FOOTER + && mouseY < footer() && hit(mouseX, mouseY) == null; } @@ -249,7 +337,7 @@ public boolean drag(int button, double dx, double dy) { } public boolean scroll(double mouseX, double mouseY, double delta) { - if (mouseX < 0 || mouseX >= WIDTH || mouseY < BODY_TOP || mouseY >= FOOTER || delta == 0) return false; + if (mouseX < 0 || mouseX >= width || mouseY < BODY_TOP || mouseY >= footer() || delta == 0) return false; zoomAt(mouseX, mouseY, zoom * Math.pow(1.15, Math.max(-8, Math.min(8, delta)))); return true; } @@ -269,35 +357,22 @@ private void zoomAt(double x, double y, double requested) { panY = y - BODY_TOP - wy * zoom; } - private void fit() { - zoom = Math.max( - 0.75, - Math.min( - 1, - Math.min( - (WIDTH - 12.0) / Math.max(1, overview.width()), - (FOOTER - BODY_TOP - 12.0) / Math.max(1, overview.height())))); - if (overview.width() * zoom <= WIDTH && overview.height() * zoom <= FOOTER - BODY_TOP) { - panX = (WIDTH - overview.width() * zoom) / 2; - panY = (FOOTER - BODY_TOP - overview.height() * zoom) / 2; - } else { - Node anchor = overview.anchor(); - panX = WIDTH / 3.0 - (anchor == null ? 0 : anchor.x) * zoom; - panY = (FOOTER - BODY_TOP) / 2.0 - (anchor == null ? 0 : anchor.y) * zoom; - } + private void resetView() { + zoom = 1; + Node anchor = focused == null ? overview.anchor() : focused; + panX = width / 2.0 - (anchor == null ? overview.width() / 2.0 : anchor.x); + panY = (footer() - BODY_TOP) / 2.0 - (anchor == null ? overview.height() / 2.0 : anchor.y); } - private void drawEdges(GuiGraphics graphics, Node hovered) { + private void drawEdges(GuiGraphics graphics) { record Wire(List path, boolean output) {} var wires = new java.util.LinkedHashMap>(); for (var edge : overview.edges()) wires.computeIfAbsent(new Wire(edge.path(), edge.endpoint().output()), ignored -> new ArrayList<>()) .add(edge); for (var entry : wires.entrySet()) { - boolean highlighted = entry.getValue().stream() - .anyMatch(edge -> related(edge.from(), hovered) || related(edge.to(), hovered)); boolean confirmed = entry.getValue().stream().allMatch(MaterialProcessOverview.Edge::confirmed); - int color = highlighted ? 0xff986c26 : TEXT; + int color = TEXT; var path = entry.getKey().path(); for (int index = 1; index < path.size(); index++) { var from = path.get(index - 1); @@ -325,7 +400,7 @@ private void segment( boolean arrow, int color) { stroke(graphics, sx, sy, tx, ty, color, dashed); - if (!arrow || tx < worldX(0) || tx >= worldX(WIDTH) || ty < worldY(BODY_TOP) || ty >= worldY(FOOTER)) return; + if (!arrow || tx < worldX(0) || tx >= worldX(width) || ty < worldY(BODY_TOP) || ty >= worldY(footer())) return; double angle = Math.atan2(ty - sy, tx - sx); graphics.pose().pushPose(); try { @@ -349,6 +424,7 @@ private static void smallText(GuiGraphics graphics, String value, int x, int y, } private static void text(GuiGraphics graphics, Component value, int x, int y, int width, int color) { + if (width <= 0) return; var font = Minecraft.getInstance().font; graphics.drawString( font, @@ -362,7 +438,7 @@ private static void text(GuiGraphics graphics, Component value, int x, int y, in private void stroke(GuiGraphics graphics, double x1, double y1, double x2, double y2, int color, boolean dashed) { double dx = x2 - x1, dy = y2 - y1, from = 0, to = 1; double[] p = {-dx, dx, -dy, dy}, - q = {x1 - worldX(-1), worldX(WIDTH + 1) - x1, y1 - worldY(BODY_TOP - 1), worldY(FOOTER + 1) - y1}; + q = {x1 - worldX(-1), worldX(width + 1) - x1, y1 - worldY(BODY_TOP - 1), worldY(footer() + 1) - y1}; for (int side = 0; side < 4; side++) { if (p[side] == 0) { if (q[side] < 0) return; diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java b/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java new file mode 100644 index 000000000..4f7ff2cf4 --- /dev/null +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java @@ -0,0 +1,115 @@ +package gregtech.client; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.item.ItemStack; + +/** Full-window host for the same graph, camera and query target used by the recipe viewer. */ +public final class MaterialProcessScreen extends Screen { + private static final int MARGIN = 6; + private final MaterialProcessPanel panel; + private final Screen parent; + private int dragButton = -1; + + private MaterialProcessScreen(MaterialProcessPanel panel, Screen parent) { + super(panel.title()); + this.panel = panel; + this.parent = parent; + } + + public static void toggle(MaterialProcessPanel panel) { + var client = Minecraft.getInstance(); + if (client.screen instanceof MaterialProcessScreen screen && screen.panel == panel) screen.onClose(); + else client.setScreen(new MaterialProcessScreen(panel, client.screen)); + } + + @Override + protected void init() { + dragButton = -1; + panel.fullscreen(true); + panel.resize(width - MARGIN * 2, height - MARGIN * 2); + } + + @Override + public void removed() { + dragButton = -1; + panel.fullscreen(false); + panel.resize(MaterialProcessPanel.preferredWidth(), MaterialProcessPanel.preferredHeight()); + } + + @Override + public void onClose() { + Minecraft.getInstance().setScreen(parent); + } + + public ItemStack stackAt(double x, double y) { + return panel.stacksAt(x - MARGIN, y - MARGIN).stream().findFirst().orElse(ItemStack.EMPTY); + } + + public Rect2i stackArea(double x, double y) { + var bounds = panel.boundsAt(x - MARGIN, y - MARGIN); + return new Rect2i(MARGIN + bounds.left(), MARGIN + bounds.top(), + Math.max(0, bounds.right() - bounds.left()), Math.max(0, bounds.bottom() - bounds.top())); + } + + @Override + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + graphics.fill(0, 0, width, height, 0xff303030); + graphics.pose().pushPose(); + try { + graphics.pose().translate(MARGIN, MARGIN, 0); + panel.draw(graphics, mouseX - MARGIN, mouseY - MARGIN); + } finally { + graphics.pose().popPose(); + } + var tooltip = panel.tooltip(mouseX - MARGIN, mouseY - MARGIN); +//? if >=1.21.1 { + /*if (!tooltip.isEmpty()) graphics.renderTooltip(font, tooltip, java.util.Optional.empty(), mouseX, mouseY); +*///?} else { + if (!tooltip.isEmpty()) graphics.renderComponentTooltip(font, tooltip, mouseX, mouseY); +//?} + } + + @Override + public boolean mouseClicked(double x, double y, int button) { + if (panel.clickControls(x - MARGIN, y - MARGIN, button)) return true; + if (panel.press(x - MARGIN, y - MARGIN, button)) { + dragButton = button; + return true; + } + return panel.click(x - MARGIN, y - MARGIN, button) || super.mouseClicked(x, y, button); + } + + @Override + public boolean mouseReleased(double x, double y, int button) { + if (dragButton == button) { + dragButton = -1; + return true; + } + return super.mouseReleased(x, y, button); + } + + @Override + public boolean mouseDragged(double x, double y, int button, double dx, double dy) { + return dragButton == button && panel.drag(button, dx, dy) || super.mouseDragged(x, y, button, dx, dy); + } + +//? if >=1.21.1 { + /*@Override + public boolean mouseScrolled(double x, double y, double dx, double dy) { + return panel.scroll(x - MARGIN, y - MARGIN, dy) || super.mouseScrolled(x, y, dx, dy); + } +*///?} else { + @Override + public boolean mouseScrolled(double x, double y, double delta) { + return panel.scroll(x - MARGIN, y - MARGIN, delta) || super.mouseScrolled(x, y, delta); + } +//?} + + @Override + public boolean isPauseScreen() { + return false; + } +} diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java index ccadaecaf..1713c5685 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java @@ -309,6 +309,14 @@ public record Page( || total < number || notices.isEmpty()) throw new IllegalArgumentException("Invalid process display page"); } + + /** Foreign reagents and byproducts belong to the recipe, not to this material's viewer index. */ + public List indexedPorts() { + return steps.stream() + .flatMap(step -> java.util.stream.Stream.concat(step.inputs().stream(), step.outputs().stream())) + .filter(port -> port.material().equals(material) && port.hasIcons()) + .toList(); + } } private MaterialProcessDisplay() {} diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java index 7e1aa25a2..a05e3d08e 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Predicate; import net.minecraft.world.item.ItemStack; /** A bounded layout of native steps; resource copies never introduce recipe facts. */ @@ -202,6 +203,8 @@ private record RouteKey(IconKey icon, String fallback, List inputs, Stri private record EdgeKey(Node from, Node to) {} + public record RecipeFrame(Node machine, int left, int top, int right, int bottom) {} + private record Arc(Node from, Node to, Edge edge) {} private record Occupancy(BitSet positive, BitSet negative) { @@ -228,11 +231,13 @@ public record Band(Section section, int left, int right) {} private final List connections; private final Map next = new HashMap<>(), previous = new HashMap<>(); private final Set feedback = new HashSet<>(); + private final List frames = new ArrayList<>(); private int width, height; private Node anchor; public MaterialProcessOverview(Page page) { this(page, true); + frameRecipes(); } private MaterialProcessOverview(Page page, boolean partition) { @@ -499,6 +504,93 @@ public Node anchor() { return anchor; } + /** Find a visible native port without treating equal item icons as equal native states. */ + public Node find(Predicate matches) { + return nodes.stream() + .filter(node -> + !node.machine() && node.endpoints.stream().anyMatch(endpoint -> matches.test(endpoint.port()))) + .min(Comparator.comparing(node -> node.returning) + .thenComparingInt(node -> -chainLength(node)) + .thenComparing(node -> node.key)) + .orElse(null); + } + + public List frames() { + return List.copyOf(frames); + } + + /** Hover synchronizes equal displayed resources and machine items, including their full native state. */ + public Set matchingNodes(Node hovered) { + if (hovered == null) return Set.of(); + ItemStack icon = icon(hovered); + var matches = new HashSet(); + for (Node node : nodes) { + if (node == hovered + || !node.machine() + && !hovered.machine() + && node.port().identity().equals(hovered.port().identity()) + || !icon.isEmpty() && StackCompat.sameItem(icon, icon(node))) matches.add(node); + } + return Set.copyOf(matches); + } + + private static ItemStack icon(Node node) { + return node.machine() + ? node.steps.get(0).icon() + : node.port().icons().stream().findFirst().orElse(ItemStack.EMPTY); + } + + private void frameRecipes() { + var owners = new HashMap(); + for (Edge edge : edges) { + Node resource = representative(resource(edge)), machine = edge.from.machine() ? edge.from : edge.to; + Node previous = owners.get(resource); + if (previous == null + || distance(resource, machine) < distance(resource, previous) + || distance(resource, machine) == distance(resource, previous) + && machine.key.compareTo(previous.key) < 0) owners.put(resource, machine); + } + var local = new HashMap>(); + owners.forEach((resource, machine) -> + local.computeIfAbsent(machine, ignored -> new ArrayList<>()).add(resource)); + var columns = new java.util.TreeMap>(); + for (Node node : nodes) + columns.computeIfAbsent(node.x, ignored -> new ArrayList<>()).add(node); + for (Node machine : nodes) { + if (!machine.machine()) continue; + int left = machine.x - 12, right = machine.x + 12, top = machine.y - 14, bottom = machine.y + 14; + for (Node resource : local.getOrDefault(machine, List.of()).stream() + .sorted(Comparator.comparingLong((Node node) -> distance(node, machine)) + .thenComparing(node -> node.key)) + .toList()) { + int l = Math.min(left, resource.grid == null ? resource.x - 12 : resource.grid.left()); + int r = Math.max(right, resource.grid == null ? resource.x + 12 : resource.grid.right()); + int t = Math.min(top, resource.grid == null ? resource.y - 14 : resource.grid.top() - 2); + int b = Math.max(bottom, resource.grid == null ? resource.y + 14 : resource.grid.bottom() + 2); + boolean clear = columns.subMap(l - 12, true, r + 12, true).values().stream() + .flatMap(List::stream) + .noneMatch(node -> node != machine + && owners.get(representative(node)) != machine + && node.x + 12 > l + && node.x - 12 < r + && node.y + 14 > t + && node.y - 14 < b); + if (clear) { + left = l; + right = r; + top = t; + bottom = b; + } + } + frames.add(new RecipeFrame(machine, left - 1, top - 1, right + 1, bottom + 1)); + } + } + + private static long distance(Node resource, Node machine) { + long dx = resource.x - machine.x, dy = resource.y - machine.y; + return dx * dx + dy * dy; + } + public int width() { return width; } diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index 2151edf65..7a6588cab 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -53,6 +53,8 @@ public void register(EmiRegistry registry) { return false; }); registry.addGenericExclusionArea((screen, areas) -> { + if (screen instanceof gregtech.client.MaterialProcessScreen) + areas.accept(new dev.emi.emi.api.widget.Bounds(0, 0, screen.width, screen.height)); if (screen instanceof gregtech.client.gui.MachineContainerScreen machine) { var tab = machine.titleBounds(); if (tab.getWidth() > 0) @@ -63,6 +65,12 @@ public void register(EmiRegistry registry) { gregtech.engine.fluid.FluidContainerDisplayBinding.invalidate(); FluidScreenStackProvider.register(registry); registry.addGenericStackProvider(EmiWidgetInput::stackAt); + registry.addStackProvider(gregtech.client.MaterialProcessScreen.class, (screen, x, y) -> { + var stack = MaterialProcessEmiStacks.of(screen.stackAt(x, y)); + return stack.isEmpty() + ? dev.emi.emi.api.stack.EmiStackInteraction.EMPTY + : new dev.emi.emi.api.stack.EmiStackInteraction(stack); + }); WoodenBucketLookupRecipe.register(registry); FormConversionEmiRecipe.register(registry); registry.addRecipeHandler( @@ -178,6 +186,16 @@ public boolean valid() { return MaterialProcessSnapshot.Store.current(snapshot); } + @Override + public boolean openStack(ItemStack stack, boolean uses) { + if (!valid() || stack.isEmpty()) return false; + var ingredient = MaterialProcessEmiStacks.of(stack); + if (ingredient.isEmpty()) return false; + if (uses) dev.emi.emi.api.EmiApi.displayUses(ingredient); + else dev.emi.emi.api.EmiApi.displayRecipes(ingredient); + return true; + } + @Override public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { if (!MaterialProcessSnapshot.Store.current(snapshot)) return false; diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java index bdf557ae2..02a3d6474 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java @@ -3,6 +3,7 @@ import dev.emi.emi.api.EmiRegistry; import dev.emi.emi.api.recipe.EmiRecipe; import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.stack.Comparison; import dev.emi.emi.api.stack.EmiIngredient; import dev.emi.emi.api.stack.EmiStack; import dev.emi.emi.api.widget.Bounds; @@ -32,6 +33,7 @@ public Component getName() { private final MaterialProcessDisplay.Page page; private MaterialProcessPanel panel; + private List focus = List.of(); private final ResourceLocation id; private final List inputs; private final List catalysts; @@ -43,10 +45,7 @@ public MaterialProcessEmiRecipe(MaterialProcessDisplay.Page page) { var inputs = new ArrayList(); var catalysts = new ArrayList(); var outputs = new ArrayList(); - for (var step : page.steps()) { - for (var port : step.inputs()) add(port, inputs, catalysts, outputs); - for (var port : step.outputs()) add(port, inputs, catalysts, outputs); - } + for (var port : page.indexedPorts()) add(port, inputs, catalysts, outputs); this.inputs = List.copyOf(inputs); this.catalysts = List.copyOf(catalysts); this.outputs = List.copyOf(outputs); @@ -91,6 +90,24 @@ public static EmiRecipeCategory category() { return CATEGORY; } + public void focus(EmiIngredient ingredient) { + focus = ingredient.getEmiStacks().stream().map(EmiStack::copy).toList(); + if (panel != null) focusPanel(); + } + + private void focusPanel() { + // Strict focus matching follows EMI's native state model: components on 1.21, NBT on 1.20. +//? if >=1.21.1 { + /*var comparison = Comparison.compareComponents(); +*///?} else { + var comparison = Comparison.compareNbt(); +//?} + panel.focus(port -> port.icons().stream().anyMatch(icon -> { + var stack = MaterialProcessEmiStacks.of(icon); + return !stack.isEmpty() && focus.stream().anyMatch(target -> stack.isEqual(target, comparison)); + })); + } + @Override public EmiRecipeCategory getCategory() { return CATEGORY; @@ -128,21 +145,25 @@ public boolean hideCraftable() { @Override public int getDisplayWidth() { - return MaterialProcessPanel.WIDTH; + return MaterialProcessPanel.preferredWidth(); } @Override public int getDisplayHeight() { - return MaterialProcessPanel.HEIGHT; + return MaterialProcessPanel.preferredHeight(); } @Override public void addWidgets(WidgetHolder widgets) { - if (panel == null) panel = new MaterialProcessPanel(page); + if (panel == null) { + panel = new MaterialProcessPanel(page); + focusPanel(); + } + panel.resize(Math.min(getDisplayWidth(), widgets.getWidth()), Math.min(getDisplayHeight(), widgets.getHeight())); widgets.add(new EmiInteractiveWidget() { @Override public Bounds getBounds() { - return new Bounds(0, 0, MaterialProcessPanel.WIDTH, MaterialProcessPanel.HEIGHT); + return new Bounds(0, 0, panel.width(), panel.height()); } @Override diff --git a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java index e224e070e..9b1c11b7d 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java @@ -52,6 +52,53 @@ public final class GregTechJEIPlugin implements IModPlugin { @Override public void registerGuiHandlers(mezz.jei.api.registration.IGuiHandlerRegistration registration) { + registration.addGuiScreenHandler(gregtech.client.MaterialProcessScreen.class, screen -> + new mezz.jei.api.gui.handlers.IGuiProperties() { + // JEI 19 renamed GUI property accessors; the occupied full-window rectangle is identical. +//? if >=1.21.1 { + /*@Override public Class screenClass() { + return gregtech.client.MaterialProcessScreen.class; + } + @Override public int guiLeft() { return 0; } + @Override public int guiTop() { return 0; } + @Override public int guiXSize() { return screen.width; } + @Override public int guiYSize() { return screen.height; } + @Override public int screenWidth() { return screen.width; } + @Override public int screenHeight() { return screen.height; } +*///?} else { + @Override public Class getScreenClass() { + return gregtech.client.MaterialProcessScreen.class; + } + @Override public int getGuiLeft() { return 0; } + @Override public int getGuiTop() { return 0; } + @Override public int getGuiXSize() { return screen.width; } + @Override public int getGuiYSize() { return screen.height; } + @Override public int getScreenWidth() { return screen.width; } + @Override public int getScreenHeight() { return screen.height; } +//?} + }); + registration.addGlobalGuiHandler(new mezz.jei.api.gui.handlers.IGlobalGuiHandler() { + @Override + public java.util.Optional> getClickableIngredientUnderMouse( + double x, double y) { + if (runtime == null || !(net.minecraft.client.Minecraft.getInstance().screen + instanceof gregtech.client.MaterialProcessScreen screen)) return java.util.Optional.empty(); + var stack = screen.stackAt(x, y); + if (stack.isEmpty()) return java.util.Optional.empty(); + Object ingredient = stack; + if (gregtech.engine.fluid.FluidDisplayBinding.hasPayload(stack)) { +//? if >=1.21.1 { + /*var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolveCurrent(stack); +*///?} else { + var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolve(stack); +//?} + if (fluid.isEmpty()) return java.util.Optional.empty(); + ingredient = fluid; + } + return runtime.getIngredientManager().createClickableIngredient(ingredient, screen.stackArea(x, y), false) + .map(value -> (mezz.jei.api.runtime.IClickableIngredient) value); + } + }); registration.addGenericGuiContainerHandler(gregtech.client.gui.MachineContainerScreen.class, new mezz.jei.api.gui.handlers.IGuiContainerHandler>() { @Override public java.util.List getGuiExtraAreas( diff --git a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java index 80033a35b..97bbeff1d 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java +++ b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java @@ -3,6 +3,9 @@ import gregtech.client.MaterialProcessPanel; import gregtech.compat.common.MaterialProcessDisplay.Page; import gregtech.compat.common.MaterialProcessDisplay.Port; +import gregtech.content.recipe.MaterialProcessSnapshot; +import gregtech.engine.fluid.FluidDisplayBinding; +import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Map; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; @@ -27,6 +30,7 @@ public final class MaterialProcessCategory implements IRecipeCategory { public static final RecipeType TYPE = RecipeType.create("gt6ce", "material_process", Page.class); private final IDrawable icon; private final Map views = new IdentityHashMap<>(); + private final Map viewFocuses = new IdentityHashMap<>(); public MaterialProcessCategory(IGuiHelper helper) { icon = helper.createDrawableItemStack(new ItemStack(Items.MAP)); @@ -49,23 +53,30 @@ public IDrawable getIcon() { @Override public int getWidth() { - return MaterialProcessPanel.WIDTH; + return MaterialProcessPanel.preferredWidth(); } @Override public int getHeight() { - return MaterialProcessPanel.HEIGHT; + return MaterialProcessPanel.preferredHeight(); } @Override public void setRecipe(IRecipeLayoutBuilder builder, Page page, IFocusGroup focuses) { - for (var step : page.steps()) { - for (var port : step.inputs()) - if (port.hasIcons()) - builder.addInvisibleIngredients(role(port)).addItemStacks(port.icons()); - for (var port : step.outputs()) - if (port.hasIcons()) - builder.addInvisibleIngredients(role(port)).addItemStacks(port.icons()); + for (var port : page.indexedPorts()) { + var ingredients = builder.addInvisibleIngredients(role(port)); + for (var icon : port.icons()) { + if (!FluidDisplayBinding.hasPayload(icon)) ingredients.addItemStack(icon); + else { +//? if >=1.21.1 { + /*var fluid = FluidDisplayBinding.resolveCurrent(icon); + if (!fluid.isEmpty()) ingredients.addIngredient(mezz.jei.api.neoforge.NeoForgeTypes.FLUID_STACK, fluid); +*///?} else { + var fluid = FluidDisplayBinding.resolve(icon); + if (!fluid.isEmpty()) ingredients.addIngredient(mezz.jei.api.forge.ForgeTypes.FLUID_STACK, fluid); +//?} + } + } } } @@ -80,10 +91,21 @@ private static RecipeIngredientRole role(Port port) { @Override public void createRecipeExtras(IRecipeExtrasBuilder builder, Page page, IFocusGroup focuses) { var panel = view(page); + var identities = new HashSet(); + focuses.getItemStackFocuses().forEach(focus -> identities.add( + MaterialProcessSnapshot.itemDisplayState(focus.getTypedValue().getIngredient()))); +//? if >=1.21.1 { + /*focuses.getFocuses(mezz.jei.api.neoforge.NeoForgeTypes.FLUID_STACK).forEach(focus -> identities.add( + MaterialProcessSnapshot.fluidDisplayState(focus.getTypedValue().getIngredient()))); +*///?} else { + focuses.getFocuses(mezz.jei.api.forge.ForgeTypes.FLUID_STACK).forEach(focus -> identities.add( + MaterialProcessSnapshot.fluidDisplayState(focus.getTypedValue().getIngredient()))); +//?} + if (viewFocuses.put(page, focuses) != focuses) panel.focus(port -> identities.contains(port.identity())); builder.addGuiEventListener(new IJeiGuiEventListener() { @Override public ScreenRectangle getArea() { - return new ScreenRectangle(0, 0, MaterialProcessPanel.WIDTH, MaterialProcessPanel.HEIGHT); + return new ScreenRectangle(0, 0, panel.width(), panel.height()); } @Override @@ -121,6 +143,8 @@ public void getTooltip(ITooltipBuilder tooltip, Page page, IRecipeSlotsView slot } private MaterialProcessPanel view(Page page) { - return views.computeIfAbsent(page, MaterialProcessPanel::new); + var panel = views.computeIfAbsent(page, MaterialProcessPanel::new); + panel.resize(getWidth(), getHeight()); + return panel; } } diff --git a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java new file mode 100644 index 000000000..00b012611 --- /dev/null +++ b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java @@ -0,0 +1,33 @@ +package gregtech.mixin; + +import dev.emi.emi.api.recipe.EmiRecipe; +import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.stack.EmiIngredient; +import gregtech.compat.emi.MaterialProcessEmiRecipe; +import java.util.List; +import java.util.Map; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +/** EMI does not expose the lookup ingredient to recipe widgets; retain it before constructing their pages. */ +@Pseudo +@Mixin(targets = "dev.emi.emi.api.EmiApi", remap = false) +public abstract class EmiMaterialProcessFocusMixin { + @Inject( + method = "setPages(Ljava/util/Map;Ldev/emi/emi/api/stack/EmiIngredient;)V", + at = @At("HEAD"), + require = 1, + remap = false) + private static void gregtech$focusMaterialProcess( + Map> recipes, EmiIngredient ingredient, CallbackInfo callback) { + // EMI opens lookups only from its recipe/tree screens or a container screen. + if (recipes.values().stream().anyMatch(rows -> !rows.isEmpty()) + && net.minecraft.client.Minecraft.getInstance().screen + instanceof gregtech.client.MaterialProcessScreen screen) screen.onClose(); + for (var recipe : recipes.getOrDefault(MaterialProcessEmiRecipe.category(), List.of())) + if (recipe instanceof MaterialProcessEmiRecipe process) process.focus(ingredient); + } +} diff --git a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java index 39b25c921..34b235fe1 100644 --- a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java +++ b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java @@ -146,6 +146,88 @@ private static gregtech.compat.common.MaterialProcessDisplay.Port displayPort( false, name, name, java.util.OptionalInt.of(10000), List.of(), MaterialProcessSnapshot.itemDisplayState(icon)); } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewIndexesOnlyItsOwnMaterialAndFindsNativeFocus(GameTestHelper helper) { + var input = displayPort("copper_input", "Copper", Items.COPPER_INGOT, false); + var output = displayPort("copper_output", "Copper", Items.COPPER_BLOCK, true); + var auxiliary = displayPort("water", "Other", Items.WATER_BUCKET, false); + var byproduct = displayPort("gold", "Gold", Items.GOLD_INGOT, true); + var catalyst = new gregtech.compat.common.MaterialProcessDisplay.Port( + auxiliary.resource(), auxiliary.material(), auxiliary.name(), auxiliary.icons(), + gregtech.compat.common.MaterialProcessDisplay.Role.CATALYST, false, auxiliary.amount(), + auxiliary.quantity(), auxiliary.chance(), auxiliary.details(), auxiliary.identity()); + var step = new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "indexed"), + net.minecraft.network.chat.Component.literal("indexed"), new ItemStack(Items.STONECUTTER), + List.of(input, auxiliary, catalyst), List.of(output, byproduct), List.of(), java.util.Optional.empty(), true); + var page = layoutPage(List.of(step), List.of()); + helper.assertTrue(page.indexedPorts().equals(List.of(input, output)), + "foreign reagents, catalysts and byproducts cannot make this material page appear in their lookups"); + + var stateful = new ItemStack(Items.COPPER_BLOCK); + var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(stateful); + data.putString("process_test", "focused_state"); + gregtech.content.data.UsbDataMedia.store(stateful, data); + var nativeOutput = new gregtech.compat.common.MaterialProcessDisplay.Port( + new gregtech.api.addon.material.DataKey("test", "stateful_output"), output.material(), output.name(), + List.of(stateful), output.role(), false, output.amount(), output.quantity(), output.chance(), + output.details(), MaterialProcessSnapshot.itemDisplayState(stateful)); + var statefulStep = new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "native_focus"), step.name(), step.icon(), + List.of(input), List.of(nativeOutput), List.of(), java.util.Optional.empty(), true); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(step, statefulStep), List.of())); + var focus = graph.find(port -> port.identity().equals(nativeOutput.identity())); + helper.assertTrue(focus != null && gregtech.engine.stack.StackCompat.sameItem(focus.port().icons().get(0), stateful), + "lookup focus selects the requested form and full native state rather than its untagged icon"); + helper.assertTrue(graph.matchingNodes(focus).size() == 1, + "equal item icons with different native state remain separate hover targets"); + helper.assertTrue(graph.find(port -> port.identity().equals("absent")) == null, + "unmatched lookups can fall back to the material anchor"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewMatchesItemsAcrossCopiesAndKeepsRecipesSeparate(GameTestHelper helper) { + var source = new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "source"), + net.minecraft.network.chat.Component.literal("source"), new ItemStack(Items.FURNACE), + List.of(displayPort("external_ore", "Other", Items.RAW_COPPER, false)), List.of(layoutPort("raw", true)), + List.of(), java.util.Optional.empty(), true); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage( + List.of(source, layoutStep("convert", "raw", "ingot"), layoutStep("branch", "raw", "plate")), + List.of(layoutConnection("source", "convert", "raw"), layoutConnection("source", "branch", "raw")))); + var raw = graph.find(port -> port.identity().equals("raw")); + var matching = graph.matchingNodes(raw); + helper.assertTrue(matching.size() > 1 && matching.stream().allMatch(node -> !node.machine() + && node.port().identity().equals("raw")), + "hover matches the same resource across section copies without highlighting machines or production lines"); + var machine = graph.nodes().stream().filter(node -> node.machine() && node.steps.get(0).reference().path().equals("convert")) + .findFirst().orElseThrow(); + helper.assertTrue(graph.matchingNodes(machine).size() == 2 + && graph.matchingNodes(machine).stream().allMatch(node -> node.machine()), + "matching machine items synchronize without lighting their inputs or outputs"); + helper.assertTrue(graph.matchingNodes(null).isEmpty(), "empty space clears item hover"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewFramesRecipesWithoutEnclosingTheirNeighbors(GameTestHelper helper) { + var steps = new ArrayList(); + for (int index = 0; index < 16; index++) steps.add(layoutStep("local_" + index, "raw_" + index, "product_" + index)); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); + helper.assertTrue(graph.frames().size() == 16, "each compact recipe gets its own light frame"); + for (var frame : graph.frames()) { + helper.assertTrue(frame.left() < frame.machine().x && frame.right() > frame.machine().x + && frame.top() < frame.machine().y && frame.bottom() > frame.machine().y, + "the frame encloses its recipe machine"); + for (var node : graph.nodes()) if (node.machine() && node != frame.machine()) + helper.assertFalse(node.x >= frame.left() && node.x < frame.right() + && node.y >= frame.top() && node.y < frame.bottom(), + "a recipe frame never encloses a neighboring machine"); + } + helper.succeed(); + } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) public static void overviewAlignsChainsAndPreservesFeedback(GameTestHelper helper) { var steps = new ArrayList(); diff --git a/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json b/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json index 1787c88f2..1063350dc 100644 --- a/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json +++ b/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json @@ -56,6 +56,7 @@ "BlockPaintColorMixin", "ColoredBookLecternScreenMixin", "ColoredBookOpenPacketMixin", + "EmiMaterialProcessFocusMixin", "EmiMaterialUsesMixin", "EmiStructureFocusMixin", "FluidAlphaConfigMixin", diff --git a/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json b/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json index 67b738459..a273b32e1 100644 --- a/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json +++ b/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json @@ -5,67 +5,68 @@ "plugin": "gregtech.mixin.GTOptimizationMixinPlugin", "compatibilityLevel": "JAVA_21", "mixins": [ - "GTStateTransitionsMixin", - "MaterialIngredientCandidatesMixin", - "FormConversionServerPlaceMixin", - "PolymorphToolResultMixin", - "DungeonRedstoneInitializationMixin", - "OreHostHardnessMixin", - "SpectatorMenuMixin", - "OreHostToolSpeedMixin", - "VanillaToolDurabilityMixin", - "VanillaToolDurabilityBarMixin", - "GasImmersionMixin", - "ConstructionRecipeMixin", - "VanillaOreConfigMixin", - "VanillaOreVeinMixin", - "LegacyConstructionStackMixin", - "BaseSpawnerAccessor", - "CraftingFormPositionMixin", - "FormConversionRecipeCacheMixin", - "PolymorphFormConversionCacheMixin", "AbstractMinecartSpeedCapMixin", + "AutoCollectDropMixin", + "BaseSpawnerAccessor", "BlockEntityPaintMixin", - "WolfCollarAccessor", - "EntityFallingOreDropMixin", - "ColoredBookUseMixin", + "BucketContentAccessor", "ColoredBookLecternMixin", - "ComponentCoverHostMixin", + "ColoredBookUseMixin", "ComponentCoverCapabilitiesMixin", + "ComponentCoverHostMixin", "ComponentCoverRemovalMixin", - "LevelChunkStructureWatchMixin", - "LevelStructureProbeMixin", - "ServerChunkCacheStructureProbeMixin", - "ServerLevelStructureDataMixin", - "CoverDropMixin", - "AutoCollectDropMixin", - "ExperienceOrbCountAccessor", - "CoverWalkMixin", + "ConstructionRecipeMixin", "CoverCollisionMixin", + "CoverDropMixin", "CoverSignalMixin", - "BucketContentAccessor", + "CoverWalkMixin", + "CraftingFormPositionMixin", + "DamageSourceDeathMessageMixin", + "DungeonRedstoneInitializationMixin", + "EndermanEnchantmentMixin", + "EntityFallingOreDropMixin", + "ExperienceOrbCountAccessor", + "FormConversionRecipeCacheMixin", + "FormConversionServerPlaceMixin", + "GasImmersionMixin", + "GTStateTransitionsMixin", + "LegacyConstructionStackMixin", + "LevelChunkStructureWatchMixin", + "LevelStructureProbeMixin", + "MaterialArrowEnchantmentMixin", + "MaterialIngredientCandidatesMixin", + "OreHostHardnessMixin", + "OreHostToolSpeedMixin", + "PolymorphFormConversionCacheMixin", + "PolymorphToolResultMixin", "PotionBrewingAccessor", "PotionBrewingMixAccessor", - "MaterialArrowEnchantmentMixin", - "EndermanEnchantmentMixin", - "DamageSourceDeathMessageMixin" + "ServerChunkCacheStructureProbeMixin", + "ServerLevelStructureDataMixin", + "SpectatorMenuMixin", + "VanillaOreConfigMixin", + "VanillaOreVeinMixin", + "VanillaToolDurabilityBarMixin", + "VanillaToolDurabilityMixin", + "WolfCollarAccessor" ], "injectors": { "defaultRequire": 1 }, "client": [ - "SpectatorCrosshairMixin", - "SpectatorBlockOutlineMixin", - "GeneratedTagLanguageMixin", - "OreTerrainParticleMixin", - "FormConversionGhostPlaceMixin", - "JadeOreHarvestToolMixin", "BlockPaintColorMixin", - "ItemPaintColorMixin", - "GasFluidRenderMixin", - "FluidAlphaConfigMixin", - "EmiStructureFocusMixin", + "EmiMaterialProcessFocusMixin", "EmiMaterialUsesMixin", - "ReliableEmiNamespaceMixin" + "EmiStructureFocusMixin", + "FluidAlphaConfigMixin", + "FormConversionGhostPlaceMixin", + "GasFluidRenderMixin", + "GeneratedTagLanguageMixin", + "ItemPaintColorMixin", + "JadeOreHarvestToolMixin", + "OreTerrainParticleMixin", + "ReliableEmiNamespaceMixin", + "SpectatorBlockOutlineMixin", + "SpectatorCrosshairMixin" ] } From 7fcbdfd6c0e20782a7a8e1a6e5e5bb8a01ec627b Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Sun, 15 Nov 2026 15:53:07 +0800 Subject: [PATCH 08/17] optimize GUI --- .../resources/assets/gt6ce/lang/en_us.json | 5 + .../resources/assets/gt6ce/lang/zh_cn.json | 5 + docs/architecture/packages/runtime.md | 3 + docs/development/material-process-display.md | 18 +- .../development/validation/checks/gametest.md | 2 + .../validation/checks/manual-ingame.md | 4 +- .../gregtech/client/MaterialProcessPanel.java | 54 ++++- .../compat/common/MaterialProcessDisplay.java | 48 ++++- .../common/MaterialProcessOverview.java | 30 ++- .../common/MaterialProcessProjection.java | 23 ++- .../compat/emi/GregTechEMIPlugin.java | 70 ++++++- .../gregtech/compat/emi/MachineEmiRecipe.java | 2 + .../compat/emi/MaterialProcessEmiRecipes.java | 188 +++++++++++++++++ .../recipe/MaterialProcessSnapshot.java | 190 +++++++++++++++++- .../mixin/EmiMaterialProcessFocusMixin.java | 5 +- .../mixin/EmiMaterialProcessRecipesMixin.java | 26 +++ .../recipe/MaterialProcessSnapshotTests.java | 105 ++++++++++ .../src/main/resources/gregtech.mixins.json | 1 + .../resources/gregtech-neoforge.mixins.json | 1 + 19 files changed, 753 insertions(+), 27 deletions(-) create mode 100644 minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java create mode 100644 minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessRecipesMixin.java diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index 01190237b..f984f5a35 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -105,6 +105,11 @@ "gt6ce.jei.material_process.amount.unknown": "Amount: unknown", "gt6ce.jei.material_process.partial_unknown": "Coverage: partial; unsupported families are not shown.", "gt6ce.jei.material_process.coverage.final_recipes": "Recipes: final published machine rows.", + "gt6ce.jei.material_process.information": "Related information", + "gt6ce.jei.material_process.open_information": "Click to open the original page", + "gt6ce.jei.material_process.information_hint": "Reference only; this entry does not establish a processing route.", + "gt6ce.jei.material_process.coverage.viewer_recipes": "Recipes: final EMI processing rows, including crafting and other mods.", + "gt6ce.jei.material_process.coverage.viewer_exclusions": "%s EMI entries were excluded from processing routes; related entries remain in the information area. Mixed-material selectors are not attributed to one material.", "gt6ce.jei.material_process.coverage.active_worldgen": "World generation: active configuration only.", "gt6ce.jei.material_process.coverage.dynamic_selectors": "Tag and material-unit selectors stay symbolic; candidates are not expanded.", "gt6ce.jei.material_process.coverage.unknown_roles": "Primary and byproduct roles remain unknown when the source does not establish them.", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index 3c35feb18..2e7d714ff 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -107,6 +107,11 @@ "gt6ce.jei.material_process.amount.unknown": "数量:未知", "gt6ce.jei.material_process.partial_unknown": "覆盖范围:部分;未支持的族未显示。", "gt6ce.jei.material_process.coverage.final_recipes": "配方:最终发布的机器配方行。", + "gt6ce.jei.material_process.information": "相关信息", + "gt6ce.jei.material_process.open_information": "点击查看原始页面", + "gt6ce.jei.material_process.information_hint": "仅供参考,此条目不构成加工路线。", + "gt6ce.jei.material_process.coverage.viewer_recipes": "配方:EMI 最终加工配方,包含工作台与其他模组。", + "gt6ce.jei.material_process.coverage.viewer_exclusions": "%s 条 EMI 条目未作为加工路线导入;其中相关条目保留在信息区,跨材料候选原料不归为单一材料。", "gt6ce.jei.material_process.coverage.active_worldgen": "世界生成:仅包含当前启用的配置。", "gt6ce.jei.material_process.coverage.dynamic_selectors": "tag 与材料单位选择器保持符号形式,不展开候选全集。", "gt6ce.jei.material_process.coverage.unknown_roles": "来源未明确主/副角色时保持未知。", diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index 83a6d8142..a8372863b 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -74,6 +74,8 @@ GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../ 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 +EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理:在 `EmiMaterialProcessRecipesMixin` 取得最终可见配方后,统一接入 GT、工作台及其他模组的完整加工关系;GT 行复用原生单位、概率及回收归属,信息页和无法完整读取的条目保留在来源区底部的信息卡片,通过原页面跳转查看,不生成加工边。`MaterialProcessSnapshot.ViewerBuilder` 只构造本次客户端视图,不更改服务端配方。JEI 仍使用原生 GT 快照;具体覆盖、候选原料和生命周期边界见[EMI 配方来源与准入](../../development/material-process-display.md#emi-配方来源与准入)。 + ## 验收 - 初始化改动核对[装配顺序](#装配顺序)与[内容注册](#内容注册),包括静态字段首次访问引起的加载。 @@ -82,6 +84,7 @@ GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../ - 网络包检查方向、解码上限、执行线程、目标实体有效性与请求者权限;Mixin 检查两个节点的配置、目标签名、注入点与未命中行为。 - 可选集成沿配置与现有入口条件加载;分别验证未安装目标模组与安装匹配版本。 - 矿物处理页按[专用场景](../../development/validation/checks/manual-ingame.md#矿物处理展示页)确认联合输入、角色、概率、端口副本、显式关联与跳转;前端未接线时不记作真实来源或远程快照验收通过。 +- EMI 数据源改动还需确认工作台与第三方加工可见、原生机器不重复、信息页位于来源区底部且点击打开原页面、信息页不生成加工边、延迟注册和配方隐藏生效,以及重载与断线后的旧导航失效。 - 运输网络快照只在布局变化时失效,空闲电线/管道不执行 tick;外部 fill/drain、覆盖板、扳手、邻居变化和区块加载都必须接到失效或唤醒钩子。 - 共享 Minecraft 输入遵循 Stonecutter 条件与版本资源路径;渲染、GUI、网络与 Mixin 的结论不能用单平台结果推出另一平台。 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md index 7365cde1c..56a96933c 100644 --- a/docs/development/material-process-display.md +++ b/docs/development/material-process-display.md @@ -1,6 +1,6 @@ # 矿物处理图展示接入 -本文说明[计划 08-E](material-system-refactor/08-material-data-api.md#e有界矿物处理图与消费者迁移)的前端接入契约。生产路径从同一 `MaterialProcessSnapshot` 取得一种材料全部形态的直接关系,并在 JEI 与 EMI 中共享单页可缩放、自由平移图和 `MaterialProcessPanel`。空状态 `unbound()` 只在没有成功发布快照时使用;具体机器行、世界生成、远程客户端和人工交互仍需按验证范围分别验收。 +本文说明[计划 08-E](material-system-refactor/08-material-data-api.md#e有界矿物处理图与消费者迁移)的前端接入契约。生产路径从 `MaterialProcessSnapshot` 取得一种材料全部形态的直接关系,并在 JEI 与 EMI 中共享单页可缩放、自由平移图和 `MaterialProcessPanel`。EMI 使用最终可见加工配方构造客户端视图,JEI 使用已发布的 GT 机器与世界生成快照。空状态 `unbound()` 只在没有可展示材料时使用;具体机器行、世界生成、远程客户端和人工交互仍需按验证范围分别验收。 这是 Minecraft 实现层的客户端调用接口,随模组编译;方法声明来自 API 1.9.0,但本页面本身不是独立 API JAR 的公共材料服务。分类和面板只在已安装 JEI/EMI 的客户端路径加载;无 viewer 的专用服务端入口不得引用它们。 @@ -21,12 +21,28 @@ | `gregtech.compat.jei.MaterialProcessCategory` | JEI 不可见检索索引、拖拽/滚轮事件和 tooltip;分类类型为 `TYPE`,标识为 `gt6ce:material_process` | | `gregtech.compat.emi.MaterialProcessEmiRecipe` | EMI 索引、拖拽/滚轮事件和共享面板适配;不读取材料目录或配方表 | | `gregtech.content.recipe.MaterialProcessSnapshot` | 绑定一次完整发布、会话和世界生成 revision;索引最终机器行与符号选择器 | +| `MaterialProcessSnapshot.ViewerBuilder` | 从查看器选中的原生机器行与物品/流体端口构造独立视图,保留活动世界生成,不修改服务端发布 | +| `gregtech.compat.emi.MaterialProcessEmiRecipes` | 将 EMI 最终可见加工配方投影为材料关系,其他相关条目保留为独立信息入口 | | `gregtech.content.worldgen.MaterialWorldgenFacts` | 只含活动世界生成事实,不构造原生图标 | | `gregtech.engine.material.MaterialProcessGraph` | core 有界递归查询、材料页直连查询、循环终止和显式预算截断 | | `gregtech.compat.common.MaterialProcessProjection` | 把 core 查询转成快照内 `DataKey`、有限图标和展示 `Page` | 复用现有 `DataKey` 表达展示引用,复用 `RecipeOutputChances.CERTAIN` 的万分比契约、viewer 检索索引、配方索引与运行期注册。没有另建 SPI、全局来源缓存、锁、服务端查询协议或材料事实表。JEI 与 EMI 共用展示模型和面板,任何共用类型都不能引用具体 viewer 类。 +## EMI 配方来源与准入 + +EMI 的机器、工作台、熔炉和其他模组配方统一取自本次 `EmiRecipes.bake` 过滤后的列表,包括延迟注册的配方。公开 `addDeferredRecipes` 回调执行时尚未建立最终管理器,也未应用全部隐藏规则,因此客户端可选的 `EmiMaterialProcessRecipesMixin` 在最终列表赋值时加入材料页。两个节点均注册此 Mixin;未安装 EMI 时由 `@Pseudo` 跳过。该接入依赖当前锁定的 EMI 1.1.24,升级时必须核对局部列表与注入次数。 + +只有 `supportsRecipeTree()` 为真且输入、输出均非空的条目可以成为加工关系。结构、战利品、世界生成展示、材料标签查询和总览页自身等声明不支持配方树的条目不作为加工关系导入。任一原料、催化剂或产物为空、数量无效或含不支持的 ingredient 类型时,整条配方移入相关信息,不能删掉该槽后将剩余部分当作完整配方。第三方错误声明自身完整性无法由通用接口自动识别;来源约束与容器返还仍通过原配方查询查看。 + +GT 的 `MachineEmiRecipe` 只决定原生行是否进入视图;端口继续使用原生配方的材料单位、精确状态、概率、特殊工艺与回收归属,不重复遍历全局机器表添加另一份。活动世界生成使用已发布事实单独保留,不从 EMI 信息页的检索槽推断来源。 + +其他配方保留每槽原生数量、输出边际概率、催化剂及完整物品 NBT/流体数据组件。候选原料作为一个 selector;只有所有候选均属于同一材料时才将它归入该材料,跨材料候选保持 `unknown`。候选集不展开为多个共同输入,也不与某个代表物品建立确认关系;代表图标最多十六个。缺少可靠工作站时保留问号。覆盖说明列出未作为加工关系导入的条目数,不声称支持未注册到 EMI 的加工方式。 + +信息页、不完整配方及不支持 ingredient 的条目,按现有物品成分和流体材料绑定关联到材料;复合物品可关联其中各个材料,不能据此推断生产或回收关系。相关条目放在来源区最下方的独立卡片,点击直接打开对应原始 EMI 页面;它们不加入 `Step`、`Connection` 或加工预算。没有加工步骤但存在相关信息的材料仍注册一张可检索的信息页。卡片随画布一起缩放、平移和裁剪,完整标题与参考性质放在 tooltip 中。关联索引与加工端口分开,索引仍只收录页面所属材料。 + +每次 EMI 重建均替换客户端视图及导航代次;旧页、断线后的页和旧发布的回调失效。JEI 未使用此 EMI 数据源,仍受 GT 原生快照的覆盖范围限制。 + ## 构造契约 - `DataKey` 在这里是调用方签发的快照内引用,不是新的材料身份或存档 ID。`Port.resource` 必须区分材料、形态、相态和原生状态;不同 tag/unit 选择器的原生引用保持独立。`Port.identity` 另作展示共享键:完整原生状态或规范选择器描述不包含查询代号及配方专属 selector 后缀;有原生图标时按实际显示代表的完整物品/流体状态识别相关展示实例;多候选 selector 可以与该代表同步高亮,并在总览共享一个资源节点,但原始候选集、消耗量和 guard 仍属于各原生步骤,不声称 selector 与具体物品可互换。不同 NBT/数据组件状态不得仅因图标相同而合并。已有 `MaterialKey`、`FormKey` 与原生匹配引用由后续适配器解析到该引用,不重新建立材料目录。 diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index 685c952c8..d85dbc1d2 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -40,6 +40,8 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe 材料领域的 `MaterialBaselineTests` 验证存储块的成分与两类准入、72U 附魔金苹果的规划和实际回收输出、复合钻头、耐久缩放、容器与有形状铸模、压模机模具、固体/流体分解及 test-source 材料 SPI。`material_baseline_reload` 为仅含一个测试的独立批次,等待两次真实资源重载;拥有规则数和固定样例必须稳定。原始投影写入根目录 `work/material-system-refactor/runtime//<运行目录>/`。已知错误行为明确标为观察,不能当作正确性依据;字段、复现与未覆盖范围见[材料基线报告](../../../integration/material-baseline.md)。 +`MaterialProcessSnapshotTests` 的 viewer 用例验证选中的原生机器行去重、未选行排除、工作台数量与工作站、活动世界生成保留,以及单槽候选、跨材料候选、完整原生状态和输出概率;还确认信息卡片位于来源下方、信息页单独存在时仍保留来源区、页面检索限于本材料且不生成加工节点或边。它们不启动 EMI,不能代替最终配方列表 Mixin、信息页过滤及第三方集成的客户端验收。 + `decompositionRespectsFormsAndExactFluidIdentities` 通过测试 SPI 声明 dust-only、blockDust-only、liquid-only 和 gas-only 分解,检查形态限制、流体输入不会错误抑制允许的固体兜底、本体完整 ID、附属完整 ID/旧裸路径、外部原版流体 ID、未知及非法 ID,以及附属流体输出的身份和数量。 针对性回归用数据表维护,不为每个 issue 新建测试类、namespace 或结构模板。GameTest 表是运行时权威,只保留 R 级运行时行;静态源检查由 core 的 `crafting-issue-static-cases.tsv` 维护。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 29e8c9c47..93839d042 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -20,7 +20,9 @@ ### 矿物处理展示页 -接口与测试输入契约见[展示接入](../../material-process-display.md)。生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用同一图和面板;没有成功快照时才显示未接入说明。 +接口与测试输入契约见[展示接入](../../material-process-display.md)。生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用展示模型和面板;EMI 从最终可见配方构造视图,JEI 使用 GT 原生快照。 + +EMI 数据源还需核对:工作台压块/拆块、熔炉和已安装第三方机器均进入材料页,GT 机器不重复;材料标签查询、结构与其他信息页不产生加工边;`supportsRecipeTree=false`、缺少输入/输出及不支持 ingredient 类型的条目仅保留为相关信息;来源区底部的信息卡片应直接打开对应原页面,只有相关信息的材料也能查询;全屏和嵌入视图下均核对点击、tooltip、平移缩放与裁剪。任一不支持槽不能静默消失。tag 的同材料候选保持一个 selector,跨材料候选不归到任一单一材料。隐藏、延迟注册、资源重载与重新入服后页面跟随当前配方,旧导航失效。未安装 EMI 时确认客户端及专用服务端不加载 EMI 类型;JEI 单独核对其原生快照覆盖范围。 1. 在 JEI/EMI 中打开真实材料的“矿物处理”。页面应直接显示同一张画布上有内容的来源/内部转换/回收/去向区域、区标题与相邻区域分割线,空区域不留占位;世界生成和泉进入来源区;无切换或分页。连续链水平向右,替代路线和分叉就近分行;未分类步骤、无外部入口环及自环不能消失。不同 GUI 缩放下右侧、底部裁剪正确。 2. 切割机三种润滑剂相同主物品/机器图标/首产物时只显示一条路线,次要输出不同也应共用机器、保留各分支,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。EMI 物品和机器使用原生槽位,确认自定义来源/用途绑定、点击释放、R/U、收藏及拖动物品均与普通 EMI 槽位一致,不精确锁定原配方;JEI 沿用普通来源/用途 focus;EMI 使用原生 tooltip,JEI 常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。非 1 件产量、U/mB 和非必然概率在图标上可见,精度保留至原生百分比;确定的 1 件产出不加数量/概率角标,未知概率显示 `?%`。共享资源采用生产端口的量,多个变体的不同量显示多值/省略号并可悬停查看;时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java index 1c9d810af..65cbcb735 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java @@ -144,6 +144,30 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { outline(graphics, frame.left(), frame.top(), frame.right(), frame.bottom(), 0xffe4e4e4); } drawEdges(graphics); + if (!overview.information().isEmpty()) { + var first = overview.information().get(0); + var hoveredInformation = informationHit(mouseX, mouseY); + text( + graphics, + Component.translatable("gt6ce.jei.material_process.information"), + first.left(), + first.top() - 12, + 152, + MUTED); + for (var card : overview.information()) { + if (card.right() < worldX(0) + || card.left() > worldX(width) + || card.bottom() < worldY(BODY_TOP) + || card.top() > worldY(footer())) continue; + boolean hover = card == hoveredInformation; + graphics.fill( + card.left(), card.top(), card.right(), card.bottom(), hover ? 0xffe0d6b5 : 0xffcfcbc0); + outline(graphics, card.left(), card.top(), card.right(), card.bottom(), 0xff9c9274); + if (!card.information().icon().isEmpty()) + graphics.renderItem(card.information().icon(), card.left() + 4, card.top() + 4); + text(graphics, card.information().name(), card.left() + 24, card.top() + 7, 122, TEXT); + } + } for (var grid : overview.grids()) { graphics.fill(grid.left(), grid.top(), grid.right(), grid.bottom(), 0xff777777); for (int y = grid.top(); y < grid.bottom(); y += 24) @@ -178,7 +202,7 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { graphics.flush(); graphics.disableScissor(); } - if (overview.nodes().isEmpty()) + if (overview.nodes().isEmpty() && overview.information().isEmpty()) graphics.drawWordWrap( Minecraft.getInstance().font, Component.translatable("gt6ce.jei.material_process.empty"), @@ -208,6 +232,14 @@ private Node hit(double mouseX, double mouseY) { return null; } + private MaterialProcessOverview.InformationCard informationHit(double mouseX, double mouseY) { + if (mouseX < 0 || mouseX >= width || mouseY < BODY_TOP || mouseY >= footer()) return null; + double x = worldX(mouseX), y = worldY(mouseY); + for (var card : overview.information()) + if (x >= card.left() && x < card.right() && y >= card.top() && y < card.bottom()) return card; + return null; + } + public List stacksAt(double mouseX, double mouseY) { Node node = hit(mouseX, mouseY); return node == null ? List.of() : stacks(node); @@ -249,6 +281,14 @@ public List tooltip(double mouseX, double mouseY) { lines.add(Component.translatable("gt6ce.jei.material_process.pan")); return List.copyOf(lines); } + var information = informationHit(mouseX, mouseY); + if (information != null) { + var lines = new ArrayList(); + lines.add(information.information().name()); + lines.addAll(information.information().details()); + lines.add(Component.translatable("gt6ce.jei.material_process.open_information")); + return List.copyOf(lines); + } Node node = hit(mouseX, mouseY); if (node == null) return List.of(); ItemStack icon = node.machine() @@ -299,6 +339,11 @@ public boolean click(double mouseX, double mouseY, int button) { public boolean clickControls(double mouseX, double mouseY, int button) { if (button != 0 && button != 1) return false; + var information = informationHit(mouseX, mouseY); + if (information != null) + return page.navigation().valid() + && page.navigation() + .openInformation(information.information().reference()); if (button == 0 && mouseY >= 0 && mouseY < 14) { if (mouseX >= width - 20 && mouseX < width) { MaterialProcessScreen.toggle(this); @@ -326,6 +371,7 @@ public boolean press(double mouseX, double mouseY, int button) { && mouseX < width && mouseY >= BODY_TOP && mouseY < footer() + && informationHit(mouseX, mouseY) == null && hit(mouseX, mouseY) == null; } @@ -360,6 +406,12 @@ private void zoomAt(double x, double y, double requested) { private void resetView() { zoom = 1; Node anchor = focused == null ? overview.anchor() : focused; + if (anchor == null && !overview.information().isEmpty()) { + var first = overview.information().get(0); + panX = width / 2.0 - (first.left() + first.right()) / 2.0; + panY = (footer() - BODY_TOP) / 2.0 - (first.top() + first.bottom()) / 2.0; + return; + } panX = width / 2.0 - (anchor == null ? overview.width() / 2.0 : anchor.x); panY = (footer() - BODY_TOP) / 2.0 - (anchor == null ? overview.height() / 2.0 : anchor.y); } diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java index 1713c5685..962ef13d6 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java @@ -259,6 +259,23 @@ public record SpecialProcess(DataKey id, Component name) { } } + /** Related viewer pages are navigation targets, with no processing ports or graph edges. */ + public record Information( + DataKey reference, Component name, ItemStack icon, List details, List index) { + public Information { + Objects.requireNonNull(reference); + name = name.copy(); + icon = icon.copy(); + details = copyText(details); + index = List.copyOf(index); + } + + @Override + public ItemStack icon() { + return icon.copy(); + } + } + /** * Bind callbacks to the same query session/generation as the page. Revalidate before resolving native references; * return false for expired or unsupported targets. Implementations run on the client thread. @@ -283,6 +300,10 @@ default boolean openStack(ItemStack stack, boolean uses) { return false; } + default boolean openInformation(DataKey reference) { + return false; + } + boolean openForm(DataKey resource, boolean uses); } @@ -295,13 +316,15 @@ public record Page( List notices, int number, int total, - Navigation navigation) { + Navigation navigation, + List information) { public Page { title = title.copy(); if (material == null) throw new IllegalArgumentException("Missing process page material"); steps = List.copyOf(steps); connections = List.copyOf(connections); notices = copyText(notices); + information = List.copyOf(information); Objects.requireNonNull(navigation); if (steps.size() > MAX_STEPS || connections.size() > MAX_CONNECTIONS @@ -310,10 +333,29 @@ public record Page( || notices.isEmpty()) throw new IllegalArgumentException("Invalid process display page"); } + public Page( + Component title, + String material, + List steps, + List connections, + List notices, + int number, + int total, + Navigation navigation) { + this(title, material, steps, connections, notices, number, total, navigation, List.of()); + } + + public Page withInformation(List information) { + return new Page(title, material, steps, connections, notices, number, total, navigation, information); + } + /** Foreign reagents and byproducts belong to the recipe, not to this material's viewer index. */ public List indexedPorts() { - return steps.stream() - .flatMap(step -> java.util.stream.Stream.concat(step.inputs().stream(), step.outputs().stream())) + return java.util.stream.Stream.concat( + steps.stream() + .flatMap(step -> java.util.stream.Stream.concat( + step.inputs().stream(), step.outputs().stream())), + information.stream().flatMap(entry -> entry.index().stream())) .filter(port -> port.material().equals(material) && port.hasIcons()) .toList(); } diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java index a05e3d08e..57c9116d2 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java @@ -227,7 +227,11 @@ private boolean contains(int lane) { public record Band(Section section, int left, int right) {} + public record InformationCard( + MaterialProcessDisplay.Information information, int left, int top, int right, int bottom) {} + private final List bands = new ArrayList<>(); + private final List information = new ArrayList<>(); private final List connections; private final Map next = new HashMap<>(), previous = new HashMap<>(); private final Set feedback = new HashSet<>(); @@ -245,7 +249,7 @@ private MaterialProcessOverview(Page page, boolean partition) { .sorted(Comparator.comparing( connection -> connection.source() + ":" + connection.target() + ":" + connection.resource())) .toList(); - if (partition && !page.steps().isEmpty()) { + if (partition && (!page.steps().isEmpty() || !page.information().isEmpty())) { partition(page); return; } @@ -335,6 +339,10 @@ public List bands() { return List.copyOf(bands); } + public List information() { + return List.copyOf(information); + } + public List grids() { return List.copyOf(grids); } @@ -436,7 +444,9 @@ private void partition(Page page) { .orElse(Section.INTERNAL) == section) .toList(); - if (steps.isEmpty()) continue; + boolean hasInformation = + section == Section.SOURCES && !page.information().isEmpty(); + if (steps.isEmpty() && !hasInformation) continue; Set references = new HashSet<>(); steps.forEach(step -> references.add(step.reference())); var local = new Page( @@ -479,7 +489,18 @@ private void partition(Page page) { graph.next.forEach((from, to) -> next.put(copies.get(from), copies.get(to))); if (graph.anchor != null && (anchor == null || section == Section.INTERNAL)) anchor = copies.get(graph.anchor); - int bandWidth = Math.max(72, graph.width); + int bandWidth = Math.max(hasInformation ? 176 : 72, graph.width); + if (hasInformation) { + int top = Math.max( + 48, + graph.nodes.stream().mapToInt(node -> node.y + 64).max().orElse(48)); + int columns = Math.max(1, Math.min(3, (bandWidth - 16) / 160)); + for (int index = 0; index < page.information().size(); index++) { + int left = offset + 8 + index % columns * 160; + int y = top + index / columns * 28; + information.add(new InformationCard(page.information().get(index), left, y, left + 152, y + 24)); + } + } bands.add(new Band(section, offset, offset + bandWidth)); offset += bandWidth; } @@ -489,6 +510,9 @@ private void partition(Page page) { if (!node.machine()) node.copy |= instances.get(node.port().identity()) > 1; applyConfirmation(); route(); + height = Math.max( + height, + information.stream().mapToInt(card -> card.bottom() + 12).max().orElse(0)); width = offset; } diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java index 0e6ca022b..b59ea46eb 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java @@ -55,6 +55,14 @@ public static List pages( return pages(snapshot, root, MATERIAL_PAGE_BUDGET, navigation, RecipeViewerIcons.categories()); } + public static MaterialProcessDisplay.Page informationPage(String material, + List information, MaterialProcessDisplay.Navigation navigation) { + return new MaterialProcessDisplay.Page( + Component.translatable("gt6ce.jei.material_process.material_title", materialName(material)), material, + List.of(), List.of(), List.of(Component.translatable("gt6ce.jei.material_process.information_hint")), + 1, 1, navigation, information); + } + private static List pages( MaterialProcessSnapshot snapshot, DataKey root, @@ -86,9 +94,9 @@ private static MaterialProcessDisplay.Step step(MaterialProcessSnapshot snapshot snapshot.recipe(step.reference()) .map(recipe -> workstations.getOrDefault(recipe.map(), new ItemStack(net.minecraft.world.item.Items.ANVIL))) .orElseGet(() -> snapshot.worldgen(step.reference()).isPresent() - ? new ItemStack(net.minecraft.world.item.Items.IRON_PICKAXE) : ItemStack.EMPTY), - step.inputs().stream().map(port -> port(port, snapshot.recipe(step.reference()).orElse(null))).toList(), - step.outputs().stream().map(port -> port(port, snapshot.recipe(step.reference()).orElse(null))).toList(), + ? new ItemStack(net.minecraft.world.item.Items.IRON_PICKAXE) : snapshot.viewerMachine(step.reference())), + step.inputs().stream().map(port -> port(snapshot, port, snapshot.recipe(step.reference()).orElse(null))).toList(), + step.outputs().stream().map(port -> port(snapshot, port, snapshot.recipe(step.reference()).orElse(null))).toList(), step.details().stream().map(MaterialProcessProjection::literal).toList(), specialProcess, step.resolved(), @@ -109,8 +117,9 @@ private static Optional specia return catalog.specialProcesses().find(id); } - private static MaterialProcessDisplay.Port port(Port port, MaterialProcessSnapshot.NativeRecipe nativeRecipe) { - List icons = nativeIcons(port.resource(), nativeRecipe); + private static MaterialProcessDisplay.Port port(MaterialProcessSnapshot snapshot, Port port, MaterialProcessSnapshot.NativeRecipe nativeRecipe) { + List icons = snapshot.viewerIcons(port.resource().key()); + if (icons.isEmpty()) icons = nativeIcons(port.resource(), nativeRecipe); String identity = port.resource().state(); if (!icons.isEmpty()) { ItemStack representative = icons.get(0); @@ -343,6 +352,10 @@ private static Component notice(Notice notice) { Component.translatable("gt6ce.jei.material_process.coverage.final_recipes"); case "coverage_active_worldgen" -> Component.translatable("gt6ce.jei.material_process.coverage.active_worldgen"); + case "coverage_viewer_recipes" -> + Component.translatable("gt6ce.jei.material_process.coverage.viewer_recipes"); + case "partial_viewer_recipes" -> + Component.translatable("gt6ce.jei.material_process.coverage.viewer_exclusions", notice.omitted()); case "partial_dynamic_selectors" -> Component.translatable("gt6ce.jei.material_process.coverage.dynamic_selectors"); case "partial_unknown_roles" -> diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index 7a6588cab..695c66a03 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -19,6 +19,7 @@ @EmiEntrypoint public final class GregTechEMIPlugin implements EmiPlugin { private static int overlayGeneration; + private static MaterialProcessSnapshot processSnapshot; @Override public void initialize(dev.emi.emi.api.EmiInitRegistry registry) { @@ -28,6 +29,7 @@ public void initialize(dev.emi.emi.api.EmiInitRegistry registry) { /** The client overlay calls this before EMI re-registers, so this pass reads the live maps. */ public static void overlayChanged() { overlayGeneration++; + processSnapshot = null; } public static int overlayGeneration() { @@ -36,11 +38,8 @@ public static int overlayGeneration() { @Override public void register(EmiRegistry registry) { - var processSnapshot = MaterialProcessSnapshot.Store.current(); - var processNavigation = new ProcessNavigation(processSnapshot); - MaterialProcessEmiRecipe.register( - registry, - gregtech.compat.common.MaterialProcessProjection.initialPages(processSnapshot, processNavigation)); + processSnapshot = null; + registry.addCategory(MaterialProcessEmiRecipe.category()); gregtech.client.gui.RecipeViewerNavigation.registerEmi(map -> { var id = ResourceLocation.fromNamespaceAndPath("gt6ce", map.mNameInternal.toLowerCase(Locale.ROOT)); var manager = dev.emi.emi.api.EmiApi.getRecipeManager(); @@ -174,16 +173,56 @@ private static boolean repairedGtTool(EmiRecipe recipe) { return false; } + /** Called after EMI has registered deferred rows and applied every recipe filter. */ + public static java.util.List addMaterialProcesses( + java.util.List recipes, + java.util.Map> workstations) { + var source = MaterialProcessSnapshot.Store.current(); + var captured = MaterialProcessEmiRecipes.capture(source, recipes, workstations); + var snapshot = captured.snapshot(); + processSnapshot = snapshot; + var navigation = new ProcessNavigation(snapshot, source, captured.information(), captured.links()); + var result = new java.util.ArrayList<>(recipes); + var materials = new java.util.HashSet(); + for (var page : gregtech.compat.common.MaterialProcessProjection.initialPages(snapshot, navigation)) + if (!page.material().isEmpty()) { + result.add(new MaterialProcessEmiRecipe(page.withInformation( + captured.information().getOrDefault(page.material(), java.util.List.of())))); + materials.add(page.material()); + } + captured.information().forEach((material, entries) -> { + if (!materials.contains(material)) + result.add( + new MaterialProcessEmiRecipe(gregtech.compat.common.MaterialProcessProjection.informationPage( + material, entries, navigation))); + }); + return java.util.List.copyOf(result); + } + private static final class ProcessNavigation implements gregtech.compat.common.MaterialProcessDisplay.Navigation { private final MaterialProcessSnapshot snapshot; + private final MaterialProcessSnapshot source; + private final java.util.Map> + information; + private final java.util.Map informationLinks; - private ProcessNavigation(MaterialProcessSnapshot snapshot) { + private ProcessNavigation( + MaterialProcessSnapshot snapshot, + MaterialProcessSnapshot source, + java.util.Map> + information, + java.util.Map informationLinks) { this.snapshot = snapshot; + this.source = source; + this.information = information; + this.informationLinks = informationLinks; } @Override public boolean valid() { - return MaterialProcessSnapshot.Store.current(snapshot); + return processSnapshot == snapshot + && MaterialProcessSnapshot.Store.current(source) + && net.minecraft.client.Minecraft.getInstance().level != null; } @Override @@ -198,10 +237,23 @@ public boolean openStack(ItemStack stack, boolean uses) { @Override public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { - if (!MaterialProcessSnapshot.Store.current(snapshot)) return false; + if (!valid()) return false; var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, resource, this); if (pages.isEmpty()) return false; - dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe(pages.get(0))); + var page = pages.get(0); + dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe( + page.withInformation(information.getOrDefault(page.material(), java.util.List.of())))); + return true; + } + + @Override + public boolean openInformation(gregtech.api.addon.material.DataKey reference) { + if (!valid()) return false; + var recipe = informationLinks.get(reference); + if (recipe == null) return false; + if (net.minecraft.client.Minecraft.getInstance().screen + instanceof gregtech.client.MaterialProcessScreen screen) screen.onClose(); + dev.emi.emi.api.EmiApi.displayRecipe(recipe); return true; } } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MachineEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MachineEmiRecipe.java index 70486eaf5..9b09f0f0a 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/MachineEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/MachineEmiRecipe.java @@ -87,6 +87,8 @@ private static EmiStack displayFluid(net.minecraftforge.fluids.FluidStack stack) @Override public List getInputs() { return inputs; } @Override public List getCatalysts() { return catalysts; } @Override public List getOutputs() { return outputs; } + RecipeMap recipeMap() { return map; } + Recipe nativeRecipe() { return recipe; } @Override public boolean supportsRecipeTree() { return !recipe.mFakeRecipe; } @Override public int getDisplayWidth() { return new RecipeGuiLayout(map,recipe).width(); } @Override public int getDisplayHeight() { return new RecipeGuiLayout(map,recipe).height(); } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java new file mode 100644 index 000000000..54dc977a9 --- /dev/null +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java @@ -0,0 +1,188 @@ +package gregtech.compat.emi; + +import dev.emi.emi.api.recipe.EmiRecipe; +import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.stack.EmiIngredient; +import dev.emi.emi.api.stack.EmiStack; +import gregtech.api.addon.material.DataKey; +import gregtech.compat.common.MaterialProcessDisplay; +import gregtech.content.registry.GTFluids; +import gregtech.content.recipe.MaterialProcessSnapshot; +import gregtech.engine.fluid.FluidVisualPolicy; +import gregtech.engine.material.ItemMaterialRegistry; +import gregtech.engine.material.MaterialProcessGraph.Port; +import gregtech.engine.material.MaterialProcessGraph.Role; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.OptionalInt; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.material.Fluid; +//? if >=1.21.1 { +/*import net.neoforged.neoforge.fluids.FluidStack; +*///?} else { +import net.minecraftforge.fluids.FluidStack; +//?} + +/** Processing rows and related information share a source, but never share graph semantics. */ +final class MaterialProcessEmiRecipes { + private MaterialProcessEmiRecipes() {} + + record Captured(MaterialProcessSnapshot snapshot, Map> information, + Map links) {} + + static Captured capture(MaterialProcessSnapshot source, List recipes, + Map> workstations) { + var builder = source.viewerBuilder(); + var information = new LinkedHashMap>(); + var links = new LinkedHashMap(); + var seen = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap()); + for (int index = 0; index < recipes.size(); index++) { + EmiRecipe recipe = recipes.get(index); + if (recipe instanceof MaterialProcessEmiRecipe || !seen.add(recipe)) continue; + // EMI's tree contract describes a complete transformation; lookup slots alone do not. + if (!recipe.supportsRecipeTree() || recipe.getInputs().isEmpty() || recipe.getOutputs().isEmpty()) { + builder.omitted(); + information(source, recipe, index, information, links); + continue; + } + if (recipe instanceof MachineEmiRecipe machine) { + builder.machine(machine.recipeMap(), machine.nativeRecipe()); + continue; + } + var inputs = ports(builder, recipe.getInputs(), Role.CONSUMED); + var catalysts = ports(builder, recipe.getCatalysts(), Role.CATALYST); + var outputs = ports(builder, recipe.getOutputs(), Role.UNKNOWN); + // Dropping an unsupported slot would turn a partial recipe into an invented route. + if (inputs == null || catalysts == null || outputs == null) { + builder.omitted(); + information(source, recipe, index, information, links); + continue; + } + inputs.addAll(catalysts); + var category = recipe.getCategory(); + var machine = workstations.getOrDefault(category, List.of()).stream() + .flatMap(ingredient -> ingredient.getEmiStacks().stream()) + .map(EmiStack::getItemStack).filter(stack -> !stack.isEmpty()) + .findFirst().orElse(ItemStack.EMPTY); + var reference = new DataKey("gt6ce", "process/emi/" + index + "/" + + Long.toUnsignedString(source.snapshot().publication().revision(), 36) + "/" + + Long.toUnsignedString(source.snapshot().sessionGeneration(), 36)); + builder.recipe(reference, category.getName().getString(), machine, inputs, outputs, + List.of("EMI category: " + category.getId(), "EMI recipe: " + recipe.getId(), + "matching constraints and remainders: see original recipe")); + } + information.replaceAll((material, entries) -> List.copyOf(entries)); + return new Captured(builder.build(), Map.copyOf(information), Map.copyOf(links)); + } + + private static void information(MaterialProcessSnapshot source, EmiRecipe recipe, int index, + Map> information, Map links) { + var inputs = informationIcons(java.util.stream.Stream.concat(recipe.getInputs().stream(), recipe.getCatalysts().stream()).toList()); + var outputs = informationIcons(recipe.getOutputs()); + var materials = new java.util.LinkedHashSet<>(inputs.keySet()); + materials.addAll(outputs.keySet()); + if (materials.isEmpty()) return; + var reference = new DataKey("gt6ce", "process/emi_information/" + index + "/" + + Long.toUnsignedString(source.snapshot().publication().revision(), 36) + "/" + + Long.toUnsignedString(source.snapshot().sessionGeneration(), 36)); + ItemStack icon = recipe.getOutputs().stream().filter(stack -> stack != null).map(EmiStack::getItemStack) + .filter(stack -> !stack.isEmpty()).findFirst().orElse(new ItemStack(Items.BOOK)); + Component name = recipe.getCategory().getName(); + int materialIndex = 0; + for (String material : materials) { + var ports = new ArrayList(); + for (boolean output : List.of(false, true)) { + var icons = (output ? outputs : inputs).getOrDefault(material, Map.of()).values().stream().toList(); + if (icons.isEmpty()) continue; + var key = new DataKey(reference.namespace(), reference.path() + "/index/" + materialIndex + "/" + output); + ports.add(new MaterialProcessDisplay.Port(key, material, icons.get(0).getHoverName(), icons, + output ? MaterialProcessDisplay.Role.UNKNOWN : MaterialProcessDisplay.Role.PRESENCE, + false, Component.empty(), Component.empty(), OptionalInt.empty(), List.of())); + } + var entry = new MaterialProcessDisplay.Information(reference, name, icon, + List.of(icon.getHoverName(), Component.translatable("gt6ce.jei.material_process.information_hint")), ports); + information.computeIfAbsent(material, ignored -> new ArrayList<>()).add(entry); + materialIndex++; + } + links.put(reference, recipe); + } + + private static Map> informationIcons(List ingredients) { + var result = new LinkedHashMap>(); + for (EmiIngredient ingredient : ingredients) { + if (ingredient == null) continue; + for (EmiStack stack : ingredient.getEmiStacks()) { + if (stack == null || stack.isEmpty()) continue; + if (stack.getKey() instanceof Item) { + var item = stack.getItemStack(); + ItemMaterialRegistry.get(item).ifPresent(composition -> composition.components().forEach(component -> + informationIcon(result, component.material().resolve().getName(), item))); + } else if (stack.getKey() instanceof Fluid fluid) { + var entry = GTFluids.entryForFluid(fluid); + if (entry == null) continue; + var material = FluidVisualPolicy.material(entry).resolve(); + if (!material.isValid()) continue; + var nativeFluid = fluid(stack, fluid); +//? if >=1.21.1 { + /*var lookup = gregtech.engine.fluid.FluidDisplayBinding.currentLookup(); + if (lookup != null) informationIcon(result, material.getName(), gregtech.engine.fluid.FluidDisplayBinding.display(lookup, nativeFluid)); +*///?} else { + informationIcon(result, material.getName(), gregtech.engine.fluid.FluidDisplayBinding.display(nativeFluid)); +//?} + } + } + } + return result; + } + + private static void informationIcon(Map> icons, String material, ItemStack stack) { + if (stack.isEmpty()) return; + var values = icons.computeIfAbsent(material, ignored -> new LinkedHashMap<>()); + if (values.size() < MaterialProcessDisplay.MAX_ICONS) + values.putIfAbsent(MaterialProcessSnapshot.itemDisplayState(stack), stack.copyWithCount(1)); + } + + private static List ports(MaterialProcessSnapshot.ViewerBuilder builder, + List ingredients, Role role) { + var ports = new ArrayList(); + for (EmiIngredient ingredient : ingredients) { + if (ingredient == null || ingredient.isEmpty() || ingredient.getAmount() <= 0) return null; + var candidates = new ArrayList(); + for (EmiStack stack : ingredient.getEmiStacks()) { + if (stack == null || stack.isEmpty()) return null; + if (role == Role.UNKNOWN && (!Float.isFinite(stack.getChance()) || stack.getChance() <= 0 || stack.getChance() > 1)) + return null; + long amount = ingredient.getAmount(); + var chance = role == Role.UNKNOWN ? chance(stack.getChance()) : OptionalInt.empty(); + if (stack.getKey() instanceof Item) { + var item = stack.getItemStack(); + if (item.isEmpty()) return null; + candidates.add(builder.item(item, role, amount, chance)); + } else if (stack.getKey() instanceof Fluid fluid) { + candidates.add(builder.fluid(fluid(stack, fluid), role, amount, chance)); + } else return null; + } + if (candidates.isEmpty()) return null; + ports.add(builder.alternatives(candidates)); + } + return ports; + } + + private static FluidStack fluid(EmiStack stack, Fluid fluid) { +//? if >=1.21.1 { + /*return new FluidStack(fluid.builtInRegistryHolder(), 1, stack.getComponentChanges()); +*///?} else { + return new FluidStack(fluid, 1, stack.getNbt()); +//?} + } + + private static OptionalInt chance(float chance) { + if (!Float.isFinite(chance) || chance <= 0 || chance > 1) return OptionalInt.empty(); + return OptionalInt.of(Math.max(1, Math.round(chance * 10_000))); + } +} diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java index 411a59ddf..f466a4ba2 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java @@ -103,24 +103,43 @@ public record Root(String material, String form, DataKey resource) { private record Bucket(List steps, Map roots) {} private final MaterialProcessGraph.Snapshot snapshot; + private final long resourceGeneration; + private final Map steps; private final Map resources; private final MaterialProcessGraph graph; private final List roots; private final Map nativeRecipes; private final Map worldgen; + private final Map> viewerIcons; + private final Map viewerMachines; private MaterialProcessSnapshot( MaterialProcessGraph.Snapshot snapshot, + long resourceGeneration, Map buckets, List roots, Map nativeRecipes, Map worldgen) { + this(snapshot, resourceGeneration, buckets, roots, nativeRecipes, worldgen, Map.of(), Map.of(), COVERAGE); + } + + private MaterialProcessSnapshot( + MaterialProcessGraph.Snapshot snapshot, + long resourceGeneration, + Map buckets, + List roots, + Map nativeRecipes, + Map worldgen, + Map> viewerIcons, + Map viewerMachines, + List coverage) { this.snapshot = snapshot; + this.resourceGeneration = resourceGeneration; var resources = new LinkedHashMap(); var steps = new LinkedHashMap(); buckets.values().forEach(bucket -> bucket.steps.forEach(step -> steps.putIfAbsent(step.reference(), step))); var builder = MaterialProcessGraph.builder(snapshot); - COVERAGE.forEach(notice -> builder.notice(notice.code(), notice.omitted())); + coverage.forEach(notice -> builder.notice(notice.code(), notice.omitted())); for (Step step : steps.values()) { NativeRecipe nativeRecipe = nativeRecipes.get(step.reference()); builder.add(step, nativeRecipe != null && nativeRecipe.genericRecovery()); @@ -128,10 +147,34 @@ private MaterialProcessSnapshot( step.outputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); } this.resources = Map.copyOf(resources); + this.steps = Map.copyOf(steps); this.graph = builder.build(); this.roots = List.copyOf(roots); this.nativeRecipes = Map.copyOf(nativeRecipes); this.worldgen = Map.copyOf(worldgen); + var retainedIcons = new LinkedHashMap>(); + viewerIcons.forEach((key, value) -> { + if (resources.containsKey(key)) retainedIcons.put(key, value); + }); + this.viewerIcons = Map.copyOf(retainedIcons); + var retainedMachines = new LinkedHashMap(); + viewerMachines.forEach((key, value) -> { + if (steps.containsKey(key)) retainedMachines.put(key, value); + }); + this.viewerMachines = Map.copyOf(retainedMachines); + } + + public List viewerIcons(DataKey resource) { + return viewerIcons.getOrDefault(resource, List.of()).stream().map(ItemStack::copy).toList(); + } + + public ItemStack viewerMachine(DataKey step) { + return viewerMachines.getOrDefault(step, ItemStack.EMPTY).copy(); + } + + /** Starts a client-local view whose processing rows come exclusively from the viewer. */ + public ViewerBuilder viewerBuilder() { + return new ViewerBuilder(this); } public MaterialProcessGraph.Snapshot snapshot() { @@ -174,6 +217,7 @@ private static MaterialProcessSnapshot empty() { var stamp = MaterialPublication.current(); return new MaterialProcessSnapshot( new MaterialProcessGraph.Snapshot(stamp, 1, 0, 0, 0), + 0, Map.of(), List.of(), Map.of(), @@ -231,7 +275,7 @@ static MaterialProcessSnapshot build( .sorted(Comparator.comparing(Root::material, String.CASE_INSENSITIVE_ORDER)) .toList(); return new MaterialProcessSnapshot( - graphSnapshot, buckets, roots, nativeRecipes, nativeWorldgen); + graphSnapshot, resourceGeneration, buckets, roots, nativeRecipes, nativeWorldgen); } private static BuiltStep recipeStep( @@ -691,6 +735,148 @@ private Bucket freeze() { } } + /** Native stacks and semantic rows for one viewer reload; never published as server recipes. */ + public static final class ViewerBuilder { + private final MaterialProcessSnapshot source; + private final Map buckets = new LinkedHashMap<>(); + private final Map recipes = new LinkedHashMap<>(); + private final Map> icons = new LinkedHashMap<>(); + private final Map machines = new LinkedHashMap<>(); + private final Map> selected = new java.util.IdentityHashMap<>(); + private final Map> nativeReferences = new java.util.IdentityHashMap<>(); + private int omitted; + + private ViewerBuilder(MaterialProcessSnapshot source) { + this.source = source; + source.nativeRecipes.forEach((reference, row) -> nativeReferences + .computeIfAbsent(row.map(), ignored -> new java.util.IdentityHashMap<>()).put(row.recipe(), reference)); + source.steps.values().stream().filter(step -> source.worldgen.containsKey(step.reference())) + .sorted(Comparator.comparing(step -> step.reference().toString())) + .forEach(this::add); + } + + public void omitted() { + omitted++; + } + + /** Reuses GT matching, unit quantities and recovery ownership, once per visible native row. */ + public void machine(RecipeMap map, Recipe recipe) { + if (!selected.computeIfAbsent(map, ignored -> java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>())) + .add(recipe)) return; + DataKey reference = nativeReferences.getOrDefault(map, Map.of()).get(recipe); + if (reference != null) { + add(source.steps.get(reference)); + recipes.put(reference, source.nativeRecipes.get(reference)); + return; + } + int index = map.mRecipeList.size() + recipes.size(); + BuiltStep built = recipeStep(map, recipe, index, + source.snapshot.publication().revision(), source.snapshot.sessionGeneration()); + if (built == null) return; + built = scoped(built, source.snapshot.publication().revision(), source.resourceGeneration); + addStep(buckets, built.step, built.materials); + recipes.put(built.step.reference(), new NativeRecipe(map, recipe, index)); + } + + public Port item(ItemStack stack, Role role, long amount, OptionalInt chance) { + String state = itemDisplayState(stack); + var form = MaterialEquivalence.form(stack); + GTMaterial material = form == null ? material(stack) : form.material().resolve(); + String prefix = form == null ? "item" : form.prefix().getName(); + if (stack.getItem() instanceof BlockItem block && block.getBlock() instanceof OreBlock ore) { + material = ore.material().resolve(); + prefix = ore.isSmall() ? "oreSmall" : "oreVanillastone"; + } + Resource resource = material == null + ? new Resource(nativeResourceKey("item", state), "unknown", "item", "solid", state) + : itemResource(material, prefix, state); + return port(resource, role, new Amount(amount, AmountUnit.ITEM), chance, stack.copyWithCount(1)); + } + + public Port fluid(FluidStack stack, Role role, long amount, OptionalInt chance) { + var entry = GTFluids.entryForFluid(stack.getFluid()); + GTMaterial material = entry == null ? null : FluidVisualPolicy.material(entry).resolve(); + if (material != null && !material.isValid()) material = null; + String state = fluidDisplayState(stack); + String phase = entry != null && entry.gas() ? "gas" : "liquid"; + var resource = new Resource( + material == null ? nativeResourceKey("fluid", state) : resourceKey("fluid", material, "fluid", phase, state), + material == null ? "unknown" : material.getName(), "fluid", phase, state); +//? if >=1.21.1 { + /*var lookup = gregtech.engine.fluid.FluidDisplayBinding.currentLookup(); + var icon = lookup == null ? ItemStack.EMPTY : gregtech.engine.fluid.FluidDisplayBinding.display(lookup, stack); +*///?} else { + var icon = gregtech.engine.fluid.FluidDisplayBinding.display(stack); +//?} + return port(resource, role, new Amount(amount, AmountUnit.MILLIBUCKET), chance, icon); + } + + private Port port(Resource resource, Role role, Amount amount, OptionalInt chance, ItemStack icon) { + var port = scoped(new Port(resource, role, amount, chance, false, List.of()), + source.snapshot.publication().revision(), source.resourceGeneration); + if (!icon.isEmpty()) icons.putIfAbsent(port.resource().key(), List.of(icon.copyWithCount(1))); + return port; + } + + /** Alternatives remain one selector, never a list of simultaneously consumed inputs. */ + public Port alternatives(List candidates) { + if (candidates.isEmpty()) throw new IllegalArgumentException("Empty viewer selector"); + Port first = candidates.get(0); + if (candidates.size() == 1) return first; + Resource representative = first.resource(); + boolean sameMaterial = candidates.stream().allMatch(port -> port.resource().material().equals(representative.material())); + boolean sameForm = candidates.stream().allMatch(port -> port.resource().form().equals(representative.form())); + boolean samePhase = candidates.stream().allMatch(port -> port.resource().phase().equals(representative.phase())); + String state = "selector:" + fingerprint(candidates.stream() + .map(port -> port.resource().state()).distinct().sorted().collect(java.util.stream.Collectors.joining("|"))); + Resource resource = new Resource(nativeResourceKey("selector", state), + sameMaterial ? representative.material() : "unknown", + sameForm ? representative.form() : "selector", samePhase ? representative.phase() : "unknown", state); + Amount amount = candidates.stream().allMatch(port -> port.amount().equals(first.amount())) + ? first.amount() : Amount.unknown(); + OptionalInt chance = !first.output() && candidates.stream().allMatch(port -> port.chance().equals(first.chance())) + ? first.chance() : OptionalInt.empty(); + var result = scoped(new Port(resource, first.role(), amount, chance, false, + List.of("viewer alternatives: " + candidates.size(), "matching constraints: see original recipe")), + source.snapshot.publication().revision(), source.resourceGeneration); + var representatives = new LinkedHashMap(); + for (Port candidate : candidates) + for (ItemStack icon : icons.getOrDefault(candidate.resource().key(), List.of())) { + if (representatives.size() >= 16) break; + representatives.putIfAbsent(itemDisplayState(icon), icon.copyWithCount(1)); + } + icons.put(result.resource().key(), List.copyOf(representatives.values())); + return result; + } + + public void recipe(DataKey reference, String name, ItemStack machine, + List inputs, List outputs, List details) { + boolean resolved = java.util.stream.Stream.concat(inputs.stream(), outputs.stream()) + .noneMatch(port -> port.resource().state().startsWith("selector:")); + add(new Step(reference, name, inputs, outputs, details, resolved)); + if (!machine.isEmpty()) machines.put(reference, machine.copyWithCount(1)); + } + + private void add(Step step) { + var materials = new LinkedHashSet(); + step.inputs().forEach(port -> addMaterial(materials, port)); + step.outputs().forEach(port -> addMaterial(materials, port)); + addStep(buckets, step, materials); + } + + public MaterialProcessSnapshot build() { + var frozen = new LinkedHashMap(); + buckets.forEach((material, bucket) -> frozen.put(material, bucket.freeze())); + var roots = frozen.entrySet().stream().map(entry -> bestRoot(entry.getKey(), entry.getValue().roots)) + .sorted(Comparator.comparing(Root::material, String.CASE_INSENSITIVE_ORDER)).toList(); + var coverage = new ArrayList<>(COVERAGE); + coverage.add(new Notice("coverage_viewer_recipes", 0)); + coverage.add(new Notice("partial_viewer_recipes", omitted)); + return new MaterialProcessSnapshot(source.snapshot, source.resourceGeneration, frozen, roots, recipes, + source.worldgen, icons, machines, coverage); + } + } + /** Bounded current/previous publication retained for in-flight viewer callbacks. */ public static final class Store { private static volatile MaterialProcessSnapshot current = EMPTY; diff --git a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java index 00b012611..289953367 100644 --- a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java +++ b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java @@ -3,9 +3,11 @@ import dev.emi.emi.api.recipe.EmiRecipe; import dev.emi.emi.api.recipe.EmiRecipeCategory; import dev.emi.emi.api.stack.EmiIngredient; +import gregtech.client.MaterialProcessScreen; import gregtech.compat.emi.MaterialProcessEmiRecipe; import java.util.List; import java.util.Map; +import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; @@ -25,8 +27,7 @@ public abstract class EmiMaterialProcessFocusMixin { Map> recipes, EmiIngredient ingredient, CallbackInfo callback) { // EMI opens lookups only from its recipe/tree screens or a container screen. if (recipes.values().stream().anyMatch(rows -> !rows.isEmpty()) - && net.minecraft.client.Minecraft.getInstance().screen - instanceof gregtech.client.MaterialProcessScreen screen) screen.onClose(); + && Minecraft.getInstance().screen instanceof MaterialProcessScreen screen) screen.onClose(); for (var recipe : recipes.getOrDefault(MaterialProcessEmiRecipe.category(), List.of())) if (recipe instanceof MaterialProcessEmiRecipe process) process.focus(ingredient); } diff --git a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessRecipesMixin.java b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessRecipesMixin.java new file mode 100644 index 000000000..5ca9ef221 --- /dev/null +++ b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessRecipesMixin.java @@ -0,0 +1,26 @@ +package gregtech.mixin; + +import dev.emi.emi.api.recipe.EmiRecipe; +import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.stack.EmiIngredient; +import gregtech.compat.emi.GregTechEMIPlugin; +import java.util.List; +import java.util.Map; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +/** EMI's deferred registration API runs before recipe filters and exposes no final row list. */ +@Pseudo +@Mixin(targets = "dev.emi.emi.registry.EmiRecipes", remap = false) +public abstract class EmiMaterialProcessRecipesMixin { + @Shadow + private static Map> workstations; + + @ModifyVariable(method = "bake", at = @At("STORE"), ordinal = 0, require = 1, allow = 1, remap = false) + private static List gregtech$includeMaterialProcesses(List filtered) { + return GregTechEMIPlugin.addMaterialProcesses(filtered, workstations); + } +} diff --git a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java index 34b235fe1..e18583f77 100644 --- a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java +++ b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java @@ -38,6 +38,111 @@ public final class MaterialProcessSnapshotTests { private MaterialProcessSnapshotTests() {} + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void relatedInformationStaysBelowSourcesWithoutProcessingEdges(GameTestHelper helper) { + var source = new gregtech.compat.common.MaterialProcessDisplay.Step( + new gregtech.api.addon.material.DataKey("test", "information_source"), + net.minecraft.network.chat.Component.literal("source"), new ItemStack(Items.FURNACE), + List.of(displayPort("source_input", "Other", Items.IRON_INGOT, false)), + List.of(displayPort("source_output", "Copper", Items.COPPER_INGOT, true)), + List.of(), java.util.Optional.empty(), true); + var reference = new gregtech.api.addon.material.DataKey("test", "information"); + var information = new gregtech.compat.common.MaterialProcessDisplay.Information(reference, + net.minecraft.network.chat.Component.literal("Reference"), new ItemStack(Items.BOOK), List.of(), + List.of(displayPort("information_copper", "Copper", Items.COPPER_BLOCK, true), + displayPort("information_iron", "Iron", Items.IRON_BLOCK, true))); + var page = layoutPage(List.of(source), List.of()).withInformation(List.of(information)); + var graph = new gregtech.compat.common.MaterialProcessOverview(page); + var card = graph.information().get(0); + helper.assertTrue(graph.nodes().size() == 3 && graph.edges().size() == 2 && page.connections().isEmpty(), + "related information does not add processing nodes or edges"); + helper.assertTrue(card.top() > graph.nodes().stream().mapToInt(node -> node.y + 12).max().orElseThrow() + && card.bottom() <= graph.height(), + "information is below the source routes and included in the canvas bounds"); + helper.assertTrue(page.indexedPorts().stream().anyMatch(port -> port.icons().get(0).is(Items.COPPER_BLOCK)) + && page.indexedPorts().stream().noneMatch(port -> port.material().equals("Iron")), + "information references are searchable only within the page material"); + var onlyInformation = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(), List.of()) + .withInformation(List.of(information))); + helper.assertTrue(onlyInformation.nodes().isEmpty() && onlyInformation.edges().isEmpty() + && onlyInformation.bands().get(0).section() == gregtech.compat.common.MaterialProcessDisplay.Section.SOURCES + && onlyInformation.information().size() == 1, + "materials with only reference pages still have an information area in sources"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void viewerRecipesSelectNativeRowsAndIncludeCrafting(GameTestHelper helper) { + var visible = row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, Items.COPPER_INGOT); + var hidden = row(new ItemStack[] {new ItemStack(Items.PAPER)}, Items.GOLD_INGOT); + var map = new RecipeMap(new ArrayList<>(List.of(visible, hidden)), + "gt.test.process.viewer", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, + false, false, false, false); + RecipeMap.unregister(map); + var ores = List.of(new Ore(Materials.Iron, "item:minecraft:iron_nugget", 0, 20, 1, 0, List.of())); + var facts = new MaterialWorldgenFacts.Snapshot(List.of( + new Fact("viewer_test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 1, ores))); + var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, facts, List.of(map)); + var builder = source.viewerBuilder(); + builder.machine(map, visible); + builder.machine(map, visible); + var reference = new gregtech.api.addon.material.DataKey("test", "crafting/iron_block"); + builder.recipe(reference, "Crafting", new ItemStack(Items.CRAFTING_TABLE), + List.of(builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 9, java.util.OptionalInt.empty())), + List.of(builder.item(new ItemStack(Items.IRON_BLOCK), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000))), List.of()); + var view = builder.build(); + var root = view.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); + var query = view.queryMaterial(root.resource(), new Budgets(0, 32, 32, 32)); + helper.assertTrue(query.steps().size() == 3 && query.steps().stream().filter(step -> view.recipe(step.reference()).isPresent()).count() == 1, + "the viewer owns machine admission, deduplicates native rows and retains real worldgen"); + helper.assertTrue(view.roots().stream().noneMatch(value -> value.material().equals("Gold")), + "a machine row absent from the viewer does not leak back from the global tables"); + var page = gregtech.compat.common.MaterialProcessProjection.pages(view, root.resource(), + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); + var crafting = page.steps().stream().filter(step -> step.reference().equals(reference)).findFirst().orElseThrow(); + helper.assertTrue(crafting.icon().is(Items.CRAFTING_TABLE) && crafting.inputs().get(0).quantity().getString().equals("9"), + "crafting routes retain their workstation and native input batch"); + helper.assertTrue(source.roots().stream().anyMatch(value -> value.material().equals("Gold")), + "a viewer projection never changes the published server snapshot"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void viewerAlternativesRemainOneStatefulSelector(GameTestHelper helper) { + var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); + var builder = source.viewerBuilder(); + var stateful = new ItemStack(Items.IRON_INGOT); + var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(stateful); + data.putString("viewer_test", "native_state"); + gregtech.content.data.UsbDataMedia.store(stateful, data); + var selector = builder.alternatives(List.of( + builder.item(stateful, Role.CONSUMED, 2, java.util.OptionalInt.empty()), + builder.item(new ItemStack(Items.IRON_NUGGET), Role.CONSUMED, 2, java.util.OptionalInt.empty()))); + var mixed = builder.alternatives(List.of( + builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()), + builder.item(new ItemStack(Items.COPPER_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()))); + helper.assertTrue(selector.resource().material().equals("Iron") && mixed.resource().material().equals("unknown"), + "one material may be attributed only when every alternative agrees"); + var reference = new gregtech.api.addon.material.DataKey("test", "external/selector"); + builder.recipe(reference, "External processing", new ItemStack(Items.FURNACE), List.of(selector), + List.of(builder.item(new ItemStack(Items.COPPER_INGOT), Role.UNKNOWN, 3, java.util.OptionalInt.of(2500))), List.of()); + var view = builder.build(); + var root = view.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); + var page = gregtech.compat.common.MaterialProcessProjection.pages(view, root.resource(), + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); + var step = page.steps().get(0); + helper.assertTrue(step.inputs().size() == 1 && step.inputs().get(0).icons().size() == 2 && !step.resolved(), + "alternatives stay a single unresolved selector rather than joint requirements"); + helper.assertTrue(gregtech.engine.stack.StackCompat.sameItem(step.inputs().get(0).icons().get(0), stateful) + && step.outputs().get(0).chance().orElseThrow() == 2500, + "external stacks keep their complete native state and output chance"); + view.viewerIcons(selector.resource().key()).get(0).setCount(12); + helper.assertTrue(view.viewerIcons(selector.resource().key()).get(0).getCount() == 1, + "native viewer representatives are copied on access"); + helper.succeed(); + } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) public static void presentationPreservesNativeItemState(GameTestHelper helper) { var input = new ItemStack(Items.IRON_INGOT); diff --git a/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json b/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json index 1063350dc..764932d5a 100644 --- a/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json +++ b/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json @@ -57,6 +57,7 @@ "ColoredBookLecternScreenMixin", "ColoredBookOpenPacketMixin", "EmiMaterialProcessFocusMixin", + "EmiMaterialProcessRecipesMixin", "EmiMaterialUsesMixin", "EmiStructureFocusMixin", "FluidAlphaConfigMixin", diff --git a/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json b/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json index a273b32e1..28599356f 100644 --- a/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json +++ b/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json @@ -56,6 +56,7 @@ "client": [ "BlockPaintColorMixin", "EmiMaterialProcessFocusMixin", + "EmiMaterialProcessRecipesMixin", "EmiMaterialUsesMixin", "EmiStructureFocusMixin", "FluidAlphaConfigMixin", From 8e09b0815ef60276d573dfc3648452e30e000f79 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Sun, 15 Nov 2026 23:12:24 +0800 Subject: [PATCH 09/17] optimize GUI --- .../api/addon/GregTechAddonsTest.java | 2 +- .../material/SpecialProcessValueTest.java | 1 + .../api/contracts/MaterialViewContracts.java | 2 + .../content/block/stone/OreHostFacts.java | 24 +- .../machine/OriginalMachineMaterialData.java | 1 - .../content/material/MaterialFactKeys.java | 18 +- .../catalog/MaterialFluidUnitFacts.java | 13 +- .../PurifiedCentrifugeMaterialFacts.java | 7 +- .../catalog/ReviewedOreMaterialFacts.java | 39 +-- .../catalog/ReviewedSourceMaterialFacts.java | 9 +- .../SourceOreCrushingMaterialFacts.java | 41 ++- .../catalog/SourceWashingMaterialFacts.java | 1 - .../content/recipe/FurnaceSmeltingRules.java | 1 - .../content/recipe/RecoveryFormCatalog.java | 200 +++++++++-- .../content/recipe/SourceLensRoles.java | 3 +- .../content/recipe/SpecialProcessData.java | 2 + .../recipe/SpecialProcessMaterialFacts.java | 137 ++++---- .../content/recipe/SpecialProcessMethods.java | 19 +- .../material/ItemCompositionResolution.java | 4 +- .../engine/material/MaterialProcessGraph.java | 158 +++++++-- .../material/ReversibleCraftingData.java | 1 - .../resources/assets/gt6ce/lang/en_us.json | 1 + .../resources/assets/gt6ce/lang/zh_cn.json | 1 + .../material/MaterialProcessGraphTest.java | 199 +++++++++++ docs/architecture/packages/engine.md | 2 +- docs/architecture/packages/runtime.md | 4 +- docs/development/material-process-display.md | 37 +- docs/development/material-process-layout.md | 14 +- .../development/validation/checks/gametest.md | 2 +- .../validation/checks/manual-ingame.md | 6 +- .../gregtech/client/MaterialProcessPanel.java | 13 +- .../compat/common/MaterialProcessDisplay.java | 248 ++++++++++--- .../common/MaterialProcessOverview.java | 130 ++++--- .../common/MaterialProcessProjection.java | 66 +++- .../compat/emi/GregTechEMIPlugin.java | 34 +- .../compat/emi/MaterialProcessEmiRecipe.java | 66 ++-- .../compat/emi/MaterialProcessEmiRecipes.java | 153 +++++--- .../material/PanelMaterialCompositions.java | 2 +- .../material/WoodMaterialCompositions.java | 15 +- .../recipe/MaterialProcessSnapshot.java | 112 ++++-- .../recipe/SourceCinnabarFollowonAdapter.java | 6 +- .../recipe/SourceOreFollowonAdapter.java | 1 + .../recipe/MaterialProcessSnapshotTests.java | 327 +++++++++++++++++- 43 files changed, 1639 insertions(+), 483 deletions(-) diff --git a/api/common/src/test/java/gregtech/api/addon/GregTechAddonsTest.java b/api/common/src/test/java/gregtech/api/addon/GregTechAddonsTest.java index f7872734a..647535233 100644 --- a/api/common/src/test/java/gregtech/api/addon/GregTechAddonsTest.java +++ b/api/common/src/test/java/gregtech/api/addon/GregTechAddonsTest.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.function.Consumer; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; class GregTechAddonsTest { private static final GregTechAddon.Context CONTEXT = new GregTechAddon.Context("forge", "1.20.1"); diff --git a/api/common/src/test/java/gregtech/api/addon/material/SpecialProcessValueTest.java b/api/common/src/test/java/gregtech/api/addon/material/SpecialProcessValueTest.java index fa76227b9..b016f0b3a 100644 --- a/api/common/src/test/java/gregtech/api/addon/material/SpecialProcessValueTest.java +++ b/api/common/src/test/java/gregtech/api/addon/material/SpecialProcessValueTest.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; final class SpecialProcessValueTest { diff --git a/api/common/src/test/java/gregtech/api/contracts/MaterialViewContracts.java b/api/common/src/test/java/gregtech/api/contracts/MaterialViewContracts.java index 5049cb645..f81da250a 100644 --- a/api/common/src/test/java/gregtech/api/contracts/MaterialViewContracts.java +++ b/api/common/src/test/java/gregtech/api/contracts/MaterialViewContracts.java @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: LGPL-3.0-or-later */ package gregtech.api.contracts; +import gregtech.api.addon.material.*; + import java.util.List; /** Only the delivered API JAR participates in this consumer. */ diff --git a/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java b/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java index faf7c1e01..05f026451 100644 --- a/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java +++ b/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java @@ -28,10 +28,26 @@ public boolean hasGangue() { private static final Map HOSTS = createHosts(); private static final Set BROKEN_SOURCE_PAIRS = Set.of( - "oreVanillastone", "oreNetherrack", "oreEndstone", "oreBlackgranite", "oreRedgranite", - "oreBasalt", "oreMarble", "oreLimestone", "oreVanillagranite", "oreDiorite", "oreAndesite", - "oreKomatiite", "oreGreenschist", "oreBlueschist", "oreKimberlite", "oreQuartzite", - "oreLightprismarine", "oreDarkprismarine", "oreSlate", "oreShale"); + "oreVanillastone", + "oreNetherrack", + "oreEndstone", + "oreBlackgranite", + "oreRedgranite", + "oreBasalt", + "oreMarble", + "oreLimestone", + "oreVanillagranite", + "oreDiorite", + "oreAndesite", + "oreKomatiite", + "oreGreenschist", + "oreBlueschist", + "oreKimberlite", + "oreQuartzite", + "oreLightprismarine", + "oreDarkprismarine", + "oreSlate", + "oreShale"); public static HostProfile hostProfile(String nativeHostId) { return nativeHostId == null ? null : HOSTS.get(nativeHostId); diff --git a/core/src/main/java/gregtech/content/machine/OriginalMachineMaterialData.java b/core/src/main/java/gregtech/content/machine/OriginalMachineMaterialData.java index 8a1b34daa..74b6488e8 100644 --- a/core/src/main/java/gregtech/content/machine/OriginalMachineMaterialData.java +++ b/core/src/main/java/gregtech/content/machine/OriginalMachineMaterialData.java @@ -9,7 +9,6 @@ import gregtech.content.data.ImportedMaterialData; import gregtech.engine.material.ItemComposition; import gregtech.engine.material.ReversibleCraftingData; - import java.util.*; /** Known source recipe components in exact CS.U units; unknown tag data is never replaced by an arbitrary ingredient. */ diff --git a/core/src/main/java/gregtech/content/material/MaterialFactKeys.java b/core/src/main/java/gregtech/content/material/MaterialFactKeys.java index b9ff9e63d..f886fd99d 100644 --- a/core/src/main/java/gregtech/content/material/MaterialFactKeys.java +++ b/core/src/main/java/gregtech/content/material/MaterialFactKeys.java @@ -32,20 +32,16 @@ public boolean matches(int materialId, String canonicalName) { } } - public static final MaterialProcessKey SOURCE_FURNACE = - single("source_furnace", Decision.class); - public static final MaterialProcessKey SOURCE_GRADED_GEM = - single("source_graded_gem", Decision.class); - public static final MaterialProcessKey SOURCE_ORE_INPUT = - single("source_ore_input", Decision.class); + public static final MaterialProcessKey SOURCE_FURNACE = single("source_furnace", Decision.class); + public static final MaterialProcessKey SOURCE_GRADED_GEM = single("source_graded_gem", Decision.class); + public static final MaterialProcessKey SOURCE_ORE_INPUT = single("source_ore_input", Decision.class); public static final MaterialProcessKey SOURCE_SIFTING_EXCLUSIONS = single("source_sifting_exclusions", PrefixExclusions.class); public static final MaterialProcessKey SOURCE_CRUSHED_EXCLUSIONS = single("source_crushed_exclusions", PrefixExclusions.class); public static final MaterialProcessKey SOURCE_ORE_SHREDDER = single("source_ore_shredder", OreShredderProfile.class); - public static final MaterialProcessKey SOURCE_MACERATION = - single("source_maceration", Decision.class); + public static final MaterialProcessKey SOURCE_MACERATION = single("source_maceration", Decision.class); public static final MaterialProcessKey SOURCE_WASHING = single("source_washing", SourceWashingMaterialFacts.Binding.class); public static final MaterialProcessKey MATERIAL_FLUID_UNIT = @@ -62,8 +58,7 @@ public boolean matches(int materialId, String canonicalName) { single("source_generated_fluid", GeneratedFluidRules.class); public static final MaterialProcessKey SOURCE_RECYCLING = single("source_recycling", SourceRecyclingMaterialFacts.Facts.class); - public static final MaterialProcessKey SOURCE_MOLTEN_FLUID = - single("source_molten_fluid", Boolean.class); + public static final MaterialProcessKey SOURCE_MOLTEN_FLUID = single("source_molten_fluid", Boolean.class); public static final MaterialProcessKey SOURCE_ORE_CRUSHING = single("source_ore_crushing", OreCrushingFact.class); public static final MaterialProcessKey SOURCE_PURIFIED_CENTRIFUGE_PHASE = @@ -176,7 +171,8 @@ public record PurifiedCentrifugeNoDefault(String phase, int meltingKelvin, int b public static Optional value(GTMaterial material, MaterialProcessKey key) { if (material == null || !material.isValid()) return Optional.empty(); - return MaterialInfoTool.currentProcess(new MaterialKey(material.resolve().getName()), key) + return MaterialInfoTool.currentProcess( + new MaterialKey(material.resolve().getName()), key) .map(rule -> rule.value()); } diff --git a/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java b/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java index 7ae659e84..d454d0164 100644 --- a/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java @@ -7,7 +7,6 @@ import gregtech.engine.material.MaterialDefinition; import gregtech.engine.material.MaterialInfoDefinition; import gregtech.engine.recipe.UnitConversion; - import java.util.LinkedHashMap; import java.util.List; import java.util.Set; @@ -77,14 +76,7 @@ public record Binding( new Binding("Helium3", 21, "gas", "GenGas_Helium3", "helium3", SOURCE_UNIT, 1000), new Binding("Honey", 9791, "liquid", "Honey", "honey", SOURCE_UNIT, 1000), new Binding("Honeydew", 9793, "liquid", "Honeydew", "honeydew", SOURCE_UNIT, 1000), - new Binding( - "HydrochloricAcid", - 9826, - "gas", - "GenGas_HydrochloricAcid", - "hydrochloricacid", - SOURCE_UNIT, - 1000), + new Binding("HydrochloricAcid", 9826, "gas", "GenGas_HydrochloricAcid", "hydrochloricacid", SOURCE_UNIT, 1000), new Binding("HydrogenFluoride", 9829, "gas", "GenGas_HydrogenFluoride", "hydrogenfluoride", SOURCE_UNIT, 1000), new Binding("Hydrogen", 10, "gas", "Hydrogen", "hydrogen", SOURCE_UNIT, 1000), new Binding("Ice", 9802, "liquid", "Ice", "ice", SOURCE_UNIT, 1000), @@ -162,7 +154,8 @@ public static Binding binding(GTMaterial material, String phase) { public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaration declaration) { var values = new java.util.ArrayList(); for (Binding binding : BINDINGS) { - if (binding.materialId() != declaration.id() || !binding.materialName().equals(declaration.name())) continue; + if (binding.materialId() != declaration.id() + || !binding.materialName().equals(declaration.name())) continue; values.add(new MaterialFactKeys.MaterialFluidUnit( binding.phase(), binding.fluidField(), diff --git a/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java index 962c67aa1..f442cfe7d 100644 --- a/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java @@ -12,6 +12,7 @@ public final class PurifiedCentrifugeMaterialFacts { private PurifiedCentrifugeMaterialFacts() {} private record Phase(int id, String name, MaterialFactKeys.PurifiedCentrifugePhase value) {} + private record None(int id, String name, MaterialFactKeys.PurifiedCentrifugeNoDefault value) {} private static final List PHASES = List.of( @@ -26,7 +27,8 @@ private record None(int id, String name, MaterialFactKeys.PurifiedCentrifugeNoDe new None(1120, "Copernicium", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 150, 357)), new None(1180, "Oganesson", new MaterialFactKeys.PurifiedCentrifugeNoDefault("gas", 258, 263)), new None(9110, "Celestine", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 275, 455)), - new None(9199, "DuraniumHexafluoride", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 216, 428)), + new None( + 9199, "DuraniumHexafluoride", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 216, 428)), new None(9801, "Snow", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 273, 373)), new None(9851, "OilSand", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 100, 400)), new None(9852, "CrudeOil", new MaterialFactKeys.PurifiedCentrifugeNoDefault("liquid", 100, 400))); @@ -44,7 +46,8 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (phase != null) rules.put(MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_PHASE, List.of(MaterialProcessRule.anyForm(phase))); if (none != null) - rules.put(MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT, List.of(MaterialProcessRule.anyForm(none))); + rules.put( + MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT, List.of(MaterialProcessRule.anyForm(none))); return new MaterialDefinition.Declaration( declaration.material(), new MaterialInfoDefinition( diff --git a/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java index 0c78fbea1..b3bcdfe5e 100644 --- a/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java @@ -112,20 +112,16 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio } var shredder = SHREDDER.get(declaration.id()); if (shredder != null && shredder.name().equals(name)) { - rules.put( - MaterialFactKeys.SOURCE_ORE_SHREDDER, - List.of(MaterialProcessRule.anyForm(shredder.profile()))); + rules.put(MaterialFactKeys.SOURCE_ORE_SHREDDER, List.of(MaterialProcessRule.anyForm(shredder.profile()))); } if (name.equals(CRUSHED_SOURCE_MATERIALS.get(declaration.id()))) { rules.put( MaterialFactKeys.SOURCE_CRUSHED_EXCLUSIONS, - List.of(MaterialProcessRule.anyForm( - new MaterialFactKeys.PrefixExclusions(CRUSHED_EXCLUSIONS)))); + List.of(MaterialProcessRule.anyForm(new MaterialFactKeys.PrefixExclusions(CRUSHED_EXCLUSIONS)))); } if (declaration.id() == 9114 && name.equals("Cinnabar")) { rules.put( - MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON, - List.of(MaterialProcessRule.anyForm(CINNABAR_FOLLOWON))); + MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON, List.of(MaterialProcessRule.anyForm(CINNABAR_FOLLOWON))); } var generatedFluid = generatedFluid(declaration.id(), name); if (generatedFluid != null) { @@ -137,13 +133,11 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (declaration.id() == 8745 && name.equals("Netherite") || declaration.id() == 1740 && name.equals("Naquadah")) { rules.put( - MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY, - List.of(MaterialProcessRule.anyForm(Boolean.TRUE))); + MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY, List.of(MaterialProcessRule.anyForm(Boolean.TRUE))); } if (declaration.id() == 9802 && name.equals("Ice")) { rules.put( - MaterialFactKeys.COMPRESSOR_DUST_TO_GEM_PLATE, - List.of(MaterialProcessRule.anyForm(Boolean.FALSE))); + MaterialFactKeys.COMPRESSOR_DUST_TO_GEM_PLATE, List.of(MaterialProcessRule.anyForm(Boolean.FALSE))); } if (rules.equals(info.processes().rules())) return declaration; return new MaterialDefinition.Declaration( @@ -157,16 +151,19 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio private static MaterialFactKeys.GeneratedFluidRule generatedFluid(int id, String name) { return switch (id) { - case 800 -> name.equals("Mercury") - ? new MaterialFactKeys.GeneratedFluidRule("GenLiquid_Mercury", "mercury", 300, 0F, false) - : null; - case 220 -> name.equals("Titanium") - ? new MaterialFactKeys.GeneratedFluidRule( - "GenMolten_Titanium", "molten.titanium", 1941, 4.54F, true) - : null; - case 260 -> name.equals("Iron") - ? new MaterialFactKeys.GeneratedFluidRule("GenMolten_Iron", "molten.iron", 1811, 7.874F, true) - : null; + case 800 -> + name.equals("Mercury") + ? new MaterialFactKeys.GeneratedFluidRule("GenLiquid_Mercury", "mercury", 300, 0F, false) + : null; + case 220 -> + name.equals("Titanium") + ? new MaterialFactKeys.GeneratedFluidRule( + "GenMolten_Titanium", "molten.titanium", 1941, 4.54F, true) + : null; + case 260 -> + name.equals("Iron") + ? new MaterialFactKeys.GeneratedFluidRule("GenMolten_Iron", "molten.iron", 1811, 7.874F, true) + : null; default -> null; }; } diff --git a/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java index ae671d5f6..68d94b0dc 100644 --- a/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java @@ -288,8 +288,7 @@ public static MaterialDefinition.Declaration applyOne(MaterialDefinition.Declara var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); for (var entry : ENTRIES) { - if (entry.id != declaration.id() - || !GTMaterial.sanitize(entry.name).equals(declaration.name())) continue; + if (entry.id != declaration.id() || !GTMaterial.sanitize(entry.name).equals(declaration.name())) continue; var key = entry.rule == Rule.FURNACE ? MaterialFactKeys.SOURCE_FURNACE : MaterialFactKeys.SOURCE_GRADED_GEM; rules.put(key, List.of(MaterialProcessRule.anyForm(entry.decision))); } @@ -306,11 +305,7 @@ public static MaterialDefinition.Declaration applyOne(MaterialDefinition.Declara properties.addAll(material.properties()); properties.add(MaterialProperty.MAGNETIC); material = new MaterialDefinition( - material.identity(), - material.presentation(), - material.physical(), - properties, - material.source()); + material.identity(), material.presentation(), material.physical(), properties, material.source()); } if (rules.equals(info.processes().rules()) && material == declaration.material()) return declaration; return new MaterialDefinition.Declaration( diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java index 28de11199..977693e1b 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java @@ -29,10 +29,8 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio new MaterialInfoDefinition.Processes(rules))); } - private static MaterialFactKeys.Decision pulverizing( - int id, String name, MaterialFactKeys.HexoriumKind hexorium) { - if (hexorium != MaterialFactKeys.HexoriumKind.NONE) - return MaterialFactKeys.Decision.NO; + private static MaterialFactKeys.Decision pulverizing(int id, String name, MaterialFactKeys.HexoriumKind hexorium) { + if (hexorium != MaterialFactKeys.HexoriumKind.NONE) return MaterialFactKeys.Decision.NO; return id == 800 && name.equals("Mercury") || id == 8333 && name.equals("Redstone") || id == 9114 && name.equals("Cinnabar") @@ -42,21 +40,26 @@ private static MaterialFactKeys.Decision pulverizing( private static MaterialFactKeys.HexoriumKind hexorium(int id, String name) { return switch (id) { - case 9224 -> name.equals("HexoriumBlack") - ? MaterialFactKeys.HexoriumKind.BLACK_WHITE - : MaterialFactKeys.HexoriumKind.NONE; - case 9239 -> name.equals("HexoriumWhite") - ? MaterialFactKeys.HexoriumKind.BLACK_WHITE - : MaterialFactKeys.HexoriumKind.NONE; - case 9225 -> name.equals("HexoriumRed") - ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE - : MaterialFactKeys.HexoriumKind.NONE; - case 9226 -> name.equals("HexoriumGreen") - ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE - : MaterialFactKeys.HexoriumKind.NONE; - case 9228 -> name.equals("HexoriumBlue") - ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE - : MaterialFactKeys.HexoriumKind.NONE; + case 9224 -> + name.equals("HexoriumBlack") + ? MaterialFactKeys.HexoriumKind.BLACK_WHITE + : MaterialFactKeys.HexoriumKind.NONE; + case 9239 -> + name.equals("HexoriumWhite") + ? MaterialFactKeys.HexoriumKind.BLACK_WHITE + : MaterialFactKeys.HexoriumKind.NONE; + case 9225 -> + name.equals("HexoriumRed") + ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE + : MaterialFactKeys.HexoriumKind.NONE; + case 9226 -> + name.equals("HexoriumGreen") + ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE + : MaterialFactKeys.HexoriumKind.NONE; + case 9228 -> + name.equals("HexoriumBlue") + ? MaterialFactKeys.HexoriumKind.RED_GREEN_BLUE + : MaterialFactKeys.HexoriumKind.NONE; default -> MaterialFactKeys.HexoriumKind.NONE; }; } diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java index c2d5271f4..f515616e1 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java @@ -4,7 +4,6 @@ import gregtech.content.material.MaterialFactKeys; import gregtech.engine.material.MaterialDefinition; import gregtech.engine.material.MaterialInfoDefinition; - import java.util.LinkedHashMap; import java.util.List; import java.util.Set; diff --git a/core/src/main/java/gregtech/content/recipe/FurnaceSmeltingRules.java b/core/src/main/java/gregtech/content/recipe/FurnaceSmeltingRules.java index 3c15cb8d8..e44b16852 100644 --- a/core/src/main/java/gregtech/content/recipe/FurnaceSmeltingRules.java +++ b/core/src/main/java/gregtech/content/recipe/FurnaceSmeltingRules.java @@ -7,7 +7,6 @@ import gregtech.content.data.MaterialPrefix; import gregtech.content.data.generated.MaterialWorkability; import gregtech.content.material.MaterialFactKeys; - import java.math.BigInteger; import java.util.List; diff --git a/core/src/main/java/gregtech/content/recipe/RecoveryFormCatalog.java b/core/src/main/java/gregtech/content/recipe/RecoveryFormCatalog.java index 531174632..5db472621 100644 --- a/core/src/main/java/gregtech/content/recipe/RecoveryFormCatalog.java +++ b/core/src/main/java/gregtech/content/recipe/RecoveryFormCatalog.java @@ -15,43 +15,181 @@ private RecoveryFormCatalog() {} /** Source {@code OP} prefixes carrying RECYCLABLE at the pinned source commit. */ private static final Set SOURCE_RECYCLABLE = Set.of( - "crushed", "crushedTiny", "crushedPurified", "crushedPurifiedTiny", "crushedCentrifuged", - "crushedCentrifugedTiny", "rockGt", "rawOreChunk", "clump", "cluster", "pebbles", "rubble", - "chunk", "crystalline", "reduced", "cleanGravel", "dirtyGravel", "dust", "dustSmall", - "dustTiny", "dustDiv72", "ingotQuintuple", "ingotQuadruple", "ingotTriple", "ingotDouble", - "ingot", "billet", "chunkGt", "nugget", "gem", "gemChipped", "gemFlawed", "gemFlawless", - "gemExquisite", "gemLegendary", "bouleGt", "crystalPure", "crystal", "lens", "scrapGt", - "plateSteamcraft", "plateDense", "plateQuintuple", "plateQuadruple", "plateTriple", - "plateDouble", "plate", "plateGem", "plateTiny", "plateGemTiny", "plateCurved", "compressed", - "sheetGt", "foil", "stick", "stickLong", "bolt", "screw", "round", "ring", "chain", "spring", - "springSmall", "wireFine", "minecartWheels", "gearGt", "gearGtSmall", "railGt", "casingSmall", - "casingMachine", "casingMachineDouble", "casingMachineQuadruple", "casingMachineDense", "rotor", - "cell", "toolHeadSaw", "toolHeadFile", "toolHeadChisel", "toolHeadBuzzSaw", - "toolHeadChainsaw", "toolHeadWrench", "toolHeadDrill", "toolHeadSword", "toolHeadPickaxe", - "toolHeadShovel", "toolHeadSpade", "toolHeadAxe", "toolHeadHoe", "toolHeadSense", - "toolHeadPlow", "toolHeadHammer", "toolHeadScrewdriver", "toolHeadBuilderwand", - "toolHeadConstructionPickaxe", "toolHeadPickaxeGem", "toolHeadAxeDouble", - "toolHeadUniversalSpade", "toolHeadArrow", "toolHeadRawSaw", "toolHeadRawChisel", - "toolHeadRawSword", "toolHeadRawPickaxe", "toolHeadRawShovel", "toolHeadRawSpade", - "toolHeadRawUniversalSpade", "toolHeadRawAxe", "toolHeadRawAxeDouble", "toolHeadRawHoe", - "toolHeadRawSense", "toolHeadRawPlow", "toolHeadRawArrow", "toolSword", "toolPickaxe", - "toolShovel", "toolAxe", "toolHoe", "toolShears", "bulletGtSmall", "bulletGtMedium", - "bulletGtLarge", "arrowGtWood", "arrowGtPlastic", "armorHelmet", "armorChestplate", - "armorLeggings", "armorBoots", "frameGt", "capcellcon", "pipeTiny", "pipeSmall", - "pipeMedium", "pipeLarge", "pipeHuge", "pipeQuadruple", "pipeNonuple", "pipeRestrictiveTiny", - "pipeRestrictiveSmall", "pipeRestrictiveMedium", "pipeRestrictiveLarge", - "pipeRestrictiveHuge", "wireGt16", "wireGt15", "wireGt14", "wireGt13", "wireGt12", "wireGt11", - "wireGt10", "wireGt09", "wireGt08", "wireGt07", "wireGt06", "wireGt05", "wireGt04", "wireGt03", - "wireGt02", "wireGt01", "cableGt12", "cableGt08", "cableGt04", "cableGt02", "cableGt01", - "blockGem", "blockDust", "blockIngot", "blockPlate", "blockPlateGem", "blockSolid", + "crushed", + "crushedTiny", + "crushedPurified", + "crushedPurifiedTiny", + "crushedCentrifuged", + "crushedCentrifugedTiny", + "rockGt", + "rawOreChunk", + "clump", + "cluster", + "pebbles", + "rubble", + "chunk", + "crystalline", + "reduced", + "cleanGravel", + "dirtyGravel", + "dust", + "dustSmall", + "dustTiny", + "dustDiv72", + "ingotQuintuple", + "ingotQuadruple", + "ingotTriple", + "ingotDouble", + "ingot", + "billet", + "chunkGt", + "nugget", + "gem", + "gemChipped", + "gemFlawed", + "gemFlawless", + "gemExquisite", + "gemLegendary", + "bouleGt", + "crystalPure", + "crystal", + "lens", + "scrapGt", + "plateSteamcraft", + "plateDense", + "plateQuintuple", + "plateQuadruple", + "plateTriple", + "plateDouble", + "plate", + "plateGem", + "plateTiny", + "plateGemTiny", + "plateCurved", + "compressed", + "sheetGt", + "foil", + "stick", + "stickLong", + "bolt", + "screw", + "round", + "ring", + "chain", + "spring", + "springSmall", + "wireFine", + "minecartWheels", + "gearGt", + "gearGtSmall", + "railGt", + "casingSmall", + "casingMachine", + "casingMachineDouble", + "casingMachineQuadruple", + "casingMachineDense", + "rotor", + "cell", + "toolHeadSaw", + "toolHeadFile", + "toolHeadChisel", + "toolHeadBuzzSaw", + "toolHeadChainsaw", + "toolHeadWrench", + "toolHeadDrill", + "toolHeadSword", + "toolHeadPickaxe", + "toolHeadShovel", + "toolHeadSpade", + "toolHeadAxe", + "toolHeadHoe", + "toolHeadSense", + "toolHeadPlow", + "toolHeadHammer", + "toolHeadScrewdriver", + "toolHeadBuilderwand", + "toolHeadConstructionPickaxe", + "toolHeadPickaxeGem", + "toolHeadAxeDouble", + "toolHeadUniversalSpade", + "toolHeadArrow", + "toolHeadRawSaw", + "toolHeadRawChisel", + "toolHeadRawSword", + "toolHeadRawPickaxe", + "toolHeadRawShovel", + "toolHeadRawSpade", + "toolHeadRawUniversalSpade", + "toolHeadRawAxe", + "toolHeadRawAxeDouble", + "toolHeadRawHoe", + "toolHeadRawSense", + "toolHeadRawPlow", + "toolHeadRawArrow", + "toolSword", + "toolPickaxe", + "toolShovel", + "toolAxe", + "toolHoe", + "toolShears", + "bulletGtSmall", + "bulletGtMedium", + "bulletGtLarge", + "arrowGtWood", + "arrowGtPlastic", + "armorHelmet", + "armorChestplate", + "armorLeggings", + "armorBoots", + "frameGt", + "capcellcon", + "pipeTiny", + "pipeSmall", + "pipeMedium", + "pipeLarge", + "pipeHuge", + "pipeQuadruple", + "pipeNonuple", + "pipeRestrictiveTiny", + "pipeRestrictiveSmall", + "pipeRestrictiveMedium", + "pipeRestrictiveLarge", + "pipeRestrictiveHuge", + "wireGt16", + "wireGt15", + "wireGt14", + "wireGt13", + "wireGt12", + "wireGt11", + "wireGt10", + "wireGt09", + "wireGt08", + "wireGt07", + "wireGt06", + "wireGt05", + "wireGt04", + "wireGt03", + "wireGt02", + "wireGt01", + "cableGt12", + "cableGt08", + "cableGt04", + "cableGt02", + "cableGt01", + "blockGem", + "blockDust", + "blockIngot", + "blockPlate", + "blockPlateGem", + "blockSolid", "oreberry"); /** * The source listener rejects these dirty ore-processing forms before thermal conversion. * They retain their distinct Shredder and ore-processing producers. */ - private static final Set THERMAL_ORE_EXCLUSIONS = Set.of( - "chunk", "cluster", "crushed", "crushedTiny", "dirtyGravel", "pebbles", "rawOreChunk", "rubble"); + private static final Set THERMAL_ORE_EXCLUSIONS = + Set.of("chunk", "cluster", "crushed", "crushedTiny", "dirtyGravel", "pebbles", "rawOreChunk", "rubble"); /** The generated prefix-handler subset eligible for generic Shredder recycling. */ public static boolean shredder(String prefixName) { diff --git a/core/src/main/java/gregtech/content/recipe/SourceLensRoles.java b/core/src/main/java/gregtech/content/recipe/SourceLensRoles.java index 2f78a952c..bed4f39a1 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceLensRoles.java +++ b/core/src/main/java/gregtech/content/recipe/SourceLensRoles.java @@ -13,7 +13,8 @@ private SourceLensRoles() {} public static SourceLensMaterialFacts.Color color(GTMaterial material) { if (material == null || !material.isValid() || AddonMaterials.owns(material)) return null; - return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_LENS_ROLE).orElse(null); + return MaterialFactKeys.value(material, MaterialFactKeys.SOURCE_LENS_ROLE) + .orElse(null); } public static List materials(SourceLensMaterialFacts.Color color) { diff --git a/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java index 9a0635e13..ab32efe75 100644 --- a/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java @@ -69,6 +69,7 @@ public record Family( fluidOutputs = List.copyOf(fluidOutputs); } } + public static final Identity MNO2 = id(9126, "Pyrolusite"), MNCL2 = id(8031, "ManganeseChloride"), PGS = id(8103, "PlatinumGroupSludge"), @@ -197,6 +198,7 @@ public record Family( f(Phase.HYDROGENFLUORIDE, 500), List.of(), Tail.GRAPHITE)); + public static List families() { return FAMILIES; } diff --git a/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java index bae310fb0..edd59dc33 100644 --- a/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java @@ -37,8 +37,7 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio } private static void attachReagents( - String name, - Map, List>> processes) { + String name, Map, List>> processes) { if (name.equals("SulfuricAcid")) reagent(processes, SpecialProcessMethods.SULFURIC_ACID_LEACHING, "liquid"); if (name.equals("AquaRegia")) reagent(processes, SpecialProcessMethods.AQUA_REGIA_LEACHING, "liquid"); if (name.equals("HydrogenFluoride")) @@ -58,10 +57,10 @@ private static void attachFixedTargets( if (member == null) continue; var method = method(family.fluidInput().phase()); if (method == null) continue; - processes.computeIfAbsent(method, ignored -> new ArrayList<>()) + processes + .computeIfAbsent(method, ignored -> new ArrayList<>()) .add(new MaterialProcessRule<>( - INPUT_COUNTS.keySet(), - fixedTarget(new MaterialKey(declaration.name()), family))); + INPUT_COUNTS.keySet(), fixedTarget(new MaterialKey(declaration.name()), family))); } } @@ -81,7 +80,9 @@ private static SpecialProcessValue.Target fixedTarget(MaterialKey target, Specia return new SpecialProcessValue.Target( INPUT_COUNTS, itemOutputs, - family.fluidOutputs().stream().map(SpecialProcessMaterialFacts::fluidOutput).toList(), + family.fluidOutputs().stream() + .map(SpecialProcessMaterialFacts::fluidOutput) + .toList(), family.fluidInput().millibuckets(), 256, 0); @@ -92,9 +93,7 @@ private static void attachManganeseTarget( Map, List>> processes) { var material = declaration.material(); if (material.properties().contains(gregtech.api.material.MaterialProperty.ANTIMATTER)) return; - boolean mnDioxideByproduct = declaration.info() - .processes() - .find(MaterialProcessKeys.ORE_PROCESSING).stream() + boolean mnDioxideByproduct = declaration.info().processes().find(MaterialProcessKeys.ORE_PROCESSING).stream() .map(MaterialProcessRule::value) .anyMatch(rule -> rule.byproducts().stream() .anyMatch(byproduct -> byproduct.name().equals("Pyrolusite"))); @@ -115,7 +114,8 @@ private static void attachManganeseTarget( 10_000)), List.of( new SpecialProcessValue.FluidOutput( - new MaterialKey("Water"), List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + new MaterialKey("Water"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), 3_000), new SpecialProcessValue.FluidOutput( new MaterialKey("Chlorine"), @@ -124,68 +124,71 @@ private static void attachManganeseTarget( 4_000, 256, 0); - processes.computeIfAbsent( - SpecialProcessMethods.HYDROCHLORIC_ACID_MANGANESE_LEACHING, - ignored -> new ArrayList<>()) + processes + .computeIfAbsent( + SpecialProcessMethods.HYDROCHLORIC_ACID_MANGANESE_LEACHING, ignored -> new ArrayList<>()) .add(new MaterialProcessRule<>(INPUT_COUNTS.keySet(), target)); } private static void attachStaticAquaRegiaTargets( - String name, - Map, List>> processes) { + String name, Map, List>> processes) { SpecialProcessValue.Target target = switch (name) { - case "Gold" -> aquaRegiaTarget( - "Gold", - "Copper", - new SpecialProcessValue.FluidOutput( - new MaterialKey("ChloroauricAcid"), - List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), - 3_000), - new SpecialProcessValue.FluidOutput( - new MaterialKey("NitrogenMonoxide"), - List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), - 1_000), - new SpecialProcessValue.FluidOutput( - new MaterialKey("Water"), - List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), - 3_000), - 6_500); - case "Copper" -> aquaRegiaTarget( - "Copper", - "Cobalt", - new SpecialProcessValue.FluidOutput( - new MaterialKey("ChloroauricAcid"), - List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), - 3_000), - new SpecialProcessValue.FluidOutput( - new MaterialKey("NitrogenMonoxide"), - List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), - 1_000), - new SpecialProcessValue.FluidOutput( - new MaterialKey("Water"), - List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), - 3_000), - 6_500); - case "Tin", "Cassiterite" -> aquaRegiaTarget( - name, - "Zinc", - new SpecialProcessValue.FluidOutput( - new MaterialKey("StannicChloride"), - List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), - 2_500), - new SpecialProcessValue.FluidOutput( - new MaterialKey("HydrochloricAcid"), - List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), - 4_000), - new SpecialProcessValue.FluidOutput( - new MaterialKey("NitrogenDioxide"), - List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), - 3_000), - 13_000); + case "Gold" -> + aquaRegiaTarget( + "Gold", + "Copper", + new SpecialProcessValue.FluidOutput( + new MaterialKey("ChloroauricAcid"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("NitrogenMonoxide"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 1_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("Water"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + 6_500); + case "Copper" -> + aquaRegiaTarget( + "Copper", + "Cobalt", + new SpecialProcessValue.FluidOutput( + new MaterialKey("ChloroauricAcid"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("NitrogenMonoxide"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 1_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("Water"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 3_000), + 6_500); + case "Tin", "Cassiterite" -> + aquaRegiaTarget( + name, + "Zinc", + new SpecialProcessValue.FluidOutput( + new MaterialKey("StannicChloride"), + List.of(new SpecialProcessValue.FormCount(form("liquid"), 1)), + 2_500), + new SpecialProcessValue.FluidOutput( + new MaterialKey("HydrochloricAcid"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 4_000), + new SpecialProcessValue.FluidOutput( + new MaterialKey("NitrogenDioxide"), + List.of(new SpecialProcessValue.FormCount(form("gas"), 1)), + 3_000), + 13_000); default -> null; }; if (target == null) return; - processes.computeIfAbsent(SpecialProcessMethods.AQUA_REGIA_LEACHING, ignored -> new ArrayList<>()) + processes + .computeIfAbsent(SpecialProcessMethods.AQUA_REGIA_LEACHING, ignored -> new ArrayList<>()) .add(new MaterialProcessRule<>(INPUT_COUNTS.keySet(), target)); } @@ -204,8 +207,7 @@ private static SpecialProcessValue.Target aquaRegiaTarget( new MaterialKey(byproduct), List.of(new SpecialProcessValue.FormCount(CENTRIFUGED_TINY, 2)), 5_000)); - return new SpecialProcessValue.Target( - INPUT_COUNTS, items, List.of(first, second, third), acid, 256, 0); + return new SpecialProcessValue.Target(INPUT_COUNTS, items, List.of(first, second, third), acid, 256, 0); } private static SpecialProcessValue.FluidOutput fluidOutput(SpecialProcessData.Fluid fluid) { @@ -230,7 +232,8 @@ private static void reagent( Map, List>> processes, MaterialProcessKey method, String form) { - processes.computeIfAbsent(method, ignored -> new ArrayList<>()) + processes + .computeIfAbsent(method, ignored -> new ArrayList<>()) .add(new MaterialProcessRule<>(Set.of(form(form)), new SpecialProcessValue.Reagent())); } diff --git a/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java index 51f9f541f..269cfde22 100644 --- a/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java @@ -9,13 +9,13 @@ /** Built-in special process methods and their stable target/reagent process keys. */ public final class SpecialProcessMethods { - public static final MaterialProcessKey SULFURIC_ACID_LEACHING = process( - "sulfuric_acid_leaching"); + public static final MaterialProcessKey SULFURIC_ACID_LEACHING = + process("sulfuric_acid_leaching"); public static final MaterialProcessKey AQUA_REGIA_LEACHING = process("aqua_regia_leaching"); - public static final MaterialProcessKey HYDROFLUORIC_ACID_LEACHING = process( - "hydrofluoric_acid_leaching"); - public static final MaterialProcessKey HYDROCHLORIC_ACID_MANGANESE_LEACHING = process( - "hydrochloric_acid_manganese_leaching"); + public static final MaterialProcessKey HYDROFLUORIC_ACID_LEACHING = + process("hydrofluoric_acid_leaching"); + public static final MaterialProcessKey HYDROCHLORIC_ACID_MANGANESE_LEACHING = + process("hydrochloric_acid_manganese_leaching"); private static final List METHODS = List.of( method(SULFURIC_ACID_LEACHING), @@ -35,11 +35,12 @@ public static void install() { private static SpecialProcessMethod method(MaterialProcessKey process) { return new SpecialProcessMethod( - process, "gt.recipe.bath", "gt6ce.special_process." + process.id().path().replace('/', '.')); + process, + "gt.recipe.bath", + "gt6ce.special_process." + process.id().path().replace('/', '.')); } private static MaterialProcessKey process(String path) { - return MaterialProcessKey.multiple( - new DataKey("gt6ce", "special_process/" + path), SpecialProcessValue.class); + return MaterialProcessKey.multiple(new DataKey("gt6ce", "special_process/" + path), SpecialProcessValue.class); } } diff --git a/core/src/main/java/gregtech/engine/material/ItemCompositionResolution.java b/core/src/main/java/gregtech/engine/material/ItemCompositionResolution.java index b4908d81b..0eddf429f 100644 --- a/core/src/main/java/gregtech/engine/material/ItemCompositionResolution.java +++ b/core/src/main/java/gregtech/engine/material/ItemCompositionResolution.java @@ -10,8 +10,8 @@ public record ItemCompositionResolution( Objects.requireNonNull(selected, "selected"); decisions = List.copyOf(Objects.requireNonNull(decisions, "decisions")); if (decisions.isEmpty()) throw new IllegalArgumentException("decisions must not be empty"); - boolean selectedCandidatePresent = decisions.stream() - .anyMatch(decision -> decision.status() == ItemCompositionDecision.Status.SELECTED); + boolean selectedCandidatePresent = + decisions.stream().anyMatch(decision -> decision.status() == ItemCompositionDecision.Status.SELECTED); if (!selectedCandidatePresent) throw new IllegalArgumentException("decisions need a selected candidate"); } } diff --git a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java index 3a426725a..6e3f9625a 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java +++ b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java @@ -7,9 +7,11 @@ * Immutable semantic process graph for one published material generation. * *

The graph owns no native recipe or world-generation objects. Queries traverse only their - * published ports and return bounded immutable rows for a viewer adapter to project.

+ * published ports and return immutable rows for a viewer adapter to project, with optional query budgets.

*/ public final class MaterialProcessGraph { + private static final System.Logger LOGGER = System.getLogger("gt6ce.material.process"); + /** One transaction boundary with the form, tag and active worldgen revisions used by the rows. */ public record Snapshot( MaterialPublication.Stamp publication, @@ -98,11 +100,17 @@ public record Step( requireText(name, "process step name"); inputs = List.copyOf(inputs); outputs = List.copyOf(outputs); - if (inputs.stream().anyMatch(Port::output) || outputs.stream().anyMatch(port -> !port.output())) - throw new IllegalArgumentException("Port role on wrong side"); - if (inputs.stream().filter(Port::main).count() > 1 - || outputs.stream().filter(Port::main).count() > 1) - throw new IllegalArgumentException("Multiple main process ports"); + var validInputs = inputs.stream().filter(port -> !port.output()).toList(); + var validOutputs = outputs.stream().filter(Port::output).toList(); + if (validInputs.size() != inputs.size() || validOutputs.size() != outputs.size()) { + LOGGER.log( + System.Logger.Level.WARNING, + "Discarded ports on the wrong side of process step {0}", + reference); + resolved = false; + } + inputs = validInputs; + outputs = validOutputs; details = List.copyOf(details); Objects.requireNonNull(specialProcess); } @@ -126,8 +134,24 @@ public record Edge(DataKey source, DataKey target, DataKey resource, boolean con } } + /** Exact resource incidence; each source/target pair is implicit instead of allocated as an edge. */ + public record Flow(DataKey resource, List sources, List targets) { + public Flow { + Objects.requireNonNull(resource); + sources = List.copyOf(sources); + targets = List.copyOf(targets); + } + + public long connectionCount() { + return (long) sources.size() * targets.size(); + } + } + public record Budgets(int maxDepth, int maxSteps, int maxPortsPerSide, int maxEdges) { public static final Budgets DEFAULT = new Budgets(8, 64, 64, 128); + /** Explicit expansion budget; viewer pages use {@link MaterialProcessGraph#queryMaterial(DataKey)} instead. */ + public static final Budgets MATERIAL_PAGE = + new Budgets(0, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); public Budgets { if (maxDepth < 0 || maxSteps <= 0 || maxPortsPerSide <= 0 || maxEdges < 0) @@ -160,6 +184,18 @@ public record Query( } } + /** A complete material page whose storage follows port occurrences, not producer/consumer products. */ + public record MaterialQuery( + Snapshot snapshot, DataKey root, List steps, List flows, List notices) { + public MaterialQuery { + Objects.requireNonNull(snapshot); + Objects.requireNonNull(root); + steps = List.copyOf(steps); + flows = List.copyOf(flows); + notices = List.copyOf(notices); + } + } + private record IndexedStep(int order, Step step, boolean genericRecovery) {} private record Node(DataKey reference, int depth) {} @@ -202,12 +238,68 @@ public Snapshot snapshot() { return snapshot; } + public Optional step(DataKey reference) { + IndexedStep indexed = steps.get(reference); + return indexed == null ? Optional.empty() : Optional.of(indexed.step()); + } + public List resources() { return resources.values().stream() .sorted(Comparator.comparing(resource -> resource.key().toString())) .toList(); } + public List materialSteps(DataKey root) { + Resource resource = resources.get(Objects.requireNonNull(root)); + return resource == null + ? List.of() + : selectMaterial(resource).stream().map(IndexedStep::step).toList(); + } + + /** Keeps every direct row and association without enumerating a resource's source/target cross-product. */ + public MaterialQuery queryMaterial(DataKey root) { + Objects.requireNonNull(root); + Resource resource = resources.get(root); + if (resource == null) return new MaterialQuery(snapshot, root, List.of(), List.of(), notices); + var selected = selectMaterial(resource); + var references = new HashSet(); + selected.forEach(indexed -> references.add(indexed.step().reference())); + var flows = new ArrayList(); + for (Resource local : materialResources(resource)) { + var sources = outputs.getOrDefault(local.key(), List.of()).stream() + .map(indexed -> indexed.step().reference()) + .filter(references::contains) + .toList(); + var targets = inputs.getOrDefault(local.key(), List.of()).stream() + .map(indexed -> indexed.step().reference()) + .filter(references::contains) + .toList(); + if (!sources.isEmpty() && !targets.isEmpty()) flows.add(new Flow(local.key(), sources, targets)); + } + var resultNotices = new ArrayList<>(notices); + if (selected.isEmpty() + && resultNotices.stream().noneMatch(notice -> notice.code().equals("no_both"))) + resultNotices.add(new Notice("no_both", 0)); + return new MaterialQuery( + snapshot, root, selected.stream().map(IndexedStep::step).toList(), flows, resultNotices); + } + + private List materialResources(Resource root) { + return root.material().equals("unknown") + ? List.of(root) + : resourcesByMaterial.getOrDefault(root.material(), List.of()); + } + + private List selectMaterial(Resource root) { + var selected = new TreeSet( + Comparator.comparing(IndexedStep::genericRecovery).thenComparingInt(IndexedStep::order)); + for (Resource resource : materialResources(root)) { + selected.addAll(inputs.getOrDefault(resource.key(), List.of())); + selected.addAll(sources(resource.key())); + } + return List.copyOf(selected); + } + /** * Traverse from one resource occurrence. The adjacency index is already published; this method * never enumerates unrelated steps or expands a selector into its member matrix. @@ -369,15 +461,7 @@ public Query queryMaterial(DataKey root, Budgets budgets) { if (rootResource == null) return new Query(snapshot, root, Direction.BOTH, List.of(), List.of(), notices, false); - var selected = new java.util.TreeSet( - Comparator.comparing(IndexedStep::genericRecovery).thenComparingInt(IndexedStep::order)); - List materialResources = rootResource.material().equals("unknown") - ? List.of(rootResource) - : resourcesByMaterial.getOrDefault(rootResource.material(), List.of()); - for (Resource resource : materialResources) { - selected.addAll(inputs.getOrDefault(resource.key(), List.of())); - selected.addAll(sources(resource.key())); - } + var selected = selectMaterial(rootResource); var retained = new ArrayList(Math.min(selected.size(), budgets.maxSteps())); int omittedSteps = 0; for (IndexedStep indexed : selected) { @@ -398,14 +482,22 @@ public Query queryMaterial(DataKey root, Budgets budgets) { .toList(); var retainedByReference = new HashMap(); resultSteps.forEach(step -> retainedByReference.put(step.reference(), step)); + var retainedInputs = new HashMap>(); + resultSteps.forEach(step -> { + var keys = new HashSet(); + step.inputs().forEach(port -> keys.add(port.resource().key())); + retainedInputs.put(step.reference(), keys); + }); var resultEdges = new LinkedHashSet(); int omittedEdges = 0; for (IndexedStep source : retained) { - for (Port port : source.step.outputs()) { + for (Port port : retainedByReference.get(source.step.reference()).outputs()) { if (!port.resource().material().equals(rootResource.material())) continue; for (IndexedStep target : inputs.getOrDefault(port.resource().key(), List.of())) { - if (!retainedByReference.containsKey(target.step.reference())) continue; + if (!retainedInputs + .getOrDefault(target.step.reference(), Set.of()) + .contains(port.resource().key())) continue; Edge edge = new Edge( source.step.reference(), target.step.reference(), @@ -465,6 +557,7 @@ private int enqueue( } private Step boundedStep(Step step, int maxPorts) { + if (step.inputs().size() <= maxPorts && step.outputs().size() <= maxPorts) return step; return new Step( step.reference(), step.name(), @@ -535,21 +628,38 @@ public Builder add(Step step) { /** Generic recovery remains a use of its input, without advertising every reclaimable item as a source. */ public Builder add(Step step, boolean genericRecovery) { Objects.requireNonNull(step); - if (steps.containsKey(step.reference())) - throw new IllegalArgumentException("Duplicate process step " + step.reference()); + if (steps.containsKey(step.reference())) { + LOGGER.log(System.Logger.Level.WARNING, "Discarded duplicate process step {0}", step.reference()); + return notice("invalid_process_data", 1); + } + // Validate the whole row before changing any index; a rejected row must leave no partial resources. + var additions = new HashMap(); + for (List ports : List.of(step.inputs(), step.outputs())) + for (Port port : ports) { + Resource resource = port.resource(); + Resource previous = additions.putIfAbsent(resource.key(), resource); + if (previous == null) previous = resources.get(resource.key()); + if (previous != null && !previous.equals(resource)) { + LOGGER.log( + System.Logger.Level.WARNING, + "Discarded process step {0}: conflicting resource identity {1}", + step.reference(), + resource.key()); + return notice("invalid_process_data", 1); + } + } int order = steps.size(); IndexedStep indexed = new IndexedStep(order, step, genericRecovery); steps.put(step.reference(), indexed); + resources.putAll(additions); var inputResources = new HashSet(); for (Port port : step.inputs()) { - register(port.resource()); if (inputResources.add(port.resource().key())) inputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) .add(indexed); } var outputResources = new HashSet(); for (Port port : step.outputs()) { - register(port.resource()); if (outputResources.add(port.resource().key())) outputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) .add(indexed); @@ -557,12 +667,6 @@ public Builder add(Step step, boolean genericRecovery) { return this; } - private void register(Resource resource) { - Resource previous = resources.putIfAbsent(resource.key(), resource); - if (previous != null && !previous.equals(resource)) - throw new IllegalArgumentException("Process resource key has conflicting identity: " + resource.key()); - } - public MaterialProcessGraph build() { return new MaterialProcessGraph(this); } diff --git a/core/src/main/java/gregtech/engine/material/ReversibleCraftingData.java b/core/src/main/java/gregtech/engine/material/ReversibleCraftingData.java index ad9e94372..b2855fbe0 100644 --- a/core/src/main/java/gregtech/engine/material/ReversibleCraftingData.java +++ b/core/src/main/java/gregtech/engine/material/ReversibleCraftingData.java @@ -7,7 +7,6 @@ import gregtech.api.material.MaterialSentinels; import gregtech.content.data.MaterialGroups; import gregtech.content.data.generated.GT6Materials; - import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index f984f5a35..41eb2ad3c 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -116,6 +116,7 @@ "gt6ce.jei.material_process.coverage.node_limit": "Depth stopped at the graph budget; %s additional steps were omitted.", "gt6ce.jei.material_process.coverage.port_limit": "Port budget reached; %s ports were omitted.", "gt6ce.jei.material_process.coverage.edge_limit": "Edge budget reached; %s links were omitted.", + "gt6ce.jei.material_process.coverage.invalid_data": "%s invalid process records were omitted; see the log for details.", "gt6ce.jei.material_process.no_sources": "No published source in the queried range.", "gt6ce.jei.material_process.no_uses": "No published use in the queried range.", "gt6ce.jei.material_process.no_both": "No connected published source or use in the queried range.", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index 2e7d714ff..228504d02 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -118,6 +118,7 @@ "gt6ce.jei.material_process.coverage.node_limit": "达到深度或节点预算,省略了 %s 个后续步骤。", "gt6ce.jei.material_process.coverage.port_limit": "达到端口预算,省略了 %s 个端口。", "gt6ce.jei.material_process.coverage.edge_limit": "达到关联预算,省略了 %s 条关联。", + "gt6ce.jei.material_process.coverage.invalid_data": "已剔除 %s 条无效加工数据,详情见日志。", "gt6ce.jei.material_process.no_sources": "查询范围内没有已发布的来源。", "gt6ce.jei.material_process.no_uses": "查询范围内没有已发布的用途。", "gt6ce.jei.material_process.no_both": "查询范围内没有相连的已发布来源或用途。", diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java index 163a9e187..1285155ec 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java @@ -165,6 +165,148 @@ private static boolean edgeIsConfirmed(MaterialProcessGraph.Edge edge) { return edge.confirmed(); } + @Test + void materialPageKeepsLargeRecipesAndDenseConnections() { + var builder = MaterialProcessGraph.builder(SNAPSHOT); + var common = resource("common"); + var outputs = new java.util.ArrayList(); + for (int index = 0; index < 160; index++) + outputs.add(port(resource("product_" + index), Role.UNKNOWN, "product_" + index)); + builder.add(step("large", List.of(port(common, Role.CONSUMED, "common")), outputs)); + for (int index = 0; index < 70; index++) { + builder.add(step("producer_" + index, List.of(), List.of(port(common, Role.UNKNOWN, "common")))); + builder.add(step("consumer_" + index, List.of(port(common, Role.CONSUMED, "common")), List.of())); + } + for (int index = 0; index < 600; index++) + builder.add(step( + "route_" + index, + List.of(), + List.of(port(resource("local_" + index), Role.UNKNOWN, "local_" + index)))); + var graph = builder.build(); + var query = graph.queryMaterial(common, Budgets.MATERIAL_PAGE); + assertEquals(741, query.steps().size()); + assertEquals(4970, query.edges().size()); + assertEquals(160, query.steps().get(0).outputs().size()); + assertFalse(query.truncated()); + assertTrue(query.notices().isEmpty()); + } + + @Test + void compactMaterialQueryStoresDenseAndCyclicAssociationsAsPortIncidence() { + var builder = MaterialProcessGraph.builder(SNAPSHOT); + var common = resource("dense_common"); + var input = port(common, Role.CONSUMED, "common"); + var output = port(common, Role.UNKNOWN, "common"); + for (int index = 0; index < 10_000; index++) { + builder.add(step("dense_source_" + index, List.of(), List.of(output))); + builder.add(step("dense_use_" + index, List.of(input), List.of())); + } + builder.add(step("dense_loop", List.of(input), List.of(output))); + var graph = builder.build(); + var query = graph.queryMaterial(common); + assertEquals(20_001, query.steps().size()); + assertEquals(query.steps(), graph.materialSteps(common)); + assertEquals(1, query.flows().size()); + var flow = query.flows().get(0); + assertEquals(10_001, flow.sources().size()); + assertEquals(10_001, flow.targets().size()); + assertEquals(100_020_001L, flow.connectionCount()); + assertTrue(flow.sources().contains(new DataKey("gt6ce", "step/dense_loop"))); + assertTrue(flow.targets().contains(new DataKey("gt6ce", "step/dense_loop"))); + assertTrue(query.notices().isEmpty()); + } + + @Test + void compactFlowsPreserveExactResourcesAndConfirmationWithoutInventingSelectorLinks() { + var first = resource("selector_first"); + var second = resource("selector_second"); + var produced = port(first, Role.UNKNOWN, "same_display"); + var used = port(first, Role.CONSUMED, "same_display"); + var other = port(second, Role.CONSUMED, "same_display"); + var source = new Step( + new DataKey("gt6ce", "step/unconfirmed"), + "unconfirmed", + List.of(), + List.of(produced), + List.of(), + false); + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(source) + .add(step("local_loop", List.of(used), List.of(produced))) + .add(step("independent_selector", List.of(other), List.of())) + .build(); + var compact = graph.queryMaterial(first); + var expanded = graph.queryMaterial(first, new Budgets(0, 32, 32, 128)); + var restored = new java.util.HashSet(); + for (Flow flow : compact.flows()) + for (DataKey from : flow.sources()) + for (DataKey to : flow.targets()) + restored.add(new Edge( + from, + to, + flow.resource(), + graph.step(from).orElseThrow().resolved() + && graph.step(to).orElseThrow().resolved())); + assertEquals(expanded.steps(), compact.steps()); + assertEquals(new java.util.HashSet<>(expanded.edges()), restored); + assertEquals(1, compact.flows().size()); + assertEquals( + List.of(new DataKey("gt6ce", "step/local_loop")), + compact.flows().get(0).targets()); + assertTrue(restored.stream().anyMatch(edge -> !edge.confirmed())); + } + + @Test + void invalidRowsDoNotPoisonPublishedIndexesOrDiscardValidRows() { + var ore = resource("ore"); + var dust = resource("dust"); + var valid = step("valid", List.of(port(ore, Role.CONSUMED, "ore")), List.of(port(dust, Role.UNKNOWN, "dust"))); + var conflict = step( + "conflict", + List.of(port(resource("partial"), Role.CONSUMED, "partial")), + List.of(port(ore, Role.UNKNOWN, "another_state"))); + var intraRow = step( + "intra_row", + List.of(port(resource("intra"), Role.CONSUMED, "one")), + List.of(port(resource("intra"), Role.UNKNOWN, "two"))); + var next = step("next", List.of(port(dust, Role.CONSUMED, "dust")), List.of()); + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(valid) + .add(valid) + .add(conflict) + .add(intraRow) + .add(next) + .build(); + assertEquals( + List.of(valid, next), + graph.queryMaterial(ore, Budgets.MATERIAL_PAGE).steps()); + assertEquals( + List.of(ore, dust).stream() + .sorted(java.util.Comparator.comparing(DataKey::toString)) + .toList(), + graph.resources().stream().map(Resource::key).toList()); + assertTrue(graph.step(conflict.reference()).isEmpty()); + assertTrue(graph.step(intraRow.reference()).isEmpty()); + assertEquals( + 3, + graph.queryMaterial(ore, Budgets.MATERIAL_PAGE).notices().stream() + .filter(notice -> notice.code().equals("invalid_process_data")) + .mapToInt(Notice::omitted) + .sum()); + } + + @Test + void mainHintsMayRepeatAndWrongSidePortsAreRemovedWithoutConfirmingTheRow() { + var first = port(resource("first"), Role.CONSUMED, "first"); + var second = port(resource("second"), Role.CONSUMED, "second"); + first = new Port(first.resource(), first.role(), first.amount(), first.chance(), true, first.details()); + second = new Port(second.resource(), second.role(), second.amount(), second.chance(), true, second.details()); + var row = step("hints", List.of(first, second), List.of(first)); + assertEquals(2, row.inputs().size()); + assertTrue(row.outputs().isEmpty()); + assertFalse(row.resolved()); + } + @Test void portsTruncatedAtTheDepthBoundaryStillReportPartialCoverage() { var graph = MaterialProcessGraph.builder(SNAPSHOT) @@ -204,6 +346,63 @@ void edgesNeverReferToPortsDiscardedByTheBudget() { assertTrue(result.truncated()); } + @Test + void materialEdgesUseTheRetainedPortsBeforeSpendingTheEdgeBudget() { + var first = resource("first"); + var second = resource("second"); + var third = resource("third"); + var graph = MaterialProcessGraph.builder(SNAPSHOT) + .add(step( + "producer", + List.of(port(resource("raw"), Role.CONSUMED, "raw")), + List.of( + port(first, Role.UNKNOWN, "first"), + port(second, Role.UNKNOWN, "second"), + port(third, Role.UNKNOWN, "third")))) + .add(step( + "consumer", + List.of( + port(third, Role.CONSUMED, "third"), + port(first, Role.CONSUMED, "first"), + port(second, Role.CONSUMED, "second")), + List.of(port(resource("end"), Role.UNKNOWN, "end")))) + .build(); + for (int ports = 1; ports <= 3; ports++) { + for (int edges : List.of(0, 1, 3)) { + var result = graph.queryMaterial(first, new Budgets(0, 8, ports, edges)); + int available = ports == 1 ? 0 : ports == 2 ? 1 : 3; + assertEquals(Math.min(available, edges), result.edges().size()); + for (Edge edge : result.edges()) { + var source = result.steps().stream() + .filter(row -> row.reference().equals(edge.source())) + .findFirst() + .orElseThrow(); + var target = result.steps().stream() + .filter(row -> row.reference().equals(edge.target())) + .findFirst() + .orElseThrow(); + assertTrue(source.outputs().stream() + .anyMatch(port -> port.resource().key().equals(edge.resource()))); + assertTrue(target.inputs().stream() + .anyMatch(port -> port.resource().key().equals(edge.resource()))); + } + int omittedPorts = 2 * (3 - ports); + assertEquals( + omittedPorts, + result.notices().stream() + .filter(notice -> notice.code().equals("port_limit")) + .mapToInt(Notice::omitted) + .sum()); + assertEquals( + Math.max(0, available - edges), + result.notices().stream() + .filter(notice -> notice.code().equals("edge_limit")) + .mapToInt(Notice::omitted) + .sum()); + } + } + } + private static DataKey resource(String name) { return new DataKey("gt6ce", "resource/" + name); } diff --git a/docs/architecture/packages/engine.md b/docs/architecture/packages/engine.md index 740847a0a..3a0732df6 100644 --- a/docs/architecture/packages/engine.md +++ b/docs/architecture/packages/engine.md @@ -70,7 +70,7 @@ `MultiblockMenus` 将已成型结构部件的普通右键交给主控现有菜单;库存、流体和菜单同步仍属于主控。`StructureWatchIndex.formedController` 读取成功匹配的非空气单元,包含普通方块和实际匹配的重复层,不重新扫描结构;没有唯一归属的共享普通壁板不自动选主控。`MultiblockMenuAccess` 为每次开窗保存点击位置,距离按该部件计算,并持续检查主控身份、结构成型和部件归属。覆盖板、工具、液体容器和潜行交互优先;没有 GUI 的主控不生成新菜单。 -`MaterialProcessGraph.Builder.add(step, genericRecovery)` 接收宿主核对回收归属及配方表后的判定,GENERIC 发布优先级本身不足以区分砧加工和回收:通用回收只作为输入用途进入材料页,不占用来源检索预算,不由机器名或物品形态推断。原始端口仍保留,原生配方注册不受此展示索引影响。 +`MaterialProcessGraph.Builder.add(step, genericRecovery)` 接收宿主核对回收归属及配方表后的判定,GENERIC 发布优先级本身不足以区分砧加工和回收:通用回收只作为输入用途进入材料页,不占用来源检索预算,不由机器名或物品形态推断。原始端口仍保留,原生配方注册不受此展示索引影响。默认材料页使用 `queryMaterial(root)` 保留该材料的全部直接关系,`Flow` 按精确资源保存生产者和消费者,空间随端口引用数增长,不展开两侧的连接乘积;`materialSteps(root)` 用于只需步骤的索引接入。显式预算版本仍用于有界查询。重复步骤和资源身份冲突逐条记录日志并拒绝,校验先于索引写入;`step(reference)` 用于宿主核对最终保留的步骤,避免导航和资源引用指向已拒绝数据。 ## 验收 diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index a8372863b..56611ce49 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,11 +70,11 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责按机器/首产物合并相似路线、原生端口实例、可见拓扑层级、连续链、局部副本、输入/产物网格、独立路线紧凑排布、端口产量角标、排线、配方浅色边界及同物品匹配,`client.MaterialProcessPanel` 负责带绿色目标外框的 100% 查询聚焦、窗口自适应视口、副本/回流标记与原生交互;`client.MaterialProcessScreen` 承载全屏浏览与返回原查看器;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、仅限页面材料的索引和事件适配;EMI 查询目标由客户端可选的 `EmiMaterialProcessFocusMixin` 传入。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 +矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责按可见机器及完整共同输入或输出集合合并相似路线、原生端口实例、可见拓扑层级、连续链、局部副本、输入/产物网格、独立路线紧凑排布、端口产量角标、排线、配方浅色边界及同物品匹配,`client.MaterialProcessPanel` 负责带绿色目标外框的 100% 查询聚焦、窗口自适应视口、副本/回流标记与原生交互;`client.MaterialProcessScreen` 承载全屏浏览与返回原查看器;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、仅限页面材料的索引和事件适配;EMI 索引按完整原生状态去重,注册时不构造全部页面,实际打开时再查询完整步骤与按资源压缩的 `Flow` 关联;EMI 查询目标由客户端可选的 `EmiMaterialProcessFocusMixin` 传入。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 -EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理:在 `EmiMaterialProcessRecipesMixin` 取得最终可见配方后,统一接入 GT、工作台及其他模组的完整加工关系;GT 行复用原生单位、概率及回收归属,信息页和无法完整读取的条目保留在来源区底部的信息卡片,通过原页面跳转查看,不生成加工边。`MaterialProcessSnapshot.ViewerBuilder` 只构造本次客户端视图,不更改服务端配方。JEI 仍使用原生 GT 快照;具体覆盖、候选原料和生命周期边界见[EMI 配方来源与准入](../../development/material-process-display.md#emi-配方来源与准入)。 +EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理:在 `EmiMaterialProcessRecipesMixin` 取得最终可见配方后,统一接入 GT、工作台及其他模组的完整加工关系;GT 行优先复用原生单位、概率及回收归属,材料单位模板不受自动配方树开关影响。可读取的非树加工以未确认关系接入;说明、结构和动态模式页保留为信息。加工行按 EMI ID 和完整端口语义去重。合成网格空位不阻止完整配方进入加工图;通用标签/候选浏览页不进入信息区。其他相关信息和无法完整读取的条目按主材料关联、按 EMI ID 去重,保留在来源区底部的信息卡片,通过原页面跳转查看,不生成加工边。`MaterialProcessSnapshot.ViewerBuilder` 只构造本次客户端视图,不更改服务端配方。JEI 仍使用原生 GT 快照;具体覆盖、候选原料和生命周期边界见[EMI 配方来源与准入](../../development/material-process-display.md#emi-配方来源与准入)。 ## 验收 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md index 56a96933c..b40de2423 100644 --- a/docs/development/material-process-display.md +++ b/docs/development/material-process-display.md @@ -13,7 +13,8 @@ | `gregtech.compat.common.MaterialProcessDisplay` | 已完成有界查询的展示投影和校验;不读取材料目录、配方表或服务端状态 | | `MaterialProcessDisplay.Port` | 一个原生状态敏感的资源选择器的展示,含角色、数量单位、概率与有限图标 | | `MaterialProcessDisplay.Step` | 同一步骤的全部共同输入、全部输出、机器/环境/时间/能量/出处说明,以及可选的 special-process method 身份 | -| `MaterialProcessDisplay.Connection` | 调用方提供的步骤关联,包含资源引用及确认状态;支持分支、回边和自环 | +| `MaterialProcessDisplay.Connection` | 调用方提供的单条步骤关联,包含资源引用及确认状态;支持分支、回边和自环 | +| `MaterialProcessDisplay.Flow` | 同一精确资源的生产者与消费者引用集合;紧凑表达全部关联,不分配两两连接 | | `MaterialProcessDisplay.Page` | 一种材料的全部已查询步骤、全图关联、覆盖说明和绑定到同一查询结果的跳转回调;页面不按步骤拆页 | | `gregtech.compat.common.MaterialProcessOverview` | 按显示身份合并重复路线与资源,保留原始步骤/端口,计算依赖层级、连续链及排线路径 | | `gregtech.client.MaterialProcessPanel` | 窗口自适应视口内的拓扑图、查询目标绿色外框、同物品悬停、配方浅色边框、平移缩放与普通来源/用途查询;不依赖 JEI/EMI | @@ -33,13 +34,17 @@ EMI 的机器、工作台、熔炉和其他模组配方统一取自本次 `EmiRecipes.bake` 过滤后的列表,包括延迟注册的配方。公开 `addDeferredRecipes` 回调执行时尚未建立最终管理器,也未应用全部隐藏规则,因此客户端可选的 `EmiMaterialProcessRecipesMixin` 在最终列表赋值时加入材料页。两个节点均注册此 Mixin;未安装 EMI 时由 `@Pseudo` 跳过。该接入依赖当前锁定的 EMI 1.1.24,升级时必须核对局部列表与注入次数。 -只有 `supportsRecipeTree()` 为真且输入、输出均非空的条目可以成为加工关系。结构、战利品、世界生成展示、材料标签查询和总览页自身等声明不支持配方树的条目不作为加工关系导入。任一原料、催化剂或产物为空、数量无效或含不支持的 ingredient 类型时,整条配方移入相关信息,不能删掉该槽后将剩余部分当作完整配方。第三方错误声明自身完整性无法由通用接口自动识别;来源约束与容器返还仍通过原配方查询查看。 +加工关系依据可读取的实际输入、输出准入,不以 `supportsRecipeTree()` 作为统一开关。禁用配方树的工具装配和第三方固定加工仍进入图中,其关系保留为未确认;不会据此承诺自动合成。结构、战利品、世界生成展示、材料标签查询、说明页、动态模式合成、木桶查询别名和总览页自身不作为加工关系导入。有序合成输入中的空 `EmiStack` 是网格占位,读取时跳过;跳过后仍须存在实际输入。零数量催化剂按存在一个工具展示,不转为消耗品。其他空原料、空催化剂、空产物、无效数量或不支持的 ingredient 类型仍使整条配方移入相关信息,不能删掉必需槽后将剩余部分当作完整配方。第三方动态约束无法由通用槽位接口完整还原;来源约束与容器返还仍通过原配方查询查看。 -GT 的 `MachineEmiRecipe` 只决定原生行是否进入视图;端口继续使用原生配方的材料单位、精确状态、概率、特殊工艺与回收归属,不重复遍历全局机器表添加另一份。活动世界生成使用已发布事实单独保留,不从 EMI 信息页的检索槽推断来源。 +GT 的 `MachineEmiRecipe` 优先按原生语义接入,材料单位模板即使禁用了 EMI 配方树也仍是加工关系;没有材料单位声明的假配方保留为信息。端口继续使用原生配方的材料单位、精确状态、概率、特殊工艺与回收归属,不重复遍历全局机器表添加另一份。活动世界生成使用已发布事实单独保留,不从 EMI 信息页的检索槽推断来源。 -其他配方保留每槽原生数量、输出边际概率、催化剂及完整物品 NBT/流体数据组件。候选原料作为一个 selector;只有所有候选均属于同一材料时才将它归入该材料,跨材料候选保持 `unknown`。候选集不展开为多个共同输入,也不与某个代表物品建立确认关系;代表图标最多十六个。缺少可靠工作站时保留问号。覆盖说明列出未作为加工关系导入的条目数,不声称支持未注册到 EMI 的加工方式。 +其他配方保留每槽原生数量、输出边际概率、催化剂及完整物品 NBT/流体数据组件。候选原料作为一个 selector;只有所有候选均属于同一材料时才将它归入该材料,跨材料候选保持 `unknown`。候选集不展开为多个共同输入,也不与某个代表物品建立确认关系;代表图标最多十六个。工作台分类缺少工作站条目时使用原版工作台,其他分类缺少可靠工作站时保留问号。同一非空 EMI ID 的加工行只接入一次;不含容器返还的行还按分类及输入、工具、输出的原生身份、角色、单位、合计数量和概率去重,不依赖槽位顺序或合成网格占位;独立概率槽保留各自批量,不等同于一个较大概率产出。含返还约束的不同 ID 行继续保留,由原配方查询呈现完整约束。覆盖说明列出未作为加工关系导入的条目数,不声称支持未注册到 EMI 的加工方式。 -信息页、不完整配方及不支持 ingredient 的条目,按现有物品成分和流体材料绑定关联到材料;复合物品可关联其中各个材料,不能据此推断生产或回收关系。相关条目放在来源区最下方的独立卡片,点击直接打开对应原始 EMI 页面;它们不加入 `Step`、`Connection` 或加工预算。没有加工步骤但存在相关信息的材料仍注册一张可检索的信息页。卡片随画布一起缩放、平移和裁剪,完整标题与参考性质放在 tooltip 中。关联索引与加工端口分开,索引仍只收录页面所属材料。 +通用 `EmiIngredientRecipe` 仅用于标签成员/候选原料消歧,不收进信息区,也不计入加工缺口;JEMI 桥接的 JEI 标签浏览页按保留的 `tag_recipes/` 分类路径同样排除,不依赖翻译标题或 JEI 实现类。GT 自有的材料单位输入说明 `MaterialUnitTagEmiRecipe` 仍保留。其余信息页、不完整配方及不支持 ingredient 的条目,按物品明确声明的主材料和流体材料绑定关联;复合物品的次要成分不扩展关联。相同非空 EMI 配方 ID 的信息入口只保留一份,未提供 ID 的不同页面保持独立。不能据此推断生产或回收关系。 + +相关条目放在来源区最下方的独立卡片,图标取自该材料的关联物品,点击直接打开对应原始 EMI 页面;它们不加入 `Step`、`Connection` 或加工预算。没有加工步骤但存在相关信息的材料仍注册一张可检索的信息页。卡片随画布一起缩放、平移和裁剪,完整标题与参考性质放在 tooltip 中。关联索引与加工端口分开,索引仍只收录页面所属材料。 + +EMI 初始化只从 `materialSteps(root)` 收集本材料资源/角色的检索代表,并按完整原生状态分别去重输入、工具和输出;`getInputs`、`getCatalysts`、`getOutputs` 等索引调用不触发页面查询或布局。实际打开页面的 `addWidgets` 才构造并缓存完整 `Page` 和面板,原始批量、概率、候选和端口仍在详情中。重复调用注册入口先剔除旧总览条目,避免累积旧页面及快照;完成后日志记录材料页数、查看器配方数与耗时。 每次 EMI 重建均替换客户端视图及导航代次;旧页、断线后的页和旧发布的回调失效。JEI 未使用此 EMI 数据源,仍受 GT 原生快照的覆盖范围限制。 @@ -48,37 +53,39 @@ GT 的 `MachineEmiRecipe` 只决定原生行是否进入视图;端口继续使 - `DataKey` 在这里是调用方签发的快照内引用,不是新的材料身份或存档 ID。`Port.resource` 必须区分材料、形态、相态和原生状态;不同 tag/unit 选择器的原生引用保持独立。`Port.identity` 另作展示共享键:完整原生状态或规范选择器描述不包含查询代号及配方专属 selector 后缀;有原生图标时按实际显示代表的完整物品/流体状态识别相关展示实例;多候选 selector 可以与该代表同步高亮,并在总览共享一个资源节点,但原始候选集、消耗量和 guard 仍属于各原生步骤,不声称 selector 与具体物品可互换。不同 NBT/数据组件状态不得仅因图标相同而合并。已有 `MaterialKey`、`FormKey` 与原生匹配引用由后续适配器解析到该引用,不重新建立材料目录。 - `Port` 的 `amount` 必须包含原生批量及单位,如件、U 或 mB。`quantity` 是生产者同时提供的紧凑图标角标(件数、省略为 1 的件数、U、mB 或未知标记),前端不解析 `amount` 文本、不换算、不从图标栈数量推导材料量。旧构造方法默认不显示数量角标。资源图标右下角显示非 1 件数量或带单位的量,左上角显示非必然产出的百分比,未知概率显示 `?%`。共享资源优先采用产出端口的值;同一外观路线的多个产出批量不同时以 `/` 分隔,超过三个不同值用省略号,tooltip 列出原生批量与概率,不取其中一个覆盖其他值。输入概率不绘制,原生批量不从图标栈数量推导。`icons` 为有限代表,空列表表示符号资源;不展开 tag 或 unit 候选全集。使用现有 `FluidDisplayBinding.display(...)` 取得带相态/状态的流体代理物品,不创建另一套流体身份转换。 - `Role.CONSUMED`、`CATALYST`、`PRESENCE` 只用于输入;`PRIMARY`、`BYPRODUCT`、`UNKNOWN` 只用于输出。输入不因为存在数量就自动消耗。无可靠主/副角色时用 `UNKNOWN`,不得按槽位猜测。 -- `main` 是生产者提供的路线提示,每一步的输入和输出分别至多一个。总览显示本材料在该侧的全部消耗输入或产物;该侧没有本材料时,用 `main` 或稳定端口顺序选一个外部主输入/产物。工具、存在条件及其余辅料/额外副产物留在 `+` 中。这不改变原始角色,也不声称一个可见输入就是完整配方。 +- `main` 是生产者提供的路线提示;同侧有多个提示时按原生顺序选择首个,不因提示数量丢弃端口。总览显示本材料在该侧的全部消耗输入或产物;该侧没有本材料时,用 `main` 或稳定端口顺序选一个外部主输入/产物。工具、存在条件及其余辅料/额外副产物留在 `+` 中。这不改变原始角色,也不声称一个可见输入就是完整配方。 - `chance` 使用 `OptionalInt`,已知概率为 1—10000,未知为 `OptionalInt.empty()`,确定产出为 `OptionalInt.of(RecipeOutputChances.CERTAIN)`。输入概率不参与绘制。互斥/共享随机事件、未知相关性和原生状态限制必须放在 `details`;不能用边际概率声称各输出独立。世界生成权重放说明,不能当成掉落概率。 - `Step` 保存同一步的联合输入、多输出及条件;`genericRecovery` 来自宿主同时核对回收归属与配方表的判定,兼容构造方法默认为 `false`。`icon` 是生产者提供的代表机器图标,访问时返回副本;没有可靠机器代表时使用空图标,面板显示问号。`worldGenerated` 由快照的真实世界生成引用设置,不根据空输入、图标或引用字符串猜测;兼容构造方法默认为 `false`。活动世界生成步骤使用镐作为采集符号。普通机器工序复用 EMI 分类的 `RecipeMachines` 索引与 `RecipeViewerIcons.category(...)`,包括锤子等工具类图标;不再只遍历基础机器。机器、时间、能量、温度、维度、选择器、来源等通过 `details` 传入。`resolved=false` 表示原生关系/约束尚未解析,连接为虚线;显示图标仍可执行普通来源/用途查询。`resolved=true` 也不承诺玩家库存可执行。 -- `Connection(source, target, resource, confirmed)` 必须指向当前结果内的两个步骤,且资源同时出现在源步骤输出和目标步骤输入中。前端不按相同物品图标补边;`confirmed=false` 保留为未确认关系。 -- 文本与图标在构造时复制,列表只读,图标访问返回副本。调用方须将传入后取得的 `Component` 及说明视为只读。禁止传 `null`、空物品栈、错误侧角色、重复步骤引用、悬空关联或非法概率;构造/校验时抛出 `IllegalArgumentException`,不把无效数据改成空结果。 +- `Connection(source, target, resource, confirmed)` 必须指向当前结果内的两个步骤,且资源同时出现在源步骤输出和目标步骤输入中。默认材料查询使用 `Flow(resource, sources, targets)` 保存同一精确资源的全部生产者和消费者;每个引用都按原始端口校验。关联数为两侧引用数的乘积,但不展开或分配该乘积数量的对象。确认状态由对应原始 `Step.resolved` 决定;任一未确认生产者仍使相关消费端口保留虚线,包括跨分区关系。前端不按相同物品图标补边;显式 `confirmed=false` 关联继续保留。 +- 文本与图标在构造时复制,列表只读,图标访问返回副本。调用方须将传入后取得的 `Component` 及说明视为只读。展示层剔除空代表图标、错误侧端口、重复步骤及悬空或端口不匹配的关联,并记录日志;删除端口的步骤改为未解析。非法显示概率降为未知。重复关联去重;有效步骤和关联继续保留,剔除记录通过覆盖提示说明。资源引用等不可缺少的对象契约仍要求非空。 -`pages(title, material, steps, connections, notices, navigation)` 生成一张材料页,不执行图遍历、自动规划或步骤分页。当前展示上限为 512 步、4096 条关联、每步每侧 128 个端口、每端口 16 个代表图标;超限直接拒绝。调用方应在查询层按预算取得结果,并提供准确截断原因,不能先全量枚举再交给 UI 截断。 +`pages(title, material, steps, connections, notices, navigation)` 生成一张材料页,不执行图遍历、自动规划或步骤分页。材料页使用紧凑的 `queryMaterial(root)`,保留当前材料全部已发布的直接步骤、端口和资源关联,不再按固定数量截断;查询仍不沿其他材料递归。展示层不再限制调用方已提供的代表图标数;自动采样 tag/unit 图标仍最多十六个,这只限制显示代表,不改变原始选择器。需要有界递归或逐条关联查询的调用方仍可显式使用 `Budgets`,并保留准确截断原因;EMI 注册及默认展示页不能调用无上限的逐条连接展开。 -`notices` 必须非空,通过页脚的 `i` 提示入口悬停显示全部内容。调用方必须说明完整/部分覆盖、未支持族和节点/端口/边预算截断;空结果也必须说明范围。默认 `unbound()` 只表示尚未接线,不能当作“该材料没有来源”。 +`notices` 通过页脚的 `i` 提示入口悬停显示全部内容;空列表补上部分覆盖提示。调用方必须说明完整/部分覆盖、未支持族和节点/端口/边预算截断;空结果也必须说明范围。默认 `unbound()` 只表示尚未接线,不能当作“该材料没有来源”。 ## 布局与交互 -生产查询使用 `MaterialProcessGraph.queryMaterial(...)`:先展开根材料的 ore、raw、crushed、dust、fluid 等全部已发布形态,再收集与任一形态直接相邻的步骤,不沿另一材料的产物继续递归。因此同一材料页同时包含: +生产查询使用 `MaterialProcessGraph.queryMaterial(root)`:先展开根材料的 ore、raw、crushed、dust、fluid 等全部已发布形态,再收集与任一形态直接相邻的步骤,不沿另一材料的产物继续递归。因此同一材料页同时包含: - “来源”:实际消耗非本材料、产出本材料且不消耗本材料的配方,以及明确来自世界生成的本材料。 - “内部转换”:实际消耗并产出本材料形态的步骤;洗矿等含辅料和副产物的转换仍归这里。 - “去向”:实际消耗本材料、产出其他材料且不再产出本材料的配方。 +显式指定有限预算时,端口预算先作用于步骤,再生成连接;被裁掉端口的连接不占连接预算,缺失范围通过端口截断提示呈现。默认材料页保留全部直接端口。展示层按步骤端口建立索引校验连接,错误关联单独剔除并记录日志,不中断整页注册。原生快照逐条隔离无法读取的配方;重复步骤或冲突资源身份的步骤在修改图索引前整条拒绝,不留下半条记录,其他合法步骤继续发布。EMI 采集也按条目隔离运行期读取失败。 + 分类只使用 `CONSUMED` 输入。仅作为催化剂或存在条件出现的本材料不能建立加工流向;无输入但没有世界生成标记的步骤不能据此声称是来源。没有满足上述条件的步骤不纳入这三个材料转换分类,不能把“不是来源”直接当成去向。 通用回收统一由 `MaterialProcessSnapshot.NativeRecipe.genericRecovery()` 判定:配方必须具有 GENERIC 归属,且属于 `MachineRecipeMaps.Shredder`、`Melter` 或 `Smelter`。GENERIC 本身只是配方发布时的兜底优先级,砧敲碎等普通加工也使用它,不能单独作为回收标记。快照索引和展示投影共用此判定,再传给 core 的 `Builder.add(step, genericRecovery)`;不按翻译名称、诊断来源或粉末外观猜测。来源查询不收集通用回收行,材料页只在对应输入材料中把它作为用途保留,且在节点预算之前过滤;预算不足时先保留显式加工,再保留通用回收,仍报告准确截断;普通显式配方的来源关系不变。回收产物在机器旁使用带 `↩` 的独立展示实例,不反向约束主生产链。原始端口、逻辑关联和 viewer 原配方均保留。 -分类按消费输入、产出和真实 worldGenerated 标记决定横向区域:其他材料转入本材料(含世界生成/泉)、本材料内部形态转换、本材料转为其他材料;通用回收独立归入内部转换之后、去向之前的回收区。这些区域共用一张画布、平移、缩放和标题;空区域不占宽度,有内容的相邻区域之间绘制分割线。未能可靠分类的合法步骤放入内部区,不据名称猜测,也不丢弃。未分类、纯符号、无输入或无输出的合法步骤仍保留原始引用。图按**机器图标的完整物品状态+首个可见输出身份+通用回收标记**直接合并相似路线;没有可见输出时才比较输入身份集合;次要输出不同的变体共用机器,其输出分支取可见端口的并集,并保留各自原生归属;数量、条件、辅料、特殊工艺 method 或不同原生引用不再强制复制一条外观相同的路线。无图标工序没有可靠外观身份,仍按引用区分。 +分类按消费输入、产出和真实 worldGenerated 标记决定横向区域:其他材料转入本材料(含世界生成/泉)、本材料内部形态转换、本材料转为其他材料;通用回收独立归入内部转换之后、去向之前的回收区。这些区域共用一张画布、平移、缩放和标题;空区域不占宽度,有内容的相邻区域之间绘制分割线。未能可靠分类的合法步骤放入内部区,不据名称猜测,也不丢弃。未分类、纯符号、无输入或无输出的合法步骤仍保留原始引用。各区的折叠只比较机器图标的完整物品状态与完整可见输入身份集合或完整可见输出身份集合;工艺 ID、翻译标题、特殊工艺 method、隐藏辅料及条件不参与折叠。缺少可靠机器图标时不合并。仅有相同首产物不足以合并不同的完整产物集合;数量、概率和不同原生引用不单独复制外观相同的路线。 -相同机器和首产物的路线直接共用机器,不再以输入形态数、次要产物、概率、批量或隐藏辅料作为拆分条件。不同输入形态排列为三列网格;原生配方的联合输入仍完整保留。此处的共用表示可选路线,不能据此把各格输入解释为一次执行需要同时消耗,也不能把变体输出并集解释为一次执行同时产出。未知图标仍按原生引用区分。 +同图标下,相同完整可见输入的多个产物或相同完整可见产物的替代输入可以共用机器。优先折叠覆盖步骤最多的一侧,相同时优先输出;已归组步骤不会通过另一侧继续连锁合并,避免把 A→X、A→Y、B→Y 暗示成不存在的 B→X。不同输入和输出形态排列为三列网格;原生配方的联合输入仍完整保留。此处的共用表示可选路线,不能据此把各格输入解释为一次执行需要同时消耗,也不能把变体输出并集解释为一次执行同时产出。 合并只作用于总览:`Node.steps` 保留全部原生步骤;每条可见边的 `endpoints()` 保留全部 `Endpoint(step, output, index, port)`。原生配方、选择器约束、数量、概率与 viewer 检索索引不合并或删除。此图不用于推断配方执行等价性。 -同一 `Port.identity` 在整图优先共享一个资源节点,即使来自不同 selector 或快照资源引用;不同完整 NBT/组件状态仍分开。点击只查询当前显示物品/流体的普通来源或用途,不再把一个节点绑定到任意一条原生配方。`Connection` 仍原样保留,不因展示共享新增逻辑关联。 +同一 `Port.identity` 在整图优先共享一个资源节点,即使来自不同 selector 或快照资源引用;不同完整 NBT/组件状态仍分开。点击只查询当前显示物品/流体的普通来源或用途,不再把一个节点绑定到任意一条原生配方。`Connection`/`Flow` 仍原样保留,不因展示共享新增逻辑关联。 -各区分别排布可见依赖并横向拼接,跨区重复材料使用带标记的实例,不用长线穿过分割线;原始跨区 Connection 仍保留并可反查。区内依赖图按稳定引用遍历,解除反馈边的前向层级约束后计算 DAG 层级;纯环与自环保留方向和标记。相邻层优先按原生端口顺序对齐首个可见输出和首个可见输入,再参考连接度和链长;该排布优先级不会把未知角色改成 PRIMARY。同一机器的多个本材料产物按端口顺序紧挨排成至多三列的网格,输入替代形态使用相同网格;必要时为共享端口创建可反查的局部实例。网格与机器共用一根输入线或输出箭头,每个物品格仍独立命中、查询和显示角标。链段和网格按整体包围盒预留矩形空间后一起排布,并做四轮邻接重心排序,减少交叉;不因连接度大于阈值就拆散公共物品。边跨越超过三层、纵向距离超过 128 单位、穿过中间节点或属于反馈边时,将该端口改为机器附近的局部资源副本,再重新排布。次要输出离机器超过两行时也使用局部副本,避免副产物远离所属配方。每个可见端口最多拆出一个副本,短距离连续主链和邻近分支仍共享资源。建立局部副本后只按可见边计算层级,保留的逻辑 Connection 不再预留远处的隐形依赖列。互不相连的路线按各自网格宽度压紧横向列和空行,再按矩形尺寸就近排列成多列,避免短配方被最长链或其他路线的网格宽度撑开。 +各区分别排布可见依赖并横向拼接,跨区重复材料使用带标记的实例,不用长线穿过分割线;原始跨区 Connection/Flow 仍保留并可反查。区内依赖图按稳定引用遍历,解除反馈边的前向层级约束后计算 DAG 层级;纯环与自环保留方向和标记。相邻层优先按原生端口顺序对齐首个可见输出和首个可见输入,再参考连接度和链长;该排布优先级不会把未知角色改成 PRIMARY。同一机器的多个本材料产物按端口顺序紧挨排成至多三列的网格,输入替代形态使用相同网格;必要时为共享端口创建可反查的局部实例。网格与机器共用一根输入线或输出箭头,每个物品格仍独立命中、查询和显示角标。链段和网格按整体包围盒预留矩形空间后一起排布,并做四轮邻接重心排序,减少交叉;不因连接度大于阈值就拆散公共物品。边跨越超过三层、纵向距离超过 128 单位、穿过中间节点或属于反馈边时,将该端口改为机器附近的局部资源副本,再重新排布。次要输出离机器超过两行时也使用局部副本,避免副产物远离所属配方。每个可见端口最多拆出一个副本,短距离连续主链和邻近分支仍共享资源。建立局部副本后只按可见边计算层级,保留的逻辑 Connection 不再预留远处的隐形依赖列。互不相连的路线按各自网格宽度压紧横向列和空行,再按矩形尺寸就近排列成多列,避免短配方被最长链或其他路线的网格宽度撑开。 共享面板的常规悬停只显示实际物品/机器名称;EMI 节点使用原生槽位 tooltip;无原生图标时使用符号名称。机器右上角 `+` 的独立悬停区域显示合并配方数和去重后的辅料名称,最多列出十二项;完整配方信息通过 viewer 普通查询查看。局部副本与回流仍有 `↗`/`↩` 标记,相同物品实例同步悬停高亮,连线不随悬停变色。 diff --git a/docs/development/material-process-layout.md b/docs/development/material-process-layout.md index 785309233..96e5e59f1 100644 --- a/docs/development/material-process-layout.md +++ b/docs/development/material-process-layout.md @@ -10,7 +10,7 @@ 规模增大时增加画布面积,利用现有平移与缩放浏览。默认构图优先保证物品和箭头可辨认,不强制把整图缩到一个小视口。该方案接受资源图标重复和较长画布,以减少交叉、长连线与额外查找操作。 -范围仍是当前有界查询返回的 `Page`。布局不递归补查其他材料、不扫描配方表、不把“图中没有来源”解释为不可获得,也不把潜在路线解释为玩家库存可执行的生产计划。 +范围是当前材料直接关联查询返回的 `Page`,不按固定步骤数、端口数或关联数截断。布局不递归补查其他材料、不扫描配方表、不把“图中没有来源”解释为不可获得,也不把潜在路线解释为玩家库存可执行的生产计划。 ## 图形规则 @@ -39,7 +39,7 @@ | 对象 | 必须保存的信息 | | --- | --- | | 逻辑步骤 | `Step.reference`、全部原始端口、条件、原生配方引用和解析状态 | -| 逻辑关联 | 原始 `Connection` 及其资源、源步骤、目标步骤、确认状态 | +| 逻辑关联 | 原始 `Connection` 或精确资源的 `Flow` 生产者/消费者引用,以及原始步骤确认状态 | | 端口关联 | 步骤、输入/输出侧、端口位置、角色,以及该端口的原始 `Port` | | 资源展示实例 | 独立的实例键、展示共享键、对应的端口关联、是否副本及实例位置 | | 工序展示实例 | 对应全部原始步骤引用及位置;视觉重复的路线共享实例 | @@ -55,7 +55,7 @@ ## 展示去重与原生事实分离 -相似路线按机器图标完整状态、首个可见输出身份和通用回收标记直接合并,没有可见输出时才比较输入身份集合。次要输出存在差异的变体共用机器,并保留全部可见输出分支及其原生归属;它不表示这些分支会在同一次执行中同时产出。不同 `Step.reference`、辅料、数量、条件或 method 仍保存于原始步骤,但不再要求总览重复显示相同图形。未知图标没有可靠外观键,不能只因同为问号就合并。 +相似路线在各分区内只按机器图标完整状态及一侧完整可见身份集合合并。相同完整可见输入允许聚合可选产物,相同完整可见输出允许聚合替代输入;只共享首产物的不同产物集合保持分开。聚合仍保留全部可见分支及其原生归属,不表示这些分支会在同一次执行中同时产出。不同 `Step.reference`、辅料、数量、条件或 method 仍保存于原始步骤,但不再要求总览重复显示相同图形。未知图标没有可靠外观键,不能只因同为问号就合并。 所有原生步骤、端口、选择器、单位、概率及关联原样保留,合并边可以反查全部原始端口;它不改变配方注册项或 viewer 索引,也不声称执行等价。原生配方重复采集仍需在事实产生处处理,不能通过视觉合并掩盖数据问题。 @@ -83,7 +83,7 @@ 将适合连续阅读的链段尽量放在同一水平线上,外观不同的替代路线及分叉就近排列。交汇点不能无条件合并所有相邻链段,否则一个公共原料会把全图重新拉成一个大团。这里的链段只用于坐标分配,不生成带工艺名称的分区,不删除原始步骤,也不要求玩家进入链段后才能阅读。 -同一机器的本材料多产物按原生端口顺序紧邻排成至多三列、自动换行的物品栏网格,共用一根输出箭头。同机器图标和首产物的替代路线共用机器,不要求输入形态数、次要产物、概率或隐藏辅料相同;输入形态使用相同的网格与一根输入线。共享资源必要时采用局部实例;格子仍保留原生端口、独立导航和角标。链和网格按整块矩形预留空间后一起分配位置,并进行四轮邻接重心排序;随后按实际节点包围盒压紧和避让。局部副本只受可见边约束,原始 Connection 保留用于反查与确认状态,不再占据隐形依赖列。独立连通块使用各自的列宽、移除空行,再按矩形尺寸紧凑排列成多列;不同路线不会共用最长链和最宽网格的占位。优化顺序为:不遮挡节点与文字、减少交叉、保持连续链水平、缩短连线,再减少画布面积。相同快照输入顺序变化时,稳定引用应保证结果可重复;悬停和高亮不得触发布局。 +同一机器的本材料多产物按原生端口顺序紧邻排成至多三列、自动换行的物品栏网格,共用一根输出箭头。相同机器图标下,完整可见输入相同的多个产物,或完整可见产物相同的替代输入,可以共用机器;数量、概率和隐藏辅料差异仍保留在原始端口中。优先折叠覆盖步骤最多的一侧,相同时优先输出;已归组步骤不再经另一侧连锁合并,避免把 A→X、A→Y、B→Y 画成暗示 B→X 的输入/输出笛卡尔积。工艺分类、特殊方法和隐藏详情不参与视觉折叠;未知机器图标保持独立。输入和输出形态均使用相同的网格与一根相应连线。共享资源必要时采用局部实例;格子仍保留原生端口、独立导航和角标。链和网格按整块矩形预留空间后一起分配位置,并进行四轮邻接重心排序;随后按实际节点包围盒压紧和避让。局部副本只受可见边约束,原始 Connection 保留用于反查与确认状态,不再占据隐形依赖列。独立连通块使用各自的列宽、移除空行,再按矩形尺寸紧凑排列成多列;不同路线不会共用最长链和最宽网格的占位。优化顺序为:不遮挡节点与文字、减少交叉、保持连续链水平、缩短连线,再减少画布面积。相同快照输入顺序变化时,稳定引用应保证结果可重复;悬停和高亮不得触发布局。 ### 选择资源局部副本 @@ -121,7 +121,7 @@ | 入口 | 当前职责 | | --- | --- | -| `MaterialProcessSnapshot` / `MaterialProcessGraph` | 继续作为事实与有界查询来源;图布局不额外枚举数据。重复采集如需修复,单独定位事实来源 | +| `MaterialProcessSnapshot` / `MaterialProcessGraph` | 继续作为事实与材料直接关联查询来源;图布局不额外枚举数据。重复采集如需修复,单独定位事实来源 | | `MaterialProcessProjection` / `MaterialProcessDisplay` | 保留完整原生步骤、端口及确认关联,不以图标推断关系;副本实例属于布局结果,不成为新的 `DataKey` 或配方事实 | | `MaterialProcessOverview` | 按原生端口和已提供关联计算依赖层级、连续链、副本与路径;保留原始端口反查 | | `MaterialProcessPanel` / `MaterialProcessArrows` | 消费布局结果,绘制主材料图、副本和回流;调整默认缩放与复位,统一实例命中和裁剪 | @@ -131,7 +131,7 @@ 布局按快照/页面、视口相关尺寸及字体尺寸缓存。平移、缩放和悬停不能每帧重算全图;重载或 generation 变化时释放旧实例和回调。渲染时可以做视口裁剪,但所有已查询节点仍须存在于布局中,不能把离屏节点当作删除或截断。 -当前 `MaterialProcessDisplay` 接受最多 512 步、4096 条关联、每步每侧 128 个端口、每端口 16 个图标。这些是现行输入边界;752 步的浏览器演示只是界面压力样例,不证明生产页可接收该输入,也不构成提高上限的决定。 +当前材料页不设固定步骤、关联或端口上限,查询范围限于根材料的直接关联。关系按精确资源保存为 `Flow` 的生产者/消费者引用,两侧数量相乘只用于统计,初始化与布局均不展开该乘积。EMI 注册只保留去重的本材料检索代表与页面工厂,打开页面时才查询完整步骤、紧凑关系和布局。自动采样的选择器图标最多十六个;显式提供的图标列表不受该采样数限制。坏记录记录日志后单独剔除,并保留覆盖提示;展示校验采用端口索引,折叠复用已计算的可见端口,布局不反复扫描同一合并机器的全部端口来判断主连线。浏览器压力演示仍不代替生产页的游戏性能验收。 副本最多恢复到每个可见原始端口一个实例,资源实例总数不超过可见端口数;工序数不超过原始步骤数。该内部成本界限不删除步骤或原始端口,辅料和副产物仍留在工序详情。查询已截断时继续显示准确的覆盖提示,不显示“完整生产链”。 @@ -149,7 +149,7 @@ | 相同图标,不同原生状态或 selector | 原始约束与导航目标保留,不产生伪关联或任意替换 | | 同名机器、同 A/B,条件或辅料不同 | 总览合并相同外观,保留所有原始步骤;图标点击执行普通来源/用途查询 | | 纯符号资源、未知来源、未确认连接 | 保留节点与范围说明,不猜世界生成,不把回流等同于未确认 | -| 百步及接近现行上限的图 | 节点/文字不重叠,箭头不穿节点;保持可读比例,布局成本有界 | +| 百步、超过旧数量限制及大端口配方 | 节点/文字不重叠,箭头不穿节点;保持可读比例,布局成本有界 | | 相同快照打乱输入顺序 | 布局稳定;每个输入输出均能反查到原始端口 | | 缩放、平移、GUI 缩放与重载 | 命中和图标一致,旧快照无法跳转,无离屏误删 | diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index d85dbc1d2..919984e4d 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -40,7 +40,7 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe 材料领域的 `MaterialBaselineTests` 验证存储块的成分与两类准入、72U 附魔金苹果的规划和实际回收输出、复合钻头、耐久缩放、容器与有形状铸模、压模机模具、固体/流体分解及 test-source 材料 SPI。`material_baseline_reload` 为仅含一个测试的独立批次,等待两次真实资源重载;拥有规则数和固定样例必须稳定。原始投影写入根目录 `work/material-system-refactor/runtime//<运行目录>/`。已知错误行为明确标为观察,不能当作正确性依据;字段、复现与未覆盖范围见[材料基线报告](../../../integration/material-baseline.md)。 -`MaterialProcessSnapshotTests` 的 viewer 用例验证选中的原生机器行去重、未选行排除、工作台数量与工作站、活动世界生成保留,以及单槽候选、跨材料候选、完整原生状态和输出概率;还确认信息卡片位于来源下方、信息页单独存在时仍保留来源区、页面检索限于本材料且不生成加工节点或边。它们不启动 EMI,不能代替最终配方列表 Mixin、信息页过滤及第三方集成的客户端验收。 +`MaterialProcessSnapshotTests` 的 viewer 用例验证选中的原生机器行去重、未选行排除、工作台数量与工作站、活动世界生成保留,材料单位模板与非树加工的确认状态,以及单槽候选、跨材料候选、完整原生状态和输出概率;还确认信息卡片位于来源下方、信息页单独存在时仍保留来源区、页面检索限于本材料且不生成加工节点或边。160 槽 viewer 配方通过 `MaterialProcessProjection.initialPages` 检查默认完整端口与连接,显式有限预算仍检查截断一致性及覆盖提示;608 步及 4800 条逻辑关联验证默认材料页不受旧上限截断,关联保存为一个资源分组而非 4800 个连接对象,索引只保留唯一资源/角色;跨分区未确认来源仍使消费端口呈虚线。core 的 `MaterialProcessGraphTest` 另以 20001 步、100020001 条隐含关联验证线性规模的资源引用表示,并与小图逐条连接核对等价性。折叠回归覆盖完整可见输入/输出、忽略工艺 ID 和 method 等隐藏信息、不同机器状态、未知图标保持独立、禁止连锁误合并及输入顺序稳定;坏端口、重复步骤、悬空关联及原生坏配方验证日志隔离和其余数据保留。它们不启动 EMI,不能代替最终配方列表 Mixin、信息页过滤及第三方集成的客户端验收。 `decompositionRespectsFormsAndExactFluidIdentities` 通过测试 SPI 声明 dust-only、blockDust-only、liquid-only 和 gas-only 分解,检查形态限制、流体输入不会错误抑制允许的固体兜底、本体完整 ID、附属完整 ID/旧裸路径、外部原版流体 ID、未知及非法 ID,以及附属流体输出的身份和数量。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 93839d042..934abaac7 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -22,13 +22,13 @@ 接口与测试输入契约见[展示接入](../../material-process-display.md)。生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用展示模型和面板;EMI 从最终可见配方构造视图,JEI 使用 GT 原生快照。 -EMI 数据源还需核对:工作台压块/拆块、熔炉和已安装第三方机器均进入材料页,GT 机器不重复;材料标签查询、结构与其他信息页不产生加工边;`supportsRecipeTree=false`、缺少输入/输出及不支持 ingredient 类型的条目仅保留为相关信息;来源区底部的信息卡片应直接打开对应原页面,只有相关信息的材料也能查询;全屏和嵌入视图下均核对点击、tooltip、平移缩放与裁剪。任一不支持槽不能静默消失。tag 的同材料候选保持一个 selector,跨材料候选不归到任一单一材料。隐藏、延迟注册、资源重载与重新入服后页面跟随当前配方,旧导航失效。未安装 EMI 时确认客户端及专用服务端不加载 EMI 类型;JEI 单独核对其原生快照覆盖范围。 +EMI 数据源还需核对:工作台压块/拆块、熔炉和已安装第三方机器均进入材料页,GT 机器不重复;包含空网格的有序合成进入加工图,不因占位变成信息卡片;没有实际输入的行不能成为加工来源。通用物品/方块/流体标签及候选浏览页不出现在信息区;GT 材料单位输入说明仍可打开。GT 材料单位模板即使 `supportsRecipeTree=false` 仍保留原生材料单位与概率;工具装配和可读取的第三方非树加工进入图中并使用未确认关系。结构、说明、动态模式与木桶查询别名不产生加工边;缺少输入/输出及不支持 ingredient 类型的条目仅保留为相关信息。零数量工具只作为催化剂,不使整条配方降级。相同 EMI ID,以及同分类下仅注册 ID、槽位顺序或网格占位不同的等价加工行不重复;数量、概率、原生状态或工具不同的行继续保留。关联只取明确主材料/流体绑定,次要成分不带入额外信息卡片;相同非空 EMI ID 的信息页不重复。来源区底部的信息卡片应使用本材料图标并直接打开对应原页面,只有相关信息的材料也能查询;全屏和嵌入视图下均核对点击、tooltip、平移缩放与裁剪。任一不支持槽不能静默消失。超过每侧 128 槽、512 步或 4096 条关联时,确认默认材料页保留全部直接数据且重载可完成;人为指定有限预算时才出现相应截断提示。加入坏记录时应有诊断日志和覆盖提示,其余有效路线仍可查询。tag 的同材料候选保持一个 selector,跨材料候选不归到任一单一材料。隐藏、延迟注册、资源重载与重新入服后页面跟随当前配方,旧导航失效。EMI 初始化和连续重载不能提前构造所有材料图或展开生产者/消费者的连接乘积;日志应出现材料索引完成记录。检索输入、工具及产物不按配方出现次数重复,首次打开才构建详情,仍须保留完整原生批量及概率。未安装 EMI 时确认客户端及专用服务端不加载 EMI 类型;JEI 单独核对其原生快照覆盖范围。 1. 在 JEI/EMI 中打开真实材料的“矿物处理”。页面应直接显示同一张画布上有内容的来源/内部转换/回收/去向区域、区标题与相邻区域分割线,空区域不留占位;世界生成和泉进入来源区;无切换或分页。连续链水平向右,替代路线和分叉就近分行;未分类步骤、无外部入口环及自环不能消失。不同 GUI 缩放下右侧、底部裁剪正确。 -2. 切割机三种润滑剂相同主物品/机器图标/首产物时只显示一条路线,次要输出不同也应共用机器、保留各分支,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。EMI 物品和机器使用原生槽位,确认自定义来源/用途绑定、点击释放、R/U、收藏及拖动物品均与普通 EMI 槽位一致,不精确锁定原配方;JEI 沿用普通来源/用途 focus;EMI 使用原生 tooltip,JEI 常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。非 1 件产量、U/mB 和非必然概率在图标上可见,精度保留至原生百分比;确定的 1 件产出不加数量/概率角标,未知概率显示 `?%`。共享资源采用生产端口的量,多个变体的不同量显示多值/省略号并可悬停查看;时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 +2. 切割机三种润滑剂相同机器图标和完整可见输入或输出时只显示一条路线;仅首产物相同而其他可见产物不同、输入又不同的路线保持独立,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。EMI 物品和机器使用原生槽位,确认自定义来源/用途绑定、点击释放、R/U、收藏及拖动物品均与普通 EMI 槽位一致,不精确锁定原配方;JEI 沿用普通来源/用途 focus;EMI 使用原生 tooltip,JEI 常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。非 1 件产量、U/mB 和非必然概率在图标上可见,精度保留至原生百分比;确定的 1 件产出不加数量/概率角标,未知概率显示 `?%`。共享资源采用生产端口的量,多个变体的不同量显示多值/省略号并可悬停查看;时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 3. 资源局部副本带 `↗`,回流带 `↩`。悬停只突出相同物品的全部实例,机器图标也按真实物品匹配;其他资源、机器和连线均不跟随高亮,移到空白清除。不同 NBT/组件状态分开,流体副本按完整显示身份匹配。查询目标持续显示淡绿色外框,移开鼠标后仍保留。每条配方有较浅外框,独立小配方容易区分,共享端口与网格不能使边框包住相邻机器。连接为单段直线,分支斜连,输入无箭头、输出有箭头;回流不占顶部通道,确认关系不因循环改为虚线。 4. 对带 NBT/组件物品与真实流体,逐个副本检查左/右击、R/U、tooltip 和 EMI ingredient provider;流体代理应查询实际流体。各节点使用实际显示的完整物品/流体状态查询,无法恢复时保留符号,不用无数据假栈。 -5. 来源/内部转换/回收/去向决定横向分区,不依据机器名称分组;“本材料+辅料 → 本材料其他形态+副产物”仍属内部转换。工具、存在条件及额外辅料/副产物均不扩展生产路线。主材料的多输入、多输出分支仍保留。相同机器和首产物的替代形态应折叠为三列网格,共用一根输入线;用多种木材产树皮的路线确认辅料、输入形态数、次要产物、批量和概率不同也会合并,差异可在普通配方查询中查看。透镜或螺栓加工等本材料多输出按端口顺序紧邻排成至多三列网格,共用输出箭头;共享资源也不能把产物挤到其他配方之外。逐格验证原生查询、悬停和 EMI 命中;同一组矩形内部不能插入其他路线的节点或连线。通用研磨/熔化回收配方同时核对 GENERIC 归属及 Shredder/Melter/Smelter 配方表,砧敲碎等普通加工不得进入回收区或被从材料来源中隐藏;回收途径在内部转换后、去向前的独立回收区展示,不能因产出少量粉末就铺成粉末来源;显式来源配方仍应存在。 +5. 来源/内部转换/回收/去向决定横向分区,不依据机器名称分组;“本材料+辅料 → 本材料其他形态+副产物”仍属内部转换。工具、存在条件及额外辅料/副产物均不扩展生产路线。主材料的多输入、多输出分支仍保留。同机器图标下,完整共同可见输入加工成多个产物,以及完整可见产物相同的替代输入应折叠为三列网格;完整共同输入不同不能仅因其中一个原料相同就按输入折叠。不能将 A→X、A→Y、B→Y 连锁合并而暗示不存在的 B→X;工艺 ID、翻译标题和 method 等隐藏信息不应阻止相同可见路线折叠;机器图标的原生状态不同或缺少可靠图标时保持独立。网格共用一根输入或输出线;用多种木材产树皮的路线确认隐藏辅料、批量和概率不同不阻止折叠;本材料的次要产物必须参与完整输出集合比较,差异可在普通配方查询中查看。透镜或螺栓加工等本材料多输出按端口顺序紧邻排成至多三列网格,共用输出箭头;共享资源也不能把产物挤到其他配方之外。逐格验证原生查询、悬停和 EMI 命中;同一组矩形内部不能插入其他路线的节点或连线。通用研磨/熔化回收配方同时核对 GENERIC 归属及 Shredder/Melter/Smelter 配方表,砧敲碎等普通加工不得进入回收区或被从材料来源中隐藏;回收途径在内部转换后、去向前的独立回收区展示,不能因产出少量粉末就铺成粉末来源;显式来源配方仍应存在。 6. 独立路线应紧凑排列成多列,局部副本不在远处预留依赖列,短配方也不被其他路线的宽网格撑开。分别查询原料、粉末、锭、零件与真实流体,材料总览只匹配页面所属材料,不能因另一材料配方使用了该物品作辅料、催化剂或外来副产物而出现。每次查询打开与复位均为 100%,查询的具体物品/流体节点位于视口中心;无目标时定位代表链。先平移、缩放再查询另一形态及同一形态,确认缓存视图也会重新定位;不同 NBT/组件状态分别确认。滚轮围绕鼠标缩放,顶部 `−/+` 缩放;空白处左右、上下拖动有效。在 100%、25% 和约 8% 比例下确认线宽、虚线间距及箭头与图标同比缩小,不出现盖住整图的固定尺寸箭头。缩放和平移后,图标、`+`、tooltip、点击及 EMI 悬停命中一致。 调整窗口尺寸及 GUI 缩放后,视口、按钮、裁剪与原生命中应一起变化;右上角全屏按钮展开到窗口,Esc 或按钮返回原查看器。全屏、返回及窗口变化均保留中心世界坐标和缩放;验证全屏中的 JEI/EMI 来源/用途、快捷键、收藏及拖拽,流体仍查询真实流体。 7. 连续重载两次后确认配方增删同步、旧引用拒绝跳转;断线/换服不沿用回调。布局副本数不改变配方数量或原生 viewer 索引;方法标签只来自 API target/reagent 声明。 8. 两平台分别检查 JEI-only、EMI-only 和双装环境,双装沿既有去重规则。另验无 viewer 的专用服务端与独立远程客户端;未实际执行的场景不能用编译或集成服务器静态表代替。 diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java index 65cbcb735..678cf40ac 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java @@ -182,9 +182,8 @@ public void draw(GuiGraphics graphics, double mouseX, double mouseY) { outline(graphics, node.x - 13, node.y - 13, node.x + 14, node.y + 14, 0xffa7dba0); outline(graphics, node.x - 12, node.y - 12, node.x + 13, node.y + 13, 0xffbce7b6); } - ItemStack icon = node.machine() - ? selected(node).icon() - : node.port().icons().stream().findFirst().orElse(ItemStack.EMPTY); + ItemStack icon = + node.machine() ? selected(node).icon() : node.port().icon(); if (icon.isEmpty()) text(graphics, Component.literal("?"), node.x - 3, node.y - 4, 10, MUTED); else graphics.renderItem(icon, node.x - 8, node.y - 8); if (!node.machine()) { @@ -263,7 +262,7 @@ public List stacks(Node node) { return selected(node).icon().isEmpty() ? List.of() : List.of(selected(node).icon()); - return node.port().hasIcons() ? List.of(node.port().icons().get(0)) : List.of(); + return node.port().hasIcons() ? List.of(node.port().icon()) : List.of(); } public List tooltip(double mouseX, double mouseY) { @@ -291,9 +290,7 @@ public List tooltip(double mouseX, double mouseY) { } Node node = hit(mouseX, mouseY); if (node == null) return List.of(); - ItemStack icon = node.machine() - ? selected(node).icon() - : node.port().icons().stream().findFirst().orElse(ItemStack.EMPTY); + ItemStack icon = node.machine() ? selected(node).icon() : node.port().icon(); Component name = icon.isEmpty() ? (node.machine() ? selected(node).name() : node.port().name()) : icon.getHoverName(); @@ -320,7 +317,7 @@ public List tooltip(double mouseX, double mouseY) { lines.add(Component.translatable("gt6ce.jei.material_process.variants", node.steps.size())); var names = new java.util.LinkedHashMap(); for (var port : node.auxiliaries) { - Component label = port.hasIcons() ? port.icons().get(0).getHoverName() : port.name(); + Component label = port.hasIcons() ? port.icon().getHoverName() : port.name(); names.putIfAbsent(label.getString(), label); } lines.addAll(names.values().stream().limit(12).toList()); diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java index 962ef13d6..543ef3a9b 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java @@ -1,25 +1,27 @@ package gregtech.compat.common; +import com.mojang.logging.LogUtils; import gregtech.api.addon.material.DataKey; import gregtech.api.addon.recipe.RecipeOutputChances; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Objects; import java.util.OptionalInt; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; +import org.slf4j.Logger; /** - * Client presentation values for an already bounded process query. This is not a source index or an execution model. + * Client presentation values for a material process query. This is not a source index or an execution model. * No material catalog, native recipe enumeration, or viewer API is accessed here. */ public final class MaterialProcessDisplay { - public static final int MAX_STEPS = 512; - public static final int MAX_PORTS = 128; + private static final Logger LOGGER = LogUtils.getLogger(); + /** Only limits automatic icon sampling from selectors, never steps, ports or supplied representatives. */ public static final int MAX_ICONS = 16; - public static final int MAX_CONNECTIONS = 4096; /** Roles come from the producer; neither slot order nor quantity establishes a primary output. */ public enum Role { @@ -52,19 +54,27 @@ public record Port( public Port { Objects.requireNonNull(resource); Objects.requireNonNull(identity); - if (material == null || material.isBlank()) - throw new IllegalArgumentException("Missing process port material"); + if (material == null || material.isBlank()) { + LOGGER.warn("Missing material for process resource {}; retaining it as unknown", resource); + material = "unknown"; + } name = name.copy(); amount = amount.copy(); quantity = quantity.copy(); Objects.requireNonNull(role); Objects.requireNonNull(chance); - if (icons.size() > MAX_ICONS) throw new IllegalArgumentException("Too many display representatives"); - icons = icons.stream().map(ItemStack::copy).toList(); - if (icons.stream().anyMatch(ItemStack::isEmpty)) - throw new IllegalArgumentException("Use an empty icon list for symbolic resources"); - if (chance.isPresent() && (chance.getAsInt() < 1 || chance.getAsInt() > RecipeOutputChances.CERTAIN)) - throw new IllegalArgumentException("Invalid output chance"); + var validIcons = icons.stream() + .filter(Objects::nonNull) + .filter(stack -> !stack.isEmpty()) + .toList(); + if (validIcons.size() != icons.size()) + LOGGER.warn("Discarded {} empty display icons for {}", icons.size() - validIcons.size(), resource); + icons = validIcons.stream().map(ItemStack::copy).toList(); + if (chance.isPresent() && (chance.getAsInt() < 1 || chance.getAsInt() > RecipeOutputChances.CERTAIN)) { + LOGGER.warn( + "Invalid display chance {} for {}; retaining an unknown chance", chance.getAsInt(), resource); + chance = OptionalInt.empty(); + } details = copyText(details); } @@ -104,6 +114,14 @@ public boolean hasIcons() { return !icons.isEmpty(); } + public int iconCount() { + return icons.size(); + } + + public ItemStack icon() { + return icons.isEmpty() ? ItemStack.EMPTY : icons.get(0).copy(); + } + public List tooltip() { var lines = new ArrayList(); lines.add(name); @@ -130,7 +148,20 @@ public record Connection(DataKey source, DataKey target, DataKey resource, boole } } - /** All co-inputs and outputs belong to this one step. Main is a layout hint, separate from the output role. */ + /** All exact source/target associations for one resource, stored without allocating their cross-product. */ + public record Flow(DataKey resource, List sources, List targets) { + public Flow { + Objects.requireNonNull(resource); + sources = List.copyOf(sources); + targets = List.copyOf(targets); + } + + public long connectionCount() { + return (long) sources.size() * targets.size(); + } + } + + /** All ports belong to one step. Process is the producer's stable category, independent of the translated name. */ public record Step( DataKey reference, Component name, @@ -141,17 +172,20 @@ public record Step( java.util.Optional specialProcess, boolean resolved, boolean worldGenerated, - boolean genericRecovery) { + boolean genericRecovery, + String process) { public Step { Objects.requireNonNull(reference); name = name.copy(); icon = icon.copy(); - inputs = List.copyOf(inputs); - outputs = List.copyOf(outputs); - validatePorts(inputs, false); - validatePorts(outputs, true); + var validInputs = validPorts(inputs, false, reference); + var validOutputs = validPorts(outputs, true, reference); + resolved &= validInputs.size() == inputs.size() && validOutputs.size() == outputs.size(); + inputs = validInputs; + outputs = validOutputs; details = copyText(details); Objects.requireNonNull(specialProcess); + Objects.requireNonNull(process); } @Override @@ -159,6 +193,31 @@ public ItemStack icon() { return icon.copy(); } + public Step( + DataKey reference, + Component name, + ItemStack icon, + List inputs, + List outputs, + List details, + java.util.Optional specialProcess, + boolean resolved, + boolean worldGenerated, + boolean genericRecovery) { + this( + reference, + name, + icon, + inputs, + outputs, + details, + specialProcess, + resolved, + worldGenerated, + genericRecovery, + name.getString()); + } + public Step( DataKey reference, Component name, @@ -293,7 +352,7 @@ public boolean openForm(DataKey resource, boolean uses) { }; default boolean openPort(Port port, boolean uses) { - return port.hasIcons() && openStack(port.icons().get(0), uses); + return port.hasIcons() && openStack(port.icon(), uses); } default boolean openStack(ItemStack stack, boolean uses) { @@ -317,20 +376,47 @@ public record Page( int number, int total, Navigation navigation, - List information) { + List information, + List flows) { public Page { title = title.copy(); - if (material == null) throw new IllegalArgumentException("Missing process page material"); - steps = List.copyOf(steps); - connections = List.copyOf(connections); + material = Objects.requireNonNullElse(material, ""); + int suppliedSteps = steps.size(), suppliedConnections = connections.size(), suppliedFlows = flows.size(); + steps = validSteps(steps); + var ports = new PortIndex(steps); + connections = validConnections(connections, ports); + flows = validFlows(flows, ports); notices = copyText(notices); + if (notices.isEmpty()) + notices = List.of(Component.translatable("gt6ce.jei.material_process.partial_unknown")); + int discarded = suppliedSteps + - steps.size() + + suppliedConnections + - connections.size() + + suppliedFlows + - flows.size(); + if (discarded > 0) { + var coverage = new ArrayList<>(notices); + coverage.add(Component.translatable("gt6ce.jei.material_process.coverage.invalid_data", discarded)); + notices = List.copyOf(coverage); + } information = List.copyOf(information); Objects.requireNonNull(navigation); - if (steps.size() > MAX_STEPS - || connections.size() > MAX_CONNECTIONS - || number < 1 - || total < number - || notices.isEmpty()) throw new IllegalArgumentException("Invalid process display page"); + number = Math.max(1, number); + total = Math.max(number, total); + } + + public Page( + Component title, + String material, + List steps, + List connections, + List notices, + int number, + int total, + Navigation navigation, + List information) { + this(title, material, steps, connections, notices, number, total, navigation, information, List.of()); } public Page( @@ -346,7 +432,8 @@ public Page( } public Page withInformation(List information) { - return new Page(title, material, steps, connections, notices, number, total, navigation, information); + return new Page( + title, material, steps, connections, notices, number, total, navigation, information, flows); } /** Foreign reagents and byproducts belong to the recipe, not to this material's viewer index. */ @@ -371,24 +458,6 @@ public static List pages( List connections, List notices, Navigation navigation) { - if (steps.size() > MAX_STEPS) throw new IllegalArgumentException("Process query exceeds display budget"); - if (connections.size() > MAX_CONNECTIONS) throw new IllegalArgumentException("Too many process connections"); - var references = new HashMap(); - for (var step : steps) - if (references.putIfAbsent(step.reference(), step) != null) - throw new IllegalArgumentException("Duplicate process reference"); - var uniqueConnections = new HashSet(); - for (var connection : connections) { - if (!references.containsKey(connection.source()) - || !references.containsKey(connection.target()) - || !uniqueConnections.add(connection)) - throw new IllegalArgumentException("Invalid process connection"); - if (references.get(connection.source()).outputs().stream() - .noneMatch(port -> port.resource().equals(connection.resource())) - || references.get(connection.target()).inputs().stream() - .noneMatch(port -> port.resource().equals(connection.resource()))) - throw new IllegalArgumentException("Connection does not match process ports"); - } return List.of(new Page(title, material, steps, connections, notices, 1, 1, navigation)); } @@ -406,11 +475,86 @@ private static boolean isOutput(Role role) { return role == Role.PRIMARY || role == Role.BYPRODUCT || role == Role.UNKNOWN; } - private static void validatePorts(List ports, boolean output) { - if (ports.size() > MAX_PORTS || ports.stream().filter(Port::main).count() > 1) - throw new IllegalArgumentException("Invalid process ports"); - for (var port : ports) - if (isOutput(port.role()) != output) throw new IllegalArgumentException("Port role on wrong side"); + private static List validPorts(List ports, boolean output, DataKey reference) { + var valid = ports.stream() + .filter(Objects::nonNull) + .filter(port -> isOutput(port.role()) == output) + .toList(); + if (valid.size() != ports.size()) + LOGGER.warn( + "Discarded {} invalid {} ports for {}", + ports.size() - valid.size(), + output ? "output" : "input", + reference); + return valid; + } + + private static List validSteps(List steps) { + var references = new LinkedHashMap(); + for (Step step : steps) { + if (step == null) { + LOGGER.warn("Discarded null material process step"); + } else if (references.putIfAbsent(step.reference(), step) != null) { + LOGGER.warn("Discarded duplicate material process step {}", step.reference()); + } + } + return List.copyOf(references.values()); + } + + private static final class PortIndex { + private final java.util.Map> inputs = new HashMap<>(), + outputs = new HashMap<>(); + + private PortIndex(List steps) { + for (Step step : steps) { + inputs.put(step.reference(), resources(step.inputs())); + outputs.put(step.reference(), resources(step.outputs())); + } + } + + private boolean contains(DataKey step, DataKey resource, boolean output) { + return (output ? outputs : inputs) + .getOrDefault(step, java.util.Set.of()) + .contains(resource); + } + } + + private static List validConnections(List connections, PortIndex ports) { + var unique = new HashSet(); + var valid = new ArrayList(); + for (Connection connection : connections) { + if (connection == null + || !ports.contains(connection.source(), connection.resource(), true) + || !ports.contains(connection.target(), connection.resource(), false)) { + LOGGER.warn("Discarded material process connection with missing endpoint ports: {}", connection); + } else if (unique.add(connection)) valid.add(connection); + } + return List.copyOf(valid); + } + + private static List validFlows(List flows, PortIndex ports) { + var valid = new ArrayList(); + for (Flow flow : flows) { + var sources = flow.sources().stream() + .filter(source -> ports.contains(source, flow.resource(), true)) + .distinct() + .toList(); + var targets = flow.targets().stream() + .filter(target -> ports.contains(target, flow.resource(), false)) + .distinct() + .toList(); + if (sources.size() != flow.sources().size() + || targets.size() != flow.targets().size()) + LOGGER.warn("Discarded invalid material process flow endpoints for {}", flow.resource()); + if (!sources.isEmpty() && !targets.isEmpty()) valid.add(new Flow(flow.resource(), sources, targets)); + } + return List.copyOf(valid); + } + + private static java.util.Set resources(List ports) { + var result = new HashSet(); + ports.forEach(port -> result.add(port.resource())); + return result; } private static List copyText(List lines) { diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java index 57c9116d2..776592159 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java @@ -21,7 +21,7 @@ import java.util.function.Predicate; import net.minecraft.world.item.ItemStack; -/** A bounded layout of native steps; resource copies never introduce recipe facts. */ +/** A layout of material-local native steps; resource copies never introduce recipe facts. */ public final class MaterialProcessOverview { /** The original port, including its side and slot, survives sharing and local copying. */ public record Endpoint(Step step, boolean output, int index, Port port) { @@ -96,7 +96,7 @@ public boolean extra() { || steps.stream() .anyMatch(step -> java.util.stream.Stream.concat( step.inputs().stream(), step.outputs().stream()) - .anyMatch(port -> port.icons().size() > 1)); + .anyMatch(port -> port.iconCount() > 1)); } public final List auxiliaries = new ArrayList<>(); @@ -139,15 +139,17 @@ public record Point(int x, int y) {} public static final class Edge { private Node from, to; private final Endpoint endpoint; + private final boolean primary; private final List endpoints = new ArrayList<>(); private boolean confirmed; private boolean feedback; private List path = List.of(); - private Edge(Node from, Node to, Endpoint endpoint) { + private Edge(Node from, Node to, Endpoint endpoint, boolean primary) { this.from = from; this.to = to; this.endpoint = endpoint; + this.primary = primary; endpoints.add(endpoint); confirmed = endpoint.step().resolved(); } @@ -199,7 +201,9 @@ public int hashCode() { } } - private record RouteKey(IconKey icon, String fallback, List inputs, String output, boolean recovery) {} + private record RouteKey(IconKey machine, boolean output, List resources) {} + + private record VisiblePorts(List inputs, List outputs) {} private record EdgeKey(Node from, Node to) {} @@ -233,6 +237,8 @@ public record InformationCard( private final List bands = new ArrayList<>(); private final List information = new ArrayList<>(); private final List connections; + private final List flows; + private final Set unresolved = new HashSet<>(); private final Map next = new HashMap<>(), previous = new HashMap<>(); private final Set feedback = new HashSet<>(); private final List frames = new ArrayList<>(); @@ -245,6 +251,8 @@ public MaterialProcessOverview(Page page) { } private MaterialProcessOverview(Page page, boolean partition) { + flows = page.flows(); + for (Step step : page.steps()) if (!step.resolved()) unresolved.add(step.reference()); connections = page.connections().stream() .sorted(Comparator.comparing( connection -> connection.source() + ":" + connection.target() + ":" + connection.resource())) @@ -254,35 +262,31 @@ private MaterialProcessOverview(Page page, boolean partition) { return; } var resources = new LinkedHashMap(); - var routes = new LinkedHashMap(); - var wires = new LinkedHashMap(); - for (Step step : page.steps().stream() + var ordered = page.steps().stream() .sorted(Comparator.comparing(value -> value.reference().toString())) - .toList()) { - List visibleInputs = visible(step.inputs(), page.material(), false); - List visibleOutputs = visible(step.outputs(), page.material(), true); - ItemStack icon = step.icon(); - // Similar routes share a machine and primary product; native recipe differences stay in the details. - var key = new RouteKey( - new IconKey(icon), - icon.isEmpty() ? step.reference().toString() : "", - visibleOutputs.isEmpty() ? identities(visibleInputs) : List.of(), - visibleOutputs.isEmpty() ? "" : visibleOutputs.get(0).identity(), - step.genericRecovery()); - Node machine = routes.computeIfAbsent(key, ignored -> { - var node = new Node( - "step:" + step.reference(), - MaterialProcessDisplay.section(step, page.material()).orElse(null)); - nodes.add(node); - return node; - }); + .toList(); + var visibility = new HashMap(); + for (Step step : ordered) + visibility.put( + step.reference(), + new VisiblePorts( + visible(step.inputs(), page.material(), false), + visible(step.outputs(), page.material(), true))); + var routes = routes(ordered, visibility, page.material()); + var wires = new LinkedHashMap(); + for (Step step : ordered) { + Node machine = routes.get(step.reference()); machine.steps.add(step); for (boolean output : List.of(false, true)) { List ports = output ? step.outputs() : step.inputs(); - List visible = output ? visibleOutputs : visibleInputs; + List visible = output + ? visibility.get(step.reference()).outputs() + : visibility.get(step.reference()).inputs(); + Set shown = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); + shown.addAll(visible); for (int index = 0; index < ports.size(); index++) { Port port = ports.get(index); - if (!visible.contains(port)) { + if (!shown.contains(port)) { machine.auxiliaries.add(port); continue; } @@ -304,7 +308,7 @@ private MaterialProcessOverview(Page page, boolean partition) { Node from = output ? machine : resource, to = output ? resource : machine; Edge edge = wires.get(new EdgeKey(from, to)); if (edge == null) { - edge = new Edge(from, to, endpoint); + edge = new Edge(from, to, endpoint, port == visible.get(0)); wires.put(new EdgeKey(from, to), edge); edges.add(edge); } else { @@ -331,6 +335,53 @@ private MaterialProcessOverview(Page page, boolean partition) { .orElse(nodes.isEmpty() ? null : nodes.get(0)); } + private Map routes(List ordered, Map visibility, String material) { + var candidates = new LinkedHashMap>(); + for (Step step : ordered) { + ItemStack icon = step.icon(); + if (icon.isEmpty()) continue; + var machine = new IconKey(icon); + List inputs = visibility.get(step.reference()).inputs(); + List outputs = visibility.get(step.reference()).outputs(); + if (!inputs.isEmpty()) + candidates + .computeIfAbsent(new RouteKey(machine, false, identities(inputs)), ignored -> new ArrayList<>()) + .add(step); + if (!outputs.isEmpty()) + candidates + .computeIfAbsent(new RouteKey(machine, true, identities(outputs)), ignored -> new ArrayList<>()) + .add(step); + } + var groups = candidates.entrySet().stream() + .sorted(Comparator.>>comparingInt( + entry -> -entry.getValue().size()) + .thenComparing(entry -> !entry.getKey().output()) + .thenComparing( + entry -> entry.getValue().get(0).reference().toString())) + .toList(); + var result = new HashMap(); + // Fold one shared side at a time. Transitive input/output unions would invent a cross-product of routes. + for (var group : groups) { + var available = group.getValue().stream() + .filter(step -> !result.containsKey(step.reference())) + .toList(); + if (available.size() < 2) continue; + Node machine = machine(available.get(0), material); + for (Step step : available) result.put(step.reference(), machine); + } + for (Step step : ordered) + if (!result.containsKey(step.reference())) result.put(step.reference(), machine(step, material)); + return result; + } + + private Node machine(Step step, String material) { + var node = new Node( + "step:" + step.reference(), + MaterialProcessDisplay.section(step, material).orElse(null)); + nodes.add(node); + return node; + } + public List nodes() { return List.copyOf(nodes); } @@ -429,6 +480,9 @@ private void applyConfirmation() { Set uncertain = new HashSet<>(); for (Connection connection : connections) if (!connection.confirmed()) uncertain.add(connection.target() + ":" + connection.resource()); + for (var flow : flows) + if (flow.sources().stream().anyMatch(unresolved::contains)) + for (DataKey target : flow.targets()) uncertain.add(target + ":" + flow.resource()); for (Edge edge : edges) if (edge.endpoints.stream() .anyMatch(endpoint -> !endpoint.output() @@ -479,7 +533,8 @@ private void partition(Page page) { for (Grid original : graph.grids) grids.add(new Grid(original.members.stream().map(copies::get).toList())); for (Edge original : graph.edges) { - var edge = new Edge(copies.get(original.from), copies.get(original.to), original.endpoint); + var edge = new Edge( + copies.get(original.from), copies.get(original.to), original.endpoint, original.primary); edge.endpoints.clear(); edge.endpoints.addAll(original.endpoints); edge.confirmed = original.confirmed; @@ -524,6 +579,10 @@ public List connections() { return connections; } + public List flows() { + return flows; + } + public Node anchor() { return anchor; } @@ -559,9 +618,7 @@ public Set matchingNodes(Node hovered) { } private static ItemStack icon(Node node) { - return node.machine() - ? node.steps.get(0).icon() - : node.port().icons().stream().findFirst().orElse(ItemStack.EMPTY); + return node.machine() ? node.steps.get(0).icon() : node.port().icon(); } private void frameRecipes() { @@ -662,14 +719,7 @@ private void split(Edge edge) { } private static boolean primary(Edge edge) { - Node machine = edge.from.machine() ? edge.from : edge.to; - int first = machine.endpoints.stream() - .filter(endpoint -> endpoint.output() == edge.endpoint.output()) - .filter(endpoint -> endpoint.step() == edge.endpoint.step()) - .mapToInt(Endpoint::index) - .min() - .orElse(edge.endpoint.index()); - return edge.endpoint.index() == first; + return edge.primary; } private boolean splitLongEdges() { diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java index b59ea46eb..1e0fc3df9 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java @@ -1,5 +1,6 @@ package gregtech.compat.common; +import com.mojang.logging.LogUtils; import gregtech.api.addon.material.DataKey; import gregtech.api.addon.material.MaterialCatalogView; import gregtech.api.addon.material.MaterialKey; @@ -7,10 +8,8 @@ import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.engine.material.MaterialProcessGraph; import gregtech.engine.material.MaterialProcessGraph.AmountUnit; -import gregtech.engine.material.MaterialProcessGraph.Budgets; import gregtech.engine.material.MaterialProcessGraph.Notice; import gregtech.engine.material.MaterialProcessGraph.Port; -import gregtech.engine.material.MaterialProcessGraph.Query; import gregtech.engine.material.MaterialProcessGraph.Resource; import gregtech.engine.material.MaterialProcessGraph.Step; import java.util.ArrayList; @@ -29,11 +28,9 @@ import net.minecraftforge.fluids.FluidStack; //?} -/** Converts one already bounded semantic query into native viewer values. */ +/** Converts one material-local semantic query into native viewer values. */ public final class MaterialProcessProjection { - private static final Budgets MATERIAL_PAGE_BUDGET = - new Budgets(0, MaterialProcessDisplay.MAX_STEPS, MaterialProcessDisplay.MAX_PORTS, - MaterialProcessDisplay.MAX_CONNECTIONS); + private static final org.slf4j.Logger LOGGER = LogUtils.getLogger(); private MaterialProcessProjection() {} @@ -42,7 +39,7 @@ public static List initialPages( var pages = new ArrayList(); var workstations = RecipeViewerIcons.categories(); for (MaterialProcessSnapshot.Root root : snapshot.roots()) { - var rootPages = pages(snapshot, root.resource(), MATERIAL_PAGE_BUDGET, navigation, workstations); + var rootPages = pages(snapshot, root.resource(), navigation, workstations); pages.addAll(rootPages); } return pages.isEmpty() ? MaterialProcessDisplay.unbound() : List.copyOf(pages); @@ -52,7 +49,32 @@ public static List pages( MaterialProcessSnapshot snapshot, DataKey root, MaterialProcessDisplay.Navigation navigation) { - return pages(snapshot, root, MATERIAL_PAGE_BUDGET, navigation, RecipeViewerIcons.categories()); + return pages(snapshot, root, navigation, RecipeViewerIcons.categories()); + } + + private record IndexPort(DataKey resource, MaterialProcessGraph.Role role) {} + + /** Viewer registration needs unique material resource/role representatives, without any graph or layout. */ + public static List indexedPorts(MaterialProcessSnapshot snapshot, DataKey root) { + Resource resource = snapshot.resource(root).orElse(null); + if (resource == null) return List.of(); + var ports = new java.util.LinkedHashMap(); + for (Step step : snapshot.materialSteps(root)) { + var recipe = snapshot.recipe(step.reference()).orElse(null); + for (List side : List.of(step.inputs(), step.outputs())) + for (Port port : side) { + if (!port.resource().material().equals(resource.material())) continue; + var key = new IndexPort(port.resource().key(), port.role()); + var existing = ports.get(key); + if (existing != null && existing.hasIcons()) continue; + try { + ports.put(key, port(snapshot, port, recipe)); + } catch (RuntimeException failure) { + LOGGER.warn("Discarded invalid material process index resource {}", port.resource().key(), failure); + } + } + } + return List.copyOf(ports.values()); } public static MaterialProcessDisplay.Page informationPage(String material, @@ -66,21 +88,28 @@ public static MaterialProcessDisplay.Page informationPage(String material, private static List pages( MaterialProcessSnapshot snapshot, DataKey root, - Budgets budgets, MaterialProcessDisplay.Navigation navigation, java.util.Map workstations) { - Query query = snapshot.queryMaterial(root, budgets); - var steps = query.steps().stream().map(step -> step(snapshot, step, workstations)).toList(); - var connections = query.edges().stream() - .map(edge -> new MaterialProcessDisplay.Connection( - edge.source(), edge.target(), edge.resource(), edge.confirmed())) + var query = snapshot.queryMaterial(root); + var steps = new ArrayList(); + for (Step step : query.steps()) { + try { + steps.add(step(snapshot, step, workstations)); + } catch (RuntimeException failure) { + LOGGER.warn("Discarded invalid material process display step {}", step.reference(), failure); + } + } + var flows = query.flows().stream() + .map(flow -> new MaterialProcessDisplay.Flow(flow.resource(), flow.sources(), flow.targets())) .toList(); - var notices = query.notices().stream().map(MaterialProcessProjection::notice).toList(); + List notices = new ArrayList<>(query.notices().stream().map(MaterialProcessProjection::notice).toList()); + if (steps.size() != query.steps().size()) + notices.add(Component.translatable("gt6ce.jei.material_process.coverage.invalid_data", query.steps().size() - steps.size())); if (notices.isEmpty()) notices = List.of(Component.translatable("gt6ce.jei.material_process.partial_unknown")); Resource resource = snapshot.resource(query.root()).orElse(null); Component title = title(query.root(), resource); String material = resource == null ? "" : resource.material(); - return MaterialProcessDisplay.pages(title, material, steps, connections, notices, navigation); + return List.of(new MaterialProcessDisplay.Page(title, material, steps, List.of(), notices, 1, 1, navigation, List.of(), flows)); } private static MaterialProcessDisplay.Step step(MaterialProcessSnapshot snapshot, Step step, @@ -103,7 +132,8 @@ private static MaterialProcessDisplay.Step step(MaterialProcessSnapshot snapshot snapshot.worldgen(step.reference()).isPresent(), snapshot.recipe(step.reference()) .map(MaterialProcessSnapshot.NativeRecipe::genericRecovery) - .orElse(false)); + .orElse(false), + snapshot.process(step.reference())); } private static Optional specialMethod( @@ -360,6 +390,8 @@ private static Component notice(Notice notice) { Component.translatable("gt6ce.jei.material_process.coverage.dynamic_selectors"); case "partial_unknown_roles" -> Component.translatable("gt6ce.jei.material_process.coverage.unknown_roles"); + case "invalid_process_data" -> + Component.translatable("gt6ce.jei.material_process.coverage.invalid_data", notice.omitted()); case "node_limit" -> Component.translatable("gt6ce.jei.material_process.coverage.node_limit", notice.omitted()); case "port_limit" -> diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index 695c66a03..05f10583c 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -177,6 +177,11 @@ private static boolean repairedGtTool(EmiRecipe recipe) { public static java.util.List addMaterialProcesses( java.util.List recipes, java.util.Map> workstations) { + long started = System.nanoTime(); + // A repeated bake replaces our previous pages instead of retaining their snapshots and indexes. + recipes = recipes.stream() + .filter(recipe -> !(recipe instanceof MaterialProcessEmiRecipe)) + .toList(); var source = MaterialProcessSnapshot.Store.current(); var captured = MaterialProcessEmiRecipes.capture(source, recipes, workstations); var snapshot = captured.snapshot(); @@ -184,18 +189,35 @@ public static java.util.List addMaterialProcesses( var navigation = new ProcessNavigation(snapshot, source, captured.information(), captured.links()); var result = new java.util.ArrayList<>(recipes); var materials = new java.util.HashSet(); - for (var page : gregtech.compat.common.MaterialProcessProjection.initialPages(snapshot, navigation)) - if (!page.material().isEmpty()) { - result.add(new MaterialProcessEmiRecipe(page.withInformation( - captured.information().getOrDefault(page.material(), java.util.List.of())))); - materials.add(page.material()); - } + for (var root : snapshot.roots()) { + var information = captured.information().getOrDefault(root.material(), java.util.List.of()); + var indexedPorts = new java.util.ArrayList<>( + gregtech.compat.common.MaterialProcessProjection.indexedPorts(snapshot, root.resource())); + information.forEach(entry -> indexedPorts.addAll(entry.index())); + result.add(new MaterialProcessEmiRecipe( + root.material(), + () -> navigation.valid() + ? gregtech.compat.common.MaterialProcessProjection.pages( + snapshot, root.resource(), navigation) + .get(0) + .withInformation(information) + : gregtech.compat.common.MaterialProcessDisplay.unbound() + .get(0), + indexedPorts)); + materials.add(root.material()); + } captured.information().forEach((material, entries) -> { if (!materials.contains(material)) result.add( new MaterialProcessEmiRecipe(gregtech.compat.common.MaterialProcessProjection.informationPage( material, entries, navigation))); }); + com.mojang.logging.LogUtils.getLogger() + .info( + "[gregtech] EMI material process index: {} materials from {} viewer recipes in {} ms; pages build on demand", + result.size() - recipes.size(), + recipes.size(), + (System.nanoTime() - started) / 1_000_000L); return java.util.List.copyOf(result); } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java index 02a3d6474..91cfddd73 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java @@ -11,9 +11,13 @@ import gregtech.client.MaterialProcessPanel; import gregtech.compat.common.MaterialProcessDisplay; import gregtech.compat.common.RecipeViewerIcons; -import java.util.ArrayList; +import gregtech.content.recipe.MaterialProcessSnapshot; +import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.function.Supplier; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.network.chat.Component; @@ -31,7 +35,8 @@ public Component getName() { } }; - private final MaterialProcessDisplay.Page page; + private final Supplier pageFactory; + private MaterialProcessDisplay.Page page; private MaterialProcessPanel panel; private List focus = List.of(); private final ResourceLocation id; @@ -40,15 +45,22 @@ public Component getName() { private final List outputs; public MaterialProcessEmiRecipe(MaterialProcessDisplay.Page page) { + this(page.material(), () -> page, page.indexedPorts()); this.page = page; - id = ResourceLocation.fromNamespaceAndPath("gt6ce", "/material_process/" + path(page.material())); - var inputs = new ArrayList(); - var catalysts = new ArrayList(); - var outputs = new ArrayList(); - for (var port : page.indexedPorts()) add(port, inputs, catalysts, outputs); - this.inputs = List.copyOf(inputs); - this.catalysts = List.copyOf(catalysts); - this.outputs = List.copyOf(outputs); + } + + /** Index getters never resolve the page; EMI calls them for every recipe during each bake. */ + public MaterialProcessEmiRecipe(String material, Supplier pageFactory, + List indexedPorts) { + this.pageFactory = Objects.requireNonNull(pageFactory); + id = ResourceLocation.fromNamespaceAndPath("gt6ce", "/material_process/" + path(material)); + var inputs = new LinkedHashMap(); + var catalysts = new LinkedHashMap(); + var outputs = new LinkedHashMap(); + for (var port : indexedPorts) add(port, inputs, catalysts, outputs); + this.inputs = List.copyOf(inputs.values()); + this.catalysts = List.copyOf(catalysts.values()); + this.outputs = List.copyOf(outputs.values()); } private static String path(String material) { @@ -58,29 +70,22 @@ private static String path(String material) { private static void add( MaterialProcessDisplay.Port port, - List inputs, - List catalysts, - List outputs) { - if (!port.hasIcons()) return; - var stacks = stacks(port); - var ingredient = EmiIngredient.of(stacks); - switch (port.role()) { - case CONSUMED -> inputs.add(ingredient); - case CATALYST, PRESENCE -> catalysts.add(ingredient); - case PRIMARY, BYPRODUCT, UNKNOWN -> outputs.addAll(stacks); + Map inputs, + Map catalysts, + Map outputs) { + var index = switch (port.role()) { + case CONSUMED -> inputs; + case CATALYST, PRESENCE -> catalysts; + case PRIMARY, BYPRODUCT, UNKNOWN -> outputs; + }; + for (var icon : port.icons()) { + String state = MaterialProcessSnapshot.itemDisplayState(icon); + if (index.containsKey(state)) continue; + var stack = MaterialProcessEmiStacks.of(icon); + if (!stack.isEmpty()) index.put(state, stack); } } - private static List stacks(MaterialProcessDisplay.Port port) { - return port.icons().stream() - .map(MaterialProcessEmiStacks::of) - .filter(stack -> !stack.isEmpty()) - .map(stack -> port.chance().isPresent() - ? stack.setChance(port.chance().getAsInt() / 10_000F) - : stack) - .toList(); - } - public static void register(EmiRegistry registry, List pages) { registry.addCategory(CATEGORY); for (var page : pages) registry.addRecipe(new MaterialProcessEmiRecipe(page)); @@ -156,6 +161,7 @@ public int getDisplayHeight() { @Override public void addWidgets(WidgetHolder widgets) { if (panel == null) { + if (page == null) page = pageFactory.get(); panel = new MaterialProcessPanel(page); focusPanel(); } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java index 54dc977a9..46b6523f6 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java +++ b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java @@ -1,7 +1,13 @@ package gregtech.compat.emi; +import com.mojang.logging.LogUtils; +import dev.emi.emi.api.recipe.EmiCraftingRecipe; +import dev.emi.emi.api.recipe.EmiIngredientRecipe; +import dev.emi.emi.api.recipe.EmiInfoRecipe; +import dev.emi.emi.api.recipe.EmiPatternCraftingRecipe; import dev.emi.emi.api.recipe.EmiRecipe; import dev.emi.emi.api.recipe.EmiRecipeCategory; +import dev.emi.emi.api.recipe.VanillaEmiRecipeCategories; import dev.emi.emi.api.stack.EmiIngredient; import dev.emi.emi.api.stack.EmiStack; import gregtech.api.addon.material.DataKey; @@ -11,13 +17,20 @@ import gregtech.engine.fluid.FluidVisualPolicy; import gregtech.engine.material.ItemMaterialRegistry; import gregtech.engine.material.MaterialProcessGraph.Port; +import gregtech.engine.material.MaterialProcessGraph.AmountUnit; +import gregtech.engine.material.MaterialProcessGraph.Resource; import gregtech.engine.material.MaterialProcessGraph.Role; +import java.math.BigInteger; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.OptionalInt; +import java.util.Set; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -30,72 +43,127 @@ /** Processing rows and related information share a source, but never share graph semantics. */ final class MaterialProcessEmiRecipes { + private static final org.slf4j.Logger LOGGER = LogUtils.getLogger(); + private MaterialProcessEmiRecipes() {} record Captured(MaterialProcessSnapshot snapshot, Map> information, Map links) {} + private record SlotKey(Resource resource, Role role, AmountUnit unit, OptionalInt chance, long stochasticBatch) {} + + private record ProcessKey(ResourceLocation category, Map inputs, Map outputs) {} + static Captured capture(MaterialProcessSnapshot source, List recipes, Map> workstations) { var builder = source.viewerBuilder(); var information = new LinkedHashMap>(); var links = new LinkedHashMap(); + var informationIds = new HashSet(); + var processIds = new HashSet(); + var processes = new HashSet(); var seen = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap()); for (int index = 0; index < recipes.size(); index++) { EmiRecipe recipe = recipes.get(index); - if (recipe instanceof MaterialProcessEmiRecipe || !seen.add(recipe)) continue; - // EMI's tree contract describes a complete transformation; lookup slots alone do not. - if (!recipe.supportsRecipeTree() || recipe.getInputs().isEmpty() || recipe.getOutputs().isEmpty()) { - builder.omitted(); - information(source, recipe, index, information, links); - continue; - } - if (recipe instanceof MachineEmiRecipe machine) { - builder.machine(machine.recipeMap(), machine.nativeRecipe()); - continue; - } - var inputs = ports(builder, recipe.getInputs(), Role.CONSUMED); - var catalysts = ports(builder, recipe.getCatalysts(), Role.CATALYST); - var outputs = ports(builder, recipe.getOutputs(), Role.UNKNOWN); - // Dropping an unsupported slot would turn a partial recipe into an invented route. - if (inputs == null || catalysts == null || outputs == null) { + try { + if (recipe instanceof MaterialProcessEmiRecipe || !seen.add(recipe)) continue; + // Ingredient disambiguation lists tag members, not material-specific guidance. + if (recipe instanceof EmiIngredientRecipe && !(recipe instanceof MaterialUnitTagEmiRecipe)) continue; + // JEMI wraps JEI tag browsers as plain recipes, retaining the registry's tag_recipes category. + if (recipe.getCategory().getId().getPath().startsWith("tag_recipes/")) continue; + // Unit templates opt out of automatic crafting, but carry GT's complete processing semantics. + if (recipe instanceof MachineEmiRecipe machine + && builder.machine(machine.recipeMap(), machine.nativeRecipe())) continue; + if (informationOnly(recipe) || recipe.getInputs().isEmpty() || recipe.getOutputs().isEmpty()) { + builder.omitted(); + information(source, recipe, index, information, links, informationIds); + continue; + } + boolean crafting = recipe instanceof EmiCraftingRecipe + || recipe.getCategory().getId().equals(VanillaEmiRecipeCategories.CRAFTING.getId()); + var inputs = ports(builder, recipe.getInputs(), Role.CONSUMED, crafting); + var catalysts = ports(builder, recipe.getCatalysts(), Role.CATALYST, false); + var outputs = ports(builder, recipe.getOutputs(), Role.UNKNOWN, false); + // Dropping an unsupported slot would turn a partial recipe into an invented route. + if (inputs == null || catalysts == null || outputs == null || inputs.isEmpty() || outputs.isEmpty()) { + builder.omitted(); + information(source, recipe, index, information, links, informationIds); + continue; + } + inputs.addAll(catalysts); + var category = recipe.getCategory(); + // IDs catch repeated registrations; slot multisets also catch equivalent synthetic wrappers. + var id = recipe.getId(); + if (id != null && processIds.contains(id)) continue; + boolean remainders = java.util.stream.Stream.concat(recipe.getInputs().stream(), recipe.getCatalysts().stream()) + .flatMap(ingredient -> ingredient.getEmiStacks().stream()).anyMatch(stack -> !stack.getRemainder().isEmpty()); + var process = remainders ? null : new ProcessKey(category.getId(), slots(inputs), slots(outputs)); + if (process != null && processes.contains(process)) continue; + var machine = workstations.getOrDefault(category, List.of()).stream() + .flatMap(ingredient -> ingredient.getEmiStacks().stream()) + .map(EmiStack::getItemStack).filter(stack -> !stack.isEmpty()) + .findFirst().orElseGet(() -> category.getId().equals(VanillaEmiRecipeCategories.CRAFTING.getId()) + ? new ItemStack(Items.CRAFTING_TABLE) : ItemStack.EMPTY); + var reference = new DataKey("gt6ce", "process/emi/" + index + "/" + + Long.toUnsignedString(source.snapshot().publication().revision(), 36) + "/" + + Long.toUnsignedString(source.snapshot().sessionGeneration(), 36)); + builder.recipe(reference, category.getId().toString(), category.getName().getString(), machine, inputs, outputs, + List.of("EMI category: " + category.getId(), "EMI recipe: " + recipe.getId(), + "matching constraints and remainders: see original recipe"), recipe.supportsRecipeTree()); + if (id != null) processIds.add(id); + if (process != null) processes.add(process); + } catch (RuntimeException failure) { builder.omitted(); - information(source, recipe, index, information, links); - continue; + LOGGER.warn("Discarded invalid EMI material process entry at index {}", index, failure); } - inputs.addAll(catalysts); - var category = recipe.getCategory(); - var machine = workstations.getOrDefault(category, List.of()).stream() - .flatMap(ingredient -> ingredient.getEmiStacks().stream()) - .map(EmiStack::getItemStack).filter(stack -> !stack.isEmpty()) - .findFirst().orElse(ItemStack.EMPTY); - var reference = new DataKey("gt6ce", "process/emi/" + index + "/" - + Long.toUnsignedString(source.snapshot().publication().revision(), 36) + "/" - + Long.toUnsignedString(source.snapshot().sessionGeneration(), 36)); - builder.recipe(reference, category.getName().getString(), machine, inputs, outputs, - List.of("EMI category: " + category.getId(), "EMI recipe: " + recipe.getId(), - "matching constraints and remainders: see original recipe")); } information.replaceAll((material, entries) -> List.copyOf(entries)); return new Captured(builder.build(), Map.copyOf(information), Map.copyOf(links)); } + private static boolean informationOnly(EmiRecipe recipe) { + return recipe instanceof MachineEmiRecipe + || recipe instanceof EmiInfoRecipe + || recipe instanceof EmiPatternCraftingRecipe + || recipe instanceof StructureEmiRecipe + || recipe instanceof WorldgenEmiRecipe + || recipe instanceof LootEmiRecipe + || recipe instanceof MaterialUnitTagEmiRecipe + || recipe instanceof MoldChiselEmiRecipe + || recipe instanceof WoodenBucketLookupRecipe + || recipe.getCategory().getId().equals(VanillaEmiRecipeCategories.INFO.getId()); + } + + private static Map slots(List ports) { + var result = new HashMap(); + for (Port port : ports) { + // Two independent random output slots are not one double-sized random batch. + long batch = port.output() && port.chance().orElse(0) != 10_000 ? port.amount().value() : 0; + result.merge(new SlotKey(port.resource(), port.role(), port.amount().unit(), port.chance(), batch), + BigInteger.valueOf(port.amount().value()), BigInteger::add); + } + return Map.copyOf(result); + } + private static void information(MaterialProcessSnapshot source, EmiRecipe recipe, int index, - Map> information, Map links) { + Map> information, Map links, + Set informationIds) { var inputs = informationIcons(java.util.stream.Stream.concat(recipe.getInputs().stream(), recipe.getCatalysts().stream()).toList()); var outputs = informationIcons(recipe.getOutputs()); var materials = new java.util.LinkedHashSet<>(inputs.keySet()); materials.addAll(outputs.keySet()); if (materials.isEmpty()) return; + // EMI IDs identify pages, even when plugins register a fresh object for the same page. + if (recipe.getId() != null && !informationIds.add(recipe.getId())) return; var reference = new DataKey("gt6ce", "process/emi_information/" + index + "/" + Long.toUnsignedString(source.snapshot().publication().revision(), 36) + "/" + Long.toUnsignedString(source.snapshot().sessionGeneration(), 36)); - ItemStack icon = recipe.getOutputs().stream().filter(stack -> stack != null).map(EmiStack::getItemStack) - .filter(stack -> !stack.isEmpty()).findFirst().orElse(new ItemStack(Items.BOOK)); Component name = recipe.getCategory().getName(); int materialIndex = 0; for (String material : materials) { var ports = new ArrayList(); + var materialIcons = outputs.getOrDefault(material, inputs.getOrDefault(material, Map.of())); + ItemStack icon = materialIcons.values().iterator().next(); for (boolean output : List.of(false, true)) { var icons = (output ? outputs : inputs).getOrDefault(material, Map.of()).values().stream().toList(); if (icons.isEmpty()) continue; @@ -120,8 +188,10 @@ private static Map> informationIcons(List composition.components().forEach(component -> - informationIcon(result, component.material().resolve().getName(), item))); + ItemMaterialRegistry.get(item).ifPresent(composition -> { + var material = composition.primaryMaterial().resolve(); + if (material.isValid()) informationIcon(result, material.getName(), item); + }); } else if (stack.getKey() instanceof Fluid fluid) { var entry = GTFluids.entryForFluid(fluid); if (entry == null) continue; @@ -148,19 +218,24 @@ private static void informationIcon(Map> icons, S } private static List ports(MaterialProcessSnapshot.ViewerBuilder builder, - List ingredients, Role role) { + List ingredients, Role role, boolean padding) { var ports = new ArrayList(); for (EmiIngredient ingredient : ingredients) { - if (ingredient == null || ingredient.isEmpty() || ingredient.getAmount() <= 0) return null; + // Shaped crafting pads its grid with EMPTY. An unresolved nonempty ingredient is not padding. + if (padding && ingredient == EmiStack.EMPTY) continue; + if (role == Role.CATALYST && ingredient != null && ingredient.getAmount() == 0) + ingredient = ingredient.copy().setAmount(1); + if (ingredient == null || ingredient.isEmpty() || ingredient.getAmount() < 0 + || ingredient.getAmount() == 0 && role != Role.CATALYST) return null; var candidates = new ArrayList(); for (EmiStack stack : ingredient.getEmiStacks()) { if (stack == null || stack.isEmpty()) return null; if (role == Role.UNKNOWN && (!Float.isFinite(stack.getChance()) || stack.getChance() <= 0 || stack.getChance() > 1)) return null; - long amount = ingredient.getAmount(); + long amount = Math.max(1, ingredient.getAmount()); var chance = role == Role.UNKNOWN ? chance(stack.getChance()) : OptionalInt.empty(); if (stack.getKey() instanceof Item) { - var item = stack.getItemStack(); + var item = stack.copy().setAmount(1).getItemStack(); if (item.isEmpty()) return null; candidates.add(builder.item(item, role, amount, chance)); } else if (stack.getKey() instanceof Fluid fluid) { diff --git a/minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java b/minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java index 032762160..a75b6d104 100644 --- a/minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java +++ b/minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java @@ -4,9 +4,9 @@ import gregtech.api.material.*; import gregtech.content.data.MaterialPrefix; +import gregtech.content.transport.*; import gregtech.content.transport.PanelCatalog; import gregtech.content.transport.PanelMaterialRules; -import gregtech.content.transport.*; import gregtech.engine.material.*; import java.util.*; import net.minecraft.core.registries.BuiltInRegistries; diff --git a/minecraft/src/main/java/gregtech/content/material/WoodMaterialCompositions.java b/minecraft/src/main/java/gregtech/content/material/WoodMaterialCompositions.java index 4284c552d..8bb9ac6bb 100644 --- a/minecraft/src/main/java/gregtech/content/material/WoodMaterialCompositions.java +++ b/minecraft/src/main/java/gregtech/content/material/WoodMaterialCompositions.java @@ -6,7 +6,6 @@ import gregtech.content.data.MaterialPrefix; import gregtech.content.plant.WoodSlabCatalog; import gregtech.content.recipe.NaturalWoodCraftingRows; -import gregtech.content.recipe.RegisteredWoodSurvivalRecipes; import gregtech.content.registry.GTWoods; import gregtech.engine.material.GTMaterialRegistry; import gregtech.engine.material.ItemComposition; @@ -55,8 +54,7 @@ private static void registerNativeWoods() { ItemCompositionSource.Kind.EXPLICIT, "gt6ce:wood-log/" + species.id(), "GT6 WoodEntry"); - ItemMaterialRegistry.register( - GTWoods.strippedLog(species).asItem(), null, material, 8 * GTValues.U); + ItemMaterialRegistry.register(GTWoods.strippedLog(species).asItem(), null, material, 8 * GTValues.U); } } @@ -64,9 +62,8 @@ private static void registerNaturalWoods() { for (var wood : NaturalWoodCraftingRows.SPECIES) { var material = GTMaterialRegistry.get(wood.material()); var bark = GTMaterialRegistry.get(wood.barkMaterial()); - var components = List.of( - MaterialComponent.of(material, 5 * GTValues.U), - MaterialComponent.of(bark, GTValues.U)); + var components = + List.of(MaterialComponent.of(material, 5 * GTValues.U), MaterialComponent.of(bark, GTValues.U)); ItemMaterialRegistry.register( item("gt6ce:log_" + wood.kind()), new ItemComposition( @@ -89,9 +86,9 @@ private static void registerNaturalWoods() { } private static void registerVanillaWoods() { - for (String wood : new String[] { - "oak", "spruce", "birch", "jungle", "acacia", "dark_oak", "mangrove", "cherry" - }) registerVanillaWood(wood, "log", "wood"); + for (String wood : + new String[] {"oak", "spruce", "birch", "jungle", "acacia", "dark_oak", "mangrove", "cherry"}) + registerVanillaWood(wood, "log", "wood"); registerVanillaWood("crimson", "stem", "hyphae"); registerVanillaWood("warped", "stem", "hyphae"); } diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java index f466a4ba2..a5949fec4 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java @@ -111,7 +111,9 @@ private record Bucket(List steps, Map roots) {} private final Map nativeRecipes; private final Map worldgen; private final Map> viewerIcons; - private final Map viewerMachines; + private record ViewerRecipe(String process, ItemStack machine) {} + + private final Map viewerRecipes; private MaterialProcessSnapshot( MaterialProcessGraph.Snapshot snapshot, @@ -131,7 +133,7 @@ private MaterialProcessSnapshot( Map nativeRecipes, Map worldgen, Map> viewerIcons, - Map viewerMachines, + Map viewerRecipes, List coverage) { this.snapshot = snapshot; this.resourceGeneration = resourceGeneration; @@ -143,25 +145,45 @@ private MaterialProcessSnapshot( for (Step step : steps.values()) { NativeRecipe nativeRecipe = nativeRecipes.get(step.reference()); builder.add(step, nativeRecipe != null && nativeRecipe.genericRecovery()); + } + this.graph = builder.build(); + int suppliedSteps = steps.size(); + steps.entrySet().removeIf(entry -> graph.step(entry.getKey()).isEmpty()); + for (Step step : steps.values()) { step.inputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); step.outputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); } this.resources = Map.copyOf(resources); this.steps = Map.copyOf(steps); - this.graph = builder.build(); - this.roots = List.copyOf(roots); - this.nativeRecipes = Map.copyOf(nativeRecipes); - this.worldgen = Map.copyOf(worldgen); + this.roots = suppliedSteps == steps.size() ? List.copyOf(roots) : roots.stream().map(root -> { + var candidates = new LinkedHashMap(); + for (Resource resource : buckets.get(root.material()).roots().values()) { + Resource retained = resources.get(resource.key()); + if (retained != null && retained.material().equals(root.material())) + candidates.put(retained.key().toString(), retained); + } + return candidates.isEmpty() ? null : bestRoot(root.material(), candidates); + }).filter(Objects::nonNull).toList(); + var retainedNative = new LinkedHashMap(); + nativeRecipes.forEach((key, value) -> { + if (steps.containsKey(key)) retainedNative.put(key, value); + }); + this.nativeRecipes = Map.copyOf(retainedNative); + var retainedWorldgen = new LinkedHashMap(); + worldgen.forEach((key, value) -> { + if (steps.containsKey(key)) retainedWorldgen.put(key, value); + }); + this.worldgen = Map.copyOf(retainedWorldgen); var retainedIcons = new LinkedHashMap>(); viewerIcons.forEach((key, value) -> { if (resources.containsKey(key)) retainedIcons.put(key, value); }); this.viewerIcons = Map.copyOf(retainedIcons); - var retainedMachines = new LinkedHashMap(); - viewerMachines.forEach((key, value) -> { - if (steps.containsKey(key)) retainedMachines.put(key, value); + var retainedRecipes = new LinkedHashMap(); + viewerRecipes.forEach((key, value) -> { + if (steps.containsKey(key)) retainedRecipes.put(key, value); }); - this.viewerMachines = Map.copyOf(retainedMachines); + this.viewerRecipes = Map.copyOf(retainedRecipes); } public List viewerIcons(DataKey resource) { @@ -169,7 +191,16 @@ public List viewerIcons(DataKey resource) { } public ItemStack viewerMachine(DataKey step) { - return viewerMachines.getOrDefault(step, ItemStack.EMPTY).copy(); + var recipe = viewerRecipes.get(step); + return recipe == null ? ItemStack.EMPTY : recipe.machine().copy(); + } + + public String process(DataKey step) { + var recipe = nativeRecipes.get(step); + if (recipe != null) return recipe.map().mNameInternal; + var viewer = viewerRecipes.get(step); + var value = steps.get(step); + return viewer != null ? viewer.process() : value == null ? "" : value.name(); } /** Starts a client-local view whose processing rows come exclusively from the viewer. */ @@ -201,6 +232,14 @@ public Query queryMaterial(DataKey root, Budgets budgets) { return graph.queryMaterial(root, budgets); } + public MaterialProcessGraph.MaterialQuery queryMaterial(DataKey root) { + return graph.queryMaterial(root); + } + + public List materialSteps(DataKey root) { + return graph.materialSteps(root); + } + public Optional recipe(DataKey reference) { return Optional.ofNullable(nativeRecipes.get(reference)); } @@ -248,13 +287,26 @@ static MaterialProcessSnapshot build( var mutable = new LinkedHashMap(); var nativeRecipes = new LinkedHashMap(); var nativeWorldgen = new LinkedHashMap(); + int invalid = 0; for (RecipeMap map : maps) { var rows = new ArrayList(map.mRecipeList); for (int index = 0; index < rows.size(); index++) { Recipe recipe = rows.get(index); + if (recipe == null) { + LOGGER.warn("Discarded null material process recipe in {} at index {}", map.mNameInternal, index); + invalid++; + continue; + } if (!recipe.mEnabled || recipe.mHidden) continue; if (recipe.mFakeRecipe && !hasMaterialUnitInput(recipe)) continue; - var built = recipeStep(map, recipe, index, publication.revision(), sessionGeneration); + BuiltStep built; + try { + built = recipeStep(map, recipe, index, publication.revision(), sessionGeneration); + } catch (RuntimeException failure) { + LOGGER.warn("Discarded invalid material process recipe in {} at index {}", map.mNameInternal, index, failure); + invalid++; + continue; + } if (built == null) continue; built = scoped(built, publication.revision(), resourceGeneration); addStep(mutable, built.step, built.materials); @@ -274,8 +326,10 @@ static MaterialProcessSnapshot build( .map(entry -> bestRoot(entry.getKey(), entry.getValue().roots)) .sorted(Comparator.comparing(Root::material, String.CASE_INSENSITIVE_ORDER)) .toList(); + var coverage = new ArrayList<>(COVERAGE); + if (invalid > 0) coverage.add(new Notice("invalid_process_data", invalid)); return new MaterialProcessSnapshot( - graphSnapshot, resourceGeneration, buckets, roots, nativeRecipes, nativeWorldgen); + graphSnapshot, resourceGeneration, buckets, roots, nativeRecipes, nativeWorldgen, Map.of(), Map.of(), coverage); } private static BuiltStep recipeStep( @@ -741,7 +795,7 @@ public static final class ViewerBuilder { private final Map buckets = new LinkedHashMap<>(); private final Map recipes = new LinkedHashMap<>(); private final Map> icons = new LinkedHashMap<>(); - private final Map machines = new LinkedHashMap<>(); + private final Map viewerRecipes = new LinkedHashMap<>(); private final Map> selected = new java.util.IdentityHashMap<>(); private final Map> nativeReferences = new java.util.IdentityHashMap<>(); private int omitted; @@ -760,22 +814,26 @@ public void omitted() { } /** Reuses GT matching, unit quantities and recovery ownership, once per visible native row. */ - public void machine(RecipeMap map, Recipe recipe) { - if (!selected.computeIfAbsent(map, ignored -> java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>())) - .add(recipe)) return; + public boolean machine(RecipeMap map, Recipe recipe) { + if (!recipe.mEnabled || recipe.mHidden || recipe.mFakeRecipe && !hasMaterialUnitInput(recipe)) return false; + var rows = selected.computeIfAbsent(map, ignored -> java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>())); + if (rows.contains(recipe)) return true; DataKey reference = nativeReferences.getOrDefault(map, Map.of()).get(recipe); if (reference != null) { add(source.steps.get(reference)); recipes.put(reference, source.nativeRecipes.get(reference)); - return; + rows.add(recipe); + return true; } int index = map.mRecipeList.size() + recipes.size(); BuiltStep built = recipeStep(map, recipe, index, source.snapshot.publication().revision(), source.snapshot.sessionGeneration()); - if (built == null) return; + if (built == null) return false; built = scoped(built, source.snapshot.publication().revision(), source.resourceGeneration); addStep(buckets, built.step, built.materials); recipes.put(built.step.reference(), new NativeRecipe(map, recipe, index)); + rows.add(recipe); + return true; } public Port item(ItemStack stack, Role role, long amount, OptionalInt chance) { @@ -851,10 +909,20 @@ public Port alternatives(List candidates) { public void recipe(DataKey reference, String name, ItemStack machine, List inputs, List outputs, List details) { - boolean resolved = java.util.stream.Stream.concat(inputs.stream(), outputs.stream()) + recipe(reference, name, machine, inputs, outputs, details, true); + } + + public void recipe(DataKey reference, String name, ItemStack machine, + List inputs, List outputs, List details, boolean resolved) { + recipe(reference, name, name, machine, inputs, outputs, details, resolved); + } + + public void recipe(DataKey reference, String process, String name, ItemStack machine, + List inputs, List outputs, List details, boolean resolved) { + resolved &= java.util.stream.Stream.concat(inputs.stream(), outputs.stream()) .noneMatch(port -> port.resource().state().startsWith("selector:")); add(new Step(reference, name, inputs, outputs, details, resolved)); - if (!machine.isEmpty()) machines.put(reference, machine.copyWithCount(1)); + viewerRecipes.put(reference, new ViewerRecipe(process, machine.copyWithCount(1))); } private void add(Step step) { @@ -873,7 +941,7 @@ public MaterialProcessSnapshot build() { coverage.add(new Notice("coverage_viewer_recipes", 0)); coverage.add(new Notice("partial_viewer_recipes", omitted)); return new MaterialProcessSnapshot(source.snapshot, source.resourceGeneration, frozen, roots, recipes, - source.worldgen, icons, machines, coverage); + source.worldgen, icons, viewerRecipes, coverage); } } diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceCinnabarFollowonAdapter.java b/minecraft/src/main/java/gregtech/content/recipe/SourceCinnabarFollowonAdapter.java index 63afb956f..593d5adb4 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceCinnabarFollowonAdapter.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceCinnabarFollowonAdapter.java @@ -101,8 +101,9 @@ public SourceOreFollowonRows.Environment environment(GTMaterial m, long units) { // Baseline source DEF_ENV_TEMP293 < melting500/388/500. Never infer from missing molten fluid. int melt = identity(m, rule.byproducts().get(0)) ? 500 - : identity(m, rule.byproducts().get(1)) ? 388 - : identity(m, rule.byproducts().get(2)) ? 500 : -1; + : identity(m, rule.byproducts().get(1)) + ? 388 + : identity(m, rule.byproducts().get(2)) ? 500 : -1; if (melt < 0 || m.resolve().getMeltingPoint() != melt) return new SourceOreFollowonRows.Environment(UNKNOWN, null); return new SourceOreFollowonRows.Environment(YES, null); @@ -143,5 +144,4 @@ public ItemStack blockDust(GTMaterial m, int n) { ResourceLocation.parse("gt6ce:" + BlockMaterialPrefix.blockDust.getBlockId(m.resolve()))); return block == Blocks.AIR ? ItemStack.EMPTY : new ItemStack(block, n); } - } diff --git a/minecraft/src/main/java/gregtech/content/recipe/SourceOreFollowonAdapter.java b/minecraft/src/main/java/gregtech/content/recipe/SourceOreFollowonAdapter.java index fbf5aa5f1..f8af0eb3d 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SourceOreFollowonAdapter.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SourceOreFollowonAdapter.java @@ -21,6 +21,7 @@ public final class SourceOreFollowonAdapter implements SourceOreFollowonRows.Fac public static final SourceOreFollowonAdapter INSTANCE = new SourceOreFollowonAdapter(); private SourceOreFollowonAdapter() {} + private static final List INPUTS = List.of( MaterialPrefix.crushed, MaterialPrefix.crushedPurified, diff --git a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java index e18583f77..d6c702cf6 100644 --- a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java +++ b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java @@ -143,6 +143,81 @@ public static void viewerAlternativesRemainOneStatefulSelector(GameTestHelper he helper.succeed(); } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void viewerKeepsNativeUnitTemplatesAndUnconfirmedProcessing(GameTestHelper helper) { + var template = row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, Items.COPPER_INGOT) + .withMaterialInputDisplay(0, gregtech.api.material.GTValues.U, + List.of(new ItemStack(Items.IRON_INGOT)), gregtech.api.addon.recipe.MaterialUnitIngredient.Rounding.EXACT_RATIO); + template.mFakeRecipe = true; + var referenceOnly = row(new ItemStack[] {new ItemStack(Items.GOLD_INGOT)}, Items.COPPER_INGOT); + referenceOnly.mFakeRecipe = true; + var map = new RecipeMap(new ArrayList<>(List.of(template, referenceOnly)), + "gt.test.process.unit_viewer", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, + false, false, false, false); + RecipeMap.unregister(map); + var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of(map)); + var builder = source.viewerBuilder(); + helper.assertTrue(builder.machine(map, template) && builder.machine(map, template) + && !builder.machine(map, referenceOnly), + "unit templates are processing rows, while fake reference rows remain information"); + var reference = new gregtech.api.addon.material.DataKey("test", "viewer/manual_processing"); + builder.recipe(reference, "Manual", new ItemStack(Items.CRAFTING_TABLE), + List.of(builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty())), + List.of(builder.item(new ItemStack(Items.IRON_BLOCK), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000))), + List.of(), false); + var view = builder.build(); + var root = view.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); + var query = view.queryMaterial(root.resource(), new Budgets(0, 32, 32, 32)); + helper.assertTrue(query.steps().size() == 2 && query.steps().stream() + .filter(step -> view.recipe(step.reference()).isPresent()).count() == 1, + "native templates are not duplicated and manual transformations remain graph steps"); + var nativeStep = query.steps().stream().filter(step -> view.recipe(step.reference()).isPresent()).findFirst().orElseThrow(); + helper.assertTrue(nativeStep.inputs().get(0).amount().unit() == AmountUnit.MATERIAL_UNIT + && nativeStep.inputs().get(0).amount().value() == gregtech.api.material.GTValues.U, + "the native unit quantity survives admission without converting to a representative item count"); + helper.assertTrue(query.steps().stream().filter(step -> step.reference().equals(reference)).noneMatch(Step::resolved), + "a viewer's non-tree transformation does not acquire confirmed recipe-tree semantics"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void viewerProjectionKeepsLargeRecipesAndExplicitBudgets(GameTestHelper helper) { + var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); + var builder = source.viewerBuilder(); + var outputs = new ArrayList(); + var inputs = new ArrayList(); + for (int index = 0; index < 160; index++) { + var stack = new ItemStack(Items.IRON_INGOT); + var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(stack); + data.putInt("process_port", index); + gregtech.content.data.UsbDataMedia.store(stack, data); + outputs.add(builder.item(stack, Role.UNKNOWN, 1, java.util.OptionalInt.of(10000))); + inputs.add(0, builder.item(stack, Role.CONSUMED, 1, java.util.OptionalInt.empty())); + } + builder.recipe(new gregtech.api.addon.material.DataKey("test", "bounded_producer"), "Producer", new ItemStack(Items.FURNACE), + List.of(builder.item(new ItemStack(Items.COPPER_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty())), outputs, List.of()); + builder.recipe(new gregtech.api.addon.material.DataKey("test", "bounded_consumer"), "Consumer", new ItemStack(Items.CRAFTING_TABLE), + inputs, List.of(builder.item(new ItemStack(Items.IRON_BLOCK), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000))), List.of()); + var view = builder.build(); + var pages = gregtech.compat.common.MaterialProcessProjection.initialPages(view, + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE); + var page = pages.stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); + helper.assertTrue(page.steps().size() == 2 && page.connections().isEmpty() && page.flows().size() == 160 + && page.flows().stream().mapToLong(gregtech.compat.common.MaterialProcessDisplay.Flow::connectionCount).sum() == 160, + "material pages retain all large-recipe associations as resource groups"); + helper.assertTrue(page.steps().stream().allMatch(step -> step.inputs().size() <= 160 + && step.outputs().size() <= 160), + "large viewer recipes keep their complete input and output lists"); + var root = view.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); + var query = view.queryMaterial(root.resource(), new Budgets(0, 512, 128, 4096)); + helper.assertTrue(query.truncated() && query.notices().stream() + .anyMatch(notice -> notice.code().equals("port_limit") && notice.omitted() == 64), + "explicitly bounded queries still report discarded ports"); + helper.succeed(); + } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) public static void presentationPreservesNativeItemState(GameTestHelper helper) { var input = new ItemStack(Items.IRON_INGOT); @@ -222,24 +297,70 @@ public static void overviewFoldsSimilarRoutesAcrossNativeRecipeDifferences(GameT } var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(alternatives, List.of())); var machines = graph.nodes().stream().filter(node -> node.machine()).toList(); - helper.assertTrue(machines.size() == 1 && machines.get(0).steps.size() == 4, - "similar wood routes fold despite different input sets, auxiliaries, yields and probabilities"); - helper.assertTrue(graph.grids().stream().anyMatch(grid -> grid.members.size() == 5) + helper.assertTrue(machines.size() == 2 && machines.stream().mapToInt(node -> node.steps.size()).sum() == 4, + "auxiliaries and yields do not split equal visible outputs, but an additional local output does"); + helper.assertTrue(graph.grids().stream().anyMatch(grid -> grid.members.size() == 4) && graph.grids().stream().anyMatch(grid -> grid.members.size() == 2), "alternative inputs and variant products remain visible beside the shared machine"); helper.assertTrue(graph.nodes().stream().filter(node -> !node.machine()) - .anyMatch(node -> node.port().identity().equals("bark") && node.chanceBadge().equals("…%")), + .anyMatch(node -> node.port().identity().equals("bark") && node.chanceBadge().equals("25%/50%/75%")), "a shared product preserves the different native probabilities"); for (var step : alternatives) for (boolean output : List.of(false, true)) { var ports = output ? step.outputs() : step.inputs(); for (var port : ports) helper.assertTrue( - machines.get(0).endpoints.stream().anyMatch(endpoint -> endpoint.step() == step && endpoint.port() == port) - || machines.get(0).auxiliaries.contains(port), + machines.stream().anyMatch(machine -> machine.endpoints.stream().anyMatch(endpoint -> endpoint.step() == step && endpoint.port() == port) + || machine.auxiliaries.contains(port)), "every original port survives visual folding"); } helper.succeed(); } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewFoldsSharedInputsWithoutJoiningUnrelatedRoutes(GameTestHelper helper) { + var steps = new ArrayList(); + for (int index = 0; index < 18; index++) steps.add(layoutStep("plate_" + index, "plate", "component_" + index)); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); + var machines = graph.nodes().stream().filter(node -> node.machine()).toList(); + helper.assertTrue(machines.size() == 1 && machines.get(0).steps.size() == 18 + && graph.grids().stream().anyMatch(grid -> grid.members.size() == 18), + "the same material input and process share one machine and a grid of alternative products"); + helper.assertTrue(machines.get(0).endpoints.size() == 36, + "input-based folding retains every original input and output association"); + java.util.Collections.reverse(steps); + helper.assertTrue(layoutPositions(graph).equals(layoutPositions( + new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())))), + "input-based folding is stable across recipe registration order"); + var crossing = List.of(layoutStep("ax", "a", "x"), layoutStep("ay", "a", "y"), layoutStep("by", "b", "y")); + var separate = new gregtech.compat.common.MaterialProcessOverview(layoutPage(crossing, List.of())); + helper.assertTrue(separate.nodes().stream().filter(node -> node.machine()).count() == 2 + && separate.nodes().stream().filter(node -> node.machine()).noneMatch(node -> node.steps.size() == 3), + "shared-side groups do not transitively suggest a nonexistent b-to-x route"); + var other = layoutStep("other", "plate", "component_0"); + var differentProcess = new gregtech.compat.common.MaterialProcessDisplay.Step(other.reference(), + other.name(), other.icon(), other.inputs(), other.outputs(), + List.of(), java.util.Optional.empty(), true, false, false, "test:other_process"); + var kinds = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(steps.get(0), differentProcess), List.of())); + helper.assertTrue(kinds.nodes().stream().filter(node -> node.machine()).count() == 1, + "hidden process identifiers do not split routes with the same visible machine and inputs"); + var localized = new gregtech.compat.common.MaterialProcessDisplay.Step(other.reference(), + net.minecraft.network.chat.Component.literal("another translation"), other.icon(), other.inputs(), other.outputs(), + List.of(), java.util.Optional.empty(), true, false, false, "cutting"); + helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(steps.get(0), localized), List.of())) + .nodes().stream().filter(node -> node.machine()).count() == 1, + "translated labels do not change visible shared-input grouping"); + var jointA = layoutStep("joint_a", "plate", "x"); + var jointB = layoutStep("joint_b", "plate", "y"); + var joint = new ArrayList(); + for (var entry : List.of(jointA, jointB)) joint.add(new gregtech.compat.common.MaterialProcessDisplay.Step( + entry.reference(), entry.name(), entry.icon(), List.of(entry.inputs().get(0), + layoutPort(entry == jointA ? "rod" : "gear", false)), entry.outputs(), + List.of(), java.util.Optional.empty(), true)); + helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(joint, List.of())) + .nodes().stream().filter(node -> node.machine()).count() == 2, + "one shared ingredient does not stand in for the complete visible co-input set"); + helper.succeed(); + } + private static gregtech.compat.common.MaterialProcessDisplay.Port displayPort( String reference, String material, net.minecraft.world.item.Item item, boolean output) { var name = net.minecraft.network.chat.Component.literal(reference); @@ -251,6 +372,178 @@ private static gregtech.compat.common.MaterialProcessDisplay.Port displayPort( false, name, name, java.util.OptionalInt.of(10000), List.of(), MaterialProcessSnapshot.itemDisplayState(icon)); } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void overviewUsesCompleteVisibleSidesAndReliableMachineIcons(GameTestHelper helper) { + var first = layoutStep("visible_first", "a", "x"); + var second = layoutStep("visible_second", "b", "x"); + var extra = new gregtech.compat.common.MaterialProcessDisplay.Step(second.reference(), second.name(), second.icon(), + second.inputs(), List.of(second.outputs().get(0), layoutPort("y", true)), List.of(), java.util.Optional.empty(), true); + var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(first, extra), List.of())); + helper.assertTrue(graph.nodes().stream().filter(node -> node.machine()).count() == 2, + "a shared first output never hides a different visible output set"); + var unknown = new ArrayList(); + for (var row : List.of(first, second)) unknown.add(new gregtech.compat.common.MaterialProcessDisplay.Step( + row.reference(), row.name(), ItemStack.EMPTY, row.inputs(), row.outputs(), List.of(), java.util.Optional.empty(), true)); + helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(unknown, List.of())).nodes().stream() + .filter(node -> node.machine()).count() == 2, + "two missing machine icons are not evidence for visual folding"); + var changed = new gregtech.compat.common.MaterialProcessDisplay.Step(second.reference(), second.name(), first.icon(), + second.inputs(), second.outputs(), List.of(net.minecraft.network.chat.Component.literal("hidden condition")), + java.util.Optional.of(new gregtech.compat.common.MaterialProcessDisplay.SpecialProcess( + new gregtech.api.addon.material.DataKey("test", "hidden_method"), net.minecraft.network.chat.Component.literal("method"))), + true, false, false, "different:process"); + helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(first, changed), List.of())).nodes().stream() + .filter(node -> node.machine()).count() == 1, + "hidden methods, conditions and process identifiers do not split equal visible routes"); + var stateful = second.icon(); + var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(stateful); + data.putInt("machine_state", 1); + gregtech.content.data.UsbDataMedia.store(stateful, data); + var differentMachine = new gregtech.compat.common.MaterialProcessDisplay.Step(second.reference(), second.name(), stateful, + second.inputs(), second.outputs(), List.of(), java.util.Optional.empty(), true); + helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(first, differentMachine), List.of())).nodes().stream() + .filter(node -> node.machine()).count() == 2, + "machine icons retain their complete native state when folding"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void invalidDisplayRowsAndLinksDoNotInterruptThePage(GameTestHelper helper) { + var source = layoutStep("clean_source", "raw", "dust"); + var target = layoutStep("clean_target", "dust", "ingot"); + var malformed = new gregtech.compat.common.MaterialProcessDisplay.Step(target.reference(), target.name(), target.icon(), + java.util.Arrays.asList(target.inputs().get(0), source.outputs().get(0), null), target.outputs(), + List.of(), java.util.Optional.empty(), true); + var validLink = layoutConnection("clean_source", "clean_target", "dust"); + var page = new gregtech.compat.common.MaterialProcessDisplay.Page( + net.minecraft.network.chat.Component.literal("Copper"), "Copper", + java.util.Arrays.asList(source, malformed, source, null), + java.util.Arrays.asList(validLink, validLink, layoutConnection("missing", "clean_target", "dust"), + layoutConnection("clean_source", "clean_target", "raw"), null), + List.of(), 0, 0, gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE); + helper.assertTrue(page.steps().size() == 2 && page.connections().equals(List.of(validLink)), + "invalid and duplicate records are removed while valid steps and links survive"); + helper.assertTrue(malformed.inputs().equals(target.inputs()) && !malformed.resolved(), + "removing invalid ports does not claim that the remaining recipe is fully resolved"); + helper.assertTrue(page.number() == 1 && page.total() == 1 && !page.notices().isEmpty(), + "missing page hints fall back to partial coverage without aborting registration"); + new gregtech.compat.common.MaterialProcessOverview(page); + var icons = new ArrayList(); + for (int index = 0; index < 24; index++) icons.add(new ItemStack(Items.IRON_INGOT)); + icons.add(ItemStack.EMPTY); + var port = new gregtech.compat.common.MaterialProcessDisplay.Port(source.outputs().get(0).resource(), "Copper", + source.name(), icons, gregtech.compat.common.MaterialProcessDisplay.Role.UNKNOWN, false, source.name(), + java.util.OptionalInt.of(-1), List.of()); + helper.assertTrue(port.iconCount() == 24 && port.chance().isEmpty(), + "supplied representatives survive while empty icons and invalid chance values are removed"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void projectionKeepsLargePagesWithoutExpandingConnections(GameTestHelper helper) { + var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); + var builder = source.viewerBuilder(); + var ironIn = builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()); + var ironOut = builder.item(new ItemStack(Items.IRON_INGOT), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000)); + for (int index = 0; index < 600; index++) + builder.recipe(new gregtech.api.addon.material.DataKey("test", "many_rows/" + index), "Source", new ItemStack(Items.FURNACE), + List.of(), List.of(ironOut), List.of()); + for (int index = 0; index < 8; index++) + builder.recipe(new gregtech.api.addon.material.DataKey("test", "many_uses/" + index), "Use", new ItemStack(Items.STONECUTTER), + List.of(ironIn), List.of(), List.of()); + var snapshot = builder.build(); + var root = snapshot.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); + var page = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, root.resource(), + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); + helper.assertTrue(page.steps().size() == 608 && page.connections().isEmpty() && page.flows().size() == 1 + && page.flows().get(0).connectionCount() == 4800, + "material pages retain all direct rows and dense associations without allocating pairwise links"); + helper.assertTrue(gregtech.compat.common.MaterialProcessProjection.indexedPorts(snapshot, root.resource()).size() == 2, + "viewer registration indexes each resource and role once instead of every recipe occurrence"); + var graph = new gregtech.compat.common.MaterialProcessOverview(page); + helper.assertTrue(graph.flows().equals(page.flows()), "compact native associations survive the layout unchanged"); + helper.assertTrue(graph.nodes().stream().filter(node -> node.machine()).mapToInt(node -> node.steps.size()).sum() == 608, + "folding a large page retains every original recipe reference"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void compactFlowsKeepUnconfirmedSourcesAcrossMaterialSections(GameTestHelper helper) { + var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); + var builder = source.viewerBuilder(); + var ironIn = builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()); + var ironOut = builder.item(new ItemStack(Items.IRON_INGOT), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000)); + var copperIn = builder.item(new ItemStack(Items.COPPER_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()); + var copperOut = builder.item(new ItemStack(Items.COPPER_INGOT), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000)); + for (int index = 0; index < 2; index++) + builder.recipe(new gregtech.api.addon.material.DataKey("test", "flow_source_" + index), "Source", new ItemStack(Items.FURNACE), + List.of(copperIn), List.of(ironOut), List.of(), index == 0); + var target = new gregtech.api.addon.material.DataKey("test", "flow_target"); + builder.recipe(target, "Use", new ItemStack(Items.STONECUTTER), List.of(ironIn), List.of(copperOut), List.of()); + var snapshot = builder.build(); + var root = snapshot.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); + var page = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, root.resource(), + gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); + var flow = page.flows().get(0); + helper.assertTrue(flow.sources().size() == 2 && flow.targets().equals(List.of(target)) && flow.connectionCount() == 2, + "a compact resource group keeps both exact source associations"); + var graph = new gregtech.compat.common.MaterialProcessOverview(page); + helper.assertTrue(graph.bands().size() == 2 && graph.edges().stream() + .filter(edge -> !edge.endpoint().output() && edge.endpoint().step().reference().equals(target)) + .noneMatch(edge -> edge.confirmed()), + "an unconfirmed source keeps its consuming ports dashed across section boundaries"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void invalidNativeRecipeDoesNotDiscardOtherSnapshotRows(GameTestHelper helper) { + var valid = row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, Items.COPPER_INGOT); + var broken = row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, Items.COPPER_BLOCK); + broken.mChances[0] = -1; + var rows = new ArrayList<>(List.of(valid, broken)); + var map = new RecipeMap(rows, + "gt.test.process.invalid", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, + false, false, false, false); + RecipeMap.unregister(map); + rows.add(null); + var snapshot = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of(map)); + var root = snapshot.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); + var query = snapshot.queryMaterial(root.resource(), Budgets.MATERIAL_PAGE); + helper.assertTrue(query.steps().size() == 1 && snapshot.recipe(query.steps().get(0).reference()).orElseThrow().recipe() == valid, + "a malformed native recipe is isolated without losing the valid recipe generation"); + helper.assertTrue(query.notices().stream().anyMatch(notice -> notice.code().equals("invalid_process_data") && notice.omitted() == 2), + "excluded native rows retain an explicit coverage notice"); + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) + public static void rejectedViewerRowsDoNotHideValidMaterialRoots(GameTestHelper helper) { + var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, + new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); + var builder = source.viewerBuilder(); + var iron = builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()); + var copper = builder.item(new ItemStack(Items.COPPER_INGOT), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000)); + var valid = new gregtech.api.addon.material.DataKey("test", "valid_root_recipe"); + builder.recipe(valid, "Valid", new ItemStack(Items.FURNACE), List.of(iron), List.of(copper), List.of()); + var rejected = new gregtech.api.addon.material.DataKey("test", "rejected_root_recipe"); + var ore = new Resource(new gregtech.api.addon.material.DataKey("test", "rejected_preferred_root"), + "Iron", "ore", "solid", "item:test:ore"); + var conflict = new Resource(copper.resource().key(), "Copper", "dust", "solid", "item:test:conflict"); + builder.recipe(rejected, "Invalid", new ItemStack(Items.FURNACE), + List.of(new Port(ore, Role.CONSUMED, iron.amount(), iron.chance(), true, List.of())), + List.of(new Port(conflict, Role.UNKNOWN, copper.amount(), copper.chance(), true, List.of())), List.of()); + var snapshot = builder.build(); + var root = snapshot.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); + var query = snapshot.queryMaterial(root.resource(), Budgets.MATERIAL_PAGE); + helper.assertTrue(root.resource().equals(iron.resource().key()) && query.steps().size() == 1 + && query.steps().get(0).reference().equals(valid) && snapshot.resource(ore.key()).isEmpty(), + "a rejected preferred root falls back to a valid resource without leaving partial recipe data"); + helper.succeed(); + } + @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) public static void overviewIndexesOnlyItsOwnMaterialAndFindsNativeFocus(GameTestHelper helper) { var input = displayPort("copper_input", "Copper", Items.COPPER_INGOT, false); @@ -298,8 +591,12 @@ public static void overviewMatchesItemsAcrossCopiesAndKeepsRecipesSeparate(GameT net.minecraft.network.chat.Component.literal("source"), new ItemStack(Items.FURNACE), List.of(displayPort("external_ore", "Other", Items.RAW_COPPER, false)), List.of(layoutPort("raw", true)), List.of(), java.util.Optional.empty(), true); + var branch = layoutStep("branch", "raw", "plate", "pressing"); + branch = new gregtech.compat.common.MaterialProcessDisplay.Step(branch.reference(), branch.name(), branch.icon(), + List.of(branch.inputs().get(0), layoutPort("plate_blank", false)), branch.outputs(), + List.of(), java.util.Optional.empty(), true); var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage( - List.of(source, layoutStep("convert", "raw", "ingot"), layoutStep("branch", "raw", "plate")), + List.of(source, layoutStep("convert", "raw", "ingot"), branch), List.of(layoutConnection("source", "convert", "raw"), layoutConnection("source", "branch", "raw")))); var raw = graph.find(port -> port.identity().equals("raw")); var matching = graph.matchingNodes(raw); @@ -389,7 +686,7 @@ public static void overviewSharesHubsWithoutInventingConnections(GameTestHelper helper.assertTrue(node.endpoints.size() == 1, "each local copy owns its native endpoint"); var endpoint = node.endpoints.get(0); var machine = graph.nodes().stream().filter(candidate -> candidate.machine() - && candidate.steps.get(0).reference().equals(endpoint.step().reference())).findFirst().orElseThrow(); + && candidate.steps.contains(endpoint.step())).findFirst().orElseThrow(); helper.assertTrue(Math.abs(node.layer - machine.layer) == 1, "local copies stay next to their consuming or producing machine"); } @@ -497,8 +794,12 @@ public static void overviewKeepsFirstOutputAndVariantsTogether(GameTestHelper he new gregtech.api.addon.material.DataKey("test", "lens_" + index), base.name(), base.icon(), base.inputs(), List.of(base.outputs().get(0), layoutPort("a_dust_" + index, true)), List.of(), java.util.Optional.empty(), true)); - for (int index = 0; index < 12; index++) - steps.add(layoutStep("other_" + index, "gem", "other_output_" + index)); + for (int index = 0; index < 12; index++) { + var other = layoutStep("other_" + index, "gem", "other_output_" + index, "other_process_" + index); + steps.add(new gregtech.compat.common.MaterialProcessDisplay.Step(other.reference(), other.name(), other.icon(), + List.of(other.inputs().get(0), layoutPort("other_input_" + index, false)), other.outputs(), + List.of(), java.util.Optional.empty(), true)); + } var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); var machine = graph.nodes().stream().filter(node -> node.machine() && node.steps.size() == 2) .findFirst().orElseThrow(); @@ -654,8 +955,12 @@ public static void overviewShowsPortYieldsAndOrdersRecoveryAfterConversions(Game } private static gregtech.compat.common.MaterialProcessDisplay.Step layoutStep(String id, String input, String output) { + return layoutStep(id, input, output, "cutting"); + } + + private static gregtech.compat.common.MaterialProcessDisplay.Step layoutStep(String id, String input, String output, String process) { return new gregtech.compat.common.MaterialProcessDisplay.Step(new gregtech.api.addon.material.DataKey("test", id), - net.minecraft.network.chat.Component.literal(id), new ItemStack(Items.STONECUTTER), + net.minecraft.network.chat.Component.literal(process), new ItemStack(Items.STONECUTTER), List.of(layoutPort(input, false)), List.of(layoutPort(output, true)), List.of(), java.util.Optional.empty(), true); } From 538b95c0e86f0b820b5c61c05cb74a57bc146270 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Mon, 16 Nov 2026 00:08:43 +0800 Subject: [PATCH 10/17] remove excess tests --- .../material/MaterialBaselineSnapshot.java | 113 - .../material/MaterialBaselineTest.java | 302 -- .../material/MaterialBaselineTestAddon.java | 39 - .../material/MaterialReferenceAudit.java | 186 - .../material/MaterialLifecycleProbe.java | 407 -- .../MaterialMetadataProbeContributor.java | 312 -- .../material/MaterialRegistrationTest.java | 78 - .../gregtech/material-import-references.tsv | 4064 ----------------- .../gregtech/material-reference-history.tsv | 94 - docs/architecture/packages/content.md | 2 +- .../development/validation/checks/gametest.md | 8 +- docs/development/validation/checks/junit.md | 2 +- .../validation/checks/manual-ingame.md | 4 +- docs/integration/material-baseline.md | 16 +- docs/integration/material-process-snapshot.md | 13 +- .../recipe/MaterialProcessSnapshotTests.java | 1149 ----- .../gametest/MaterialBaselineAddon.java | 110 - .../gametest/MaterialBaselineTests.java | 1119 ----- ...pi.addon.material.AddonMaterialContributor | 1 - tools/material/README.md | 2 +- 20 files changed, 19 insertions(+), 8002 deletions(-) delete mode 100644 core/src/test/java/gregtech/content/material/MaterialBaselineSnapshot.java delete mode 100644 core/src/test/java/gregtech/content/material/MaterialBaselineTest.java delete mode 100644 core/src/test/java/gregtech/content/material/MaterialBaselineTestAddon.java delete mode 100644 core/src/test/java/gregtech/content/material/MaterialReferenceAudit.java delete mode 100644 core/src/test/java/gregtech/engine/material/MaterialLifecycleProbe.java delete mode 100644 core/src/test/java/gregtech/engine/material/MaterialMetadataProbeContributor.java delete mode 100644 core/src/test/resources/gregtech/material-import-references.tsv delete mode 100644 core/src/test/resources/gregtech/material-reference-history.tsv delete mode 100644 minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java delete mode 100644 minecraft/src/test/java/gregtech/gametest/MaterialBaselineAddon.java delete mode 100644 minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java delete mode 100644 minecraft/src/test/resources/META-INF/services/gregtech.api.addon.material.AddonMaterialContributor diff --git a/core/src/test/java/gregtech/content/material/MaterialBaselineSnapshot.java b/core/src/test/java/gregtech/content/material/MaterialBaselineSnapshot.java deleted file mode 100644 index 5a39fbb41..000000000 --- a/core/src/test/java/gregtech/content/material/MaterialBaselineSnapshot.java +++ /dev/null @@ -1,113 +0,0 @@ -package gregtech.content.material; - -import gregtech.api.material.GTMaterial; -import gregtech.api.material.MaterialComponent; -import gregtech.api.mod.ModData; -import gregtech.content.data.generated.MaterialForms; -import gregtech.engine.addon.AddonMaterials; -import gregtech.engine.material.GTMaterialRegistry; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -/** Test-only, stable projection; raw identity and resolved identity deliberately occupy separate columns. */ -public final class MaterialBaselineSnapshot { - private MaterialBaselineSnapshot() {} - - public static String identity(GTMaterial material) { - if (material == null) return "-"; - // Addon numeric ids depend on the installed contributor set. - return (AddonMaterials.owns(material) ? AddonMaterials.owner(material) : "core") + ":" + material.getName(); - } - - public static String components(List parts, boolean ordered) { - var stream = parts.stream().map(part -> identity(part.material().resolve()) + "=" + part.amount()); - return (ordered ? stream : stream.sorted()).collect(Collectors.joining(",")); - } - - public static List materials(Collection materials) { - return materials.stream() - .map(raw -> { - var m = raw.resolve(); - return String.join( - "\t", - identity(raw), - identity(m), - AddonMaterials.owns(raw) ? "dynamic" : Integer.toString(raw.getId()), - AddonMaterials.owns(m) ? "dynamic" : Integer.toString(m.getId()), - Boolean.toString(raw.isValid()), - Boolean.toString(m.isValid()), - m.getSourceModName(), - m.getProtons() + "/" + m.getElectrons() + "/" + m.getNeutrons() + "/" + m.getMass(), - m.getMeltingPoint() + "/" + m.getBoilingPoint() + "/" + Float.toString(m.getDensity()), - m.getProperties().stream().map(Enum::name).sorted().collect(Collectors.joining(",")), - m.getFurnaceBurnTime() + "/" + identity(m.getTargetBurningMaterial()) + "/" - + m.getTargetBurningAmount(), - identity(m.getTargetCrushingMaterial()) + "=" + m.getTargetCrushingAmount(), - identity(m.getTargetSmeltingMaterial()) + "=" + m.getTargetSmeltingAmount(), - identity(m.getTargetPulverMaterial()) + "=" + m.getTargetPulverAmount(), - m.getByProducts().stream() - .map(MaterialBaselineSnapshot::identity) - .collect(Collectors.joining(",")), - Long.toString(m.getCompositionDivider()), - components(m.getCompositionComponents(), true), - m.getAliasesToThis().stream() - .map(MaterialBaselineSnapshot::identity) - .sorted() - .collect(Collectors.joining(",")), - MaterialForms.of(m).stream().sorted().collect(Collectors.joining(","))); - }) - .sorted() - .toList(); - } - - public static List prefixes() { - return gregtech.engine.prefix.PrefixRegistry.all().stream() - .map(p -> p.getName() + "\t" + p.getMaterialWeight()) - .sorted() - .toList(); - } - - @SuppressWarnings("unchecked") - private static List aliases() throws Exception { - var field = GTMaterialRegistry.class.getDeclaredField("BY_NAME"); - field.setAccessible(true); - var names = (java.util.Map) field.get(null); - return names.entrySet().stream() - .map(entry -> entry.getKey() + "\t" + identity(entry.getValue().resolve())) - .sorted() - .toList(); - } - - /** Launched by JUnit in independent JVMs, without adding a production reset hook. */ - public static void main(String[] args) throws Exception { - ModData.bindPresence(id -> false); - if (args.length > 1) { - try (var loader = new java.net.URLClassLoader( - new java.net.URL[] {Path.of(args[1]).toUri().toURL()}, - MaterialBaselineSnapshot.class.getClassLoader())) { - AddonMaterials.collectContributors(loader); - } - } - GTMaterialRegistry.init(); - GTMaterialRegistry.postInit(); - Path output = Path.of(args[0]); - Files.createDirectories(output); - write(output.resolve("materials.tsv"), materials(GTMaterialRegistry.allMaterials())); - write(output.resolve("prefixes.tsv"), prefixes()); - write(output.resolve("aliases.tsv"), aliases()); - write( - output.resolve("references.tsv"), - MaterialReferenceAudit.collect().stream() - .map(MaterialReferenceAudit::describe) - .sorted() - .toList()); - } - - static void write(Path path, List rows) throws IOException { - Files.write(path, rows); - } -} diff --git a/core/src/test/java/gregtech/content/material/MaterialBaselineTest.java b/core/src/test/java/gregtech/content/material/MaterialBaselineTest.java deleted file mode 100644 index 6031c342e..000000000 --- a/core/src/test/java/gregtech/content/material/MaterialBaselineTest.java +++ /dev/null @@ -1,302 +0,0 @@ -package gregtech.content.material; - -import gregtech.api.material.GTMaterial; -import gregtech.api.material.GTValues; -import gregtech.api.material.MaterialComponent; -import gregtech.content.data.MaterialPrefix; -import gregtech.content.recipe.MaterialRecoveryRules; -import gregtech.engine.material.GTMaterialRegistry; -import gregtech.engine.material.ItemComposition; -import gregtech.engine.material.ItemCompositionSource; -import gregtech.engine.material.VanillaUnificationDefinitions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import static org.junit.jupiter.api.Assertions.*; - -class MaterialBaselineTest { - @BeforeAll - static void init() { - MaterialTestFixture.ensureInitialized(); - } - - @Test - void cleanJvmSnapshotsAreRepeatableAndSpiIsIsolated() throws Exception { - Path output = MaterialReferenceAudit.root().resolve("work/material-system-refactor/core"); - runSnapshot(output.resolve("first"), null); - runSnapshot(output.resolve("second"), null); - for (String file : List.of("materials.tsv", "prefixes.tsv", "aliases.tsv", "references.tsv")) - assertEquals( - Files.readString(output.resolve("first/" + file)), - Files.readString(output.resolve("second/" + file)), - file); - Path spi = output.resolve("spi"); - Path service = spi.resolve("META-INF/services/gregtech.api.addon.material.AddonMaterialContributor"); - Files.createDirectories(service.getParent()); - Files.writeString(service, MaterialBaselineTestAddon.class.getName() + "\n"); - runSnapshot(output.resolve("addon"), spi); - var addon = Files.readAllLines(output.resolve("addon/materials.tsv")); - var base = Files.readAllLines(output.resolve("first/materials.tsv")); - assertTrue(base.stream().noneMatch(line -> line.contains("BaselineCompound"))); - String row = addon.stream() - .filter(line -> line.startsWith("material_baseline_test:BaselineCompound\t")) - .findFirst() - .orElseThrow(); - assertTrue(row.contains("\tdynamic\ttrue\ttrue\t"), row); - assertTrue(row.contains("CENTRIFUGE"), row); - assertTrue(row.contains("core:Iron=" + GTValues.U * 2 + ",core:Copper=" + GTValues.U), row); - assertEquals( - base, - addon.stream() - .filter(line -> !line.startsWith("material_baseline_test:")) - .toList()); - } - - private static void runSnapshot(Path output, Path spi) throws Exception { - Files.createDirectories(output); - var classpath = new ArrayList(); - for (Class type : List.of(MaterialBaselineSnapshot.class, GTMaterialRegistry.class, GTMaterial.class)) - classpath.add(Path.of(type.getProtectionDomain() - .getCodeSource() - .getLocation() - .toURI()) - .toString()); - classpath.add(Path.of(MaterialBaselineTest.class - .getResource("/gregtech/material-reference-history.tsv") - .toURI()) - .getParent() - .getParent() - .toString()); - var command = new ArrayList<>(List.of( - Path.of(System.getProperty("java.home"), "bin/java").toString(), - "-cp", - String.join(File.pathSeparator, classpath), - MaterialBaselineSnapshot.class.getName(), - output.toString())); - if (spi != null) command.add(spi.toString()); - var process = new ProcessBuilder(command) - .directory(MaterialReferenceAudit.root().toFile()) - .redirectErrorStream(true) - .redirectOutput(output.resolve("startup.log").toFile()) - .start(); - boolean finished = process.waitFor(45, TimeUnit.SECONDS); - if (!finished) process.destroyForcibly(); - assertTrue(finished, "snapshot JVM timed out: " + output); - assertEquals(0, process.exitValue(), () -> "snapshot JVM failed; see " + output.resolve("startup.log")); - } - - @Test - void componentNormalizationKeepsThePrimaryAndSemanticOrder() { - var iron = MaterialComponent.of(Materials.Iron, GTValues.U); - var copper = MaterialComponent.of(Materials.Copper, GTValues.U * 2); - assertEquals( - MaterialBaselineSnapshot.components(List.of(iron, copper), false), - MaterialBaselineSnapshot.components(List.of(copper, iron), false)); - assertNotEquals( - MaterialBaselineSnapshot.components(List.of(iron, copper), true), - MaterialBaselineSnapshot.components(List.of(copper, iron), true)); - var composition = - new ItemComposition(null, List.of(iron, copper), Materials.Iron, "normalization fixture", true); - assertSame(Materials.Iron, composition.material()); - assertThrows( - IllegalArgumentException.class, - () -> new ItemComposition( - null, List.of(MaterialComponent.of(Materials.Iron, -1)), "invalid fixture", true)); - var reversed = new ArrayList<>(GTMaterialRegistry.allMaterials()); - java.util.Collections.reverse(reversed); - assertEquals( - MaterialBaselineSnapshot.materials(GTMaterialRegistry.allMaterials()), - MaterialBaselineSnapshot.materials(reversed)); - for (var material : GTMaterialRegistry.allMaterials()) { - if (!material.resolve().isValid()) continue; - for (var part : material.getCompositionComponents()) { - assertTrue(part.material().resolve().isValid(), material.getName() + " component identity"); - assertTrue(part.amount() > 0, material.getName() + " component amount"); - } - if (material.hasComposition()) assertTrue(material.getCompositionDivider() > 0, material.getName()); - } - } - - @Test - void referencesAreClassifiedAndNewInvalidReferencesFailWithContext() throws Exception { - var rows = MaterialReferenceAudit.collect().stream() - .map(MaterialReferenceAudit::describe) - .sorted() - .toList(); - Path output = MaterialReferenceAudit.root().resolve("work/material-system-refactor/core"); - Files.createDirectories(output); - Files.write(output.resolve("reference-audit.tsv"), rows); - var failures = rows.stream() - .filter(row -> row.endsWith("\tDANGLING") || row.endsWith("\tID_NAME_MISMATCH")) - .toList(); - try (var stream = getClass().getResourceAsStream("/gregtech/material-reference-history.tsv")) { - assertNotNull(stream); - var seen = new java.util.HashSet(); - for (String line : new String(stream.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8) - .lines() - .toList()) { - if (line.isBlank() || line.startsWith("#")) continue; - var cells = line.split("\t", -1); - String key = String.join("\t", java.util.Arrays.copyOf(cells, 5)); - assertTrue(seen.add(key), "duplicate historical reference: " + key); - assertTrue(rows.contains(key + "\t" + cells[5]), "stale historical classification: " + line); - } - } - assertTrue( - failures.isEmpty(), - () -> "Invalid material references: " + failures + "; see " + output.resolve("reference-audit.tsv")); - var missing = new MaterialReferenceAudit.Reference( - "composition", "Iron", "component[0]", "BaselineMissingMaterial", 0); - var error = assertThrows(IllegalArgumentException.class, () -> MaterialReferenceAudit.requireValid(missing)); - assertTrue(error.getMessage().contains("composition\tIron\tcomponent[0]\tBaselineMissingMaterial")); - assertThrows( - IllegalArgumentException.class, - () -> MaterialReferenceAudit.requireValid(new MaterialReferenceAudit.Reference( - "decomposition", "Iron", "owner", "Copper", Materials.Iron.getId()))); - } - - @Test - void auditedParityExpectationsRemainSeparateFromObservedDifferences() { - // MT.Fe / MT.Cu and the explicit GT6CE Graphite decision are correctness expectations. - assertSame(GTMaterialRegistry.get("Fe"), GTMaterialRegistry.get(260)); - assertSame(GTMaterialRegistry.get("Cu"), GTMaterialRegistry.get(290)); - var graphite = GTMaterialRegistry.get("Graphite"); - assertEquals(GTValues.U, graphite.getTargetSmeltingAmount()); - assertSame(GTMaterialRegistry.get("C"), graphite.getTargetSmeltingMaterial()); - var plan = MaterialRecoveryRules.dustPlan(72 * GTValues.U); - assertTrue(plan.complete()); - assertEquals(72 * GTValues.U, plan.representedUnits()); - assertEquals(0, plan.remainderUnits()); - assertEquals(2, plan.stackCount()); - assertEquals( - List.of( - new MaterialRecoveryRules.DustPile(MaterialPrefix.dust, 64), - new MaterialRecoveryRules.DustPile(MaterialPrefix.dust, 8)), - plan.piles()); - var slot = MaterialRecoveryRules.dustSlotPlan(72 * GTValues.U); - assertFalse(slot.complete()); - assertEquals(64 * GTValues.U, slot.representedUnits()); - assertEquals(8 * GTValues.U, slot.remainderUnits()); - assertEquals(List.of(new MaterialRecoveryRules.DustPile(MaterialPrefix.dust, 64)), slot.piles()); - var eighth = MaterialRecoveryRules.dustSlotPlan(9 * GTValues.U72); - assertTrue(eighth.complete()); - assertEquals(9 * GTValues.U72, eighth.representedUnits()); - assertEquals(List.of(new MaterialRecoveryRules.DustPile(MaterialPrefix.dustDiv72, 9)), eighth.piles()); - - var composition = new ItemComposition( - null, - List.of(MaterialComponent.of(Materials.Gold, 72 * GTValues.U)), - Materials.Gold, - List.of(new ItemCompositionSource( - ItemCompositionSource.Kind.EXPLICIT, "recovery-test", "test", "", "")), - true); - var shredder = MaterialRecoveryRules.planShredder(composition, 4); - assertTrue(shredder.accepted()); - assertEquals(2, shredder.stackCount()); - assertEquals( - MaterialRecoveryRules.shredderWork(Materials.Gold), - MaterialRecoveryRules.planShredderDamaged( - new ItemComposition( - null, - List.of(MaterialComponent.of(Materials.Gold, GTValues.U)), - Materials.Gold, - List.of(new ItemCompositionSource( - ItemCompositionSource.Kind.EXPLICIT, - "damaged-dynamic-work", - "test", - "", - "")), - true), - 4, - false) - .duration()); - assertEquals( - MaterialRecoveryRules.staticShredderWork(Materials.Gold), - MaterialRecoveryRules.planShredderDamaged( - new ItemComposition( - null, - List.of(MaterialComponent.of(Materials.Gold, GTValues.U)), - Materials.Gold, - List.of(new ItemCompositionSource( - ItemCompositionSource.Kind.EXPLICIT, - "damaged-static-work", - "test", - "", - "")), - true), - 4, - true) - .duration()); - assertEquals( - MaterialRecoveryRules.ShredderRejection.OUTPUT_LIMIT, - MaterialRecoveryRules.planShredder(composition, 1).rejection()); - var subFraction = new ItemComposition( - null, - List.of(MaterialComponent.of(Materials.Gold, 1)), - Materials.Gold, - List.of(new ItemCompositionSource( - ItemCompositionSource.Kind.EXPLICIT, "recovery-remainder-test", "test", "", "")), - true); - assertEquals( - MaterialRecoveryRules.ShredderRejection.UNREPRESENTABLE_AMOUNT, - MaterialRecoveryRules.planShredder(subFraction, 4).rejection()); - var damagedFraction = new ItemComposition( - null, - List.of(MaterialComponent.of(Materials.Gold, GTValues.U * 24 / 25)), - Materials.Gold, - List.of(new ItemCompositionSource( - ItemCompositionSource.Kind.EXPLICIT, "damaged-remainder-test", "test", "", "")), - true); - assertEquals( - MaterialRecoveryRules.ShredderRejection.UNREPRESENTABLE_AMOUNT, - MaterialRecoveryRules.planShredder(damagedFraction, 4).rejection()); - var damagedPlan = MaterialRecoveryRules.planShredderDamaged(damagedFraction, 4, false); - assertTrue(damagedPlan.accepted()); - assertTrue(damagedPlan.outputs().get(0).dust().remainderUnits() > 0); - assertTrue(damagedPlan.skippedComponents().stream() - .anyMatch(component -> - component.reason() == MaterialRecoveryRules.ShredderRejection.UNREPRESENTABLE_AMOUNT)); - } - - @Test - void shredderProfilesKeepStaticAndDynamicMultipliersSeparate() { - assertEquals( - 256L * Math.max(1, Materials.NetherStar.getToolQuality() + 1), - MaterialRecoveryRules.staticShredderWork(Materials.NetherStar)); - assertEquals( - 16L * Math.max(1, Materials.Rubber.getToolQuality() + 1), - MaterialRecoveryRules.staticShredderWork(Materials.Rubber)); - assertEquals( - 64L * Math.max(1, Materials.Firestone.getToolQuality() + 1), - MaterialRecoveryRules.shredderWork(Materials.Firestone)); - assertEquals( - 2L * Math.max(1, Materials.Rubber.getToolQuality() + 1), - MaterialRecoveryRules.shredderWork(Materials.Rubber)); - assertEquals( - 2L * Math.max(1, Materials.MeatRotten.getToolQuality() + 1), - MaterialRecoveryRules.shredderWork(Materials.MeatRotten)); - } - - @Test - void recoveryOreClassificationKeepsRawItemsAndBlocksDistinct() { - assertSame( - VanillaUnificationDefinitions.OreInputKind.ORE, - VanillaUnificationDefinitions.oreInputKind("copper_ore")); - assertSame( - VanillaUnificationDefinitions.OreInputKind.RAW_METAL, - VanillaUnificationDefinitions.oreInputKind("raw_iron")); - assertSame( - VanillaUnificationDefinitions.OreInputKind.RAW_METAL_BLOCK, - VanillaUnificationDefinitions.oreInputKind("raw_iron_block")); - assertSame( - VanillaUnificationDefinitions.OreInputKind.OTHER, - VanillaUnificationDefinitions.oreInputKind("iron_ingot")); - } -} diff --git a/core/src/test/java/gregtech/content/material/MaterialBaselineTestAddon.java b/core/src/test/java/gregtech/content/material/MaterialBaselineTestAddon.java deleted file mode 100644 index 9f2781965..000000000 --- a/core/src/test/java/gregtech/content/material/MaterialBaselineTestAddon.java +++ /dev/null @@ -1,39 +0,0 @@ -package gregtech.content.material; - -import gregtech.api.addon.material.*; -import gregtech.api.material.GTValues; -import java.util.List; -import java.util.Set; - -/** Loaded only by the isolated SPI test, never by the ordinary material fixture or a release jar. */ -public final class MaterialBaselineTestAddon implements AddonMaterialContributor { - @Override - public String addonId() { - return "material_baseline_test"; - } - - @Override - public List materials() { - return List.of(MaterialDeclaration.builder("BaselineCompound").dust().build()); - } - - @Override - public void materialInfo(MaterialInfoTool.Registrar registrar) { - registrar.registerProcess( - new MaterialKey("BaselineCompound"), - MaterialProcessKeys.DECOMPOSITION, - MaterialProcessRule.anyForm(new MaterialDecompositionRule( - Set.of(MaterialDecompositionRule.Route.CENTRIFUGE), List.of(), false))); - } - - @Override - public List compositions() { - return List.of(new MaterialComposition( - "BaselineCompound", - 3, - List.of( - new MaterialComposition.Part("Iron", GTValues.U * 2), - new MaterialComposition.Part("Copper", GTValues.U)), - false)); - } -} diff --git a/core/src/test/java/gregtech/content/material/MaterialReferenceAudit.java b/core/src/test/java/gregtech/content/material/MaterialReferenceAudit.java deleted file mode 100644 index 6a25a1e11..000000000 --- a/core/src/test/java/gregtech/content/material/MaterialReferenceAudit.java +++ /dev/null @@ -1,186 +0,0 @@ -package gregtech.content.material; - -import gregtech.api.addon.material.MaterialProcessKeys; -import gregtech.api.addon.material.MaterialTarget; -import gregtech.api.material.GTMaterial; -import gregtech.content.data.generated.MaterialForms; -import gregtech.engine.material.GTMaterialRegistry; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - -/** Audits the committed inputs as well as the live graph, so silently skipped rows remain visible. */ -final class MaterialReferenceAudit { - record Reference(String table, String owner, String field, String name, int id) {} - - enum Kind { - VALID, - ALIAS, - RETIRED, - DANGLING, - ID_NAME_MISMATCH - } - - private MaterialReferenceAudit() {} - - static Path root() { - Path here = Path.of("").toAbsolutePath(); - return Files.isDirectory(here.resolve("core")) ? here : here.getParent(); - } - - static String input(String name) throws Exception { - return Files.readString(root().resolve("core/src/main/java/gregtech/content/data/generated/" + name + ".java")); - } - - static List collect() throws Exception { - var refs = new ArrayList(); - // The retired import is test-only historical input, never fed to runtime link resolution. - try (var stream = - MaterialReferenceAudit.class.getResourceAsStream("/gregtech/material-import-references.tsv")) { - if (stream == null) throw new IllegalStateException("Missing historical import audit"); - for (String line : new String(stream.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8) - .lines() - .toList()) { - if (line.isBlank() || line.startsWith("#")) continue; - var cells = line.split("\t", -1); - if (cells.length != 6) throw new IllegalStateException("Invalid historical reference: " + line); - refs.add(new Reference(cells[0], cells[1], cells[2], cells[3], Integer.parseInt(cells[4]))); - } - } - for (var declaration : MaterialDefinitions.declarations()) { - var definition = declaration.material(); - var info = declaration.info(); - if (definition.id() > 0) - refs.add(new Reference("catalog", definition.name(), "owner", definition.name(), definition.id())); - int slot = 0; - for (var part : info.composition().parts()) - refs.add(new Reference("catalog", definition.name(), "component[" + slot++ + "]", part.material(), 0)); - var byproducts = info.processes().find(MaterialProcessKeys.ORE_PROCESSING); - if (!byproducts.isEmpty()) - for (var target : byproducts.get(0).value().byproducts()) - refs.add(new Reference("catalog", definition.name(), "byproduct", target.name(), 0)); - var fuel = info.processes().find(MaterialProcessKeys.FUEL); - for (var target : new MaterialTarget[] { - fuel.isEmpty() ? null : fuel.get(0).value().residue().orElse(null), - first(info, MaterialProcessKeys.CRUSHING), - first(info, MaterialProcessKeys.SMELTING), - first(info, MaterialProcessKeys.PULVERIZING) - }) - if (target != null) - refs.add(new Reference( - "catalog", - definition.name(), - "target", - target.material().name(), - 0)); - for (var target : processing(info).values()) - refs.add(new Reference( - "catalog", - definition.name(), - "processing", - target.material().name(), - 0)); - for (String target : info.relations().members()) - refs.add(new Reference("catalog", definition.name(), "member", target, 0)); - } - return refs; - } - - private static T first( - gregtech.engine.material.MaterialInfoDefinition info, - gregtech.api.addon.material.MaterialProcessKey key) { - var rules = info.processes().find(key); - return rules.isEmpty() ? null : rules.get(0).value(); - } - - private static Map processing(gregtech.engine.material.MaterialInfoDefinition info) { - var result = new HashMap(); - for (var entry : info.processes().rules().entrySet()) { - var kind = MaterialProcessKeys.legacyTargetName(entry.getKey()).orElse(null); - if (kind != null - && !entry.getValue().isEmpty() - && entry.getValue().get(0).value() instanceof MaterialTarget target) result.put(kind, target); - } - return result; - } - - static Map retired() throws Exception { - var result = new HashMap(); - String doc = Files.readString(root().resolve("docs/decisions/parity/material-removal.md")); - var names = Pattern.compile("`([^`]+)`\\((\\d+)").matcher(doc); - while (names.find()) { - result.put(names.group(1), names.group(2)); - result.put(names.group(2), names.group(1)); - result.put(MaterialForms.normalize(names.group(1)), names.group(2)); - } - return result; - } - - static Kind classify(Reference ref) throws Exception { - if (ref.table().equals("decomposition") && ref.id() <= 0) return Kind.ID_NAME_MISMATCH; - GTMaterial byName = GTMaterialRegistry.get(ref.name()); - GTMaterial byId = GTMaterialRegistry.get(ref.id()); - if (ref.id() > 0) { - if (byId.isValid()) { - if (!ref.name().isEmpty() && (!byName.isValid() || byName.resolve() != byId.resolve())) - return Kind.ID_NAME_MISMATCH; - return Kind.VALID; - } - if (ref.table().equals("catalog") && MaterialDefinitions.find(ref.name()) != null) return Kind.VALID; - if (byName.isValid()) return Kind.ID_NAME_MISMATCH; - var retired = retired(); - if (!retired.containsKey(Integer.toString(ref.id()))) return Kind.DANGLING; - return ref.name().isEmpty() || Integer.toString(ref.id()).equals(retired.get(ref.name())) - ? Kind.RETIRED - : Kind.ID_NAME_MISMATCH; - } - if (ref.table().equals("catalog") && MaterialDefinitions.find(ref.name()) != null) return Kind.VALID; - if (byName.isValid()) return byName.getName().equals(ref.name()) ? Kind.VALID : Kind.ALIAS; - if (ref.table().equals("forms")) { - for (var entry : GTMaterialRegistry.registeredNames().entrySet()) - if (MaterialForms.normalize(entry.getKey()).equals(ref.name()) - && entry.getValue().isValid()) return Kind.ALIAS; - long candidates = GTMaterialRegistry.allMaterials().stream() - .map(GTMaterial::resolve) - .distinct() - .filter(m -> MaterialForms.normalize(m.getName()).equals(ref.name())) - .count(); - if (candidates == 1) return Kind.ALIAS; - } - // Each historical exception is tied to one table/owner/field/target, with a reviewed source. - // It cannot admit a new occurrence of that name elsewhere. - try (var stream = - MaterialReferenceAudit.class.getResourceAsStream("/gregtech/material-reference-history.tsv")) { - if (stream == null) throw new IllegalStateException("Missing material reference history"); - String key = ref.table() + "\t" + ref.owner() + "\t" + ref.field() + "\t" + ref.name() + "\t" + ref.id(); - for (String line : new String(stream.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8) - .lines() - .toList()) { - if (line.startsWith("#") || line.isBlank()) continue; - String[] cells = line.split("\t", -1); - if (cells.length != 7 || !cells[5].equals("RETIRED") || cells[6].isBlank()) - throw new IllegalStateException("Invalid reference history: " + line); - if (line.startsWith(key + "\t")) return Kind.valueOf(cells[5]); - } - } - return retired().containsKey(ref.name()) ? Kind.RETIRED : Kind.DANGLING; - } - - static String describe(Reference ref) { - try { - return ref.table() + "\t" + ref.owner() + "\t" + ref.field() + "\t" + ref.name() + "\t" + ref.id() + "\t" - + classify(ref); - } catch (Exception failure) { - throw new IllegalStateException(failure); - } - } - - static void requireValid(Reference ref) throws Exception { - Kind kind = classify(ref); - if (kind == Kind.DANGLING || kind == Kind.ID_NAME_MISMATCH) throw new IllegalArgumentException(describe(ref)); - } -} diff --git a/core/src/test/java/gregtech/engine/material/MaterialLifecycleProbe.java b/core/src/test/java/gregtech/engine/material/MaterialLifecycleProbe.java deleted file mode 100644 index 369fc80f3..000000000 --- a/core/src/test/java/gregtech/engine/material/MaterialLifecycleProbe.java +++ /dev/null @@ -1,407 +0,0 @@ -package gregtech.engine.material; - -import gregtech.api.addon.material.*; -import gregtech.api.material.*; -import gregtech.api.mod.ModData; -import gregtech.content.material.MaterialDefinitions; -import gregtech.content.material.Materials; -import gregtech.engine.addon.AddonCoreServices; -import gregtech.engine.addon.AddonMaterials; -import java.util.List; - -/** Independent lifecycle fixture; intentionally has no dependency on the JUnit runtime. */ -public final class MaterialLifecycleProbe { - private MaterialLifecycleProbe() {} - - private static void check(boolean value) { - if (!value) throw new AssertionError("Lifecycle assertion failed"); - } - - private static RuntimeException rejects(Runnable operation) { - try { - operation.run(); - } catch (RuntimeException failure) { - return failure; - } - throw new AssertionError("Expected operation to fail"); - } - - public static void main(String[] args) throws Exception { - ModData.bindPresence(id -> false); - AddonCoreServices.bind(); - String scenario = args[0]; - check(!MaterialDefinitions.all().isEmpty()); - check(GTMaterialRegistry.allMaterials().size() == 2); - rejects(MaterialViews::catalog); - if (scenario.equals("early")) { - rejects(() -> GTMaterialRegistry.requireInstalled("Iron")); - rejects(() -> GTMaterialRegistry.createMaterial(260, "Iron", "Iron", 0)); - check(GTMaterialRegistry.allMaterials().size() == 2); - GTMaterialRegistry.init(); - check(GTMaterialRegistry.get("Iron").getId() == 260); - return; - } - if (scenario.equals("facade")) { - try { - Class.forName(Materials.class.getName()); - throw new AssertionError("Facade must require bootstrap"); - } catch (ExceptionInInitializerError expected) { - check(expected.getCause() instanceof IllegalStateException); - } - check(GTMaterialRegistry.allMaterials().size() == 2); - check(GTMaterialRegistry.registrationPhase() == GTMaterialRegistry.RegistrationPhase.DEFINITIONS); - return; - } - if (scenario.startsWith("metadata") - || scenario.startsWith("relation") - || scenario.startsWith("process") - || scenario.startsWith("info")) { - System.setProperty("material.metadata.scenario", scenario); - var spi = java.nio.file.Files.createTempDirectory("gt6ce-material-metadata-"); - var service = spi.resolve("META-INF/services/" + AddonMaterialContributor.class.getName()); - java.nio.file.Files.createDirectories(service.getParent()); - java.nio.file.Files.writeString(service, MaterialMetadataProbeContributor.class.getName()); - try (var loader = new java.net.URLClassLoader( - new java.net.URL[] {spi.toUri().toURL()}, MaterialLifecycleProbe.class.getClassLoader())) { - try { - AddonMaterials.collectContributors(loader); - } catch (IllegalStateException failure) { - if (scenario.equals("infoNamespaceFailure")) { - check(failure.getCause() instanceof IllegalArgumentException); - check(failure.getCause().getMessage().contains("cannot declare key")); - return; - } - if (scenario.equals("infoProcessSingleConflictFailure")) { - check(failure.getCause() instanceof IllegalArgumentException); - check(failure.getCause().getMessage().contains("already registered")); - return; - } - throw failure; - } - } - } - var shared = MaterialDefinition.builder(1, "SharedMaterial") - .density(2) - .dust() - .build(); - if (scenario.equals("merge") || scenario.equals("conflict")) { - AddonMaterials.submit("alpha_addon", List.of(shared), List.of(), () -> {}); - AddonMaterials.submit( - "beta_addon", - List.of( - scenario.equals("merge") - ? shared - : MaterialDefinition.builder(1, "SharedMaterial") - .density(3) - .dust() - .build()), - List.of(), - () -> {}); - } - if (scenario.equals("definitionFailure")) - AddonMaterials.submit( - "bad_addon", List.of(MaterialDefinition.builder(1, "Iron").build()), List.of(), () -> {}); - if (scenario.equals("linkFailure")) - AddonMaterials.submit( - "bad_addon", - List.of(), - List.of(), - () -> GTMaterialRegistry.registerAlias("Typo", "NoSuchMaterial")); - if (scenario.equals("normal")) - AddonMaterials.submit("legal_link", List.of(), List.of(), () -> { - check(Materials.Iron == GTMaterialRegistry.get(260)); - check(Materials.Coal.getFurnaceBurnTime() > 0); - check(Materials.Iron.has(MaterialProperty.NEVER_FURNACE)); - GTMaterialRegistry.registerAlias("LinkedIron", "Iron"); - rejects(MaterialViews::catalog); - rejects(() -> GTMaterialRegistry.createMaterial(9000, "Late", "Late", 0)); - }); - if (scenario.equals("aliasPublication")) - AddonMaterials.submit( - "alias_addon", - List.of( - MaterialDefinition.builder(1, "AliasSource").dust().build(), - MaterialDefinition.builder(1, "AliasTarget").dust().build()), - List.of(), - () -> GTMaterialRegistry.get("AliasSource").setRegistration(GTMaterialRegistry.get("AliasTarget"))); - if (scenario.endsWith("Failure") || scenario.equals("conflict")) { - var failure = rejects(GTMaterialRegistry::init); - check(GTMaterialRegistry.registrationPhase() == GTMaterialRegistry.RegistrationPhase.FAILED); - if (scenario.equals("conflict")) - check(failure.getMessage().contains("density") - && failure.getMessage().contains("alpha_addon") - && failure.getMessage().contains("beta_addon")); - if (scenario.equals("infoLegacyToolConflictFailure")) - check(failure.getMessage().contains("tool profile") - && failure.getMessage().contains("MetadataMaterial") - && failure.getMessage().contains("metadata_test")); - if (scenario.equals("processGroupMaterialFailure")) - check(failure.getMessage().contains("unknown material") - && failure.getMessage().contains("AnyIron")); - rejects(GTMaterialRegistry::init); - rejects(() -> GTMaterialRegistry.get("Iron")); - rejects(GTMaterialRegistry::allMaterials); - rejects(MaterialViews::catalog); - check(MaterialInfoTool.tool(new MaterialKey("Iron")).isEmpty()); - check(MaterialInfoTool.frozenTool(new MaterialKey("Iron")).isEmpty()); - check(MaterialInfoTool.composition(new MaterialKey("Iron")).isEmpty()); - check(MaterialInfoTool.currentTool(new MaterialKey("Iron")).isEmpty()); - check(MaterialInfoTool.currentComposition(new MaterialKey("Water")).isEmpty()); - check(MaterialInfoTool.currentProcess(new MaterialKey("Graphite"), MaterialProcessKeys.SMELTING) - .isEmpty()); - check(MaterialToolHelper.profile(new MaterialKey("Iron")).isEmpty()); - return; - } - GTMaterialRegistry.init(); - rejects(() -> Materials.Iron.setOreMultiplier(2)); - rejects(() -> Materials.Iron.setRegistration(Materials.Gold)); - var before = List.copyOf(GTMaterialRegistry.allMaterials()); - GTMaterialRegistry.init(); - GTMaterialRegistry.postInit(); - check(before.equals(List.copyOf(GTMaterialRegistry.allMaterials()))); - check(Materials.Trinium == GTMaterialRegistry.get(1260)); - check(GTMaterialRegistry.get("Ke") == Materials.Trinium); - check(GTMaterialRegistry.get("Tn") == GTMaterialRegistry.get("TritaniumElemental")); - check(GTMaterialRegistry.get("Gold") == GTMaterialRegistry.get(790)); - check(GTMaterialRegistry.get("Black") == GTMaterialRegistry.get(8250)); - check(GTMaterialRegistry.get("AntiElectron") == GTMaterialRegistry.get("Positron")); - check(GTMaterialRegistry.get("Iron") != GTMaterialRegistry.get("AntiIron")); - if (scenario.equals("aliasPublication")) { - var source = new MaterialKey("AliasSource"); - var target = new MaterialKey("AliasTarget"); - check(MaterialViews.catalog().resolve(source.name()).orElseThrow().equals(target)); - check(MaterialViews.catalog().find(source).isEmpty()); - check(MaterialViews.catalog().materials().stream() - .noneMatch(material -> material.key().equals(source))); - check(MaterialViews.catalog().find(target).isPresent()); - } - check(MaterialViews.catalog().find(new MaterialKey("AnyIron")).isEmpty()); - check(MaterialViews.catalog() - .find(new MaterialKey("Iron")) - .orElseThrow() - .property(MaterialProperties.MELTING_POINT) - .orElseThrow() - == Materials.Iron.getMeltingPoint()); - check(MaterialViews.catalog().find(new MaterialKey("UnknownMaterial")).isEmpty()); - rejects(() -> MaterialViews.catalog().materials().clear()); - rejects(() -> MaterialViews.catalog().forms().forms().clear()); - if (scenario.equals("normal") || scenario.equals("infoLegacy")) checkEffectiveQueries(); - if (scenario.equals("merge")) { - var material = GTMaterialRegistry.get("SharedMaterial"); - check(material.getId() >= GTMaterialRegistry.ADDON_ID_START); - check(AddonMaterials.owners(material).equals(List.of("alpha_addon", "beta_addon"))); - check(!GTMaterialRegistry.isCoreMaterial(material)); - } - check(MaterialViews.catalog().resolve("Fe").orElseThrow().equals(new MaterialKey("Iron"))); - var woodFamily = new DataKey("gt6ce", "wood_family"); - check(MaterialViews.catalog().tags().members(woodFamily).size() == 32); - check(!MaterialViews.catalog().tags().contains(new MaterialKey("PetrifiedWood"), woodFamily)); - var group = MaterialViews.catalog() - .tags() - .group(new MaterialGroupKey(new DataKey("gt6ce", "anyiron"))) - .orElseThrow(); - check(group.members().contains(new MaterialKey("Iron"))); - check(!MaterialViews.catalog().resolve("AnyIron").isPresent()); - check(MaterialViews.catalog().forms().allows(new MaterialKey("Graphite"), new FormKey("dust"))); - check(MaterialViews.catalog().forms().rules(new MaterialKey("Graphite")).stream() - .anyMatch(rule -> rule.form().equals(new FormKey("dust")) - && rule.kind() == MaterialFormKind.ITEM - && rule.materialUnits() > 0)); - check(MaterialViews.catalog().forms().rules(new MaterialKey("Iron")).stream() - .anyMatch(rule -> - rule.form().equals(new FormKey("blockIngot")) && rule.kind() == MaterialFormKind.BLOCK)); - check(MaterialViews.catalog() - .formBindings() - .find(new MaterialKey("Iron")) - .isEmpty()); - var graphiteSmelting = - MaterialViews.catalog().processes().find(new MaterialKey("Graphite"), MaterialProcessKeys.SMELTING); - check(graphiteSmelting.size() == 1); - check(graphiteSmelting.get(0).value().equals(new MaterialTarget(new MaterialKey("Carbon"), 648648000L))); - rejects(() -> graphiteSmelting.clear()); - if (scenario.equals("metadata")) { - check(MaterialViews.catalog() - .find(new MaterialKey("MetadataMaterial")) - .orElseThrow() - .property(new PropertyKey<>(new DataKey("metadata_test", "hardness"), Integer.class)) - .orElseThrow() - == 3); - check(MaterialViews.catalog() - .tags() - .contains(new MaterialKey("Iron"), new DataKey("metadata_test", "descriptive"))); - check(GTMaterialRegistry.get("MetadataMaterial") - .getProperties() - .equals(java.util.Set.of( - MaterialProperty.DUST, MaterialProperty.GENERATE_DUST, MaterialProperty.UNIT))); - } - if (scenario.equals("relations")) { - var iron = new MaterialKey("Iron"); - var leaf = new DataKey("metadata_test", "leaf"); - var parent = new DataKey("metadata_test", "parent"); - check(MaterialViews.catalog().tags().contains(iron, leaf)); - check(MaterialViews.catalog().tags().contains(iron, parent)); - check(MaterialViews.catalog().tags().members(parent).contains(iron)); - var family = new MaterialGroupKey(new DataKey("metadata_test", "family")); - check(MaterialViews.catalog() - .tags() - .group(family) - .orElseThrow() - .members() - .contains(iron)); - check(MaterialViews.catalog() - .tags() - .group(family) - .orElseThrow() - .members() - .contains(new MaterialKey("Steel"))); - } - if (scenario.contains("Decomposition")) { - var material = new MaterialKey("MetadataMaterial"); - var process = MaterialProcessKeys.DECOMPOSITION; - checkProcessPublication(material, process); - var declared = MaterialViews.catalog() - .processes() - .findSingle(material, process) - .orElseThrow(); - String form = scenario.endsWith("Block") - ? "blockDust" - : scenario.endsWith("Liquid") ? "liquid" : scenario.endsWith("Gas") ? "gas" : "dust"; - check(declared.forms().equals(java.util.Set.of(new FormKey(form)))); - check(declared.value().routes().equals(java.util.Set.of(MaterialDecompositionRule.Route.CENTRIFUGE))); - check(GTMaterialRegistry.get(material.name()).has(MaterialProperty.CENTRIFUGE)); - } - if (scenario.equals("processes")) { - var key = MaterialProcessKey.multiple(new DataKey("metadata_test", "throw_into_water"), String.class); - checkProcessPublication(new MaterialKey("Iron"), key); - var rules = MaterialViews.catalog().processes().find(new MaterialKey("Iron"), new FormKey("dust"), key); - check(rules.size() == 1 && rules.get(0).value().equals("wet")); - check(MaterialViews.catalog() - .processes() - .find(new MaterialKey("Iron"), new FormKey("ingot"), key) - .isEmpty()); - } - if (scenario.equals("processFormAlias") || scenario.equals("infoProcessFormAlias")) { - var key = scenario.equals("processFormAlias") - ? MaterialProcessKey.multiple(new DataKey("metadata_test", "throw_into_water"), String.class) - : MaterialProcessKey.multiple(new DataKey("metadata_test", "typed_process"), String.class); - var iron = new MaterialKey("Iron"); - checkProcessPublication(iron, key); - check(MaterialViews.catalog() - .processes() - .find(iron, new FormKey("itemCasing"), key) - .size() - == 1); - check(MaterialViews.catalog() - .processes() - .find(iron, new FormKey("casingSmall"), key) - .isEmpty()); - } - if (scenario.equals("info")) { - var material = new MaterialKey("MetadataMaterial"); - check(GTMaterialRegistry.get(material.name()).tool().equals(new MaterialToolProfile(1, 3F, 64, 1))); - check(MaterialInfoTool.tool(material).orElseThrow().equals(new MaterialToolProfile(1, 3F, 64, 1))); - check(MaterialInfoTool.tool(new MaterialKey("DefinitelyUnknown")).isEmpty()); - check(MaterialInfoTool.composition(material).orElseThrow().parts().size() == 1); - check(SmeltingMaterialHelper.target(new MaterialKey("Graphite")) - .orElseThrow() - .equals(new MaterialTarget(new MaterialKey("Carbon"), 648648000L))); - check(MaterialViews.catalog().tags().contains(material, new DataKey("metadata_test", "typed_tag"))); - var process = MaterialProcessKey.multiple(new DataKey("metadata_test", "typed_process"), String.class); - check(MaterialViews.catalog() - .processes() - .find(material, process) - .get(0) - .value() - .equals("typed")); - rejects(() -> - MaterialInfoRegistry.addonRegistrar("metadata_test").registerForm(material, new FormKey("dust"))); - } - if (scenario.equals("infoProcessMultiple")) { - var material = new MaterialKey("MetadataMaterial"); - var process = new MaterialProcessKey<>( - new DataKey("metadata_test", "typed_multi"), String.class, MaterialProcessCardinality.MULTIPLE); - checkProcessPublication(material, process); - var rules = MaterialViews.catalog().processes().find(material, process); - check(rules.size() == 2); - check(rules.stream().map(MaterialProcessRule::value).toList().equals(List.of("wet", "dry"))); - check(MaterialViews.catalog() - .processes() - .findSingle(material, process) - .isEmpty()); - } - if (scenario.equals("processMultiple")) { - var material = new MaterialKey("Iron"); - var process = new MaterialProcessKey<>( - new DataKey("metadata_test", "listed_multi"), String.class, MaterialProcessCardinality.MULTIPLE); - checkProcessPublication(material, process); - check(MaterialViews.catalog().processes().find(material, process).size() == 2); - } - if (scenario.equals("infoLegacy")) { - var material = new MaterialKey("MetadataMaterial"); - var composition = MaterialInfoTool.composition(material).orElseThrow(); - check(composition.divider() == 2 && composition.parts().size() == 2 && composition.crucible()); - check(composition.parts().get(0).equals(new MaterialComposition.Part("Iron", GTValues.U))); - check(composition.parts().get(1).equals(new MaterialComposition.Part("Copper", GTValues.U))); - check(MaterialInfoTool.tool(material).orElseThrow().equals(new MaterialToolProfile(3, 7F, 600L, 4))); - check(GregTechMaterials.find(material.name()).toolQuality() == 4); - check(SmeltingMaterialHelper.target(material) - .orElseThrow() - .equals(new MaterialTarget(new MaterialKey("Copper"), GTValues.U2))); - var second = new MaterialKey("MetadataSecond"); - check(!MaterialInfoTool.composition(second).orElseThrow().crucible()); - check(SmeltingMaterialHelper.target(second).isEmpty()); - check(PulverizationMaterialHelper.target(second).isEmpty()); - check(CrushingMaterialHelper.target(second).isEmpty()); - check(MaterialViews.catalog() - .processes() - .find(second, MaterialProcessKeys.SMELTING) - .isEmpty()); - } - rejects(() -> GTMaterialRegistry.registerDefinition(shared.material())); - rejects(() -> GTMaterialRegistry.installAddonMaterial(shared, 10001)); - rejects(() -> GTMaterialRegistry.registerAlias("Fe", "Iron")); - } - - private static void checkProcessPublication(MaterialKey material, MaterialProcessKey process) { - var auxiliary = MaterialInfoRegistry.processes(material).find(process); - check(!auxiliary.isEmpty()); - check(auxiliary.equals(MaterialViews.catalog().processes().find(material, process))); - if (process.cardinality() == MaterialProcessCardinality.SINGLE) - check(MaterialInfoTool.currentProcess(material, process) - .equals(MaterialViews.catalog().processes().findSingle(material, process))); - rejects(() -> auxiliary.clear()); - } - - private static void checkEffectiveQueries() { - for (var view : MaterialViews.catalog().materials()) { - var key = view.key(); - var material = GTMaterialRegistry.get(key.name()); - check(SmeltingMaterialHelper.target(material).equals(SmeltingMaterialHelper.target(key))); - check(CrushingMaterialHelper.target(material).equals(CrushingMaterialHelper.target(key))); - check(PulverizationMaterialHelper.target(material).equals(PulverizationMaterialHelper.target(key))); - check(FuelMaterialHelper.rule(material).equals(FuelMaterialHelper.rule(key))); - check(OreProcessingMaterialHelper.rule(material).equals(OreProcessingMaterialHelper.rule(key))); - check(material.tool() - .equals(new MaterialToolProfile( - material.getToolTypes(), - material.getToolSpeed(), - material.getToolDurability(), - material.getToolQuality()))); - var indexed = MaterialInfoTool.composition(key); - check(indexed.isPresent() == material.hasComposition()); - if (indexed.isPresent()) { - check(indexed.get().divider() == material.getCompositionDivider()); - check(indexed.get() - .parts() - .equals(material.getCompositionComponents().stream() - .map(part -> new MaterialComposition.Part( - part.material().getName(), part.amount())) - .toList())); - } - } - var iron = MaterialViews.catalog().resolve("Fe").orElseThrow(); - check(SmeltingMaterialHelper.target(iron).orElseThrow().equals(new MaterialTarget(iron, GTValues.U))); - check(SmeltingMaterialHelper.isMaterialSmeltable(iron)); - check(PulverizationMaterialHelper.target(iron).orElseThrow().equals(new MaterialTarget(iron, GTValues.U))); - } -} diff --git a/core/src/test/java/gregtech/engine/material/MaterialMetadataProbeContributor.java b/core/src/test/java/gregtech/engine/material/MaterialMetadataProbeContributor.java deleted file mode 100644 index c67e8d772..000000000 --- a/core/src/test/java/gregtech/engine/material/MaterialMetadataProbeContributor.java +++ /dev/null @@ -1,312 +0,0 @@ -package gregtech.engine.material; - -import gregtech.api.addon.material.*; -import gregtech.api.material.GTValues; -import gregtech.api.material.MaterialToolProfile; -import java.util.List; - -/** Test-only SPI fixture for side metadata ownership, namespace and catalog-wide type checks. */ -public final class MaterialMetadataProbeContributor implements AddonMaterialContributor { - public String addonId() { - return "metadata_test"; - } - - public List materials() { - var material = MaterialDeclaration.builder("MetadataMaterial").dust(); - if (System.getProperty("material.metadata.scenario", "").contains("Decomposition")) - material.liquid().gas(); - return List.of( - material.build(), - MaterialDeclaration.builder("MetadataSecond").dust().build()); - } - - @Override - public List compositions() { - String scenario = System.getProperty("material.metadata.scenario"); - if (scenario.contains("Decomposition")) - return List.of(new MaterialComposition( - "MetadataMaterial", 1, List.of(new MaterialComposition.Part("Iron", GTValues.U)), false)); - if (!"infoLegacy".equals(scenario)) return List.of(); - return List.of( - new MaterialComposition( - "MetadataMaterial", - 2, - List.of( - new MaterialComposition.Part("Iron", GTValues.U), - new MaterialComposition.Part("Copper", GTValues.U)), - true), - new MaterialComposition( - "MetadataSecond", 1, List.of(new MaterialComposition.Part("Iron", GTValues.U)), false)); - } - - @Override - public List smeltingTargets() { - return "infoLegacy".equals(System.getProperty("material.metadata.scenario")) - ? List.of(new SmeltingTargetDeclaration("MetadataMaterial", "Copper", GTValues.U2)) - : List.of(); - } - - @Override - public List smeltingTargetRemovals() { - return "infoLegacy".equals(System.getProperty("material.metadata.scenario")) - ? List.of(new SmeltingTargetRemoval("MetadataSecond")) - : List.of(); - } - - @Override - public void link() { - String scenario = System.getProperty("material.metadata.scenario"); - if ("infoLegacy".equals(scenario)) { - var material = GTMaterialRegistry.get("MetadataMaterial"); - material.setToolStats(3, 7F, 600L, 4) - .setCrushing(GTMaterialRegistry.get("Iron"), GTValues.U2) - .setPulver(GTMaterialRegistry.get("Copper"), GTValues.U9) - .setFurnaceBurnTime(100) - .setBurning(GTMaterialRegistry.get("Ashes"), GTValues.U9) - .setOreMultiplier(2) - .setOreProcessingMultiplier(3); - material.addOreByProducts(GTMaterialRegistry.get("Copper")); - GTMaterialRegistry.get("MetadataSecond").setPulver(null, 0).setCrushing(null, 0); - } else if ("infoLegacyToolConflictFailure".equals(scenario)) { - GTMaterialRegistry.get("MetadataMaterial").setToolStats(3, 7F, 600L, 4); - } - } - - public List metadata() { - String scenario = System.getProperty("material.metadata.scenario"); - var value = new PropertyKey<>(new DataKey(addonId(), "hardness"), Integer.class); - return switch (scenario) { - case "metadataUnknownFailure" -> - List.of(new MaterialMetadataDeclaration( - "TypoMaterial", MaterialMetadata.builder().build())); - case "metadataOwnerFailure" -> - List.of(new MaterialMetadataDeclaration( - "Iron", MaterialMetadata.builder().property(value, 3).build())); - case "metadataNamespaceFailure" -> - List.of(new MaterialMetadataDeclaration( - "Iron", - MaterialMetadata.builder() - .tag(new DataKey("another_addon", "label")) - .build())); - case "metadataTypeFailure" -> - List.of( - new MaterialMetadataDeclaration( - "MetadataMaterial", - MaterialMetadata.builder().property(value, 3).build()), - new MaterialMetadataDeclaration( - "MetadataSecond", - MaterialMetadata.builder() - .property(new PropertyKey<>(value.id(), String.class), "hard") - .build())); - case "relations", "relationTagCycleFailure", "relationUnknownTagFailure" -> - List.of( - new MaterialMetadataDeclaration( - "MetadataMaterial", - MaterialMetadata.builder().property(value, 3).build()), - new MaterialMetadataDeclaration( - "Iron", - MaterialMetadata.builder() - .tag(new DataKey(addonId(), "leaf")) - .build())); - default -> - List.of( - new MaterialMetadataDeclaration( - "MetadataMaterial", - MaterialMetadata.builder().property(value, 3).build()), - new MaterialMetadataDeclaration( - "Fe", - MaterialMetadata.builder() - .tag(new DataKey(addonId(), "descriptive")) - .build())); - }; - } - - public List materialTags() { - String scenario = System.getProperty("material.metadata.scenario"); - var leaf = new DataKey(addonId(), "leaf"); - var parent = new DataKey(addonId(), "parent"); - return switch (scenario) { - case "relations" -> - List.of( - new MaterialTagDeclaration(leaf, java.util.Set.of()), - new MaterialTagDeclaration(parent, java.util.Set.of(leaf))); - case "relationTagCycleFailure" -> - List.of( - new MaterialTagDeclaration(leaf, java.util.Set.of(parent)), - new MaterialTagDeclaration(parent, java.util.Set.of(leaf))); - case "relationUnknownTagFailure" -> - List.of(new MaterialTagDeclaration(parent, java.util.Set.of(new DataKey(addonId(), "missing")))); - case "relationNamespaceFailure" -> - List.of(new MaterialTagDeclaration(new DataKey("another_addon", "leaf"), java.util.Set.of())); - default -> List.of(); - }; - } - - public List materialGroups() { - String scenario = System.getProperty("material.metadata.scenario"); - var family = new MaterialGroupKey(new DataKey(addonId(), "family")); - var first = new MaterialGroupKey(new DataKey(addonId(), "first")); - var second = new MaterialGroupKey(new DataKey(addonId(), "second")); - return switch (scenario) { - case "relations" -> - List.of(new MaterialGroupDeclaration( - family, - "Family", - java.util.Set.of(new MaterialKey("Steel")), - java.util.Set.of(new MaterialGroupKey(new DataKey("gt6ce", "anyiron"))))); - case "relationUnknownGroupFailure" -> - List.of(new MaterialGroupDeclaration( - family, "Family", java.util.Set.of(new MaterialKey("MissingMaterial")), java.util.Set.of())); - case "relationGroupCycleFailure" -> - List.of( - new MaterialGroupDeclaration(first, "First", java.util.Set.of(), java.util.Set.of(second)), - new MaterialGroupDeclaration(second, "Second", java.util.Set.of(), java.util.Set.of(first))); - default -> List.of(); - }; - } - - public List> processes() { - String scenario = System.getProperty("material.metadata.scenario"); - var key = MaterialProcessKey.multiple(new DataKey(addonId(), "throw_into_water"), String.class); - return switch (scenario) { - case "processDecomposition", "infoDecompositionConflictFailure" -> - List.of(new MaterialProcessDeclaration<>( - "MetadataMaterial", - MaterialProcessKeys.DECOMPOSITION, - java.util.Set.of(new FormKey("dust")), - decomposition())); - case "processDecompositionOwnerFailure" -> - List.of(new MaterialProcessDeclaration<>( - "Iron", MaterialProcessKeys.DECOMPOSITION, java.util.Set.of(), decomposition())); - case "processes" -> - List.of(new MaterialProcessDeclaration<>("Iron", key, java.util.Set.of(new FormKey("dust")), "wet")); - case "processFormAlias" -> - List.of(new MaterialProcessDeclaration<>( - "Iron", key, java.util.Set.of(new FormKey("casingSmall")), "wet")); - case "processSingleConflictFailure" -> { - var single = MaterialProcessKey.single(new DataKey(addonId(), "listed_single"), String.class); - yield List.of( - new MaterialProcessDeclaration<>("Iron", single, java.util.Set.of(), "wet"), - new MaterialProcessDeclaration<>("Iron", single, java.util.Set.of(), "dry")); - } - case "processMultiple" -> { - var multiple = MaterialProcessKey.multiple(new DataKey(addonId(), "listed_multi"), String.class); - yield List.of( - new MaterialProcessDeclaration<>("Iron", multiple, java.util.Set.of(), "wet"), - new MaterialProcessDeclaration<>("Iron", multiple, java.util.Set.of(), "dry")); - } - case "processUnknownFormFailure" -> - List.of(new MaterialProcessDeclaration<>( - "Iron", key, java.util.Set.of(new FormKey("definitelyNotAPrefix")), "wet")); - case "processNamespaceFailure" -> - List.of(new MaterialProcessDeclaration<>( - "Iron", - MaterialProcessKey.multiple(new DataKey("another_addon", "throw_into_water"), String.class), - java.util.Set.of(), - "wet")); - case "processUnknownMaterialFailure" -> - List.of(new MaterialProcessDeclaration<>("MissingMaterial", key, java.util.Set.of(), "wet")); - case "processGroupMaterialFailure" -> - List.of(new MaterialProcessDeclaration<>("AnyIron", key, java.util.Set.of(), "wet")); - default -> List.of(); - }; - } - - @Override - public void materialInfo(MaterialInfoTool.Registrar registrar) { - String scenario = System.getProperty("material.metadata.scenario"); - var material = new MaterialKey("MetadataMaterial"); - switch (scenario) { - case "infoDecomposition", - "infoDecompositionBlock", - "infoDecompositionLiquid", - "infoDecompositionGas", - "infoDecompositionConflictFailure": - String form = scenario.equals("infoDecompositionBlock") - ? "blockDust" - : scenario.equals("infoDecompositionLiquid") - ? "liquid" - : scenario.equals("infoDecompositionGas") ? "gas" : "dust"; - registrar.registerProcess( - material, - MaterialProcessKeys.DECOMPOSITION, - new MaterialProcessRule<>(java.util.Set.of(new FormKey(form)), decomposition())); - return; - case "infoDecompositionOwnerFailure": - registrar.registerProcess( - new MaterialKey("Iron"), - MaterialProcessKeys.DECOMPOSITION, - MaterialProcessRule.anyForm(decomposition())); - return; - case "infoLegacyToolConflictFailure": - registrar.registerTool(material, new MaterialToolProfile(1, 3F, 64, 1)); - return; - case "infoOwnerFailure": - registrar.registerTool(new MaterialKey("Iron"), new MaterialToolProfile(1, 2F, 8, 1)); - return; - case "infoNamespaceFailure": - registrar.registerTag(new MaterialKey("Iron"), new DataKey("another_addon", "typed_tag")); - return; - case "infoProcessTypeFailure": - var key = new DataKey(addonId(), "typed_process"); - registrar.registerProcess( - material, MaterialProcessKey.multiple(key, Integer.class), MaterialProcessRule.anyForm(1)); - registrar.registerProcess( - new MaterialKey("MetadataSecond"), - MaterialProcessKey.multiple(key, String.class), - MaterialProcessRule.anyForm("typed")); - return; - case "infoProcessFormAlias": - registrar.registerProcess( - new MaterialKey("Iron"), - MaterialProcessKey.multiple(new DataKey(addonId(), "typed_process"), String.class), - new MaterialProcessRule<>(java.util.Set.of(new FormKey("casingSmall")), "typed")); - return; - case "infoProcessSingleConflictFailure": { - var single = MaterialProcessKey.single(new DataKey(addonId(), "typed_single"), String.class); - registrar.registerProcess(material, single, MaterialProcessRule.anyForm("wet")); - registrar.registerProcess(material, single, MaterialProcessRule.anyForm("dry")); - return; - } - case "infoProcessMultiple": { - var multiple = MaterialProcessKey.multiple(new DataKey(addonId(), "typed_multi"), String.class); - registrar.registerProcess(material, multiple, MaterialProcessRule.anyForm("wet")); - registrar.registerProcess(material, multiple, MaterialProcessRule.anyForm("dry")); - return; - } - case "infoProcessUnknownFormFailure": - registrar.registerProcess( - new MaterialKey("Iron"), - MaterialProcessKey.multiple(new DataKey(addonId(), "typed_process"), String.class), - new MaterialProcessRule<>(java.util.Set.of(new FormKey("definitelyNotAPrefix")), "typed")); - return; - case "infoProcessMissingFormFailure": - registrar.registerProcess( - new MaterialKey("Iron"), - MaterialProcessKey.multiple(new DataKey(addonId(), "typed_process"), String.class), - new MaterialProcessRule<>(java.util.Set.of(new FormKey("plateGem")), "typed")); - return; - case "info": - break; - default: - return; - } - registrar - .registerTool(material, new MaterialToolProfile(1, 3F, 64, 1)) - .registerComposition( - material, - new MaterialComposition( - material.name(), 1, List.of(new MaterialComposition.Part("Iron", GTValues.U)), false)) - .registerForm(material, new FormKey("dust")) - .registerTag(material, new DataKey(addonId(), "typed_tag")) - .registerProcess( - material, - MaterialProcessKey.multiple(new DataKey(addonId(), "typed_process"), String.class), - MaterialProcessRule.anyForm("typed")); - } - - private static MaterialDecompositionRule decomposition() { - return new MaterialDecompositionRule( - java.util.Set.of(MaterialDecompositionRule.Route.CENTRIFUGE), List.of(), false); - } -} diff --git a/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java b/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java index 25722e988..18cb3bc2e 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java @@ -7,13 +7,11 @@ import gregtech.content.material.MaterialDefinitions; import org.junit.jupiter.api.Test; -import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; import static org.junit.jupiter.api.Assertions.*; @@ -297,80 +295,4 @@ void everyRealCanonicalMaterialHasEnglishAndChineseTranslations() throws Excepti var almandine = MaterialDefinitions.info("Almandine"); assertTrue(almandine.relations().forms().contains("ORES")); } - - @Test - void isolatedLifecyclesCoverEarlyReadsFailuresAndSharedAddonDeclarations() throws Exception { - for (String scenario : List.of( - "early", - "facade", - "normal", - "aliasPublication", - "merge", - "conflict", - "definitionFailure", - "linkFailure", - "metadata", - "metadataUnknownFailure", - "metadataOwnerFailure", - "metadataNamespaceFailure", - "metadataTypeFailure", - "info", - "infoLegacy", - "infoLegacyToolConflictFailure", - "infoOwnerFailure", - "infoNamespaceFailure", - "infoProcessTypeFailure", - "infoProcessFormAlias", - "infoProcessSingleConflictFailure", - "infoProcessMultiple", - "infoProcessMissingFormFailure", - "infoProcessUnknownFormFailure", - "relations", - "relationTagCycleFailure", - "relationUnknownTagFailure", - "relationNamespaceFailure", - "relationUnknownGroupFailure", - "relationGroupCycleFailure", - "processDecomposition", - "infoDecomposition", - "infoDecompositionBlock", - "infoDecompositionLiquid", - "infoDecompositionGas", - "infoDecompositionConflictFailure", - "infoDecompositionOwnerFailure", - "processDecompositionOwnerFailure", - "processes", - "processFormAlias", - "processSingleConflictFailure", - "processMultiple", - "processUnknownFormFailure", - "processNamespaceFailure", - "processUnknownMaterialFailure", - "processGroupMaterialFailure")) { - var root = Path.of("").toAbsolutePath(); - if (!Files.isDirectory(root.resolve("core"))) root = root.getParent(); - var output = root.resolve("work/material-system-refactor/02/lifecycle-" + scenario + ".log"); - Files.createDirectories(output.getParent()); - var classpath = new java.util.ArrayList(); - for (Class type : List.of(MaterialLifecycleProbe.class, GTMaterialRegistry.class, GTMaterial.class)) - classpath.add(Path.of(type.getProtectionDomain() - .getCodeSource() - .getLocation() - .toURI()) - .toString()); - var process = new ProcessBuilder( - Path.of(System.getProperty("java.home"), "bin/java").toString(), - "-cp", - String.join(File.pathSeparator, classpath), - MaterialLifecycleProbe.class.getName(), - scenario) - .redirectErrorStream(true) - .redirectOutput(output.toFile()) - .start(); - boolean done = process.waitFor(45, TimeUnit.SECONDS); - if (!done) process.destroyForcibly(); - assertTrue(done, scenario + " timed out"); - assertEquals(0, process.exitValue(), () -> "Lifecycle failed: " + output); - } - } } diff --git a/core/src/test/resources/gregtech/material-import-references.tsv b/core/src/test/resources/gregtech/material-import-references.tsv deleted file mode 100644 index ea560715a..000000000 --- a/core/src/test/resources/gregtech/material-import-references.tsv +++ /dev/null @@ -1,4064 +0,0 @@ -# Historical import references before canonical migration; runtime does not parse this file. -composition Adamantine component[0] Ad 0 ALIAS -composition Adamantine component[1] O 0 ALIAS -composition Adamantine owner Adamantine 0 VALID -composition Air component[0] N 0 ALIAS -composition Air component[1] O 0 ALIAS -composition Air component[2] Ar 0 ALIAS -composition Air owner Air 0 VALID -composition Al2O3 component[0] Al 0 ALIAS -composition Al2O3 component[1] O 0 ALIAS -composition Al2O3 owner Al2O3 0 ALIAS -composition AlF3 component[0] Al 0 ALIAS -composition AlF3 component[1] F 0 ALIAS -composition AlF3 owner AlF3 0 ALIAS -composition AlO3H3 component[0] Al 0 ALIAS -composition AlO3H3 component[1] O 0 ALIAS -composition AlO3H3 component[2] H 0 ALIAS -composition AlO3H3 owner AlO3H3 0 ALIAS -composition Almandine component[0] Al2O3 0 ALIAS -composition Almandine component[1] Fe 0 ALIAS -composition Almandine component[2] SiO2 0 ALIAS -composition Almandine component[3] O 0 ALIAS -composition Almandine owner Almandine 0 VALID -composition AluminiumAlloy component[0] Al 0 ALIAS -composition AluminiumAlloy component[1] Si 0 ALIAS -composition AluminiumAlloy owner AluminiumAlloy 0 VALID -composition AluminiumBrass component[0] Al 0 ALIAS -composition AluminiumBrass component[1] Cu 0 ALIAS -composition AluminiumBrass owner AluminiumBrass 0 VALID -composition Alumite component[0] Al2O3 0 ALIAS -composition Alumite component[1] WroughtIron 0 VALID -composition Alumite component[2] Obsidian 0 VALID -composition Alumite owner Alumite 0 VALID -composition Alunite component[0] Al2O3 0 ALIAS -composition Alunite component[1] KOH 0 ALIAS -composition Alunite component[2] SO3 0 ALIAS -composition Alunite component[3] H2O 0 ALIAS -composition Alunite component[4] O 0 ALIAS -composition Alunite owner Alunite 0 VALID -composition Amazonite component[0] Al2O3 0 ALIAS -composition Amazonite component[1] SiO2 0 ALIAS -composition Amazonite component[2] K 0 ALIAS -composition Amazonite component[3] O 0 ALIAS -composition Amazonite owner Amazonite 0 VALID -composition Amethyst component[0] SiO2 0 ALIAS -composition Amethyst component[1] Fe 0 ALIAS -composition Amethyst owner Amethyst 0 VALID -composition Andradite component[0] Ca 0 ALIAS -composition Andradite component[1] Fe 0 ALIAS -composition Andradite component[2] SiO2 0 ALIAS -composition Andradite component[3] O 0 ALIAS -composition Andradite owner Andradite 0 VALID -composition AnnealedCopper component[0] Cu 0 ALIAS -composition AnnealedCopper owner AnnealedCopper 0 VALID -composition Apatite component[0] Ca 0 ALIAS -composition Apatite component[1] PO4 0 ALIAS -composition Apatite component[2] Cl 0 ALIAS -composition Apatite owner Apatite 0 VALID -composition AquaRegia component[0] HNO3 0 ALIAS -composition AquaRegia component[1] HCl 0 ALIAS -composition AquaRegia owner AquaRegia 0 VALID -composition Aquamarine component[0] Al2O3 0 ALIAS -composition Aquamarine component[1] Be 0 ALIAS -composition Aquamarine component[2] SiO2 0 ALIAS -composition Aquamarine component[3] O 0 ALIAS -composition Aquamarine owner Aquamarine 0 VALID -composition ArsenicBronze component[0] As 0 ALIAS -composition ArsenicBronze component[1] Bronze 0 VALID -composition ArsenicBronze owner ArsenicBronze 0 VALID -composition ArsenicCopper component[0] Cu 0 ALIAS -composition ArsenicCopper component[1] As 0 ALIAS -composition ArsenicCopper owner ArsenicCopper 0 VALID -composition Arsenopyrite component[0] Fe 0 ALIAS -composition Arsenopyrite component[1] As 0 ALIAS -composition Arsenopyrite component[2] S 0 ALIAS -composition Arsenopyrite owner Arsenopyrite 0 VALID -composition Asbestos component[0] Mg 0 ALIAS -composition Asbestos component[1] SiO2 0 ALIAS -composition Asbestos component[2] H2O 0 ALIAS -composition Asbestos component[3] O 0 ALIAS -composition Asbestos owner Asbestos 0 VALID -composition Azurite component[0] Cu 0 ALIAS -composition Azurite component[1] CO3 0 ALIAS -composition Azurite component[2] O 0 ALIAS -composition Azurite component[3] H2O 0 ALIAS -composition Azurite owner Azurite 0 VALID -composition BalasRuby component[0] Cr 0 ALIAS -composition BalasRuby component[1] Mg 0 ALIAS -composition BalasRuby component[2] O 0 ALIAS -composition BalasRuby owner BalasRuby 0 VALID -composition Bamboo component[0] C 0 ALIAS -composition Bamboo component[1] H2O 0 ALIAS -composition Bamboo owner Bamboo 0 VALID -composition Barite component[0] Ba 0 ALIAS -composition Barite component[1] S 0 ALIAS -composition Barite component[2] O 0 ALIAS -composition Barite owner Barite 0 VALID -composition Bark component[0] C 0 ALIAS -composition Bark component[1] H2O 0 ALIAS -composition Bark owner Bark 0 VALID -composition Basalt component[0] Peridot 0 VALID -composition Basalt component[1] CaCO3 0 ALIAS -composition Basalt component[2] Flint 0 VALID -composition Basalt component[3] DarkAsh 0 ALIAS -composition Basalt owner Basalt 0 VALID -composition BasalticMineralSand component[0] Fe 0 ALIAS -composition BasalticMineralSand component[1] O 0 ALIAS -composition BasalticMineralSand owner BasalticMineralSand 0 VALID -composition Bastnasite component[0] Ce 0 ALIAS -composition Bastnasite component[1] C 0 ALIAS -composition Bastnasite component[2] F 0 ALIAS -composition Bastnasite component[3] O 0 ALIAS -composition Bastnasite owner Bastnasite 0 VALID -composition BatteryAlloy component[0] Pb 0 ALIAS -composition BatteryAlloy component[1] Sb 0 ALIAS -composition BatteryAlloy owner BatteryAlloy 0 VALID -composition Bauxite component[0] TiO2 0 ALIAS -composition Bauxite component[1] Ilmenite 0 VALID -composition Bauxite component[2] Al2O3 0 ALIAS -composition Bauxite owner Bauxite 0 VALID -composition Biotite component[0] K 0 ALIAS -composition Biotite component[1] Mg 0 ALIAS -composition Biotite component[2] Al2O3 0 ALIAS -composition Biotite component[3] F 0 ALIAS -composition Biotite component[4] SiO2 0 ALIAS -composition Biotite owner Biotite 0 VALID -composition Bischofite component[0] MgCl2 0 ALIAS -composition Bischofite component[1] H2O 0 ALIAS -composition Bischofite owner Bischofite 0 VALID -composition BismuthBronze component[0] Bi 0 ALIAS -composition BismuthBronze component[1] Brass 0 VALID -composition BismuthBronze owner BismuthBronze 0 VALID -composition Bixbite component[0] Al2O3 0 ALIAS -composition Bixbite component[1] Be 0 ALIAS -composition Bixbite component[2] SiO2 0 ALIAS -composition Bixbite component[3] O 0 ALIAS -composition Bixbite owner Bixbite 0 VALID -composition BlackBronze component[0] Cu 0 ALIAS -composition BlackBronze component[1] Electrum 0 VALID -composition BlackBronze owner BlackBronze 0 VALID -composition BlackSteel component[0] Ni 0 ALIAS -composition BlackSteel component[1] BlackBronze 0 VALID -composition BlackSteel component[2] Steel 0 VALID -composition BlackSteel owner BlackSteel 0 VALID -composition BlackVitriol component[0] Fe 0 ALIAS -composition BlackVitriol component[1] S 0 ALIAS -composition BlackVitriol owner BlackVitriol 0 VALID -composition BlazeQuartz component[0] SiO2 0 ALIAS -composition BlazeQuartz owner BlazeQuartz 0 VALID -composition BlueAlloy component[0] Ag 0 ALIAS -composition BlueAlloy component[1] Nikolite 0 VALID -composition BlueAlloy owner BlueAlloy 0 VALID -composition BlueSapphire component[0] Al2O3 0 ALIAS -composition BlueSapphire component[1] Fe 0 ALIAS -composition BlueSapphire owner BlueSapphire 0 VALID -composition BlueSteel component[0] SterlingSilver 0 VALID -composition BlueSteel component[1] BismuthBronze 0 VALID -composition BlueSteel component[2] Steel 0 VALID -composition BlueSteel component[3] BlackSteel 0 VALID -composition BlueSteel owner BlueSteel 0 VALID -composition BlueTopaz component[0] Al2O3 0 ALIAS -composition BlueTopaz component[1] SiO2 0 ALIAS -composition BlueTopaz component[2] F 0 ALIAS -composition BlueTopaz component[3] H2O 0 ALIAS -composition BlueTopaz owner BlueTopaz 0 VALID -composition BlueVitriol component[0] Cu 0 ALIAS -composition BlueVitriol component[1] S 0 ALIAS -composition BlueVitriol component[2] O 0 ALIAS -composition BlueVitriol owner BlueVitriol 0 VALID -composition Bone component[0] Ca 0 ALIAS -composition Bone owner Bone 0 VALID -composition Borax component[0] Na 0 ALIAS -composition Borax component[1] B 0 ALIAS -composition Borax component[2] H2O 0 ALIAS -composition Borax component[3] O 0 ALIAS -composition Borax owner Borax 0 VALID -composition Brass component[0] Cu 0 ALIAS -composition Brass component[1] Zn 0 ALIAS -composition Brass owner Brass 0 VALID -composition Brick component[0] Ceramic 0 VALID -composition Brick owner Brick 0 ALIAS -composition Bromargyrite component[0] Ag 0 ALIAS -composition Bromargyrite component[1] Br 0 ALIAS -composition Bromargyrite owner Bromargyrite 0 VALID -composition Bronze component[0] Cu 0 ALIAS -composition Bronze component[1] Sn 0 ALIAS -composition Bronze owner Bronze 0 VALID -composition BrownLimonite component[0] Fe 0 ALIAS -composition BrownLimonite component[1] H 0 ALIAS -composition BrownLimonite component[2] O 0 ALIAS -composition BrownLimonite owner BrownLimonite 0 VALID -composition CH4 component[0] C 0 ALIAS -composition CH4 component[1] H 0 ALIAS -composition CH4 owner CH4 0 ALIAS -composition CO component[0] C 0 ALIAS -composition CO component[1] O 0 ALIAS -composition CO owner CO 0 ALIAS -composition CO2 component[0] C 0 ALIAS -composition CO2 component[1] O 0 ALIAS -composition CO2 owner CO2 0 ALIAS -composition CO3 component[0] C 0 ALIAS -composition CO3 component[1] O 0 ALIAS -composition CO3 owner CO3 0 ALIAS -composition CaCO3 component[0] Ca 0 ALIAS -composition CaCO3 component[1] CO3 0 ALIAS -composition CaCO3 owner CaCO3 0 ALIAS -composition CaCl2 component[0] Ca 0 ALIAS -composition CaCl2 component[1] Cl 0 ALIAS -composition CaCl2 owner CaCl2 0 ALIAS -composition CaSO4 component[0] Ca 0 ALIAS -composition CaSO4 component[1] S 0 ALIAS -composition CaSO4 component[2] O 0 ALIAS -composition CaSO4 owner CaSO4 0 ALIAS -composition Cassiterite component[0] Sn 0 ALIAS -composition Cassiterite component[1] O 0 ALIAS -composition Cassiterite owner Cassiterite 0 VALID -composition Cd_In_Ag_Alloy component[0] Cd 0 ALIAS -composition Cd_In_Ag_Alloy component[1] In 0 ALIAS -composition Cd_In_Ag_Alloy component[2] Ag 0 ALIAS -composition Cd_In_Ag_Alloy owner Cd_In_Ag_Alloy 0 ALIAS -composition Celestine component[0] Sr 0 ALIAS -composition Celestine component[1] S 0 ALIAS -composition Celestine component[2] O 0 ALIAS -composition Celestine owner Celestine 0 VALID -composition Ceramic component[0] Al2O3 0 ALIAS -composition Ceramic component[1] SiO2 0 ALIAS -composition Ceramic owner Ceramic 0 VALID -composition CertusQuartz component[0] SiO2 0 ALIAS -composition CertusQuartz owner CertusQuartz 0 VALID -composition Chalcopyrite component[0] Cu 0 ALIAS -composition Chalcopyrite component[1] Fe 0 ALIAS -composition Chalcopyrite component[2] S 0 ALIAS -composition Chalcopyrite owner Chalcopyrite 0 VALID -composition Charcoal component[0] C 0 ALIAS -composition Charcoal owner Charcoal 0 VALID -composition ChargedCertusQuartz component[0] SiO2 0 ALIAS -composition ChargedCertusQuartz owner ChargedCertusQuartz 0 VALID -composition ChloroauricAcid component[0] Au 0 ALIAS -composition ChloroauricAcid component[1] Cl 0 ALIAS -composition ChloroauricAcid component[2] H 0 ALIAS -composition ChloroauricAcid owner ChloroauricAcid 0 VALID -composition ChloroplatinicAcid component[0] Pt 0 ALIAS -composition ChloroplatinicAcid component[1] Cl 0 ALIAS -composition ChloroplatinicAcid component[2] H 0 ALIAS -composition ChloroplatinicAcid owner ChloroplatinicAcid 0 VALID -composition Chocolate component[0] Cocoa 0 VALID -composition Chocolate component[1] Sugar 0 VALID -composition Chocolate owner Chocolate 0 VALID -composition Chromite component[0] Fe 0 ALIAS -composition Chromite component[1] Cr 0 ALIAS -composition Chromite component[2] O 0 ALIAS -composition Chromite owner Chromite 0 VALID -composition ChromiumDioxide component[0] Cr 0 ALIAS -composition ChromiumDioxide component[1] O 0 ALIAS -composition ChromiumDioxide owner ChromiumDioxide 0 VALID -composition Cinnabar component[0] Hg 0 ALIAS -composition Cinnabar component[1] S 0 ALIAS -composition Cinnabar owner Cinnabar 0 VALID -composition Clay component[0] Ceramic 0 VALID -composition Clay component[1] H2O 0 ALIAS -composition Clay owner Clay 0 VALID -composition Coal component[0] C 0 ALIAS -composition Coal owner Coal 0 VALID -composition CoalCoke component[0] C 0 ALIAS -composition CoalCoke owner CoalCoke 0 VALID -composition CobaltBrass component[0] Brass 0 VALID -composition CobaltBrass component[1] Al 0 ALIAS -composition CobaltBrass component[2] Co 0 ALIAS -composition CobaltBrass owner CobaltBrass 0 VALID -composition CobaltHexahydrate component[0] Co 0 ALIAS -composition CobaltHexahydrate component[1] H2O 0 ALIAS -composition CobaltHexahydrate owner CobaltHexahydrate 0 VALID -composition Cobaltite component[0] Co 0 ALIAS -composition Cobaltite component[1] As 0 ALIAS -composition Cobaltite component[2] S 0 ALIAS -composition Cobaltite owner Cobaltite 0 VALID -composition Coltan component[0] Tantalite 0 VALID -composition Coltan component[1] Columbite 0 VALID -composition Coltan owner Coltan 0 VALID -composition Columbite component[0] Nb2O5 0 ALIAS -composition Columbite component[1] MnO2 0 ALIAS -composition Columbite owner Columbite 0 VALID -composition Concrete component[0] Stone 0 VALID -composition Concrete owner Concrete 0 VALID -composition ConductiveIron component[0] WroughtIron 0 VALID -composition ConductiveIron component[1] Redstone 0 VALID -composition ConductiveIron owner ConductiveIron 0 VALID -composition Constantan component[0] Cu 0 ALIAS -composition Constantan component[1] Ni 0 ALIAS -composition Constantan owner Constantan 0 VALID -composition Cooperite component[0] Pt 0 ALIAS -composition Cooperite component[1] Ni 0 ALIAS -composition Cooperite component[2] Pd 0 ALIAS -composition Cooperite component[3] S 0 ALIAS -composition Cooperite owner Cooperite 0 VALID -composition CrystalMatrix component[0] Diamond 0 VALID -composition CrystalMatrix component[1] NetherStar 0 VALID -composition CrystalMatrix owner CrystalMatrix 0 VALID -composition CyanVitriol component[0] Ni 0 ALIAS -composition CyanVitriol component[1] S 0 ALIAS -composition CyanVitriol component[2] O 0 ALIAS -composition CyanVitriol owner CyanVitriol 0 VALID -composition D2O component[0] D 0 ALIAS -composition D2O component[1] O 0 ALIAS -composition D2O owner D2O 0 ALIAS -composition DamascusSteel component[0] Steel 0 VALID -composition DamascusSteel component[1] V 0 ALIAS -composition DamascusSteel component[2] W 0 ALIAS -composition DamascusSteel owner DamascusSteel 0 VALID -composition Datolite component[0] H 0 ALIAS -composition Datolite component[1] Ca 0 ALIAS -composition Datolite component[2] B 0 ALIAS -composition Datolite component[3] Si 0 ALIAS -composition Datolite component[4] O 0 ALIAS -composition Datolite owner Datolite 0 VALID -composition Diamond component[0] C 0 ALIAS -composition Diamond owner Diamond 0 VALID -composition DiamondBlue component[0] C 0 ALIAS -composition DiamondBlue owner DiamondBlue 0 ALIAS -composition DiamondGreen component[0] C 0 ALIAS -composition DiamondGreen owner DiamondGreen 0 ALIAS -composition DiamondIndustrial component[0] C 0 ALIAS -composition DiamondIndustrial owner DiamondIndustrial 0 VALID -composition DiamondPink component[0] C 0 ALIAS -composition DiamondPink owner DiamondPink 0 ALIAS -composition DiamondRed component[0] C 0 ALIAS -composition DiamondRed owner DiamondRed 0 ALIAS -composition DiamondYellow component[0] C 0 ALIAS -composition DiamondYellow owner DiamondYellow 0 ALIAS -composition Diatomite component[0] Flint 0 VALID -composition Diatomite component[1] Fe2O3 0 ALIAS -composition Diatomite component[2] Sapphire 0 VALID -composition Diatomite owner Diatomite 0 VALID -composition DiduraniumTrioxide component[0] Dn 0 ALIAS -composition DiduraniumTrioxide component[1] O 0 ALIAS -composition DiduraniumTrioxide owner DiduraniumTrioxide 0 VALID -composition Dioptase component[0] SiO2 0 ALIAS -composition Dioptase component[1] Cu 0 ALIAS -composition Dioptase component[2] O 0 ALIAS -composition Dioptase component[3] H2O 0 ALIAS -composition Dioptase owner Dioptase 0 VALID -composition DistWater component[0] H 0 ALIAS -composition DistWater component[1] O 0 ALIAS -composition DistWater owner DistWater 0 ALIAS -composition Dreamwood component[0] C 0 ALIAS -composition Dreamwood component[1] H2O 0 ALIAS -composition Dreamwood owner Dreamwood 0 VALID -composition Duralumin component[0] Al 0 ALIAS -composition Duralumin component[1] Cu 0 ALIAS -composition Duralumin owner Duralumin 0 VALID -composition DuraniumAlloy component[0] Dn 0 ALIAS -composition DuraniumAlloy component[1] Mg 0 ALIAS -composition DuraniumAlloy owner DuraniumAlloy 0 ALIAS -composition DuraniumHexaastatide component[0] Dn 0 ALIAS -composition DuraniumHexaastatide component[1] At 0 ALIAS -composition DuraniumHexaastatide owner DuraniumHexaastatide 0 VALID -composition DuraniumHexabromide component[0] Dn 0 ALIAS -composition DuraniumHexabromide component[1] Br 0 ALIAS -composition DuraniumHexabromide owner DuraniumHexabromide 0 VALID -composition DuraniumHexachloride component[0] Dn 0 ALIAS -composition DuraniumHexachloride component[1] Cl 0 ALIAS -composition DuraniumHexachloride owner DuraniumHexachloride 0 VALID -composition DuraniumHexafluoride component[0] Dn 0 ALIAS -composition DuraniumHexafluoride component[1] F 0 ALIAS -composition DuraniumHexafluoride owner DuraniumHexafluoride 0 VALID -composition DuraniumHexaiodide component[0] Dn 0 ALIAS -composition DuraniumHexaiodide component[1] I 0 ALIAS -composition DuraniumHexaiodide owner DuraniumHexaiodide 0 VALID -composition Dynamite component[0] Glyceryl 0 VALID -composition Dynamite component[1] Wood 0 VALID -composition Dynamite owner Dynamite 0 VALID -composition ElectricalSteel component[0] Steel 0 VALID -composition ElectricalSteel component[1] Si 0 ALIAS -composition ElectricalSteel owner ElectricalSteel 0 VALID -composition ElectrotineAlloy component[0] WroughtIron 0 VALID -composition ElectrotineAlloy component[1] Nikolite 0 VALID -composition ElectrotineAlloy owner ElectrotineAlloy 0 VALID -composition Electrum component[0] Ag 0 ALIAS -composition Electrum component[1] Au 0 ALIAS -composition Electrum owner Electrum 0 VALID -composition ElvenQuartz component[0] SiO2 0 ALIAS -composition ElvenQuartz owner ElvenQuartz 0 VALID -composition Emerald component[0] Al2O3 0 ALIAS -composition Emerald component[1] Be 0 ALIAS -composition Emerald component[2] SiO2 0 ALIAS -composition Emerald component[3] O 0 ALIAS -composition Emerald owner Emerald 0 VALID -composition EnderEye component[0] EnderPearl 0 VALID -composition EnderEye component[1] Blaze 0 VALID -composition EnderEye owner EnderEye 0 VALID -composition EnderPearl component[0] Be 0 ALIAS -composition EnderPearl component[1] K 0 ALIAS -composition EnderPearl component[2] N 0 ALIAS -composition EnderPearl component[3] Ma 0 ALIAS -composition EnderPearl owner EnderPearl 0 VALID -composition Enderium component[0] EnderiumBase 0 VALID -composition Enderium component[1] EnderPearl 0 VALID -composition Enderium owner Enderium 0 VALID -composition EnderiumBase component[0] Sn 0 ALIAS -composition EnderiumBase component[1] Ag 0 ALIAS -composition EnderiumBase component[2] Pt 0 ALIAS -composition EnderiumBase owner EnderiumBase 0 VALID -composition EnergiumCyan component[0] Sapphire 0 VALID -composition EnergiumCyan component[1] Nikolite 0 VALID -composition EnergiumCyan owner EnergiumCyan 0 VALID -composition EnergiumRed component[0] Sapphire 0 VALID -composition EnergiumRed component[1] Redstone 0 VALID -composition EnergiumRed owner EnergiumRed 0 VALID -composition Eudialyte component[0] Zircon 0 VALID -composition Eudialyte component[1] MnO2 0 ALIAS -composition Eudialyte component[2] Na 0 ALIAS -composition Eudialyte component[3] Ca 0 ALIAS -composition Eudialyte component[4] Cl 0 ALIAS -composition Eudialyte component[5] SiO2 0 ALIAS -composition Eudialyte component[6] O 0 ALIAS -composition Eudialyte owner Eudialyte 0 VALID -composition Fe2O3 component[0] Fe 0 ALIAS -composition Fe2O3 component[1] O 0 ALIAS -composition Fe2O3 owner Fe2O3 0 ALIAS -composition FeCl2 component[0] Fe 0 ALIAS -composition FeCl2 component[1] Cl 0 ALIAS -composition FeCl2 owner FeCl2 0 ALIAS -composition FeCl3 component[0] Fe 0 ALIAS -composition FeCl3 component[1] Cl 0 ALIAS -composition FeCl3 owner FeCl3 0 ALIAS -composition FeO3H3 component[0] Fe 0 ALIAS -composition FeO3H3 component[1] O 0 ALIAS -composition FeO3H3 component[2] H 0 ALIAS -composition FeO3H3 owner FeO3H3 0 ALIAS -composition Ferberite component[0] Fe 0 ALIAS -composition Ferberite component[1] WO3 0 ALIAS -composition Ferberite component[2] O 0 ALIAS -composition Ferberite owner Ferberite 0 VALID -composition Ferrovanadium component[0] Magnetite 0 VALID -composition Ferrovanadium component[1] V2O5 0 ALIAS -composition Ferrovanadium owner Ferrovanadium 0 ALIAS -composition FierySteel component[0] Steel 0 VALID -composition FierySteel component[1] Ma 0 ALIAS -composition FierySteel owner FierySteel 0 VALID -composition Fireleaf component[0] Steel 0 VALID -composition Fireleaf component[1] Ma 0 ALIAS -composition Fireleaf owner Fireleaf 0 VALID -composition FlamascusSteel component[0] DamascusSteel 0 VALID -composition FlamascusSteel component[1] Ma 0 ALIAS -composition FlamascusSteel owner FlamascusSteel 0 VALID -composition Flint component[0] SiO2 0 ALIAS -composition Flint owner Flint 0 VALID -composition Fluix component[0] SiO2 0 ALIAS -composition Fluix component[1] Redstone 0 VALID -composition Fluix owner Fluix 0 VALID -composition FreshWater component[0] H 0 ALIAS -composition FreshWater component[1] O 0 ALIAS -composition FreshWater owner FreshWater 0 VALID -composition Galena component[0] Pb 0 ALIAS -composition Galena component[1] Ag 0 ALIAS -composition Galena component[2] S 0 ALIAS -composition Galena owner Galena 0 VALID -composition GarnetSand component[0] Almandine 0 VALID -composition GarnetSand component[1] Andradite 0 VALID -composition GarnetSand component[2] Grossular 0 VALID -composition GarnetSand component[3] Pyrope 0 VALID -composition GarnetSand component[4] Spessartine 0 VALID -composition GarnetSand component[5] Uvarovite 0 VALID -composition GarnetSand owner GarnetSand 0 VALID -composition Garnierite component[0] Ni 0 ALIAS -composition Garnierite component[1] O 0 ALIAS -composition Garnierite owner Garnierite 0 VALID -composition Glass component[0] SiO2 0 ALIAS -composition Glass owner Glass 0 VALID -composition Glauconite component[0] Al2O3 0 ALIAS -composition Glauconite component[1] K 0 ALIAS -composition Glauconite component[2] Mg 0 ALIAS -composition Glauconite component[3] H2O 0 ALIAS -composition Glauconite component[4] O 0 ALIAS -composition Glauconite owner Glauconite 0 VALID -composition Glowstone component[0] Phosphorite 0 VALID -composition Glowstone component[1] Au 0 ALIAS -composition Glowstone component[2] SiO2 0 ALIAS -composition Glowstone component[3] He 0 ALIAS -composition Glowstone owner Glowstone 0 VALID -composition Glycerol component[0] C 0 ALIAS -composition Glycerol component[1] H 0 ALIAS -composition Glycerol component[2] O 0 ALIAS -composition Glycerol owner Glycerol 0 VALID -composition Glyceryl component[0] C 0 ALIAS -composition Glyceryl component[1] H 0 ALIAS -composition Glyceryl component[2] N 0 ALIAS -composition Glyceryl component[3] O 0 ALIAS -composition Glyceryl owner Glyceryl 0 VALID -composition Goshenite component[0] Al2O3 0 ALIAS -composition Goshenite component[1] Be 0 ALIAS -composition Goshenite component[2] SiO2 0 ALIAS -composition Goshenite component[3] O 0 ALIAS -composition Goshenite owner Goshenite 0 VALID -composition Granite component[0] Biotite 0 VALID -composition Granite component[1] PotassiumFeldspar 0 VALID -composition Granite component[2] Flint 0 VALID -composition Granite owner Granite 0 VALID -composition GraniteBlack component[0] Biotite 0 VALID -composition GraniteBlack component[1] PotassiumFeldspar 0 VALID -composition GraniteBlack component[2] Flint 0 VALID -composition GraniteBlack owner GraniteBlack 0 VALID -composition GraniteRed component[0] Biotite 0 VALID -composition GraniteRed component[1] PotassiumFeldspar 0 VALID -composition GraniteRed component[2] Flint 0 VALID -composition GraniteRed owner GraniteRed 0 VALID -composition GraniticMineralSand component[0] Fe 0 ALIAS -composition GraniticMineralSand component[1] O 0 ALIAS -composition GraniticMineralSand owner GraniticMineralSand 0 VALID -composition Graphene component[0] C 0 ALIAS -composition Graphene owner Graphene 0 VALID -composition Graphite component[0] C 0 ALIAS -composition Graphite owner Graphite 0 VALID -composition GrayVitriol component[0] Mn 0 ALIAS -composition GrayVitriol component[1] S 0 ALIAS -composition GrayVitriol component[2] O 0 ALIAS -composition GrayVitriol owner GrayVitriol 0 VALID -composition Greatwood component[0] C 0 ALIAS -composition Greatwood component[1] H2O 0 ALIAS -composition Greatwood owner Greatwood 0 VALID -composition GreenSapphire component[0] Al2O3 0 ALIAS -composition GreenSapphire component[1] Mg 0 ALIAS -composition GreenSapphire owner GreenSapphire 0 VALID -composition GreenVitriol component[0] Fe 0 ALIAS -composition GreenVitriol component[1] S 0 ALIAS -composition GreenVitriol component[2] O 0 ALIAS -composition GreenVitriol owner GreenVitriol 0 VALID -composition Grossular component[0] Al2O3 0 ALIAS -composition Grossular component[1] Ca 0 ALIAS -composition Grossular component[2] SiO2 0 ALIAS -composition Grossular component[3] O 0 ALIAS -composition Grossular owner Grossular 0 VALID -composition Gunpowder component[0] C 0 ALIAS -composition Gunpowder component[1] S 0 ALIAS -composition Gunpowder component[2] NaNO3 0 ALIAS -composition Gunpowder owner Gunpowder 0 VALID -composition Gypsum component[0] CaSO4 0 ALIAS -composition Gypsum component[1] H2O 0 ALIAS -composition Gypsum owner Gypsum 0 VALID -composition H2O component[0] H 0 ALIAS -composition H2O component[1] O 0 ALIAS -composition H2O owner H2O 0 ALIAS -composition H2O2 component[0] H 0 ALIAS -composition H2O2 component[1] O 0 ALIAS -composition H2O2 owner H2O2 0 ALIAS -composition H2S component[0] H 0 ALIAS -composition H2S component[1] S 0 ALIAS -composition H2S owner H2S 0 ALIAS -composition H2S2O7 component[0] H 0 ALIAS -composition H2S2O7 component[1] S 0 ALIAS -composition H2S2O7 component[2] O 0 ALIAS -composition H2S2O7 owner H2S2O7 0 ALIAS -composition H2SO4 component[0] H 0 ALIAS -composition H2SO4 component[1] S 0 ALIAS -composition H2SO4 component[2] O 0 ALIAS -composition H2SO4 owner H2SO4 0 ALIAS -composition H2SiF6 component[0] H 0 ALIAS -composition H2SiF6 component[1] Si 0 ALIAS -composition H2SiF6 component[2] F 0 ALIAS -composition H2SiF6 owner H2SiF6 0 ALIAS -composition H2WO4 component[0] H 0 ALIAS -composition H2WO4 component[1] W 0 ALIAS -composition H2WO4 component[2] O 0 ALIAS -composition H2WO4 owner H2WO4 0 ALIAS -composition H3BO3 component[0] H 0 ALIAS -composition H3BO3 component[1] B 0 ALIAS -composition H3BO3 component[2] O 0 ALIAS -composition H3BO3 owner H3BO3 0 ALIAS -composition HCl component[0] H 0 ALIAS -composition HCl component[1] Cl 0 ALIAS -composition HCl owner HCl 0 ALIAS -composition HDO component[0] H 0 ALIAS -composition HDO component[1] D 0 ALIAS -composition HDO component[2] O 0 ALIAS -composition HDO owner HDO 0 ALIAS -composition HF component[0] H 0 ALIAS -composition HF component[1] F 0 ALIAS -composition HF owner HF 0 ALIAS -composition HNO3 component[0] H 0 ALIAS -composition HNO3 component[1] N 0 ALIAS -composition HNO3 component[2] O 0 ALIAS -composition HNO3 owner HNO3 0 ALIAS -composition HSSE component[0] HSSG 0 VALID -composition HSSE component[1] Co 0 ALIAS -composition HSSE component[2] Mn 0 ALIAS -composition HSSE component[3] Si 0 ALIAS -composition HSSE owner HSSE 0 VALID -composition HSSG component[0] TungstenSteel 0 ALIAS -composition HSSG component[1] Cr 0 ALIAS -composition HSSG component[2] Mo 0 ALIAS -composition HSSG component[3] V 0 ALIAS -composition HSSG owner HSSG 0 VALID -composition HSSS component[0] HSSG 0 VALID -composition HSSS component[1] Osmiridium 0 VALID -composition HSSS component[2] Ir 0 ALIAS -composition HSSS owner HSSS 0 VALID -composition HeNe component[0] He 0 ALIAS -composition HeNe component[1] Ne 0 ALIAS -composition HeNe owner HeNe 0 ALIAS -composition Heliodor component[0] Al2O3 0 ALIAS -composition Heliodor component[1] Be 0 ALIAS -composition Heliodor component[2] SiO2 0 ALIAS -composition Heliodor component[3] O 0 ALIAS -composition Heliodor owner Heliodor 0 VALID -composition HolyWater component[0] H 0 ALIAS -composition HolyWater component[1] O 0 ALIAS -composition HolyWater owner HolyWater 0 VALID -composition Huebnerite component[0] Mn 0 ALIAS -composition Huebnerite component[1] WO3 0 ALIAS -composition Huebnerite component[2] O 0 ALIAS -composition Huebnerite owner Huebnerite 0 VALID -composition HydratedCoal component[0] Coal 0 VALID -composition HydratedCoal component[1] H2O 0 ALIAS -composition HydratedCoal owner HydratedCoal 0 VALID -composition Ice component[0] H 0 ALIAS -composition Ice component[1] O 0 ALIAS -composition Ice owner Ice 0 VALID -composition Ilmenite component[0] Fe 0 ALIAS -composition Ilmenite component[1] Ti 0 ALIAS -composition Ilmenite component[2] O 0 ALIAS -composition Ilmenite owner Ilmenite 0 VALID -composition Invar component[0] WroughtIron 0 VALID -composition Invar component[1] Ni 0 ALIAS -composition Invar owner Invar 0 VALID -composition Iridiron component[0] Ir 0 ALIAS -composition Iridiron component[1] Fe 0 ALIAS -composition Iridiron owner Iridiron 0 RETIRED -composition IridironReinforced component[0] Ir 0 ALIAS -composition IridironReinforced component[1] Fe 0 ALIAS -composition IridironReinforced owner IridironReinforced 0 RETIRED -composition Iritanium component[0] Ir 0 ALIAS -composition Iritanium component[1] Ti 0 ALIAS -composition Iritanium owner Iritanium 0 ALIAS -composition IronCast component[0] Fe 0 ALIAS -composition IronCast owner IronCast 0 ALIAS -composition IronMagnetic component[0] Fe 0 ALIAS -composition IronMagnetic owner IronMagnetic 0 VALID -composition K2CO3 component[0] K 0 ALIAS -composition K2CO3 component[1] CO3 0 ALIAS -composition K2CO3 owner K2CO3 0 ALIAS -composition K2S component[0] K 0 ALIAS -composition K2S component[1] S 0 ALIAS -composition K2S owner K2S 0 ALIAS -composition K2S2O7 component[0] K 0 ALIAS -composition K2S2O7 component[1] S 0 ALIAS -composition K2S2O7 component[2] O 0 ALIAS -composition K2S2O7 owner K2S2O7 0 ALIAS -composition K2SO3 component[0] K 0 ALIAS -composition K2SO3 component[1] S 0 ALIAS -composition K2SO3 component[2] O 0 ALIAS -composition K2SO3 owner K2SO3 0 ALIAS -composition K2SO4 component[0] K 0 ALIAS -composition K2SO4 component[1] S 0 ALIAS -composition K2SO4 component[2] O 0 ALIAS -composition K2SO4 owner K2SO4 0 ALIAS -composition K2TaF7 component[0] K 0 ALIAS -composition K2TaF7 component[1] Ta 0 ALIAS -composition K2TaF7 component[2] F 0 ALIAS -composition K2TaF7 owner K2TaF7 0 ALIAS -composition KAlO2 component[0] K 0 ALIAS -composition KAlO2 component[1] Al 0 ALIAS -composition KAlO2 component[2] O 0 ALIAS -composition KAlO2 owner KAlO2 0 ALIAS -composition KCl component[0] K 0 ALIAS -composition KCl component[1] Cl 0 ALIAS -composition KCl owner KCl 0 ALIAS -composition KF component[0] K 0 ALIAS -composition KF component[1] F 0 ALIAS -composition KF owner KF 0 ALIAS -composition KHSO4 component[0] K 0 ALIAS -composition KHSO4 component[1] H 0 ALIAS -composition KHSO4 component[2] S 0 ALIAS -composition KHSO4 component[3] O 0 ALIAS -composition KHSO4 owner KHSO4 0 ALIAS -composition KIO3 component[0] K 0 ALIAS -composition KIO3 component[1] I 0 ALIAS -composition KIO3 component[2] O 0 ALIAS -composition KIO3 owner KIO3 0 ALIAS -composition KNO3 component[0] K 0 ALIAS -composition KNO3 component[1] N 0 ALIAS -composition KNO3 component[2] O 0 ALIAS -composition KNO3 owner KNO3 0 ALIAS -composition KOH component[0] K 0 ALIAS -composition KOH component[1] O 0 ALIAS -composition KOH component[2] H 0 ALIAS -composition KOH owner KOH 0 ALIAS -composition KSO4 component[0] K 0 ALIAS -composition KSO4 component[1] S 0 ALIAS -composition KSO4 component[2] O 0 ALIAS -composition KSO4 owner KSO4 0 ALIAS -composition Kanthal component[0] WroughtIron 0 VALID -composition Kanthal component[1] Al 0 ALIAS -composition Kanthal component[2] Cr 0 ALIAS -composition Kanthal owner Kanthal 0 VALID -composition Kesterite component[0] Cu 0 ALIAS -composition Kesterite component[1] Zn 0 ALIAS -composition Kesterite component[2] Sn 0 ALIAS -composition Kesterite component[3] S 0 ALIAS -composition Kesterite owner Kesterite 0 VALID -composition Knightmetal component[0] Steel 0 VALID -composition Knightmetal component[1] Ma 0 ALIAS -composition Knightmetal owner Knightmetal 0 VALID -composition Komatiite component[0] Peridot 0 VALID -composition Komatiite component[1] MgCO3 0 ALIAS -composition Komatiite component[2] Flint 0 VALID -composition Komatiite component[3] DarkAsh 0 ALIAS -composition Komatiite owner Komatiite 0 VALID -composition Kyanite component[0] Al2O3 0 ALIAS -composition Kyanite component[1] SiO2 0 ALIAS -composition Kyanite owner Kyanite 0 VALID -composition Lapis component[0] Lazurite 0 VALID -composition Lapis component[1] Sodalite 0 VALID -composition Lapis component[2] Pyrite 0 VALID -composition Lapis component[3] CaCO3 0 ALIAS -composition Lapis owner Lapis 0 VALID -composition Lazurite component[0] Al2O3 0 ALIAS -composition Lazurite component[1] SiO2 0 ALIAS -composition Lazurite component[2] Ca 0 ALIAS -composition Lazurite component[3] Na 0 ALIAS -composition Lazurite owner Lazurite 0 VALID -composition Lepidolite component[0] Al2O3 0 ALIAS -composition Lepidolite component[1] K 0 ALIAS -composition Lepidolite component[2] Li 0 ALIAS -composition Lepidolite component[3] F 0 ALIAS -composition Lepidolite component[4] O 0 ALIAS -composition Lepidolite owner Lepidolite 0 VALID -composition LiCl component[0] Li 0 ALIAS -composition LiCl component[1] Cl 0 ALIAS -composition LiCl owner LiCl 0 ALIAS -composition LiClO3 component[0] Li 0 ALIAS -composition LiClO3 component[1] Cl 0 ALIAS -composition LiClO3 component[2] O 0 ALIAS -composition LiClO3 owner LiClO3 0 ALIAS -composition LiClO4 component[0] Li 0 ALIAS -composition LiClO4 component[1] Cl 0 ALIAS -composition LiClO4 component[2] O 0 ALIAS -composition LiClO4 owner LiClO4 0 ALIAS -composition LiOH component[0] Li 0 ALIAS -composition LiOH component[1] O 0 ALIAS -composition LiOH component[2] H 0 ALIAS -composition LiOH owner LiOH 0 ALIAS -composition Lignite component[0] C 0 ALIAS -composition Lignite component[1] H2O 0 ALIAS -composition Lignite component[2] DarkAsh 0 ALIAS -composition Lignite owner Lignite 0 VALID -composition LigniteCoke component[0] C 0 ALIAS -composition LigniteCoke component[1] DarkAsh 0 ALIAS -composition LigniteCoke owner LigniteCoke 0 VALID -composition Limestone component[0] CaCO3 0 ALIAS -composition Limestone owner Limestone 0 VALID -composition LiveRoot component[0] Wood 0 VALID -composition LiveRoot component[1] Ma 0 ALIAS -composition LiveRoot owner LiveRoot 0 VALID -composition Livingwood component[0] C 0 ALIAS -composition Livingwood component[1] H2O 0 ALIAS -composition Livingwood owner Livingwood 0 VALID -composition Lumium component[0] Sn 0 ALIAS -composition Lumium component[1] Ag 0 ALIAS -composition Lumium component[2] Glowstone 0 VALID -composition Lumium owner Lumium 0 VALID -composition Magnalium component[0] Mg 0 ALIAS -composition Magnalium component[1] Al 0 ALIAS -composition Magnalium owner Magnalium 0 VALID -composition Magnetite component[0] Fe 0 ALIAS -composition Magnetite component[1] O 0 ALIAS -composition Magnetite owner Magnetite 0 VALID -composition Malachite component[0] Cu 0 ALIAS -composition Malachite component[1] CO3 0 ALIAS -composition Malachite component[2] H 0 ALIAS -composition Malachite component[3] O 0 ALIAS -composition Malachite owner Malachite 0 VALID -composition ManaDiamond component[0] C 0 ALIAS -composition ManaDiamond component[1] Ma 0 ALIAS -composition ManaDiamond owner ManaDiamond 0 VALID -composition Manasteel component[0] Fe 0 ALIAS -composition Manasteel component[1] Ma 0 ALIAS -composition Manasteel owner Manasteel 0 VALID -composition Marble component[0] Mg 0 ALIAS -composition Marble component[1] CaCO3 0 ALIAS -composition Marble owner Marble 0 VALID -composition Maxixe component[0] Al2O3 0 ALIAS -composition Maxixe component[1] Be 0 ALIAS -composition Maxixe component[2] SiO2 0 ALIAS -composition Maxixe component[3] O 0 ALIAS -composition Maxixe owner Maxixe 0 VALID -composition MethaneIce component[0] CH4 0 ALIAS -composition MethaneIce component[1] Ice 0 VALID -composition MethaneIce owner MethaneIce 0 VALID -composition MgCO3 component[0] Mg 0 ALIAS -composition MgCO3 component[1] CO3 0 ALIAS -composition MgCO3 owner MgCO3 0 ALIAS -composition MgCl2 component[0] Mg 0 ALIAS -composition MgCl2 component[1] Cl 0 ALIAS -composition MgCl2 owner MgCl2 0 ALIAS -composition Mica component[0] Al2O3 0 ALIAS -composition Mica component[1] K 0 ALIAS -composition Mica component[2] SiO2 0 ALIAS -composition Mica component[3] F 0 ALIAS -composition Mica owner Mica 0 VALID -composition MilkyQuartz component[0] SiO2 0 ALIAS -composition MilkyQuartz owner MilkyQuartz 0 VALID -composition Mirabilite component[0] Na2SO4 0 ALIAS -composition Mirabilite component[1] H2O 0 ALIAS -composition Mirabilite owner Mirabilite 0 VALID -composition MnCl2 component[0] Mn 0 ALIAS -composition MnCl2 component[1] Cl 0 ALIAS -composition MnCl2 owner MnCl2 0 ALIAS -composition MnO2 component[0] Mn 0 ALIAS -composition MnO2 component[1] O 0 ALIAS -composition MnO2 owner MnO2 0 ALIAS -composition Molybdenite component[0] Mo 0 ALIAS -composition Molybdenite component[1] S 0 ALIAS -composition Molybdenite owner Molybdenite 0 VALID -composition Monazite component[0] RareEarth 0 VALID -composition Monazite component[1] PO4 0 ALIAS -composition Monazite owner Monazite 0 VALID -composition Morganite component[0] Al2O3 0 ALIAS -composition Morganite component[1] Be 0 ALIAS -composition Morganite component[2] SiO2 0 ALIAS -composition Morganite component[3] O 0 ALIAS -composition Morganite owner Morganite 0 VALID -composition NH3 component[0] N 0 ALIAS -composition NH3 component[1] H 0 ALIAS -composition NH3 owner NH3 0 ALIAS -composition NO component[0] N 0 ALIAS -composition NO component[1] O 0 ALIAS -composition NO owner NO 0 ALIAS -composition NO2 component[0] N 0 ALIAS -composition NO2 component[1] O 0 ALIAS -composition NO2 owner NO2 0 ALIAS -composition Na2CO3 component[0] Na 0 ALIAS -composition Na2CO3 component[1] CO3 0 ALIAS -composition Na2CO3 owner Na2CO3 0 ALIAS -composition Na2S component[0] Na 0 ALIAS -composition Na2S component[1] S 0 ALIAS -composition Na2S owner Na2S 0 ALIAS -composition Na2S2O7 component[0] Na 0 ALIAS -composition Na2S2O7 component[1] S 0 ALIAS -composition Na2S2O7 component[2] O 0 ALIAS -composition Na2S2O7 owner Na2S2O7 0 ALIAS -composition Na2SO3 component[0] Na 0 ALIAS -composition Na2SO3 component[1] S 0 ALIAS -composition Na2SO3 component[2] O 0 ALIAS -composition Na2SO3 owner Na2SO3 0 ALIAS -composition Na2SO4 component[0] Na 0 ALIAS -composition Na2SO4 component[1] S 0 ALIAS -composition Na2SO4 component[2] O 0 ALIAS -composition Na2SO4 owner Na2SO4 0 ALIAS -composition Na3AlF6 component[0] Na 0 ALIAS -composition Na3AlF6 component[1] Al 0 ALIAS -composition Na3AlF6 component[2] F 0 ALIAS -composition Na3AlF6 owner Na3AlF6 0 ALIAS -composition NaAlO2 component[0] Na 0 ALIAS -composition NaAlO2 component[1] Al 0 ALIAS -composition NaAlO2 component[2] O 0 ALIAS -composition NaAlO2 owner NaAlO2 0 ALIAS -composition NaCl component[0] Na 0 ALIAS -composition NaCl component[1] Cl 0 ALIAS -composition NaCl owner NaCl 0 ALIAS -composition NaF component[0] Na 0 ALIAS -composition NaF component[1] F 0 ALIAS -composition NaF owner NaF 0 ALIAS -composition NaHCO3 component[0] Na 0 ALIAS -composition NaHCO3 component[1] H 0 ALIAS -composition NaHCO3 component[2] C 0 ALIAS -composition NaHCO3 component[3] O 0 ALIAS -composition NaHCO3 owner NaHCO3 0 ALIAS -composition NaHSO4 component[0] Na 0 ALIAS -composition NaHSO4 component[1] H 0 ALIAS -composition NaHSO4 component[2] S 0 ALIAS -composition NaHSO4 component[3] O 0 ALIAS -composition NaHSO4 owner NaHSO4 0 ALIAS -composition NaNO3 component[0] Na 0 ALIAS -composition NaNO3 component[1] N 0 ALIAS -composition NaNO3 component[2] O 0 ALIAS -composition NaNO3 owner NaNO3 0 ALIAS -composition NaOH component[0] Na 0 ALIAS -composition NaOH component[1] O 0 ALIAS -composition NaOH component[2] H 0 ALIAS -composition NaOH owner NaOH 0 ALIAS -composition NaSO4 component[0] Na 0 ALIAS -composition NaSO4 component[1] S 0 ALIAS -composition NaSO4 component[2] O 0 ALIAS -composition NaSO4 owner NaSO4 0 ALIAS -composition Nb2O5 component[0] Nb 0 ALIAS -composition Nb2O5 component[1] O 0 ALIAS -composition Nb2O5 owner Nb2O5 0 ALIAS -composition NeodymiumMagnetic component[0] Nd 0 ALIAS -composition NeodymiumMagnetic owner NeodymiumMagnetic 0 VALID -composition NetherQuartz component[0] SiO2 0 ALIAS -composition NetherQuartz owner NetherQuartz 0 VALID -composition Netherite component[0] Au 0 ALIAS -composition Netherite component[1] AncientDebris 0 VALID -composition Netherite owner Netherite 0 VALID -composition NetherizedDiamond component[0] Netherite 0 VALID -composition NetherizedDiamond component[1] Diamond 0 VALID -composition NetherizedDiamond owner NetherizedDiamond 0 VALID -composition Nichrome component[0] Ni 0 ALIAS -composition Nichrome component[1] Cr 0 ALIAS -composition Nichrome owner Nichrome 0 VALID -composition NikolineAlloy component[0] Si 0 ALIAS -composition NikolineAlloy component[1] Nikolite 0 VALID -composition NikolineAlloy owner NikolineAlloy 0 VALID -composition Nikolite component[0] Sodalite 0 VALID -composition Nikolite component[1] Cu 0 ALIAS -composition Nikolite component[2] SiO2 0 ALIAS -composition Nikolite component[3] Ar 0 ALIAS -composition Nikolite owner Nikolite 0 VALID -composition NiobiumTitanium component[0] Nb 0 ALIAS -composition NiobiumTitanium component[1] Ti 0 ALIAS -composition NiobiumTitanium owner NiobiumTitanium 0 VALID -composition Niter component[0] KNO3 0 ALIAS -composition Niter component[1] NaNO3 0 ALIAS -composition Niter owner Niter 0 VALID -composition NitroCarbon component[0] N 0 ALIAS -composition NitroCarbon component[1] C 0 ALIAS -composition NitroCarbon owner NitroCarbon 0 VALID -composition NitroFuel component[0] Glyceryl 0 VALID -composition NitroFuel component[1] Fuel 0 VALID -composition NitroFuel owner NitroFuel 0 VALID -composition Obsidian component[0] Mg 0 ALIAS -composition Obsidian component[1] Fe 0 ALIAS -composition Obsidian component[2] SiO2 0 ALIAS -composition Obsidian component[3] O 0 ALIAS -composition Obsidian owner Obsidian 0 VALID -composition Oilshale component[0] CaCO3 0 ALIAS -composition Oilshale component[1] MilkyQuartz 0 VALID -composition Oilshale component[2] Clay 0 VALID -composition Oilshale owner Oilshale 0 ALIAS -composition OnyxBlack component[0] SiO2 0 ALIAS -composition OnyxBlack owner OnyxBlack 0 VALID -composition OnyxRed component[0] SiO2 0 ALIAS -composition OnyxRed owner OnyxRed 0 VALID -composition Opal component[0] SiO2 0 ALIAS -composition Opal owner Opal 0 VALID -composition OrangeSapphire component[0] Al2O3 0 ALIAS -composition OrangeSapphire component[1] Cu 0 ALIAS -composition OrangeSapphire owner OrangeSapphire 0 VALID -composition Osmiridium component[0] Os 0 ALIAS -composition Osmiridium component[1] Ir 0 ALIAS -composition Osmiridium owner Osmiridium 0 VALID -composition OsmiumTetroxide component[0] Os 0 ALIAS -composition OsmiumTetroxide component[1] O 0 ALIAS -composition OsmiumTetroxide owner OsmiumTetroxide 0 RETIRED -composition PO4 component[0] P 0 ALIAS -composition PO4 component[1] O 0 ALIAS -composition PO4 owner PO4 0 ALIAS -composition PVC component[0] C 0 ALIAS -composition PVC component[1] H 0 ALIAS -composition PVC owner PVC 0 VALID -composition Pentlandite component[0] Ni 0 ALIAS -composition Pentlandite component[1] S 0 ALIAS -composition Pentlandite owner Pentlandite 0 VALID -composition Peridot component[0] SiO2 0 ALIAS -composition Peridot component[1] Fe 0 ALIAS -composition Peridot component[2] Mg 0 ALIAS -composition Peridot owner Peridot 0 VALID -composition Perlite component[0] Obsidian 0 VALID -composition Perlite component[1] H2O 0 ALIAS -composition Perlite owner Perlite 0 VALID -composition PetCoke component[0] C 0 ALIAS -composition PetCoke component[1] S 0 ALIAS -composition PetCoke owner PetCoke 0 ALIAS -composition PetrifiedWood component[0] Wood 0 VALID -composition PetrifiedWood owner PetrifiedWood 0 VALID -composition Petrotheum component[0] Clay 0 VALID -composition Petrotheum component[1] Obsidian 0 VALID -composition Petrotheum component[2] Redstone 0 VALID -composition Petrotheum component[3] Basalz 0 VALID -composition Petrotheum owner Petrotheum 0 RETIRED -composition Phosphorite component[0] Ca 0 ALIAS -composition Phosphorite component[1] PO4 0 ALIAS -composition Phosphorite component[2] F 0 ALIAS -composition Phosphorite owner Phosphorite 0 VALID -composition Phosphorus component[0] Ca 0 ALIAS -composition Phosphorus component[1] PO4 0 ALIAS -composition Phosphorus owner Phosphorus 0 VALID -composition PhosphorusBlue component[0] Ca 0 ALIAS -composition PhosphorusBlue component[1] PO4 0 ALIAS -composition PhosphorusBlue owner PhosphorusBlue 0 ALIAS -composition PhosphorusRed component[0] Ca 0 ALIAS -composition PhosphorusRed component[1] PO4 0 ALIAS -composition PhosphorusRed owner PhosphorusRed 0 ALIAS -composition PhosphorusWhite component[0] Ca 0 ALIAS -composition PhosphorusWhite component[1] PO4 0 ALIAS -composition PhosphorusWhite owner PhosphorusWhite 0 ALIAS -composition Pinalite component[0] Pb 0 ALIAS -composition Pinalite component[1] WO3 0 ALIAS -composition Pinalite component[2] Cl 0 ALIAS -composition Pinalite component[3] O 0 ALIAS -composition Pinalite owner Pinalite 0 VALID -composition PinkVitriol component[0] Mg 0 ALIAS -composition PinkVitriol component[1] S 0 ALIAS -composition PinkVitriol component[2] O 0 ALIAS -composition PinkVitriol owner PinkVitriol 0 VALID -composition Pitchblende component[0] Uraninite 0 VALID -composition Pitchblende component[1] Th 0 ALIAS -composition Pitchblende component[2] Pb 0 ALIAS -composition Pitchblende owner Pitchblende 0 VALID -composition Plastic component[0] C 0 ALIAS -composition Plastic component[1] H 0 ALIAS -composition Plastic owner Plastic 0 VALID -composition Pollucite component[0] Al2O3 0 ALIAS -composition Pollucite component[1] Cs 0 ALIAS -composition Pollucite component[2] SiO2 0 ALIAS -composition Pollucite component[3] H2O 0 ALIAS -composition Pollucite component[4] O 0 ALIAS -composition Pollucite owner Pollucite 0 VALID -composition Porcelain component[0] Ceramic 0 VALID -composition Porcelain component[1] SiO2 0 ALIAS -composition Porcelain component[2] PotassiumFeldspar 0 VALID -composition Porcelain owner Porcelain 0 VALID -composition PotassiumFeldspar component[0] K 0 ALIAS -composition PotassiumFeldspar component[1] Al2O3 0 ALIAS -composition PotassiumFeldspar component[2] SiO2 0 ALIAS -composition PotassiumFeldspar component[3] O 0 ALIAS -composition PotassiumFeldspar owner PotassiumFeldspar 0 VALID -composition Powellite component[0] Ca 0 ALIAS -composition Powellite component[1] Mo 0 ALIAS -composition Powellite component[2] O 0 ALIAS -composition Powellite owner Powellite 0 VALID -composition Pumice component[0] Peridot 0 VALID -composition Pumice component[1] MgCO3 0 ALIAS -composition Pumice component[2] Flint 0 VALID -composition Pumice component[3] DarkAsh 0 ALIAS -composition Pumice owner Pumice 0 VALID -composition PurpleSapphire component[0] Al2O3 0 ALIAS -composition PurpleSapphire component[1] V 0 ALIAS -composition PurpleSapphire owner PurpleSapphire 0 VALID -composition Pyrite component[0] Fe 0 ALIAS -composition Pyrite component[1] S 0 ALIAS -composition Pyrite owner Pyrite 0 VALID -composition Pyrope component[0] Al2O3 0 ALIAS -composition Pyrope component[1] Mg 0 ALIAS -composition Pyrope component[2] SiO2 0 ALIAS -composition Pyrope component[3] O 0 ALIAS -composition Pyrope owner Pyrope 0 VALID -composition Pyrotheum component[0] Coal 0 VALID -composition Pyrotheum component[1] S 0 ALIAS -composition Pyrotheum component[2] Redstone 0 VALID -composition Pyrotheum component[3] Blaze 0 VALID -composition Pyrotheum owner Pyrotheum 0 RETIRED -composition QuartzSand component[0] CertusQuartz 0 VALID -composition QuartzSand component[1] MilkyQuartz 0 VALID -composition QuartzSand owner QuartzSand 0 VALID -composition Quicklime component[0] Ca 0 ALIAS -composition Quicklime component[1] O 0 ALIAS -composition Quicklime owner Quicklime 0 VALID -composition Realgar component[0] As 0 ALIAS -composition Realgar component[1] S 0 ALIAS -composition Realgar owner Realgar 0 VALID -composition RedAlloy component[0] Cu 0 ALIAS -composition RedAlloy component[1] Redstone 0 VALID -composition RedAlloy owner RedAlloy 0 VALID -composition RedQuartz component[0] SiO2 0 ALIAS -composition RedQuartz owner RedQuartz 0 VALID -composition RedSteel component[0] RoseGold 0 VALID -composition RedSteel component[1] Brass 0 VALID -composition RedSteel component[2] Steel 0 VALID -composition RedSteel component[3] BlackSteel 0 VALID -composition RedSteel owner RedSteel 0 VALID -composition RedVitriol component[0] Co 0 ALIAS -composition RedVitriol component[1] S 0 ALIAS -composition RedVitriol component[2] O 0 ALIAS -composition RedVitriol owner RedVitriol 0 VALID -composition Redstone component[0] Pyrite 0 VALID -composition Redstone component[1] Hg 0 ALIAS -composition Redstone component[2] SiO2 0 ALIAS -composition Redstone component[3] Ruby 0 VALID -composition Redstone owner Redstone 0 VALID -composition RedstoneAlloy component[0] Si 0 ALIAS -composition RedstoneAlloy component[1] Redstone 0 VALID -composition RedstoneAlloy owner RedstoneAlloy 0 VALID -composition RoseGold component[0] Cu 0 ALIAS -composition RoseGold component[1] Au 0 ALIAS -composition RoseGold owner RoseGold 0 VALID -composition Rubber component[0] C 0 ALIAS -composition Rubber component[1] H 0 ALIAS -composition Rubber owner Rubber 0 VALID -composition Ruby component[0] Al2O3 0 ALIAS -composition Ruby component[1] Cr 0 ALIAS -composition Ruby owner Ruby 0 VALID -composition Russellite component[0] Bi 0 ALIAS -composition Russellite component[1] WO3 0 ALIAS -composition Russellite component[2] O 0 ALIAS -composition Russellite owner Russellite 0 VALID -composition SO2 component[0] S 0 ALIAS -composition SO2 component[1] O 0 ALIAS -composition SO2 owner SO2 0 ALIAS -composition SO3 component[0] S 0 ALIAS -composition SO3 component[1] O 0 ALIAS -composition SO3 owner SO3 0 ALIAS -composition SaltWater component[0] H2O 0 ALIAS -composition SaltWater component[1] NaCl 0 ALIAS -composition SaltWater owner SaltWater 0 ALIAS -composition SaltedWater component[0] H2O 0 ALIAS -composition SaltedWater component[1] KCl 0 ALIAS -composition SaltedWater owner SaltedWater 0 VALID -composition Sapphire component[0] Al2O3 0 ALIAS -composition Sapphire owner Sapphire 0 VALID -composition Scheelite component[0] Ca 0 ALIAS -composition Scheelite component[1] WO3 0 ALIAS -composition Scheelite component[2] O 0 ALIAS -composition Scheelite owner Scheelite 0 VALID -composition SeaWater component[0] H 0 ALIAS -composition SeaWater component[1] O 0 ALIAS -composition SeaWater owner SeaWater 0 VALID -composition Shale component[0] CaCO3 0 ALIAS -composition Shale component[1] MilkyQuartz 0 VALID -composition Shale component[2] Clay 0 VALID -composition Shale owner Shale 0 VALID -composition SiC component[0] Si 0 ALIAS -composition SiC component[1] C 0 ALIAS -composition SiC owner SiC 0 ALIAS -composition SiO2 component[0] Si 0 ALIAS -composition SiO2 component[1] O 0 ALIAS -composition SiO2 owner SiO2 0 ALIAS -composition Signalum component[0] Cu 0 ALIAS -composition Signalum component[1] Ag 0 ALIAS -composition Signalum component[2] RedAlloy 0 VALID -composition Signalum owner Signalum 0 VALID -composition Silverwood component[0] C 0 ALIAS -composition Silverwood component[1] H2O 0 ALIAS -composition Silverwood owner Silverwood 0 VALID -composition Smithsonite component[0] Zn 0 ALIAS -composition Smithsonite component[1] C 0 ALIAS -composition Smithsonite component[2] O 0 ALIAS -composition Smithsonite owner Smithsonite 0 VALID -composition SmokeyQuartz component[0] SiO2 0 ALIAS -composition SmokeyQuartz owner SmokeyQuartz 0 VALID -composition Snow component[0] H 0 ALIAS -composition Snow component[1] O 0 ALIAS -composition Snow owner Snow 0 VALID -composition Sodalite component[0] Al2O3 0 ALIAS -composition Sodalite component[1] SiO2 0 ALIAS -composition Sodalite component[2] Na 0 ALIAS -composition Sodalite component[3] Cl 0 ALIAS -composition Sodalite owner Sodalite 0 VALID -composition SodiumPeroxide component[0] Na 0 ALIAS -composition SodiumPeroxide component[1] O 0 ALIAS -composition SodiumPeroxide owner SodiumPeroxide 0 RETIRED -composition SolderingAlloy component[0] Sn 0 ALIAS -composition SolderingAlloy component[1] Sb 0 ALIAS -composition SolderingAlloy owner SolderingAlloy 0 VALID -composition Soularium component[0] SoulSand 0 ALIAS -composition Soularium component[1] Au 0 ALIAS -composition Soularium owner Soularium 0 VALID -composition Sperrylite component[0] Pt 0 ALIAS -composition Sperrylite component[1] As 0 ALIAS -composition Sperrylite owner Sperrylite 0 VALID -composition Spessartine component[0] Al2O3 0 ALIAS -composition Spessartine component[1] Mn 0 ALIAS -composition Spessartine component[2] SiO2 0 ALIAS -composition Spessartine component[3] O 0 ALIAS -composition Spessartine owner Spessartine 0 VALID -composition Sphalerite component[0] Zn 0 ALIAS -composition Sphalerite component[1] S 0 ALIAS -composition Sphalerite owner Sphalerite 0 VALID -composition Spinel component[0] Al2O3 0 ALIAS -composition Spinel component[1] Mg 0 ALIAS -composition Spinel component[2] O 0 ALIAS -composition Spinel owner Spinel 0 VALID -composition Spodumene component[0] Al2O3 0 ALIAS -composition Spodumene component[1] Li 0 ALIAS -composition Spodumene component[2] SiO2 0 ALIAS -composition Spodumene component[3] O 0 ALIAS -composition Spodumene owner Spodumene 0 VALID -composition StainlessSteel component[0] WroughtIron 0 VALID -composition StainlessSteel component[1] Invar 0 VALID -composition StainlessSteel component[2] Cr 0 ALIAS -composition StainlessSteel component[3] Mn 0 ALIAS -composition StainlessSteel owner StainlessSteel 0 VALID -composition StannicChloride component[0] Sn 0 ALIAS -composition StannicChloride component[1] Cl 0 ALIAS -composition StannicChloride owner StannicChloride 0 VALID -composition Stannite component[0] Cu 0 ALIAS -composition Stannite component[1] Fe 0 ALIAS -composition Stannite component[2] Sn 0 ALIAS -composition Stannite component[3] S 0 ALIAS -composition Stannite owner Stannite 0 VALID -composition Steam component[0] H 0 ALIAS -composition Steam component[1] O 0 ALIAS -composition Steam owner Steam 0 VALID -composition Steel component[0] WroughtIron 0 VALID -composition Steel owner Steel 0 VALID -composition SteelGalvanized component[0] Steel 0 VALID -composition SteelGalvanized component[1] Zn 0 ALIAS -composition SteelGalvanized owner SteelGalvanized 0 VALID -composition SteelMagnetic component[0] Steel 0 VALID -composition SteelMagnetic owner SteelMagnetic 0 VALID -composition Steeleaf component[0] Steel 0 VALID -composition Steeleaf component[1] Ma 0 ALIAS -composition Steeleaf owner Steeleaf 0 VALID -composition SterlingSilver component[0] Cu 0 ALIAS -composition SterlingSilver component[1] Ag 0 ALIAS -composition SterlingSilver owner SterlingSilver 0 VALID -composition Stibnite component[0] Sb 0 ALIAS -composition Stibnite component[1] S 0 ALIAS -composition Stibnite owner Stibnite 0 VALID -composition Stolzite component[0] Pb 0 ALIAS -composition Stolzite component[1] WO3 0 ALIAS -composition Stolzite component[2] O 0 ALIAS -composition Stolzite owner Stolzite 0 VALID -composition Sugar component[0] C 0 ALIAS -composition Sugar component[1] H 0 ALIAS -composition Sugar component[2] O 0 ALIAS -composition Sugar owner Sugar 0 VALID -composition SunnyQuartz component[0] SiO2 0 ALIAS -composition SunnyQuartz owner SunnyQuartz 0 VALID -composition T2O component[0] T 0 ALIAS -composition T2O component[1] O 0 ALIAS -composition T2O owner T2O 0 ALIAS -composition Ta2O5 component[0] Ta 0 ALIAS -composition Ta2O5 component[1] O 0 ALIAS -composition Ta2O5 owner Ta2O5 0 ALIAS -composition Ta4HfC5 component[0] Ta 0 ALIAS -composition Ta4HfC5 component[1] Hf 0 ALIAS -composition Ta4HfC5 component[2] C 0 ALIAS -composition Ta4HfC5 owner Ta4HfC5 0 ALIAS -composition Talc component[0] Mg 0 ALIAS -composition Talc component[1] SiO2 0 ALIAS -composition Talc component[2] H2O 0 ALIAS -composition Talc component[3] O 0 ALIAS -composition Talc owner Talc 0 VALID -composition Tantalite component[0] Ta2O5 0 ALIAS -composition Tantalite component[1] MnO2 0 ALIAS -composition Tantalite owner Tantalite 0 VALID -composition Tanzanite component[0] Al2O3 0 ALIAS -composition Tanzanite component[1] SiO2 0 ALIAS -composition Tanzanite component[2] Ca 0 ALIAS -composition Tanzanite component[3] H2O 0 ALIAS -composition Tanzanite component[4] O 0 ALIAS -composition Tanzanite owner Tanzanite 0 VALID -composition Teflon component[0] C 0 ALIAS -composition Teflon component[1] H 0 ALIAS -composition Teflon owner Teflon 0 VALID -composition Tetrahedrite component[0] Cu 0 ALIAS -composition Tetrahedrite component[1] Sb 0 ALIAS -composition Tetrahedrite component[2] Fe 0 ALIAS -composition Tetrahedrite component[3] S 0 ALIAS -composition Tetrahedrite owner Tetrahedrite 0 VALID -composition Thaumium component[0] Fe 0 ALIAS -composition Thaumium component[1] Ma 0 ALIAS -composition Thaumium owner Thaumium 0 VALID -composition TiCl4 component[0] Ti 0 ALIAS -composition TiCl4 component[1] Cl 0 ALIAS -composition TiCl4 owner TiCl4 0 ALIAS -composition TiO2 component[0] Ti 0 ALIAS -composition TiO2 component[1] O 0 ALIAS -composition TiO2 owner TiO2 0 ALIAS -composition TinAlloy component[0] Sn 0 ALIAS -composition TinAlloy component[1] WroughtIron 0 VALID -composition TinAlloy owner TinAlloy 0 VALID -composition Topaz component[0] Al2O3 0 ALIAS -composition Topaz component[1] SiO2 0 ALIAS -composition Topaz component[2] F 0 ALIAS -composition Topaz component[3] H2O 0 ALIAS -composition Topaz owner Topaz 0 VALID -composition Trinaquadalloy component[0] Ke 0 ALIAS -composition Trinaquadalloy component[1] Nq 0 ALIAS -composition Trinaquadalloy component[2] C 0 ALIAS -composition Trinaquadalloy owner Trinaquadalloy 0 VALID -composition Trinitanium component[0] Ke 0 ALIAS -composition Trinitanium component[1] Ti 0 ALIAS -composition Trinitanium owner Trinitanium 0 VALID -composition TritaniumAlloy component[0] Tn 0 ALIAS -composition TritaniumAlloy component[1] Dn 0 ALIAS -composition TritaniumAlloy owner TritaniumAlloy 0 ALIAS -composition TritaniumDioxide component[0] Tn 0 ALIAS -composition TritaniumDioxide component[1] O 0 ALIAS -composition TritaniumDioxide owner TritaniumDioxide 0 VALID -composition TritaniumHexaastatide component[0] Tn 0 ALIAS -composition TritaniumHexaastatide component[1] At 0 ALIAS -composition TritaniumHexaastatide owner TritaniumHexaastatide 0 VALID -composition TritaniumHexabromide component[0] Tn 0 ALIAS -composition TritaniumHexabromide component[1] Br 0 ALIAS -composition TritaniumHexabromide owner TritaniumHexabromide 0 VALID -composition TritaniumHexachloride component[0] Tn 0 ALIAS -composition TritaniumHexachloride component[1] Cl 0 ALIAS -composition TritaniumHexachloride owner TritaniumHexachloride 0 VALID -composition TritaniumHexafluoride component[0] Tn 0 ALIAS -composition TritaniumHexafluoride component[1] F 0 ALIAS -composition TritaniumHexafluoride owner TritaniumHexafluoride 0 VALID -composition TritaniumHexaiodide component[0] Tn 0 ALIAS -composition TritaniumHexaiodide component[1] I 0 ALIAS -composition TritaniumHexaiodide owner TritaniumHexaiodide 0 VALID -composition Trona component[0] Na2CO3 0 ALIAS -composition Trona component[1] H2O 0 ALIAS -composition Trona owner Trona 0 VALID -composition Tungstate component[0] Li 0 ALIAS -composition Tungstate component[1] WO3 0 ALIAS -composition Tungstate component[2] O 0 ALIAS -composition Tungstate owner Tungstate 0 VALID -composition TungstenCarbide component[0] W 0 ALIAS -composition TungstenCarbide component[1] C 0 ALIAS -composition TungstenCarbide owner TungstenCarbide 0 VALID -composition TungstenSintered component[0] W 0 ALIAS -composition TungstenSintered owner TungstenSintered 0 VALID -composition TungstenSteel component[0] Steel 0 VALID -composition TungstenSteel component[1] W 0 ALIAS -composition TungstenSteel owner TungstenSteel 0 ALIAS -composition U235F4 component[0] U_235 0 ALIAS -composition U235F4 component[1] F 0 ALIAS -composition U235F4 owner U235F4 0 ALIAS -composition U235F6 component[0] U_235 0 ALIAS -composition U235F6 component[1] F 0 ALIAS -composition U235F6 owner U235F6 0 ALIAS -composition U238F4 component[0] U_238 0 ALIAS -composition U238F4 component[1] F 0 ALIAS -composition U238F4 owner U238F4 0 ALIAS -composition U238F6 component[0] U_238 0 ALIAS -composition U238F6 component[1] F 0 ALIAS -composition U238F6 owner U238F6 0 ALIAS -composition UF4 component[0] U_238 0 ALIAS -composition UF4 component[1] F 0 ALIAS -composition UF4 owner UF4 0 ALIAS -composition UF6 component[0] U_238 0 ALIAS -composition UF6 component[1] F 0 ALIAS -composition UF6 owner UF6 0 ALIAS -composition Ultimet component[0] Co 0 ALIAS -composition Ultimet component[1] Ni 0 ALIAS -composition Ultimet component[2] Cr 0 ALIAS -composition Ultimet component[3] Mo 0 ALIAS -composition Ultimet owner Ultimet 0 VALID -composition Uraninite component[0] U_238 0 ALIAS -composition Uraninite component[1] O 0 ALIAS -composition Uraninite owner Uraninite 0 VALID -composition Uvarovite component[0] Ca 0 ALIAS -composition Uvarovite component[1] Cr 0 ALIAS -composition Uvarovite component[2] SiO2 0 ALIAS -composition Uvarovite component[3] O 0 ALIAS -composition Uvarovite owner Uvarovite 0 VALID -composition V2O5 component[0] V 0 ALIAS -composition V2O5 component[1] O 0 ALIAS -composition V2O5 owner V2O5 0 ALIAS -composition VanadiumGallium component[0] V 0 ALIAS -composition VanadiumGallium component[1] Ga 0 ALIAS -composition VanadiumGallium owner VanadiumGallium 0 VALID -composition VanadiumSteel component[0] Steel 0 VALID -composition VanadiumSteel component[1] V 0 ALIAS -composition VanadiumSteel owner VanadiumSteel 0 VALID -composition Vermiculite component[0] Al2O3 0 ALIAS -composition Vermiculite component[1] Fe 0 ALIAS -composition Vermiculite component[2] SiO2 0 ALIAS -composition Vermiculite component[3] H2O 0 ALIAS -composition Vermiculite component[4] H 0 ALIAS -composition Vermiculite owner Vermiculite 0 VALID -composition Vibramantium component[0] Vb 0 ALIAS -composition Vibramantium component[1] Ad 0 ALIAS -composition Vibramantium owner Vibramantium 0 VALID -composition VibraniumSilver component[0] Vb 0 ALIAS -composition VibraniumSilver component[1] Ag 0 ALIAS -composition VibraniumSilver owner VibraniumSilver 0 VALID -composition VibraniumSteel component[0] Vb 0 ALIAS -composition VibraniumSteel component[1] Steel 0 VALID -composition VibraniumSteel owner VibraniumSteel 0 VALID -composition Vinteum component[0] Ma 0 ALIAS -composition Vinteum owner Vinteum 0 RETIRED -composition VinteumPurified component[0] Ma 0 ALIAS -composition VinteumPurified owner VinteumPurified 0 RETIRED -composition Vis component[0] Ma 0 ALIAS -composition Vis owner Vis 0 RETIRED -composition VitriolOfClay component[0] Al2O3 0 ALIAS -composition VitriolOfClay component[1] S 0 ALIAS -composition VitriolOfClay component[2] O 0 ALIAS -composition VitriolOfClay owner VitriolOfClay 0 VALID -composition WO3 component[0] W 0 ALIAS -composition WO3 component[1] O 0 ALIAS -composition WO3 owner WO3 0 ALIAS -composition WhiteVitriol component[0] Zn 0 ALIAS -composition WhiteVitriol component[1] S 0 ALIAS -composition WhiteVitriol component[2] O 0 ALIAS -composition WhiteVitriol owner WhiteVitriol 0 VALID -composition Wolframite component[0] Mg 0 ALIAS -composition Wolframite component[1] WO3 0 ALIAS -composition Wolframite component[2] O 0 ALIAS -composition Wolframite owner Wolframite 0 VALID -composition Wollastonite component[0] Ca 0 ALIAS -composition Wollastonite component[1] SiO2 0 ALIAS -composition Wollastonite component[2] O 0 ALIAS -composition Wollastonite owner Wollastonite 0 VALID -composition Wood component[0] C 0 ALIAS -composition Wood component[1] H2O 0 ALIAS -composition Wood owner Wood 0 VALID -composition WoodPolished component[0] C 0 ALIAS -composition WoodPolished component[1] H2O 0 ALIAS -composition WoodPolished owner WoodPolished 0 VALID -composition WoodRubber component[0] C 0 ALIAS -composition WoodRubber component[1] H2O 0 ALIAS -composition WoodRubber owner WoodRubber 0 VALID -composition WoodTreated component[0] C 0 ALIAS -composition WoodTreated component[1] H2O 0 ALIAS -composition WoodTreated owner WoodTreated 0 VALID -composition WroughtIron component[0] Fe 0 ALIAS -composition WroughtIron owner WroughtIron 0 VALID -composition Wulfenite component[0] Pb 0 ALIAS -composition Wulfenite component[1] Mo 0 ALIAS -composition Wulfenite component[2] O 0 ALIAS -composition Wulfenite owner Wulfenite 0 VALID -composition YellowLimonite component[0] Fe 0 ALIAS -composition YellowLimonite component[1] H 0 ALIAS -composition YellowLimonite component[2] O 0 ALIAS -composition YellowLimonite owner YellowLimonite 0 VALID -composition YellowSapphire component[0] Al2O3 0 ALIAS -composition YellowSapphire component[1] TiO2 0 ALIAS -composition YellowSapphire owner YellowSapphire 0 VALID -composition YttriumBariumCuprate component[0] Y 0 ALIAS -composition YttriumBariumCuprate component[1] Ba 0 ALIAS -composition YttriumBariumCuprate component[2] Cu 0 ALIAS -composition YttriumBariumCuprate component[3] O 0 ALIAS -composition YttriumBariumCuprate owner YttriumBariumCuprate 0 VALID -composition Zeolite component[0] Al2O3 0 ALIAS -composition Zeolite component[1] Na 0 ALIAS -composition Zeolite component[2] SiO2 0 ALIAS -composition Zeolite component[3] H2O 0 ALIAS -composition Zeolite component[4] O 0 ALIAS -composition Zeolite owner Zeolite 0 VALID -composition Zircon component[0] Zr 0 ALIAS -composition Zircon component[1] SiO2 0 ALIAS -composition Zircon component[2] O 0 ALIAS -composition Zircon owner Zircon 0 VALID -decomposition Adamantine owner Adamantine 8784 VALID -decomposition Almandine owner Almandine 9101 VALID -decomposition Alumina owner Alumina 8008 VALID -decomposition AluminiumAlloy owner AluminiumAlloy 8622 VALID -decomposition AluminiumBrass owner AluminiumBrass 8700 VALID -decomposition AluminiumFluoride owner AluminiumFluoride 8010 VALID -decomposition AluminiumHydroxide owner AluminiumHydroxide 8014 VALID -decomposition Alumite owner Alumite 8702 VALID -decomposition Alunite owner Alunite 9162 VALID -decomposition Amazonite owner Amazonite 8417 VALID -decomposition Amethyst owner Amethyst 8313 VALID -decomposition Ammonia owner Ammonia 8025 VALID -decomposition Andradite owner Andradite 9102 VALID -decomposition AnnealedCopper owner AnnealedCopper 8640 VALID -decomposition Apatite owner Apatite 8209 VALID -decomposition AquaRegia owner AquaRegia 9827 VALID -decomposition Aquamarine owner Aquamarine 8323 VALID -decomposition ArsenicBronze owner ArsenicBronze 8615 VALID -decomposition ArsenicCopper owner ArsenicCopper 8614 VALID -decomposition Arsenopyrite owner Arsenopyrite 9216 VALID -decomposition Asbestos owner Asbestos 9103 VALID -decomposition Azurite owner Azurite 8420 VALID -decomposition BalasRuby owner BalasRuby 8303 VALID -decomposition Barite owner Barite 9160 VALID -decomposition Basalt owner Basalt 8505 VALID -decomposition BasalticMineralSand owner BasalticMineralSand 9003 VALID -decomposition Bastnasite owner Bastnasite 9144 VALID -decomposition BatteryAlloy owner BatteryAlloy 8668 VALID -decomposition Bauxite owner Bauxite 9105 VALID -decomposition Bentonite owner Bentonite 9153 VALID -decomposition Biotite owner Biotite 9141 VALID -decomposition Bischofite owner Bischofite 9221 VALID -decomposition BismuthBronze owner BismuthBronze 8612 VALID -decomposition Bixbite owner Bixbite 8386 VALID -decomposition BlackAventurine owner BlackAventurine 8449 VALID -decomposition BlackBronze owner BlackBronze 8611 VALID -decomposition BlackEye owner BlackEye 8434 VALID -decomposition BlackFluorite owner BlackFluorite 8440 VALID -decomposition BlackSteel owner BlackSteel 8631 VALID -decomposition BlackVitriol owner BlackVitriol 8403 VALID -decomposition BlueAlloy owner BlueAlloy 8659 VALID -decomposition BlueAventurine owner BlueAventurine 8450 VALID -decomposition BlueDiamond owner BlueDiamond 8464 VALID -decomposition BlueFluorite owner BlueFluorite 8438 VALID -decomposition BlueJasper owner BlueJasper 8427 VALID -decomposition BluePhosphorus owner BluePhosphorus 8458 VALID -decomposition BlueSapphire owner BlueSapphire 8328 VALID -decomposition BlueSteel owner BlueSteel 8632 VALID -decomposition BlueTopaz owner BlueTopaz 8307 VALID -decomposition BlueVitriol owner BlueVitriol 8404 VALID -decomposition Bone owner Bone 8219 VALID -decomposition Borax owner Borax 9139 VALID -decomposition Brass owner Brass 8620 VALID -decomposition Bromargyrite owner Bromargyrite 9210 VALID -decomposition Bronze owner Bronze 8610 VALID -decomposition BrownAventurine owner BrownAventurine 8446 VALID -decomposition BrownLimonite owner BrownLimonite 9106 VALID -decomposition Butane owner Butane 9866 VALID -decomposition Calcite owner Calcite 9107 VALID -decomposition CalciumChloride owner CalciumChloride 8028 VALID -decomposition CalciumSulfate owner CalciumSulfate 8274 VALID -decomposition CarbonDioxide owner CarbonDioxide 9836 VALID -decomposition CarbonMonoxide owner CarbonMonoxide 9838 VALID -decomposition CarbonTrioxide owner CarbonTrioxide 9843 VALID -decomposition Carborundum owner Carborundum 8003 VALID -decomposition Cassiterite owner Cassiterite 9108 VALID -decomposition CastIron owner CastIron 8803 VALID -decomposition CatsEye owner CatsEye 8431 VALID -decomposition CdInAgAlloy owner CdInAgAlloy 8605 VALID -decomposition Celestine owner Celestine 9110 VALID -decomposition Ceramic owner Ceramic 8225 VALID -decomposition Chalcopyrite owner Chalcopyrite 9111 VALID -decomposition Charcoal owner Charcoal 8336 VALID -decomposition ChloroauricAcid owner ChloroauricAcid 8400 VALID -decomposition ChloroplatinicAcid owner ChloroplatinicAcid 8401 VALID -decomposition Chocolate owner Chocolate 9783 VALID -decomposition Chromite owner Chromite 9113 VALID -decomposition ChromiumDioxide owner ChromiumDioxide 8685 VALID -decomposition Cinnabar owner Cinnabar 9114 VALID -decomposition Clay owner Clay 8215 VALID -decomposition ClayBrown owner ClayBrown 8276 VALID -decomposition ClayRed owner ClayRed 8455 VALID -decomposition Coal owner Coal 8334 VALID -decomposition CoalCoke owner CoalCoke 8349 VALID -decomposition CobaltBrass owner CobaltBrass 8621 VALID -decomposition CobaltHexahydrate owner CobaltHexahydrate 8229 VALID -decomposition Cobaltite owner Cobaltite 9115 VALID -decomposition Coltan owner Coltan 9247 VALID -decomposition Columbite owner Columbite 9246 VALID -decomposition ConductiveIron owner ConductiveIron 8727 VALID -decomposition Constantan owner Constantan 8662 VALID -decomposition Cooperite owner Cooperite 9116 VALID -decomposition Cryolite owner Cryolite 8009 VALID -decomposition CrystalMatrix owner CrystalMatrix 8799 VALID -decomposition CyanVitriol owner CyanVitriol 8408 VALID -decomposition DamascusSteel owner DamascusSteel 8634 VALID -decomposition Datolite owner Datolite 8006 VALID -decomposition Diamantine owner Diamantine 8377 RETIRED -decomposition Diamond owner Diamond 8300 VALID -decomposition DiamondIndustrial owner DiamondIndustrial 8423 VALID -decomposition Diatomite owner Diatomite 9001 VALID -decomposition DiduraniumTrioxide owner DiduraniumTrioxide 9198 VALID -decomposition Dioptase owner Dioptase 8325 VALID -decomposition DisulfuricAcid owner DisulfuricAcid 9844 VALID -decomposition DragonEye owner DragonEye 8432 VALID -decomposition Duralumin owner Duralumin 8756 VALID -decomposition Duranium owner Duranium 8751 VALID -decomposition DuraniumHexaastatide owner DuraniumHexaastatide 9203 VALID -decomposition DuraniumHexabromide owner DuraniumHexabromide 9201 VALID -decomposition DuraniumHexachloride owner DuraniumHexachloride 9200 VALID -decomposition DuraniumHexafluoride owner DuraniumHexafluoride 9199 VALID -decomposition DuraniumHexaiodide owner DuraniumHexaiodide 9202 VALID -decomposition ElectricalSteel owner ElectricalSteel 8730 VALID -decomposition ElectrotineAlloy owner ElectrotineAlloy 8658 VALID -decomposition Electrum owner Electrum 8600 VALID -decomposition ElvenElementium owner ElvenElementium 8722 VALID -decomposition Emeradic owner Emeradic 8379 RETIRED -decomposition Emerald owner Emerald 8301 VALID -decomposition EnderEye owner EnderEye 8319 VALID -decomposition EnderPearl owner EnderPearl 8318 VALID -decomposition Enderium owner Enderium 8710 VALID -decomposition EnderiumBase owner EnderiumBase 8729 VALID -decomposition EnergiumCyan owner EnergiumCyan 8299 VALID -decomposition EnergiumRed owner EnergiumRed 8298 VALID -decomposition Enori owner Enori 8380 RETIRED -decomposition Ethylene owner Ethylene 9868 VALID -decomposition Eudialyte owner Eudialyte 8421 VALID -decomposition Ferberite owner Ferberite 9194 VALID -decomposition FerricChloride owner FerricChloride 8017 VALID -decomposition FerricOxyhydroxide owner FerricOxyhydroxide 8035 VALID -decomposition FerrousChloride owner FerrousChloride 8030 VALID -decomposition FierySteel owner FierySteel 8675 VALID -decomposition Fireleaf owner Fireleaf 8698 VALID -decomposition FlamascusSteel owner FlamascusSteel 8697 VALID -decomposition Flint owner Flint 8002 VALID -decomposition Fluorite owner Fluorite 9215 VALID -decomposition GaiaSpirit owner GaiaSpirit 8735 VALID -decomposition Galena owner Galena 9117 VALID -decomposition GarnetSand owner GarnetSand 9005 VALID -decomposition Garnierite owner Garnierite 9118 VALID -decomposition Glass owner Glass 8001 VALID -decomposition Glauconite owner Glauconite 9150 VALID -decomposition Glowstone owner Glowstone 8341 VALID -decomposition Glycerol owner Glycerol 9828 VALID -decomposition Glyceryl owner Glyceryl 9821 VALID -decomposition Goshenite owner Goshenite 8385 VALID -decomposition Granite owner Granite 8518 VALID -decomposition GraniteBlack owner GraniteBlack 8508 VALID -decomposition GraniteRed owner GraniteRed 8507 VALID -decomposition GraniticMineralSand owner GraniticMineralSand 9004 VALID -decomposition Graphene owner Graphene 9175 VALID -decomposition Graphite owner Graphite 9174 VALID -decomposition GrayVitriol owner GrayVitriol 8410 VALID -decomposition GreenAventurine owner GreenAventurine 8448 VALID -decomposition GreenDiamond owner GreenDiamond 8465 VALID -decomposition GreenFluorite owner GreenFluorite 8439 VALID -decomposition GreenJasper owner GreenJasper 8428 VALID -decomposition GreenSapphire owner GreenSapphire 8305 VALID -decomposition GreenVitriol owner GreenVitriol 8405 VALID -decomposition Grossular owner Grossular 9119 VALID -decomposition Gypsum owner Gypsum 9161 VALID -decomposition HSSE owner HSSE 8797 VALID -decomposition HSSG owner HSSG 8796 VALID -decomposition HSSS owner HSSS 8798 VALID -decomposition HawksEye owner HawksEye 8433 VALID -decomposition HeavyWater owner HeavyWater 9812 VALID -decomposition Heliodor owner Heliodor 8384 VALID -decomposition HeliumNeon owner HeliumNeon 9839 VALID -decomposition Hematite owner Hematite 9104 VALID -decomposition HexafluorosilicicAcid owner HexafluorosilicicAcid 8011 VALID -decomposition Huebnerite owner Huebnerite 9195 VALID -decomposition HydratedCoal owner HydratedCoal 8335 VALID -decomposition HydrochloricAcid owner HydrochloricAcid 9826 VALID -decomposition HydrogenBorate owner HydrogenBorate 8007 VALID -decomposition HydrogenFluoride owner HydrogenFluoride 9829 VALID -decomposition HydrogenPeroxide owner HydrogenPeroxide 9809 VALID -decomposition HydrosulfuricAcid owner HydrosulfuricAcid 8024 VALID -decomposition Ilmenite owner Ilmenite 9120 VALID -decomposition Invar owner Invar 8661 VALID -decomposition IodineSalt owner IodineSalt 8242 VALID -decomposition Ironwood owner Ironwood 8672 VALID -decomposition Kanthal owner Kanthal 8664 VALID -decomposition Kaolinite owner Kaolinite 9167 VALID -decomposition Kesterite owner Kesterite 9213 VALID -decomposition Knightmetal owner Knightmetal 8674 VALID -decomposition Komatiite owner Komatiite 9177 VALID -decomposition Kyanite owner Kyanite 9166 VALID -decomposition Lapis owner Lapis 8332 VALID -decomposition Lazurite owner Lazurite 8330 VALID -decomposition Lepidolite owner Lepidolite 9149 VALID -decomposition Lignite owner Lignite 8337 VALID -decomposition LigniteCoke owner LigniteCoke 8365 VALID -decomposition Limestone owner Limestone 9189 VALID -decomposition LithiumChlorate owner LithiumChlorate 8033 VALID -decomposition LithiumChloride owner LithiumChloride 8029 VALID -decomposition LithiumHydroxide owner LithiumHydroxide 8032 VALID -decomposition LithiumPerchlorate owner LithiumPerchlorate 8034 VALID -decomposition LiveRoot owner LiveRoot 8223 VALID -decomposition Lumium owner Lumium 8709 VALID -decomposition MagentaFluorite owner MagentaFluorite 8444 VALID -decomposition Magnalium owner Magnalium 8665 VALID -decomposition MagnesiumCarbonate owner MagnesiumCarbonate 8016 VALID -decomposition MagnesiumChloride owner MagnesiumChloride 8018 VALID -decomposition Magnetite owner Magnetite 9122 VALID -decomposition Malachite owner Malachite 9156 VALID -decomposition ManaDiamond owner ManaDiamond 8278 VALID -decomposition Manasteel owner Manasteel 8720 VALID -decomposition ManganeseChloride owner ManganeseChloride 8031 VALID -decomposition Marble owner Marble 8506 VALID -decomposition Maxixe owner Maxixe 8387 VALID -decomposition Methane owner Methane 9832 VALID -decomposition MethaneIce owner MethaneIce 9833 VALID -decomposition Mica owner Mica 9158 VALID -decomposition Mirabilite owner Mirabilite 9157 VALID -decomposition Molybdenite owner Molybdenite 9123 VALID -decomposition Monazite owner Monazite 8338 VALID -decomposition Morganite owner Morganite 8324 VALID -decomposition Netherite owner Netherite 8745 VALID -decomposition NetherizedDiamond owner NetherizedDiamond 8746 VALID -decomposition Nichrome owner Nichrome 8663 VALID -decomposition NikolineAlloy owner NikolineAlloy 8737 VALID -decomposition Nikolite owner Nikolite 8340 VALID -decomposition NiobiumPentoxide owner NiobiumPentoxide 8461 VALID -decomposition NiobiumTitanium owner NiobiumTitanium 8689 VALID -decomposition Niter owner Niter 8206 VALID -decomposition NitricAcid owner NitricAcid 9825 VALID -decomposition NitroCarbon owner NitroCarbon 9820 VALID -decomposition NitrogenDioxide owner NitrogenDioxide 9831 VALID -decomposition NitrogenMonoxide owner NitrogenMonoxide 9837 VALID -decomposition Obsidian owner Obsidian 8214 VALID -decomposition OceanJasper owner OceanJasper 8425 VALID -decomposition OilShale owner OilShale 9853 VALID -decomposition OnyxBlack owner OnyxBlack 8416 VALID -decomposition OnyxRed owner OnyxRed 8415 VALID -decomposition Opal owner Opal 8312 VALID -decomposition OrangeFluorite owner OrangeFluorite 8443 VALID -decomposition OrangeSapphire owner OrangeSapphire 8314 VALID -decomposition Osmiridium owner Osmiridium 8682 VALID -decomposition Palis owner Palis 8376 RETIRED -decomposition Palygorskite owner Palygorskite 9154 VALID -decomposition Pentlandite owner Pentlandite 9145 VALID -decomposition Peridot owner Peridot 8311 VALID -decomposition Perlite owner Perlite 9138 VALID -decomposition PetroleumCoke owner PetroleumCoke 8390 VALID -decomposition Petrotheum owner Petrotheum 8245 RETIRED -decomposition Phosphate owner Phosphate 8207 VALID -decomposition Phosphorite owner Phosphorite 8226 VALID -decomposition Phosphorus owner Phosphorus 8208 VALID -decomposition Pinalite owner Pinalite 9197 VALID -decomposition PinkDiamond owner PinkDiamond 8424 VALID -decomposition PinkFluorite owner PinkFluorite 8437 VALID -decomposition PinkVitriol owner PinkVitriol 8407 VALID -decomposition Pitchblende owner Pitchblende 9155 VALID -decomposition Pollucite owner Pollucite 9147 VALID -decomposition Porcelain owner Porcelain 8273 VALID -decomposition PotassiumAluminate owner PotassiumAluminate 8023 VALID -decomposition PotassiumBisulfate owner PotassiumBisulfate 8232 VALID -decomposition PotassiumCarbonate owner PotassiumCarbonate 8020 VALID -decomposition PotassiumFeldspar owner PotassiumFeldspar 9140 VALID -decomposition PotassiumFluoride owner PotassiumFluoride 8036 VALID -decomposition PotassiumHeptafluorotantalate owner PotassiumHeptafluorotantalate 8038 VALID -decomposition PotassiumHydroxide owner PotassiumHydroxide 8015 VALID -decomposition PotassiumNitrate owner PotassiumNitrate 8205 VALID -decomposition PotassiumPersulfate owner PotassiumPersulfate 8022 VALID -decomposition PotassiumPyrosulfate owner PotassiumPyrosulfate 8233 VALID -decomposition PotassiumSulfate owner PotassiumSulfate 8271 VALID -decomposition PotassiumSulfide owner PotassiumSulfide 8272 VALID -decomposition PotassiumSulfite owner PotassiumSulfite 8021 VALID -decomposition Powellite owner Powellite 9124 VALID -decomposition Propane owner Propane 9865 VALID -decomposition Propylene owner Propylene 9867 VALID -decomposition Pumice owner Pumice 9000 VALID -decomposition PurpleSapphire owner PurpleSapphire 8383 VALID -decomposition Pyrite owner Pyrite 9125 VALID -decomposition Pyrolusite owner Pyrolusite 9126 VALID -decomposition Pyrope owner Pyrope 9127 VALID -decomposition Pyrotheum owner Pyrotheum 8212 RETIRED -decomposition QuartzSand owner QuartzSand 9006 VALID -decomposition Quicklime owner Quicklime 9271 VALID -decomposition RainforestJasper owner RainforestJasper 8426 VALID -decomposition Realgar owner Realgar 9109 VALID -decomposition RedAlloy owner RedAlloy 8660 VALID -decomposition RedAventurine owner RedAventurine 8451 VALID -decomposition RedDiamond owner RedDiamond 8467 VALID -decomposition RedFluorite owner RedFluorite 8436 VALID -decomposition RedJasper owner RedJasper 8309 VALID -decomposition RedPhosphorus owner RedPhosphorus 8459 VALID -decomposition RedSteel owner RedSteel 8633 VALID -decomposition RedVitriol owner RedVitriol 8406 VALID -decomposition Redstone owner Redstone 8333 VALID -decomposition RedstoneAlloy owner RedstoneAlloy 8733 VALID -decomposition Redstonia owner Redstonia 8375 RETIRED -decomposition RoseGold owner RoseGold 8602 VALID -decomposition Ruby owner Ruby 8302 VALID -decomposition Russellite owner Russellite 9196 VALID -decomposition Rutile owner Rutile 9192 VALID -decomposition Salt owner Salt 8204 VALID -decomposition SaltedWater owner SaltedWater 9815 VALID -decomposition Saltwater owner Saltwater 9804 VALID -decomposition Sapphire owner Sapphire 8304 VALID -decomposition Scheelite owner Scheelite 9128 VALID -decomposition SemiheavyWater owner SemiheavyWater 9811 VALID -decomposition Shale owner Shale 9190 VALID -decomposition Signalum owner Signalum 8708 VALID -decomposition SiliconDioxide owner SiliconDioxide 8000 VALID -decomposition SkyStone owner SkyStone 8528 VALID -decomposition Smithsonite owner Smithsonite 9211 VALID -decomposition Sodalite owner Sodalite 8331 VALID -decomposition SodiumAluminate owner SodiumAluminate 8012 VALID -decomposition SodiumBisulfate owner SodiumBisulfate 8230 VALID -decomposition SodiumCarbonate owner SodiumCarbonate 8013 VALID -decomposition SodiumFluoride owner SodiumFluoride 8037 VALID -decomposition SodiumHydrogencarbonate owner SodiumHydrogencarbonate 8039 VALID -decomposition SodiumHydroxide owner SodiumHydroxide 8268 VALID -decomposition SodiumNitrate owner SodiumNitrate 8019 VALID -decomposition SodiumPersulfate owner SodiumPersulfate 9822 VALID -decomposition SodiumPyrosulfate owner SodiumPyrosulfate 8231 VALID -decomposition SodiumSulfate owner SodiumSulfate 8270 VALID -decomposition SodiumSulfide owner SodiumSulfide 9823 VALID -decomposition SodiumSulfite owner SodiumSulfite 8269 VALID -decomposition SolderingAlloy owner SolderingAlloy 8669 VALID -decomposition Soularium owner Soularium 8732 VALID -decomposition Sperrylite owner Sperrylite 9212 VALID -decomposition Spessartine owner Spessartine 9129 VALID -decomposition Sphalerite owner Sphalerite 9130 VALID -decomposition Spinel owner Spinel 8326 VALID -decomposition Spodumene owner Spodumene 9146 VALID -decomposition StainlessSteel owner StainlessSteel 8636 VALID -decomposition StannicChloride owner StannicChloride 8402 VALID -decomposition Stannite owner Stannite 9214 VALID -decomposition Steam owner Steam 9814 VALID -decomposition Steel owner Steel 8630 VALID -decomposition SteelGalvanized owner SteelGalvanized 8651 VALID -decomposition Steeleaf owner Steeleaf 8673 VALID -decomposition SterlingSilver owner SterlingSilver 8601 VALID -decomposition Stibnite owner Stibnite 9131 VALID -decomposition Stolzite owner Stolzite 9193 VALID -decomposition Sugar owner Sugar 9703 VALID -decomposition SulfurDioxide owner SulfurDioxide 9834 VALID -decomposition SulfurTrioxide owner SulfurTrioxide 9835 VALID -decomposition SulfuricAcid owner SulfuricAcid 9824 VALID -decomposition Sylvite owner Sylvite 8203 VALID -decomposition Talc owner Talc 9169 VALID -decomposition Tantalite owner Tantalite 9148 VALID -decomposition TantalumHafniumCarbide owner TantalumHafniumCarbide 8802 VALID -decomposition TantalumPentoxide owner TantalumPentoxide 8462 VALID -decomposition Tanzanite owner Tanzanite 8308 VALID -decomposition Terrasteel owner Terrasteel 8721 VALID -decomposition Tetrahedrite owner Tetrahedrite 9132 VALID -decomposition Thaumium owner Thaumium 8679 VALID -decomposition TigerEye owner TigerEye 8430 VALID -decomposition TigerIron owner TigerIron 8435 VALID -decomposition TinAlloy owner TinAlloy 8667 VALID -decomposition TitaniumIridium owner TitaniumIridium 8793 VALID -decomposition TitaniumTetrachloride owner TitaniumTetrachloride 8413 VALID -decomposition Topaz owner Topaz 8306 VALID -decomposition Trinaquadalloy owner Trinaquadalloy 8684 VALID -decomposition Trinitanium owner Trinitanium 8790 VALID -decomposition Tritanium owner Tritanium 8752 VALID -decomposition TritaniumDioxide owner TritaniumDioxide 9204 VALID -decomposition TritaniumHexaastatide owner TritaniumHexaastatide 9209 VALID -decomposition TritaniumHexabromide owner TritaniumHexabromide 9207 VALID -decomposition TritaniumHexachloride owner TritaniumHexachloride 9206 VALID -decomposition TritaniumHexafluoride owner TritaniumHexafluoride 9205 VALID -decomposition TritaniumHexaiodide owner TritaniumHexaiodide 9208 VALID -decomposition TritiatedWater owner TritiatedWater 9813 VALID -decomposition Trona owner Trona 9159 VALID -decomposition Tungstate owner Tungstate 9133 VALID -decomposition TungstenCarbide owner TungstenCarbide 8638 VALID -decomposition TungstenSintered owner TungstenSintered 8652 VALID -decomposition TungstenTrioxide owner TungstenTrioxide 8026 VALID -decomposition Tungstensteel owner Tungstensteel 8635 VALID -decomposition TungsticAcid owner TungsticAcid 8027 VALID -decomposition Ultimet owner Ultimet 8666 VALID -decomposition Uraninite owner Uraninite 9134 VALID -decomposition Uranium235Hexafluoride owner Uranium235Hexafluoride 9012 VALID -decomposition Uranium235Tetrafluoride owner Uranium235Tetrafluoride 9011 VALID -decomposition Uranium238Hexafluoride owner Uranium238Hexafluoride 9010 VALID -decomposition Uranium238Tetrafluoride owner Uranium238Tetrafluoride 9009 VALID -decomposition UraniumHexafluoride owner UraniumHexafluoride 9008 VALID -decomposition UraniumTetrafluoride owner UraniumTetrafluoride 9007 VALID -decomposition Uvarovite owner Uvarovite 9135 VALID -decomposition VanadiumGallium owner VanadiumGallium 8686 VALID -decomposition VanadiumMagnetite owner VanadiumMagnetite 9143 VALID -decomposition VanadiumPentoxide owner VanadiumPentoxide 8234 VALID -decomposition VanadiumSteel owner VanadiumSteel 8653 VALID -decomposition Vermiculite owner Vermiculite 9152 VALID -decomposition Vibramantium owner Vibramantium 8706 VALID -decomposition VibraniumSilver owner VibraniumSilver 8705 VALID -decomposition VibraniumSteel owner VibraniumSteel 8704 VALID -decomposition VibrantAlloy owner VibrantAlloy 8726 VALID -decomposition Vinteum owner Vinteum 8316 RETIRED -decomposition VinteumPurified owner VinteumPurified 8327 RETIRED -decomposition VitriolOfClay owner VitriolOfClay 8412 VALID -decomposition VoidCrystal owner VoidCrystal 8378 RETIRED -decomposition Water owner Water 9800 VALID -decomposition WaterDistilled owner WaterDistilled 9808 VALID -decomposition WhiteFluorite owner WhiteFluorite 8441 VALID -decomposition WhitePhosphorus owner WhitePhosphorus 8460 VALID -decomposition WhiteVitriol owner WhiteVitriol 8409 VALID -decomposition Wolframite owner Wolframite 9217 VALID -decomposition Wollastonite owner Wollastonite 9164 VALID -decomposition WroughtIron owner WroughtIron 8643 VALID -decomposition Wulfenite owner Wulfenite 9136 VALID -decomposition YellowAventurine owner YellowAventurine 8447 VALID -decomposition YellowDiamond owner YellowDiamond 8468 VALID -decomposition YellowFluorite owner YellowFluorite 8442 VALID -decomposition YellowJasper owner YellowJasper 8429 VALID -decomposition YellowLimonite owner YellowLimonite 9137 VALID -decomposition YellowSapphire owner YellowSapphire 8315 VALID -decomposition YttriumBariumCuprate owner YttriumBariumCuprate 8687 VALID -decomposition Zeolite owner Zeolite 9165 VALID -decomposition Zircon owner Zircon 8419 VALID -forms 10 owner 10 VALID -forms 100 owner 100 VALID -forms 1000 owner 1000 VALID -forms 1010 owner 1010 VALID -forms 1020 owner 1020 VALID -forms 1030 owner 1030 VALID -forms 1040 owner 1040 VALID -forms 1050 owner 1050 VALID -forms 1060 owner 1060 VALID -forms 1070 owner 1070 VALID -forms 1080 owner 1080 VALID -forms 1090 owner 1090 VALID -forms 11 owner 11 VALID -forms 110 owner 110 VALID -forms 1100 owner 1100 VALID -forms 1110 owner 1110 VALID -forms 1120 owner 1120 VALID -forms 1130 owner 1130 VALID -forms 1140 owner 1140 VALID -forms 1148 owner 1148 VALID -forms 1150 owner 1150 VALID -forms 1160 owner 1160 VALID -forms 1170 owner 1170 VALID -forms 1180 owner 1180 VALID -forms 12 owner 12 VALID -forms 120 owner 120 VALID -forms 1250 owner 1250 VALID -forms 1260 owner 1260 VALID -forms 130 owner 130 VALID -forms 140 owner 140 VALID -forms 1450 owner 1450 VALID -forms 150 owner 150 VALID -forms 1520 owner 1520 VALID -forms 160 owner 160 VALID -forms 170 owner 170 VALID -forms 1740 owner 1740 VALID -forms 1741 owner 1741 VALID -forms 1742 owner 1742 VALID -forms 180 owner 180 VALID -forms 190 owner 190 VALID -forms 20 owner 20 VALID -forms 200 owner 200 VALID -forms 21 owner 21 VALID -forms 210 owner 210 VALID -forms 220 owner 220 VALID -forms 2220 owner 2220 VALID -forms 230 owner 230 VALID -forms 240 owner 240 VALID -forms 250 owner 250 VALID -forms 260 owner 260 VALID -forms 270 owner 270 VALID -forms 278 owner 278 VALID -forms 280 owner 280 VALID -forms 290 owner 290 VALID -forms 30 owner 30 VALID -forms 300 owner 300 VALID -forms 31 owner 31 VALID -forms 310 owner 310 VALID -forms 320 owner 320 VALID -forms 330 owner 330 VALID -forms 340 owner 340 VALID -forms 350 owner 350 VALID -forms 360 owner 360 VALID -forms 370 owner 370 VALID -forms 3720 owner 3720 VALID -forms 380 owner 380 VALID -forms 390 owner 390 VALID -forms 40 owner 40 VALID -forms 400 owner 400 VALID -forms 41 owner 41 VALID -forms 410 owner 410 VALID -forms 42 owner 42 VALID -forms 420 owner 420 VALID -forms 430 owner 430 VALID -forms 440 owner 440 VALID -forms 450 owner 450 VALID -forms 460 owner 460 VALID -forms 470 owner 470 VALID -forms 480 owner 480 VALID -forms 490 owner 490 VALID -forms 50 owner 50 VALID -forms 500 owner 500 VALID -forms 51 owner 51 VALID -forms 510 owner 510 VALID -forms 520 owner 520 VALID -forms 530 owner 530 VALID -forms 540 owner 540 VALID -forms 550 owner 550 VALID -forms 560 owner 560 VALID -forms 570 owner 570 VALID -forms 580 owner 580 VALID -forms 590 owner 590 VALID -forms 60 owner 60 VALID -forms 600 owner 600 VALID -forms 61 owner 61 VALID -forms 610 owner 610 VALID -forms 62 owner 62 VALID -forms 620 owner 620 VALID -forms 630 owner 630 VALID -forms 640 owner 640 VALID -forms 650 owner 650 VALID -forms 660 owner 660 VALID -forms 670 owner 670 VALID -forms 680 owner 680 VALID -forms 690 owner 690 VALID -forms 70 owner 70 VALID -forms 700 owner 700 VALID -forms 710 owner 710 VALID -forms 720 owner 720 VALID -forms 730 owner 730 VALID -forms 740 owner 740 VALID -forms 750 owner 750 VALID -forms 760 owner 760 VALID -forms 770 owner 770 VALID -forms 780 owner 780 VALID -forms 790 owner 790 VALID -forms 791 owner 791 VALID -forms 80 owner 80 VALID -forms 800 owner 800 VALID -forms 8000 owner 8000 VALID -forms 8001 owner 8001 VALID -forms 8002 owner 8002 VALID -forms 8003 owner 8003 VALID -forms 8006 owner 8006 VALID -forms 8007 owner 8007 VALID -forms 8008 owner 8008 VALID -forms 8009 owner 8009 VALID -forms 8010 owner 8010 VALID -forms 8011 owner 8011 VALID -forms 8012 owner 8012 VALID -forms 8013 owner 8013 VALID -forms 8014 owner 8014 VALID -forms 8015 owner 8015 VALID -forms 8016 owner 8016 VALID -forms 8017 owner 8017 VALID -forms 8018 owner 8018 VALID -forms 8019 owner 8019 VALID -forms 8020 owner 8020 VALID -forms 8021 owner 8021 VALID -forms 8022 owner 8022 VALID -forms 8023 owner 8023 VALID -forms 8024 owner 8024 VALID -forms 8025 owner 8025 VALID -forms 8026 owner 8026 VALID -forms 8027 owner 8027 VALID -forms 8028 owner 8028 VALID -forms 8029 owner 8029 VALID -forms 8030 owner 8030 VALID -forms 8031 owner 8031 VALID -forms 8032 owner 8032 VALID -forms 8033 owner 8033 VALID -forms 8034 owner 8034 VALID -forms 8035 owner 8035 VALID -forms 8036 owner 8036 VALID -forms 8037 owner 8037 VALID -forms 8038 owner 8038 VALID -forms 8039 owner 8039 VALID -forms 810 owner 810 VALID -forms 8100 owner 8100 VALID -forms 8101 owner 8101 VALID -forms 8102 owner 8102 VALID -forms 8103 owner 8103 VALID -forms 8104 owner 8104 VALID -forms 8196 owner 8196 VALID -forms 8197 owner 8197 VALID -forms 820 owner 820 VALID -forms 8200 owner 8200 VALID -forms 8201 owner 8201 VALID -forms 8203 owner 8203 VALID -forms 8204 owner 8204 VALID -forms 8205 owner 8205 VALID -forms 8206 owner 8206 VALID -forms 8207 owner 8207 VALID -forms 8208 owner 8208 VALID -forms 8209 owner 8209 VALID -forms 8210 owner 8210 VALID -forms 8211 owner 8211 VALID -forms 8212 owner 8212 RETIRED -forms 8213 owner 8213 RETIRED -forms 8214 owner 8214 VALID -forms 8215 owner 8215 VALID -forms 8216 owner 8216 VALID -forms 8217 owner 8217 VALID -forms 8218 owner 8218 VALID -forms 8219 owner 8219 VALID -forms 8220 owner 8220 VALID -forms 8221 owner 8221 VALID -forms 8222 owner 8222 VALID -forms 8223 owner 8223 VALID -forms 8224 owner 8224 VALID -forms 8225 owner 8225 VALID -forms 8226 owner 8226 VALID -forms 8229 owner 8229 VALID -forms 8230 owner 8230 VALID -forms 8231 owner 8231 VALID -forms 8232 owner 8232 VALID -forms 8233 owner 8233 VALID -forms 8234 owner 8234 VALID -forms 8235 owner 8235 VALID -forms 8236 owner 8236 VALID -forms 8238 owner 8238 VALID -forms 8239 owner 8239 VALID -forms 8242 owner 8242 VALID -forms 8245 owner 8245 RETIRED -forms 8246 owner 8246 RETIRED -forms 8247 owner 8247 VALID -forms 8248 owner 8248 VALID -forms 8249 owner 8249 VALID -forms 8250 owner 8250 VALID -forms 8251 owner 8251 VALID -forms 8252 owner 8252 VALID -forms 8253 owner 8253 VALID -forms 8254 owner 8254 VALID -forms 8255 owner 8255 VALID -forms 8256 owner 8256 VALID -forms 8257 owner 8257 VALID -forms 8258 owner 8258 VALID -forms 8259 owner 8259 VALID -forms 8260 owner 8260 VALID -forms 8261 owner 8261 VALID -forms 8262 owner 8262 VALID -forms 8263 owner 8263 VALID -forms 8264 owner 8264 VALID -forms 8265 owner 8265 VALID -forms 8266 owner 8266 VALID -forms 8267 owner 8267 VALID -forms 8268 owner 8268 VALID -forms 8269 owner 8269 VALID -forms 8270 owner 8270 VALID -forms 8271 owner 8271 VALID -forms 8272 owner 8272 VALID -forms 8273 owner 8273 VALID -forms 8274 owner 8274 VALID -forms 8275 owner 8275 VALID -forms 8276 owner 8276 VALID -forms 8277 owner 8277 VALID -forms 8278 owner 8278 VALID -forms 8289 owner 8289 VALID -forms 8290 owner 8290 VALID -forms 8296 owner 8296 VALID -forms 8297 owner 8297 VALID -forms 8298 owner 8298 VALID -forms 8299 owner 8299 VALID -forms 830 owner 830 VALID -forms 8300 owner 8300 VALID -forms 8301 owner 8301 VALID -forms 8302 owner 8302 VALID -forms 8303 owner 8303 VALID -forms 8304 owner 8304 VALID -forms 8305 owner 8305 VALID -forms 8306 owner 8306 VALID -forms 8307 owner 8307 VALID -forms 8308 owner 8308 VALID -forms 8309 owner 8309 VALID -forms 8310 owner 8310 VALID -forms 8311 owner 8311 VALID -forms 8312 owner 8312 VALID -forms 8313 owner 8313 VALID -forms 8314 owner 8314 VALID -forms 8315 owner 8315 VALID -forms 8316 owner 8316 RETIRED -forms 8318 owner 8318 VALID -forms 8319 owner 8319 VALID -forms 8320 owner 8320 VALID -forms 8321 owner 8321 VALID -forms 8322 owner 8322 VALID -forms 8323 owner 8323 VALID -forms 8324 owner 8324 VALID -forms 8325 owner 8325 VALID -forms 8326 owner 8326 VALID -forms 8327 owner 8327 RETIRED -forms 8328 owner 8328 VALID -forms 8330 owner 8330 VALID -forms 8331 owner 8331 VALID -forms 8332 owner 8332 VALID -forms 8333 owner 8333 VALID -forms 8334 owner 8334 VALID -forms 8335 owner 8335 VALID -forms 8336 owner 8336 VALID -forms 8337 owner 8337 VALID -forms 8338 owner 8338 VALID -forms 8340 owner 8340 VALID -forms 8341 owner 8341 VALID -forms 8346 owner 8346 VALID -forms 8347 owner 8347 VALID -forms 8348 owner 8348 VALID -forms 8349 owner 8349 VALID -forms 8360 owner 8360 VALID -forms 8365 owner 8365 VALID -forms 8375 owner 8375 RETIRED -forms 8376 owner 8376 RETIRED -forms 8377 owner 8377 RETIRED -forms 8378 owner 8378 RETIRED -forms 8379 owner 8379 RETIRED -forms 8380 owner 8380 RETIRED -forms 8383 owner 8383 VALID -forms 8384 owner 8384 VALID -forms 8385 owner 8385 VALID -forms 8386 owner 8386 VALID -forms 8387 owner 8387 VALID -forms 8389 owner 8389 VALID -forms 8390 owner 8390 VALID -forms 8393 owner 8393 VALID -forms 8395 owner 8395 VALID -forms 8396 owner 8396 VALID -forms 8397 owner 8397 VALID -forms 8398 owner 8398 VALID -forms 8399 owner 8399 VALID -forms 840 owner 840 VALID -forms 8400 owner 8400 VALID -forms 8401 owner 8401 VALID -forms 8402 owner 8402 VALID -forms 8403 owner 8403 VALID -forms 8404 owner 8404 VALID -forms 8405 owner 8405 VALID -forms 8406 owner 8406 VALID -forms 8407 owner 8407 VALID -forms 8408 owner 8408 VALID -forms 8409 owner 8409 VALID -forms 8410 owner 8410 VALID -forms 8412 owner 8412 VALID -forms 8413 owner 8413 VALID -forms 8415 owner 8415 VALID -forms 8416 owner 8416 VALID -forms 8417 owner 8417 VALID -forms 8418 owner 8418 VALID -forms 8419 owner 8419 VALID -forms 8420 owner 8420 VALID -forms 8421 owner 8421 VALID -forms 8422 owner 8422 VALID -forms 8423 owner 8423 VALID -forms 8424 owner 8424 VALID -forms 8425 owner 8425 VALID -forms 8426 owner 8426 VALID -forms 8427 owner 8427 VALID -forms 8428 owner 8428 VALID -forms 8429 owner 8429 VALID -forms 8430 owner 8430 VALID -forms 8431 owner 8431 VALID -forms 8432 owner 8432 VALID -forms 8433 owner 8433 VALID -forms 8434 owner 8434 VALID -forms 8435 owner 8435 VALID -forms 8436 owner 8436 VALID -forms 8437 owner 8437 VALID -forms 8438 owner 8438 VALID -forms 8439 owner 8439 VALID -forms 8440 owner 8440 VALID -forms 8441 owner 8441 VALID -forms 8442 owner 8442 VALID -forms 8443 owner 8443 VALID -forms 8444 owner 8444 VALID -forms 8445 owner 8445 VALID -forms 8446 owner 8446 VALID -forms 8447 owner 8447 VALID -forms 8448 owner 8448 VALID -forms 8449 owner 8449 VALID -forms 8450 owner 8450 VALID -forms 8451 owner 8451 VALID -forms 8452 owner 8452 RETIRED -forms 8453 owner 8453 RETIRED -forms 8455 owner 8455 VALID -forms 8458 owner 8458 VALID -forms 8459 owner 8459 VALID -forms 8460 owner 8460 VALID -forms 8461 owner 8461 VALID -forms 8462 owner 8462 VALID -forms 8464 owner 8464 VALID -forms 8465 owner 8465 VALID -forms 8467 owner 8467 VALID -forms 8468 owner 8468 VALID -forms 8470 owner 8470 VALID -forms 8471 owner 8471 VALID -forms 850 owner 850 VALID -forms 8500 owner 8500 VALID -forms 8501 owner 8501 VALID -forms 8502 owner 8502 VALID -forms 8503 owner 8503 VALID -forms 8504 owner 8504 VALID -forms 8505 owner 8505 VALID -forms 8506 owner 8506 VALID -forms 8507 owner 8507 VALID -forms 8508 owner 8508 VALID -forms 8511 owner 8511 VALID -forms 8516 owner 8516 VALID -forms 8518 owner 8518 VALID -forms 8521 owner 8521 VALID -forms 8528 owner 8528 VALID -forms 8599 owner 8599 VALID -forms 860 owner 860 VALID -forms 8600 owner 8600 VALID -forms 8601 owner 8601 VALID -forms 8602 owner 8602 VALID -forms 8605 owner 8605 VALID -forms 8610 owner 8610 VALID -forms 8611 owner 8611 VALID -forms 8612 owner 8612 VALID -forms 8614 owner 8614 VALID -forms 8615 owner 8615 VALID -forms 8620 owner 8620 VALID -forms 8621 owner 8621 VALID -forms 8622 owner 8622 VALID -forms 8630 owner 8630 VALID -forms 8631 owner 8631 VALID -forms 8632 owner 8632 VALID -forms 8633 owner 8633 VALID -forms 8634 owner 8634 VALID -forms 8635 owner 8635 VALID -forms 8636 owner 8636 VALID -forms 8638 owner 8638 VALID -forms 8640 owner 8640 VALID -forms 8643 owner 8643 VALID -forms 8645 owner 8645 VALID -forms 8646 owner 8646 VALID -forms 8647 owner 8647 VALID -forms 8651 owner 8651 VALID -forms 8652 owner 8652 VALID -forms 8653 owner 8653 VALID -forms 8658 owner 8658 VALID -forms 8659 owner 8659 VALID -forms 8660 owner 8660 VALID -forms 8661 owner 8661 VALID -forms 8662 owner 8662 VALID -forms 8663 owner 8663 VALID -forms 8664 owner 8664 VALID -forms 8665 owner 8665 VALID -forms 8666 owner 8666 VALID -forms 8667 owner 8667 VALID -forms 8668 owner 8668 VALID -forms 8669 owner 8669 VALID -forms 8672 owner 8672 VALID -forms 8673 owner 8673 VALID -forms 8674 owner 8674 VALID -forms 8675 owner 8675 VALID -forms 8679 owner 8679 VALID -forms 8682 owner 8682 VALID -forms 8684 owner 8684 VALID -forms 8685 owner 8685 VALID -forms 8686 owner 8686 VALID -forms 8687 owner 8687 VALID -forms 8689 owner 8689 VALID -forms 8697 owner 8697 VALID -forms 8698 owner 8698 VALID -forms 870 owner 870 VALID -forms 8700 owner 8700 VALID -forms 8702 owner 8702 VALID -forms 8704 owner 8704 VALID -forms 8705 owner 8705 VALID -forms 8706 owner 8706 VALID -forms 8708 owner 8708 VALID -forms 8709 owner 8709 VALID -forms 8710 owner 8710 VALID -forms 8717 owner 8717 VALID -forms 8720 owner 8720 VALID -forms 8721 owner 8721 VALID -forms 8722 owner 8722 VALID -forms 8726 owner 8726 VALID -forms 8727 owner 8727 VALID -forms 8729 owner 8729 VALID -forms 8730 owner 8730 VALID -forms 8732 owner 8732 VALID -forms 8733 owner 8733 VALID -forms 8735 owner 8735 VALID -forms 8737 owner 8737 VALID -forms 8744 owner 8744 VALID -forms 8745 owner 8745 VALID -forms 8746 owner 8746 VALID -forms 8751 owner 8751 VALID -forms 8752 owner 8752 VALID -forms 8756 owner 8756 VALID -forms 8784 owner 8784 VALID -forms 8790 owner 8790 VALID -forms 8791 owner 8791 VALID -forms 8792 owner 8792 VALID -forms 8795 owner 8795 RETIRED -forms 8796 owner 8796 VALID -forms 8797 owner 8797 VALID -forms 8798 owner 8798 VALID -forms 8799 owner 8799 VALID -forms 880 owner 880 VALID -forms 8800 owner 8800 VALID -forms 8801 owner 8801 VALID -forms 8802 owner 8802 VALID -forms 8803 owner 8803 VALID -forms 8805 owner 8805 RETIRED -forms 8813 owner 8813 RETIRED -forms 890 owner 890 VALID -forms 90 owner 90 VALID -forms 900 owner 900 VALID -forms 9000 owner 9000 VALID -forms 9001 owner 9001 VALID -forms 9003 owner 9003 VALID -forms 9004 owner 9004 VALID -forms 9005 owner 9005 VALID -forms 9006 owner 9006 VALID -forms 9007 owner 9007 VALID -forms 9008 owner 9008 VALID -forms 9009 owner 9009 VALID -forms 9010 owner 9010 VALID -forms 9011 owner 9011 VALID -forms 9012 owner 9012 VALID -forms 910 owner 910 VALID -forms 9100 owner 9100 VALID -forms 9101 owner 9101 VALID -forms 9102 owner 9102 VALID -forms 9103 owner 9103 VALID -forms 9104 owner 9104 VALID -forms 9105 owner 9105 VALID -forms 9106 owner 9106 VALID -forms 9107 owner 9107 VALID -forms 9108 owner 9108 VALID -forms 9109 owner 9109 VALID -forms 9110 owner 9110 VALID -forms 9111 owner 9111 VALID -forms 9113 owner 9113 VALID -forms 9114 owner 9114 VALID -forms 9115 owner 9115 VALID -forms 9116 owner 9116 VALID -forms 9117 owner 9117 VALID -forms 9118 owner 9118 VALID -forms 9119 owner 9119 VALID -forms 9120 owner 9120 VALID -forms 9122 owner 9122 VALID -forms 9123 owner 9123 VALID -forms 9124 owner 9124 VALID -forms 9125 owner 9125 VALID -forms 9126 owner 9126 VALID -forms 9127 owner 9127 VALID -forms 9128 owner 9128 VALID -forms 9129 owner 9129 VALID -forms 9130 owner 9130 VALID -forms 9131 owner 9131 VALID -forms 9132 owner 9132 VALID -forms 9133 owner 9133 VALID -forms 9134 owner 9134 VALID -forms 9135 owner 9135 VALID -forms 9136 owner 9136 VALID -forms 9137 owner 9137 VALID -forms 9138 owner 9138 VALID -forms 9139 owner 9139 VALID -forms 9140 owner 9140 VALID -forms 9141 owner 9141 VALID -forms 9143 owner 9143 VALID -forms 9144 owner 9144 VALID -forms 9145 owner 9145 VALID -forms 9146 owner 9146 VALID -forms 9147 owner 9147 VALID -forms 9148 owner 9148 VALID -forms 9149 owner 9149 VALID -forms 9150 owner 9150 VALID -forms 9152 owner 9152 VALID -forms 9153 owner 9153 VALID -forms 9154 owner 9154 VALID -forms 9155 owner 9155 VALID -forms 9156 owner 9156 VALID -forms 9157 owner 9157 VALID -forms 9158 owner 9158 VALID -forms 9159 owner 9159 VALID -forms 9160 owner 9160 VALID -forms 9161 owner 9161 VALID -forms 9162 owner 9162 VALID -forms 9164 owner 9164 VALID -forms 9165 owner 9165 VALID -forms 9166 owner 9166 VALID -forms 9167 owner 9167 VALID -forms 9169 owner 9169 VALID -forms 9171 owner 9171 VALID -forms 9174 owner 9174 VALID -forms 9175 owner 9175 VALID -forms 9177 owner 9177 VALID -forms 9180 owner 9180 VALID -forms 9184 owner 9184 VALID -forms 9185 owner 9185 VALID -forms 9186 owner 9186 VALID -forms 9187 owner 9187 VALID -forms 9188 owner 9188 VALID -forms 9189 owner 9189 VALID -forms 9190 owner 9190 VALID -forms 9192 owner 9192 VALID -forms 9193 owner 9193 VALID -forms 9194 owner 9194 VALID -forms 9195 owner 9195 VALID -forms 9196 owner 9196 VALID -forms 9197 owner 9197 VALID -forms 9198 owner 9198 VALID -forms 9199 owner 9199 VALID -forms 920 owner 920 VALID -forms 9200 owner 9200 VALID -forms 9201 owner 9201 VALID -forms 9202 owner 9202 VALID -forms 9203 owner 9203 VALID -forms 9204 owner 9204 VALID -forms 9205 owner 9205 VALID -forms 9206 owner 9206 VALID -forms 9207 owner 9207 VALID -forms 9208 owner 9208 VALID -forms 9209 owner 9209 VALID -forms 921 owner 921 VALID -forms 9210 owner 9210 VALID -forms 9211 owner 9211 VALID -forms 9212 owner 9212 VALID -forms 9213 owner 9213 VALID -forms 9214 owner 9214 VALID -forms 9215 owner 9215 VALID -forms 9216 owner 9216 VALID -forms 9217 owner 9217 VALID -forms 9218 owner 9218 VALID -forms 9219 owner 9219 VALID -forms 922 owner 922 VALID -forms 9220 owner 9220 VALID -forms 9221 owner 9221 VALID -forms 9222 owner 9222 VALID -forms 9223 owner 9223 VALID -forms 9224 owner 9224 RETIRED -forms 9225 owner 9225 RETIRED -forms 9226 owner 9226 RETIRED -forms 9228 owner 9228 RETIRED -forms 9239 owner 9239 RETIRED -forms 9246 owner 9246 VALID -forms 9247 owner 9247 VALID -forms 9248 owner 9248 VALID -forms 9261 owner 9261 VALID -forms 9271 owner 9271 VALID -forms 930 owner 930 VALID -forms 9300 owner 9300 VALID -forms 9301 owner 9301 VALID -forms 9302 owner 9302 VALID -forms 9303 owner 9303 VALID -forms 9304 owner 9304 VALID -forms 9305 owner 9305 VALID -forms 9306 owner 9306 VALID -forms 9307 owner 9307 VALID -forms 9308 owner 9308 VALID -forms 9309 owner 9309 VALID -forms 9310 owner 9310 VALID -forms 9311 owner 9311 VALID -forms 9312 owner 9312 VALID -forms 9313 owner 9313 VALID -forms 9314 owner 9314 VALID -forms 9315 owner 9315 VALID -forms 9316 owner 9316 VALID -forms 9317 owner 9317 VALID -forms 9318 owner 9318 VALID -forms 9319 owner 9319 VALID -forms 9344 owner 9344 VALID -forms 9372 owner 9372 VALID -forms 940 owner 940 VALID -forms 9409 owner 9409 VALID -forms 942 owner 942 VALID -forms 943 owner 943 VALID -forms 945 owner 945 VALID -forms 946 owner 946 VALID -forms 947 owner 947 VALID -forms 950 owner 950 VALID -forms 951 owner 951 VALID -forms 952 owner 952 VALID -forms 960 owner 960 VALID -forms 970 owner 970 VALID -forms 9700 owner 9700 VALID -forms 9701 owner 9701 VALID -forms 9702 owner 9702 VALID -forms 9703 owner 9703 VALID -forms 9705 owner 9705 VALID -forms 9709 owner 9709 VALID -forms 9710 owner 9710 VALID -forms 9711 owner 9711 VALID -forms 9712 owner 9712 VALID -forms 9713 owner 9713 VALID -forms 9779 owner 9779 VALID -forms 9780 owner 9780 VALID -forms 9781 owner 9781 VALID -forms 9782 owner 9782 VALID -forms 9783 owner 9783 VALID -forms 9784 owner 9784 VALID -forms 9785 owner 9785 VALID -forms 9790 owner 9790 VALID -forms 9791 owner 9791 VALID -forms 9792 owner 9792 VALID -forms 9793 owner 9793 VALID -forms 9794 owner 9794 VALID -forms 9796 owner 9796 VALID -forms 980 owner 980 VALID -forms 9800 owner 9800 VALID -forms 9801 owner 9801 VALID -forms 9802 owner 9802 VALID -forms 9803 owner 9803 VALID -forms 9804 owner 9804 VALID -forms 9805 owner 9805 VALID -forms 9806 owner 9806 VALID -forms 9808 owner 9808 VALID -forms 9809 owner 9809 VALID -forms 9810 owner 9810 VALID -forms 9811 owner 9811 VALID -forms 9812 owner 9812 VALID -forms 9813 owner 9813 VALID -forms 9814 owner 9814 VALID -forms 9815 owner 9815 VALID -forms 9820 owner 9820 VALID -forms 9821 owner 9821 VALID -forms 9822 owner 9822 VALID -forms 9823 owner 9823 VALID -forms 9824 owner 9824 VALID -forms 9825 owner 9825 VALID -forms 9826 owner 9826 VALID -forms 9827 owner 9827 VALID -forms 9828 owner 9828 VALID -forms 9829 owner 9829 VALID -forms 9830 owner 9830 VALID -forms 9831 owner 9831 VALID -forms 9832 owner 9832 VALID -forms 9833 owner 9833 VALID -forms 9834 owner 9834 VALID -forms 9835 owner 9835 VALID -forms 9836 owner 9836 VALID -forms 9837 owner 9837 VALID -forms 9838 owner 9838 VALID -forms 9839 owner 9839 VALID -forms 9840 owner 9840 VALID -forms 9841 owner 9841 VALID -forms 9842 owner 9842 VALID -forms 9843 owner 9843 VALID -forms 9844 owner 9844 VALID -forms 9850 owner 9850 VALID -forms 9851 owner 9851 VALID -forms 9852 owner 9852 VALID -forms 9853 owner 9853 VALID -forms 9860 owner 9860 VALID -forms 9861 owner 9861 VALID -forms 9862 owner 9862 VALID -forms 9863 owner 9863 VALID -forms 9864 owner 9864 VALID -forms 9865 owner 9865 VALID -forms 9866 owner 9866 VALID -forms 9867 owner 9867 VALID -forms 9868 owner 9868 VALID -forms 9870 owner 9870 VALID -forms 9871 owner 9871 VALID -forms 9872 owner 9872 VALID -forms 9873 owner 9873 VALID -forms 9874 owner 9874 VALID -forms 9875 owner 9875 VALID -forms 9876 owner 9876 VALID -forms 9877 owner 9877 VALID -forms 9880 owner 9880 VALID -forms 9881 owner 9881 VALID -forms 9882 owner 9882 VALID -forms 9883 owner 9883 VALID -forms 9884 owner 9884 RETIRED -forms 9885 owner 9885 RETIRED -forms 9886 owner 9886 VALID -forms 990 owner 990 VALID -forms ac owner ac 0 ALIAS -forms acacia owner acacia 0 ALIAS -forms ad owner ad 0 ALIAS -forms adamantine owner adamantine 0 ALIAS -forms adamite owner adamite 0 RETIRED -forms adluorite owner adluorite 0 RETIRED -forms advancedalloy owner advancedalloy 0 RETIRED -forms ag owner ag 0 ALIAS -forms agate owner agate 0 RETIRED -forms air owner air 0 ALIAS -forms al owner al 0 ALIAS -forms al2o3 owner al2o3 0 ALIAS -forms alf3 owner alf3 0 ALIAS -forms almandine owner almandine 0 ALIAS -forms alo3h3 owner alo3h3 0 ALIAS -forms aluminiumalloy owner aluminiumalloy 0 ALIAS -forms aluminiumbrass owner aluminiumbrass 0 ALIAS -forms alumite owner alumite 0 ALIAS -forms alunite owner alunite 0 ALIAS -forms am owner am 0 ALIAS -forms am241 owner am241 0 ALIAS -forms am242 owner am242 0 ALIAS -forms amazonite owner amazonite 0 ALIAS -forms amber owner amber 0 ALIAS -forms amberdominican owner amberdominican 0 ALIAS -forms amethyst owner amethyst 0 ALIAS -forms ametrine owner ametrine 0 RETIRED -forms ammonium owner ammonium 0 RETIRED -forms ancientdebris owner ancientdebris 0 ALIAS -forms andesite owner andesite 0 ALIAS -forms andradite owner andradite 0 ALIAS -forms angelite owner angelite 0 RETIRED -forms annealedcopper owner annealedcopper 0 ALIAS -forms apatite owner apatite 0 ALIAS -forms aquamarine owner aquamarine 0 ALIAS -forms aquaregia owner aquaregia 0 ALIAS -forms ar owner ar 0 ALIAS -forms arsenicbronze owner arsenicbronze 0 ALIAS -forms arseniccopper owner arseniccopper 0 ALIAS -forms arsenopyrite owner arsenopyrite 0 ALIAS -forms as owner as 0 ALIAS -forms asbestos owner asbestos 0 ALIAS -forms ash owner ash 0 ALIAS -forms asphalt owner asphalt 0 ALIAS -forms at owner at 0 ALIAS -forms au owner au 0 ALIAS -forms au198 owner au198 0 ALIAS -forms australium owner australium 0 RETIRED -forms aventurineblack owner aventurineblack 0 ALIAS -forms aventurineblue owner aventurineblue 0 ALIAS -forms aventurinebrown owner aventurinebrown 0 ALIAS -forms aventurinegreen owner aventurinegreen 0 ALIAS -forms aventurinered owner aventurinered 0 ALIAS -forms aventurineyellow owner aventurineyellow 0 ALIAS -forms azurite owner azurite 0 ALIAS -forms b owner b 0 ALIAS -forms b11 owner b11 0 ALIAS -forms ba owner ba 0 ALIAS -forms balasruby owner balasruby 0 ALIAS -forms bamboo owner bamboo 0 ALIAS -forms barite owner barite 0 ALIAS -forms bark owner bark 0 ALIAS -forms basalt owner basalt 0 ALIAS -forms basalticmineralsand owner basalticmineralsand 0 ALIAS -forms basalz owner basalz 0 ALIAS -forms basanite owner basanite 0 RETIRED -forms bastnasite owner bastnasite 0 ALIAS -forms batteryalloy owner batteryalloy 0 ALIAS -forms bauxite owner bauxite 0 ALIAS -forms be owner be 0 ALIAS -forms be7 owner be7 0 ALIAS -forms be8 owner be8 0 ALIAS -forms bedrock owner bedrock 0 ALIAS -forms bentonite owner bentonite 0 ALIAS -forms bh owner bh 0 ALIAS -forms bi owner bi 0 ALIAS -forms biofuel owner biofuel 0 ALIAS -forms biomass owner biomass 0 ALIAS -forms biotite owner biotite 0 ALIAS -forms birch owner birch 0 ALIAS -forms bischofite owner bischofite 0 ALIAS -forms bismuthbronze owner bismuthbronze 0 ALIAS -forms bitumen owner bitumen 0 RETIRED -forms bixbite owner bixbite 0 ALIAS -forms bk owner bk 0 ALIAS -forms black owner black 0 ALIAS -forms blackberyl owner blackberyl 0 RETIRED -forms blackbronze owner blackbronze 0 ALIAS -forms blacksteel owner blacksteel 0 ALIAS -forms blackstone owner blackstone 0 ALIAS -forms blackvitriol owner blackvitriol 0 ALIAS -forms blaze owner blaze 0 ALIAS -forms blazequartz owner blazequartz 0 ALIAS -forms blitz owner blitz 0 ALIAS -forms blizz owner blizz 0 ALIAS -forms bloodstone owner bloodstone 0 RETIRED -forms blue owner blue 0 ALIAS -forms bluealloy owner bluealloy 0 ALIAS -forms bluemahoe owner bluemahoe 0 ALIAS -forms bluesapphire owner bluesapphire 0 ALIAS -forms blueschist owner blueschist 0 ALIAS -forms bluespruce owner bluespruce 0 ALIAS -forms bluesteel owner bluesteel 0 ALIAS -forms bluestone owner bluestone 0 ALIAS -forms bluetopaz owner bluetopaz 0 ALIAS -forms bluevitriol owner bluevitriol 0 ALIAS -forms bone owner bone 0 ALIAS -forms borax owner borax 0 ALIAS -forms br owner br 0 ALIAS -forms brass owner brass 0 ALIAS -forms breeze owner breeze 0 ALIAS -forms bromargyrite owner bromargyrite 0 ALIAS -forms bronze owner bronze 0 ALIAS -forms brown owner brown 0 ALIAS -forms brownlimonite owner brownlimonite 0 ALIAS -forms butane owner butane 0 ALIAS -forms c owner c 0 ALIAS -forms c13 owner c13 0 ALIAS -forms c14 owner c14 0 ALIAS -forms ca owner ca 0 ALIAS -forms cacl2 owner cacl2 0 ALIAS -forms caco3 owner caco3 0 ALIAS -forms caf2 owner caf2 0 ALIAS -forms carminite owner carminite 0 ALIAS -forms carnelian owner carnelian 0 RETIRED -forms caso4 owner caso4 0 ALIAS -forms cassiterite owner cassiterite 0 ALIAS -forms cd owner cd 0 ALIAS -forms cdinagalloy owner cdinagalloy 0 ALIAS -forms ce owner ce 0 ALIAS -forms celestine owner celestine 0 ALIAS -forms ceramic owner ceramic 0 ALIAS -forms certusquartz owner certusquartz 0 ALIAS -forms cf owner cf 0 ALIAS -forms ch4 owner ch4 0 ALIAS -forms chalcopyrite owner chalcopyrite 0 ALIAS -forms chalk owner chalk 0 RETIRED -forms charcoal owner charcoal 0 ALIAS -forms chargedcertusquartz owner chargedcertusquartz 0 ALIAS -forms charoite owner charoite 0 RETIRED -forms cheese owner cheese 0 ALIAS -forms cherry owner cherry 0 ALIAS -forms chert owner chert 0 ALIAS -forms chestnut owner chestnut 0 RETIRED -forms chili owner chili 0 ALIAS -forms chloroauricacid owner chloroauricacid 0 ALIAS -forms chloroplatinicacid owner chloroplatinicacid 0 ALIAS -forms chocolate owner chocolate 0 ALIAS -forms chromite owner chromite 0 ALIAS -forms chromiumdioxide owner chromiumdioxide 0 ALIAS -forms chrysocolla owner chrysocolla 0 RETIRED -forms chrysoprase owner chrysoprase 0 RETIRED -forms cinnabar owner cinnabar 0 ALIAS -forms cinnamon owner cinnamon 0 ALIAS -forms citrine owner citrine 0 RETIRED -forms citrus owner citrus 0 RETIRED -forms cl owner cl 0 ALIAS -forms clay owner clay 0 ALIAS -forms claybrown owner claybrown 0 ALIAS -forms clayred owner clayred 0 ALIAS -forms cm owner cm 0 ALIAS -forms cmbsteel owner cmbsteel 0 RETIRED -forms cn owner cn 0 ALIAS -forms co2 owner co2 0 ALIAS -forms co3 owner co3 0 ALIAS -forms co60 owner co60 0 ALIAS -forms coal owner coal 0 ALIAS -forms coalcoke owner coalcoke 0 ALIAS -forms cobaltbrass owner cobaltbrass 0 ALIAS -forms cobalthexahydrate owner cobalthexahydrate 0 ALIAS -forms cobaltite owner cobaltite 0 ALIAS -forms cocoa owner cocoa 0 ALIAS -forms coconut owner coconut 0 ALIAS -forms coffee owner coffee 0 ALIAS -forms coltan owner coltan 0 ALIAS -forms columbite owner columbite 0 ALIAS -forms compressed owner compressed 0 ALIAS -forms concrete owner concrete 0 ALIAS -forms conductiveiron owner conductiveiron 0 ALIAS -forms constantan owner constantan 0 ALIAS -forms constructionfoam owner constructionfoam 0 ALIAS -forms cooperite owner cooperite 0 ALIAS -forms coral owner coral 0 RETIRED -forms cosmicneutronium owner cosmicneutronium 0 ALIAS -forms cr owner cr 0 ALIAS -forms craponite owner craponite 0 ALIAS -forms creosote owner creosote 0 ALIAS -forms crimson owner crimson 0 ALIAS -forms crudeoil owner crudeoil 0 ALIAS -forms crystalflux owner crystalflux 0 RETIRED -forms crystalmatrix owner crystalmatrix 0 ALIAS -forms cs owner cs 0 ALIAS -forms cu owner cu 0 ALIAS -forms cyan owner cyan 0 ALIAS -forms cyanite owner cyanite 0 ALIAS -forms cyanvitriol owner cyanvitriol 0 ALIAS -forms d owner d 0 ALIAS -forms d2o owner d2o 0 ALIAS -forms dacite owner dacite 0 ALIAS -forms daffergon owner daffergon 0 RETIRED -forms damascussteel owner damascussteel 0 ALIAS -forms darkash owner darkash 0 ALIAS -forms darkoak owner darkoak 0 ALIAS -forms darkstone owner darkstone 0 RETIRED -forms datolite owner datolite 0 ALIAS -forms db owner db 0 ALIAS -forms dead owner dead 0 ALIAS -forms deepslate owner deepslate 0 ALIAS -forms demonite owner demonite 0 RETIRED -forms diamantine owner diamantine 0 RETIRED -forms diamond owner diamond 0 ALIAS -forms diamondblue owner diamondblue 0 ALIAS -forms diamondgreen owner diamondgreen 0 ALIAS -forms diamondindustrial owner diamondindustrial 0 ALIAS -forms diamondpink owner diamondpink 0 ALIAS -forms diamondred owner diamondred 0 ALIAS -forms diamondyellow owner diamondyellow 0 ALIAS -forms diatomite owner diatomite 0 ALIAS -forms diduraniumtrioxide owner diduraniumtrioxide 0 ALIAS -forms diesel owner diesel 0 ALIAS -forms dineutronium owner dineutronium 0 RETIRED -forms dioptase owner dioptase 0 ALIAS -forms diorite owner diorite 0 ALIAS -forms distwater owner distwater 0 ALIAS -forms dn owner dn 0 ALIAS -forms dolomite owner dolomite 0 RETIRED -forms draconic owner draconic 0 RETIRED -forms draconium owner draconium 0 ALIAS -forms draconiumawakened owner draconiumawakened 0 ALIAS -forms dreamwood owner dreamwood 0 ALIAS -forms ds owner ds 0 ALIAS -forms dumortierite owner dumortierite 0 RETIRED -forms duralumin owner duralumin 0 ALIAS -forms duraniumalloy owner duraniumalloy 0 ALIAS -forms duraniumhexaastatide owner duraniumhexaastatide 0 ALIAS -forms duraniumhexabromide owner duraniumhexabromide 0 ALIAS -forms duraniumhexachloride owner duraniumhexachloride 0 ALIAS -forms duraniumhexafluoride owner duraniumhexafluoride 0 ALIAS -forms duraniumhexaiodide owner duraniumhexaiodide 0 ALIAS -forms durasteel owner durasteel 0 RETIRED -forms dy owner dy 0 ALIAS -forms dynamite owner dynamite 0 ALIAS -forms efrine owner efrine 0 ALIAS -forms elder owner elder 0 RETIRED -forms electricalsteel owner electricalsteel 0 ALIAS -forms electrotinealloy owner electrotinealloy 0 ALIAS -forms electrum owner electrum 0 ALIAS -forms elvenelementium owner elvenelementium 0 ALIAS -forms elvenquartz owner elvenquartz 0 ALIAS -forms emeradic owner emeradic 0 RETIRED -forms emerald owner emerald 0 ALIAS -forms empty owner empty 0 ALIAS -forms endereye owner endereye 0 ALIAS -forms enderium owner enderium 0 ALIAS -forms enderiumbase owner enderiumbase 0 ALIAS -forms enderpearl owner enderpearl 0 ALIAS -forms endstone owner endstone 0 ALIAS -forms energiumcyan owner energiumcyan 0 ALIAS -forms energiumred owner energiumred 0 ALIAS -forms enori owner enori 0 RETIRED -forms er owner er 0 ALIAS -forms es owner es 0 ALIAS -forms ethanol owner ethanol 0 ALIAS -forms ethylene owner ethylene 0 ALIAS -forms eu owner eu 0 ALIAS -forms eudialyte owner eudialyte 0 ALIAS -forms euphemium owner euphemium 0 RETIRED -forms f owner f 0 ALIAS -forms fa owner fa 0 ALIAS -forms fe owner fe 0 ALIAS -forms fe2o3 owner fe2o3 0 ALIAS -forms fecl2 owner fecl2 0 ALIAS -forms fecl3 owner fecl3 0 ALIAS -forms feo3h3 owner feo3h3 0 ALIAS -forms ferberite owner ferberite 0 ALIAS -forms ferrovanadium owner ferrovanadium 0 ALIAS -forms fierysteel owner fierysteel 0 ALIAS -forms fig owner fig 0 RETIRED -forms fireleaf owner fireleaf 0 ALIAS -forms firestone owner firestone 0 ALIAS -forms fishcooked owner fishcooked 0 ALIAS -forms fishoil owner fishoil 0 ALIAS -forms fishraw owner fishraw 0 ALIAS -forms fishrotten owner fishrotten 0 ALIAS -forms fl owner fl 0 ALIAS -forms fl298 owner fl298 0 ALIAS -forms flamascussteel owner flamascussteel 0 ALIAS -forms flint owner flint 0 ALIAS -forms fluix owner fluix 0 ALIAS -forms fluoriteblack owner fluoriteblack 0 ALIAS -forms fluoriteblue owner fluoriteblue 0 ALIAS -forms fluoritegreen owner fluoritegreen 0 ALIAS -forms fluoritemagenta owner fluoritemagenta 0 ALIAS -forms fluoriteorange owner fluoriteorange 0 ALIAS -forms fluoritepink owner fluoritepink 0 ALIAS -forms fluoritered owner fluoritered 0 ALIAS -forms fluoritewhite owner fluoritewhite 0 ALIAS -forms fluoriteyellow owner fluoriteyellow 0 ALIAS -forms fm owner fm 0 ALIAS -forms fr owner fr 0 ALIAS -forms freshwater owner freshwater 0 ALIAS -forms frozen owner frozen 0 ALIAS -forms fryingoilhot owner fryingoilhot 0 ALIAS -forms fuel owner fuel 0 ALIAS -forms ga owner ga 0 ALIAS -forms gabbro owner gabbro 0 RETIRED -forms gaiaspirit owner gaiaspirit 0 ALIAS -forms galena owner galena 0 ALIAS -forms garnetsand owner garnetsand 0 ALIAS -forms garnierite owner garnierite 0 ALIAS -forms gd owner gd 0 ALIAS -forms ge owner ge 0 ALIAS -forms glass owner glass 0 ALIAS -forms glauconite owner glauconite 0 ALIAS -forms glowstone owner glowstone 0 ALIAS -forms glue owner glue 0 ALIAS -forms glycerol owner glycerol 0 ALIAS -forms glyceryl owner glyceryl 0 ALIAS -forms gneiss owner gneiss 0 RETIRED -forms goshenite owner goshenite 0 ALIAS -forms granite owner granite 0 ALIAS -forms graniteblack owner graniteblack 0 ALIAS -forms granitered owner granitered 0 ALIAS -forms graniticmineralsand owner graniticmineralsand 0 ALIAS -forms graphene owner graphene 0 ALIAS -forms graphite owner graphite 0 ALIAS -forms gray owner gray 0 ALIAS -forms grayvitriol owner grayvitriol 0 ALIAS -forms greatwood owner greatwood 0 ALIAS -forms green owner green 0 ALIAS -forms greensapphire owner greensapphire 0 ALIAS -forms greenschist owner greenschist 0 ALIAS -forms greenvitriol owner greenvitriol 0 ALIAS -forms grossular owner grossular 0 ALIAS -forms gt owner gt 0 ALIAS -forms gunpowder owner gunpowder 0 ALIAS -forms gypsum owner gypsum 0 ALIAS -forms h owner h 0 ALIAS -forms h2o owner h2o 0 ALIAS -forms h2o2 owner h2o2 0 ALIAS -forms h2s owner h2s 0 ALIAS -forms h2s2o7 owner h2s2o7 0 ALIAS -forms h2sif6 owner h2sif6 0 ALIAS -forms h2so4 owner h2so4 0 ALIAS -forms h2wo4 owner h2wo4 0 ALIAS -forms h3bo3 owner h3bo3 0 ALIAS -forms hazel owner hazel 0 ALIAS -forms hazelnut owner hazelnut 0 ALIAS -forms hcl owner hcl 0 ALIAS -forms hdo owner hdo 0 ALIAS -forms he owner he 0 ALIAS -forms he3 owner he3 0 ALIAS -forms heliodor owner heliodor 0 ALIAS -forms hempoil owner hempoil 0 ALIAS -forms hene owner hene 0 ALIAS -forms hexoriumblack owner hexoriumblack 0 RETIRED -forms hexoriumblue owner hexoriumblue 0 RETIRED -forms hexoriumgreen owner hexoriumgreen 0 RETIRED -forms hexoriumred owner hexoriumred 0 RETIRED -forms hexoriumwhite owner hexoriumwhite 0 RETIRED -forms hg owner hg 0 ALIAS -forms hno3 owner hno3 0 ALIAS -forms ho owner ho 0 ALIAS -forms holywater owner holywater 0 ALIAS -forms honey owner honey 0 ALIAS -forms honeydew owner honeydew 0 ALIAS -forms hs owner hs 0 ALIAS -forms hsse owner hsse 0 ALIAS -forms hssg owner hssg 0 ALIAS -forms hsss owner hsss 0 ALIAS -forms huebnerite owner huebnerite 0 ALIAS -forms hydratedcoal owner hydratedcoal 0 ALIAS -forms i owner i 0 ALIAS -forms ice owner ice 0 ALIAS -forms ilmenite owner ilmenite 0 ALIAS -forms in owner in 0 ALIAS -forms infinity owner infinity 0 ALIAS -forms infusedgold owner infusedgold 0 RETIRED -forms invar owner invar 0 ALIAS -forms invisium owner invisium 0 RETIRED -forms ir owner ir 0 ALIAS -forms iridiron owner iridiron 0 RETIRED -forms iridironreinforced owner iridironreinforced 0 RETIRED -forms iritanium owner iritanium 0 ALIAS -forms ironcast owner ironcast 0 ALIAS -forms ironmagnetic owner ironmagnetic 0 ALIAS -forms ironsharp owner ironsharp 0 RETIRED -forms ironwood owner ironwood 0 ALIAS -forms irridantreinforced owner irridantreinforced 0 RETIRED -forms irridanturanium owner irridanturanium 0 RETIRED -forms jade owner jade 0 ALIAS -forms jasper owner jasper 0 ALIAS -forms jasperblue owner jasperblue 0 ALIAS -forms jaspergreen owner jaspergreen 0 ALIAS -forms jasperocean owner jasperocean 0 ALIAS -forms jasperrainforest owner jasperrainforest 0 ALIAS -forms jasperyellow owner jasperyellow 0 ALIAS -forms jet owner jet 0 RETIRED -forms jungle owner jungle 0 ALIAS -forms k owner k 0 ALIAS -forms k2co3 owner k2co3 0 ALIAS -forms k2s owner k2s 0 ALIAS -forms k2s2o7 owner k2s2o7 0 ALIAS -forms k2so3 owner k2so3 0 ALIAS -forms k2so4 owner k2so4 0 ALIAS -forms k2taf7 owner k2taf7 0 ALIAS -forms kalo2 owner kalo2 0 ALIAS -forms kanthal owner kanthal 0 ALIAS -forms kaolinite owner kaolinite 0 ALIAS -forms kcl owner kcl 0 ALIAS -forms ke owner ke 0 ALIAS -forms kerosine owner kerosine 0 ALIAS -forms kesterite owner kesterite 0 ALIAS -forms kf owner kf 0 ALIAS -forms khso4 owner khso4 0 ALIAS -forms kimberlite owner kimberlite 0 ALIAS -forms kio3 owner kio3 0 ALIAS -forms knightmetal owner knightmetal 0 ALIAS -forms kno3 owner kno3 0 ALIAS -forms koh owner koh 0 ALIAS -forms komatiite owner komatiite 0 ALIAS -forms kr owner kr 0 ALIAS -forms kso4 owner kso4 0 ALIAS -forms kunzite owner kunzite 0 RETIRED -forms kyanite owner kyanite 0 ALIAS -forms la owner la 0 ALIAS -forms labradorite owner labradorite 0 RETIRED -forms lapis owner lapis 0 ALIAS -forms lapislazuli owner lapislazuli 0 RETIRED -forms larimar owner larimar 0 RETIRED -forms latex owner latex 0 ALIAS -forms lava owner lava 0 ALIAS -forms lazurite owner lazurite 0 ALIAS -forms lepidolite owner lepidolite 0 ALIAS -forms li owner li 0 ALIAS -forms li6 owner li6 0 ALIAS -forms licl owner licl 0 ALIAS -forms liclo3 owner liclo3 0 ALIAS -forms liclo4 owner liclo4 0 ALIAS -forms lightblue owner lightblue 0 ALIAS -forms lightgray owner lightgray 0 ALIAS -forms lignite owner lignite 0 ALIAS -forms lignitecoke owner lignitecoke 0 ALIAS -forms lime owner lime 0 ALIAS -forms limestone owner limestone 0 ALIAS -forms linoil owner linoil 0 ALIAS -forms lioh owner lioh 0 ALIAS -forms liveroot owner liveroot 0 ALIAS -forms livingrock owner livingrock 0 ALIAS -forms livingwood owner livingwood 0 ALIAS -forms lodestone owner lodestone 0 RETIRED -forms lr owner lr 0 ALIAS -forms lu owner lu 0 ALIAS -forms lubricant owner lubricant 0 ALIAS -forms luminite owner luminite 0 RETIRED -forms lumium owner lumium 0 ALIAS -forms lv owner lv 0 ALIAS -forms magenta owner magenta 0 ALIAS -forms magic owner magic 0 ALIAS -forms magnalium owner magnalium 0 ALIAS -forms magnetite owner magnetite 0 ALIAS -forms magnetizedtungsten owner magnetizedtungsten 0 RETIRED -forms mahoe owner mahoe 0 RETIRED -forms malachite owner malachite 0 ALIAS -forms manadiamond owner manadiamond 0 ALIAS -forms manaquartz owner manaquartz 0 ALIAS -forms manasteel owner manasteel 0 ALIAS -forms mangrove owner mangrove 0 ALIAS -forms maple owner maple 0 ALIAS -forms marble owner marble 0 ALIAS -forms marssand owner marssand 0 ALIAS -forms mawsitsit owner mawsitsit 0 RETIRED -forms maxixe owner maxixe 0 ALIAS -forms mc owner mc 0 ALIAS -forms md owner md 0 ALIAS -forms meatcooked owner meatcooked 0 ALIAS -forms meatraw owner meatraw 0 ALIAS -forms meatrotten owner meatrotten 0 ALIAS -forms mercassium owner mercassium 0 RETIRED -forms methaneice owner methaneice 0 ALIAS -forms mg owner mg 0 ALIAS -forms mgcl2 owner mgcl2 0 ALIAS -forms mgco3 owner mgco3 0 ALIAS -forms mica owner mica 0 ALIAS -forms milk owner milk 0 ALIAS -forms milkyquartz owner milkyquartz 0 ALIAS -forms mimichite owner mimichite 0 RETIRED -forms mint owner mint 0 ALIAS -forms mirabilite owner mirabilite 0 ALIAS -forms mn owner mn 0 ALIAS -forms mncl2 owner mncl2 0 ALIAS -forms mno2 owner mno2 0 ALIAS -forms mo owner mo 0 ALIAS -forms moissanite owner moissanite 0 RETIRED -forms molybdenite owner molybdenite 0 ALIAS -forms monazite owner monazite 0 ALIAS -forms mookaite owner mookaite 0 RETIRED -forms morganite owner morganite 0 ALIAS -forms mossy owner mossy 0 ALIAS -forms mt owner mt 0 ALIAS -forms n owner n 0 ALIAS -forms na owner na 0 ALIAS -forms na2co3 owner na2co3 0 ALIAS -forms na2s owner na2s 0 ALIAS -forms na2s2o7 owner na2s2o7 0 ALIAS -forms na2so3 owner na2so3 0 ALIAS -forms na2so4 owner na2so4 0 ALIAS -forms na3alf6 owner na3alf6 0 ALIAS -forms naalo2 owner naalo2 0 ALIAS -forms nacl owner nacl 0 ALIAS -forms naf owner naf 0 ALIAS -forms nahco3 owner nahco3 0 ALIAS -forms nahso4 owner nahso4 0 ALIAS -forms nano3 owner nano3 0 ALIAS -forms naoh owner naoh 0 ALIAS -forms naso4 owner naso4 0 ALIAS -forms nb owner nb 0 ALIAS -forms nb2o5 owner nb2o5 0 ALIAS -forms nd owner nd 0 ALIAS -forms ne owner ne 0 ALIAS -forms neodymiummagnetic owner neodymiummagnetic 0 ALIAS -forms netherbrick owner netherbrick 0 ALIAS -forms netherite owner netherite 0 ALIAS -forms netherizeddiamond owner netherizeddiamond 0 ALIAS -forms netherquartz owner netherquartz 0 ALIAS -forms netherrack owner netherrack 0 ALIAS -forms netherstar owner netherstar 0 ALIAS -forms nh owner nh 0 ALIAS -forms nh3 owner nh3 0 ALIAS -forms ni owner ni 0 ALIAS -forms nichrome owner nichrome 0 ALIAS -forms nikolinealloy owner nikolinealloy 0 ALIAS -forms nikolite owner nikolite 0 ALIAS -forms niobiumtitanium owner niobiumtitanium 0 ALIAS -forms niter owner niter 0 ALIAS -forms nitrocarbon owner nitrocarbon 0 ALIAS -forms nitrofuel owner nitrofuel 0 ALIAS -forms no2 owner no2 0 ALIAS -forms np owner np 0 ALIAS -forms nq owner nq 0 ALIAS -forms nq522 owner nq522 0 ALIAS -forms nq528 owner nq528 0 ALIAS -forms nutoil owner nutoil 0 ALIAS -forms o owner o 0 ALIAS -forms oak owner oak 0 ALIAS -forms obsidian owner obsidian 0 ALIAS -forms obsidianflux owner obsidianflux 0 RETIRED -forms og owner og 0 ALIAS -forms oil owner oil 0 ALIAS -forms oilsands owner oilsands 0 ALIAS -forms oilshale owner oilshale 0 ALIAS -forms olive owner olive 0 RETIRED -forms oliveoil owner oliveoil 0 ALIAS -forms onyxblack owner onyxblack 0 ALIAS -forms onyxred owner onyxred 0 ALIAS -forms opal owner opal 0 ALIAS -forms orange owner orange 0 ALIAS -forms orangesapphire owner orangesapphire 0 ALIAS -forms os owner os 0 ALIAS -forms osmiridium owner osmiridium 0 ALIAS -forms osmonium owner osmonium 0 RETIRED -forms p owner p 0 ALIAS -forms pa owner pa 0 ALIAS -forms palis owner palis 0 RETIRED -forms palygorskite owner palygorskite 0 ALIAS -forms papaya owner papaya 0 RETIRED -forms paper owner paper 0 ALIAS -forms pb owner pb 0 ALIAS -forms pd owner pd 0 ALIAS -forms pear owner pear 0 RETIRED -forms peat owner peat 0 ALIAS -forms pentlandite owner pentlandite 0 ALIAS -forms peridot owner peridot 0 ALIAS -forms perlite owner perlite 0 ALIAS -forms petcoke owner petcoke 0 ALIAS -forms petrifiedwood owner petrifiedwood 0 ALIAS -forms petrol owner petrol 0 ALIAS -forms petroleum owner petroleum 0 RETIRED -forms petrotheum owner petrotheum 0 RETIRED -forms phoenixite owner phoenixite 0 RETIRED -forms phosphorite owner phosphorite 0 ALIAS -forms phosphorus owner phosphorus 0 ALIAS -forms phosphorusblue owner phosphorusblue 0 ALIAS -forms phosphorusred owner phosphorusred 0 ALIAS -forms phosphoruswhite owner phosphoruswhite 0 ALIAS -forms pietersite owner pietersite 0 RETIRED -forms pinalite owner pinalite 0 ALIAS -forms pink owner pink 0 ALIAS -forms pinkvitriol owner pinkvitriol 0 ALIAS -forms pitchblende owner pitchblende 0 ALIAS -forms plastic owner plastic 0 ALIAS -forms platinumgroupsludge owner platinumgroupsludge 0 ALIAS -forms plum owner plum 0 RETIRED -forms pm owner pm 0 ALIAS -forms po owner po 0 ALIAS -forms po4 owner po4 0 ALIAS -forms pollucite owner pollucite 0 ALIAS -forms porcelain owner porcelain 0 ALIAS -forms potassiumfeldspar owner potassiumfeldspar 0 ALIAS -forms potato owner potato 0 ALIAS -forms powellite owner powellite 0 ALIAS -forms pr owner pr 0 ALIAS -forms prismarinedark owner prismarinedark 0 ALIAS -forms prismarinelight owner prismarinelight 0 ALIAS -forms propane owner propane 0 ALIAS -forms propylene owner propylene 0 ALIAS -forms pt owner pt 0 ALIAS -forms pu owner pu 0 ALIAS -forms pu238 owner pu238 0 ALIAS -forms pu239 owner pu239 0 ALIAS -forms pu240 owner pu240 0 ALIAS -forms pu241 owner pu241 0 ALIAS -forms pu243 owner pu243 0 ALIAS -forms pumice owner pumice 0 ALIAS -forms purple owner purple 0 ALIAS -forms purplesapphire owner purplesapphire 0 ALIAS -forms pvc owner pvc 0 ALIAS -forms pyrite owner pyrite 0 ALIAS -forms pyrope owner pyrope 0 ALIAS -forms pyrotheum owner pyrotheum 0 RETIRED -forms quartzite owner quartzite 0 ALIAS -forms quartzsand owner quartzsand 0 ALIAS -forms quicklime owner quicklime 0 ALIAS -forms ra owner ra 0 ALIAS -forms rainbowood owner rainbowood 0 ALIAS -forms randomite owner randomite 0 RETIRED -forms rareearth owner rareearth 0 ALIAS -forms rb owner rb 0 ALIAS -forms re owner re 0 ALIAS -forms realgar owner realgar 0 ALIAS -forms red owner red 0 ALIAS -forms redalloy owner redalloy 0 ALIAS -forms redquartz owner redquartz 0 ALIAS -forms redsand owner redsand 0 ALIAS -forms redsteel owner redsteel 0 ALIAS -forms redstone owner redstone 0 ALIAS -forms redstonealloy owner redstonealloy 0 ALIAS -forms redstonia owner redstonia 0 RETIRED -forms redvitriol owner redvitriol 0 ALIAS -forms reiium owner reiium 0 RETIRED -forms rf owner rf 0 ALIAS -forms rg owner rg 0 ALIAS -forms rh owner rh 0 ALIAS -forms rhodonite owner rhodonite 0 RETIRED -forms rhyolite owner rhyolite 0 RETIRED -forms rn owner rn 0 ALIAS -forms rosegold owner rosegold 0 ALIAS -forms rotten owner rotten 0 ALIAS -forms ru owner ru 0 ALIAS -forms rubber owner rubber 0 ALIAS -forms ruby owner ruby 0 ALIAS -forms russellite owner russellite 0 ALIAS -forms rye owner rye 0 ALIAS -forms s owner s 0 ALIAS -forms saltedwater owner saltedwater 0 ALIAS -forms saltwater owner saltwater 0 ALIAS -forms sand owner sand 0 ALIAS -forms sapphire owner sapphire 0 ALIAS -forms saturnite owner saturnite 0 RETIRED -forms sb owner sb 0 ALIAS -forms sc owner sc 0 ALIAS -forms scapolite owner scapolite 0 RETIRED -forms scheelite owner scheelite 0 ALIAS -forms schrabidium owner schrabidium 0 RETIRED -forms se owner se 0 ALIAS -forms seawater owner seawater 0 ALIAS -forms seedoil owner seedoil 0 ALIAS -forms selenite owner selenite 0 RETIRED -forms sg owner sg 0 ALIAS -forms shale owner shale 0 ALIAS -forms si owner si 0 ALIAS -forms sic owner sic 0 ALIAS -forms signalum owner signalum 0 ALIAS -forms silverwood owner silverwood 0 ALIAS -forms sio2 owner sio2 0 ALIAS -forms skystone owner skystone 0 ALIAS -forms slate owner slate 0 ALIAS -forms sluicesand owner sluicesand 0 ALIAS -forms sm owner sm 0 ALIAS -forms smithsonite owner smithsonite 0 ALIAS -forms smokeyquartz owner smokeyquartz 0 ALIAS -forms sn owner sn 0 ALIAS -forms snow owner snow 0 ALIAS -forms snowflakeobsidian owner snowflakeobsidian 0 RETIRED -forms so2 owner so2 0 ALIAS -forms so3 owner so3 0 ALIAS -forms sodalite owner sodalite 0 ALIAS -forms solderingalloy owner solderingalloy 0 ALIAS -forms soularium owner soularium 0 ALIAS -forms soulsand owner soulsand 0 ALIAS -forms soylentgreen owner soylentgreen 0 ALIAS -forms sperrylite owner sperrylite 0 ALIAS -forms spessartine owner spessartine 0 ALIAS -forms sphalerite owner sphalerite 0 ALIAS -forms spinel owner spinel 0 ALIAS -forms spodumene owner spodumene 0 ALIAS -forms spruce owner spruce 0 ALIAS -forms sr owner sr 0 ALIAS -forms stainlesssteel owner stainlesssteel 0 ALIAS -forms stannicchloride owner stannicchloride 0 ALIAS -forms stannite owner stannite 0 ALIAS -forms starconium owner starconium 0 RETIRED -forms starmetal owner starmetal 0 RETIRED -forms steam owner steam 0 ALIAS -forms steel owner steel 0 ALIAS -forms steeleaf owner steeleaf 0 ALIAS -forms steelgalvanized owner steelgalvanized 0 ALIAS -forms steelmagnetic owner steelmagnetic 0 ALIAS -forms sterlingsilver owner sterlingsilver 0 ALIAS -forms stibnite owner stibnite 0 ALIAS -forms stolzite owner stolzite 0 ALIAS -forms stone owner stone 0 ALIAS -forms sugar owner sugar 0 ALIAS -forms sunfloweroil owner sunfloweroil 0 ALIAS -forms sunnyquartz owner sunnyquartz 0 ALIAS -forms sunstone owner sunstone 0 RETIRED -forms t owner t 0 ALIAS -forms t2o owner t2o 0 ALIAS -forms ta owner ta 0 ALIAS -forms ta2o5 owner ta2o5 0 ALIAS -forms ta4hfc5 owner ta4hfc5 0 ALIAS -forms talc owner talc 0 ALIAS -forms tantalite owner tantalite 0 ALIAS -forms tanzanite owner tanzanite 0 ALIAS -forms tapazite owner tapazite 0 RETIRED -forms tb owner tb 0 ALIAS -forms tc owner tc 0 ALIAS -forms te owner te 0 ALIAS -forms tea owner tea 0 ALIAS -forms teflon owner teflon 0 ALIAS -forms terrasteel owner terrasteel 0 ALIAS -forms terrasteelalloyraw owner terrasteelalloyraw 0 RETIRED -forms terrasteelalloystrengthened owner terrasteelalloystrengthened 0 RETIRED -forms teslatite owner teslatite 0 RETIRED -forms tetrahedrite owner tetrahedrite 0 ALIAS -forms th owner th 0 ALIAS -forms thaumium owner thaumium 0 ALIAS -forms thyrium owner thyrium 0 RETIRED -forms ti owner ti 0 ALIAS -forms ticl4 owner ticl4 0 ALIAS -forms tigereyeblack owner tigereyeblack 0 ALIAS -forms tigereyeblue owner tigereyeblue 0 ALIAS -forms tigereyegreen owner tigereyegreen 0 ALIAS -forms tigereyered owner tigereyered 0 ALIAS -forms tigereyeyellow owner tigereyeyellow 0 ALIAS -forms tigeriron owner tigeriron 0 ALIAS -forms tinalloy owner tinalloy 0 ALIAS -forms tio2 owner tio2 0 ALIAS -forms titanrock owner titanrock 0 ALIAS -forms tl owner tl 0 ALIAS -forms tm owner tm 0 ALIAS -forms tn owner tn 0 ALIAS -forms topaz owner topaz 0 ALIAS -forms tourmaline owner tourmaline 0 RETIRED -forms trinaquadalloy owner trinaquadalloy 0 ALIAS -forms trinitanium owner trinitanium 0 ALIAS -forms tritaniumalloy owner tritaniumalloy 0 ALIAS -forms tritaniumdioxide owner tritaniumdioxide 0 ALIAS -forms tritaniumhexaastatide owner tritaniumhexaastatide 0 ALIAS -forms tritaniumhexabromide owner tritaniumhexabromide 0 ALIAS -forms tritaniumhexachloride owner tritaniumhexachloride 0 ALIAS -forms tritaniumhexafluoride owner tritaniumhexafluoride 0 ALIAS -forms tritaniumhexaiodide owner tritaniumhexaiodide 0 ALIAS -forms trona owner trona 0 ALIAS -forms tungstate owner tungstate 0 ALIAS -forms tungstencarbide owner tungstencarbide 0 ALIAS -forms tungstensintered owner tungstensintered 0 ALIAS -forms tungstensteel owner tungstensteel 0 ALIAS -forms turquoise owner turquoise 0 RETIRED -forms u233 owner u233 0 ALIAS -forms u235 owner u235 0 ALIAS -forms u235f4 owner u235f4 0 ALIAS -forms u235f6 owner u235f6 0 ALIAS -forms u238 owner u238 0 ALIAS -forms u238f4 owner u238f4 0 ALIAS -forms u238f6 owner u238f6 0 ALIAS -forms uf4 owner uf4 0 ALIAS -forms uf6 owner uf6 0 ALIAS -forms ultimet owner ultimet 0 ALIAS -forms unakite owner unakite 0 RETIRED -forms unobtainium owner unobtainium 0 RETIRED -forms uraninite owner uraninite 0 ALIAS -forms uuamplifier owner uuamplifier 0 RETIRED -forms uumatter owner uumatter 0 RETIRED -forms uvarovite owner uvarovite 0 ALIAS -forms v owner v 0 ALIAS -forms v2o5 owner v2o5 0 ALIAS -forms vanadiumgallium owner vanadiumgallium 0 ALIAS -forms vanadiumsteel owner vanadiumsteel 0 ALIAS -forms vb owner vb 0 ALIAS -forms vermiculite owner vermiculite 0 ALIAS -forms verticium owner verticium 0 RETIRED -forms vibramantium owner vibramantium 0 ALIAS -forms vibraniumsilver owner vibraniumsilver 0 ALIAS -forms vibraniumsteel owner vibraniumsteel 0 ALIAS -forms vibrantalloy owner vibrantalloy 0 ALIAS -forms vinteum owner vinteum 0 RETIRED -forms vinteumpurified owner vinteumpurified 0 RETIRED -forms vitriolofclay owner vitriolofclay 0 ALIAS -forms voidcrystal owner voidcrystal 0 RETIRED -forms w owner w 0 ALIAS -forms walnut owner walnut 0 RETIRED -forms warped owner warped 0 ALIAS -forms wax owner wax 0 ALIAS -forms waxbee owner waxbee 0 ALIAS -forms waxparaffin owner waxparaffin 0 ALIAS -forms waxplant owner waxplant 0 ALIAS -forms weidanium owner weidanium 0 RETIRED -forms wheat owner wheat 0 ALIAS -forms white owner white 0 ALIAS -forms whitevitriol owner whitevitriol 0 ALIAS -forms willow owner willow 0 ALIAS -forms wimalite owner wimalite 0 RETIRED -forms wo3 owner wo3 0 ALIAS -forms wolframite owner wolframite 0 ALIAS -forms wollastonite owner wollastonite 0 ALIAS -forms wonderstone owner wonderstone 0 RETIRED -forms wood owner wood 0 ALIAS -forms woodpolished owner woodpolished 0 ALIAS -forms woodrubber owner woodrubber 0 ALIAS -forms woodtreated owner woodtreated 0 ALIAS -forms wroughtiron owner wroughtiron 0 ALIAS -forms wulfenite owner wulfenite 0 ALIAS -forms xe owner xe 0 ALIAS -forms y owner y 0 ALIAS -forms yb owner yb 0 ALIAS -forms yellow owner yellow 0 ALIAS -forms yellowlimonite owner yellowlimonite 0 ALIAS -forms yellowsapphire owner yellowsapphire 0 ALIAS -forms yttriumbariumcuprate owner yttriumbariumcuprate 0 ALIAS -forms zectium owner zectium 0 RETIRED -forms zeolite owner zeolite 0 ALIAS -forms zircon owner zircon 0 ALIAS -forms zn owner zn 0 ALIAS -forms zr owner zr 0 ALIAS -processing Ceramic Bending.owner Ceramic 0 VALID -processing Ceramic Compressing.owner Ceramic 0 VALID -processing Ceramic Forging.owner Ceramic 0 VALID -processing Ceramic Smashing.owner Ceramic 0 VALID -processing EndSandWhite Forging.owner EndSandWhite 0 RETIRED -processing EndSandWhite Forging.target Glass 0 VALID -processing FishRaw Forging.owner FishRaw 0 VALID -processing FishRaw Forging.target FishCooked 0 VALID -processing FrozenIron Forging.owner FrozenIron 0 RETIRED -processing FrozenIron Forging.target Fe 0 ALIAS -processing H2O Solidifying.owner H2O 0 ALIAS -processing H2O Solidifying.target Ice 0 VALID -processing IronMagnetic Bending.owner IronMagnetic 0 VALID -processing IronMagnetic Bending.target Fe 0 ALIAS -processing IronMagnetic Compressing.owner IronMagnetic 0 VALID -processing IronMagnetic Compressing.target Fe 0 ALIAS -processing IronMagnetic Forging.owner IronMagnetic 0 VALID -processing IronMagnetic Forging.target Fe 0 ALIAS -processing IronMagnetic Smashing.owner IronMagnetic 0 VALID -processing IronMagnetic Smashing.target Fe 0 ALIAS -processing IronMagnetic Working.owner IronMagnetic 0 VALID -processing IronMagnetic Working.target Fe 0 ALIAS -processing Lava Solidifying.owner Lava 0 VALID -processing Lava Solidifying.target Obsidian 0 VALID -processing MeatRaw Forging.owner MeatRaw 0 VALID -processing MeatRaw Forging.target MeatCooked 0 VALID -processing NeodymiumMagnetic Bending.owner NeodymiumMagnetic 0 VALID -processing NeodymiumMagnetic Bending.target Fe 0 ALIAS -processing NeodymiumMagnetic Compressing.owner NeodymiumMagnetic 0 VALID -processing NeodymiumMagnetic Compressing.target Nd 0 ALIAS -processing NeodymiumMagnetic Forging.owner NeodymiumMagnetic 0 VALID -processing NeodymiumMagnetic Forging.target Nd 0 ALIAS -processing NeodymiumMagnetic Smashing.owner NeodymiumMagnetic 0 VALID -processing NeodymiumMagnetic Smashing.target Nd 0 ALIAS -processing NeodymiumMagnetic Working.owner NeodymiumMagnetic 0 VALID -processing NeodymiumMagnetic Working.target Nd 0 ALIAS -processing Porcelain Bending.owner Porcelain 0 VALID -processing Porcelain Compressing.owner Porcelain 0 VALID -processing Porcelain Forging.owner Porcelain 0 VALID -processing Porcelain Smashing.owner Porcelain 0 VALID -processing RedSand Forging.owner RedSand 0 VALID -processing RedSand Forging.target Glass 0 VALID -processing Sand Forging.owner Sand 0 VALID -processing Sand Forging.target Glass 0 VALID -processing SteelGalvanized Forging.owner SteelGalvanized 0 VALID -processing SteelGalvanized Forging.target Steel 0 VALID -processing SteelMagnetic Bending.owner SteelMagnetic 0 VALID -processing SteelMagnetic Bending.target Steel 0 VALID -processing SteelMagnetic Compressing.owner SteelMagnetic 0 VALID -processing SteelMagnetic Compressing.target Steel 0 VALID -processing SteelMagnetic Forging.owner SteelMagnetic 0 VALID -processing SteelMagnetic Forging.target Steel 0 VALID -processing SteelMagnetic Smashing.owner SteelMagnetic 0 VALID -processing SteelMagnetic Smashing.target Steel 0 VALID -processing SteelMagnetic Working.owner SteelMagnetic 0 VALID -processing SteelMagnetic Working.target Steel 0 VALID -processing TungstenSintered Cutting.owner TungstenSintered 0 VALID -processing TungstenSintered Forging.owner TungstenSintered 0 VALID -processing TungstenSintered Smashing.owner TungstenSintered 0 VALID -processing TungstenSintered Working.owner TungstenSintered 0 VALID -uum 10 owner 10 VALID -uum 100 owner 100 VALID -uum 110 owner 110 VALID -uum 120 owner 120 VALID -uum 1250 owner 1250 VALID -uum 1260 owner 1260 VALID -uum 130 owner 130 VALID -uum 140 owner 140 VALID -uum 1450 owner 1450 VALID -uum 150 owner 150 VALID -uum 1520 owner 1520 VALID -uum 160 owner 160 VALID -uum 170 owner 170 VALID -uum 1740 owner 1740 VALID -uum 180 owner 180 VALID -uum 1850 owner 1850 RETIRED -uum 1860 owner 1860 RETIRED -uum 1870 owner 1870 RETIRED -uum 1880 owner 1880 RETIRED -uum 190 owner 190 VALID -uum 20 owner 20 VALID -uum 200 owner 200 VALID -uum 210 owner 210 VALID -uum 220 owner 220 VALID -uum 2210 owner 2210 RETIRED -uum 2220 owner 2220 VALID -uum 230 owner 230 VALID -uum 2390 owner 2390 RETIRED -uum 240 owner 240 VALID -uum 250 owner 250 VALID -uum 260 owner 260 VALID -uum 270 owner 270 VALID -uum 280 owner 280 VALID -uum 290 owner 290 VALID -uum 30 owner 30 VALID -uum 300 owner 300 VALID -uum 310 owner 310 VALID -uum 320 owner 320 VALID -uum 330 owner 330 VALID -uum 340 owner 340 VALID -uum 350 owner 350 VALID -uum 360 owner 360 VALID -uum 370 owner 370 VALID -uum 3720 owner 3720 VALID -uum 380 owner 380 VALID -uum 390 owner 390 VALID -uum 40 owner 40 VALID -uum 400 owner 400 VALID -uum 410 owner 410 VALID -uum 420 owner 420 VALID -uum 440 owner 440 VALID -uum 450 owner 450 VALID -uum 460 owner 460 VALID -uum 470 owner 470 VALID -uum 480 owner 480 VALID -uum 490 owner 490 VALID -uum 50 owner 50 VALID -uum 500 owner 500 VALID -uum 510 owner 510 VALID -uum 520 owner 520 VALID -uum 530 owner 530 VALID -uum 540 owner 540 VALID -uum 550 owner 550 VALID -uum 560 owner 560 VALID -uum 570 owner 570 VALID -uum 580 owner 580 VALID -uum 590 owner 590 VALID -uum 60 owner 60 VALID -uum 600 owner 600 VALID -uum 620 owner 620 VALID -uum 630 owner 630 VALID -uum 640 owner 640 VALID -uum 650 owner 650 VALID -uum 660 owner 660 VALID -uum 670 owner 670 VALID -uum 680 owner 680 VALID -uum 690 owner 690 VALID -uum 70 owner 70 VALID -uum 700 owner 700 VALID -uum 710 owner 710 VALID -uum 720 owner 720 VALID -uum 730 owner 730 VALID -uum 740 owner 740 VALID -uum 750 owner 750 VALID -uum 760 owner 760 VALID -uum 770 owner 770 VALID -uum 780 owner 780 VALID -uum 790 owner 790 VALID -uum 80 owner 80 VALID -uum 800 owner 800 VALID -uum 8000 owner 8000 VALID -uum 8001 owner 8001 VALID -uum 8002 owner 8002 VALID -uum 8003 owner 8003 VALID -uum 8004 owner 8004 RETIRED -uum 8005 owner 8005 RETIRED -uum 8006 owner 8006 VALID -uum 8007 owner 8007 VALID -uum 8008 owner 8008 VALID -uum 8009 owner 8009 VALID -uum 8010 owner 8010 VALID -uum 8011 owner 8011 VALID -uum 8012 owner 8012 VALID -uum 8013 owner 8013 VALID -uum 8014 owner 8014 VALID -uum 8015 owner 8015 VALID -uum 8016 owner 8016 VALID -uum 8017 owner 8017 VALID -uum 8018 owner 8018 VALID -uum 8019 owner 8019 VALID -uum 8020 owner 8020 VALID -uum 8021 owner 8021 VALID -uum 8022 owner 8022 VALID -uum 8023 owner 8023 VALID -uum 8024 owner 8024 VALID -uum 8025 owner 8025 VALID -uum 8026 owner 8026 VALID -uum 8027 owner 8027 VALID -uum 8028 owner 8028 VALID -uum 8029 owner 8029 VALID -uum 8030 owner 8030 VALID -uum 8031 owner 8031 VALID -uum 8032 owner 8032 VALID -uum 8033 owner 8033 VALID -uum 8034 owner 8034 VALID -uum 8035 owner 8035 VALID -uum 8036 owner 8036 VALID -uum 8037 owner 8037 VALID -uum 8038 owner 8038 VALID -uum 8039 owner 8039 VALID -uum 810 owner 810 VALID -uum 8196 owner 8196 VALID -uum 8197 owner 8197 VALID -uum 8198 owner 8198 RETIRED -uum 8199 owner 8199 RETIRED -uum 820 owner 820 VALID -uum 8203 owner 8203 VALID -uum 8204 owner 8204 VALID -uum 8205 owner 8205 VALID -uum 8206 owner 8206 VALID -uum 8207 owner 8207 VALID -uum 8208 owner 8208 VALID -uum 8209 owner 8209 VALID -uum 8215 owner 8215 VALID -uum 8217 owner 8217 VALID -uum 8218 owner 8218 VALID -uum 8219 owner 8219 VALID -uum 8220 owner 8220 VALID -uum 8221 owner 8221 VALID -uum 8222 owner 8222 VALID -uum 8224 owner 8224 VALID -uum 8225 owner 8225 VALID -uum 8226 owner 8226 VALID -uum 8227 owner 8227 RETIRED -uum 8229 owner 8229 VALID -uum 8230 owner 8230 VALID -uum 8231 owner 8231 VALID -uum 8232 owner 8232 VALID -uum 8233 owner 8233 VALID -uum 8234 owner 8234 VALID -uum 8242 owner 8242 VALID -uum 8243 owner 8243 RETIRED -uum 8249 owner 8249 VALID -uum 8267 owner 8267 VALID -uum 8268 owner 8268 VALID -uum 8269 owner 8269 VALID -uum 8270 owner 8270 VALID -uum 8271 owner 8271 VALID -uum 8272 owner 8272 VALID -uum 8273 owner 8273 VALID -uum 8274 owner 8274 VALID -uum 8275 owner 8275 VALID -uum 8276 owner 8276 VALID -uum 8286 owner 8286 RETIRED -uum 8287 owner 8287 RETIRED -uum 8291 owner 8291 RETIRED -uum 8292 owner 8292 RETIRED -uum 8298 owner 8298 VALID -uum 8299 owner 8299 VALID -uum 8300 owner 8300 VALID -uum 8301 owner 8301 VALID -uum 8302 owner 8302 VALID -uum 8303 owner 8303 VALID -uum 8304 owner 8304 VALID -uum 8305 owner 8305 VALID -uum 8306 owner 8306 VALID -uum 8307 owner 8307 VALID -uum 8308 owner 8308 VALID -uum 8309 owner 8309 VALID -uum 8311 owner 8311 VALID -uum 8312 owner 8312 VALID -uum 8313 owner 8313 VALID -uum 8314 owner 8314 VALID -uum 8315 owner 8315 VALID -uum 8323 owner 8323 VALID -uum 8324 owner 8324 VALID -uum 8325 owner 8325 VALID -uum 8326 owner 8326 VALID -uum 8328 owner 8328 VALID -uum 8330 owner 8330 VALID -uum 8331 owner 8331 VALID -uum 8332 owner 8332 VALID -uum 8333 owner 8333 VALID -uum 8334 owner 8334 VALID -uum 8335 owner 8335 VALID -uum 8336 owner 8336 VALID -uum 8340 owner 8340 VALID -uum 8341 owner 8341 VALID -uum 8346 owner 8346 VALID -uum 8347 owner 8347 VALID -uum 8348 owner 8348 VALID -uum 8349 owner 8349 VALID -uum 8362 owner 8362 RETIRED -uum 8363 owner 8363 RETIRED -uum 8364 owner 8364 RETIRED -uum 8368 owner 8368 RETIRED -uum 8369 owner 8369 RETIRED -uum 8370 owner 8370 RETIRED -uum 8371 owner 8371 RETIRED -uum 8372 owner 8372 RETIRED -uum 8374 owner 8374 RETIRED -uum 8375 owner 8375 RETIRED -uum 8376 owner 8376 RETIRED -uum 8377 owner 8377 RETIRED -uum 8378 owner 8378 RETIRED -uum 8379 owner 8379 RETIRED -uum 8380 owner 8380 RETIRED -uum 8383 owner 8383 VALID -uum 8384 owner 8384 VALID -uum 8385 owner 8385 VALID -uum 8386 owner 8386 VALID -uum 8387 owner 8387 VALID -uum 8388 owner 8388 RETIRED -uum 8389 owner 8389 VALID -uum 8390 owner 8390 VALID -uum 8393 owner 8393 VALID -uum 8394 owner 8394 RETIRED -uum 8395 owner 8395 VALID -uum 8396 owner 8396 VALID -uum 8397 owner 8397 VALID -uum 8400 owner 8400 VALID -uum 8401 owner 8401 VALID -uum 8402 owner 8402 VALID -uum 8403 owner 8403 VALID -uum 8404 owner 8404 VALID -uum 8405 owner 8405 VALID -uum 8406 owner 8406 VALID -uum 8407 owner 8407 VALID -uum 8408 owner 8408 VALID -uum 8409 owner 8409 VALID -uum 8410 owner 8410 VALID -uum 8411 owner 8411 RETIRED -uum 8412 owner 8412 VALID -uum 8413 owner 8413 VALID -uum 8415 owner 8415 VALID -uum 8416 owner 8416 VALID -uum 8417 owner 8417 VALID -uum 8418 owner 8418 VALID -uum 8419 owner 8419 VALID -uum 8420 owner 8420 VALID -uum 8423 owner 8423 VALID -uum 8424 owner 8424 VALID -uum 8425 owner 8425 VALID -uum 8426 owner 8426 VALID -uum 8427 owner 8427 VALID -uum 8428 owner 8428 VALID -uum 8429 owner 8429 VALID -uum 8430 owner 8430 VALID -uum 8431 owner 8431 VALID -uum 8432 owner 8432 VALID -uum 8433 owner 8433 VALID -uum 8434 owner 8434 VALID -uum 8435 owner 8435 VALID -uum 8436 owner 8436 VALID -uum 8437 owner 8437 VALID -uum 8438 owner 8438 VALID -uum 8439 owner 8439 VALID -uum 8440 owner 8440 VALID -uum 8441 owner 8441 VALID -uum 8442 owner 8442 VALID -uum 8443 owner 8443 VALID -uum 8444 owner 8444 VALID -uum 8445 owner 8445 VALID -uum 8446 owner 8446 VALID -uum 8447 owner 8447 VALID -uum 8448 owner 8448 VALID -uum 8449 owner 8449 VALID -uum 8450 owner 8450 VALID -uum 8451 owner 8451 VALID -uum 8455 owner 8455 VALID -uum 8456 owner 8456 RETIRED -uum 8457 owner 8457 RETIRED -uum 8458 owner 8458 VALID -uum 8459 owner 8459 VALID -uum 8460 owner 8460 VALID -uum 8461 owner 8461 VALID -uum 8462 owner 8462 VALID -uum 8463 owner 8463 RETIRED -uum 8464 owner 8464 VALID -uum 8465 owner 8465 VALID -uum 8466 owner 8466 RETIRED -uum 8467 owner 8467 VALID -uum 8468 owner 8468 VALID -uum 8600 owner 8600 VALID -uum 8601 owner 8601 VALID -uum 8602 owner 8602 VALID -uum 8603 owner 8603 RETIRED -uum 8604 owner 8604 RETIRED -uum 8605 owner 8605 VALID -uum 8610 owner 8610 VALID -uum 8611 owner 8611 VALID -uum 8613 owner 8613 RETIRED -uum 8614 owner 8614 VALID -uum 8615 owner 8615 VALID -uum 8620 owner 8620 VALID -uum 8621 owner 8621 VALID -uum 8622 owner 8622 VALID -uum 8630 owner 8630 VALID -uum 8631 owner 8631 VALID -uum 8633 owner 8633 VALID -uum 8634 owner 8634 VALID -uum 8635 owner 8635 VALID -uum 8636 owner 8636 VALID -uum 8637 owner 8637 RETIRED -uum 8638 owner 8638 VALID -uum 8639 owner 8639 RETIRED -uum 8640 owner 8640 VALID -uum 8642 owner 8642 RETIRED -uum 8643 owner 8643 VALID -uum 8644 owner 8644 RETIRED -uum 8645 owner 8645 VALID -uum 8646 owner 8646 VALID -uum 8647 owner 8647 VALID -uum 8649 owner 8649 RETIRED -uum 8650 owner 8650 RETIRED -uum 8652 owner 8652 VALID -uum 8653 owner 8653 VALID -uum 8654 owner 8654 RETIRED -uum 8657 owner 8657 RETIRED -uum 8658 owner 8658 VALID -uum 8659 owner 8659 VALID -uum 8660 owner 8660 VALID -uum 8661 owner 8661 VALID -uum 8662 owner 8662 VALID -uum 8663 owner 8663 VALID -uum 8664 owner 8664 VALID -uum 8665 owner 8665 VALID -uum 8666 owner 8666 VALID -uum 8667 owner 8667 VALID -uum 8668 owner 8668 VALID -uum 8669 owner 8669 VALID -uum 8682 owner 8682 VALID -uum 8684 owner 8684 VALID -uum 8685 owner 8685 VALID -uum 8686 owner 8686 VALID -uum 8687 owner 8687 VALID -uum 8688 owner 8688 RETIRED -uum 8689 owner 8689 VALID -uum 8690 owner 8690 RETIRED -uum 8692 owner 8692 RETIRED -uum 8700 owner 8700 VALID -uum 8704 owner 8704 VALID -uum 8705 owner 8705 VALID -uum 8706 owner 8706 VALID -uum 8708 owner 8708 VALID -uum 8709 owner 8709 VALID -uum 8711 owner 8711 RETIRED -uum 8727 owner 8727 VALID -uum 8728 owner 8728 RETIRED -uum 8729 owner 8729 VALID -uum 8730 owner 8730 VALID -uum 8733 owner 8733 VALID -uum 8737 owner 8737 VALID -uum 8750 owner 8750 RETIRED -uum 8751 owner 8751 VALID -uum 8752 owner 8752 VALID -uum 8756 owner 8756 VALID -uum 8757 owner 8757 RETIRED -uum 8758 owner 8758 RETIRED -uum 8766 owner 8766 RETIRED -uum 8776 owner 8776 RETIRED -uum 8780 owner 8780 RETIRED -uum 8782 owner 8782 RETIRED -uum 8784 owner 8784 VALID -uum 8790 owner 8790 VALID -uum 8793 owner 8793 VALID -uum 8794 owner 8794 RETIRED -uum 8796 owner 8796 VALID -uum 8797 owner 8797 VALID -uum 8798 owner 8798 VALID -uum 8802 owner 8802 VALID -uum 8803 owner 8803 VALID -uum 8804 owner 8804 RETIRED -uum 8808 owner 8808 RETIRED -uum 90 owner 90 VALID -uum 9101 owner 9101 VALID -uum 9102 owner 9102 VALID -uum 9103 owner 9103 VALID -uum 9104 owner 9104 VALID -uum 9107 owner 9107 VALID -uum 9109 owner 9109 VALID -uum 9110 owner 9110 VALID -uum 9111 owner 9111 VALID -uum 9114 owner 9114 VALID -uum 9115 owner 9115 VALID -uum 9116 owner 9116 VALID -uum 9117 owner 9117 VALID -uum 9119 owner 9119 VALID -uum 9120 owner 9120 VALID -uum 9123 owner 9123 VALID -uum 9125 owner 9125 VALID -uum 9126 owner 9126 VALID -uum 9127 owner 9127 VALID -uum 9128 owner 9128 VALID -uum 9129 owner 9129 VALID -uum 9130 owner 9130 VALID -uum 9131 owner 9131 VALID -uum 9132 owner 9132 VALID -uum 9133 owner 9133 VALID -uum 9135 owner 9135 VALID -uum 9140 owner 9140 VALID -uum 9145 owner 9145 VALID -uum 9153 owner 9153 VALID -uum 9154 owner 9154 VALID -uum 9160 owner 9160 VALID -uum 9161 owner 9161 VALID -uum 9167 owner 9167 VALID -uum 9169 owner 9169 VALID -uum 9174 owner 9174 VALID -uum 9175 owner 9175 VALID -uum 9192 owner 9192 VALID -uum 9193 owner 9193 VALID -uum 9194 owner 9194 VALID -uum 9195 owner 9195 VALID -uum 9197 owner 9197 VALID -uum 9213 owner 9213 VALID -uum 9214 owner 9214 VALID -uum 9215 owner 9215 VALID -uum 9216 owner 9216 VALID -uum 9217 owner 9217 VALID -uum 9243 owner 9243 VALID -uum 9271 owner 9271 VALID -uum 9300 owner 9300 VALID -uum 9301 owner 9301 VALID -uum 9302 owner 9302 VALID -uum 9303 owner 9303 VALID -uum 9304 owner 9304 VALID -uum 9305 owner 9305 VALID -uum 9306 owner 9306 VALID -uum 9307 owner 9307 VALID -uum 9308 owner 9308 VALID -uum 9309 owner 9309 VALID -uum 9310 owner 9310 VALID -uum 9311 owner 9311 VALID -uum 9312 owner 9312 VALID -uum 9313 owner 9313 VALID -uum 9314 owner 9314 VALID -uum 9315 owner 9315 VALID -uum 9316 owner 9316 VALID -uum 9317 owner 9317 VALID -uum 9318 owner 9318 VALID -uum 9319 owner 9319 VALID -uum 9320 owner 9320 RETIRED -uum 9321 owner 9321 RETIRED -uum 9322 owner 9322 RETIRED -uum 9323 owner 9323 RETIRED -uum 9324 owner 9324 RETIRED -uum 9325 owner 9325 RETIRED -uum 9326 owner 9326 RETIRED -uum 9327 owner 9327 RETIRED -uum 9328 owner 9328 RETIRED -uum 9329 owner 9329 RETIRED -uum 9330 owner 9330 RETIRED -uum 9331 owner 9331 RETIRED -uum 9332 owner 9332 RETIRED -uum 9333 owner 9333 RETIRED -uum 9334 owner 9334 RETIRED -uum 9335 owner 9335 RETIRED -uum 9336 owner 9336 RETIRED -uum 9337 owner 9337 RETIRED -uum 9338 owner 9338 RETIRED -uum 9339 owner 9339 RETIRED -uum 9340 owner 9340 RETIRED -uum 9341 owner 9341 RETIRED -uum 9342 owner 9342 RETIRED -uum 9343 owner 9343 RETIRED -uum 9344 owner 9344 VALID -uum 9345 owner 9345 RETIRED -uum 9346 owner 9346 RETIRED -uum 9347 owner 9347 RETIRED -uum 9348 owner 9348 RETIRED -uum 9349 owner 9349 RETIRED -uum 9350 owner 9350 RETIRED -uum 9351 owner 9351 RETIRED -uum 9352 owner 9352 RETIRED -uum 9353 owner 9353 RETIRED -uum 9354 owner 9354 RETIRED -uum 9355 owner 9355 RETIRED -uum 9356 owner 9356 RETIRED -uum 9357 owner 9357 RETIRED -uum 9358 owner 9358 RETIRED -uum 9359 owner 9359 RETIRED -uum 9360 owner 9360 RETIRED -uum 9361 owner 9361 RETIRED -uum 9362 owner 9362 RETIRED -uum 9363 owner 9363 RETIRED -uum 9364 owner 9364 RETIRED -uum 9365 owner 9365 RETIRED -uum 9366 owner 9366 RETIRED -uum 9367 owner 9367 RETIRED -uum 9368 owner 9368 RETIRED -uum 9369 owner 9369 RETIRED -uum 9370 owner 9370 RETIRED -uum 9371 owner 9371 RETIRED -uum 9372 owner 9372 VALID -uum 9373 owner 9373 RETIRED -uum 9374 owner 9374 RETIRED -uum 9375 owner 9375 RETIRED -uum 9376 owner 9376 RETIRED -uum 9377 owner 9377 RETIRED -uum 9378 owner 9378 RETIRED -uum 9379 owner 9379 RETIRED -uum 9380 owner 9380 RETIRED -uum 9381 owner 9381 RETIRED -uum 9382 owner 9382 RETIRED -uum 9383 owner 9383 RETIRED -uum 9384 owner 9384 RETIRED -uum 9385 owner 9385 RETIRED -uum 9386 owner 9386 RETIRED -uum 9387 owner 9387 RETIRED -uum 9388 owner 9388 RETIRED -uum 9389 owner 9389 RETIRED -uum 9390 owner 9390 RETIRED -uum 9391 owner 9391 RETIRED -uum 9392 owner 9392 RETIRED -uum 9393 owner 9393 RETIRED -uum 9394 owner 9394 RETIRED -uum 9395 owner 9395 RETIRED -uum 9396 owner 9396 RETIRED -uum 9397 owner 9397 RETIRED -uum 9398 owner 9398 RETIRED -uum 9399 owner 9399 RETIRED -uum 9400 owner 9400 RETIRED -uum 9401 owner 9401 RETIRED -uum 9402 owner 9402 RETIRED -uum 9403 owner 9403 RETIRED -uum 9404 owner 9404 RETIRED -uum 9405 owner 9405 RETIRED -uum 9406 owner 9406 RETIRED -uum 9407 owner 9407 RETIRED -uum 9408 owner 9408 RETIRED -uum 9409 owner 9409 VALID -uum 9703 owner 9703 VALID -uum 9787 owner 9787 RETIRED -uum 9800 owner 9800 VALID -uum 9801 owner 9801 VALID -uum 9802 owner 9802 VALID -uum 9803 owner 9803 VALID -uum 9804 owner 9804 VALID -uum 9808 owner 9808 VALID -uum 9809 owner 9809 VALID -uum 9814 owner 9814 VALID -uum 9815 owner 9815 VALID -uum 9820 owner 9820 VALID -uum 9821 owner 9821 VALID -uum 9822 owner 9822 VALID -uum 9823 owner 9823 VALID -uum 9824 owner 9824 VALID -uum 9825 owner 9825 VALID -uum 9826 owner 9826 VALID -uum 9827 owner 9827 VALID -uum 9828 owner 9828 VALID -uum 9829 owner 9829 VALID -uum 9830 owner 9830 VALID -uum 9831 owner 9831 VALID -uum 9832 owner 9832 VALID -uum 9834 owner 9834 VALID -uum 9835 owner 9835 VALID -uum 9836 owner 9836 VALID -uum 9837 owner 9837 VALID -uum 9838 owner 9838 VALID -uum 9839 owner 9839 VALID -uum 9843 owner 9843 VALID -uum 9844 owner 9844 VALID diff --git a/core/src/test/resources/gregtech/material-reference-history.tsv b/core/src/test/resources/gregtech/material-reference-history.tsv deleted file mode 100644 index f37e8fe3a..000000000 --- a/core/src/test/resources/gregtech/material-reference-history.tsv +++ /dev/null @@ -1,94 +0,0 @@ -# table owner field name id classification evidence (GT6 3703e403 MT.java, or existing parity) -composition Iridiron owner Iridiron 0 RETIRED MT.java:3997 unused/deprecated;上游即非可用材料 -composition IridironReinforced owner IridironReinforced 0 RETIRED MT.java:3998 unused/deprecated;上游即非可用材料 -composition OsmiumTetroxide owner OsmiumTetroxide 0 RETIRED MT.java:3994 unused/deprecated;上游即非可用材料 -composition SodiumPeroxide owner SodiumPeroxide 0 RETIRED MT.java:3995 unused/deprecated;上游即非可用材料 -composition Vis owner Vis 0 RETIRED MT.java:4003 unused/deprecated;上游即非可用材料 -forms adamite owner adamite 0 RETIRED MT.java:4044 unused/deprecated;上游即非可用材料 -forms adluorite owner adluorite 0 RETIRED MT.java:4045 unused/deprecated;上游即非可用材料 -forms advancedalloy owner advancedalloy 0 RETIRED MT.java:4066 unused/deprecated;上游即非可用材料 -forms agate owner agate 0 RETIRED MT.java:4046 unused/deprecated;上游即非可用材料 -forms amberdominican owner amberdominican 0 RETIRED DominicanAmber 的导入别名随 Fossils and Archeology 材料一并退役,见 docs/decisions/parity/material-removal.md -forms ametrine owner ametrine 0 RETIRED MT.java:1475 valgem(0);未分配有效材料 ID -forms ammonium owner ammonium 0 RETIRED MT.java:4047 unused/deprecated;上游即非可用材料 -forms angelite owner angelite 0 RETIRED MT.java:1472 valgem(0);未分配有效材料 ID -forms australium owner australium 0 RETIRED MT.java:4060 unused/deprecated;上游即非可用材料 -forms basanite owner basanite 0 RETIRED MT.java:1470 valgem(0);未分配有效材料 ID -forms bitumen owner bitumen 0 RETIRED MT.java:4048 unused/deprecated;上游即非可用材料 -forms blackberyl owner blackberyl 0 RETIRED MT.java:1455 valgem(0);未分配有效材料 ID -forms bloodstone owner bloodstone 0 RETIRED MT.java:1449,4049 unused/deprecated;上游即非可用材料 -forms carnelian owner carnelian 0 RETIRED MT.java:1464 valgem(0);未分配有效材料 ID -forms charoite owner charoite 0 RETIRED MT.java:1463 valgem(0);未分配有效材料 ID -forms chestnut owner chestnut 0 RETIRED MT.java:3929;字段对应 Chestnutwood(9345),见 docs/decisions/parity/material-removal.md -forms chrysocolla owner chrysocolla 0 RETIRED MT.java:1468,4052 unused/deprecated;上游即非可用材料 -forms chrysoprase owner chrysoprase 0 RETIRED MT.java:1474 valgem(0);未分配有效材料 ID -forms citrine owner citrine 0 RETIRED MT.java:4050 unused/deprecated;上游即非可用材料 -forms citrus owner citrus 0 RETIRED MT.java:3930;字段对应 Citruswood(9346),见 docs/decisions/parity/material-removal.md -forms cmbsteel owner cmbsteel 0 RETIRED MT.java:4064 unused/deprecated;上游即非可用材料 -forms coral owner coral 0 RETIRED MT.java:1469,4051 unused/deprecated;上游即非可用材料 -forms crystalflux owner crystalflux 0 RETIRED MT.java:4018 unused/deprecated;上游即非可用材料 -forms daffergon owner daffergon 0 RETIRED MT.java:4056 unused/deprecated;上游即非可用材料 -forms darkstone owner darkstone 0 RETIRED MT.java:4053 unused/deprecated;上游即非可用材料 -forms demonite owner demonite 0 RETIRED MT.java:4054 unused/deprecated;上游即非可用材料 -forms dineutronium owner dineutronium 0 RETIRED MT.java:4068 unused/deprecated;上游即非可用材料 -forms draconic owner draconic 0 RETIRED MT.java:4012 unused/deprecated;上游即非可用材料 -forms dumortierite owner dumortierite 0 RETIRED MT.java:1459 valgem(0);未分配有效材料 ID -forms durasteel owner durasteel 0 RETIRED MT.java:4065 unused/deprecated;上游即非可用材料 -forms elder owner elder 0 RETIRED MT.java:3967;字段对应 Elderwood(9382),见 docs/decisions/parity/material-removal.md -forms euphemium owner euphemium 0 RETIRED MT.java:4070 unused/deprecated;上游即非可用材料 -forms fig owner fig 0 RETIRED MT.java:3970;字段对应 Figwood(9385),见 docs/decisions/parity/material-removal.md -forms infusedgold owner infusedgold 0 RETIRED MT.java:4055 unused/deprecated;上游即非可用材料 -forms invisium owner invisium 0 RETIRED MT.java:4021 unused/deprecated;上游即非可用材料 -forms iridiron owner iridiron 0 RETIRED MT.java:3997 unused/deprecated;上游即非可用材料 -forms iridironreinforced owner iridironreinforced 0 RETIRED MT.java:3998 unused/deprecated;上游即非可用材料 -forms ironsharp owner ironsharp 0 RETIRED MT.java:4016 unused/deprecated;上游即非可用材料 -forms irridantreinforced owner irridantreinforced 0 RETIRED MT.java:4015 unused/deprecated;上游即非可用材料 -forms irridanturanium owner irridanturanium 0 RETIRED MT.java:4014 unused/deprecated;上游即非可用材料 -forms jet owner jet 0 RETIRED MT.java:1452,4091 unused/deprecated;上游即非可用材料 -forms kunzite owner kunzite 0 RETIRED MT.java:1471 valgem(0);未分配有效材料 ID -forms labradorite owner labradorite 0 RETIRED MT.java:1458 valgem(0);未分配有效材料 ID -forms lapislazuli owner lapislazuli 0 RETIRED MT.java:1453 valgem(0);未分配有效材料 ID -forms larimar owner larimar 0 RETIRED MT.java:1462 valgem(0);未分配有效材料 ID -forms lodestone owner lodestone 0 RETIRED MT.java:4022 unused/deprecated;上游即非可用材料 -forms luminite owner luminite 0 RETIRED MT.java:4023 unused/deprecated;上游即非可用材料 -forms magnetizedtungsten owner magnetizedtungsten 0 RETIRED MT.java:4069 unused/deprecated;上游即非可用材料 -forms mawsitsit owner mawsitsit 0 RETIRED MT.java:4025 unused/deprecated;上游即非可用材料 -forms mercassium owner mercassium 0 RETIRED MT.java:4005 unused/deprecated;上游即非可用材料 -forms mimichite owner mimichite 0 RETIRED MT.java:4019 unused/deprecated;上游即非可用材料 -forms moissanite owner moissanite 0 RETIRED MT.java:1460 valgem(0);未分配有效材料 ID -forms mookaite owner mookaite 0 RETIRED MT.java:1461 valgem(0);未分配有效材料 ID -forms obsidianflux owner obsidianflux 0 RETIRED MT.java:4017 unused/deprecated;上游即非可用材料 -forms olive owner olive 0 RETIRED MT.java:3980;字段对应 Olivewood(9395),见 docs/decisions/parity/material-removal.md -forms osmonium owner osmonium 0 RETIRED MT.java:4006 unused/deprecated;上游即非可用材料 -forms papaya owner papaya 0 RETIRED MT.java:3941;字段对应 Papayawood(9359),见 docs/decisions/parity/material-removal.md -forms pear owner pear 0 RETIRED MT.java:3981;字段对应 Pearwood(9396),见 docs/decisions/parity/material-removal.md -forms petroleum owner petroleum 0 RETIRED MT.java:4028 unused/deprecated;上游即非可用材料 -forms phoenixite owner phoenixite 0 RETIRED MT.java:4007 unused/deprecated;上游即非可用材料 -forms pietersite owner pietersite 0 RETIRED MT.java:1467 valgem(0);未分配有效材料 ID -forms plum owner plum 0 RETIRED MT.java:3942;字段对应 Plumwood(9360),见 docs/decisions/parity/material-removal.md -forms randomite owner randomite 0 RETIRED MT.java:4031 unused/deprecated;上游即非可用材料 -forms reiium owner reiium 0 RETIRED MT.java:4057 unused/deprecated;上游即非可用材料 -forms rhodonite owner rhodonite 0 RETIRED MT.java:1457 valgem(0);未分配有效材料 ID -forms saturnite owner saturnite 0 RETIRED MT.java:4067 unused/deprecated;上游即非可用材料 -forms scapolite owner scapolite 0 RETIRED MT.java:1473 valgem(0);未分配有效材料 ID -forms schrabidium owner schrabidium 0 RETIRED MT.java:4061 unused/deprecated;上游即非可用材料 -forms selenite owner selenite 0 RETIRED MT.java:1466,4090 unused/deprecated;上游即非可用材料 -forms snowflakeobsidian owner snowflakeobsidian 0 RETIRED MT.java:1454 valgem(0);未分配有效材料 ID -forms starconium owner starconium 0 RETIRED MT.java:4009 unused/deprecated;上游即非可用材料 -forms starmetal owner starmetal 0 RETIRED MT.java:4062 unused/deprecated;上游即非可用材料 -forms tapazite owner tapazite 0 RETIRED MT.java:4040 unused/deprecated;上游即非可用材料 -forms terrasteelalloyraw owner terrasteelalloyraw 0 RETIRED MT.java:4001 unused/deprecated;上游即非可用材料 -forms terrasteelalloystrengthened owner terrasteelalloystrengthened 0 RETIRED MT.java:4002 unused/deprecated;上游即非可用材料 -forms teslatite owner teslatite 0 RETIRED MT.java:4013 unused/deprecated;上游即非可用材料 -forms thyrium owner thyrium 0 RETIRED MT.java:4010 unused/deprecated;上游即非可用材料 -forms tourmaline owner tourmaline 0 RETIRED MT.java:4041 unused/deprecated;上游即非可用材料 -forms turquoise owner turquoise 0 RETIRED MT.java:4042 unused/deprecated;上游即非可用材料 -forms unakite owner unakite 0 RETIRED MT.java:1465 valgem(0);未分配有效材料 ID -forms unobtainium owner unobtainium 0 RETIRED MT.java:4063 unused/deprecated;上游即非可用材料 -forms verticium owner verticium 0 RETIRED MT.java:4059 unused/deprecated;上游即非可用材料 -forms walnut owner walnut 0 RETIRED MT.java:3946;字段对应 Walnutwood(9364),见 docs/decisions/parity/material-removal.md -forms weidanium owner weidanium 0 RETIRED MT.java:4058 unused/deprecated;上游即非可用材料 -forms wimalite owner wimalite 0 RETIRED MT.java:4043 unused/deprecated;上游即非可用材料 -forms wonderstone owner wonderstone 0 RETIRED MT.java:1450 valgem(0);未分配有效材料 ID -forms zectium owner zectium 0 RETIRED MT.java:4011 unused/deprecated;上游即非可用材料 -processing EndSandWhite Forging.owner EndSandWhite 0 RETIRED MT.java:1620;字段对应 White End Sand(8105),见 docs/decisions/parity/material-removal.md diff --git a/docs/architecture/packages/content.md b/docs/architecture/packages/content.md index cdb613415..01d3fdd48 100644 --- a/docs/architecture/packages/content.md +++ b/docs/architecture/packages/content.md @@ -99,7 +99,7 @@ - 线缆、管道、轴、电池、覆盖板与储罐的实际传输、断开与方向变化。 - 材料物品/方块注册与统一化;矿脉或结构的注册存在性。 - 现有测试集 - - `MaterialBaselineTest` 与共享 `MaterialBaselineTests` 提供材料源表引用审计、独立 JVM 快照、测试材料 SPI、成分与回收/分解及真实重载入口;观察与正确性依据分开,见[材料基线](../../integration/material-baseline.md)。 + - 材料注册、成分解析、分解计划和过程图分别由 `MaterialRegistrationTest`、`ItemCompositionResolverTest`、`MaterialDecompositionPlannerTest` 与 `MaterialProcessGraphTest` 覆盖;一次性基线快照和运行时测试附属已移除。 - core 静态 TSV 与 GameTest TSV 由对应 JUnit/GameTest 维护;用例覆盖物品管道路由与调度回归。 - `core/src/test` 的材料目录、标签名翻译、熔融浇筑与配方引擎测试;`api/common` 的材料、机器、能源模型测试。 - 机器 tick、多方块、能源网络、物流、世界生成完整流程等仍是待补范围。 diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index 919984e4d..5542016e4 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -36,13 +36,7 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe ### 配方回归案例表 -材料处理的 `MaterialProcessSnapshotTests` 验证输入 tag 不污染输出、跨材料路线、世界生成形态与完整 revision、普通共同原料、辅助工具说明、相似路线跨辅料/概率/输入形态合并、砧加工与研磨/熔化回收的分类、局部副本无隐形依赖占位、独立路线紧凑排布、仅限页面材料的查询索引、完整原生状态的聚焦目标、同物品悬停的原生状态区分与跨分区副本匹配、局部配方边框不框入相邻机器、过期资源拒绝和同代索引复用;`material_process` 批次不写生产配方。 - -材料领域的 `MaterialBaselineTests` 验证存储块的成分与两类准入、72U 附魔金苹果的规划和实际回收输出、复合钻头、耐久缩放、容器与有形状铸模、压模机模具、固体/流体分解及 test-source 材料 SPI。`material_baseline_reload` 为仅含一个测试的独立批次,等待两次真实资源重载;拥有规则数和固定样例必须稳定。原始投影写入根目录 `work/material-system-refactor/runtime//<运行目录>/`。已知错误行为明确标为观察,不能当作正确性依据;字段、复现与未覆盖范围见[材料基线报告](../../../integration/material-baseline.md)。 - -`MaterialProcessSnapshotTests` 的 viewer 用例验证选中的原生机器行去重、未选行排除、工作台数量与工作站、活动世界生成保留,材料单位模板与非树加工的确认状态,以及单槽候选、跨材料候选、完整原生状态和输出概率;还确认信息卡片位于来源下方、信息页单独存在时仍保留来源区、页面检索限于本材料且不生成加工节点或边。160 槽 viewer 配方通过 `MaterialProcessProjection.initialPages` 检查默认完整端口与连接,显式有限预算仍检查截断一致性及覆盖提示;608 步及 4800 条逻辑关联验证默认材料页不受旧上限截断,关联保存为一个资源分组而非 4800 个连接对象,索引只保留唯一资源/角色;跨分区未确认来源仍使消费端口呈虚线。core 的 `MaterialProcessGraphTest` 另以 20001 步、100020001 条隐含关联验证线性规模的资源引用表示,并与小图逐条连接核对等价性。折叠回归覆盖完整可见输入/输出、忽略工艺 ID 和 method 等隐藏信息、不同机器状态、未知图标保持独立、禁止连锁误合并及输入顺序稳定;坏端口、重复步骤、悬空关联及原生坏配方验证日志隔离和其余数据保留。它们不启动 EMI,不能代替最终配方列表 Mixin、信息页过滤及第三方集成的客户端验收。 - -`decompositionRespectsFormsAndExactFluidIdentities` 通过测试 SPI 声明 dust-only、blockDust-only、liquid-only 和 gas-only 分解,检查形态限制、流体输入不会错误抑制允许的固体兜底、本体完整 ID、附属完整 ID/旧裸路径、外部原版流体 ID、未知及非法 ID,以及附属流体输出的身份和数量。 +材料图的纯数据、查询方向和预算由 core 的 `MaterialProcessGraphTest` 覆盖。一次性的材料基线快照、运行时测试附属材料和材料展示页示例集不再常驻;展示投影、JEI/EMI 接入和真实配方列表必须按[游戏内人工验收](manual-ingame.md#矿物处理展示页)检查。 针对性回归用数据表维护,不为每个 issue 新建测试类、namespace 或结构模板。GameTest 表是运行时权威,只保留 R 级运行时行;静态源检查由 core 的 `crafting-issue-static-cases.tsv` 维护。 diff --git a/docs/development/validation/checks/junit.md b/docs/development/validation/checks/junit.md index 85a81a33f..2adffd64f 100644 --- a/docs/development/validation/checks/junit.md +++ b/docs/development/validation/checks/junit.md @@ -54,4 +54,4 @@ issue source kind target expected JUnit XML 在 `/build/test-results/test/TEST-*.xml`,HTML 报告在 `/build/reports/tests/test/`。 -材料基线入口为 `gregtech.content.material.MaterialBaselineTest`。它在三个独立 JVM 中区分无附属重复启动和测试 SPI 附属,原始投影写入根目录 `work/material-system-refactor/core/`;不使用生产 reset。源表引用的逐行历史依据在 `core/src/test/resources/gregtech/material-reference-history.tsv`;悬空引用与 ID/name 矛盾必须为零,不能用快照允许列表认可错误。历史分类必须核对来源,不能自动重录。字段、权威期望和限制见[材料基线报告](../../../integration/material-baseline.md)。 +材料纯规则的常驻入口是 `MaterialRegistrationTest`、`ItemCompositionResolverTest`、`MaterialDecompositionPlannerTest` 和 `MaterialProcessGraphTest`。一次性的基线快照、独立 JVM 生命周期矩阵和测试附属注入已移除;长期行为应落入可直接重复运行、不会向运行时注册测试内容的定向测试。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 934abaac7..677c9fb5f 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -33,12 +33,10 @@ EMI 数据源还需核对:工作台压块/拆块、熔炉和已安装第三 7. 连续重载两次后确认配方增删同步、旧引用拒绝跳转;断线/换服不沿用回调。布局副本数不改变配方数量或原生 viewer 索引;方法标签只来自 API target/reagent 声明。 8. 两平台分别检查 JEI-only、EMI-only 和双装环境,双装沿既有去重规则。另验无 viewer 的专用服务端与独立远程客户端;未实际执行的场景不能用编译或集成服务器静态表代替。 -`MaterialProcessSnapshotTests` 中的 `presentationPreservesNativeItemState`、`overviewGroupsVisibleRoutesAndHidesAuxiliaries`、`overviewAlignsChainsAndPreservesFeedback`、`overviewSharesHubsWithoutInventingConnections` 、`overviewKeepsDenseEdgesLocal`、`overviewKeepsFirstOutputAndVariantsTogether` 、`recoveryOwnershipAndMachineKindDriveOverviewClassification` 和 `overviewSeparatesSourcesConversionsAndUses`、`overviewFoldsAlternativeInputsAndKeepsProductGridsLocal`、`overviewShowsPortYieldsAndOrdersRecoveryAfterConversions`、`overviewFoldsSimilarRoutesAcrossNativeRecipeDifferences` 和 `overviewPacksLocalRoutesWithoutInvisibleDependencies` 覆盖原生状态、锤子分类图标、辅料隐藏、原始步骤保留、外观去重、公共资源集中、连续链、顺序稳定、循环、副本、密集图直线避让和关联保留。编译这些测试不代表已运行 GameTest;箭头外观、真实 EMI 查询和鼠标手感仍需人工确认。 +材料展示页不再维护逐布局场景的示例 GameTest。原状态、辅料隐藏、路线折叠、连续链、循环、副本、排布和关联保留必须直接按上述步骤做真实查看器验收;core 的图测试只证明纯数据与查询预算,不证明投影布局或鼠标手感。 ## 注意事项 -`overviewIndexesOnlyItsOwnMaterialAndFindsNativeFocus`、`overviewMatchesItemsAcrossCopiesAndKeepsRecipesSeparate` 与 `overviewFramesRecipesWithoutEnclosingTheirNeighbors` 覆盖查询索引、原生状态目标、同物品副本匹配及配方边框边界;不代替目标绿色外框、动态视口、全屏往返、两平台 `EmiApi.setPages` Mixin 命中与真实查看器的鼠标/键盘验收。 - - 使用隔离实例;EULA 由操作者自行处理;完整日志、截图与实例配置放 `work/<任务名>/`,公共记录只保留脱敏结论。 - 记录提交或源码状态、JDK、Minecraft 与加载器版本、GT6CE 构建、依赖模组及版本、配置差异。 - 每条场景写清前置条件与操作、预期、实际、判定和平台;判定使用“未验证 / 部分验证 / 验证通过 / 已知失败”。 diff --git a/docs/integration/material-baseline.md b/docs/integration/material-baseline.md index f9590a979..d3e92b9f8 100644 --- a/docs/integration/material-baseline.md +++ b/docs/integration/material-baseline.md @@ -2,6 +2,8 @@ 本页记录[计划 01](../development/material-system-refactor/01-baseline.md)的观察口径、已审阅的历史引用和可重复测试入口。当前行为快照用于发现迁移变化;正确性依据另列,不能通过重录快照认可缺陷。 +专用的基线快照、独立 JVM 生命周期矩阵和测试附属材料在生产验证后已删除。本页数值与测试名称仅作为历史证据保留,当前代码不再生成这些投影。 + ## 范围与状态 源码基线为 `2e5627aa9da706416251ae83538a62cfc07a8783`,调查日期为 2026-11-07。本次新增测试、测试数据和文档,并独立清理形态表误抽取的一个局部变量键;没有改变实际材料、配方、初始化顺序、API 或持久化格式。开工已有未跟踪的重构计划和设计提议,均保留。工作期间外部修改 `.gitignore`,新增 `/docs` 忽略规则,也保留;新增文档因此不会自动出现在 Git 未跟踪列表中。 @@ -17,10 +19,10 @@ | 类型 | 存放位置 | 用途 | | --- | --- | --- | | 当前行为 | 根目录 `work/material-system-refactor/core/`、`runtime//<运行目录>/` | 全量材料、别名、引用、形态、成分、配方及代表案例;不提交原始 dump | -| 权威期望 | `MaterialBaselineTest`、`MaterialBaselineTests` 中注明依据的断言 | 固定 GT6 事实、现有 parity 决策、公开 SPI 契约 | +| 权威期望 | 当时基线测试中的断言与现行材料纯规则测试 | 固定 GT6 事实、现有 parity 决策、公开 SPI 契约 | | 已知差异 | 本页、测试中明确标记的 observation、测试资源中的历史引用清单 | 让后续修改显露差异;不赋予当前错误行为正确性 | -core 快照在独立 JVM 中各初始化一次,不提供生产 reset。无附属环境连续采集两次,比较材料、prefix、别名和引用四份排序后的 TSV;第三个 JVM 通过临时 ServiceLoader 资源加载测试附属,并验证内建材料投影不变。游戏测试附属由 test source set 的 SPI 服务文件发现,不要求安装真实联动模组。 +历史 core 快照在独立 JVM 中各初始化一次。无附属环境连续采集两次,比较材料、prefix、别名和引用四份排序后的 TSV;第三个 JVM 通过临时 ServiceLoader 资源加载测试附属。该入口和游戏测试附属均已移除,避免为一次性审计长期向测试运行注册额外材料。 材料投影区分原始对象、`resolve()` 后身份与有效性;内建 ID 保留,附属数值 ID 写为 `dynamic`,用所有者和注册名表示稳定身份。属性、别名和无语义集合排序,化学组成与副产物的顺序保留。物品组件排序前单列主材料;prefix 重量与实际生成物品分开,不生成全部材料与 prefix 的笛卡尔积。 @@ -30,7 +32,7 @@ core 快照在独立 JVM 中各初始化一次,不提供生产 reset。无附 ## 引用审计 -`MaterialReferenceAudit` 检查已提交的组成声明、分解 ID/name 行、形态表、UUM ID 集合和七类加工目标;组成表采用当前 literal bind 语法,并核对解析行数,语法变化不能静默漏行。仅看注册后对象会遗漏被 `bind` 跳过的输入,所以源表和有效图都检查。 +历史 `MaterialReferenceAudit` 检查已提交的组成声明、分解 ID/name 行、形态表、UUM ID 集合和七类加工目标;该测试工具已删除。下文的分类与数量只记录当时审计结果。 首次审阅 4,069 条引用后,移除 1 条误抽取行。最终审计 4,068 条:2,032 条直接有效、1,729 条可映射别名、307 条已解释的历史/停注引用;当前悬空引用与 ID/name 矛盾均为零。这些数量仅描述本次观察;测试不把固定总数当作永久容差。 @@ -38,7 +40,7 @@ core 快照在独立 JVM 中各初始化一次,不提供生产 reset。无附 - 有数值 ID 的停注材料从[现有移除决策](../decisions/parity/material-removal.md)读取,不能因为查不到就自动允许。 - 归一化后的 GT6 字段别名与当前注册名分别记录。能识别别名不代表生产 `MaterialForms.of` 一定命中了对应 fallback。 -- `material-reference-history.tsv` 逐条限定表、owner、字段、目标和 ID,并给出固定 GT6 的 `unused`/`deprecated`、未分配 ID 的 `valgem(0)` 或现有移除决策。它只标注已确认的历史行,不创建第二份生产材料事实,也不允许同名新引用出现在其他字段。 +- 历史 `material-reference-history.tsv` 逐条限定表、owner、字段、目标和 ID,并给出固定 GT6 的 `unused`/`deprecated`、未分配 ID 的 `valgem(0)` 或现有移除决策。该清单已随基线测试删除。 - `MaterialForms` 的 `rmaterial` 来自 GT6 `MT.create` 的局部变量 `rMaterial`,不是材料。作为独立小清理,仅删除提交表中的该行,然后开启“当前未知错误必须为零”的严格断言;没有用期望文件豁免它。原生成脚本不在仓库,固定 GT6 原始输入已核对,未臆造可再生成流程。此键没有有效材料和 `MaterialForms.count` 生产调用者,不涉及任何材料/物品移除、ID 或存档迁移;后续恢复生成器时须排除局部变量。 新增悬空引用、ID/name 矛盾、非法物品组件会失败。负例直接构造缺失材料引用、铁 ID 配铜名和负数材料量;缺失引用异常包含表、材料、字段和目标。另在 `work/` 编译独立负例探针,注入假引用后进程确实以 1 退出;正常输入的完整 core 测试随后恢复通过;负例未改动生产输入。历史清单不豁免这些负例。01 阶段保留的 `MaterialCompositionData` 等生成表因缺少可复现脚本未重写;02 随后将其运行时事实迁入规范目录并删除旧写入入口。 @@ -85,14 +87,14 @@ NeoForge 的 386 条移除全部来自 `gt.recipe.fermenter` 的药水相关行 ## 复现与执行记录 -所有命令从仓库根执行,标准命令与注意事项见 [JUnit](../development/validation/checks/junit.md)、[编译](../development/validation/checks/compile.md)、[GameTest](../development/validation/checks/gametest.md)和[格式](../development/validation/checks/format.md)。定向入口为: +所有命令从仓库根执行,标准命令与注意事项见 [JUnit](../development/validation/checks/junit.md)、[编译](../development/validation/checks/compile.md)、[GameTest](../development/validation/checks/gametest.md)和[格式](../development/validation/checks/format.md)。当前材料纯规则入口为: ```bash -./gradlew :core:test --tests 'gregtech.content.material.MaterialBaselineTest' +./gradlew :core:test --tests 'gregtech.engine.material.*' --tests 'gregtech.engine.recipe.MaterialDecompositionPlannerTest' ./gradlew :minecraft:1.20.1-forge:compileTestJava :minecraft:1.21.1-neoforge:compileTestJava ``` -GameTest 使用检查文档已有的 `gameTestDirectory` 指定不同隔离目录,避免第二次启动复用第一次的世界或配置。重复启动后逐文件比较排序的 TSV;跨版本物品以注册 ID 交集比较,版本独有物品另列,配方差异只作调查线索。 +基线 TSV 不再生成,因此不能继续运行后文的重复采集命令作为当前验收;保留的 `work/material-system-refactor/` 原始文件仅用于追溯历史结论。 默认开发环境会加载 JEI/Jade。无可选模组采集仅从 `runtimeOnly` 移除这两个查看器,保留全部编译 API,并核对实际加载列表只有 Minecraft、加载器和 GT6CE。复现时把下面内容保存到本地 `work/material-system-refactor/no-optional.init.gradle`: diff --git a/docs/integration/material-process-snapshot.md b/docs/integration/material-process-snapshot.md index 954bb1bd4..d5035d6d2 100644 --- a/docs/integration/material-process-snapshot.md +++ b/docs/integration/material-process-snapshot.md @@ -38,18 +38,15 @@ JEI 与 EMI 同装时,JEI 提前返回是已有桥接去重约定;本模组 python tools/validation/route.py check python tools/comments/check_comment_refs.py --diff HEAD git diff --check -./gradlew :minecraft:1.20.1-forge:runGameTestServer -PgameTestHeap=4g -PgameTestDirectory=../../../work/material-process-review/gametest-forge -./gradlew :minecraft:1.21.1-neoforge:runGameTestServer -PgameTestHeap=4g -PgameTestDirectory=../../../work/material-process-review/gametest-neoforge ``` -`MaterialProcessGraphTest` 包含循环、共同输入、前反向查询、各项预算、深度边界的端口截断及裁剪后的边合法性。`MaterialProcessSnapshotTests` 使用未发布到生产 Store 的小型原生行集,验证跨材料链、世界生成形态、普通共同原料、工具说明、物品/流体输出身份及快照引用隔离;另检查世界生成 revision 与相同上下文的索引复用。现有 `MaterialBaselineTests` 覆盖真实两次资源重载及成功发布戳。 - -原始日志位于本机忽略目录 `work/material-process-review/`,不随仓库提交。GameTest 用例数、平台与最终结果见下文;Gradle 退出成功不能代替游戏测试统计。 +`MaterialProcessGraphTest` 包含循环、共同输入、前反向查询、各项预算、深度边界的端口截断及裁剪后的边合法性。展示投影、世界生成形态、物品/流体状态和布局示例不再保留逐场景 GameTest;这些行为按[人工检查](../development/validation/checks/manual-ingame.md#矿物处理展示页)使用真实 JEI/EMI 验收。 ## 验证结果与剩余事项 -- 执行且通过:`MaterialProcessGraphTest` 7 项;API `SpecialProcessValueTest` 与 `apiContracts`;材料页单测覆盖全部形态直连、跨区边和停止于另一材料。GameTest 从实际加载的物品/流体标签系统确认王水 target tag 只含声明的 purified 形态,reagent tag 只含王水液体。Spotless、双平台生产/测试源码编译、双平台发行包组装、Forge 99 项 GameTest、NeoForge 104 项 GameTest、资源 JSON 与发行 JAR 检查、路由和注释检查均通过。 -- 执行但失败或阻塞:无。 -- 尚未执行:独立远程客户端、JEI-only/EMI-only/双装实际拖拽、工艺组展开与截图、无 viewer 的独立客户端、附属差异与世界生成开关矩阵。 +以下 GameTest 结果是移除一次性展示快照测试前的历史证据,不能代表当前测试数。当前常驻的纯规则入口为 `MaterialProcessGraphTest`,客户端展示仍需人工验收。 + +- 历史执行且通过:`MaterialProcessGraphTest`、API `SpecialProcessValueTest`、`apiContracts`,以及清理前 Forge 99 项、NeoForge 104 项 GameTest。 +- 尚未执行:独立远程客户端、JEI-only/EMI-only/双装实际拖拽、路线折叠、全屏、无 viewer 的独立客户端、附属差异与世界生成开关矩阵。 08 的 A—C 已有定义与形态入口;D—E 已有内部来源/用途快照、符号选择器、共享材料页图和 API 1.9 的显式特殊工艺所有权。tag/unit 仍保持符号投影,不能声称枚举了全部动态工艺或完整可执行路线;本轮不新增网络同步协议。远程同代数据、断线/换服、实际 viewer 拖拽/折叠与精确跳转仍需要按[人工检查](../development/validation/checks/manual-ingame.md#矿物处理展示页)记录实际结果。局部图模型通过不能替代这些场景。 diff --git a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java b/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java deleted file mode 100644 index d6c702cf6..000000000 --- a/minecraft/src/test/java/gregtech/content/recipe/MaterialProcessSnapshotTests.java +++ /dev/null @@ -1,1149 +0,0 @@ -package gregtech.content.recipe; - -import gregtech.content.material.Materials; -import gregtech.content.registry.GTFluids; -import gregtech.content.worldgen.MaterialWorldgenFacts; -import gregtech.content.worldgen.MaterialWorldgenFacts.Fact; -import gregtech.content.worldgen.MaterialWorldgenFacts.Kind; -import gregtech.content.worldgen.MaterialWorldgenFacts.Ore; -import gregtech.engine.material.MaterialProcessGraph.*; -import gregtech.engine.material.MaterialEquivalence; -import gregtech.engine.material.MaterialPublication; -import gregtech.engine.material.MaterialViews; -import gregtech.engine.recipe.Recipe; -import gregtech.engine.recipe.RecipeMap; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; -import net.minecraft.gametest.framework.GameTest; -import net.minecraft.gametest.framework.GameTestHelper; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.material.Fluids; -//? if >=1.21.1 { -/*import net.neoforged.neoforge.fluids.FluidStack; -import net.neoforged.neoforge.gametest.GameTestHolder; -import net.neoforged.neoforge.gametest.PrefixGameTestTemplate; -*///?} else { -import net.minecraftforge.gametest.GameTestHolder; -import net.minecraftforge.gametest.PrefixGameTestTemplate; -import net.minecraftforge.fluids.FluidStack; -//?} - -@GameTestHolder("gt6ce") -@PrefixGameTestTemplate(false) -public final class MaterialProcessSnapshotTests { - private MaterialProcessSnapshotTests() {} - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void relatedInformationStaysBelowSourcesWithoutProcessingEdges(GameTestHelper helper) { - var source = new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "information_source"), - net.minecraft.network.chat.Component.literal("source"), new ItemStack(Items.FURNACE), - List.of(displayPort("source_input", "Other", Items.IRON_INGOT, false)), - List.of(displayPort("source_output", "Copper", Items.COPPER_INGOT, true)), - List.of(), java.util.Optional.empty(), true); - var reference = new gregtech.api.addon.material.DataKey("test", "information"); - var information = new gregtech.compat.common.MaterialProcessDisplay.Information(reference, - net.minecraft.network.chat.Component.literal("Reference"), new ItemStack(Items.BOOK), List.of(), - List.of(displayPort("information_copper", "Copper", Items.COPPER_BLOCK, true), - displayPort("information_iron", "Iron", Items.IRON_BLOCK, true))); - var page = layoutPage(List.of(source), List.of()).withInformation(List.of(information)); - var graph = new gregtech.compat.common.MaterialProcessOverview(page); - var card = graph.information().get(0); - helper.assertTrue(graph.nodes().size() == 3 && graph.edges().size() == 2 && page.connections().isEmpty(), - "related information does not add processing nodes or edges"); - helper.assertTrue(card.top() > graph.nodes().stream().mapToInt(node -> node.y + 12).max().orElseThrow() - && card.bottom() <= graph.height(), - "information is below the source routes and included in the canvas bounds"); - helper.assertTrue(page.indexedPorts().stream().anyMatch(port -> port.icons().get(0).is(Items.COPPER_BLOCK)) - && page.indexedPorts().stream().noneMatch(port -> port.material().equals("Iron")), - "information references are searchable only within the page material"); - var onlyInformation = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(), List.of()) - .withInformation(List.of(information))); - helper.assertTrue(onlyInformation.nodes().isEmpty() && onlyInformation.edges().isEmpty() - && onlyInformation.bands().get(0).section() == gregtech.compat.common.MaterialProcessDisplay.Section.SOURCES - && onlyInformation.information().size() == 1, - "materials with only reference pages still have an information area in sources"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void viewerRecipesSelectNativeRowsAndIncludeCrafting(GameTestHelper helper) { - var visible = row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, Items.COPPER_INGOT); - var hidden = row(new ItemStack[] {new ItemStack(Items.PAPER)}, Items.GOLD_INGOT); - var map = new RecipeMap(new ArrayList<>(List.of(visible, hidden)), - "gt.test.process.viewer", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, - false, false, false, false); - RecipeMap.unregister(map); - var ores = List.of(new Ore(Materials.Iron, "item:minecraft:iron_nugget", 0, 20, 1, 0, List.of())); - var facts = new MaterialWorldgenFacts.Snapshot(List.of( - new Fact("viewer_test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 1, ores))); - var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, facts, List.of(map)); - var builder = source.viewerBuilder(); - builder.machine(map, visible); - builder.machine(map, visible); - var reference = new gregtech.api.addon.material.DataKey("test", "crafting/iron_block"); - builder.recipe(reference, "Crafting", new ItemStack(Items.CRAFTING_TABLE), - List.of(builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 9, java.util.OptionalInt.empty())), - List.of(builder.item(new ItemStack(Items.IRON_BLOCK), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000))), List.of()); - var view = builder.build(); - var root = view.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); - var query = view.queryMaterial(root.resource(), new Budgets(0, 32, 32, 32)); - helper.assertTrue(query.steps().size() == 3 && query.steps().stream().filter(step -> view.recipe(step.reference()).isPresent()).count() == 1, - "the viewer owns machine admission, deduplicates native rows and retains real worldgen"); - helper.assertTrue(view.roots().stream().noneMatch(value -> value.material().equals("Gold")), - "a machine row absent from the viewer does not leak back from the global tables"); - var page = gregtech.compat.common.MaterialProcessProjection.pages(view, root.resource(), - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); - var crafting = page.steps().stream().filter(step -> step.reference().equals(reference)).findFirst().orElseThrow(); - helper.assertTrue(crafting.icon().is(Items.CRAFTING_TABLE) && crafting.inputs().get(0).quantity().getString().equals("9"), - "crafting routes retain their workstation and native input batch"); - helper.assertTrue(source.roots().stream().anyMatch(value -> value.material().equals("Gold")), - "a viewer projection never changes the published server snapshot"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void viewerAlternativesRemainOneStatefulSelector(GameTestHelper helper) { - var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); - var builder = source.viewerBuilder(); - var stateful = new ItemStack(Items.IRON_INGOT); - var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(stateful); - data.putString("viewer_test", "native_state"); - gregtech.content.data.UsbDataMedia.store(stateful, data); - var selector = builder.alternatives(List.of( - builder.item(stateful, Role.CONSUMED, 2, java.util.OptionalInt.empty()), - builder.item(new ItemStack(Items.IRON_NUGGET), Role.CONSUMED, 2, java.util.OptionalInt.empty()))); - var mixed = builder.alternatives(List.of( - builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()), - builder.item(new ItemStack(Items.COPPER_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()))); - helper.assertTrue(selector.resource().material().equals("Iron") && mixed.resource().material().equals("unknown"), - "one material may be attributed only when every alternative agrees"); - var reference = new gregtech.api.addon.material.DataKey("test", "external/selector"); - builder.recipe(reference, "External processing", new ItemStack(Items.FURNACE), List.of(selector), - List.of(builder.item(new ItemStack(Items.COPPER_INGOT), Role.UNKNOWN, 3, java.util.OptionalInt.of(2500))), List.of()); - var view = builder.build(); - var root = view.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); - var page = gregtech.compat.common.MaterialProcessProjection.pages(view, root.resource(), - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); - var step = page.steps().get(0); - helper.assertTrue(step.inputs().size() == 1 && step.inputs().get(0).icons().size() == 2 && !step.resolved(), - "alternatives stay a single unresolved selector rather than joint requirements"); - helper.assertTrue(gregtech.engine.stack.StackCompat.sameItem(step.inputs().get(0).icons().get(0), stateful) - && step.outputs().get(0).chance().orElseThrow() == 2500, - "external stacks keep their complete native state and output chance"); - view.viewerIcons(selector.resource().key()).get(0).setCount(12); - helper.assertTrue(view.viewerIcons(selector.resource().key()).get(0).getCount() == 1, - "native viewer representatives are copied on access"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void viewerKeepsNativeUnitTemplatesAndUnconfirmedProcessing(GameTestHelper helper) { - var template = row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, Items.COPPER_INGOT) - .withMaterialInputDisplay(0, gregtech.api.material.GTValues.U, - List.of(new ItemStack(Items.IRON_INGOT)), gregtech.api.addon.recipe.MaterialUnitIngredient.Rounding.EXACT_RATIO); - template.mFakeRecipe = true; - var referenceOnly = row(new ItemStack[] {new ItemStack(Items.GOLD_INGOT)}, Items.COPPER_INGOT); - referenceOnly.mFakeRecipe = true; - var map = new RecipeMap(new ArrayList<>(List.of(template, referenceOnly)), - "gt.test.process.unit_viewer", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, - false, false, false, false); - RecipeMap.unregister(map); - var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of(map)); - var builder = source.viewerBuilder(); - helper.assertTrue(builder.machine(map, template) && builder.machine(map, template) - && !builder.machine(map, referenceOnly), - "unit templates are processing rows, while fake reference rows remain information"); - var reference = new gregtech.api.addon.material.DataKey("test", "viewer/manual_processing"); - builder.recipe(reference, "Manual", new ItemStack(Items.CRAFTING_TABLE), - List.of(builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty())), - List.of(builder.item(new ItemStack(Items.IRON_BLOCK), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000))), - List.of(), false); - var view = builder.build(); - var root = view.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); - var query = view.queryMaterial(root.resource(), new Budgets(0, 32, 32, 32)); - helper.assertTrue(query.steps().size() == 2 && query.steps().stream() - .filter(step -> view.recipe(step.reference()).isPresent()).count() == 1, - "native templates are not duplicated and manual transformations remain graph steps"); - var nativeStep = query.steps().stream().filter(step -> view.recipe(step.reference()).isPresent()).findFirst().orElseThrow(); - helper.assertTrue(nativeStep.inputs().get(0).amount().unit() == AmountUnit.MATERIAL_UNIT - && nativeStep.inputs().get(0).amount().value() == gregtech.api.material.GTValues.U, - "the native unit quantity survives admission without converting to a representative item count"); - helper.assertTrue(query.steps().stream().filter(step -> step.reference().equals(reference)).noneMatch(Step::resolved), - "a viewer's non-tree transformation does not acquire confirmed recipe-tree semantics"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void viewerProjectionKeepsLargeRecipesAndExplicitBudgets(GameTestHelper helper) { - var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); - var builder = source.viewerBuilder(); - var outputs = new ArrayList(); - var inputs = new ArrayList(); - for (int index = 0; index < 160; index++) { - var stack = new ItemStack(Items.IRON_INGOT); - var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(stack); - data.putInt("process_port", index); - gregtech.content.data.UsbDataMedia.store(stack, data); - outputs.add(builder.item(stack, Role.UNKNOWN, 1, java.util.OptionalInt.of(10000))); - inputs.add(0, builder.item(stack, Role.CONSUMED, 1, java.util.OptionalInt.empty())); - } - builder.recipe(new gregtech.api.addon.material.DataKey("test", "bounded_producer"), "Producer", new ItemStack(Items.FURNACE), - List.of(builder.item(new ItemStack(Items.COPPER_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty())), outputs, List.of()); - builder.recipe(new gregtech.api.addon.material.DataKey("test", "bounded_consumer"), "Consumer", new ItemStack(Items.CRAFTING_TABLE), - inputs, List.of(builder.item(new ItemStack(Items.IRON_BLOCK), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000))), List.of()); - var view = builder.build(); - var pages = gregtech.compat.common.MaterialProcessProjection.initialPages(view, - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE); - var page = pages.stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); - helper.assertTrue(page.steps().size() == 2 && page.connections().isEmpty() && page.flows().size() == 160 - && page.flows().stream().mapToLong(gregtech.compat.common.MaterialProcessDisplay.Flow::connectionCount).sum() == 160, - "material pages retain all large-recipe associations as resource groups"); - helper.assertTrue(page.steps().stream().allMatch(step -> step.inputs().size() <= 160 - && step.outputs().size() <= 160), - "large viewer recipes keep their complete input and output lists"); - var root = view.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); - var query = view.queryMaterial(root.resource(), new Budgets(0, 512, 128, 4096)); - helper.assertTrue(query.truncated() && query.notices().stream() - .anyMatch(notice -> notice.code().equals("port_limit") && notice.omitted() == 64), - "explicitly bounded queries still report discarded ports"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void presentationPreservesNativeItemState(GameTestHelper helper) { - var input = new ItemStack(Items.IRON_INGOT); - var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(input); - data.putString("process_test", "stateful_input"); - gregtech.content.data.UsbDataMedia.store(input, data); - var recipe = row(new ItemStack[] {input}, Items.COPPER_INGOT); - var map = new RecipeMap(new ArrayList<>(List.of(recipe)), - "gt.test.process.presentation", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, - false, false, false, false); - RecipeMap.unregister(map); - var snapshot = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of(map)); - var root = snapshot.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); - var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, root.resource(), - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE); - var displayInput = pages.get(0).steps().get(0).inputs().get(0); - helper.assertTrue(gregtech.engine.stack.StackCompat.sameItem(displayInput.icons().get(0), input), - "presentation keeps the native item data instead of reconstructing an untagged icon"); - helper.assertTrue(displayInput.identity().equals(MaterialProcessSnapshot.itemDisplayState(input)), - "display identity preserves native state independently of snapshot references"); - var hammer = gregtech.compat.jei.RecipeMachines.collect().get(gregtech.content.data.MachineRecipeMaps.Hammer); - var hammerIcon = gregtech.compat.common.RecipeViewerIcons.categories().get(gregtech.content.data.MachineRecipeMaps.Hammer); - helper.assertTrue(hammer != null && !hammer.isEmpty() && hammerIcon != null && !hammerIcon.isEmpty() - && gregtech.engine.stack.StackCompat.sameItem(hammer.get(0), hammerIcon), - "hammer processes reuse the native viewer category icon instead of a partial workstation lookup"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewGroupsVisibleRoutesAndHidesAuxiliaries(GameTestHelper helper) { - var steps = new ArrayList(); - for (int variant = 0; variant < 3; variant++) { - var input = displayPort("selector_" + variant, "Copper", Items.COPPER_INGOT, false); - var lubricant = displayPort("lubricant_" + variant, "Other", Items.WATER_BUCKET, false); - var output = displayPort("output_" + variant, "Copper", Items.COPPER_BLOCK, true); - steps.add(new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "cutting_" + variant), - net.minecraft.network.chat.Component.literal("cutter"), new ItemStack(Items.STONECUTTER), - List.of(input, lubricant), List.of(output), List.of(), java.util.Optional.empty(), true)); - } - var page = gregtech.compat.common.MaterialProcessDisplay.pages( - net.minecraft.network.chat.Component.literal("Copper"), "Copper", steps, List.of(), - List.of(net.minecraft.network.chat.Component.literal("test")), - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); - var overview = new gregtech.compat.common.MaterialProcessOverview(page); - helper.assertTrue(overview.nodes().size() == 3 && overview.edges().size() == 2, - "visually identical A-machine-B routes merge across native selectors"); - var machine = overview.nodes().stream().filter(node -> node.machine()).findFirst().orElseThrow(); - helper.assertTrue(machine.steps.size() == 3 && machine.extra(), - "every original recipe survives behind one route and its plus marker"); - helper.assertTrue(overview.edges().stream().allMatch(edge -> edge.endpoints().size() == 3), - "merged wires retain all original port associations"); - helper.assertTrue(overview.nodes().stream().filter(node -> !node.machine()) - .noneMatch(node -> node.port().material().equals("Other") || node.copy), - "auxiliaries stay hidden and identical resources remain shared"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewFoldsSimilarRoutesAcrossNativeRecipeDifferences(GameTestHelper helper) { - var alternatives = new ArrayList(); - for (int index = 0; index < 4; index++) { - var output = layoutPort("bark", true); - var variableOutput = new gregtech.compat.common.MaterialProcessDisplay.Port( - output.resource(), output.material(), output.name(), output.icons(), output.role(), false, - output.amount(), net.minecraft.network.chat.Component.literal(Integer.toString(index + 1)), - java.util.OptionalInt.of(2500 * (index + 1)), output.details(), output.identity()); - var inputs = new ArrayList<>(List.of(layoutPort("wood_" + index, false), - displayPort("lubricant_" + index, "Other", index % 2 == 0 ? Items.WATER_BUCKET : Items.LAVA_BUCKET, false))); - if (index == 1) inputs.add(layoutPort("extra_wood", false)); - alternatives.add(new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "wood_" + index), - net.minecraft.network.chat.Component.literal("cutter"), new ItemStack(Items.STONECUTTER), inputs, - index == 3 ? List.of(variableOutput, layoutPort("wood_dust", true)) : List.of(variableOutput), - List.of(), java.util.Optional.empty(), true)); - } - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(alternatives, List.of())); - var machines = graph.nodes().stream().filter(node -> node.machine()).toList(); - helper.assertTrue(machines.size() == 2 && machines.stream().mapToInt(node -> node.steps.size()).sum() == 4, - "auxiliaries and yields do not split equal visible outputs, but an additional local output does"); - helper.assertTrue(graph.grids().stream().anyMatch(grid -> grid.members.size() == 4) - && graph.grids().stream().anyMatch(grid -> grid.members.size() == 2), - "alternative inputs and variant products remain visible beside the shared machine"); - helper.assertTrue(graph.nodes().stream().filter(node -> !node.machine()) - .anyMatch(node -> node.port().identity().equals("bark") && node.chanceBadge().equals("25%/50%/75%")), - "a shared product preserves the different native probabilities"); - for (var step : alternatives) for (boolean output : List.of(false, true)) { - var ports = output ? step.outputs() : step.inputs(); - for (var port : ports) helper.assertTrue( - machines.stream().anyMatch(machine -> machine.endpoints.stream().anyMatch(endpoint -> endpoint.step() == step && endpoint.port() == port) - || machine.auxiliaries.contains(port)), - "every original port survives visual folding"); - } - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewFoldsSharedInputsWithoutJoiningUnrelatedRoutes(GameTestHelper helper) { - var steps = new ArrayList(); - for (int index = 0; index < 18; index++) steps.add(layoutStep("plate_" + index, "plate", "component_" + index)); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); - var machines = graph.nodes().stream().filter(node -> node.machine()).toList(); - helper.assertTrue(machines.size() == 1 && machines.get(0).steps.size() == 18 - && graph.grids().stream().anyMatch(grid -> grid.members.size() == 18), - "the same material input and process share one machine and a grid of alternative products"); - helper.assertTrue(machines.get(0).endpoints.size() == 36, - "input-based folding retains every original input and output association"); - java.util.Collections.reverse(steps); - helper.assertTrue(layoutPositions(graph).equals(layoutPositions( - new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())))), - "input-based folding is stable across recipe registration order"); - var crossing = List.of(layoutStep("ax", "a", "x"), layoutStep("ay", "a", "y"), layoutStep("by", "b", "y")); - var separate = new gregtech.compat.common.MaterialProcessOverview(layoutPage(crossing, List.of())); - helper.assertTrue(separate.nodes().stream().filter(node -> node.machine()).count() == 2 - && separate.nodes().stream().filter(node -> node.machine()).noneMatch(node -> node.steps.size() == 3), - "shared-side groups do not transitively suggest a nonexistent b-to-x route"); - var other = layoutStep("other", "plate", "component_0"); - var differentProcess = new gregtech.compat.common.MaterialProcessDisplay.Step(other.reference(), - other.name(), other.icon(), other.inputs(), other.outputs(), - List.of(), java.util.Optional.empty(), true, false, false, "test:other_process"); - var kinds = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(steps.get(0), differentProcess), List.of())); - helper.assertTrue(kinds.nodes().stream().filter(node -> node.machine()).count() == 1, - "hidden process identifiers do not split routes with the same visible machine and inputs"); - var localized = new gregtech.compat.common.MaterialProcessDisplay.Step(other.reference(), - net.minecraft.network.chat.Component.literal("another translation"), other.icon(), other.inputs(), other.outputs(), - List.of(), java.util.Optional.empty(), true, false, false, "cutting"); - helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(steps.get(0), localized), List.of())) - .nodes().stream().filter(node -> node.machine()).count() == 1, - "translated labels do not change visible shared-input grouping"); - var jointA = layoutStep("joint_a", "plate", "x"); - var jointB = layoutStep("joint_b", "plate", "y"); - var joint = new ArrayList(); - for (var entry : List.of(jointA, jointB)) joint.add(new gregtech.compat.common.MaterialProcessDisplay.Step( - entry.reference(), entry.name(), entry.icon(), List.of(entry.inputs().get(0), - layoutPort(entry == jointA ? "rod" : "gear", false)), entry.outputs(), - List.of(), java.util.Optional.empty(), true)); - helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(joint, List.of())) - .nodes().stream().filter(node -> node.machine()).count() == 2, - "one shared ingredient does not stand in for the complete visible co-input set"); - helper.succeed(); - } - - private static gregtech.compat.common.MaterialProcessDisplay.Port displayPort( - String reference, String material, net.minecraft.world.item.Item item, boolean output) { - var name = net.minecraft.network.chat.Component.literal(reference); - var icon = new ItemStack(item); - return new gregtech.compat.common.MaterialProcessDisplay.Port( - new gregtech.api.addon.material.DataKey("test", reference), material, name, List.of(icon), - output ? gregtech.compat.common.MaterialProcessDisplay.Role.UNKNOWN - : gregtech.compat.common.MaterialProcessDisplay.Role.CONSUMED, - false, name, name, java.util.OptionalInt.of(10000), List.of(), MaterialProcessSnapshot.itemDisplayState(icon)); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewUsesCompleteVisibleSidesAndReliableMachineIcons(GameTestHelper helper) { - var first = layoutStep("visible_first", "a", "x"); - var second = layoutStep("visible_second", "b", "x"); - var extra = new gregtech.compat.common.MaterialProcessDisplay.Step(second.reference(), second.name(), second.icon(), - second.inputs(), List.of(second.outputs().get(0), layoutPort("y", true)), List.of(), java.util.Optional.empty(), true); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(first, extra), List.of())); - helper.assertTrue(graph.nodes().stream().filter(node -> node.machine()).count() == 2, - "a shared first output never hides a different visible output set"); - var unknown = new ArrayList(); - for (var row : List.of(first, second)) unknown.add(new gregtech.compat.common.MaterialProcessDisplay.Step( - row.reference(), row.name(), ItemStack.EMPTY, row.inputs(), row.outputs(), List.of(), java.util.Optional.empty(), true)); - helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(unknown, List.of())).nodes().stream() - .filter(node -> node.machine()).count() == 2, - "two missing machine icons are not evidence for visual folding"); - var changed = new gregtech.compat.common.MaterialProcessDisplay.Step(second.reference(), second.name(), first.icon(), - second.inputs(), second.outputs(), List.of(net.minecraft.network.chat.Component.literal("hidden condition")), - java.util.Optional.of(new gregtech.compat.common.MaterialProcessDisplay.SpecialProcess( - new gregtech.api.addon.material.DataKey("test", "hidden_method"), net.minecraft.network.chat.Component.literal("method"))), - true, false, false, "different:process"); - helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(first, changed), List.of())).nodes().stream() - .filter(node -> node.machine()).count() == 1, - "hidden methods, conditions and process identifiers do not split equal visible routes"); - var stateful = second.icon(); - var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(stateful); - data.putInt("machine_state", 1); - gregtech.content.data.UsbDataMedia.store(stateful, data); - var differentMachine = new gregtech.compat.common.MaterialProcessDisplay.Step(second.reference(), second.name(), stateful, - second.inputs(), second.outputs(), List.of(), java.util.Optional.empty(), true); - helper.assertTrue(new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(first, differentMachine), List.of())).nodes().stream() - .filter(node -> node.machine()).count() == 2, - "machine icons retain their complete native state when folding"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void invalidDisplayRowsAndLinksDoNotInterruptThePage(GameTestHelper helper) { - var source = layoutStep("clean_source", "raw", "dust"); - var target = layoutStep("clean_target", "dust", "ingot"); - var malformed = new gregtech.compat.common.MaterialProcessDisplay.Step(target.reference(), target.name(), target.icon(), - java.util.Arrays.asList(target.inputs().get(0), source.outputs().get(0), null), target.outputs(), - List.of(), java.util.Optional.empty(), true); - var validLink = layoutConnection("clean_source", "clean_target", "dust"); - var page = new gregtech.compat.common.MaterialProcessDisplay.Page( - net.minecraft.network.chat.Component.literal("Copper"), "Copper", - java.util.Arrays.asList(source, malformed, source, null), - java.util.Arrays.asList(validLink, validLink, layoutConnection("missing", "clean_target", "dust"), - layoutConnection("clean_source", "clean_target", "raw"), null), - List.of(), 0, 0, gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE); - helper.assertTrue(page.steps().size() == 2 && page.connections().equals(List.of(validLink)), - "invalid and duplicate records are removed while valid steps and links survive"); - helper.assertTrue(malformed.inputs().equals(target.inputs()) && !malformed.resolved(), - "removing invalid ports does not claim that the remaining recipe is fully resolved"); - helper.assertTrue(page.number() == 1 && page.total() == 1 && !page.notices().isEmpty(), - "missing page hints fall back to partial coverage without aborting registration"); - new gregtech.compat.common.MaterialProcessOverview(page); - var icons = new ArrayList(); - for (int index = 0; index < 24; index++) icons.add(new ItemStack(Items.IRON_INGOT)); - icons.add(ItemStack.EMPTY); - var port = new gregtech.compat.common.MaterialProcessDisplay.Port(source.outputs().get(0).resource(), "Copper", - source.name(), icons, gregtech.compat.common.MaterialProcessDisplay.Role.UNKNOWN, false, source.name(), - java.util.OptionalInt.of(-1), List.of()); - helper.assertTrue(port.iconCount() == 24 && port.chance().isEmpty(), - "supplied representatives survive while empty icons and invalid chance values are removed"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void projectionKeepsLargePagesWithoutExpandingConnections(GameTestHelper helper) { - var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); - var builder = source.viewerBuilder(); - var ironIn = builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()); - var ironOut = builder.item(new ItemStack(Items.IRON_INGOT), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000)); - for (int index = 0; index < 600; index++) - builder.recipe(new gregtech.api.addon.material.DataKey("test", "many_rows/" + index), "Source", new ItemStack(Items.FURNACE), - List.of(), List.of(ironOut), List.of()); - for (int index = 0; index < 8; index++) - builder.recipe(new gregtech.api.addon.material.DataKey("test", "many_uses/" + index), "Use", new ItemStack(Items.STONECUTTER), - List.of(ironIn), List.of(), List.of()); - var snapshot = builder.build(); - var root = snapshot.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); - var page = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, root.resource(), - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); - helper.assertTrue(page.steps().size() == 608 && page.connections().isEmpty() && page.flows().size() == 1 - && page.flows().get(0).connectionCount() == 4800, - "material pages retain all direct rows and dense associations without allocating pairwise links"); - helper.assertTrue(gregtech.compat.common.MaterialProcessProjection.indexedPorts(snapshot, root.resource()).size() == 2, - "viewer registration indexes each resource and role once instead of every recipe occurrence"); - var graph = new gregtech.compat.common.MaterialProcessOverview(page); - helper.assertTrue(graph.flows().equals(page.flows()), "compact native associations survive the layout unchanged"); - helper.assertTrue(graph.nodes().stream().filter(node -> node.machine()).mapToInt(node -> node.steps.size()).sum() == 608, - "folding a large page retains every original recipe reference"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void compactFlowsKeepUnconfirmedSourcesAcrossMaterialSections(GameTestHelper helper) { - var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); - var builder = source.viewerBuilder(); - var ironIn = builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()); - var ironOut = builder.item(new ItemStack(Items.IRON_INGOT), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000)); - var copperIn = builder.item(new ItemStack(Items.COPPER_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()); - var copperOut = builder.item(new ItemStack(Items.COPPER_INGOT), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000)); - for (int index = 0; index < 2; index++) - builder.recipe(new gregtech.api.addon.material.DataKey("test", "flow_source_" + index), "Source", new ItemStack(Items.FURNACE), - List.of(copperIn), List.of(ironOut), List.of(), index == 0); - var target = new gregtech.api.addon.material.DataKey("test", "flow_target"); - builder.recipe(target, "Use", new ItemStack(Items.STONECUTTER), List.of(ironIn), List.of(copperOut), List.of()); - var snapshot = builder.build(); - var root = snapshot.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); - var page = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, root.resource(), - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); - var flow = page.flows().get(0); - helper.assertTrue(flow.sources().size() == 2 && flow.targets().equals(List.of(target)) && flow.connectionCount() == 2, - "a compact resource group keeps both exact source associations"); - var graph = new gregtech.compat.common.MaterialProcessOverview(page); - helper.assertTrue(graph.bands().size() == 2 && graph.edges().stream() - .filter(edge -> !edge.endpoint().output() && edge.endpoint().step().reference().equals(target)) - .noneMatch(edge -> edge.confirmed()), - "an unconfirmed source keeps its consuming ports dashed across section boundaries"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void invalidNativeRecipeDoesNotDiscardOtherSnapshotRows(GameTestHelper helper) { - var valid = row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, Items.COPPER_INGOT); - var broken = row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, Items.COPPER_BLOCK); - broken.mChances[0] = -1; - var rows = new ArrayList<>(List.of(valid, broken)); - var map = new RecipeMap(rows, - "gt.test.process.invalid", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, - false, false, false, false); - RecipeMap.unregister(map); - rows.add(null); - var snapshot = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of(map)); - var root = snapshot.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); - var query = snapshot.queryMaterial(root.resource(), Budgets.MATERIAL_PAGE); - helper.assertTrue(query.steps().size() == 1 && snapshot.recipe(query.steps().get(0).reference()).orElseThrow().recipe() == valid, - "a malformed native recipe is isolated without losing the valid recipe generation"); - helper.assertTrue(query.notices().stream().anyMatch(notice -> notice.code().equals("invalid_process_data") && notice.omitted() == 2), - "excluded native rows retain an explicit coverage notice"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void rejectedViewerRowsDoNotHideValidMaterialRoots(GameTestHelper helper) { - var source = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of()); - var builder = source.viewerBuilder(); - var iron = builder.item(new ItemStack(Items.IRON_INGOT), Role.CONSUMED, 1, java.util.OptionalInt.empty()); - var copper = builder.item(new ItemStack(Items.COPPER_INGOT), Role.UNKNOWN, 1, java.util.OptionalInt.of(10000)); - var valid = new gregtech.api.addon.material.DataKey("test", "valid_root_recipe"); - builder.recipe(valid, "Valid", new ItemStack(Items.FURNACE), List.of(iron), List.of(copper), List.of()); - var rejected = new gregtech.api.addon.material.DataKey("test", "rejected_root_recipe"); - var ore = new Resource(new gregtech.api.addon.material.DataKey("test", "rejected_preferred_root"), - "Iron", "ore", "solid", "item:test:ore"); - var conflict = new Resource(copper.resource().key(), "Copper", "dust", "solid", "item:test:conflict"); - builder.recipe(rejected, "Invalid", new ItemStack(Items.FURNACE), - List.of(new Port(ore, Role.CONSUMED, iron.amount(), iron.chance(), true, List.of())), - List.of(new Port(conflict, Role.UNKNOWN, copper.amount(), copper.chance(), true, List.of())), List.of()); - var snapshot = builder.build(); - var root = snapshot.roots().stream().filter(value -> value.material().equals("Iron")).findFirst().orElseThrow(); - var query = snapshot.queryMaterial(root.resource(), Budgets.MATERIAL_PAGE); - helper.assertTrue(root.resource().equals(iron.resource().key()) && query.steps().size() == 1 - && query.steps().get(0).reference().equals(valid) && snapshot.resource(ore.key()).isEmpty(), - "a rejected preferred root falls back to a valid resource without leaving partial recipe data"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewIndexesOnlyItsOwnMaterialAndFindsNativeFocus(GameTestHelper helper) { - var input = displayPort("copper_input", "Copper", Items.COPPER_INGOT, false); - var output = displayPort("copper_output", "Copper", Items.COPPER_BLOCK, true); - var auxiliary = displayPort("water", "Other", Items.WATER_BUCKET, false); - var byproduct = displayPort("gold", "Gold", Items.GOLD_INGOT, true); - var catalyst = new gregtech.compat.common.MaterialProcessDisplay.Port( - auxiliary.resource(), auxiliary.material(), auxiliary.name(), auxiliary.icons(), - gregtech.compat.common.MaterialProcessDisplay.Role.CATALYST, false, auxiliary.amount(), - auxiliary.quantity(), auxiliary.chance(), auxiliary.details(), auxiliary.identity()); - var step = new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "indexed"), - net.minecraft.network.chat.Component.literal("indexed"), new ItemStack(Items.STONECUTTER), - List.of(input, auxiliary, catalyst), List.of(output, byproduct), List.of(), java.util.Optional.empty(), true); - var page = layoutPage(List.of(step), List.of()); - helper.assertTrue(page.indexedPorts().equals(List.of(input, output)), - "foreign reagents, catalysts and byproducts cannot make this material page appear in their lookups"); - - var stateful = new ItemStack(Items.COPPER_BLOCK); - var data = gregtech.content.data.UsbDataMedia.tagOrEmpty(stateful); - data.putString("process_test", "focused_state"); - gregtech.content.data.UsbDataMedia.store(stateful, data); - var nativeOutput = new gregtech.compat.common.MaterialProcessDisplay.Port( - new gregtech.api.addon.material.DataKey("test", "stateful_output"), output.material(), output.name(), - List.of(stateful), output.role(), false, output.amount(), output.quantity(), output.chance(), - output.details(), MaterialProcessSnapshot.itemDisplayState(stateful)); - var statefulStep = new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "native_focus"), step.name(), step.icon(), - List.of(input), List.of(nativeOutput), List.of(), java.util.Optional.empty(), true); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(step, statefulStep), List.of())); - var focus = graph.find(port -> port.identity().equals(nativeOutput.identity())); - helper.assertTrue(focus != null && gregtech.engine.stack.StackCompat.sameItem(focus.port().icons().get(0), stateful), - "lookup focus selects the requested form and full native state rather than its untagged icon"); - helper.assertTrue(graph.matchingNodes(focus).size() == 1, - "equal item icons with different native state remain separate hover targets"); - helper.assertTrue(graph.find(port -> port.identity().equals("absent")) == null, - "unmatched lookups can fall back to the material anchor"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewMatchesItemsAcrossCopiesAndKeepsRecipesSeparate(GameTestHelper helper) { - var source = new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "source"), - net.minecraft.network.chat.Component.literal("source"), new ItemStack(Items.FURNACE), - List.of(displayPort("external_ore", "Other", Items.RAW_COPPER, false)), List.of(layoutPort("raw", true)), - List.of(), java.util.Optional.empty(), true); - var branch = layoutStep("branch", "raw", "plate", "pressing"); - branch = new gregtech.compat.common.MaterialProcessDisplay.Step(branch.reference(), branch.name(), branch.icon(), - List.of(branch.inputs().get(0), layoutPort("plate_blank", false)), branch.outputs(), - List.of(), java.util.Optional.empty(), true); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage( - List.of(source, layoutStep("convert", "raw", "ingot"), branch), - List.of(layoutConnection("source", "convert", "raw"), layoutConnection("source", "branch", "raw")))); - var raw = graph.find(port -> port.identity().equals("raw")); - var matching = graph.matchingNodes(raw); - helper.assertTrue(matching.size() > 1 && matching.stream().allMatch(node -> !node.machine() - && node.port().identity().equals("raw")), - "hover matches the same resource across section copies without highlighting machines or production lines"); - var machine = graph.nodes().stream().filter(node -> node.machine() && node.steps.get(0).reference().path().equals("convert")) - .findFirst().orElseThrow(); - helper.assertTrue(graph.matchingNodes(machine).size() == 2 - && graph.matchingNodes(machine).stream().allMatch(node -> node.machine()), - "matching machine items synchronize without lighting their inputs or outputs"); - helper.assertTrue(graph.matchingNodes(null).isEmpty(), "empty space clears item hover"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewFramesRecipesWithoutEnclosingTheirNeighbors(GameTestHelper helper) { - var steps = new ArrayList(); - for (int index = 0; index < 16; index++) steps.add(layoutStep("local_" + index, "raw_" + index, "product_" + index)); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); - helper.assertTrue(graph.frames().size() == 16, "each compact recipe gets its own light frame"); - for (var frame : graph.frames()) { - helper.assertTrue(frame.left() < frame.machine().x && frame.right() > frame.machine().x - && frame.top() < frame.machine().y && frame.bottom() > frame.machine().y, - "the frame encloses its recipe machine"); - for (var node : graph.nodes()) if (node.machine() && node != frame.machine()) - helper.assertFalse(node.x >= frame.left() && node.x < frame.right() - && node.y >= frame.top() && node.y < frame.bottom(), - "a recipe frame never encloses a neighboring machine"); - } - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewAlignsChainsAndPreservesFeedback(GameTestHelper helper) { - var steps = new ArrayList(); - var links = new ArrayList(); - for (int index = 0; index < 8; index++) { - steps.add(layoutStep("chain_" + index, "form_" + index, "form_" + (index + 1))); - if (index > 0) links.add(layoutConnection("chain_" + (index - 1), "chain_" + index, "form_" + index)); - } - var chain = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, links)); - helper.assertTrue(chain.nodes().size() == 17 && chain.nodes().stream().map(node -> node.y).distinct().count() == 1, - "eight native steps align as one continuous chain"); - var positions = layoutPositions(chain); - java.util.Collections.reverse(steps); - java.util.Collections.reverse(links); - helper.assertTrue(positions.equals(layoutPositions(new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, links)))), - "stable references make layout independent of input order"); - var loop = new gregtech.compat.common.MaterialProcessOverview(layoutPage( - List.of(layoutStep("loop_a", "loop_x", "loop_y"), layoutStep("loop_b", "loop_y", "loop_x"), - layoutStep("self", "self_form", "self_form")), - List.of(layoutConnection("loop_a", "loop_b", "loop_y"), layoutConnection("loop_b", "loop_a", "loop_x"), - layoutConnection("self", "self", "self_form")))); - helper.assertTrue(loop.nodes().stream().filter(node -> node.machine()).count() == 3, - "pure loops and self loops retain every native step"); - helper.assertTrue(loop.nodes().stream().anyMatch(node -> node.returning) - && loop.edges().stream().allMatch(edge -> edge.confirmed()), - "feedback is marked independently of confirmation"); - for (var edge : loop.edges()) { - helper.assertTrue(edge.feedback() || edge.to().layer > edge.from().layer, - "forward edges obey dependency layers"); - var ports = edge.endpoint().output() ? edge.endpoint().step().outputs() : edge.endpoint().step().inputs(); - helper.assertTrue(ports.get(edge.endpoint().index()) == edge.endpoint().port(), - "every visible arrow retains its exact original endpoint"); - } - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewSharesHubsWithoutInventingConnections(GameTestHelper helper) { - var steps = new ArrayList(); - var links = new ArrayList(); - steps.add(layoutStep("producer", "ore", "hub")); - for (int index = 0; index < 8; index++) { - steps.add(layoutStep("branch_" + index, "hub", "product_" + index)); - if (index != 7) links.add(layoutConnection("producer", "branch_" + index, "hub")); - } - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, links)); - helper.assertTrue(graph.connections().equals(links.stream().sorted(java.util.Comparator.comparing(connection -> - connection.source() + ":" + connection.target() + ":" + connection.resource())).toList()), - "layout retains only the supplied cross-step associations"); - helper.assertTrue(graph.nodes().stream().filter(node -> !node.machine() && node.port().resource().path().equals("hub")).count() == 1 - && graph.nodes().stream().noneMatch(node -> node.copy), - "busy resources stay shared instead of scattering copies across branches"); - for (var node : graph.nodes()) if (!node.machine() && node.endpoints.size() == 1) { - helper.assertTrue(node.endpoints.size() == 1, "each local copy owns its native endpoint"); - var endpoint = node.endpoints.get(0); - var machine = graph.nodes().stream().filter(candidate -> candidate.machine() - && candidate.steps.contains(endpoint.step())).findFirst().orElseThrow(); - helper.assertTrue(Math.abs(node.layer - machine.layer) == 1, - "local copies stay next to their consuming or producing machine"); - } - var left = layoutStep("left", "left_input", "left_output"); - var right = layoutStep("right", "right_input", "right_output"); - var withAuxiliary = List.of(new gregtech.compat.common.MaterialProcessDisplay.Step(left.reference(), left.name(), left.icon(), - left.inputs(), List.of(left.outputs().get(0), displayPort("water", "Other", Items.WATER_BUCKET, true)), - List.of(), java.util.Optional.empty(), true), - new gregtech.compat.common.MaterialProcessDisplay.Step(right.reference(), right.name(), right.icon(), - List.of(right.inputs().get(0), displayPort("water", "Other", Items.WATER_BUCKET, false)), right.outputs(), - List.of(), java.util.Optional.empty(), true)); - var noLink = new gregtech.compat.common.MaterialProcessOverview(layoutPage(withAuxiliary, List.of())); - var auxiliaryLink = new gregtech.compat.common.MaterialProcessOverview(layoutPage(withAuxiliary, - List.of(layoutConnection("left", "right", "water")))); - helper.assertTrue(layoutPositions(noLink).equals(layoutPositions(auxiliaryLink)), - "hidden auxiliary ports do not add layout dependencies or resources"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewKeepsDenseEdgesLocal(GameTestHelper helper) { - var random = new java.util.Random(42); - var steps = new ArrayList(); - for (int index = 0; index < 96; index++) - steps.add(layoutStep("dense_" + index, "form_" + random.nextInt(40), "form_" + random.nextInt(40))); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); - helper.assertTrue( - graph.nodes().stream() - .filter(node -> node.machine()) - .mapToInt(node -> node.steps.size()) - .sum() - == steps.size(), - "local copies retain all native steps"); - helper.assertTrue(graph.nodes().stream().anyMatch(node -> node.copy && node.returning), - "dense feedback uses marked local resources"); - helper.assertTrue(graph.nodes().stream().mapToInt(node -> node.y).min().orElseThrow() == 52, - "feedback does not reserve empty lanes above the graph"); - for (var edge : graph.edges()) { - helper.assertTrue(edge.path().size() == 2 && edge.to().layer > edge.from().layer, - "every visible connection is a single forward segment"); - for (var endpoint : edge.endpoints()) - helper.assertTrue( - (endpoint.output() ? endpoint.step().outputs() : endpoint.step().inputs()) - .get(endpoint.index()) - == endpoint.port(), - "copied and shared connections retain exact native ports"); - var from = edge.path().get(0); - var to = edge.path().get(1); - helper.assertTrue(to.x() > from.x(), "visible routes read from left to right"); - double slope = (double) (to.y() - from.y()) / (to.x() - from.x()); - for (var node : graph.nodes()) { - if (node == edge.from() || node == edge.to() || node.x + 12 <= from.x() || node.x - 12 >= to.x()) continue; - double leftY = from.y() + (Math.max(node.x - 12, from.x()) - from.x()) * slope; - double rightY = from.y() + (Math.min(node.x + 12, to.x()) - from.x()) * slope; - helper.assertTrue( - Math.max(leftY, rightY) < node.y - 14 || Math.min(leftY, rightY) > node.y + 14, - "direct connections avoid intermediate icons and markers"); - } - } - java.util.Collections.shuffle(steps, random); - helper.assertTrue( - layoutPositions(graph) - .equals(layoutPositions(new gregtech.compat.common.MaterialProcessOverview( - layoutPage(steps, List.of())))), - "dense cyclic layouts are stable when input order changes"); - helper.assertTrue(graph.connections().isEmpty(), "local copies do not invent logical associations"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewPacksLocalRoutesWithoutInvisibleDependencies(GameTestHelper helper) { - var random = new java.util.Random(42); - var steps = new ArrayList(); - var links = new ArrayList(); - for (int index = 0; index < 100; index++) - steps.add(layoutStep("packed_" + index, "form_" + random.nextInt(40), "form_" + random.nextInt(40))); - for (var source : steps) for (var target : steps) - if (source.outputs().get(0).resource().equals(target.inputs().get(0).resource())) - links.add(new gregtech.compat.common.MaterialProcessDisplay.Connection(source.reference(), target.reference(), - source.outputs().get(0).resource(), true)); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, links)); - var local = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); - helper.assertTrue(layoutPositions(graph).equals(layoutPositions(local)) && graph.connections().size() == links.size(), - "retained native associations do not stretch copies into invisible dependency columns"); - helper.assertTrue(graph.width() < 1000 && graph.height() < 1000, - "dense local recipe blocks use a compact canvas"); - var islands = new ArrayList(); - for (int index = 0; index < 24; index++) islands.add(layoutStep("island_" + index, "input_" + index, "output_" + index)); - var packed = new gregtech.compat.common.MaterialProcessOverview(layoutPage(islands, List.of())); - helper.assertTrue(packed.width() < 600 && packed.height() < 600 - && packed.nodes().stream().filter(node -> node.machine()).count() == 24, - "independent routes fill adjacent shelves while retaining every route"); - for (var first : graph.nodes()) for (var second : graph.nodes()) - if (first != second) helper.assertTrue(Math.abs(first.x - second.x) >= 24 || Math.abs(first.y - second.y) >= 24, - "packing keeps resource and machine boxes separate"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewKeepsFirstOutputAndVariantsTogether(GameTestHelper helper) { - var base = layoutStep("lens", "gem", "lens"); - var steps = new ArrayList(); - for (int index = 0; index < 2; index++) - steps.add(new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "lens_" + index), base.name(), base.icon(), - base.inputs(), List.of(base.outputs().get(0), layoutPort("a_dust_" + index, true)), - List.of(), java.util.Optional.empty(), true)); - for (int index = 0; index < 12; index++) { - var other = layoutStep("other_" + index, "gem", "other_output_" + index, "other_process_" + index); - steps.add(new gregtech.compat.common.MaterialProcessDisplay.Step(other.reference(), other.name(), other.icon(), - List.of(other.inputs().get(0), layoutPort("other_input_" + index, false)), other.outputs(), - List.of(), java.util.Optional.empty(), true)); - } - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(steps, List.of())); - var machine = graph.nodes().stream().filter(node -> node.machine() && node.steps.size() == 2) - .findFirst().orElseThrow(); - var outputs = graph.edges().stream().filter(edge -> edge.from() == machine).toList(); - helper.assertTrue(outputs.size() == 3, "variants share a machine while retaining their distinct outputs"); - var grid = graph.grids().stream().filter(value -> value.members.contains(outputs.get(0).to())).findFirst().orElseThrow(); - helper.assertTrue(grid.members.size() == 3 && grid.members.stream().allMatch(node -> node.y == machine.y), - "variant products occupy adjacent cells inside their recipe block"); - helper.assertTrue(outputs.stream().map(edge -> edge.path()).distinct().count() == 1, - "one output arrow connects the machine to the whole product grid"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void recoveryOwnershipAndMachineKindDriveOverviewClassification(GameTestHelper helper) { - var foreign = RecoveryRecipePublisher.generic(row(new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, - Items.COPPER_INGOT), "test-recycling"); - var local = RecoveryRecipePublisher.generic(row(new ItemStack[] {new ItemStack(Items.COPPER_INGOT)}, - Items.IRON_INGOT), "test-recycling"); - var ordinary = row(new ItemStack[] {new ItemStack(Items.GOLD_INGOT)}, Items.COPPER_INGOT); - for (var recoveryMap : List.of(gregtech.content.data.MachineRecipeMaps.Shredder, - gregtech.content.data.MachineRecipeMaps.Melter, gregtech.content.data.MachineRecipeMaps.Smelter)) - helper.assertTrue(new MaterialProcessSnapshot.NativeRecipe(recoveryMap, local, 0).genericRecovery(), - "generic grinding and melting routes are recovery"); - helper.assertTrue(!new MaterialProcessSnapshot.NativeRecipe(gregtech.content.data.MachineRecipeMaps.Anvil, local, 0).genericRecovery() - && !new MaterialProcessSnapshot.NativeRecipe(gregtech.content.data.MachineRecipeMaps.Shredder, ordinary, 0).genericRecovery(), - "anvil fallback ownership and ordinary shredder recipes do not imply recovery"); - var map = new RecipeMap(new ArrayList<>(List.of(foreign, local, ordinary)), - "gt.test.process.recovery", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, - false, false, false, false); - RecipeMap.unregister(map); - var snapshot = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, - new MaterialWorldgenFacts.Snapshot(List.of()), List.of(map)); - var root = snapshot.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); - var query = snapshot.queryMaterial(root.resource(), new Budgets(0, 8, 16, 16)); - helper.assertTrue(query.steps().size() == 3, - "fallback ownership on an ordinary process does not hide its material sources"); - var page = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, root.resource(), - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); - helper.assertTrue(page.steps().stream().noneMatch(value -> value.genericRecovery()), - "projection and source indexing use the same recovery classification"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewSeparatesSourcesConversionsAndUses(GameTestHelper helper) { - var source = new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "source"), - net.minecraft.network.chat.Component.literal("source"), new ItemStack(Items.STONECUTTER), - List.of(displayPort("foreign", "Other", Items.IRON_INGOT, false)), List.of(layoutPort("ore", true)), - List.of(), java.util.Optional.empty(), true); - var use = new gregtech.compat.common.MaterialProcessDisplay.Step( - new gregtech.api.addon.material.DataKey("test", "use"), - net.minecraft.network.chat.Component.literal("use"), new ItemStack(Items.STONECUTTER), - List.of(layoutPort("dust", false)), List.of(displayPort("foreign_product", "Other", Items.GOLD_INGOT, true)), - List.of(), java.util.Optional.empty(), true); - var uncertain = layoutConnection("source", "convert", "ore"); - var links = List.of(new gregtech.compat.common.MaterialProcessDisplay.Connection( - uncertain.source(), uncertain.target(), uncertain.resource(), false), - layoutConnection("convert", "use", "dust")); - var graph = new gregtech.compat.common.MaterialProcessOverview( - layoutPage(List.of(use, layoutStep("convert", "ore", "dust"), source), links)); - helper.assertTrue(graph.bands().size() == 3 && graph.connections().size() == 2, - "one overview preserves all associations and only allocates populated bands"); - helper.assertTrue(graph.edges().stream().filter(edge -> !edge.endpoint().output() - && edge.endpoint().step().reference().equals(uncertain.target())).noneMatch(edge -> edge.confirmed()), - "cross-band associations retain their uncertainty after local layout"); - for (var node : graph.nodes()) if (node.machine()) { - var band = graph.bands().stream().filter(value -> value.section() == node.section).findFirst().orElseThrow(); - helper.assertTrue(node.x >= band.left() && node.x < band.right(), - "machines stay in their semantic source, conversion or use band"); - } - helper.assertTrue(graph.nodes().stream().filter(node -> !node.machine() - && (node.port().identity().equals("ore") || node.port().identity().equals("dust"))) - .allMatch(node -> node.copy), - "boundary material instances carry copy markers instead of crossing separators with long wires"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewFoldsAlternativeInputsAndKeepsProductGridsLocal(GameTestHelper helper) { - var alternatives = new ArrayList(); - for (int index = 0; index < 13; index++) alternatives.add(layoutStep("smelt_" + index, "form_" + index, "molten")); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(alternatives, List.of())); - var grid = graph.grids().get(0); - helper.assertTrue(grid.members.size() == 13 && grid.right() - grid.left() == 72 - && grid.bottom() - grid.top() == 120, - "thirteen alternative inputs occupy a three-column, five-row inventory"); - helper.assertTrue(graph.nodes().stream().filter(node -> node.machine()).count() == 1 - && graph.nodes().stream().filter(node -> node.machine()).findFirst().orElseThrow().steps.size() == 13, - "alternative forms share one machine while retaining all native recipes"); - helper.assertTrue(graph.edges().stream().filter(edge -> !edge.endpoint().output()).map(edge -> edge.path()).distinct().count() == 1, - "all input cells connect through one trunk"); - var yields = new ArrayList(); - for (int count : List.of(2, 4)) { - var nativeStep = layoutStep("yield_" + count, "form_" + count, "molten"); - var nativePort = nativeStep.outputs().get(0); - var port = new gregtech.compat.common.MaterialProcessDisplay.Port(nativePort.resource(), nativePort.material(), nativePort.name(), - nativePort.icons(), nativePort.role(), false, net.minecraft.network.chat.Component.literal(count + " items"), - net.minecraft.network.chat.Component.literal(Integer.toString(count)), nativePort.chance(), nativePort.details(), nativePort.identity()); - yields.add(new gregtech.compat.common.MaterialProcessDisplay.Step(nativeStep.reference(), nativeStep.name(), nativeStep.icon(), - nativeStep.inputs(), List.of(port), List.of(), java.util.Optional.empty(), true)); - } - var yieldGraph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(yields, List.of())); - helper.assertTrue(yieldGraph.grids().size() == 1 && yieldGraph.nodes().stream().anyMatch(node -> !node.machine() && node.quantityBadge().equals("2/4")), - "different batch yields do not prevent form folding or overwrite each other's quantities"); - var positions = layoutPositions(graph); - java.util.Collections.reverse(alternatives); - helper.assertTrue(positions.equals(layoutPositions(new gregtech.compat.common.MaterialProcessOverview(layoutPage(alternatives, List.of())))), - "folded grids do not depend on snapshot order"); - var base = layoutStep("bolt", "bolt", "small_dust"); - var bolt = new gregtech.compat.common.MaterialProcessDisplay.Step(base.reference(), base.name(), base.icon(), base.inputs(), - List.of(base.outputs().get(0), layoutPort("tiny_dust", true)), List.of(), java.util.Optional.empty(), true); - var products = new gregtech.compat.common.MaterialProcessOverview(layoutPage( - List.of(bolt, layoutStep("small_source", "ore", "small_dust"), layoutStep("tiny_use", "tiny_dust", "ingot")), List.of())); - helper.assertTrue(products.grids().stream().anyMatch(value -> value.members.size() == 2 - && value.members.stream().map(node -> node.port().identity()).collect(java.util.stream.Collectors.toSet()) - .equals(java.util.Set.of("small_dust", "tiny_dust"))), - "a bolt's two products stay adjacent even when one has other producers and the other has consumers"); - var manyOutputs = new ArrayList(); - for (int index = 0; index < 128; index++) manyOutputs.add(layoutPort("many_" + index, true)); - var many = new gregtech.compat.common.MaterialProcessDisplay.Step(base.reference(), base.name(), base.icon(), base.inputs(), - manyOutputs, List.of(), java.util.Optional.empty(), true); - var large = new gregtech.compat.common.MaterialProcessOverview(layoutPage( - List.of(many, layoutStep("consume", "many_0", "result")), List.of())); - helper.assertTrue(large.grids().stream().anyMatch(value -> value.members.size() == 128), - "long-edge detection uses the grid anchor instead of detaching a tall grid's first cell"); - for (var edge : products.edges()) for (var endpoint : edge.endpoints()) - helper.assertTrue((endpoint.output() ? endpoint.step().outputs() : endpoint.step().inputs()).get(endpoint.index()) == endpoint.port(), - "grid cells and shared trunks retain exact native endpoint ownership"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void overviewShowsPortYieldsAndOrdersRecoveryAfterConversions(GameTestHelper helper) { - var base = layoutPort("dust", true); - var output = new gregtech.compat.common.MaterialProcessDisplay.Port(base.resource(), base.material(), base.name(), base.icons(), base.role(), - base.main(), net.minecraft.network.chat.Component.literal("2 items"), net.minecraft.network.chat.Component.literal("2"), - java.util.OptionalInt.of(1111), base.details(), base.identity()); - var step = layoutStep("grind", "bolt", "dust"); - var recovery = new gregtech.compat.common.MaterialProcessDisplay.Step(step.reference(), step.name(), step.icon(), step.inputs(), - List.of(output), List.of(), java.util.Optional.empty(), true, false, true); - var graph = new gregtech.compat.common.MaterialProcessOverview(layoutPage(List.of(recovery), List.of())); - var product = graph.nodes().stream().filter(node -> !node.machine() && node.endpoints.stream().anyMatch(endpoint -> endpoint.output())) - .findFirst().orElseThrow(); - helper.assertTrue(product.quantityBadge().equals("2") && product.chanceBadge().equals("11.11%"), - "quantity and basis-point probability are rendered without reconstructing them from icon counts"); - helper.assertTrue(graph.bands().stream().map(value -> value.section()).toList().equals(List.of( - gregtech.compat.common.MaterialProcessDisplay.Section.RECOVERY)), - "a recovery-only page does not reserve space for three empty bands"); - helper.assertTrue(product.returning, "recovery products retain their return marker"); - helper.succeed(); - } - - private static gregtech.compat.common.MaterialProcessDisplay.Step layoutStep(String id, String input, String output) { - return layoutStep(id, input, output, "cutting"); - } - - private static gregtech.compat.common.MaterialProcessDisplay.Step layoutStep(String id, String input, String output, String process) { - return new gregtech.compat.common.MaterialProcessDisplay.Step(new gregtech.api.addon.material.DataKey("test", id), - net.minecraft.network.chat.Component.literal(process), new ItemStack(Items.STONECUTTER), - List.of(layoutPort(input, false)), - List.of(layoutPort(output, true)), List.of(), java.util.Optional.empty(), true); - } - - private static gregtech.compat.common.MaterialProcessDisplay.Port layoutPort(String reference, boolean output) { - var name = net.minecraft.network.chat.Component.literal(reference); - return new gregtech.compat.common.MaterialProcessDisplay.Port(new gregtech.api.addon.material.DataKey("test", reference), - "Copper", name, List.of(), output ? gregtech.compat.common.MaterialProcessDisplay.Role.UNKNOWN - : gregtech.compat.common.MaterialProcessDisplay.Role.CONSUMED, - false, name, name, java.util.OptionalInt.of(10000), List.of(), reference); - } - - private static gregtech.compat.common.MaterialProcessDisplay.Connection layoutConnection(String source, String target, String resource) { - return new gregtech.compat.common.MaterialProcessDisplay.Connection(new gregtech.api.addon.material.DataKey("test", source), - new gregtech.api.addon.material.DataKey("test", target), new gregtech.api.addon.material.DataKey("test", resource), true); - } - - private static gregtech.compat.common.MaterialProcessDisplay.Page layoutPage( - List steps, - List connections) { - return gregtech.compat.common.MaterialProcessDisplay.pages(net.minecraft.network.chat.Component.literal("Copper"), "Copper", - steps, connections, List.of(net.minecraft.network.chat.Component.literal("test")), - gregtech.compat.common.MaterialProcessDisplay.Navigation.NONE).get(0); - } - - private static java.util.Map layoutPositions(gregtech.compat.common.MaterialProcessOverview graph) { - var result = new java.util.TreeMap(); - for (var node : graph.nodes()) result.put(node.key, node.x + ":" + node.y); - return result; - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void nativeProjectionKeepsOutputsAndCrossMaterialRoutes(GameTestHelper helper) { - var first = row(new ItemStack[] {new ItemStack(Items.IRON_NUGGET), new ItemStack(Items.PAPER), - new ItemStack(Items.STICK)}, Items.COPPER_INGOT).withCatalystInputs(2); - var second = row(new ItemStack[] {new ItemStack(Items.COPPER_INGOT)}, Items.GOLD_INGOT); - var third = row(new ItemStack[] {new ItemStack(Items.GOLD_INGOT)}, Items.DIAMOND); - var tagged = new Recipe(new ItemStack[] {new ItemStack(Items.GOLD_INGOT)}, - new ItemStack[] {new ItemStack(Items.IRON_INGOT)}, null, null, - new FluidStack[] {new FluidStack(Fluids.WATER, 1000)}, - new FluidStack[] {new FluidStack(Fluids.LAVA, 1000)}, 20, 16, 0) - .withItemTagInput(0, ResourceLocation.fromNamespaceAndPath("c", "ingots/gold")) - .withFluidTagInput(0, ResourceLocation.fromNamespaceAndPath("c", "water")); - var map = new RecipeMap(new ArrayList<>(List.of(first, second, third, tagged)), - "gt.test.process.snapshot", "Test", "textures/gui/test", 9, 9, 0, 0, 0, 0, 0, - false, false, false, false); - RecipeMap.unregister(map); - var ores = List.of(new Ore(Materials.Iron, "item:minecraft:iron_nugget", 0, 20, 1, 0, List.of())); - var facts = new MaterialWorldgenFacts.Snapshot(List.of( - new Fact("test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 1, ores))); - var snapshot = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, facts, List.of(map)); - var root = snapshot.roots().stream().filter(value -> value.material().equals("Copper")).findFirst().orElseThrow(); - var query = snapshot.query(root.resource(), Direction.BOTH, Budgets.DEFAULT); - helper.assertTrue(query.steps().size() == 4, "route traverses other materials and the native worldgen form"); - var firstStep = query.steps().stream().filter(step -> snapshot.recipe(step.reference()) - .map(nativeRow -> nativeRow.recipe() == first).orElse(false)).findFirst().orElseThrow(); - helper.assertTrue(firstStep.inputs().size() == 2, "ordinary co-input survives; auxiliary tool stays in details"); - helper.assertTrue(firstStep.inputs().stream().anyMatch(port -> port.resource().state().equals("item:minecraft:paper")), - "unclassified ordinary input keeps its native identity"); - helper.assertTrue(firstStep.details().stream().anyMatch(detail -> detail.contains("minecraft:stick")), - "auxiliary catalyst is available in recipe details"); - var taggedStep = snapshot.roots().stream() - .flatMap(value -> snapshot.query(value.resource(), Direction.BOTH, Budgets.DEFAULT).steps().stream()) - .filter(step -> snapshot.recipe(step.reference()) - .map(nativeRow -> nativeRow.recipe() == tagged).orElse(false)).findFirst().orElseThrow(); - helper.assertTrue(taggedStep.outputs().get(0).resource().state().equals("item:minecraft:iron_ingot"), - "input tag never changes the output identity"); - helper.assertTrue(taggedStep.outputs().stream().anyMatch(port -> port.resource().state().equals("fluid:minecraft:lava")), - "fluid input tag never changes the fluid output identity"); - var replacement = MaterialProcessSnapshot.build(MaterialPublication.current(), 1, facts, List.of(map)); - helper.assertTrue(replacement.query(root.resource(), Direction.BOTH, Budgets.DEFAULT).steps().isEmpty(), - "resource references cannot cross snapshots even with the same stamp"); - helper.assertTrue(snapshot.query(root.resource(), Direction.BOTH, Budgets.DEFAULT).equals(query), - "old query remains self-consistent"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void worldgenRevisionIncludesSelectionAndKind(GameTestHelper helper) { - var ores = List.of(new Ore(Materials.Iron, "item:minecraft:iron_nugget", 0, 20, 1, 0, List.of())); - var baseline = new Fact("test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 10, ores); - long revision = new MaterialWorldgenFacts.Snapshot(List.of(baseline)).revision(); - for (Fact changed : List.of( - new Fact("test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 2, 10, ores), - new Fact("test", "test", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 20, ores), - new Fact("test", "test", Kind.BEDROCK, "minecraft:overworld", 0, 20, 1, 10, ores), - new Fact("test", "renamed", Kind.LARGE_VEIN, "minecraft:overworld", 0, 20, 1, 10, ores))) { - helper.assertTrue(new MaterialWorldgenFacts.Snapshot(List.of(changed)).revision() != revision, - "each changed worldgen field changes the revision"); - } - var activeFacts = MaterialWorldgenFacts.capture(); - helper.assertFalse(activeFacts.facts().isEmpty(), "active worldgen facts are projected"); - helper.assertFalse(activeFacts.facts().stream().flatMap(fact -> fact.ores().stream()) - .anyMatch(ore -> ore.itemState().equals("item:minecraft:stone") - || ore.itemState().equals("item:minecraft:air")), - "missing ore registrations never turn into stone or air sources"); - var current = MaterialProcessSnapshot.Store.publish(MachineRecipeOverlay.lastPublication(), - MachineRecipeOverlay.generation()); - helper.assertTrue(current.samePublication(MachineRecipeOverlay.lastPublication()), - "snapshot follows the last successful publication"); - helper.assertTrue(MaterialProcessSnapshot.Store.publish(MachineRecipeOverlay.lastPublication(), - MachineRecipeOverlay.generation()) == current, "unchanged publication reuses its index"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = "material_process", timeoutTicks = 200) - public static void specialProcessRulesDriveTagsAndRecipeOwnership(GameTestHelper helper) { - var catalog = MaterialViews.catalog(); - var gold = new gregtech.api.addon.material.MaterialKey("Gold"); - var aquaRegia = new gregtech.api.addon.material.MaterialKey("AquaRegia"); - helper.assertTrue( - catalog.specialProcesses() - .find(SpecialProcessMethods.AQUA_REGIA_LEACHING.id()) - .isPresent(), - "aqua regia method is published"); - helper.assertTrue( - catalog.tags().contains(gold, new gregtech.api.addon.material.DataKey( - "gt6ce", "special_process/aqua_regia_leaching/target")), - "target tag is derived from the target rule"); - helper.assertTrue( - catalog.tags().contains(aquaRegia, new gregtech.api.addon.material.DataKey( - "gt6ce", "special_process/aqua_regia_leaching/reagent")), - "reagent tag is derived from the reagent rule"); - var method = catalog.specialProcesses() - .find(SpecialProcessMethods.AQUA_REGIA_LEACHING.id()) - .orElseThrow(); - var targetItemTag = TagKey.create( - Registries.ITEM, - ResourceLocation.fromNamespaceAndPath( - method.targetTag().namespace(), method.targetTag().path())); - var targetItems = BuiltInRegistries.ITEM.getTag(targetItemTag).orElseThrow(); - helper.assertFalse(targetItems.size() == 0, "target item resource tag has members"); - for (var holder : targetItems) { - var form = MaterialEquivalence.form(new ItemStack(holder.value())); - helper.assertTrue( - form != null - && (form.prefix().getName().equals("crushedPurified") - || form.prefix().getName().equals("crushedPurifiedTiny")), - "target item tag only contains declared purified forms"); - } - var reagentFluidTag = TagKey.create( - Registries.FLUID, - ResourceLocation.fromNamespaceAndPath( - method.reagentTag().namespace(), method.reagentTag().path())); - var reagentFluids = BuiltInRegistries.FLUID.getTag(reagentFluidTag).orElseThrow(); - helper.assertFalse(reagentFluids.size() == 0, "reagent fluid resource tag has members"); - for (var holder : reagentFluids) { - var entry = GTFluids.entryForFluid(holder.value()); - helper.assertTrue(entry != null, "reagent tag member has a fluid entry"); - if (entry == null) continue; - var material = gregtech.engine.fluid.FluidVisualPolicy.material(entry).resolve(); - helper.assertTrue( - material != null - && material.isValid() - && material.getName().equals("AquaRegia") - && !entry.gas(), - "reagent fluid tag only contains declared aqua regia liquid"); - } - var bath = RecipeMap.RECIPE_MAP_LIST.stream() - .filter(map -> map.mNameInternal.equals("gt.recipe.bath")) - .findFirst() - .orElseThrow(); - helper.assertTrue( - bath.mRecipeList.stream() - .anyMatch(recipe -> SpecialProcessMethods.AQUA_REGIA_LEACHING - .id() - .equals(recipe.specialProcess())), - "at least one Bath row is owned by the API method"); - var snapshot = MaterialProcessSnapshot.Store.current(); - var root = snapshot.roots().stream() - .filter(value -> value.material().equals("Gold")) - .findFirst() - .orElseThrow(); - var query = snapshot.queryMaterial(root.resource(), new Budgets(0, 512, 128, 4096)); - helper.assertTrue( - query.steps().stream().anyMatch(step -> step.specialProcess() - .filter(id -> id.equals(SpecialProcessMethods.AQUA_REGIA_LEACHING.id())) - .isPresent()), - "published aqua regia rows retain method ownership"); - helper.succeed(); - } - - private static Recipe row(ItemStack[] inputs, net.minecraft.world.item.Item output) { - return new Recipe(inputs, new ItemStack[] {new ItemStack(output)}, null, null, null, null, 20, 16, 0); - } -} diff --git a/minecraft/src/test/java/gregtech/gametest/MaterialBaselineAddon.java b/minecraft/src/test/java/gregtech/gametest/MaterialBaselineAddon.java deleted file mode 100644 index 355c5f937..000000000 --- a/minecraft/src/test/java/gregtech/gametest/MaterialBaselineAddon.java +++ /dev/null @@ -1,110 +0,0 @@ -package gregtech.gametest; - -import gregtech.api.addon.material.AddonMaterialContributor; -import gregtech.api.addon.material.FormKey; -import gregtech.api.addon.material.MaterialComposition; -import gregtech.api.addon.material.MaterialDeclaration; -import gregtech.api.addon.material.MaterialDecompositionRule; -import gregtech.api.addon.material.MaterialInfoTool; -import gregtech.api.addon.material.MaterialKey; -import gregtech.api.addon.material.MaterialProcessKeys; -import gregtech.api.addon.material.MaterialProcessRule; -import gregtech.api.material.GTValues; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** Test-source SPI contributor exercises host installation without a real optional mod. */ -public final class MaterialBaselineAddon implements AddonMaterialContributor { - record DecompositionCase(String material, String form, String fluid, boolean gas) {} - - static final List DECOMPOSITIONS = List.of( - new DecompositionCase("BaselineDustOnly", "dust", null, false), - new DecompositionCase("BaselineBlockOnly", "blockDust", null, false), - new DecompositionCase("BaselineLiquidOnly", "liquid", "material_baseline_test:baselineliquidonly", false), - new DecompositionCase("BaselineGasOnly", "gas", "material_baseline_test:baselinegasonly", true), - new DecompositionCase("BaselineLegacyFluid", "liquid", "baselinelegacyfluid", false), - new DecompositionCase("BaselineBuiltinFluid", "gas", "gt6ce:oxygen", true), - new DecompositionCase("BaselineExternalFluid", "liquid", "minecraft:flowing_water", false), - new DecompositionCase("BaselineUnknownFluid", "liquid", "missing:baselineliquidonly", false), - new DecompositionCase("BaselineInvalidFluid", "liquid", "Invalid:fluid", false)); - - @Override - public String addonId() { - return "material_baseline_test"; - } - - @Override - public List materials() { - var declarations = new ArrayList<>(List.of( - MaterialDeclaration.builder("BaselineRuntimeCompound").dust().build(), - MaterialDeclaration.builder("BaselineThermalAddon") - .dust() - .liquid() - .build())); - for (var test : DECOMPOSITIONS) { - var material = MaterialDeclaration.builder(test.material()).dust(); - if (test.gas()) material.gas(); - else material.liquid(); - if (test.material().equals("BaselineLiquidOnly")) material.meltingPointKelvin(200); - declarations.add(material.build()); - } - declarations.add( - MaterialDeclaration.builder("BaselineFluidOutput").dust().build()); - return List.copyOf(declarations); - } - - @Override - public void materialInfo(MaterialInfoTool.Registrar registrar) { - registrar.registerProcess( - new MaterialKey("BaselineRuntimeCompound"), - MaterialProcessKeys.DECOMPOSITION, - MaterialProcessRule.anyForm(new MaterialDecompositionRule( - Set.of(MaterialDecompositionRule.Route.CENTRIFUGE), List.of(), false))); - for (var test : DECOMPOSITIONS) { - var fluids = test.fluid() == null - ? List.of() - : List.of(new MaterialDecompositionRule.FluidBinding( - test.gas() ? MaterialDecompositionRule.Phase.GAS : MaterialDecompositionRule.Phase.LIQUID, - test.fluid(), - GTValues.U, - 1000)); - registrar.registerProcess( - new MaterialKey(test.material()), - MaterialProcessKeys.DECOMPOSITION, - new MaterialProcessRule<>( - Set.of(new FormKey(test.form())), - new MaterialDecompositionRule( - Set.of(MaterialDecompositionRule.Route.CENTRIFUGE), - fluids, - !test.form().equals("dust") && !test.form().equals("blockDust")))); - } - registrar.registerProcess( - new MaterialKey("BaselineFluidOutput"), - MaterialProcessKeys.DECOMPOSITION, - MaterialProcessRule.anyForm(new MaterialDecompositionRule( - Set.of(MaterialDecompositionRule.Route.CENTRIFUGE), List.of(), false))); - } - - @Override - public List compositions() { - var compositions = new ArrayList<>(List.of(new MaterialComposition( - "BaselineRuntimeCompound", - 3, - List.of( - new MaterialComposition.Part("Iron", GTValues.U * 2), - new MaterialComposition.Part("Copper", GTValues.U)), - false))); - for (var test : DECOMPOSITIONS) - compositions.add(new MaterialComposition( - test.material(), 9, List.of(new MaterialComposition.Part("Iron", GTValues.U * 9)), false)); - compositions.add(new MaterialComposition( - "BaselineFluidOutput", - 2, - List.of( - new MaterialComposition.Part("Iron", GTValues.U), - new MaterialComposition.Part("BaselineLiquidOnly", GTValues.U)), - false)); - return List.copyOf(compositions); - } -} diff --git a/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java b/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java deleted file mode 100644 index 034e82d1f..000000000 --- a/minecraft/src/test/java/gregtech/gametest/MaterialBaselineTests.java +++ /dev/null @@ -1,1119 +0,0 @@ -package gregtech.gametest; - -import gregtech.api.addon.material.MaterialInfoTool; -import gregtech.api.addon.material.GregTechMaterials; -import gregtech.api.addon.material.MaterialFormKind; -import gregtech.api.addon.material.MaterialKey; -import gregtech.api.addon.material.MaterialProcessKeys; -import gregtech.api.material.GTValues; -import gregtech.api.material.PulverizationMaterialHelper; -import gregtech.api.material.SmeltingMaterialHelper; -import gregtech.content.block.machine.MoldBlock; -import gregtech.content.block.machine.MoldItemData; -import gregtech.content.block.machine.BasicMachineBlock; -import gregtech.content.block.DenseOreBlock; -import gregtech.content.block.OreBlock; -import gregtech.content.block.VanillaOreBlock; -import gregtech.content.blockentity.machine.BasicMachineBlockEntity; -import gregtech.content.data.MachineRecipeMaps; -import gregtech.content.data.MaterialPrefix; -import gregtech.content.item.GTToolItem; -import gregtech.content.material.Materials; -import gregtech.content.recipe.CraftingMaterialForms; -import gregtech.content.recipe.MachineRecipeOverlay; -import gregtech.content.recipe.MaterialProcessSnapshot; -import gregtech.content.recipe.MaterialRecoveryRules; -import gregtech.content.registry.GTItems; -import gregtech.content.registry.GTTechnological; -import gregtech.content.worldgen.MaterialWorldgenFacts; -import gregtech.engine.fluid.PortableFluidContainerSpec; -import gregtech.engine.machine.crucible.CrucibleItemInput; -import gregtech.engine.material.ItemComposition; -import gregtech.engine.material.ItemMaterialRegistry; -import gregtech.engine.material.ItemCompositionSource; -import gregtech.engine.material.MaterialEquivalence; -import gregtech.engine.material.MaterialPublication; -import gregtech.engine.recipe.Recipe; -import gregtech.engine.recipe.RecipeMap; -import gregtech.engine.tool.GTToolType; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.gametest.framework.GameTest; -import net.minecraft.gametest.framework.GameTestHelper; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; -//? if >=1.21.1 { -/*import net.neoforged.neoforge.fluids.FluidStack; -import net.neoforged.neoforge.gametest.GameTestHolder; -import net.neoforged.neoforge.gametest.PrefixGameTestTemplate; -*///?} else { -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.gametest.GameTestHolder; -import net.minecraftforge.gametest.PrefixGameTestTemplate; -//?} - -/** Observations and correctness checks are separate; known differences are named in each assertion. */ -@GameTestHolder("gt6ce") -@PrefixGameTestTemplate(false) -public final class MaterialBaselineTests { - private static final String BATCH = "material_baseline"; - private static final AtomicBoolean RELOAD_COMPLETE = new AtomicBoolean(); - private static final AtomicReference RELOAD_FAILURE = new AtomicReference<>(); - - private MaterialBaselineTests() {} - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void materialSpiInstallsLinkedCompositionAndGeneratedForm(GameTestHelper helper) { - var material = gregtech.engine.material.GTMaterialRegistry.get("BaselineRuntimeCompound"); - helper.assertTrue(material.isValid(), "SPI material installed"); - helper.assertTrue("material_baseline_test".equals(gregtech.engine.addon.AddonMaterials.owner(material)), "SPI ownership"); - helper.assertTrue(!gregtech.engine.material.GTMaterialRegistry.isCoreMaterial(material), "addon identity is separate from core"); - helper.assertTrue(material.getCompositionComponents().size() == 2 && material.getCompositionDivider() == 3, "SPI composition linked"); - var indexed = MaterialInfoTool.composition(new MaterialKey(material.getName())).orElseThrow(); - helper.assertTrue(indexed.divider() == 3 && indexed.parts().size() == 2 && !indexed.crucible(), "legacy SPI composition reaches the frozen index"); - helper.assertTrue(indexed.parts().get(0).material().equals("Iron") && indexed.parts().get(0).amount() == GTValues.U * 2 - && indexed.parts().get(1).material().equals("Copper") && indexed.parts().get(1).amount() == GTValues.U, "indexed composition retains order and amounts"); - var iron = new MaterialKey("Iron"); - helper.assertTrue(SmeltingMaterialHelper.target(iron).equals(SmeltingMaterialHelper.target(Materials.Iron)) - && SmeltingMaterialHelper.target(iron).isPresent(), "default smelting agrees across query entries"); - helper.assertTrue(PulverizationMaterialHelper.target(iron).equals(PulverizationMaterialHelper.target(Materials.Iron)) - && PulverizationMaterialHelper.target(iron).isPresent(), "default pulverization agrees across query entries"); - var dust = GTItems.getStack(MaterialPrefix.dust, material, 3); - helper.assertFalse(dust.isEmpty(), "host generated the requested dust form"); - helper.assertTrue(find(MachineRecipeMaps.Centrifuge, List.of(dust), List.of()) != null, "SPI decomposition is queryable"); - observe(helper, "spi_dust", dust); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void addonDecompositionExecutesThroughThePublishedCentrifugeRow(GameTestHelper helper) { - var level = helper.getLevel(); - var pos = helper.absolutePos(new net.minecraft.core.BlockPos(2, 1, 2)); - var block = BuiltInRegistries.BLOCK.get( - ResourceLocation.fromNamespaceAndPath("gt6ce", "centrifuge_bronze")); - level.setBlockAndUpdate(pos, block.defaultBlockState()); - var machine = (BasicMachineBlockEntity) level.getBlockEntity(pos); - helper.assertTrue(machine != null, "centrifuge fixture is registered"); - machine.setSpec(((BasicMachineBlock) block).basicSpec()); - var material = gregtech.engine.material.GTMaterialRegistry.get("BaselineRuntimeCompound"); - var dust = GTItems.getStack(MaterialPrefix.dust, material, 3); - machine.inventory().setStackInSlot(0, dust); - machine.inventoryChanged(); - var config = new gregtech.engine.machine.RecipeProcessor.Config() { - public RecipeMap recipeMap() { - return machine.recipeMap(); - } - - public boolean searchOutputTanks() { - return false; - } - - public boolean exclusiveOutputs() { - return false; - } - - public int parallelLimit() { - return 1; - } - - public boolean parallelScalesDuration() { - return true; - } - - public boolean cheapOverclocking() { - return false; - } - - public boolean usesTimeEnergy() { - return false; - } - - public int efficiency() { - return 10_000; - } - - public long inputMinimum() { - return 16; - } - - public long inputMaximum() { - return 64; - } - - public long nominalEnergyInput() { - return 32; - } - - public long startupEnergyFor(Recipe recipe) { - return 0; - } - }; - var io = new gregtech.engine.machine.RecipeProcessor.IO() { - public gregtech.engine.machine.MachineInventory inventory() { - return machine.autoIOInventory(); - } - - public net.minecraft.world.level.Level level() { - return level; - } - - public ItemStack autocraftingProgram() { - return ItemStack.EMPTY; - } - - public void setStartupEnergy(long value) {} - - public void clearStartupEnergy() {} - - public void markJobStarted() {} - - public net.minecraft.world.level.block.entity.BlockEntity owner() { - return machine; - } - }; - var gate = new gregtech.engine.machine.RecipeProcessor.Gate() { - public boolean structureComplete() { - return true; - } - - public boolean switchesAllowRunning() { - return true; - } - - public boolean recipeStartAllowed() { - return true; - } - - public boolean lightAllowsStart() { - return true; - } - }; - var processor = new gregtech.engine.machine.RecipeProcessor(config, io, gate); - helper.assertTrue( - processor.startJob() == gregtech.engine.machine.RecipeProcessor.StartResult.STARTED, - "published decomposition row did not start through the shared recipe processor"); - helper.assertTrue( - machine.inventory().getStackInSlot(0).isEmpty(), - "centrifuge consumed its decomposition input"); - helper.assertTrue( - processor.recipeDetails() != null - && processor.recipeDetails().duration() == 876 - && processor.recipeDetails().power() == 42, - "decomposition plan supplied duration and EU/t to the machine: " + processor.recipeDetails()); - helper.assertTrue( - processor.advance(processor.totalWork()), - "centrifuge did not complete its planned work; work=" + processor.totalWork() - + ", progress=" + processor.progress()); - helper.assertTrue( - processor.flushOutputs(), - "centrifuge did not flush its planned outputs; pending=" + processor.pendingOutputs()); - var iron = machine.inventory().getStackInSlot(machine.inputSlots()); - var copper = machine.inventory().getStackInSlot(machine.inputSlots() + 1); - helper.assertTrue( - iron.is(GTItems.getStack(MaterialPrefix.dust, Materials.Iron, 1).getItem()) - && iron.getCount() == 2, - "centrifuge emitted two Iron dust"); - helper.assertTrue( - copper.is(GTItems.getStack(MaterialPrefix.dust, Materials.Copper, 1).getItem()) - && copper.getCount() == 1, - "centrifuge emitted one Copper dust"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void registeredFormsPublishItemBlockAndFluidBindings(GameTestHelper helper) { - var iron = new MaterialKey("Iron"); - var ironBindings = GregTechMaterials.formBindings().find(iron); - helper.assertTrue( - ironBindings.stream().anyMatch(binding -> binding.kind() == MaterialFormKind.ITEM), - "iron has a registered item binding"); - helper.assertTrue( - ironBindings.stream() - .anyMatch(binding -> binding.id().equals("minecraft:iron_ingot")), - "explicit vanilla iron ingot is part of the same form inventory"); - helper.assertTrue( - ironBindings.stream().anyMatch(binding -> binding.kind() == MaterialFormKind.BLOCK), - "iron has a registered block binding"); - var hydrogenBindings = GregTechMaterials.formBindings().find(new MaterialKey("Hydrogen")); - helper.assertTrue( - hydrogenBindings.stream().anyMatch(binding -> binding.kind() == MaterialFormKind.FLUID), - "hydrogen has a registered fluid binding"); - helper.assertTrue( - GregTechMaterials.forms().rules(iron).stream() - .anyMatch(rule -> rule.kind() == MaterialFormKind.ITEM - && GregTechMaterials.formBindings() - .present(iron, rule.form())), - "allowed item rules intersect native bindings"); - helper.assertTrue( - "ores".equals(MaterialEquivalence.commonGroup("ore")) - && "raw_ore_chunks".equals(MaterialEquivalence.commonGroup("rawOreChunk")), - "external ore tag names remain mapped"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void oreBlocksUseTheirDeclaredMaterialForm(GameTestHelper helper) { - int checked = 0; - for (Block block : BuiltInRegistries.BLOCK) { - MaterialPrefix expected; - gregtech.api.material.GTMaterial material; - if (block instanceof DenseOreBlock ore) { - expected = MaterialPrefix.oreDense; - material = ore.material(); - } else if (block instanceof VanillaOreBlock ore) { - expected = MaterialPrefix.oreVanillastone; - material = ore.material(); - } else if (block instanceof OreBlock ore && !ore.isSmall()) { - expected = MaterialPrefix.oreVanillastone; - material = ore.material(); - } else { - continue; - } - checked++; - var item = block.asItem(); - var composition = ItemMaterialRegistry.base(item).orElse(null); - helper.assertTrue(composition != null, "missing ore composition: " + id(new ItemStack(item))); - helper.assertTrue( - composition.prefix() == expected, - "wrong ore form: " + id(new ItemStack(item)) + " -> " + composition.prefix()); - helper.assertTrue( - composition.material().resolve() == material.resolve(), - "wrong ore material: " + id(new ItemStack(item))); - } - helper.assertTrue(checked > 0, "no registered ore block was checked"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void storageBlocksExposeCompositionAndBothAdmissions(GameTestHelper helper) { - var iron = ItemMaterialRegistry.get(new ItemStack(Items.IRON_BLOCK)).orElseThrow(); - helper.assertTrue(iron.components().size() == 1 && iron.material().resolve() == Materials.Iron.resolve() - && iron.amount() == 9 * GTValues.U, "iron block contains exactly 9U Iron"); - helper.assertTrue(CrucibleItemInput.isValid(new ItemStack(Items.IRON_BLOCK)), "crucible admits iron block"); - for (Item item : List.of(Items.IRON_BLOCK, Items.COPPER_BLOCK)) { - var stack = new ItemStack(item); - helper.assertTrue(ItemMaterialRegistry.get(stack).isPresent(), "missing composition: " + id(stack)); - helper.assertTrue(ItemMaterialRegistry.canRecover(stack), "storage block is recoverable: " + id(stack)); - observe(helper, id(stack), stack); - } - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void traversalAndSingleQueriesUseTheSameEffectiveSnapshot(GameTestHelper helper) { - long tagged = 0; - for (var entry : ItemMaterialRegistry.entries().entrySet()) { - helper.assertTrue( - ItemMaterialRegistry.base(entry.getKey()).orElseThrow().equals(entry.getValue()), - "traversal and lookup disagree for " + id(new ItemStack(entry.getKey()))); - helper.assertTrue( - ItemMaterialRegistry.get(new ItemStack(entry.getKey())).orElseThrow().equals(entry.getValue()), - "stack lookup differs from base for " + id(new ItemStack(entry.getKey()))); - helper.assertFalse(entry.getValue().sources().isEmpty(), "composition has no provenance"); - if (entry.getValue().sources().stream() - .anyMatch(source -> source.kind() == ItemCompositionSource.Kind.FORM_TAG)) tagged++; - } - helper.assertTrue(ItemMaterialRegistry.tagInputReady(), "tag input generation is ready at runtime"); - helper.assertTrue( - ItemMaterialRegistry.compositionStatus(Items.DRAGON_EGG) - != ItemMaterialRegistry.CompositionLookupState.TAG_INPUT_NOT_READY, - "completed tag input distinguishes absence from an unpublished generation"); - helper.assertTrue( - gregtech.content.recipe.ExternalOreProcessing.taggedCompositions() == 0 || tagged > 0, - "loaded common-form tags contribute effective compositions"); - helper.assertTrue(ItemMaterialRegistry.explicit(Items.IRON_BLOCK).isPresent(), "explicit diagnostics remain"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void seventyTwoUnitsExposePlanAndQueryableOutput(GameTestHelper helper) { - var stack = new ItemStack(Items.ENCHANTED_GOLDEN_APPLE); - var data = ItemMaterialRegistry.get(stack).orElseThrow(); - helper.assertTrue(data.components().size() == 1 && data.material().resolve() == Materials.Gold.resolve() - && data.amount() == 72 * GTValues.U, "enchanted golden apple carries 72U Gold"); - var plan = MaterialRecoveryRules.dustPlan(data.amount()); - helper.assertTrue(plan.complete() && plan.representedUnits() == 72 * GTValues.U, - "72U dust planner preserves every unit"); - helper.assertTrue( - plan.stackCount() == 2 - && plan.piles().get(0).equals(new MaterialRecoveryRules.DustPile(MaterialPrefix.dust, 64)) - && plan.piles().get(1).equals(new MaterialRecoveryRules.DustPile(MaterialPrefix.dust, 8)), - "72U uses legal 64 dust plus 8 dust stacks"); - var oneSlot = gregtech.util.OM.dust(Materials.Gold, 72 * GTValues.U); - var allSlots = gregtech.util.OM.dustAll(Materials.Gold, 72 * GTValues.U); - helper.assertTrue( - oneSlot.getCount() == 64 - && allSlots.size() == 2 - && allSlots.get(0).getCount() == 64 - && allSlots.get(1).getCount() == 8, - "single-slot and complete dust adapters project the same plan"); - var recipe = find(MachineRecipeMaps.Shredder, List.of(stack), List.of()); - helper.assertTrue(recipe != null, "72U item has a queryable recycling recipe"); - helper.assertTrue( - recipe.mOutputs.length == 2 - && recipe.mOutputs[0].is(GTItems.getStack(MaterialPrefix.dust, Materials.Gold, 1) - .getItem()) - && recipe.mOutputs[0].getCount() == 64 - && recipe.mOutputs[1].is(GTItems.getStack(MaterialPrefix.dust, Materials.Gold, 1) - .getItem()) - && recipe.mOutputs[1].getCount() == 8, - "final shredder row preserves 72U Gold"); - write(helper, "72u.tsv", List.of("input\t" + describe(stack), "plan\t" + plan.piles(), - "lookup\t" + (recipe == null ? "absent" : signature(MachineRecipeMaps.Shredder, recipe)))); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void capsuleRecyclingUsesTheSharedStaticShredderPlan(GameTestHelper helper) { - var spec = Arrays.stream(PortableFluidContainerSpec.values()) - .filter(candidate -> candidate.id().equals("cell_tin")) - .findFirst() - .orElseThrow(); - var input = new ItemStack(gregtech.platform.Mc.item( - ResourceLocation.fromNamespaceAndPath("gt6ce", "fluid_" + spec.id()))); - var composition = ItemMaterialRegistry.get(input).orElseThrow(); - var expected = MaterialRecoveryRules.planShredderStatic( - composition, MachineRecipeMaps.Shredder.mOutputItemsCount); - var recipe = find(MachineRecipeMaps.Shredder, List.of(input), List.of()); - helper.assertTrue(expected.accepted() && recipe != null, "capsule Shredder recipe exists"); - helper.assertTrue(recipe.mDuration == expected.duration(), "capsule duration comes from the shared plan"); - helper.assertTrue( - recipe.mRecoveryOwnership != null - && recipe.mRecoveryOwnership.scope() - == Recipe.RecoveryOwnership.Scope.EXPLICIT - && recipe.mRecoveryOwnership.family().equals("capsule-cell"), - "capsule row carries typed explicit ownership"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void compositeHeadKeepsEveryComponentAcrossQueries(GameTestHelper helper) { - var stack = GTItems.getStack(MaterialPrefix.toolHeadDrill, Materials.Titanium, 1); - helper.assertFalse(stack.isEmpty(), "composite drill head exists"); - var explicit = ItemMaterialRegistry.explicit(stack.getItem()).orElseThrow(); - var actual = ItemMaterialRegistry.get(stack).orElseThrow(); - helper.assertTrue(explicit.equals(actual), "registry and pristine stack agree"); - helper.assertTrue(actual.components().size() == 2, "drill head has two components"); - helper.assertTrue(actual.components().get(0).material().resolve() == Materials.Titanium.resolve() - && actual.components().get(0).amount() == 4 * GTValues.U, "primary: 4U Titanium"); - helper.assertTrue(actual.components().get(1).material().resolve() == Materials.Steel.resolve() - && actual.components().get(1).amount() == 4 * GTValues.U, "secondary: 4U Steel"); - var form = MaterialEquivalence.form(stack); - helper.assertTrue(form == null, "a composite tool head is not a pure material form"); - helper.assertTrue(explicit.components().stream() - .anyMatch(component -> component.material().resolve() == Materials.Steel.resolve()), - "equivalence rejection does not discard the secondary Steel"); - var plan = MaterialRecoveryRules.planShredder(actual, MachineRecipeMaps.Shredder.mOutputItemsCount); - helper.assertTrue(plan.accepted(), "complete composite composition has a shredder plan"); - helper.assertTrue( - plan.outputs().stream() - .map(output -> output.material().resolve()) - .toList() - .containsAll(List.of( - Materials.Titanium.getTargetPulverMaterial().resolve(), - Materials.Steel.getTargetPulverMaterial().resolve())), - "composite shredder plan converts every component through its own pulverization target"); - observe(helper, "composite_head", stack); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void damagedToolsAndContainersExposeStateAdmission(GameTestHelper helper) { - var tool = new ItemStack(Items.IRON_PICKAXE); - helper.assertTrue(ItemMaterialRegistry.get(tool).isPresent(), "iron pickaxe composition exists"); - var full = ItemMaterialRegistry.get(tool).orElseThrow(); - observe(helper, "tool_full", tool); - tool.setDamageValue(tool.getMaxDamage() / 2); - var half = ItemMaterialRegistry.get(tool).orElseThrow(); - for (int i = 0; i < full.components().size(); i++) - helper.assertTrue(half.components().get(i).amount() == full.components().get(i).amount() - * (tool.getMaxDamage() - tool.getDamageValue()) / tool.getMaxDamage(), "damage scales component " + i); - observe(helper, "tool_partial", tool); - helper.assertTrue( - ItemMaterialRegistry.recoveryRejection(tool) - == ItemMaterialRegistry.RecoveryRejection.ELIGIBLE, - "partial tools retain an eligible scaled composition"); - var expectedHalf = MaterialRecoveryRules.planShredder(half, MachineRecipeMaps.Shredder.mOutputItemsCount); - var halfRecipe = find(MachineRecipeMaps.Shredder, List.of(tool), List.of()); - helper.assertTrue( - expectedHalf.accepted() && halfRecipe != null, - "partial tools query the Shredder from their remaining composition"); - helper.assertTrue( - halfRecipe.mOutputs.length == expectedHalf.stackCount(), - "partial tools recover exactly the scaled Shredder output"); - tool.setDamageValue(tool.getMaxDamage()); - helper.assertTrue(ItemMaterialRegistry.get(tool).orElseThrow().components().isEmpty(), "exhausted tool has no positive material"); - helper.assertFalse(ItemMaterialRegistry.canRecover(tool), "no recovery from exhausted tool"); - helper.assertTrue( - ItemMaterialRegistry.recoveryRejection(tool) - == ItemMaterialRegistry.RecoveryRejection.NO_COMPONENTS, - "exhausted recovery rejection names the empty composition"); - observe(helper, "tool_exhausted", tool); - var nativeTool = GTToolItem.create(GTToolType.PICKAXE, Materials.Iron, gregtech.engine.material.GTMaterialRegistry.get("Wood")); - helper.assertFalse(nativeTool.isEmpty(), "native material tool exists"); - helper.assertTrue(ItemMaterialRegistry.get(nativeTool).isEmpty(), "observed difference: native tool instance has no registry composition"); - observe(helper, "native_tool", nativeTool); - var empty = new ItemStack(Items.BUCKET); - var filled = new ItemStack(Items.WATER_BUCKET); - helper.assertTrue(CrucibleItemInput.isValid(empty), "empty bucket is meltable"); - helper.assertFalse(CrucibleItemInput.isValid(filled), "filled bucket is protected"); - observe(helper, "bucket_empty", empty); - observe(helper, "bucket_filled", filled); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void shapedMoldsExposeShapeCompositionAndRejection(GameTestHelper helper) { - var block = BuiltInRegistries.BLOCK.get(net.minecraft.resources.ResourceLocation.fromNamespaceAndPath("gt6ce", "mold_stone")); - helper.assertTrue(block instanceof MoldBlock, "stone casting mold is registered on both nodes"); - var empty = new ItemStack(block); - int mask = gregtech.content.blockentity.machine.MoldBlockEntity.randomDungeonShape(net.minecraft.util.RandomSource.create(0)); - var shaped = MoldItemData.withShape(empty.copy(), mask); - var composition = ItemMaterialRegistry.get(empty).orElseThrow(); - helper.assertTrue(composition.components().size() == 1 && composition.amount() == 45 * GTValues.U, - "stone mold carries its 45U construction composition"); - helper.assertTrue(ItemMaterialRegistry.canRecover(empty), "plain stone mold is admitted for recovery"); - helper.assertTrue(MoldItemData.shape(shaped) == mask, "casting cavity survives on the item"); - helper.assertTrue(ItemMaterialRegistry.get(empty).equals(ItemMaterialRegistry.get(shaped)), "shape keeps composition"); - helper.assertFalse(ItemMaterialRegistry.hasStoredContents(shaped), "a casting cavity is shape state, not inventory"); - helper.assertTrue(CrucibleItemInput.isValid(shaped), "a shaped casting mold remains meltable"); - helper.assertTrue(ItemMaterialRegistry.canRecover(shaped), "a shaped casting mold keeps bulk recovery"); - observe(helper, "casting_mold_empty", empty); - observe(helper, "casting_mold_shaped", shaped); - var press = GTTechnological.get("press_bullet_casing_shape_small"); - helper.assertTrue(press != null, "press mold is registered"); - helper.assertTrue(ItemMaterialRegistry.get(new ItemStack(press)).isEmpty(), - "observed difference: registered press mold has no composition (#350)"); - observe(helper, "press_mold", new ItemStack(press)); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void solidAndFluidDecompositionAreQueryable(GameTestHelper helper) { - var salt = GTItems.getStack(MaterialPrefix.dust, gregtech.engine.material.GTMaterialRegistry.get("Powellite"), 6); - var solid = find(MachineRecipeMaps.Electrolyzer, - List.of(new ItemStack(GTTechnological.selectorTag(0)), salt), List.of()); - helper.assertTrue(solid != null, "Powellite decomposition is queryable with mode 0 (accepted #318 rule)"); - helper.assertTrue( - solid.isCatalystInput(0) && Arrays.equals(solid.explicitCatalystInputs(), new int[] {0}), - "the electrolyser selector is an explicit presence-only catalyst"); - helper.assertTrue( - solid.mDuration == 1752 && solid.mEUt == 84, - "Powellite decomposition retains its planned duration and EU/t"); - helper.assertTrue( - solid.mOutputs.length == 2 - && solid.mOutputs[0].is(GTItems.getStack(MaterialPrefix.dust, Materials.Calcium, 1) - .getItem()) - && solid.mOutputs[0].getCount() == 1 - && solid.mOutputs[1].is(GTItems.getStack(MaterialPrefix.dust, Materials.Molybdenum, 1) - .getItem()) - && solid.mOutputs[1].getCount() == 1, - "Powellite solid outputs retain declaration order and quantities"); - helper.assertTrue( - Arrays.stream(solid.mFluidOutputs) - .anyMatch(output -> output != null - && output.getAmount() == 4000 - && "oxygen".equals(BuiltInRegistries.FLUID - .getKey(output.getFluid()) - .getPath())), - "Powellite oxygen output uses the declared gas conversion"); - var water = new FluidStack(net.minecraft.world.level.material.Fluids.WATER, 3000); - var liquid = find(MachineRecipeMaps.Electrolyzer, - List.of(new ItemStack(GTTechnological.selectorTag(0))), List.of(water)); - helper.assertTrue(liquid != null, "water decomposition is queryable with fluid input"); - var alloy = gregtech.engine.material.GTMaterialRegistry.get("AluminiumAlloy"); - var alloyDust = GTItems.getStack(MaterialPrefix.dust, alloy, 45); - var alloyBlock = gregtech.content.registry.GTBlocks.getStack( - gregtech.engine.prefix.BlockMaterialPrefix.blockDust, alloy); - alloyBlock.setCount(5); - helper.assertTrue( - find(MachineRecipeMaps.Centrifuge, List.of(alloyDust), List.of()) != null - && find(MachineRecipeMaps.Centrifuge, List.of(alloyBlock), List.of()) != null, - "AluminiumAlloy without a fluid binding retains both solid decomposition inputs"); - helper.assertTrue(Arrays.stream(solid.mOutputs).anyMatch(s -> s != null && !s.isEmpty()) - || Arrays.stream(solid.mFluidOutputs).anyMatch(s -> s != null && !s.isEmpty()), "solid decomposition has outputs"); - helper.assertTrue(Arrays.stream(liquid.mFluidOutputs).anyMatch(s -> s != null && !s.isEmpty()), "water decomposition has fluid outputs"); - write(helper, "decomposition.tsv", List.of(signature(MachineRecipeMaps.Electrolyzer, solid), signature(MachineRecipeMaps.Electrolyzer, liquid))); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void decompositionRespectsFormsAndExactFluidIdentities(GameTestHelper helper) { - var owned = gregtech.content.recipe.DecompositionRecipeLoader.owned(); - for (var test : MaterialBaselineAddon.DECOMPOSITIONS) { - var material = gregtech.engine.material.GTMaterialRegistry.get(test.material()); - var key = new MaterialKey(material.getName()); - helper.assertTrue(MaterialInfoTool.currentProcess(key, MaterialProcessKeys.DECOMPOSITION) - .equals(GregTechMaterials.processes().findSingle(key, MaterialProcessKeys.DECOMPOSITION)), - test.material() + " process queries agree"); - var dust = GTItems.getStack(MaterialPrefix.dust, material, 9); - var block = gregtech.content.registry.GTBlocks.getStack( - gregtech.engine.prefix.BlockMaterialPrefix.blockDust, material); - helper.assertFalse(dust.isEmpty() || block.isEmpty(), test.material() + " solid fixtures registered"); - boolean dustRow = owned.stream().anyMatch(row -> Arrays.stream(row.mInputs) - .anyMatch(input -> input != null && input.is(dust.getItem()))); - boolean blockRow = owned.stream().anyMatch(row -> Arrays.stream(row.mInputs) - .anyMatch(input -> input != null && input.is(block.getItem()))); - helper.assertTrue(dustRow == test.form().equals("dust"), test.material() + " dust permission"); - helper.assertTrue(blockRow == test.form().equals("blockDust"), test.material() + " block permission"); - String fluidId = test.fluid() == null || !test.fluid().contains(":") - ? "material_baseline_test:" + test.material().toLowerCase(java.util.Locale.ROOT) - : test.fluid(); - var id = ResourceLocation.tryParse(fluidId); - boolean registered = id != null && BuiltInRegistries.FLUID.containsKey(id); - boolean allowsFluid = test.form().equals("liquid") || test.form().equals("gas"); - Recipe row = null; - if (registered) { - var fluid = BuiltInRegistries.FLUID.get(id); - row = owned.stream().filter(candidate -> Arrays.stream(candidate.mFluidInputs) - .anyMatch(input -> input != null && input.getFluid() == fluid)).findFirst().orElse(null); - } - helper.assertTrue((row != null) == (registered && allowsFluid), test.material() + " fluid permission and identity"); - if (row != null) { - helper.assertTrue(row.mFluidInputs.length == 1 && row.mFluidInputs[0].getAmount() == 1000, - test.material() + " exact fluid conversion after recipe reduction"); - helper.assertTrue(row.mOutputs.length == 1 && row.mOutputs[0].getCount() == 1 - && row.mOutputs[0].is(GTItems.getStack(MaterialPrefix.dust, Materials.Iron, 1).getItem()), - test.material() + " complete solid output"); - helper.assertTrue(row.mDuration == 292 && row.mEUt == 126, - test.material() + " reduced duration and unchanged EU/t"); - } - } - var outputMaterial = gregtech.engine.material.GTMaterialRegistry.get("BaselineFluidOutput"); - var outputRow = find(MachineRecipeMaps.Centrifuge, - List.of(GTItems.getStack(MaterialPrefix.dust, outputMaterial, 2)), List.of()); - helper.assertTrue(outputRow != null && outputRow.mFluidOutputs.length == 1, - "namespaced fluid output does not discard the entire decomposition plan"); - helper.assertTrue(outputRow.mFluidOutputs[0].getAmount() == 1000 - && BuiltInRegistries.FLUID.getKey(outputRow.mFluidOutputs[0].getFluid()).toString() - .equals("material_baseline_test:baselineliquidonly"), - "namespaced addon fluid output retains identity and quantity"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void compositionAdmissionAndCookingPolicyStayIndependent(GameTestHelper helper) { - var descriptive = ItemMaterialRegistry.entries().entrySet().stream() - .filter(entry -> entry.getValue().sources().stream() - .anyMatch(source -> source.kind() == ItemCompositionSource.Kind.VANILLA_JSON)) - .findFirst() - .orElseThrow(); - var stack = new ItemStack(descriptive.getKey()); - helper.assertTrue(ItemMaterialRegistry.get(stack).isPresent(), "descriptive composition is queryable"); - helper.assertTrue(ItemMaterialRegistry.canMelt(stack), "composition existence remains independently meltable"); - helper.assertTrue( - ItemMaterialRegistry.canRecover(stack), - "GT6 has no separate item-level bulk recovery authorization"); - helper.assertTrue( - ItemMaterialRegistry.recoveryRejection(stack) - == ItemMaterialRegistry.RecoveryRejection.ELIGIBLE, - "composition admission remains independent of the selected process"); - helper.assertFalse( - ItemMaterialRegistry.hasMaterialProcessingRule(stack), - "descriptive vanilla data does not delete material cooking rules"); - var materialItem = GTItems.getStack(MaterialPrefix.ingot, Materials.Iron, 1); - helper.assertTrue( - ItemMaterialRegistry.hasMaterialProcessingRule(materialItem), - "native material forms retain material cooking policy"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void addonThermalRecoveryUsesDeclaredTargetAndPhase(GameTestHelper helper) { - var material = gregtech.engine.material.GTMaterialRegistry.get("BaselineThermalAddon"); - var dust = GTItems.getStack(MaterialPrefix.dust, material, 1); - helper.assertFalse(dust.isEmpty(), "addon dust form is registered"); - var smelting = GregTechMaterials.processes() - .findSingle(new MaterialKey(material.getName()), MaterialProcessKeys.SMELTING) - .filter(rule -> rule.value().amount() > 0) - .orElseThrow(); - helper.assertTrue( - material.getName().equals(smelting.value().material().name()), - "addon smelting target is its declared material"); - helper.assertTrue( - gregtech.engine.recipe.chem.MaterialFluidBinding.findAll(material.getName()).size() == 1, - "addon has one declared thermal phase"); - var composition = ItemMaterialRegistry.base(dust.getItem()).orElseThrow(); - helper.assertTrue( - composition.prefix() == MaterialPrefix.dust - && composition.material().resolve() == material - && composition.components().size() == 1, - "addon dust uses its authoritative composition"); - helper.assertTrue(ItemMaterialRegistry.canRecover(dust), "addon dust is recoverable"); - var recipe = find(MachineRecipeMaps.Smelter, List.of(dust), List.of()); - var matchingRows = MachineRecipeMaps.Smelter.mRecipeList.stream() - .filter(row -> row.mInputs.length == 1 - && !row.mInputs[0].isEmpty() - && row.mInputs[0].getItem() == dust.getItem()) - .toList(); - helper.assertTrue( - recipe != null, - "addon material participates in thermal recovery; matching-row-count=" - + matchingRows.size() - + "; input-matches=" - + matchingRows.stream().anyMatch(row -> row.matchesItemInput(0, dust))); - helper.assertTrue( - Arrays.stream(recipe.mFluidOutputs) - .anyMatch(output -> output != null && !output.isEmpty()), - "addon thermal row uses its declared native phase"); - helper.assertTrue( - Arrays.stream(recipe.mFluidOutputs).anyMatch(output -> output.getAmount() == 1000), - "one addon material unit uses its declared 1000 mB phase scale"); - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void tagCandidateReplacementIsAtomicAndRemovalIsObservable(GameTestHelper helper) { - var item = Items.DRAGON_EGG; - helper.assertTrue(ItemMaterialRegistry.explicit(item).isEmpty(), "tag probe item has no explicit composition"); - var first = taggedComposition(Materials.Copper, 4); - try { - ItemMaterialRegistry.publishTagCandidates(Map.of(item, List.of(first))); - var effective = ItemMaterialRegistry.base(item).orElseThrow(); - var diagnosis = ItemMaterialRegistry.compositionDiagnosis(item).orElseThrow(); - helper.assertTrue( - effective.equals(diagnosis.selected()), - "composition diagnosis exposes the effective selection"); - helper.assertTrue( - diagnosis.decisions().stream() - .anyMatch(decision -> decision.status() - == gregtech.engine.material.ItemCompositionDecision.Status.SELECTED), - "composition diagnosis records the selected source"); - long revision = ItemMaterialRegistry.compositionRevision(); - var generation = ItemMaterialRegistry.compositionState(); - - ItemMaterialRegistry.beginTagGeneration(); - var pending = ItemMaterialRegistry.compositionState(); - helper.assertFalse(pending.tagInputReady(), "a new tag generation starts before its input is ready"); - helper.assertTrue( - pending.tagGeneration() == generation.tagGeneration() + 1, - "starting a session advances the tag generation exactly once"); - helper.assertTrue( - ItemMaterialRegistry.base(item).isEmpty(), - "a new generation does not expose the previous server's tag candidates"); - helper.assertTrue(pending.explicitClosed(), "explicit definitions remain process-static"); - ItemMaterialRegistry.publishTagCandidates(Map.of(item, List.of(first))); - revision = ItemMaterialRegistry.compositionRevision(); - - IllegalStateException conflict = null; - try { - ItemMaterialRegistry.publishTagCandidates(Map.of( - item, - List.of(taggedComposition(Materials.Iron, 1), taggedComposition(Materials.Gold, 2)))); - } catch (IllegalStateException failure) { - conflict = failure; - } - helper.assertTrue(conflict != null, "conflicting tag candidates must fail"); - helper.assertTrue( - effective.equals(ItemMaterialRegistry.base(item).orElseThrow()), - "failed tag publication preserves the previous effective composition"); - helper.assertTrue( - ItemMaterialRegistry.compositionRevision() == revision, - "failed tag publication does not advance the composition revision"); - - ItemMaterialRegistry.publishTagCandidates(Map.of(item, List.of())); - helper.assertTrue( - ItemMaterialRegistry.base(item).isEmpty(), - "removed tag candidates drop the effective composition"); - helper.assertTrue( - ItemMaterialRegistry.compositionDiagnosis(item).isEmpty(), - "removed tag candidates also withdraw their diagnosis"); - - var descriptive = ItemMaterialRegistry.entries().entrySet().stream() - .filter(entry -> entry.getValue().sources().stream() - .anyMatch(source -> source.kind() == ItemCompositionSource.Kind.VANILLA_JSON)) - .findFirst() - .orElseThrow(); - var declaredItem = descriptive.getKey(); - ItemMaterialRegistry.publishTagCandidates( - Map.of(declaredItem, List.of(taggedComposition(MaterialPrefix.ingot, Materials.Iron, GTValues.U)))); - helper.assertTrue( - ItemMaterialRegistry.base(declaredItem).orElseThrow().sources().stream() - .allMatch(source -> source.kind() == ItemCompositionSource.Kind.VANILLA_JSON), - "explicit JSON remains the selected composition over a tag fallback"); - helper.assertFalse( - ItemMaterialRegistry.hasMaterialProcessingRule(new ItemStack(declaredItem)), - "a discarded lower-priority tag does not authorize cooking rules"); - - boolean closed = false; - try { - ItemMaterialRegistry.register( - Items.DRAGON_EGG, - new ItemComposition(null, Materials.Copper, 4), - ItemCompositionSource.Kind.VANILLA_JSON, - "gt6ce:test/closed-explicit", - "GameTest closed explicit registration"); - } catch (IllegalStateException expected) { - closed = expected.getMessage().contains("closed"); - } - helper.assertTrue(closed, "explicit item composition registration closes after final validation"); - } finally { - ItemMaterialRegistry.publishTagCandidates(Map.of(item, List.of())); - } - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void failedTagGenerationRestoresThePreviousPublicationState(GameTestHelper helper) { - var item = Items.DRAGON_EGG; - var previous = taggedComposition(Materials.Copper, 4); - try { - ItemMaterialRegistry.publishTagCandidates(Map.of(item, List.of(previous))); - var previousComposition = ItemMaterialRegistry.base(item).orElseThrow(); - var previousDiagnosis = ItemMaterialRegistry.compositionDiagnosis(item).orElseThrow(); - var previousState = ItemMaterialRegistry.compositionState(); - var previousPublication = MaterialPublication.current(); - - var checkpoint = ItemMaterialRegistry.beginTagGeneration(); - ItemMaterialRegistry.publishTagCandidates( - Map.of(item, List.of(taggedComposition(Materials.Iron, GTValues.U)))); - helper.assertFalse( - previousComposition.equals(ItemMaterialRegistry.base(item).orElseThrow()), - "a pending tag generation can replace the effective composition"); - - ItemMaterialRegistry.restoreTagGeneration(checkpoint); - helper.assertTrue( - previousComposition.equals(ItemMaterialRegistry.base(item).orElseThrow()), - "rolling back a failed generation restores the previous effective composition"); - helper.assertTrue( - previousDiagnosis.equals(ItemMaterialRegistry.compositionDiagnosis(item).orElseThrow()), - "rolling back a failed generation restores the previous composition diagnosis"); - helper.assertTrue( - previousState.equals(ItemMaterialRegistry.compositionState()), - "rolling back a failed generation restores readiness, generation and revision state"); - helper.assertTrue( - previousPublication == MaterialPublication.current(), - "rolling back a failed generation leaves the last successful publication untouched"); - } finally { - ItemMaterialRegistry.publishTagCandidates(Map.of(item, List.of())); - } - helper.succeed(); - } - - @GameTest(template = "test_empty", batch = BATCH, timeoutTicks = 200) - public static void tagDrivenShredderRowsFollowTheEffectiveSnapshot(GameTestHelper helper) { - var item = Items.CARROT_ON_A_STICK; - var stack = new ItemStack(item); - helper.assertTrue(ItemMaterialRegistry.explicit(item).isEmpty(), "probe item starts without explicit material"); - var cachedSnapshot = ItemMaterialRegistry.entries(); - helper.assertTrue( - cachedSnapshot == ItemMaterialRegistry.entries(), - "unchanged composition revision reuses the traversal snapshot"); - try { - ItemMaterialRegistry.publishTagCandidates( - Map.of(item, List.of(taggedComposition(MaterialPrefix.ingot, Materials.Copper, GTValues.U)))); - helper.assertFalse( - cachedSnapshot == ItemMaterialRegistry.entries(), - "published tag changes invalidate the traversal snapshot"); - gregtech.content.recipe.ShredderRecyclingRecipes.rebuildTagRows(); - var recipe = find(MachineRecipeMaps.Shredder, List.of(stack), List.of()); - helper.assertTrue(recipe != null, "tag-derived composition creates a Shredder row"); - helper.assertTrue(recipe.mMaterialRecovery, "tag-derived Shredder row uses recovery admission"); - helper.assertTrue( - Arrays.stream(recipe.mOutputs) - .anyMatch(output -> output.is(GTItems.getStack(MaterialPrefix.dust, Materials.Copper, 1) - .getItem())), - "tag-derived Shredder row uses the resolved composition"); - var damaged = stack.copy(); - damaged.setDamageValue(1); - helper.assertTrue( - find(MachineRecipeMaps.Shredder, List.of(damaged), List.of()) != null, - "tag-derived Shredder row rebuilds output from damaged input"); - CraftingMaterialForms.rebuild(true); - var resolvedForm = CraftingMaterialForms.form(stack); - helper.assertTrue( - resolvedForm != null - && resolvedForm.prefix().equals("ingot") - && resolvedForm.material().equals("Copper"), - "form consumers read the resolved tag composition"); - gregtech.engine.material.MaterialFormContent.publish(); - helper.assertTrue( - GregTechMaterials.formBindings().find(new MaterialKey("Copper")).stream() - .anyMatch(binding -> binding.id().equals("minecraft:carrot_on_a_stick")), - "published form bindings include the tag-derived item"); - - ItemMaterialRegistry.publishTagCandidates(Map.of()); - gregtech.content.recipe.ShredderRecyclingRecipes.rebuildTagRows(); - helper.assertTrue( - ItemMaterialRegistry.compositionStatus(item) - == ItemMaterialRegistry.CompositionLookupState.ABSENT, - "cleared tag generation remains distinct from an unpublished generation"); - helper.assertTrue( - find(MachineRecipeMaps.Shredder, List.of(stack), List.of()) == null, - "removing the tag composition withdraws its Shredder row"); - gregtech.engine.material.MaterialFormContent.publish(); - helper.assertFalse( - GregTechMaterials.formBindings().find(new MaterialKey("Copper")).stream() - .anyMatch(binding -> binding.id().equals("minecraft:carrot_on_a_stick")), - "removing the tag composition withdraws its public form binding"); - } finally { - ItemMaterialRegistry.publishTagCandidates(Map.of()); - gregtech.content.recipe.ShredderRecyclingRecipes.clearTagRows(); - CraftingMaterialForms.rebuild(); - } - helper.succeed(); - } - - // GameTest runs batches sequentially, so the asynchronous reload cannot overlap other tests. - @GameTest(template = "test_empty", batch = "material_baseline_reload", timeoutTicks = 6000) - public static void realResourceReloadDoesNotAccumulateRules(GameTestHelper helper) { - var server = helper.getLevel().getServer(); - var packs = List.copyOf(server.getPackRepository().getSelectedIds()); - int applications = MachineRecipeOverlay.applications(); - long compositionRevision = ItemMaterialRegistry.compositionRevision(); - var compositions = compositionSnapshot(); - capture(helper, "startup"); - var before = ownedCounts(); - var sample = describe(new ItemStack(Items.IRON_BLOCK)); - RELOAD_COMPLETE.set(false); - RELOAD_FAILURE.set(null); - server.reloadResources(packs).thenCompose(ignored -> server.reloadResources(packs)).whenComplete((ignored, failure) -> { - RELOAD_FAILURE.set(failure); - RELOAD_COMPLETE.set(true); - }); - awaitReload(helper, applications, compositionRevision, compositions, before, sample); - } - - @GameTest(template = "test_empty", batch = "material_baseline_reload", timeoutTicks = 600) - public static void materialProcessSnapshotIsBoundedAndCurrent(GameTestHelper helper) { - var snapshot = MaterialProcessSnapshot.Store.current(); - var worldgen = MaterialWorldgenFacts.capture(); - helper.assertTrue( - snapshot.samePublication(MachineRecipeOverlay.lastPublication()), - "process graph uses the successful material publication"); - helper.assertTrue( - snapshot.snapshot().worldgenRevision() == worldgen.revision(), - "process graph binds the active worldgen fact revision"); - helper.assertFalse(worldgen.facts().isEmpty(), "active worldgen facts are present"); - helper.assertTrue( - worldgen.revision() == MaterialWorldgenFacts.capture().revision(), - "worldgen fact revision is stable"); - helper.assertTrue( - worldgen.facts().stream() - .allMatch(fact -> !fact.ores().isEmpty() - && fact.minY() <= fact.maxY() - && fact.ores().stream().allMatch(ore -> ore.minY() <= ore.maxY())), - "worldgen facts retain bounded, ordered native heights"); - helper.assertFalse(snapshot.roots().isEmpty(), "process graph exposes published material roots"); - var budgets = gregtech.engine.material.MaterialProcessGraph.Budgets.DEFAULT; - for (var root : snapshot.roots().stream().limit(24).toList()) { - var first = snapshot.query( - root.resource(), gregtech.engine.material.MaterialProcessGraph.Direction.BOTH, budgets); - var second = snapshot.query( - root.resource(), gregtech.engine.material.MaterialProcessGraph.Direction.BOTH, budgets); - helper.assertTrue(first.steps().size() <= budgets.maxSteps(), "step budget is enforced"); - helper.assertTrue(first.edges().size() <= budgets.maxEdges(), "edge budget is enforced"); - helper.assertFalse(first.notices().isEmpty(), "coverage is always reported"); - helper.assertTrue(first.steps().equals(second.steps()), "repeated queries have stable steps"); - helper.assertTrue(first.edges().equals(second.edges()), "repeated queries have stable edges"); - var references = first.steps().stream() - .map(gregtech.engine.material.MaterialProcessGraph.Step::reference) - .collect(java.util.stream.Collectors.toSet()); - helper.assertTrue( - first.edges().stream() - .allMatch(edge -> references.contains(edge.source()) - && references.contains(edge.target())), - "every edge endpoint belongs to the bounded query result"); - } - helper.succeed(); - } - - private static void awaitReload( - GameTestHelper helper, - int applications, - long compositionRevision, - Map compositions, - List before, - String sample) { - if (!RELOAD_COMPLETE.get()) { - helper.runAfterDelay( - 1, () -> awaitReload(helper, applications, compositionRevision, compositions, before, sample)); - return; - } - var failure = RELOAD_FAILURE.get(); - if (failure != null) { - helper.fail("resource reload failed: " + failure); - return; - } - helper.assertTrue( - MachineRecipeOverlay.applications() >= applications + 2, - "both real reloads applied the overlay"); - helper.assertTrue( - before.equals(ownedCounts()), "owned rules do not accumulate: " + before + " -> " + ownedCounts()); - helper.assertTrue( - sample.equals(describe(new ItemStack(Items.IRON_BLOCK))), - "fixed composition is stable after reload"); - helper.assertTrue( - ItemMaterialRegistry.compositionRevision() >= compositionRevision, - "reload invalidates composition-dependent caches"); - helper.assertTrue( - MachineRecipeOverlay.lastPublication().recipeRevision() == MachineRecipeOverlay.generation(), - "the successful recipe overlay publishes one stable material/composition/recipe stamp"); - helper.assertTrue( - MachineRecipeOverlay.lastPublication().compositionRevision() - == ItemMaterialRegistry.compositionRevision(), - "the publication stamp names the composition snapshot used by the recipe overlay"); - helper.assertTrue( - MaterialProcessSnapshot.Store.current().samePublication(MachineRecipeOverlay.lastPublication()), - "the process graph republished with the successful recipe generation"); - helper.assertTrue( - compositions.equals(compositionSnapshot()), - "repeat reload preserves effective composition membership and values"); - capture(helper, "reload"); - var reloadedRecipe = find(MachineRecipeMaps.Shredder, List.of(new ItemStack(Items.IRON_INGOT)), List.of()); - helper.assertTrue( - reloadedRecipe != null, - "iron ingot recycling remains queryable after reload"); - var powellite = - GTItems.getStack(MaterialPrefix.dust, gregtech.engine.material.GTMaterialRegistry.get("Powellite"), 6); - var reloadedDecomposition = find( - MachineRecipeMaps.Electrolyzer, - List.of(new ItemStack(GTTechnological.selectorTag(0)), powellite), - List.of()); - helper.assertTrue(reloadedDecomposition != null, "decomposition row is rebuilt after reload"); - helper.succeed(); - } - - private static List ownedCounts() { - return List.of(gregtech.content.recipe.ExternalOreProcessing.owned().size(), - gregtech.content.recipe.DecompositionRecipeLoader.owned().size(), - gregtech.content.recipe.ShredderRecyclingRecipes.owned().size(), - gregtech.content.recipe.SharedThermalInputRows.owned().size()); - } - - private static Recipe find(RecipeMap map, List items, List fluids) { - return map.findRecipe(items, fluids, false, map.mInputItemsCount, map.mOutputItemsCount); - } - - private static String id(ItemStack stack) { return BuiltInRegistries.ITEM.getKey(stack.getItem()).toString(); } - - private static ItemComposition taggedComposition(gregtech.api.material.GTMaterial material, long amount) { - return taggedComposition(null, material, amount); - } - - private static ItemComposition taggedComposition( - MaterialPrefix prefix, gregtech.api.material.GTMaterial material, long amount) { - return new ItemComposition( - prefix, - List.of(gregtech.api.material.MaterialComponent.of(material, amount)), - material, - List.of(new ItemCompositionSource(ItemCompositionSource.Kind.FORM_TAG, "probe", "test", "", "")), - true); - } - - private static Map compositionSnapshot() { - var entries = new TreeMap(); - for (var entry : ItemMaterialRegistry.entries().entrySet()) - entries.put(id(new ItemStack(entry.getKey())), entry.getValue()); - return Map.copyOf(entries); - } - - private static String describe(ItemStack stack) { - var data = ItemMaterialRegistry.get(stack).orElse(null); - String state = "\tdamage=" + stack.getDamageValue() + "/" + stack.getMaxDamage() + "\tshape=" + MoldItemData.shape(stack); - if (data == null) return id(stack) + "\tabsent" + state; - return id(stack) + "\t" + (data.prefix() == null ? "-" : data.prefix().getName()) - + "\t" + data.material().resolve().getName() + "\t" + data.components().stream() - .map(c -> c.material().resolve().getName() + "=" + c.amount()).sorted().collect(Collectors.joining(",")) - + "\t" + data.bulkRecoveryAllowed() + "\t" + ItemMaterialRegistry.canRecover(stack) - + "\t" + ItemMaterialRegistry.canMelt(stack) + "\t" + ItemMaterialRegistry.hasStoredContents(stack) - + "\t" + CrucibleItemInput.parse(stack).stream().map(c -> c.material.getName() + "=" + c.amount).sorted().collect(Collectors.joining(",")) - + "\t" + data.source() + state; - } - - private static void observe(GameTestHelper helper, String name, ItemStack stack) { - write(helper, name.replace(':', '_') + ".tsv", List.of(describe(stack))); - } - - private static String signature(RecipeMap map, Recipe row) { - var slots = new ArrayList(); - for (int i = 0; i < row.mInputs.length; i++) { - var unit = row.materialInputDisplay(i); - // A tag's representative is selected from an unordered set; it is not the input contract. - String input = row.itemTag(i) == null ? item(row.mInputs[i]) - : "tag:" + row.itemTag(i).location() + "*" + row.mInputs[i].getCount(); - slots.add("in[" + i + "]=" + input + (unit == null ? "" : ":unit:" + unit.amount() + ":" + unit.rounding()) - + ":tag=" + (row.itemTag(i) == null ? "-" : row.itemTag(i).location()) - + ":catalyst=" + row.isCatalystInput(i) + ":guard=" + row.hasItemInputGuard(i)); - } - for (int i = 0; i < row.mOutputs.length; i++) slots.add("out[" + i + "]=" + item(row.mOutputs[i]) + ":chance=" + row.getOutputChance(i)); - for (int i = 0; i < row.mFluidInputs.length; i++) slots.add("fluidIn[" + i + "]=" - + (row.fluidTag(i) == null ? fluid(row.mFluidInputs[i]) - : "tag:" + row.fluidTag(i).location() + "*" + row.mFluidInputs[i].getAmount()) - + ":tag=" + (row.fluidTag(i) == null ? "-" : row.fluidTag(i).location()) - + ":catalyst=" + row.isCatalystFluidInput(i) + ":presence=" + row.isPresenceFluidInput(i)); - for (int i = 0; i < row.mFluidOutputs.length; i++) slots.add("fluidOut[" + i + "]=" + fluid(row.mFluidOutputs[i])); - return map.mNameInternal + "\t" + String.join(";", slots) + "\t" + row.mDuration + "\t" + row.mEUt + "\t" + row.mSpecialValue - + "\t" + row.mEnabled + "/" + row.mFakeRecipe + "/" + row.mNeedsEmptyOutput + "/" + row.mMaterialRecovery - + "/" + row.mRequiresEmptyContainerInputs + "/" + row.mExactItemInputs + "/" + row.mExplicitCatalystsOnly; - } - - private static String item(ItemStack stack) { return stack == null || stack.isEmpty() ? "-" : id(stack) + "*" + stack.getCount(); } - private static String fluid(FluidStack stack) { return stack == null || stack.isEmpty() ? "-" : BuiltInRegistries.FLUID.getKey(stack.getFluid()) + "*" + stack.getAmount(); } - - private static void capture(GameTestHelper helper, String phase) { - write(helper, phase + "-items.tsv", BuiltInRegistries.ITEM.stream().map(ItemStack::new) - .filter(s -> ItemMaterialRegistry.base(s.getItem()).isPresent()).map(MaterialBaselineTests::describe).sorted().toList()); - var rows = new ArrayList(); - for (var map : RecipeMap.RECIPE_MAP_LIST) for (var row : map.mRecipeList) rows.add(signature(map, row)); - rows.sort(String::compareTo); - write(helper, phase + "-recipes.tsv", rows); - var tags = new java.util.TreeMap(); - for (var map : RecipeMap.RECIPE_MAP_LIST) for (var row : map.mRecipeList) { - for (int i = 0; i < row.mInputs.length; i++) { - var tag = row.itemTag(i); - if (tag != null) tags.computeIfAbsent("item:" + tag.location(), key -> BuiltInRegistries.ITEM.getTag(tag) - .map(set -> set.stream().map(holder -> BuiltInRegistries.ITEM.getKey(holder.value()).toString()) - .sorted().collect(Collectors.joining(","))).orElse("")); - } - for (int i = 0; i < row.mFluidInputs.length; i++) { - var tag = row.fluidTag(i); - if (tag != null) tags.computeIfAbsent("fluid:" + tag.location(), key -> BuiltInRegistries.FLUID.getTag(tag) - .map(set -> set.stream().map(holder -> BuiltInRegistries.FLUID.getKey(holder.value()).toString()) - .sorted().collect(Collectors.joining(","))).orElse("")); - } - } - write(helper, phase + "-tags.tsv", tags.entrySet().stream().map(entry -> entry.getKey() + "\t" + entry.getValue()).toList()); - write(helper, phase + "-forms.tsv", BuiltInRegistries.ITEM.stream() - .filter(item -> item instanceof gregtech.engine.material.MaterialFormItem) - .map(item -> { - var form = (gregtech.engine.material.MaterialFormItem) item; - return BuiltInRegistries.ITEM.getKey(item) + "\t" + form.getPrefix().getName() + "\t" - + form.getMaterial().resolve().getName() + "\t" + form.getPrefix().getMaterialWeight() - + "\t" + form.getPrefix().isValidFor(form.getMaterial()); - }).sorted().toList()); - write(helper, phase + "-block-forms.tsv", BuiltInRegistries.BLOCK.stream() - .filter(block -> block instanceof gregtech.content.block.MaterialBlockLike) - .map(block -> { - var form = (gregtech.content.block.MaterialBlockLike) block; - return BuiltInRegistries.BLOCK.getKey(block) + "\t" + BuiltInRegistries.ITEM.getKey(block.asItem()) - + "\t" + form.prefix().getName() + "\t" + form.material().resolve().getName() - + "\t" + form.prefix().getMaterialWeight() + "\t" + form.prefix().isValidFor(form.material()); - }).sorted().toList()); - } - - private static void write(GameTestHelper helper, String file, List rows) { - try { - Path run = Path.of("").toAbsolutePath(); - Path root = run; - while (root != null && !Files.isRegularFile(root.resolve("settings.gradle"))) root = root.getParent(); - if (root == null) throw new IllegalStateException("cannot find repository root for baseline output"); - Path output = root.resolve("work/material-system-refactor/runtime") - .resolve(net.minecraft.SharedConstants.getCurrentVersion().getName()).resolve(run.getFileName()); - Files.createDirectories(output); - Files.write(output.resolve(file), rows); - } catch (Exception failure) { helper.fail("cannot write material baseline: " + failure); } - } -} diff --git a/minecraft/src/test/resources/META-INF/services/gregtech.api.addon.material.AddonMaterialContributor b/minecraft/src/test/resources/META-INF/services/gregtech.api.addon.material.AddonMaterialContributor deleted file mode 100644 index 50cc4dc9a..000000000 --- a/minecraft/src/test/resources/META-INF/services/gregtech.api.addon.material.AddonMaterialContributor +++ /dev/null @@ -1 +0,0 @@ -gregtech.gametest.MaterialBaselineAddon diff --git a/tools/material/README.md b/tools/material/README.md index 82b8f131d..5cc7bcb62 100644 --- a/tools/material/README.md +++ b/tools/material/README.md @@ -12,7 +12,7 @@ - `reload-recipes.tsv` - `reload-tags.tsv` -这些文件由共享 `MaterialBaselineTests` 生成。必须使用同一次首次启动或重载代,不能混用不同运行目录。 +这些文件来自已删除的历史材料基线 GameTest。当前测试集不再生成新快照;本工具仅用于复核仍保存在 `work/` 中的历史证据,不能把旧目录当作当前实现验证。 ## 运行 From 9e21aebb6eb06a7ed417146dd3a6c606b87c0550 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Mon, 16 Nov 2026 00:22:07 +0800 Subject: [PATCH 11/17] remove excess docs --- AGENTS.md | 4 +- README.md | 1 - README.zh-CN.md | 2 - .../machine/OriginalMachineMaterialData.java | 3 +- docs/AGENTS.md | 3 +- docs/README.md | 5 +- docs/architecture/packages/content.md | 2 +- .../packages/platforms/neoforge.md | 2 +- docs/architecture/packages/runtime.md | 4 +- docs/decisions/0001-material-data-api.md | 277 ------------------ docs/decisions/README.md | 2 +- docs/development/README.md | 2 - docs/development/material-process-display.md | 139 --------- docs/development/material-process-layout.md | 160 ---------- .../01-03-implementation-summary.md | 78 ----- .../material-system-refactor/01-baseline.md | 89 ------ .../02-material-registration.md | 101 ------- .../03-properties-and-forms.md | 82 ------ .../04-item-composition.md | 139 --------- .../material-system-refactor/05-recovery.md | 121 -------- .../06-decomposition.md | 106 ------- .../07-cleanup-and-acceptance.md | 227 -------------- .../07-recipe-package-audit.md | 83 ------ .../08-material-data-api.md | 212 -------------- .../material-system-refactor/README.md | 88 ------ .../pr-374-review-actions.md | 146 --------- docs/development/repository-layout.md | 8 +- docs/development/validation/README.md | 2 +- .../validation/checks/manual-ingame.md | 2 +- docs/integration/README.md | 16 - docs/integration/material-baseline.md | 136 --------- docs/integration/material-process-snapshot.md | 52 ---- .../material-refactor-01-02-review.md | 0 .../material-refactor-04-composition.md | 94 ------ .../material-refactor-05-recovery.md | 84 ------ .../material-refactor-06-decomposition.md | 47 --- .../material-refactor-07-roster.md | 201 ------------- docs/integration/report-template.md | 26 -- docs/operations/README.md | 24 -- docs/operations/records/README.md | 9 - docs/operations/records/TEMPLATE.md | 28 -- docs/roadmap/v1.0.md | 51 ---- tools/material/README.md | 2 +- 43 files changed, 16 insertions(+), 2844 deletions(-) delete mode 100644 docs/decisions/0001-material-data-api.md delete mode 100644 docs/development/material-process-display.md delete mode 100644 docs/development/material-process-layout.md delete mode 100644 docs/development/material-system-refactor/01-03-implementation-summary.md delete mode 100644 docs/development/material-system-refactor/01-baseline.md delete mode 100644 docs/development/material-system-refactor/02-material-registration.md delete mode 100644 docs/development/material-system-refactor/03-properties-and-forms.md delete mode 100644 docs/development/material-system-refactor/04-item-composition.md delete mode 100644 docs/development/material-system-refactor/05-recovery.md delete mode 100644 docs/development/material-system-refactor/06-decomposition.md delete mode 100644 docs/development/material-system-refactor/07-cleanup-and-acceptance.md delete mode 100644 docs/development/material-system-refactor/07-recipe-package-audit.md delete mode 100644 docs/development/material-system-refactor/08-material-data-api.md delete mode 100644 docs/development/material-system-refactor/README.md delete mode 100644 docs/development/material-system-refactor/pr-374-review-actions.md delete mode 100644 docs/integration/README.md delete mode 100644 docs/integration/material-baseline.md delete mode 100644 docs/integration/material-process-snapshot.md delete mode 100644 docs/integration/material-refactor-01-02-review.md delete mode 100644 docs/integration/material-refactor-04-composition.md delete mode 100644 docs/integration/material-refactor-05-recovery.md delete mode 100644 docs/integration/material-refactor-06-decomposition.md delete mode 100644 docs/integration/material-refactor-07-roster.md delete mode 100644 docs/integration/report-template.md delete mode 100644 docs/operations/README.md delete mode 100644 docs/operations/records/README.md delete mode 100644 docs/operations/records/TEMPLATE.md delete mode 100644 docs/roadmap/v1.0.md diff --git a/AGENTS.md b/AGENTS.md index 48a14ebf0..9feec43f8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -70,13 +70,11 @@ | 可复用且随代码演进的开发/检查脚本 | `tools//`,脚本、自带数据与该目录 `README.md` 同放,README 注明输入、依赖、输出与运行方式 | | 长期开发指南 | `docs/development/` | | 架构与包职责 | `docs/architecture/` | -| 跨模组/跨平台对照、来源、验证结论 | `docs/integration/` | -| 发布/部署流程、可提交的脱敏执行记录 | `docs/operations/`、`docs/operations/records/` | | 长期架构决策及取舍 | `docs/decisions/` | **不要往任何 `src/` 放任务笔记、agent 交接、部署记录、日志、文档草稿、临时探针或一次性迁移脚本。** JavaDoc、必要的 `package-info.java` 和随模组分发的许可证是真正源码/资源的例外;不要新建 `src/docs/` 存放工作文档。 -`docs/` 不存所有工作过程。长期结论提炼为有上下文和复现方法的文档,原始材料留在 `work/`。忽略规则不是保密措施,凭据不得进入版本库或公共记录。 +`docs/` 只保留面向开发者持续使用的上手、架构、验证、协作与长期决策。计划、中间审查、集成报告、部署记录和工作日志留在 `work/`,不建立常驻文档树。忽略规则不是保密措施,凭据不得进入版本库或公共记录。 ## 验证与交付 diff --git a/README.md b/README.md index c269a2b99..c6c151f7e 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,6 @@ Final mod JARs are written to `minecraft/versions//build/libs/`. | [Getting started](docs/development/getting-started.md) · [Validation](docs/development/validation/README.md) | Environment, builds, development runs, and checks (Chinese) | | [Architecture and packages](docs/architecture/README.md) | Core, Minecraft, platform adapters, and package responsibilities (Chinese) | | [Addon API and KubeJS](docs/ADDON_API.zh-CN.md) | Extension points, SDK boundaries, and sample availability (Chinese) | -| [Release and deployment records](docs/operations/README.md) | Artifact checks, instance updates, and sanitized records (Chinese) | ## License diff --git a/README.zh-CN.md b/README.zh-CN.md index 0a15cf91b..637c1861e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -87,8 +87,6 @@ GT6CE **正在持续开发中**。移植尚未完成,配方、交互、渲染 | [开发上手](docs/development/getting-started.md) · [验证](docs/development/validation/README.md) | 环境、构建、运行与检查 | | [架构与包职责](docs/architecture/README.md) | core、Minecraft、平台适配及各包分工 | | [Addon API 与 KubeJS](docs/ADDON_API.zh-CN.md) | 扩展入口、SDK 边界与示例状态 | -| [路线图](docs/roadmap/v1.0.md) | 方针、架构、版本节点与协作方式 | -| [发布与部署记录](docs/operations/README.md) | 产物检查、实例更新和脱敏执行记录 | ## License diff --git a/core/src/main/java/gregtech/content/machine/OriginalMachineMaterialData.java b/core/src/main/java/gregtech/content/machine/OriginalMachineMaterialData.java index 74b6488e8..ca9ce71c8 100644 --- a/core/src/main/java/gregtech/content/machine/OriginalMachineMaterialData.java +++ b/core/src/main/java/gregtech/content/machine/OriginalMachineMaterialData.java @@ -1,6 +1,5 @@ /* GregTech-6 Team / Gregorius Techneticies; LGPL-3.0-or-later. - * Adapted from CR.shaped, OreDictItemData, OP and Loader_MultiTileEntities. - * Generated by tools/integration/generate_machine_material_data.py; source provenance is in docs/integration/verification. */ + * Adapted from CR.shaped, OreDictItemData, OP and Loader_MultiTileEntities. */ package gregtech.content.machine; import gregtech.api.material.GTMaterial; diff --git a/docs/AGENTS.md b/docs/AGENTS.md index b211c4afb..3a55f286b 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -2,9 +2,10 @@ 遵守[根指南](../AGENTS.md)。文档位置按[文件与产物归属](development/repository-layout.md#文档归属)选择;本目录只补充写作与维护要求。 +- 只创建面向开发者的持久性文档:上手、架构与包职责、验证、协作约定和长期决策。计划、审查、阶段报告、集成记录、部署记录和验收日志放 `work/<任务名>/`,不进入 `docs/`。 - 新文档从所属目录 README 链接;开头写清用途,必要时给出阅读顺序。包文档讲职责、入口、边界和验收,避免逐类抄源码。 - 同一规则只在所属专题维护,其他页面直接链接到该节。 - Stonecutter 分类 README 与子样例按 [Stonecutter 文档模板](architecture/stonecutter/templates.md) 编写;新增或修改后同步更新 `categories.md` 分类总览。 - 使用相对链接,引用现存文件;命令说明执行目录。新增或修改命令、参数、任务和路径时对照 Gradle 配置核实。 -- 区分当前实现、约定、计划和未验证范围;不编造工具、示例、兼容保证或证据。模板与实际报告分开。 +- 区分当前实现、长期约定和未验证范围;不编造工具、示例、兼容保证或证据。 - 交付前按[验证与验收](development/validation/README.md)检查文档一致性;若修改忽略规则,还需确认临时产物被忽略,文档、资源与 Wrapper 未被误忽略。 diff --git a/docs/README.md b/docs/README.md index 755a2e067..b2dac3323 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,9 +13,6 @@ | 选择检查、运行命令和记录结果证据 | [验证与验收](development/validation/README.md) | | 开发附属、SDK 或 KubeJS 扩展 | [附属 API](ADDON_API.zh-CN.md) | | 制作 GUI 或查找协作约定 | [开发指南](development/README.md) | -| 保存跨平台、跨模组或上游对照结论 | [集成、来源与验证结论](integration/README.md) | -| 交付产物、更新实例或保存执行记录 | [发布、实例更新与执行记录](operations/README.md) | -| 查询或记录长期取舍、与原版的差异 | [决策](decisions/README.md) | -| 查看版本方针与路线图 | [路线图](roadmap/v1.0.md) | +| 理解长期取舍或与原版的差异 | [决策](decisions/README.md) | 文档的维护规则见[文档 AGENTS.md](AGENTS.md)。 diff --git a/docs/architecture/packages/content.md b/docs/architecture/packages/content.md index 01d3fdd48..334a07345 100644 --- a/docs/architecture/packages/content.md +++ b/docs/architecture/packages/content.md @@ -74,7 +74,7 @@ 先检查 core 目录是否已有定义,再定位游戏注册及 bootstrap。材料可能涉及前缀、形态、流体、配方和渲染;机器可能涉及 Block、BlockEntity、注册、结构、GUI、同步和资源。只补一张表通常不足以完成内容接入。 -涉及旧 GT6 数据时保存可追溯来源、单位转换与差异,提炼到 [integration](../../integration/README.md)。不要因 `Original*` 名字而声称完整还原。生成表来源缺失时先记录局限,参见[生成物说明](../resources.md)。验收与自动化测试范围见下。 +涉及旧 GT6 数据时保存可追溯来源、单位转换与差异;稳定兼容取舍记录到[决策](../../decisions/README.md),当前实现规则写回本包文档或[资源与生成内容](../resources.md)。不要因 `Original*` 名字而声称完整还原。验收与自动化测试范围见下。 ## 验收 diff --git a/docs/architecture/packages/platforms/neoforge.md b/docs/architecture/packages/platforms/neoforge.md index 34d1a149b..6022dedf8 100644 --- a/docs/architecture/packages/platforms/neoforge.md +++ b/docs/architecture/packages/platforms/neoforge.md @@ -34,7 +34,7 @@ - 参考场景通过(GameTest 或等价验证)。 - 注册 ID、capability 方向、模拟/实际资源转移、序列化、生命周期时机、客户端/专用服务端隔离逐项检查。 -- 共享门面契约以 NeoForge 行为作为基准;偏差记录到 [integration](../../../integration/README.md)。 +- 共享门面契约以 NeoForge 行为作为基准;与原版 GT6 的稳定差异记录到 [parity](../../../decisions/parity/README.md)。 - 发行产物、数据生成与版本资源路径按[组装检查](../../../development/validation/checks/assemble.md)与[资源指南](../../resources.md)检查;版本元数据与 Mixin 配置按节点检查。 - 只验证 NeoForge 时,明确写出 Forge 未覆盖。 diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index 56611ce49..ee4099cb8 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,11 +70,11 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责按可见机器及完整共同输入或输出集合合并相似路线、原生端口实例、可见拓扑层级、连续链、局部副本、输入/产物网格、独立路线紧凑排布、端口产量角标、排线、配方浅色边界及同物品匹配,`client.MaterialProcessPanel` 负责带绿色目标外框的 100% 查询聚焦、窗口自适应视口、副本/回流标记与原生交互;`client.MaterialProcessScreen` 承载全屏浏览与返回原查看器;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、仅限页面材料的索引和事件适配;EMI 索引按完整原生状态去重,注册时不构造全部页面,实际打开时再查询完整步骤与按资源压缩的 `Flow` 关联;EMI 查询目标由客户端可选的 `EmiMaterialProcessFocusMixin` 传入。调用契约与预算见[展示接入](../../development/material-process-display.md);这些类型不能成为第二套材料目录或配方事实表。 +矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责按可见机器及完整共同输入或输出集合合并相似路线、原生端口实例、可见拓扑层级、连续链、局部副本、输入/产物网格、独立路线紧凑排布、端口产量角标、排线、配方浅色边界及同物品匹配,`client.MaterialProcessPanel` 负责带绿色目标外框的 100% 查询聚焦、窗口自适应视口、副本/回流标记与原生交互;`client.MaterialProcessScreen` 承载全屏浏览与返回原查看器;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、仅限页面材料的索引和事件适配;EMI 索引按完整原生状态去重,注册时不构造全部页面,实际打开时再查询完整步骤与按资源压缩的 `Flow` 关联;EMI 查询目标由客户端可选的 `EmiMaterialProcessFocusMixin` 传入。调用契约与预算以这些类型的 JavaDoc 和本包职责为准;它们不能成为第二套材料目录或配方事实表。 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 -EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理:在 `EmiMaterialProcessRecipesMixin` 取得最终可见配方后,统一接入 GT、工作台及其他模组的完整加工关系;GT 行优先复用原生单位、概率及回收归属,材料单位模板不受自动配方树开关影响。可读取的非树加工以未确认关系接入;说明、结构和动态模式页保留为信息。加工行按 EMI ID 和完整端口语义去重。合成网格空位不阻止完整配方进入加工图;通用标签/候选浏览页不进入信息区。其他相关信息和无法完整读取的条目按主材料关联、按 EMI ID 去重,保留在来源区底部的信息卡片,通过原页面跳转查看,不生成加工边。`MaterialProcessSnapshot.ViewerBuilder` 只构造本次客户端视图,不更改服务端配方。JEI 仍使用原生 GT 快照;具体覆盖、候选原料和生命周期边界见[EMI 配方来源与准入](../../development/material-process-display.md#emi-配方来源与准入)。 +EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理:在 `EmiMaterialProcessRecipesMixin` 取得最终可见配方后,统一接入 GT、工作台及其他模组的完整加工关系;GT 行优先复用原生单位、概率及回收归属,材料单位模板不受自动配方树开关影响。可读取的非树加工以未确认关系接入;说明、结构和动态模式页保留为信息。加工行按 EMI ID 和完整端口语义去重。合成网格空位不阻止完整配方进入加工图;通用标签/候选浏览页不进入信息区。其他相关信息和无法完整读取的条目按主材料关联、按 EMI ID 去重,保留在来源区底部的信息卡片,通过原页面跳转查看,不生成加工边。`MaterialProcessSnapshot.ViewerBuilder` 只构造本次客户端视图,不更改服务端配方。JEI 仍使用原生 GT 快照;具体覆盖、候选原料和生命周期边界按[游戏内人工验收](../../development/validation/checks/manual-ingame.md#矿物处理展示页)核对。 ## 验收 diff --git a/docs/decisions/0001-material-data-api.md b/docs/decisions/0001-material-data-api.md deleted file mode 100644 index d5ea01a58..000000000 --- a/docs/decisions/0001-material-data-api.md +++ /dev/null @@ -1,277 +0,0 @@ -# 0001:材料数据 API 与加工关系视图 - -- 状态:部分实施;A(薄视图与 metadata)已完成,B 的 tag/替代组定义与查询随计划 02 完成,C 的形态规则、实际资源绑定与 tag 桥接声明随计划 03 完成;D—E 的内部快照、core 图和 JEI/EMI 接入已实施,运行期与远程/人工验收尚未闭合。 -- 日期、作者、关联任务:2026-11-07,材料系统重构设计;关联 [#351](https://github.com/GregTech6CE/GregTech6/issues/351) 与材料标签、形态、获取途径和处理图整合需求。 -- 替代/被替代关系:无;补充[材料重构计划](../development/material-system-refactor/README.md),不替代现行 API 契约。 - -本文确定数据边界、查询接口和扩展方式。分步实现与验证见[计划 08](../development/material-system-refactor/08-material-data-api.md)。A—C 的视图、metadata、分类与形态内容快照已经发布;来源和处理图已有模组实现层入口,尚未作为独立 API JAR 的公共服务发布;下文未落地的公共接口仍为设计轮廓。 - -## 背景与约束 - -材料主对象已混合身份、物性、燃料、工具与矿石处理参数。直接往其中增加 tag、世界生成列表、合金列表和图布局,会让更多系统依赖一个可变对象,并重复存储世界和配方状态。 - -本次核对发现以下相互独立的数据路径: - -| 现有入口 | 当前职责 | 接入设计时需处理的问题 | -| --- | --- | --- | -| `MaterialProperty`、`MaterialRoleFlags` | 类型、能力和后加角色 | 描述分类与加工授权混在相近概念里 | -| `MaterialGroups` | `AnyIron` 等替代组与 re-registration | 分组不应被理解成一个真实材料身份,也不等同组成相同 | -| `MaterialTagAliases`、`MaterialEquivalence` | 资源标签拼写、形态等价 | 标签映射、具体匹配与成分事实应有明确边界 | -| `MaterialTagPack` | 动态生成物品/方块/流体标签 | 夹杂材料映射、配方输入组和其他内容标签,不能全部搬到材料对象 | -| `MaterialPrefix`、`BlockMaterialPrefix`、`MaterialForms`、附属 form 请求 | 形态与生成条件 | 可生成、已注册和当前可获得是三种状态 | -| `MaterialDeclaration.oreByproducts`、矿石处理规则 | 有序副产物与工艺生成 | 一个材料数组不能描述各步骤的数量、概率、条件和副产物身份 | -| `WorldgenInfoData` | 汇集活动矿脉/小矿/岩层供展示 | 位于 JEI 包且含游戏对象;EMI 也调用它,应抽出共享数据投影 | -| `RecipeMap.allRecipes()`、unit/动态规则 | 运行时有效加工与枚举 | 全量枚举可能昂贵,部分动态匹配无法完整枚举 | - -用户提供的矿物处理图展示了多阶段加工、分支和副产物。截图用作信息组织与交互目标;不能据图标推断当前仓库的准确配比、概率或工艺。具体数据仍以活动配方、世界生成规则和 parity 依据为准。 - -核心约束:Java 17 公共契约只用平台无关类型;主材料简洁;保留现有注册身份;允许附属扩展;数据包重载后查询与游戏行为一致;客户端绘图不能成为配方权威。 - -## 备选与决定 - -| 方案 | 收益 | 代价与结论 | -| --- | --- | --- | -| 在 `GTMaterial` 上增加所有字段和方法 | 初期调用直接 | 世界状态、图和配方形成双向依赖,不采用 | -| 维持独立 tag/来源/展示表,只增加汇总门面 | 迁移少 | 同一事实继续多处维护,不采用 | -| 轻量材料视图+领域查询服务+从有效内容派生的快照 | 共享身份与查询,事实仍归实际生产系统 | 需明确阶段与适配;采用为提议方案 | - -整合的是材料身份、声明规范、查询入口和一致性约定。配方引擎继续执行配方,世界生成继续决定矿物分布;材料 API 查询它们发布的有效结果,不接管这些系统的实现。 - -```mermaid -flowchart TD - D[材料定义与附属声明] --> C[材料目录:身份、属性、flag] - D --> T[材料分类与替代组] - D --> F[形态规则] - C --> B[实际形态与资源标签绑定] - T --> B - F --> B - R[最终有效配方与动态规则] --> P[加工关系索引] - W[活动世界生成配置] --> P - B --> P - P --> Q[材料来源、用途与局部处理图查询] - Q --> V[JEI / EMI / 材料手册 / 附属] -``` - -### 1. 主材料只承载内在事实 - -主材料的公开只读视图保留稳定身份、展示信息、有类型的稀疏属性和 flag。它不持有世界生成、来源、全部配方、资源标签成员或图布局。 - -```java -// 提议轮廓;校验、构造器及其余访问器省略。 -public record MaterialKey(String name) {} -public record DataKey(String namespace, String path) {} -public record FormKey(String name) {} -public record PropertyKey(DataKey id, Class type) {} - -public interface MaterialView { - MaterialKey key(); - MaterialInfo info(); - java.util.Optional property(PropertyKey key); - java.util.Set flags(); -} - -public interface MaterialCatalogView { - long revision(); - java.util.Optional find(MaterialKey key); - MaterialTagsView tags(); - FormRulesView formRules(); -} - -public interface MaterialDataSnapshot { - SnapshotStamp stamp(); - MaterialCatalogView catalog(); - MaterialFormsView forms(); - MaterialProcessesView processes(); -} -``` - -- `MaterialKey` 使用已解析的现有规范名称,保留大小写语义;旧别名经目录解析。它不是动态数值 ID,不触发注册名或存档格式迁移。 -- `DataKey` 用于新增属性、分类、组和操作类别的命名,构造时按各域验证;与 Minecraft `ResourceLocation` 无依赖。不同域的同名 key 不互相转换。 -- `FormKey` 沿用已解析的 prefix 名,别名只由形态目录解析;此阶段不重命名现有 prefix 或物品/流体注册项。流体相态由形态描述关联现有绑定,不凭空生成新 prefix。 -- `MaterialInfo` 含名称、现有 ID、展示键、颜色和定义来源等固定信息;组成、燃料、矿石、工具与热学等放对应类型化属性。 -- `PropertyKey` 的 ID 和类型须预先注册,同 ID 异类型失败;值必须符合不可变约定。公开写入使用类型化 builder,不接受任意 `Map`。 -- 自定义 key 不自动获得宿主行为。新燃料/加工能力需要对应消费者;单纯分类标签不会授权回收或生成配方。 - -属性类型与客户端传输能力分开注册。首版同步宿主已知的不可变值类型;自定义属性需提供受支持的显式编码约定才能传输,未支持的客户端属性标为不可用。不得传 Java 类对象或通过反射反序列化任意附属类;服务端仍可在原类型下查询此属性。 - -这是公共只读模型;内部 `GTMaterial` 可以逐域改存储,再用适配器导出该视图,不需要立刻替换所有实例。 - -### 2. 明确区分四种 tag 语义 - -| 概念 | 示例 | 权威与效果 | -| --- | --- | --- | -| 材料分类 tag | 金属类、木材类、某附属的矿物族 | `MaterialTagsView` 的集合关系;可供明确声明的规则查询,单独加入不会改变行为 | -| 行为/生成 flag | 可锻造、允许某分解 map、生成某族形态 | 类型化能力声明及依赖校验;与分类 tag 不是同一集合 | -| 材料替代组 | `AnyIron`、`AnyWoodOrPlastic` | 显式组成员和指定工艺中的匹配规则;不合并材料身份、物性或成分 | -| Minecraft 资源 tag | `forge:ingots/iron`、`c:ingots/iron` | 游戏注册表的有效成员;由形态绑定导出或由外部包提供,经过适配后使用 | - -拟议查询职责:`tags().contains(material, tag)`、`tags().members(tag)`、`tags().group(groupId)`。分类 tag 和 group 使用不同参数类型或独立方法,不允许互相误传。命名例子只说明类别,不直接决定最终 key 拼写。 - -材料 tag 声明可以包含其他同类 tag,校验未知引用与环;替代组是单独的选择器声明。组与组的嵌套若需支持,按独立的无环成员规则展开。`AnyIron` 的旧内部伪材料在迁移期可保留适配,但新公开 API 返回组,而不是“可以熔化的另一种铁”。既有 re-registration 不能因此被一概删除。 - -替代匹配必须说明形态、数量和状态限制;在某手工配方允许 Iron/Steel,不意味着所有机器中两者等价,也不意味着组内物品的组件或重量相同。 - -资源标签桥接采用 `ResourceTagBinding(registryKind, tagId, target, direction)`,其中 target 只能是明确的材料形态或替代组,direction 为导出、导入或显式双向。仅“属于铁相关物品 tag”不能推导“一件物品等于 1U Iron”。 - -桥接规则如下: - -1. 将 `MaterialTagAliases` 的拼写映射与形态绑定汇入一处;分类 tag 的成员不自动合成为所有物品形式的巨大 tag。 -2. 官方导出用已注册形态及明确成分,不以重载后的资源 tag 成员反推同一份导出,避免循环。 -3. 外部资源 tag 导入只向计划 04 提交低优先级候选;不同形态重量、多个材料命中和显式成分冲突必须裁决。 -4. 物品、方块、流体注册表有独立 tag 身份,即使路径相同也不混合;物品和方块绑定需要明确关联。 -5. 1.20.1/1.21.1 的资源目录与 `forge:`/`c:` 兼容规则由适配器维护,保留现有匹配契约。材料 API 不暴露版本目录拼写。 -6. `MaterialTagPack` 中技术配方组、染料或其他非材料标签仍归其领域所有,只通过共享资源输出器接线,不强行归入材料目录。 - -内容侧通过 `forms().tagBindings()` 查询桥接声明,通过带注册表类别的 `ResourceTagRef` 查询有效表示和原始成员;材料分类查询不复用该接口。反查资源 tag 只是查询,不能向目录补写身份或物性。 - -### 3. 形态 API 同时回答规则和实际存在性 - -形态规则放目录,实际绑定放内容快照: - -| 查询 | 返回内容 | 不能据此推断 | -| --- | --- | --- | -| `catalog.formRules().describe(form)` | prefix、介质、默认材料量、规则来源 | 这个材料一定允许此形态 | -| `catalog.formRules().decide(material, form)` | 允许/禁止、缺少属性或显式例外及依据 | 游戏中已注册该物品 | -| `snapshot.forms().find(material, form)` | 注册结果、有效 item/block/fluid 表示、完整组成、首选表示、来源 | 玩家一定有制造它的路线 | -| `snapshot.processes().sources(query)` | 当前有效内容中的获取步骤与前置条件 | 玩家库存已经满足这些条件 | - -`FormAvailability` 不用一个模糊的 `canCreate` 布尔值:区分规则允许、已请求注册、绑定存在与当前启用;没有绑定可说明“无生成请求”“目标不存在”或“仅兼容元数据”。 - -默认重量属于形态定义,实际复合成分来自计划 04。材料+形态的主身份不能让复合工具头变回纯主材料。多个外部物品可实现同一纯形态,但选择器和首选统一化表示分开保留。 - -形态生成只消费定义阶段的分类、flag、属性和显式请求;可重载的 Minecraft tag 不得临时增加或删除物品注册项。重载可以更新外部绑定、可用配方和首选表示,但不修改冻结的原生注册表。 - -### 4. 来源与用途共用加工关系索引 - -“来源”分为三类,不混为 `sourceMod`: - -- **定义出处**:哪个模组/规范声明定义了材料,GT6 对照的提交与依据。 -- **有效获取途径**:世界生成、掉落、洗矿副产、电解、离心、合金、回收等实际产出步骤。 -- **运行时匹配结果**:某个具体栈或上下文此时能否进入机器;这是执行引擎判定,不由静态关系图代替。 - -来源和用途是同一个关系索引的正向/反向查询,不在材料上分别维护两份列表。`oreByproducts` 仍可作为生成矿石工艺的内在有序参数;实际“在哪一步产出多少副产物”取最终步骤,不能只从列表画边。 - -拟议的最小关系模型: - -| 类型 | 必需语义 | -| --- | --- | -| `ProcessRef` | 快照内身份、所有者、原始配方/规则/世界生成引用;不是新存档 ID | -| `ProcessKind` | 可扩展操作 key,如洗矿、电解、合金;不为每个附属扩一个封闭 enum | -| `ProcessView` | 操作、全部输入、全部输出、条件、机器/环境、时长和能量(适用时)、出处 | -| `InputPort` | 资源选择器、数量单位、角色:消耗、催化剂、仅存在性条件等 | -| `OutputPort` | 资源选择器、数量单位、主产物/副产物/未知角色、产出概率模型 | -| `ResourceSelector` | 确切资源、tag、已证明的材料形态、符号 unit 规则或原生匹配引用;可保留候选,不能强制展开 | -| `ConditionView` | 维度/高度/岩层、温度、机器等级、配方模式或原生状态限制等带类型条件 | -| `SourceHit` | 命中的步骤、输出端口、匹配依据;区分直接形态产出与仅含该成分的混合物 | - -数量显式携带 `ITEM_COUNT`、`MATERIAL_UNITS`、`MILLIBUCKETS` 等单位;显示归一化不能改变原生整数批量。原生 NBT/组件和匹配谓词用宿主签发、按会话与 generation 校验的引用承接,由平台解析,不能丢掉状态后称为精确选择器。 - -概率保留整数分子/分母及原生事件语义,复用现有 `RecipeOutputChances` 的确定性和万分比定义;若多个产物共享事件或互斥选择,还需保留事件组。未知相关性写未知,不能从边际概率推导独立性;随机来源不能展示为保证产出。主/副产物角色没有可靠声明时标未知,不按槽位或数量猜。 - -**关系以步骤为中心,是多输入、多输出的关系。** 合金必须保留 Copper 与 Tin 同时作为输入;清洗剂、选择器和催化剂也保留角色。不能画成“有 Copper 就能获得 Bronze”的无条件单边。 - -#### 4.1 特殊处理方法 - -特殊处理不新增跨材料目标大表,而是复用 typed process: - -- `SpecialProcessMethod` 绑定一个 `MaterialProcessKey`、配方表和展示键。 -- 可处理材料在同一 key 上注册 `SpecialProcessValue.Target`;Target 保存输入表单计数、物品/流体产物、概率、辅料量、时长和能耗。 -- 辅料材料在同一 key 上注册 `SpecialProcessValue.Reagent`;其表单由普通 `MaterialProcessRule.forms()` 表达。 -- 宿主生成配方后把 method ID 写入最终 `Recipe`;材料图只按该 ID 折叠步骤。没有 method ID 的配方平铺,不按步骤名猜测。 -- target/reagent 材料 tag 从 typed rules 派生;资源 tag 再根据规则表单生成,避免标签与配方双写。 -- 同一配方匹配多个 method 时视为声明冲突;静默选择会让不同内容顺序改变路线含义。 - -### 5. 各来源的发布方式 - -1. **普通配方**:从最终有效 `RecipeMap`、原版 `RecipeManager` 及必要的输入约束投影。保留数据包替换、删除、启用状态;来源索引不再次计算产物。 -2. **回收/分解**:计划 05、06 的计算/发布结果直接导出关系。不能由图服务从成分重新生成另一套回收或化学分解。 -3. **动态与 unit 规则**:优先投影其符号族和匹配约束,按需解析具体输入。现有 `allRecipes()` 可能重新枚举动态族,不能每次打开材料页全量调用;没有完整投影的族标为部分覆盖。 -4. **世界生成**:从实际启用的矿脉、小矿、岩层和维度配置投影,包括原生高度到有效高度的转换。输出为实际矿石资源/形态,不把含 Copper 的矿石直接画成 Copper ingot。矿脉权重、密度和岩层条件按原含义展示,不当作挖一块矿的概率。 -5. **其他来源**:后续可适配战利品、作物或特殊机器,只投影实际生产者;不得先建一套手填“材料来源表”等待实现与之对齐。 - -`ProcessRef` 对有原生 ID 的对象引用原 ID;没有原生 ID 的内部行按提供者、map 和完整语义生成快照内身份并检查冲突,不能使用注册序号。指纹只用来索引,不能代替完整相等判定。旧快照引用由新快照解析时明确失败,不定位到另一条“差不多”的配方。 - -第一版公开查询,附属通过已有材料、form、配方、世界生成声明获得自动索引。**不增加独立的 `sources()` 声明让附属重复手填合金/离心数据。** 特殊原生规则需要投影适配时,适配器只能引用有效的执行对象并声明覆盖程度;没有后端依据的说明页标为信息,不能计入可执行来源。 - -### 6. 查询与截图中的处理图 - -拟议的核心查询为: - -```java -public interface MaterialProcessesView { - QueryResult sources(SourceQuery query); - QueryResult uses(UseQuery query); - ProcessGraph graph(GraphQuery query); - java.util.Optional resolve(ProcessRef ref); -} -``` - -`SourceQuery` 支持材料或具体形态、操作类别、主/副产物、维度等筛选;默认直接产出,混合物中含某成分是单独筛选项。例如洗矿得到含银混合物不等同已经得到纯银,后续分离步骤仍须存在。 - -`GraphQuery` 支持根资源/形态、前向或反向、操作过滤、最大深度与节点上限;同时限制扫描端口/边的工作量,避免高出度节点绕过结果数上限。构造时要求有效预算,耗尽返回截断原因。`QueryResult` 返回结果、覆盖范围、未知适配族和截断信息;空结果不能在部分覆盖时解释为“绝对没有来源”。 - -实现截图式矿物页时: - -1. 以选定矿物的实际 ore/raw/crushed 形态作为根,查询其局部加工图;不从每种化学元素展开整个世界。 -2. 以资源形态为物料节点、工艺为步骤节点,保留配方的共同输入与多产物。主路线居中,副产物分支侧排,其他输入作为步骤条件展示。 -3. 每一步展示准确批量、概率、机器、耗时/能量与重要条件;点击步骤跳转其原始配方,点击物料切换该形态的来源/用途。 -4. 相同材料的 ore、crushed、dust、molten 不合成一个节点;原生子类型/状态敏感的表示也不能只按物品 ID 合并。 -5. 对合金/分解/回收环做回边或折叠循环,查询保持 visited 集合及预算。配方图表示潜在路径,不承诺库存可达、保证产率或最优路线。 -6. JEI、EMI 和材料手册共用 `ProcessGraph`;坐标、箭头、图标、翻译与交互属于客户端。任一 viewer 未安装不影响查询或基础服务端启动。 - -无需先建立通用全局自动化规划器;第一版有界局部图即可满足矿物处理总览与来源反查。 - -### 7. 快照、上下文与同步 - -定义目录在完成合法材料链接与最终校验后发布;具体时点由计划 02、03 处理现有 `postInit()` 和角色追加后确定,不能把目前 `READY` 枚举误当全部字段已定稿。 - -内容快照在标签、成分派生、数据包配方、全部 overlay/炉配方镜像和有效世界生成配置确定后发布。需要盘点所有实际回调,不能仅在现有较早的 `MachineRecipeLifecycle.started()` 中就认定发布完成。 - -```text -定义、分类、形态规则定稿 - → 原生物品/方块/流体绑定 - → 标签加载 → 外部候选与成分裁决 - → 配方与 overlay/动态规则发布 - → 有效世界生成配置与查询投影 - → 发布同一内容快照 → 客户端刷新展示 -``` - -`SnapshotStamp` 至少区分运行会话、定义 revision、内容 generation 和世界/配置上下文。revision 只在本会话有意义,不能持久化为内容身份。后端变更必须失效或重建相关视图,不能由后台线程扫描正在变更的原生表。 - -共同契约:旧快照只读且自洽;不能混用不同 generation 的配方、tag 和成分。资源重载先校验新结果,再在现有服务端生命周期安全边界切换。重载失败后的选择遵循游戏和现有框架的失败处理,不吞异常伪造成功。使用者有界保留旧快照,宿主不无限缓存历史版本。 - -建议通过现有 `GregTechMaterials` 增加纯定义目录访问;带服务器/世界上下文的内容快照从平台侧新增入口取得,传入当前 server/level,避免公共全局单例同时代表多个世界。API/common 只定义值与查询,不引入 `Level`、`ItemStack`、JEI 或 EMI 类型。 - -客户端消费服务器对应的内容版本。现有同步若已包含某类事实则复用;缺失的来源/条件投影按版本同步,必要时分段或按查询传输,而非广播全部展开的图。客户端不借共享 JVM 读取集成服务器表冒充远程同步;断线或换世界清除会话数据。第一版不开放任意远程图查询协议,如后续增加,必须限制请求范围和结果预算。 - -### 8. 扩展与兼容 - -新增声明继续接入现有 `AddonMaterialContributor`,建议增加默认返回空集合的 `materialTags()`、`materialGroups()`、`metadata()` 等方法;最终签名以实现时的 API 契约测试为准。既有 `forms()`、`prefixes()`、`oreVeins()`、`smallOres()` 不重复定义。 - -metadata 使用 builder 挂分类、类型化属性与 flag,不继续给 `MaterialDeclaration` record 增加大量构造参数。已有 `metal()`、`ores()`、`polymer()` 等构建方法在过渡期编译成同一内部声明;原有 `oreByproducts` 顺序语义保持,不把它改成无序 tag。 - -所有权规则:附属可定义自己命名空间的分类、组和属性键;可给其他材料增加自己的描述性分类;改变他人材料的物性、能力、实际 form 生成或组成仍需既有所有权/显式覆盖规则。同名 key 的冲突按类别校验,不以加载顺序裁决。 - -`GregTechMaterials.Material` 的现有查询方法不强加新的抽象方法给旧实现者;新视图通过适配器和新增入口提供。宿主服务能力增加时采用显式能力协商或默认“不支持”,不能默认返回空图误报完整覆盖。旧主机与新 API 组合的失败方式纳入契约测试。 - -当前 API 版本为 1.9.0。A/B 使用默认 SPI 方法和新增只读类型,旧宿主通过显式“不支持”失败,既有声明实现者保持源码兼容。API 1.5 的 `MaterialProcessKey`/`MaterialProcessesView` 允许附属用自己的 namespace 声明处理规则;API 1.6 的 `MaterialInfoTool` 将工具、组成、形态、tag 和 process 注册为按 `MaterialKey` 关联的独立域索引。API 1.7 提供详细 `MaterialFormRule`、运行期 `MaterialFormsView`、显式统一物品绑定和 item/block/fluid 分离的实际形态查询,同时保留材料组的成员与包含查询。API 1.8 通过 `MaterialProcessKeys.DECOMPOSITION` 承载单一类型化分解规则;该规则是路线唯一权威,旧离心/电解 feature 只提供弃用兼容输入。API 1.9 用一个 `SpecialProcessMethod` 绑定 `MaterialProcessKey`、配方表和展示键;同一 key 下的 `Target`/`Reagent` 规则分别挂在可处理材料和辅料材料上,宿主生成配方并派生标签。材料图只能按该 method 身份折叠,普通配方不参与名称推断。旧 `GTMaterial` 工艺访问器和旧组 re-registration 访问器暂时保留并标记弃用,READY 后只转发冻结快照。新增查询身份不改 NBT、原生注册 ID、配方单位或已有材料名。 - -## 影响、落地与验证 - -| 层次/既有包 | 拟议职责 | 禁止依赖或双写 | -| --- | --- | --- | -| `api.addon.material`(common) | 只读视图、key、tag/group/form 元数据、查询契约 | 不暴露内部 GTMaterial、Minecraft 对象或图布局 | -| `api.addon.platform`(Minecraft API) | 按 server/level 取得快照、解析原生资源引用 | 不依赖 core 实现或某 viewer | -| core `content.material`/`content.recipe` | 类型化事实与生成工艺声明 | 不重复写最终来源图 | -| core `engine.material`/`engine.recipe` | 校验、不可变索引、有界图遍历 | 不查询游戏世界,不执行 viewer 渲染 | -| 共享 Minecraft 的 material/recipe 适配 | 有效资源、tag、配方与世界生成投影 | 不二次推导成分/授权/产量 | -| `bootstrap`/平台入口 | 生命周期绑定与发布 | 不由首次客户端开页触发全量注册 | -| `compat.common`/客户端 viewer | 图数据消费与渲染接线 | 不另建材料来源或洗矿副产物表 | - -不因该表搬迁无关包。`WorldgenInfoData` 可先保留旧接口,将共享事实投影抽出后转发;原生图标和 `ItemStack` 的构造继续留游戏/展示层。 - -实施按计划 08 的 A—E 切片并入原计划 02—06,最后由 07 整体验收。首个闭环为:材料分类与形态查询 → 活动矿石洗选配方 → 来源/用途查询 → 一个 viewer 的局部图。查询服务在无 viewer 环境必须同样有效。 - -验证重点包括:分类不隐式授权;组不改变身份;形态允许不等于有配方;最终配方删除同步撤图;副产物概率与共同输入完整;unit 不全量展开;未知适配不声称无来源;多世界/重载不混版本;两节点共用语义且基础服务端不加载客户端类型。详细场景与门禁见计划 08。 - -材料定义视图、类型化 metadata、分类 tag 和替代组已随 02 实施并验证。尚需实施时裁定的项目:首批动态规则投影覆盖、远程客户端现有同步可复用范围、实际内容快照发布回调,以及合适的局部图预算;这些必须在 C—E 的运行期切片验收前解决。 diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 49fe8e09d..f7feade58 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -4,7 +4,7 @@ 先读[现有架构](../architecture/README.md),确有长期选择需要保存时复制[模板](TEMPLATE.md),按主题命名。状态使用“提议 / 接受 / 废止 / 被替代”;提议不是已实施事实。 -决定改变时保留原背景,标明新决定链接;最终使用方式仍须同步架构/开发指南,不能只留在决策历史里。证据放 [integration](../integration/README.md),部署结果放 [operations](../operations/README.md)。 +决定改变时保留原背景,标明新决定链接;最终使用方式仍须同步架构或开发指南,不能只留在决策历史里。一次性调查材料放本地 `work/`,长期可执行规则写回架构、开发或验证文档。 ## 目录 diff --git a/docs/development/README.md b/docs/development/README.md index de8dc3c84..c90e5ea0c 100644 --- a/docs/development/README.md +++ b/docs/development/README.md @@ -6,8 +6,6 @@ | [文件与产物归属](repository-layout.md) | 源码、测试、工具、文档和临时材料的位置 | | [验证与验收](validation/README.md) | 改动路径路由、检查命令与结果证据 | | [碎片贴图与机器 GUI 模板](gui-templates.md) | 模板格式、素材引用和界面接入 | -| [矿物处理图展示接入](material-process-display.md) | 前端投影、三区分区、平移、工艺组、覆盖说明与后续跳转调用契约 | -| [配方总览图布局设计](material-process-layout.md) | 待实施的拓扑分层、连续链对齐、资源局部副本、排线与验收标准 | | [Issue 分类与标签](github-issue-tags.md) | 问题分类与协作约定 | 其他主题见[GT6CE 文档](../README.md),开发工具用法见[工具目录](../../tools/README.md)。 diff --git a/docs/development/material-process-display.md b/docs/development/material-process-display.md deleted file mode 100644 index b40de2423..000000000 --- a/docs/development/material-process-display.md +++ /dev/null @@ -1,139 +0,0 @@ -# 矿物处理图展示接入 - -本文说明[计划 08-E](material-system-refactor/08-material-data-api.md#e有界矿物处理图与消费者迁移)的前端接入契约。生产路径从 `MaterialProcessSnapshot` 取得一种材料全部形态的直接关系,并在 JEI 与 EMI 中共享单页可缩放、自由平移图和 `MaterialProcessPanel`。EMI 使用最终可见加工配方构造客户端视图,JEI 使用已发布的 GT 机器与世界生成快照。空状态 `unbound()` 只在没有可展示材料时使用;具体机器行、世界生成、远程客户端和人工交互仍需按验证范围分别验收。 - -这是 Minecraft 实现层的客户端调用接口,随模组编译;方法声明来自 API 1.9.0,但本页面本身不是独立 API JAR 的公共材料服务。分类和面板只在已安装 JEI/EMI 的客户端路径加载;无 viewer 的专用服务端入口不得引用它们。 - -拓扑分层与资源局部副本的设计依据见[配方总览图布局设计](material-process-layout.md)。当前实现按可见依赖排布;来源、材料内部转换、回收、去向在同一画布中按顺序排列,只为有内容的区域保留标题和分割线;辅料、工具、存在条件及额外副产物不作为额外图节点;`+` 只列可靠辅料名称,完整约束通过普通配方查询查看。 - -## 入口与职责 - -| 类型 | 职责 | -| --- | --- | -| `gregtech.compat.common.MaterialProcessDisplay` | 已完成有界查询的展示投影和校验;不读取材料目录、配方表或服务端状态 | -| `MaterialProcessDisplay.Port` | 一个原生状态敏感的资源选择器的展示,含角色、数量单位、概率与有限图标 | -| `MaterialProcessDisplay.Step` | 同一步骤的全部共同输入、全部输出、机器/环境/时间/能量/出处说明,以及可选的 special-process method 身份 | -| `MaterialProcessDisplay.Connection` | 调用方提供的单条步骤关联,包含资源引用及确认状态;支持分支、回边和自环 | -| `MaterialProcessDisplay.Flow` | 同一精确资源的生产者与消费者引用集合;紧凑表达全部关联,不分配两两连接 | -| `MaterialProcessDisplay.Page` | 一种材料的全部已查询步骤、全图关联、覆盖说明和绑定到同一查询结果的跳转回调;页面不按步骤拆页 | -| `gregtech.compat.common.MaterialProcessOverview` | 按显示身份合并重复路线与资源,保留原始步骤/端口,计算依赖层级、连续链及排线路径 | -| `gregtech.client.MaterialProcessPanel` | 窗口自适应视口内的拓扑图、查询目标绿色外框、同物品悬停、配方浅色边框、平移缩放与普通来源/用途查询;不依赖 JEI/EMI | -| `gregtech.client.MaterialProcessScreen` | 全窗口浏览,共用面板、相机和查询目标;退出返回原查看器,窗口变化保留中心世界坐标 | -| `gregtech.compat.jei.MaterialProcessCategory` | JEI 不可见检索索引、拖拽/滚轮事件和 tooltip;分类类型为 `TYPE`,标识为 `gt6ce:material_process` | -| `gregtech.compat.emi.MaterialProcessEmiRecipe` | EMI 索引、拖拽/滚轮事件和共享面板适配;不读取材料目录或配方表 | -| `gregtech.content.recipe.MaterialProcessSnapshot` | 绑定一次完整发布、会话和世界生成 revision;索引最终机器行与符号选择器 | -| `MaterialProcessSnapshot.ViewerBuilder` | 从查看器选中的原生机器行与物品/流体端口构造独立视图,保留活动世界生成,不修改服务端发布 | -| `gregtech.compat.emi.MaterialProcessEmiRecipes` | 将 EMI 最终可见加工配方投影为材料关系,其他相关条目保留为独立信息入口 | -| `gregtech.content.worldgen.MaterialWorldgenFacts` | 只含活动世界生成事实,不构造原生图标 | -| `gregtech.engine.material.MaterialProcessGraph` | core 有界递归查询、材料页直连查询、循环终止和显式预算截断 | -| `gregtech.compat.common.MaterialProcessProjection` | 把 core 查询转成快照内 `DataKey`、有限图标和展示 `Page` | - -复用现有 `DataKey` 表达展示引用,复用 `RecipeOutputChances.CERTAIN` 的万分比契约、viewer 检索索引、配方索引与运行期注册。没有另建 SPI、全局来源缓存、锁、服务端查询协议或材料事实表。JEI 与 EMI 共用展示模型和面板,任何共用类型都不能引用具体 viewer 类。 - -## EMI 配方来源与准入 - -EMI 的机器、工作台、熔炉和其他模组配方统一取自本次 `EmiRecipes.bake` 过滤后的列表,包括延迟注册的配方。公开 `addDeferredRecipes` 回调执行时尚未建立最终管理器,也未应用全部隐藏规则,因此客户端可选的 `EmiMaterialProcessRecipesMixin` 在最终列表赋值时加入材料页。两个节点均注册此 Mixin;未安装 EMI 时由 `@Pseudo` 跳过。该接入依赖当前锁定的 EMI 1.1.24,升级时必须核对局部列表与注入次数。 - -加工关系依据可读取的实际输入、输出准入,不以 `supportsRecipeTree()` 作为统一开关。禁用配方树的工具装配和第三方固定加工仍进入图中,其关系保留为未确认;不会据此承诺自动合成。结构、战利品、世界生成展示、材料标签查询、说明页、动态模式合成、木桶查询别名和总览页自身不作为加工关系导入。有序合成输入中的空 `EmiStack` 是网格占位,读取时跳过;跳过后仍须存在实际输入。零数量催化剂按存在一个工具展示,不转为消耗品。其他空原料、空催化剂、空产物、无效数量或不支持的 ingredient 类型仍使整条配方移入相关信息,不能删掉必需槽后将剩余部分当作完整配方。第三方动态约束无法由通用槽位接口完整还原;来源约束与容器返还仍通过原配方查询查看。 - -GT 的 `MachineEmiRecipe` 优先按原生语义接入,材料单位模板即使禁用了 EMI 配方树也仍是加工关系;没有材料单位声明的假配方保留为信息。端口继续使用原生配方的材料单位、精确状态、概率、特殊工艺与回收归属,不重复遍历全局机器表添加另一份。活动世界生成使用已发布事实单独保留,不从 EMI 信息页的检索槽推断来源。 - -其他配方保留每槽原生数量、输出边际概率、催化剂及完整物品 NBT/流体数据组件。候选原料作为一个 selector;只有所有候选均属于同一材料时才将它归入该材料,跨材料候选保持 `unknown`。候选集不展开为多个共同输入,也不与某个代表物品建立确认关系;代表图标最多十六个。工作台分类缺少工作站条目时使用原版工作台,其他分类缺少可靠工作站时保留问号。同一非空 EMI ID 的加工行只接入一次;不含容器返还的行还按分类及输入、工具、输出的原生身份、角色、单位、合计数量和概率去重,不依赖槽位顺序或合成网格占位;独立概率槽保留各自批量,不等同于一个较大概率产出。含返还约束的不同 ID 行继续保留,由原配方查询呈现完整约束。覆盖说明列出未作为加工关系导入的条目数,不声称支持未注册到 EMI 的加工方式。 - -通用 `EmiIngredientRecipe` 仅用于标签成员/候选原料消歧,不收进信息区,也不计入加工缺口;JEMI 桥接的 JEI 标签浏览页按保留的 `tag_recipes/` 分类路径同样排除,不依赖翻译标题或 JEI 实现类。GT 自有的材料单位输入说明 `MaterialUnitTagEmiRecipe` 仍保留。其余信息页、不完整配方及不支持 ingredient 的条目,按物品明确声明的主材料和流体材料绑定关联;复合物品的次要成分不扩展关联。相同非空 EMI 配方 ID 的信息入口只保留一份,未提供 ID 的不同页面保持独立。不能据此推断生产或回收关系。 - -相关条目放在来源区最下方的独立卡片,图标取自该材料的关联物品,点击直接打开对应原始 EMI 页面;它们不加入 `Step`、`Connection` 或加工预算。没有加工步骤但存在相关信息的材料仍注册一张可检索的信息页。卡片随画布一起缩放、平移和裁剪,完整标题与参考性质放在 tooltip 中。关联索引与加工端口分开,索引仍只收录页面所属材料。 - -EMI 初始化只从 `materialSteps(root)` 收集本材料资源/角色的检索代表,并按完整原生状态分别去重输入、工具和输出;`getInputs`、`getCatalysts`、`getOutputs` 等索引调用不触发页面查询或布局。实际打开页面的 `addWidgets` 才构造并缓存完整 `Page` 和面板,原始批量、概率、候选和端口仍在详情中。重复调用注册入口先剔除旧总览条目,避免累积旧页面及快照;完成后日志记录材料页数、查看器配方数与耗时。 - -每次 EMI 重建均替换客户端视图及导航代次;旧页、断线后的页和旧发布的回调失效。JEI 未使用此 EMI 数据源,仍受 GT 原生快照的覆盖范围限制。 - -## 构造契约 - -- `DataKey` 在这里是调用方签发的快照内引用,不是新的材料身份或存档 ID。`Port.resource` 必须区分材料、形态、相态和原生状态;不同 tag/unit 选择器的原生引用保持独立。`Port.identity` 另作展示共享键:完整原生状态或规范选择器描述不包含查询代号及配方专属 selector 后缀;有原生图标时按实际显示代表的完整物品/流体状态识别相关展示实例;多候选 selector 可以与该代表同步高亮,并在总览共享一个资源节点,但原始候选集、消耗量和 guard 仍属于各原生步骤,不声称 selector 与具体物品可互换。不同 NBT/数据组件状态不得仅因图标相同而合并。已有 `MaterialKey`、`FormKey` 与原生匹配引用由后续适配器解析到该引用,不重新建立材料目录。 -- `Port` 的 `amount` 必须包含原生批量及单位,如件、U 或 mB。`quantity` 是生产者同时提供的紧凑图标角标(件数、省略为 1 的件数、U、mB 或未知标记),前端不解析 `amount` 文本、不换算、不从图标栈数量推导材料量。旧构造方法默认不显示数量角标。资源图标右下角显示非 1 件数量或带单位的量,左上角显示非必然产出的百分比,未知概率显示 `?%`。共享资源优先采用产出端口的值;同一外观路线的多个产出批量不同时以 `/` 分隔,超过三个不同值用省略号,tooltip 列出原生批量与概率,不取其中一个覆盖其他值。输入概率不绘制,原生批量不从图标栈数量推导。`icons` 为有限代表,空列表表示符号资源;不展开 tag 或 unit 候选全集。使用现有 `FluidDisplayBinding.display(...)` 取得带相态/状态的流体代理物品,不创建另一套流体身份转换。 -- `Role.CONSUMED`、`CATALYST`、`PRESENCE` 只用于输入;`PRIMARY`、`BYPRODUCT`、`UNKNOWN` 只用于输出。输入不因为存在数量就自动消耗。无可靠主/副角色时用 `UNKNOWN`,不得按槽位猜测。 -- `main` 是生产者提供的路线提示;同侧有多个提示时按原生顺序选择首个,不因提示数量丢弃端口。总览显示本材料在该侧的全部消耗输入或产物;该侧没有本材料时,用 `main` 或稳定端口顺序选一个外部主输入/产物。工具、存在条件及其余辅料/额外副产物留在 `+` 中。这不改变原始角色,也不声称一个可见输入就是完整配方。 -- `chance` 使用 `OptionalInt`,已知概率为 1—10000,未知为 `OptionalInt.empty()`,确定产出为 `OptionalInt.of(RecipeOutputChances.CERTAIN)`。输入概率不参与绘制。互斥/共享随机事件、未知相关性和原生状态限制必须放在 `details`;不能用边际概率声称各输出独立。世界生成权重放说明,不能当成掉落概率。 -- `Step` 保存同一步的联合输入、多输出及条件;`genericRecovery` 来自宿主同时核对回收归属与配方表的判定,兼容构造方法默认为 `false`。`icon` 是生产者提供的代表机器图标,访问时返回副本;没有可靠机器代表时使用空图标,面板显示问号。`worldGenerated` 由快照的真实世界生成引用设置,不根据空输入、图标或引用字符串猜测;兼容构造方法默认为 `false`。活动世界生成步骤使用镐作为采集符号。普通机器工序复用 EMI 分类的 `RecipeMachines` 索引与 `RecipeViewerIcons.category(...)`,包括锤子等工具类图标;不再只遍历基础机器。机器、时间、能量、温度、维度、选择器、来源等通过 `details` 传入。`resolved=false` 表示原生关系/约束尚未解析,连接为虚线;显示图标仍可执行普通来源/用途查询。`resolved=true` 也不承诺玩家库存可执行。 -- `Connection(source, target, resource, confirmed)` 必须指向当前结果内的两个步骤,且资源同时出现在源步骤输出和目标步骤输入中。默认材料查询使用 `Flow(resource, sources, targets)` 保存同一精确资源的全部生产者和消费者;每个引用都按原始端口校验。关联数为两侧引用数的乘积,但不展开或分配该乘积数量的对象。确认状态由对应原始 `Step.resolved` 决定;任一未确认生产者仍使相关消费端口保留虚线,包括跨分区关系。前端不按相同物品图标补边;显式 `confirmed=false` 关联继续保留。 -- 文本与图标在构造时复制,列表只读,图标访问返回副本。调用方须将传入后取得的 `Component` 及说明视为只读。展示层剔除空代表图标、错误侧端口、重复步骤及悬空或端口不匹配的关联,并记录日志;删除端口的步骤改为未解析。非法显示概率降为未知。重复关联去重;有效步骤和关联继续保留,剔除记录通过覆盖提示说明。资源引用等不可缺少的对象契约仍要求非空。 - -`pages(title, material, steps, connections, notices, navigation)` 生成一张材料页,不执行图遍历、自动规划或步骤分页。材料页使用紧凑的 `queryMaterial(root)`,保留当前材料全部已发布的直接步骤、端口和资源关联,不再按固定数量截断;查询仍不沿其他材料递归。展示层不再限制调用方已提供的代表图标数;自动采样 tag/unit 图标仍最多十六个,这只限制显示代表,不改变原始选择器。需要有界递归或逐条关联查询的调用方仍可显式使用 `Budgets`,并保留准确截断原因;EMI 注册及默认展示页不能调用无上限的逐条连接展开。 - -`notices` 通过页脚的 `i` 提示入口悬停显示全部内容;空列表补上部分覆盖提示。调用方必须说明完整/部分覆盖、未支持族和节点/端口/边预算截断;空结果也必须说明范围。默认 `unbound()` 只表示尚未接线,不能当作“该材料没有来源”。 - -## 布局与交互 - -生产查询使用 `MaterialProcessGraph.queryMaterial(root)`:先展开根材料的 ore、raw、crushed、dust、fluid 等全部已发布形态,再收集与任一形态直接相邻的步骤,不沿另一材料的产物继续递归。因此同一材料页同时包含: - -- “来源”:实际消耗非本材料、产出本材料且不消耗本材料的配方,以及明确来自世界生成的本材料。 -- “内部转换”:实际消耗并产出本材料形态的步骤;洗矿等含辅料和副产物的转换仍归这里。 -- “去向”:实际消耗本材料、产出其他材料且不再产出本材料的配方。 - -显式指定有限预算时,端口预算先作用于步骤,再生成连接;被裁掉端口的连接不占连接预算,缺失范围通过端口截断提示呈现。默认材料页保留全部直接端口。展示层按步骤端口建立索引校验连接,错误关联单独剔除并记录日志,不中断整页注册。原生快照逐条隔离无法读取的配方;重复步骤或冲突资源身份的步骤在修改图索引前整条拒绝,不留下半条记录,其他合法步骤继续发布。EMI 采集也按条目隔离运行期读取失败。 - -分类只使用 `CONSUMED` 输入。仅作为催化剂或存在条件出现的本材料不能建立加工流向;无输入但没有世界生成标记的步骤不能据此声称是来源。没有满足上述条件的步骤不纳入这三个材料转换分类,不能把“不是来源”直接当成去向。 - -通用回收统一由 `MaterialProcessSnapshot.NativeRecipe.genericRecovery()` 判定:配方必须具有 GENERIC 归属,且属于 `MachineRecipeMaps.Shredder`、`Melter` 或 `Smelter`。GENERIC 本身只是配方发布时的兜底优先级,砧敲碎等普通加工也使用它,不能单独作为回收标记。快照索引和展示投影共用此判定,再传给 core 的 `Builder.add(step, genericRecovery)`;不按翻译名称、诊断来源或粉末外观猜测。来源查询不收集通用回收行,材料页只在对应输入材料中把它作为用途保留,且在节点预算之前过滤;预算不足时先保留显式加工,再保留通用回收,仍报告准确截断;普通显式配方的来源关系不变。回收产物在机器旁使用带 `↩` 的独立展示实例,不反向约束主生产链。原始端口、逻辑关联和 viewer 原配方均保留。 - -分类按消费输入、产出和真实 worldGenerated 标记决定横向区域:其他材料转入本材料(含世界生成/泉)、本材料内部形态转换、本材料转为其他材料;通用回收独立归入内部转换之后、去向之前的回收区。这些区域共用一张画布、平移、缩放和标题;空区域不占宽度,有内容的相邻区域之间绘制分割线。未能可靠分类的合法步骤放入内部区,不据名称猜测,也不丢弃。未分类、纯符号、无输入或无输出的合法步骤仍保留原始引用。各区的折叠只比较机器图标的完整物品状态与完整可见输入身份集合或完整可见输出身份集合;工艺 ID、翻译标题、特殊工艺 method、隐藏辅料及条件不参与折叠。缺少可靠机器图标时不合并。仅有相同首产物不足以合并不同的完整产物集合;数量、概率和不同原生引用不单独复制外观相同的路线。 - -同图标下,相同完整可见输入的多个产物或相同完整可见产物的替代输入可以共用机器。优先折叠覆盖步骤最多的一侧,相同时优先输出;已归组步骤不会通过另一侧继续连锁合并,避免把 A→X、A→Y、B→Y 暗示成不存在的 B→X。不同输入和输出形态排列为三列网格;原生配方的联合输入仍完整保留。此处的共用表示可选路线,不能据此把各格输入解释为一次执行需要同时消耗,也不能把变体输出并集解释为一次执行同时产出。 - -合并只作用于总览:`Node.steps` 保留全部原生步骤;每条可见边的 `endpoints()` 保留全部 `Endpoint(step, output, index, port)`。原生配方、选择器约束、数量、概率与 viewer 检索索引不合并或删除。此图不用于推断配方执行等价性。 - -同一 `Port.identity` 在整图优先共享一个资源节点,即使来自不同 selector 或快照资源引用;不同完整 NBT/组件状态仍分开。点击只查询当前显示物品/流体的普通来源或用途,不再把一个节点绑定到任意一条原生配方。`Connection`/`Flow` 仍原样保留,不因展示共享新增逻辑关联。 - -各区分别排布可见依赖并横向拼接,跨区重复材料使用带标记的实例,不用长线穿过分割线;原始跨区 Connection/Flow 仍保留并可反查。区内依赖图按稳定引用遍历,解除反馈边的前向层级约束后计算 DAG 层级;纯环与自环保留方向和标记。相邻层优先按原生端口顺序对齐首个可见输出和首个可见输入,再参考连接度和链长;该排布优先级不会把未知角色改成 PRIMARY。同一机器的多个本材料产物按端口顺序紧挨排成至多三列的网格,输入替代形态使用相同网格;必要时为共享端口创建可反查的局部实例。网格与机器共用一根输入线或输出箭头,每个物品格仍独立命中、查询和显示角标。链段和网格按整体包围盒预留矩形空间后一起排布,并做四轮邻接重心排序,减少交叉;不因连接度大于阈值就拆散公共物品。边跨越超过三层、纵向距离超过 128 单位、穿过中间节点或属于反馈边时,将该端口改为机器附近的局部资源副本,再重新排布。次要输出离机器超过两行时也使用局部副本,避免副产物远离所属配方。每个可见端口最多拆出一个副本,短距离连续主链和邻近分支仍共享资源。建立局部副本后只按可见边计算层级,保留的逻辑 Connection 不再预留远处的隐形依赖列。互不相连的路线按各自网格宽度压紧横向列和空行,再按矩形尺寸就近排列成多列,避免短配方被最长链或其他路线的网格宽度撑开。 - -共享面板的常规悬停只显示实际物品/机器名称;EMI 节点使用原生槽位 tooltip;无原生图标时使用符号名称。机器右上角 `+` 的独立悬停区域显示合并配方数和去重后的辅料名称,最多列出十二项;完整配方信息通过 viewer 普通查询查看。局部副本与回流仍有 `↗`/`↩` 标记,相同物品实例同步悬停高亮,连线不随悬停变色。 - -所有可见连接统一使用单段直线,分支直接斜向相连,不再混用正交折线。输入侧只连线,输出侧保留箭头,连续链为 `材料—机器→产出`。回流使用带 `↩` 标记的局部副本,不在画布顶部预留回流通道;副本之间不额外连线。线宽、虚线间距及箭头与节点使用同一画布变换,随缩放同比变化。布局在首次打开页面创建面板时完成;EMI 注册索引时不提前排布全部材料,缩放、平移和悬停不重新排图。 - -`MaterialProcessProjection` 从同一快照的原生配方复制物品栈和流体状态。含指纹的状态字符串不是序列化数据,不能去掉指纹后新建无数据物品代替;无法恢复时保留无图标符号。EMI 的流体索引、查询和悬停提供器通过 `MaterialProcessEmiStacks` 将代理显示物品还原为真实流体键和数据,而非索引代理物品本身。物品则保留完整 NBT/组件。悬停及点击使用当前实际显示的代表,而原生索引保留全部有限代表;有可用真实图标时优先使用,不让另一条无图标引用遮蔽它。同显示身份可以有多个带标记的局部实例;实例复制不改变原始 selector 或原生索引。 - -查询打开及“复位”均采用 100% 缩放,将查询物品/流体的可见节点放在视口中心;没有匹配目标时定位本材料的代表链。JEI 从当前 `IFocusGroup` 取得完整物品/流体状态,EMI 通过仅限客户端、可选目标的 `EmiMaterialProcessFocusMixin` 在 `EmiApi.setPages` 构造页面前取得查询 ingredient;两个节点均注册该 Mixin,EMI 未安装时由 `@Pseudo` 跳过。每次新查询重新定位,不沿用上次的缩放和平移;当前查询因窗口改变或全屏切换重新排版时保留视图。 - -悬停只突出同一物品的展示实例,不向输入、输出或连线传播;机器图标也按真实物品匹配。物品保留完整 NBT/组件,流体按完整显示身份同步局部副本。匹配结果只在悬停目标变化时更新。查询选中的可见节点持续带淡绿色双线外框,移开鼠标后仍可识别;没有匹配查询目标时只定位代表链,不给它添加查询标记。 - -每条显示配方用浅色边框包围机器及可归属的局部端口;共享端口归属最近机器,边框扩展时不得框入其他路线的节点。该边界只服务阅读,不复制配方或改变原始端口。边框与布局一起缓存,不因平移或缩放重算。 - -嵌入视口根据窗口的 GUI 尺寸伸缩,EMI 再采用 WidgetHolder 实际允许的宽高;绘制、裁剪、原生槽位、控制按钮和命中使用相同的实时尺寸。右上角的全屏按钮打开 `MaterialProcessScreen`,在窗口内展开画布;Esc 或同一按钮返回原查看器。缩放与视口中心的世界坐标在尺寸变化前后保持一致,原生物品/流体提供器在全屏仍生效。JEI 全屏通过 GUI handler 提供查询,EMI 通过 stack provider 提供查询;EMI 发起原生查询前先恢复其原屏幕,满足 `EmiApi.setPages` 的屏幕类型要求。 - -拖拽空白区域向任意方向平移,滚轮围绕鼠标缩放,顶部 `−/+` 围绕视口中心缩放;仍可主动缩小查看全图。裁剪边界先通过 viewer 当前渲染矩阵转换为绝对 GUI 坐标;悬停、点击和 EMI 原生 ingredient provider 共同使用实际渲染矩阵及画布逆变换。页脚 `i` 提供覆盖及截断说明。 - -- EMI 的机器和资源直接接入原生 `SlotWidget`,槽位边界跟随画布变换并裁剪到视口;点击、释放、拖动物品、收藏、R/U 及自定义按键绑定由 EMI 处理。嵌入面板只处理缩放、全屏按钮与画布平移;全屏通过原生提供器及导航回调打开来源/用途。 -- JEI 沿用 `Navigation.openStack`/`openPort` 的原生 focus 查询;EMI 原生槽位同样使用真实物品或流体句柄。`openForm` 保留为显式打开另一材料总览的接口,不再作为生产页资源点击时重新打开总览的路径。 -- `Navigation.valid()` 校验当前 generation;EMI 过期槽位返回空 ingredient,JEI 跳转回调继续拒绝过期引用。`Navigation.NONE` 不提供程序化跳转。 -- 一个材料仍只注册一个 `Page`,局部副本只影响展示,没有删除原配方或另建执行模型。 -- JEI 与 EMI 均从 `Page.indexedPorts()` 建立检索索引,只收录 `Port.material` 等于页面材料且有原生图标的端口。外来主输入、辅料、催化剂及副产物仍保留在原始步骤中,不使该材料页出现在它们的查询结果里;端口角色与有限候选集保持原样。两种 viewer 均用真实流体句柄索引流体。 - -## 后续调用方式 - -在既有 JEI 注册回调中,把从同一已发布内容版本得到的展示投影传入: - -```java -var pages = MaterialProcessDisplay.pages(title, material, steps, connections, notices, navigation); -registration.addRecipes(MaterialProcessCategory.TYPE, pages); -``` - -这里的 `title`、`material`、`steps`、`connections`、`notices`、`navigation` 是调用方的局部变量。生产路径由 `MaterialProcessProjection.initialPages(...)` 从当前 `MaterialProcessSnapshot` 生成这些值;`MaterialProcessDisplay.unbound()` 只用于没有成功发布快照的显式空状态,不能与正式结果同时注册。 - -`Navigation` 由内容适配器创建并捕获该次查询的会话/generation。每次跳转先检查当前版本,过期或不能解析时返回 `false`,不得跳转到新版本中“相似”的配方。不要捕获旧 `Level`/服务器实例,也不要从客户端直接扫描集成服务器表。生产者应将未来 `ProcessRef` 和实际材料形态引用映射到展示引用,适配器使用原生服务重新解析;UI 不发明第二个快照协议。 - -JEI 的 `openStack` 使用 OUTPUT/INPUT focus。EMI 嵌入面板由原生 `SlotWidget` 处理机器与物品的鼠标、键盘和拖拽;全屏通过 stack provider 和 `Navigation.openStack` 接入同一原生查询。普通查询保留完整原生状态,不解析某个 `Step.reference` 来选择精确配方。 - -动态打开查询结果可复用 JEI `IRecipeManager.getRecipeCategory(TYPE)` 和 `IRecipesGui.showRecipes(category, pages, List.of())`;优先让结果仅随当前显示布局存活。若使用运行期 `addRecipes`,调用方必须负责重载、断线、换服以及旧记录和回调的释放;`hideRecipes` 只是隐藏,不能当作回收旧快照的手段。`MachineRecipeClient` 在断线时清除当前快照,`MaterialProcessSnapshot.Store` 只保留当前成功代和一代前代;展示页本身不缓存材料目录或配方表。 - -## 验证范围 - -检查路由为 `runtime`/语言资源 `content`;双平台编译、格式、资源打包与相关 JUnit 命令见[验证入口](validation/README.md)。[游戏检查](validation/checks/manual-ingame.md#矿物处理展示页)分别覆盖两平台及后续远程接线。 - -当前生产页覆盖最终机器配方与活动世界生成;tag/unit 选择器保持符号形式,没有可靠角色信息的输出保持未知。真实洗矿/合金、两次重载、远程 generation、JEI/EMI 普通来源/用途查询及两平台人工点击仍必须分别记录。测试不得为演示把假配方或额外材料来源写入生产表。 - -## 特殊工艺所有权 - -API 用 `SpecialProcessMethod` 绑定现有 typed process key、配方表和展示键。可处理材料注册 `SpecialProcessValue.Target`,辅料材料注册同一 key 下的 `SpecialProcessValue.Reagent`;宿主按 target 的表单计数、产物、概率、辅料量和反应参数生成配方,并把 method ID 写入最终 `Recipe`。已有手工 Bath 行也必须通过同一 target/reagent 规则匹配并获得 method ID,不能仅凭步骤名折叠。 - -每个 Target/Reagent 规则还会派生对应材料标签。`MaterialTagPack` 根据规则表单生成物品/流体标签,供过滤器和自动化脚本使用;分类标签和配方 method ID 共用声明,不维护第二份手写名单。 diff --git a/docs/development/material-process-layout.md b/docs/development/material-process-layout.md deleted file mode 100644 index 96e5e59f1..000000000 --- a/docs/development/material-process-layout.md +++ /dev/null @@ -1,160 +0,0 @@ -# 配方总览图:拓扑分层与资源局部副本 - -本文定义配方总览图的目标呈现方式、布局步骤和验收条件,供后续实现使用。**已接入拓扑分层、连续链、局部副本与共享面板,游戏内外观及性能尚待验收**。当前接口、查询范围、资源身份与跳转契约以[展示接入](material-process-display.md)为准;本文不另建配方事实、公共 API 或查询协议。 - -## 目标与边界 - -图标、工序节点和有向箭头是主要阅读方式。玩家打开页面后直接看到已查询的加工步骤、主材料输入和输出,无需先选工艺区、展开目录或翻配方列表。悬停用于补充数值和条件,普通来源/用途查询用于进一步查看详情。 - -布局只依赖输入输出、资源身份、端口角色及已提供的关联。附属增加处理方式时,只要满足现有展示契约,就应自动参与排布;不得要求它先归入“机械加工”“热处理”等人工工艺区。来源、内部转换、回收、去向按实际消费输入、产出与结构化回收归属分类,按此顺序排列在同一画布上,并在有内容的相邻区域之间以竖向分割线区分,空区域不占空间;这不是按机器名划分的人工工艺目录。世界生成和泉沿真实 worldGenerated 标记进入来源区,通用回收进入内部转换之后的独立回收区。未能可靠分类的合法步骤在内部区保留,不影响准入。 - -规模增大时增加画布面积,利用现有平移与缩放浏览。默认构图优先保证物品和箭头可辨认,不强制把整图缩到一个小视口。该方案接受资源图标重复和较长画布,以减少交叉、长连线与额外查找操作。 - -范围是当前材料直接关联查询返回的 `Page`,不按固定步骤数、端口数或关联数截断。布局不递归补查其他材料、不扫描配方表、不把“图中没有来源”解释为不可获得,也不把潜在路线解释为玩家库存可执行的生产计划。 - -## 图形规则 - -| 对象 | 呈现 | 语义 | -| --- | --- | --- | -| 资源 | 真实物品/流体图标,必要的短名称 | 对应一个具体端口的显示代表;保留原生状态与选择器约束 | -| 工序 | 机器图标或统一的工序符号 | 外观相同的路线可共享工序;全部原生 `Step` 保留,辅料不画入图中 | -| 输入连线 | 资源 — 工序 | 实际消耗的主材料输入,不画箭头;辅料和工具通过 `+` 查看 | -| 输出箭头 | 工序 → 资源 | 对应可见原生输出;主材料多输出在工序附近分支,额外副产物通过 `+` 查看 | -| 资源局部副本 | 相同资源图标及 `↗` 标记 | 同一资源在另一个使用位置的展示实例,不新增资源或配方 | -| 回流 | 局部资源副本及 `↩` 标记 | 返回已有资源的循环关系;方向不因布局反转 | -| 未确认关系 | 虚线及不确定性提示 | 沿用 `confirmed`/`resolved` 的含义,不能只因是回流就标成未确认 | - -辅料、催化剂、存在条件和额外副产物不作为图节点,也不扩展它们的生产路线。它们保留在原始 `Step`,由机器右上角 `+`、tooltip 和原配方展示数量、消耗语义和说明。该侧有本材料时显示本材料的全部消耗输入/产物;没有本材料时优先用 `main`,否则稳定选择一个非副产物的外部主端口。此选择仅压缩图面,不改变原始角色。 - -非 1 件数量或带单位的量显示在格子右下角,非必然产出的概率显示在左上角;未知概率显示 `?%`。共享资源优先使用生产端口的角标;不同批量保留紧凑多值或省略号及 tooltip,不能用某一变体冒充所有配方。 - -普通连续加工链表现为 `A—机器→B—机器→C`。同机器图标、同首个可见产物的多个配方共享一个工序,不同输入形态在旁边合成网格;辅料本身不画入图中。 - -工序名称和图标外观均不参与工艺分类;只比较端口材料与根材料的实际身份及结构化回收标记。多步链的布局不要求识别“粉碎”“蒸煮”等特定名称。 - -## 事实图与展示实例分离 - -实现中应分开以下对象;名称仅用于描述内部职责,不要求新增同名公共类型: - -| 对象 | 必须保存的信息 | -| --- | --- | -| 逻辑步骤 | `Step.reference`、全部原始端口、条件、原生配方引用和解析状态 | -| 逻辑关联 | 原始 `Connection` 或精确资源的 `Flow` 生产者/消费者引用,以及原始步骤确认状态 | -| 端口关联 | 步骤、输入/输出侧、端口位置、角色,以及该端口的原始 `Port` | -| 资源展示实例 | 独立的实例键、展示共享键、对应的端口关联、是否副本及实例位置 | -| 工序展示实例 | 对应全部原始步骤引用及位置;视觉重复的路线共享实例 | -| 展示连线 | 对应的端口关联/逻辑关联、实例端点、直线端点、回流与确认状态 | - -`Port.resource` 是快照内引用,`Port.identity` 是现有契约定义的展示共享键。展示共享不授权 selector 与显示代表互换,也不授权不同原生状态互换。不能从相同 `identity`、同名图标或图上路径推导新的 `Connection`。 - -每条可见输入连线/输出箭头都必须能追溯到原始步骤端口;跨步骤关联仍以调用方提供且通过校验的 `Connection` 为准。图上复用显示代表时,需要保留各端口的候选集与约束,不得将多个 selector 的候选并成一份,总览共享只表示显示代表相同,不构成原生配方可执行或选择器可互换的依据。 - -副本实例键应由稳定的资源引用、所属步骤、侧别与端口位置派生,不能仅使用屏幕坐标或本轮遍历序号。所有实例都保留对应端口的原生导航数据。共享节点和副本按实际显示物品/流体执行普通来源/用途查询,不再挑选某一条配方精确跳转。全部原始端口仍留在实例和边的反查数据中。 - -数量、单位、概率和条件属于步骤及其端口,不属于共享资源节点。图面可在对应端口旁放紧凑角标;完整值仍由该步骤的 tooltip 与原配方提供,不解析展示文本来重建执行规则。 - -## 展示去重与原生事实分离 - -相似路线在各分区内只按机器图标完整状态及一侧完整可见身份集合合并。相同完整可见输入允许聚合可选产物,相同完整可见输出允许聚合替代输入;只共享首产物的不同产物集合保持分开。聚合仍保留全部可见分支及其原生归属,不表示这些分支会在同一次执行中同时产出。不同 `Step.reference`、辅料、数量、条件或 method 仍保存于原始步骤,但不再要求总览重复显示相同图形。未知图标没有可靠外观键,不能只因同为问号就合并。 - -所有原生步骤、端口、选择器、单位、概率及关联原样保留,合并边可以反查全部原始端口;它不改变配方注册项或 viewer 索引,也不声称执行等价。原生配方重复采集仍需在事实产生处处理,不能通过视觉合并掩盖数据问题。 - -相同 `Port.identity` 在同一区内优先共享一个资源节点,跨区保留带副本标记的材料实例,原生资源引用不同不再强制拆开。高连接度本身不触发复制,仅明显跨越多层且偏离主链的长连接才使用局部副本。统计区分原生配方数、显示路线数及资源副本数。 - -## 自动布局流程 - -### 保留完整端口,构造主材料图 - -从当前 `Page` 保留完整端口及原生引用,构造可见主材料资源—工序二部图,消耗输入指向工序,产物从工序引出。输出角色未知时保留 `UNKNOWN`,不按槽位或名称补猜。`Port.main` 只作为可见外部主端口和排布提示,其余端口留在 `+`;不能改变原始主副产物语义。 - -所有合法的已查询步骤都参与展示,不再因为无法归入 `Section` 或缺少可选的主 A/B 而跳过。世界生成仅使用真实 `worldGenerated` 标记;无输入、无生产者或无图标均不能被猜成世界生成。缺少查询范围外的来源时保留符号/范围提示,不补造生产配方。 - -### 处理循环并确定横向层级 - -在可见消耗流与输出中按稳定引用检测反馈边,排除工具和存在条件的非消耗连接。通用回收由快照统一核对 GENERIC 归属与研磨/熔化回收配方表,不能把同样使用 GENERIC 发布优先级的砧敲碎当成回收,判定入口见[展示接入](material-process-display.md#布局与交互):它作为输入材料的用途保留,不作为目标粉末的来源;输出采用机器旁的回流实例,输出关联不向主生产链施加前向层级约束。其余步骤用迭代深度优先遍历解除回环约束,再对前向 DAG 确定层级;反馈边只退出前向层级约束,逻辑方向及事实关联继续保留。 - -前向图中,工序位置应晚于其参与排布的共同输入,产物位置应晚于工序。每个区域内部的层数来自依赖关系,不来自工序类型;有内容的区域最后按来源、内部、回收、去向拼接,区域间不绘制长线,原始关联仍保留在反查数据中。纯循环且没有外部入口时,用稳定引用选择布局锚点,不把这个锚点显示成“原料来源”。 - -浏览器草图用简化的最早生产层估计展示效果;生产实现必须覆盖无外部入口的环、自环、多个生产者及未解析端口,不能直接照搬草图中有限的合成数据假设。层级只表示阅读位置,不代表可达性、执行先后保证或最短生产方案。 - -### 识别连续链段并对齐 - -在已有层级上,首个可见输入与首个可见输出优先参与水平链对齐,顺序来自原生端口索引,再参考连接度、链长和稳定引用。原生首产物只获得排布优先级,不改变 UNKNOWN/PRIMARY 等事实角色。次要产物不会夺取该机器的主链位置。 - -将适合连续阅读的链段尽量放在同一水平线上,外观不同的替代路线及分叉就近排列。交汇点不能无条件合并所有相邻链段,否则一个公共原料会把全图重新拉成一个大团。这里的链段只用于坐标分配,不生成带工艺名称的分区,不删除原始步骤,也不要求玩家进入链段后才能阅读。 - -同一机器的本材料多产物按原生端口顺序紧邻排成至多三列、自动换行的物品栏网格,共用一根输出箭头。相同机器图标下,完整可见输入相同的多个产物,或完整可见产物相同的替代输入,可以共用机器;数量、概率和隐藏辅料差异仍保留在原始端口中。优先折叠覆盖步骤最多的一侧,相同时优先输出;已归组步骤不再经另一侧连锁合并,避免把 A→X、A→Y、B→Y 画成暗示 B→X 的输入/输出笛卡尔积。工艺分类、特殊方法和隐藏详情不参与视觉折叠;未知机器图标保持独立。输入和输出形态均使用相同的网格与一根相应连线。共享资源必要时采用局部实例;格子仍保留原生端口、独立导航和角标。链和网格按整块矩形预留空间后一起分配位置,并进行四轮邻接重心排序;随后按实际节点包围盒压紧和避让。局部副本只受可见边约束,原始 Connection 保留用于反查与确认状态,不再占据隐形依赖列。独立连通块使用各自的列宽、移除空行,再按矩形尺寸紧凑排列成多列;不同路线不会共用最长链和最宽网格的占位。优化顺序为:不遮挡节点与文字、减少交叉、保持连续链水平、缩短连线,再减少画布面积。相同快照输入顺序变化时,稳定引用应保证结果可重复;悬停和高亮不得触发布局。 - -### 选择资源局部副本 - -对造成明显扇入/扇出、跨多个层级、跨链长连接或回流拥挤的可见资源,在具体工序的输入侧或输出侧建立局部副本。可见产物与主输入均可采用该机制,不按工序名称或资源名单特判;隐藏辅料不参与复制。 - -当前副本选择处理跨越超过三层、纵向相距超过 128 单位、会穿过中间节点或属于反馈边的连接,以及偏离机器超过两行的次要输出,不按节点连接度直接拆副本。每轮拆分后重新排布,直到其余连接可以直接绘制;独立端口副本不再拆分。阈值仍需根据真实图调优。优先保留连续主链的直接连接及邻近分支的共享节点,避免无差别复制所有资源后把图拆成互不相连的配方小块。 - -副本应满足: - -1. 图标、名称与明确的副本标记可直接识别,不要求点击才知道它是什么。 -2. 同一资源的实例保留原始端口反查关系;悬停时可同步突出其余同身份实例及相关箭头。 -3. 同名但不同 NBT/组件、相态或选择器约束的对象不因副本机制混为一体。 -4. 以局部副本表达回流时仍标记 `↩`,不能看起来像凭空新增了一种外部供料。 -5. 不为副本之间补画虚构的物料运输/加工箭头;标记表达展示引用,不表示新增配方。 - -### 端口排线与箭头 - -所有连接统一使用单段直线;连续链保持水平,分支使用斜线,不混入正交折线。输入侧只画线,输出侧才画箭头。输入和输出分别分配固定侧的端口位置,网格按整体侧边中点分配锚点,重复端口连线只绘制一次,悬停仅突出同物品实例,不改变共享线颜色;单个物品仍按自身侧边连接。密集多端口场景尚需游戏内确认。跨层边若会穿过中间节点,改用机器附近的资源副本。 - -回流和自环使用带 `↩` 标记的局部资源副本,保留真实输入/输出方向,不画跨越全图的回路,也不为回流预留顶部空白。没有节点的交叉处不画连接圆点,不同资源不能共用一段看似混料的总线;同一资源需要共线时,也应保留各工序的独立端口归属。 - -连线、虚线间距、箭头与图标使用同一画布缩放和平移变换,缩小时线宽和箭头同比缩小,不保持固定屏幕尺寸。箭头不能压住物品图标、数量角标或名称。回流使用副本标记,未确认关系使用虚线;催化剂/存在条件留在详情中,不画入图表。 - -## 视口与交互 - -打开页面即绘制全部已查询步骤及可见主端口;完整端口仍保存在数据和各工序详情中。有内容的区域同时存在于同一画布,不需要工艺区选择器、步骤列表分页或展开操作。有内容的分区标题及分割线随画布一起缩放和平移,空分区不分配空间。常用浏览仍是看图、平移和缩放;副本标记在未悬停时也可见。 - -初始缩放与复位均为 100%,查询目标的可见节点居中并持续带淡绿色外框;没有查询目标时定位根材料的代表链。新查询即使复用缓存布局,也重新设置目标和视口。嵌入视口随窗口和查看器可用尺寸变化,全屏按钮打开窗口内完整画布,Esc 或按钮返回原查看器;尺寸变化保留缩放和中心世界坐标。整图鸟瞰通过主动缩小完成。 - -沿用现有资源与机器的普通来源/用途查询和 EMI ingredient provider。悬停只突出相同物品的可见实例,保留完整原生状态;不传播到产线或连线。查询目标持续带淡绿色外框。每条配方增加浅色边界,局部端口归属最近机器,扩展边框时避开其他路线的节点;共享资源与原始配方事实保持不变。EMI 嵌入图标使用原生槽位,鼠标、释放、快捷键、收藏及物品拖拽沿用 EMI 绑定;全屏接入原生 stack provider 与导航回调。普通 tooltip 只显示名称,`+` 区域显示合并配方数与去重辅料名。 - -所有副本的绘制、命中、tooltip、点击和原生 ingredient provider 使用同一展示实例及相同视口变换。未解析关系仍保留说明与关系提示;资源副本不绕过快照 generation 校验。 - -## 接入现有实现 - -| 入口 | 当前职责 | -| --- | --- | -| `MaterialProcessSnapshot` / `MaterialProcessGraph` | 继续作为事实与材料直接关联查询来源;图布局不额外枚举数据。重复采集如需修复,单独定位事实来源 | -| `MaterialProcessProjection` / `MaterialProcessDisplay` | 保留完整原生步骤、端口及确认关联,不以图标推断关系;副本实例属于布局结果,不成为新的 `DataKey` 或配方事实 | -| `MaterialProcessOverview` | 按原生端口和已提供关联计算依赖层级、连续链、副本与路径;保留原始端口反查 | -| `MaterialProcessPanel` / `MaterialProcessArrows` | 消费布局结果,绘制主材料图、副本和回流;调整默认缩放与复位,统一实例命中和裁剪 | -| JEI / EMI 适配器 | 继续复用同一模型与面板;资源副本仍使用具体原生状态查询,索引不随实例数重复注册 | - -此表是现有入口的改造范围,不新增包职责或规定新的公共类。纯拓扑计算应与渲染 API 解耦,以便自动验证;无需为此次展示改造修改材料注册、存档、原生配方单位或附属处理方式注册要求。 - -布局按快照/页面、视口相关尺寸及字体尺寸缓存。平移、缩放和悬停不能每帧重算全图;重载或 generation 变化时释放旧实例和回调。渲染时可以做视口裁剪,但所有已查询节点仍须存在于布局中,不能把离屏节点当作删除或截断。 - -当前材料页不设固定步骤、关联或端口上限,查询范围限于根材料的直接关联。关系按精确资源保存为 `Flow` 的生产者/消费者引用,两侧数量相乘只用于统计,初始化与布局均不展开该乘积。EMI 注册只保留去重的本材料检索代表与页面工厂,打开页面时才查询完整步骤、紧凑关系和布局。自动采样的选择器图标最多十六个;显式提供的图标列表不受该采样数限制。坏记录记录日志后单独剔除,并保留覆盖提示;展示校验采用端口索引,折叠复用已计算的可见端口,布局不反复扫描同一合并机器的全部端口来判断主连线。浏览器压力演示仍不代替生产页的游戏性能验收。 - -副本最多恢复到每个可见原始端口一个实例,资源实例总数不超过可见端口数;工序数不超过原始步骤数。该内部成本界限不删除步骤或原始端口,辅料和副产物仍留在工序详情。查询已截断时继续显示准确的覆盖提示,不显示“完整生产链”。 - -## 验证与实施顺序 - -自动验证覆盖原生引用、层级/循环、连续链、局部副本和排线,随后在共享面板中检查原生交互与可读缩放。只有真实样例证明需要时再调副本阈值,避免以某个工艺名称增加布局特判。 - -| 场景 | 必须满足的结果 | -| --- | --- | -| 八步链、多种替代配方 | 连续路线可直接沿箭头读;全部原始步骤保留,外观相同路线只显示一次 | -| 多输入、多输出、概率与未知角色 | 所有端口属于正确工序,隐藏辅料和副产物仍可在普通配方查询中查看,概率和约束不被共享节点覆盖 | -| 高连接度原料与副产物 | 优先共享同一资源,只有明显长连接才使用副本,标记可见;统计能区分事实数与实例数 | -| 未分类的新处理方式 | 仅提供合法输入输出即可排布;改名、换语言或新增 method 不要求增加分区规则 | -| 回收环、自环、无外部入口的环 | 布局终止,无伪造来源;反馈边及副本仍保留原始方向和回流标记 | -| 相同图标,不同原生状态或 selector | 原始约束与导航目标保留,不产生伪关联或任意替换 | -| 同名机器、同 A/B,条件或辅料不同 | 总览合并相同外观,保留所有原始步骤;图标点击执行普通来源/用途查询 | -| 纯符号资源、未知来源、未确认连接 | 保留节点与范围说明,不猜世界生成,不把回流等同于未确认 | -| 百步、超过旧数量限制及大端口配方 | 节点/文字不重叠,箭头不穿节点;保持可读比例,布局成本有界 | -| 相同快照打乱输入顺序 | 布局稳定;每个输入输出均能反查到原始端口 | -| 缩放、平移、GUI 缩放与重载 | 命中和图标一致,旧快照无法跳转,无离屏误删 | - -拓扑自动检查应验证:每个原始步骤均能反查对应路线实例、所有可见端口可反查,隐藏端口保留在详情、布局不新增逻辑关联、副本可反查、包围盒不相交、前向边满足层级、反馈关系保持,以及相同输入的确定性。截图与性能记录应包括逻辑节点/关联数、副本数、布局耗时、画布尺寸、GUI 缩放和实际可读比例;不能只以编译通过判定可读性。 - -实现后的检查命令按[验证入口](validation/README.md)路由选择。人工检查覆盖 Forge/NeoForge、JEI-only/EMI-only/双装、无 viewer 专用服务端及远程客户端;使用[矿物处理展示页检查](validation/checks/manual-ingame.md#矿物处理展示页)并在实现时同步其旧分区、共享唯一节点和辅料变体切换预期。测试数据只放在已接入的测试位置,不写入生产配方表。 - -当前拓扑、确定性、副本、循环与交互坐标可由自动检查验证;真实材料图、游戏内小视口、两平台 viewer 交互和运行性能均尚未按本设计人工验收。完成接入时同步[展示接入](material-process-display.md)的现行行为说明与相关检查文档;不得提前把本文的目标行为写成已经实现。 diff --git a/docs/development/material-system-refactor/01-03-implementation-summary.md b/docs/development/material-system-refactor/01-03-implementation-summary.md deleted file mode 100644 index ec2e32e0e..000000000 --- a/docs/development/material-system-refactor/01-03-implementation-summary.md +++ /dev/null @@ -1,78 +0,0 @@ -# 材料系统重构 01–03 实施摘要 - -## 核心目的与要求 - -本次重构要把分散在不同注册入口、生成表、兼容门面和机器消费者中的材料事实,收敛为**每类事实只有一个权威定义**,再通过统一校验、链接和只读查询交给各类消费者使用。目标不是单纯压缩代码,而是消除注册顺序、查询路径和双写造成的身份漂移与规则不一致。 - -核心要求: - -- 材料身份、注册名、数值 ID、配方身份和持久化单位保持兼容;附属材料仍有明确所有权和宿主分配 ID。 -- 定义安装必须经过统一校验;失败不能留下半完成索引,READY 后不可再修改目录,FAILED 后不能继续伪装为可用。 -- 组成、工具、燃料、加工目标、分类 tag、替代组和形态规则分别有明确归属,不能由消费者自行重新解释。 -- 旧 API 和生成符号只能转发到新权威,不能继续保存第二份可变事实;没有消费者的旧入口逐步删除。 -- 扩展性优先于强制深度冻结:process value 由调用方持有,但注册后必须遵守不可变契约。 -- 身份和主流程迁移不得顺带改变没有依据的游戏行为;GT6 对照、parity 决策和已知差异必须单独记录。 - -本文概括 01–03 已完成的工作、当前权威入口和兼容边界。详细验收见各阶段计划及[基线报告](../../integration/material-baseline.md)。 - -## 01:基线与正确性对照 - -- 建立三处独立材料快照:两次无附属初始化,以及一次通过真实 ServiceLoader 加载测试附属的初始化。 -- 用稳定名称、ID、别名、属性、组成、燃料、加工目标、形态和引用生成排序投影,保留有语义的顺序。 -- 新增材料引用审计,检查组成、分解、形态、UUM、加工目标等引用,并把有效、别名、历史停注和真正悬空分开。 -- 建立固定的 GT6 来源依据和已知差异清单,包括 72U 截量、铜材双平台差异、铸模状态、原生工具成分等;这些现状没有被当成正确性通过。 -- 新增共享 `MaterialBaselineTests`,覆盖存储块、72U 物品、复合工具头、损坏工具、容器、铸模、分解和附属材料,并提供真实资源重载批次。 -- 清理形态表中误抽取的 `rmaterial` 局部变量键。没有改变材料注册顺序或生产行为。 - -## 02:统一注册与规范目录 - -- 内置材料改为由 `content.material.catalog` 的七类声明统一维护:元素、化合物、矿物、石材、木材、特殊材料和组。 -- `MaterialDefinitions` 只负责收集、排序和提供稳定键索引;读取 `Materials.*` 等符号不会隐式启动注册。 -- `GTMaterialRegistry.init()` 统一执行定义安装、引用校验、链接、附属回调、最终角色、辅助数据冻结和只读视图发布。 -- 安装阶段明确分为 `DEFINITIONS`、`LINKS`、`FINALIZING`、`READY`、`FAILED`。身份、别名或附属声明失败后,公开材料入口持续拒绝访问。 -- `MaterialRegistryState` 在修改名称、ID、别名和集合前完成冲突检查;sentinel、内置、组和附属材料使用明确安装模式。 -- 附属同名一致声明继续合并;所有权、命名空间、tag 包含环、组环、未知材料和跨所有者冲突在 READY 前校验。 -- 主材料定义收敛为身份、展示、物性、基础属性和来源;工具、组成、关系和处理规则进入 `MaterialInfoDefinition` 与 `MaterialInfoRegistry`。 -- 新增只读 `MaterialCatalogView`、`MaterialView`、类型化 metadata、材料分类 tag、替代组、process 和定义期 form 查询。 -- `postInit()` 只检查 READY,不再补写静态材料事实。材料翻译继续由现有语言文件维护,并增加英中键覆盖检查。 -- API 1.4–1.6 依次加入定义视图、类型化 process、独立辅助索引和附属注册拆分。 - -## 03:属性、燃料与形态 - -- `GTMaterial` 不再保存组成、工具、燃料、矿石副产物、加工目标或倍率字段;这些事实只由每材料的辅助状态维护,并在链接和最终角色完成后发布。 -- 燃料使用 `FuelRule`,加工目标使用 `MaterialTarget`,矿石规则使用 `OreProcessingRule` 等类型化值。 -- 多组件燃料从同一组件集合计算热值和灰烬;同种灰烬合并,不同灰烬或超过单槽容量时拒绝燃烧,不再任取首组件。 -- 按固定 GT6 来源修正多处木材燃料;补齐 Bentonite 组成;删除 Phosphor 无来源的 `MELTING`。 -- 布尔 flag 使用与声明顺序无关的闭包;气体包含液体,离心/电解权限包含 `DECOMPOSABLE`,并拒绝 `FLAMMABLE` 与 `UNBURNABLE` 冲突。 -- 定义期形态统一为 `MaterialFormRule`,区分 item、block、fluid、默认材料量和显式请求来源;实际注册结果由 `MaterialFormBinding` 发布。 -- `MaterialForms` 改为兼容查询门面,从规范辅助快照读取;`MaterialFormContent` 在平台注册完成后发布真实 item、block、fluid 和显式统一物品绑定。 -- 常见 form 的资源 tag 映射集中在 `MaterialEquivalence`,`CraftingMaterialForms` 不再维护第二份映射。 -- `Any*` 消费者继续使用兼容符号,但成员和包含关系统一读取 `MaterialTagsView` 中的替代组。 -- 补测覆盖 Paper 多组板、NetherQuartz 宝石形态、Iron 物品/方块重量和 Tantalum 强制宝石规则。 -- API 1.7 增加详细 form 规则、实际绑定视图和分组包含查询;API 1.8 增加类型化分解规则。 - -## 已移除或停止作为权威 - -| 内容 | 当前状态 | -| --- | --- | -| `MaterialFactories` | 已删除;生产代码不再通过旧工厂隐式安装材料。 | -| `MaterialFacts` | 已删除;原扁平事实迁入类型化的 `MaterialInfoDefinition`。 | -| `MaterialCompositionData`、`MaterialDecompositionData`、`MaterialModTags`、`MaterialOreProcessing`、`MaterialRegistryExtras` | 已删除运行时写入;事实迁入规范目录。 | -| `MaterialFormCorrections` | 已删除;修正进入规范声明和最终派生规则。 | -| 各生成材料表和 `GT6Materials` | 保留兼容符号,只指向已安装的规范材料,不再定义第二份事实。 | -| `MaterialForms`、`MaterialProcessingTargets`、`MaterialGroups` | 保留查询门面;分别转发到辅助快照、process 快照和组视图。 | - -## 已弃用入口 - -- `GTMaterial` 整体标记为内部兼容模型;工具、燃料、矿石、粉碎、熔炼、压粉目标和倍率等旧 getter/setter 保留签名,但转发到新的辅助状态。 -- `GregTechMaterials.find()`、`find(int)`、`all()`、`invalid()` 和旧 `Material` 句柄弃用;新读取使用 `catalog()`、`MaterialView` 及各领域视图。 -- `AddonMaterialContributor` 的 `forms()`、`compositions()`、`metadata()`、`materialTags()`、`materialGroups()`、`processes()` 弃用;新附属使用 `materialInfo(MaterialInfoTool.Registrar)`。 -- `MaterialInfoTool.forAddon()` 以及接收旧 `GregTechMaterials.Material` 的注册重载弃用。 -- `MaterialToolHelper`、`FuelMaterialHelper`、`CrushingMaterialHelper`、`SmeltingMaterialHelper`、`PulverizationMaterialHelper`、`OreProcessingMaterialHelper` 中接收 `GTMaterial` 的重载弃用;优先使用 `MaterialKey` 查询。 -- `GTMaterialRegistry.createMaterial()` 弃用;内置材料走规范目录,附属材料走公开声明 SPI。 - -## 明确边界 - -- Process value 保留调用方扩展能力,不进行深度冻结;注册后必须由调用方保证不再修改。 -- 资源 tag 桥接、完整来源/用途索引和处理图仍属于后续阶段。 -- 客户端 tooltip、配方展示和实际交互仍需游戏内手工验收。 diff --git a/docs/development/material-system-refactor/01-baseline.md b/docs/development/material-system-refactor/01-baseline.md deleted file mode 100644 index d640e3b0c..000000000 --- a/docs/development/material-system-refactor/01-baseline.md +++ /dev/null @@ -1,89 +0,0 @@ -# 01:建立基线与正确性对照 - -本计划把材料链路转成可重复观察和验证的对象,作为后续迁移的验收基础。状态:已实施并完成下述范围的基线验收;无前置计划。实际结果与已知差异见[基线报告](../../integration/material-baseline.md),完整原始材料留在 `work/material-system-refactor/`。通用约束与检查代号见[总计划](README.md)。 - -## 目标与边界 - -交付“当前行为”“权威期望”“差异说明”三类可区分的结果。当前配方数量或材料数量不作为正确性结论。本阶段主要增加测试与调查证据;发现生产缺陷时先记录,由对应迁移阶段修复,不能在基线采集中顺手改变注册顺序。 - -## 先读与入口 - -- `core/src/main/java/gregtech/engine/material/GTMaterialRegistry.java`:定义、链接、别名、core 身份与附属安装阶段。 -- `core/src/main/java/gregtech/content/material/MaterialDefinitions.java` 及 `content/data/generated/Material*`:事实写入点。 -- `core/src/test/java/gregtech/content/material/MaterialTestFixture.java`、`MaterialCatalogTest.java`、`FuelParityTest.java`:已接入的 core 回归。 -- `minecraft/src/main/java/gregtech/engine/material/ItemMaterialRegistry.java`:显式、标签派生、按栈状态缩放及准入。 -- `minecraft/src/main/java/gregtech/content/recipe/MachineRecipeBootstrap.java`、`MachineRecipeLifecycle.java`、`MachineRecipeOverlay.java`:生成、覆盖及重载。 -- [parity](../../decisions/parity/README.md)、[JUnit](../validation/checks/junit.md)、[GameTest](../validation/checks/gametest.md)。 - -## 实施步骤 - -### 1. 固定调查环境与比较口径 - -1. 记录代码提交、已有工作区修改、两个节点、可选模组是否启用;不把他人未提交修改归入本计划。 -2. 在无可选模组环境采集基线,另用 test source set 的附属夹具覆盖附属声明;不能因真实联动模组缺席而跳过宿主 SPI 路径。 -3. 区分原始材料对象、`resolve()` 后材料与可用材料;快照以稳定注册身份表示链接,不使用内存地址、动态附属数值 ID 或哈希容器迭代顺序。 -4. 把两个节点同名物品的成分和授权做交集比较;版本独有物品另列,不因物品总数不同直接判定失败。 - -交付:`work/material-system-refactor/` 中的环境说明和原始采集结果;可运行的纯快照归一化测试。 - -### 2. 定义精简快照 - -| 范围 | 必须比较的字段 | 归一化规则 | -| --- | --- | --- | -| 材料 | ID、注册名、别名、来源、原子与物性、燃料/灰烬、加工目标、组成与 divider | 按稳定身份排序;有语义的副产物顺序保留 | -| 形态 | prefix 身份、可生成性、单位重量、最终物品/方块 ID | 只记录实际候选与生成结果,不物化所有材料×所有 prefix | -| 物品成分 | 物品 ID、prefix、全部材料量、批量授权、来源与派生类型 | 无语义的组件集合按身份排序;主材料另列,避免排序改变含义 | -| 配方 | map、输入身份与数量、选择器/催化剂、输出、时长、EUt、运行期限制 | 语义签名保留槽位和角色,内部 unit 折叠单列 | - -不要提交整份机器原始 dump。提交的期望文件只保留审阅过的稳定字段或代表性案例;其余全量结果留 `work/`。增加字段时说明它验证的外部行为,避免快照变成每次重构都要重录的实现副本。 - -### 3. 建立差异分类与数据校验 - -1. 枚举成分、分解、形态、UUM、加工目标表中的目标引用,分成有效、已停注、别名映射、真正悬空四类。 -2. 对已停注行要求指向现有移除决策;不能把 issue 中的历史漂移数量直接录成永久允许数量。 -3. 对未知悬空引用先输出带表名、材料身份与字段的失败证据。严格失败规则在清理或显式标注历史行后启用,避免首次开启校验就让正常启动全部失败。 -4. 当前错误行为可由明确的“已知差异案例”记录;正确性断言只采用已核对依据的预期。测试保持可执行,不用禁用测试表达待办,也不以兼容快照覆盖正确性断言。 - -交付:有限、逐条解释的差异清单,以及能对新增非法引用报错的纯校验器;如当前非法行尚未修复,应明确本阶段未完成或把对应修复作为独立小变更先完成。 - -### 4. 接入最小运行期测试 - -优先扩展 `BlockPropertyTests` 的成分存在性检查;不能用该类替代材料链路测试。新增按材料领域命名的共享 GameTest,先覆盖: - -- 普通铁/铜存储块:全部成分、材料量、批量回收与坩埚准入分别可观测。 -- 72U 物品:记录当前计划与最终可查产物,显露是否截量。 -- 复合工具头:注册表、物品实例与等价形态查询的差异可定位。 -- 完好/部分损坏/耗尽工具、空容器/有内容物容器:拒绝或缩放原因可定位。 -- 已凿形状的铸模与压模机模具:记录成分、形状状态和回收准入,承接 #351 关联的 #349、#350。现有 `MoldDropTests` 只证明掉落保留形状,不能证明坩埚或批量回收可用。 -- 一种固体化合物与一种带流体输入的化合物:分解 map、输入与输出可查询。 -- 数据包重载前后:同一固定样例可查询,拥有者和规则数量无累积。 - -若使用真实重载可能影响并行 GameTest,放入独立顺序批次并等待完成,再恢复夹具;仅调用内部 `rebuild()` 只能证明内部函数,不能宣称真实资源重载已验证。 - -## 独立验证与完成条件 - -检查集:D、F、J、C、G;若新增测试夹具改变生产打包配置,再加 B。测试源码必须实际由两个节点编译和执行。 - -| 验证项 | 通过条件 | -| --- | --- | -| 重复采集 | 同一节点两次干净启动的归一化结果一致;忽略项逐项有理由 | -| 权威期望 | 每条正确性案例有 parity 或固定 GT6 方法/数据依据;现代内容有明确项目规则 | -| 引用完整性 | 已知停注有分类;新增未知悬空、ID/name 矛盾、非法组件必须失败 | -| 负例有效 | 注入一个假材料引用或修改一条预期数量,测试确实失败;移除注入后恢复通过 | -| 游戏链路 | 两节点实际执行代表案例,首次启动与重载证据分开记录 | - -本阶段结束时应能回答“后续改动改变了什么,哪些改变获得了依据”,并能直接运行已有测试获得相同结论。 - -## 拆分与失败处理 - -建议分成:纯归一化与引用校验、已知漂移清理、运行期快照与代表案例三个小变更。全局初始化测试不添加生产 reset 方法;优先复用单次初始化 fixture,确需测试独立生命周期时使用独立 JVM 的测试隔离机制。 - -因上游源码或游戏环境缺失导致无法核实时,写出具体缺口,保留已有检查结果;相应阶段保持未验收。基线测试失败本身是定位证据,不能通过删断言变成通过。 - -## 实施结果(2026-11-07) - -- core 新增独立 JVM 材料/别名/prefix/引用投影、源表审计与逐行历史分类,测试附属经真实 ServiceLoader 安装;没有增加生产 reset;先独立删除形态表误抽取的 `rmaterial` 一行,再开启严格零未知引用校验。 -- 共享 `MaterialBaselineTests` 包含 8 个材料领域用例,覆盖代表样例、test-source 材料 SPI 和独立顺序批次中的两次真实资源重载。 -- 材料、物品/方块形态、成分、配方语义及 tag 成员采用排序投影;无序 tag 的展示代表单独归一化,不忽略输入集合。 -- 当前行为、权威断言和差异清单已经分开。72U 金苹果截量、铜材的双平台差异、原生工具/压模具缺少成分、有形状铸模被拒、NeoForge Fermenter 重载差异均保留,未在本阶段修复生产行为。 -- 检查、精确平台版本、负例和重复采集结果统一维护在[基线报告](../../integration/material-baseline.md#复现与执行记录)。后续阶段不能把更新观察数据当作正确性裁决。 diff --git a/docs/development/material-system-refactor/02-material-registration.md b/docs/development/material-system-refactor/02-material-registration.md deleted file mode 100644 index 930410923..000000000 --- a/docs/development/material-system-refactor/02-material-registration.md +++ /dev/null @@ -1,101 +0,0 @@ -# 02:统一材料注册与规范数据 - -本计划使材料身份与定义只有一条经过校验的安装路线,并把同一材料的静态事实收敛到规范目录。状态:已实施并完成下述范围;前置 [01](01-baseline.md) 已完成。目标类名用于描述拟议设计,实际命名遵循现有包与风格。 - -接口定稿前完成 [08-A](08-material-data-api.md#a确定薄视图与最小公共契约),metadata 扩展与分类/组按 08-B 接入;[设计提议 0001](../../decisions/0001-material-data-api.md) 约束主材料只承载内在事实,来源与处理图通过查询服务提供。新公开模型不把 `Any*` 组当真实材料,旧内部对象在消费者迁完前保留适配。 - -## 目标与实际入口 - -实施前 `registerDefinition()`、`createMaterial()`、`installAddonMaterial()` 的约束不同,`MaterialFactories` 又直接创建材料。迁移已把这些入口收敛到 `MaterialRegistryState.install`,旧方法只保留受阶段约束的兼容转发。 - -需要同时跟踪: - -- core 的 `engine.material.GTMaterialRegistry`、`MaterialDefinition`、`MaterialRegistryState`、`MaterialLinker`; -- `content.material.MaterialDefinitions`、`Materials` 及 `content.material.generated` 目录; -- `content.data.generated.GT6Materials`、`content.data.ImportedMaterialData`; -- `engine.addon.AddonMaterials` 的定义安装、共享声明合并、所有权、链接与发布; -- `content.data.MaterialGroups`、`AntimatterMaterials` 以及 `postInit()` 的追加事实; -- 公共 `api.addon.material` 声明和访问协议。 - -## 目标数据与阶段 - -规范目录以稳定名称和保留的内置 ID 标识材料;引用其他材料时保存稳定键,由链接阶段解析。逻辑上每种材料一条声明,可按元素、化合物、木材等分文件。先扩展并复用 `MaterialDefinition`,只有确实需要时才增加承载关联声明的类型,不引入第二种旁路注册模型。 - -主定义只承载身份、展示、物性/原子、基础属性与来源;组成与 divider、加工目标、燃料/灰烬、形态规则、工具和分解权限通过 `MaterialKey` 关联到独立附属域。03、06 负责将这些附属域进一步变成最终查询,本阶段先统一身份与数据归属。 - -定义安装、引用链接、最终校验应有清晰边界。现有链接会建立材料组,附属回调也可能进行合法操作,因此实施前先列这些调用:能预声明的移到定义阶段;确需链接时合成的组通过显式内部路线创建并接受同样身份校验。不得给普通调用者开放无限制创建窗口。 - -## 实施步骤 - -### 1. 整理身份与失败策略 - -1. 盘点所有创建、别名、replacement 与 re-registration 调用,区分历史同名覆盖和真正的材料等价关系;`setRegistration` 的语义不能直接按“重复材料”删除。 -2. 把唯一性检查放在改变任意索引之前:名称、ID、别名、阶段失败时,名称索引、ID 索引与全量集合都保持原状。 -3. 将 sentinel 的初始化、内置正 ID、附属宿主分配 ID 分别作为明确安装模式,共用名称和 ID 冲突校验。 -4. 保留附属同名一致声明的既有合并契约;定义不一致时指出附属、字段和两份来源,不把它误报成普通重复内置材料。 -5. 处理别名的规范名优先、历史反物质冲突等特例:保留有依据的规则,放进显式映射并测试;未声明的冲突报错,相同别名与目标重复安装可幂等。 - -交付:一个安装核心;旧创建方法只作为受约束的临时转发或移除,不再拥有独立放宽规则。 - -### 2. 建立规范目录并迁移定义 - -1. 先迁一组代表材料:Iron、一个气体、一个带组成的合金、一个木材、一个有意停注的条目;验证命名、相态与引用能表达后再迁余下目录。 -2. 不在声明常量初始化时执行注册。建立材料对象和按键链接的固定流程,避免读取 `Materials.X` 自动在任意生命周期安装整个目录。 -3. 逐类迁移生成目录的工厂调用;保留生成声明与已知来源,不假称历史生成器存在。一次性转换脚本和原始 GT6 源码放 `work/local-tools/`。 -4. 将补充材料、粒子、Magic、反物质、染料和必要的材料组纳入同一身份规则;内部类型可以不同,但不能再形成不受校验的注册入口。 -5. 用目录安装顺序和稳定链接顺序确保可重复结果,不以 `HashMap`/`HashSet` 的遍历顺序分配配方或附属身份。 - -交付:所有内置身份由规范目录安装,旧符号门面仅引用已安装的同一对象。 - -### 3. 收敛关联表与历史缺失行 - -1. 按事实所有权逐项迁入规范声明:组件、加工目标、基础形态集合、燃料、分解能力;迁一项即停止旧表写该字段。 -2. ID 与名称都存在的历史表先验证二者指向同一材料;不能继续“ID 优先、名称兜底”掩盖矛盾。 -3. 对停注材料清除仅供当前运行目录的无效行;若保留为历史输入,使用显式停注状态并由导入/校验阶段处理,不送入运行时解析器。 -4. 断言引用目标存在、数量与 divider 合法、必要字段完整;不要过滤掉无效组件后继续注册一个残缺配方。 -5. `postInit()` 中最终补的静态事实应迁回目录或明确的最终派生阶段,保证消费者读到的是最终状态。保留必要平台装配顺序。 - -材料翻译文本与材料物理事实各有自己的唯一来源。现有 lang 保持翻译权威,目录派生材料语言键并验证覆盖;若以后生成材料专属语言子集,必须先确定文本归属和资源合并方式,不能覆盖整份大型语言文件。 - -### 4. 关闭旁路并同步契约 - -1. 以调用方清单证明生产代码不再通过旧工厂隐式安装材料。 -2. 只读门面继续返回规范对象;删除没有消费者的重复字段与二次初始化代码。 -3. API 中的 `GTMaterial` 当前标记为内部模型,但仍位于 API 产物;对签名和生命周期变化执行 A,公共附属声明与访问器保持兼容或提供明确迁移。 -4. 更新现有 API、content、engine、runtime 包文档中的实际注册职责;新阶段真正落地后再将说明从“计划”改为“当前实现”。 - -## 独立验证 - -检查集:D、F、J、C、G;涉及 API 契约加 A,生产资源改变加 B。 - -| 层次 | 案例与断言 | -| --- | --- | -| 纯注册规则 | 重复名称、同名异 ID、重复 ID、未知别名、越阶段注册均失败;失败前后所有索引一致 | -| 初始化 | 完整初始化成功且重复初始化幂等;声明/链接失败后后续访问不能伪装 READY | -| 历史语义 | sentinel、染料身份、Trinium 的历史符号、Tn 等别名、反物质映射与材料组符合已核对预期 | -| 附属 | 两个附属相同声明按既有契约合并;不同字段冲突可定位;core 名称不可被覆盖;动态 ID 不侵入内置范围 | -| 目录 | 所有活动目标可解析;移除或拼错目标、制造 ID/name 矛盾时校验失败 | -| 游戏启动 | 两节点材料、形态身份与 01 对照一致,允许差异有单独依据 | - -负例可用独立注册状态测试安装核心,不为测试引入全局生产 reset。门面提前读取的用例需在独立生命周期环境验证,避免已初始化的测试 JVM 掩盖问题。 - -## 完成、拆分与兼容边界 - -建议依次交付:安装核心与负例、代表材料目录、全目录迁移、关联静态事实迁移、旧入口关闭。每一批保持原有消费者可用;尚未迁移的字段标明唯一写入者,避免双写。 - -完成条件:新增一种普通内置材料只增加一处领域声明;所有活动身份只安装一次;未知引用和未声明冲突能失败;01 的身份/数量对照通过。03、06 尚未迁移的复杂数据可以仍用旧表示,但必须通过规范目录关联,不能再各自决定材料身份。 - -本阶段默认不改变注册 ID 或存档格式。需要改变的历史特例作为单独兼容性变更交付;关闭入口不是删除仍被附属公开契约使用的能力。 - -## 实施结果(2026-11-07) - -- 内置身份由 `content.material.catalog` 的七类领域声明统一安装;`MaterialDefinitions` 只收集、排序和建立稳定键索引,读取符号门面不会触发注册。 -- `MaterialRegistryState` 在修改名称、ID、别名和全量集合前完成身份校验;sentinel、内置、历史和附属安装使用明确模式。`GTMaterialRegistry.init()` 依次完成定义、引用校验、链接、附属回调、最终角色和不可变视图发布,重复初始化幂等,任一阶段失败后后续访问继续失败。 -- `MaterialFactories` 已删除;生产代码不再通过旧工厂隐式安装材料。`Materials`、`GT6Materials`、`ImportedMaterialData`、粒子、反物质、染料和材料组符号返回同一规范对象。 -- 组件、加工目标、形态集合、燃料、分解权限和角色事实已经进入规范声明或明确最终派生阶段;`postInit()` 只校验 READY,不再补写静态材料事实。 -- API 1.4 新增定义目录、类型化 metadata、材料 tag 包含关系和附属替代组声明。附属只能写入自身命名空间;未知 tag/组、包含环、组环、未知材料和跨所有者冲突在 READY 前失败。 -- API 1.5 在过渡层增加类型化 `MaterialProcessKey`/`MaterialProcessesView`、附属 process 声明和 `MaterialFormRulesView`。smelting、crushing、pulverization、fuel、ore processing 与工具查询拥有独立 Helper;旧 `GTMaterial` getter/setter 暂时保留并标记弃用,现有下游仍可直接编译。`MaterialFacts` 已删除,原 34 项扁平数据先收敛到分组对象。 -- API 1.6 进一步把主声明收敛为 `MaterialDefinition` 的身份、展示、物性、基础属性和来源五项;工具、组成、关系和处理规则进入 `MaterialInfoDefinition` 与独立的 `MaterialInfoRegistry` 索引。`MaterialInfoTool.forAddon(addonId)` 提供类型化注册,`GTMaterial#tool()` 是冻结工具索引的只读快捷方式。metadata、tag、group、form 和 process 的索引在 READY 后不可修改;process value 由调用方持有,Javadoc 规定注册后不得动态修改,宿主不强制深度冻结。 -- `MaterialCatalogView` 在 READY 时发布不可变视图;旧宿主实现通过默认方法明确报告不支持。材料翻译仍由现有 `assets/gt6ce/lang/*.json` 维护,并增加全部非组规范材料的英中语言键覆盖测试。 -- 01 旧快照与当前最终状态有 87 个材料属性差异,全部来自世界生成和石材角色的最终派生 flag:79 个增加 `GENERATE_ORE`,3 个增加 `GENERATE_ORE` 与 `GENERATE_ORE_PROCESSING`,5 个增加 `STONE`。这些 flag 在旧流程中也由 `MaterialRoleFlags.apply()` 于物品注册前写入;02 将其前移到 READY 前的最终定稿。双平台物品、方块形态、配方、tag 和代表案例投影仍与 01 基线逐文件一致,注册 ID、存档格式和运行行为未改变。 -- 检查集 D、F、J、A、C、G 均已通过;API 104 个 JUnit、core 99 个 JUnit、API 契约和 READY 前失败路径全部通过,双平台各 79 个 GameTest 通过。生产资源与打包配置未改,因此本阶段未执行 B;客户端手工场景不属于本阶段完成条件,未执行 M。 diff --git a/docs/development/material-system-refactor/03-properties-and-forms.md b/docs/development/material-system-refactor/03-properties-and-forms.md deleted file mode 100644 index 0a6fc277f..000000000 --- a/docs/development/material-system-refactor/03-properties-and-forms.md +++ /dev/null @@ -1,82 +0,0 @@ -# 03:整理属性与形态规则 - -本计划让结构化属性、布尔能力和形态规则各自承担明确职责,并统一形态生成与重量查询。状态:已实施本页范围;前置为 [02](02-material-registration.md)。 - -与 [08-B/C](08-material-data-api.md) 同步实施:08-B 的分类 tag、行为 flag、替代组定义与查询已随 02 完成;本阶段继续迁移现有 `Any*` 工艺消费者,并实施 Minecraft 资源 tag 与 08-C 形态视图。形态 API 分别回答规则允许、实际绑定和有效获取途径。具体接口语义以[设计提议 0001](../../decisions/0001-material-data-api.md)为准。 - -## 当前边界与目标 - -`GTMaterial` 位于 `api/common/src/main/java/gregtech/api/material/`,混合身份、燃料、工具和加工目标;`MaterialProperty` 混合类型、状态和生成能力。core 的 `content.data.MaterialPrefix`、`MaterialPrefixes`、`content.data.generated.MaterialForms` 和 `engine.prefix.BlockMaterialPrefix` 分别承载形态事实。 - -本阶段复用现有材料对象身份,逐个字段域更换存储和消费者。目标是“身份/展示信息 + 有类型的稀疏属性 + 布尔 flag”,先验证收益再迁下一域;不要求一次性引入完整属性框架或重写全部 prefix。 - -## 实施步骤 - -### 1. 建立字段与消费者映射 - -1. 为燃料、矿石加工、工具、流体/热学、组成、生成能力分别列出读写者及默认值。 -2. 区分“没有该能力”和“有能力但数值为零”。例如零灰烬可能合法,不得因为没有灰烬就删除燃料属性。 -3. 记录字段变动是否影响附属查询、物品生成、坩埚行为或配方单位;保持由 02 确认的稳定身份与引用关系。 - -交付:每个域的唯一存储点与迁移顺序;先做燃料,再做矿石/工具,最后迁热学、组成与形态能力。 - -### 2. 先迁燃料并验证一个完整闭环 - -1. 引入燃料值和燃烧目标/灰烬数量的类型化值对象,由 02 的声明持有;取值缺失代表不是燃料。 -2. `GTMaterial` 的旧燃料 getter/setter 在过渡期只读写该属性,不能保留一组独立旧字段。 -3. 迁移 `FuelRecipeLoader`、`FurnaceFuelValue`、`FurnaceFuelHelper` 等消费者;真实游戏类留 Minecraft 层,燃料量计算留纯规则。 -4. 扩展已有 `FuelParityTest`:保留 Lignite、Peat、Charcoal 回归,核对 WoodRubber、Bamboo、Livingwood、Dreamwood、Greatwood、Silverwood 的热值与灰烬。无来源证据的条目保持待核对。 -5. 多组件燃料的燃料值与灰烬从同一完整组件集合计算;先核对输出能力与 GT6 规则,单槽不足时明确拒绝、批处理或既定副产物处理,不能任取第一组件作为通用答案。 - -本步验收通过后才复制模式到其他属性,避免未验证的抽象扩散。 - -### 3. 逐域迁移属性与 flag - -1. 对矿石、工具等实际需要组合字段的域建立小型不可变属性对象;简单布尔能力放 flag,不为每个标量建立无消费者的类型。 -2. 若使用 `PropertyKey`,读取 API 必须保持类型匹配,不能让调用者任意强转 `Map`;属性对象不能反向依赖 core 或游戏实现类型。 -3. 梳理 flag 的依赖:可补全的布尔依赖做确定性的闭包;需要数值属性的依赖缺失则报错,不凭空生成工具强度或流体转换率。 -4. 检测依赖环、重复冲突属性和链接后非法修改;最终校验时机应覆盖合法附属声明与链接回调之后的状态。 -5. 逐域迁移 getter/setter 和消费者,再删除旧字段。旧 `MaterialProperty` 在调用方迁完前只作为映射门面,其值不能与新 flag 成为两个可独立修改的集合。 -6. 核对 Phosphor 的 MELTING,变更依据与配方/坩埚行为单独记录;不能把属性迁移与无依据的行为更改混成一项。 - -### 4. 统一形态可生成性与数量 - -1. 从 `engine.material.MaterialItemDefinitions.candidatePrefixes()` 及方块注册入口追踪实际候选、过滤和最终注册,不按 prefix 声明总数推断生成数量。 -2. 保留物品 prefix 与方块 prefix 必需的不同元数据,共用稳定形态身份、材料量和可生成性规则;无需为了“一张表”强迫两者变成同一个类。 -3. 将 `MaterialForms` 的有效规则并入规范声明,删除 ID/名称双轨查询。显式强制形态、附属 prefix、polymer/wire 请求与历史例外均作为可定位规则。 -4. prefix 继续决定默认材料量、图标与显示类别;复合工具头、弹药等实际成分由 04 的权威成分记录决定,不能被默认重量替代。 -5. 形态注册与配方生成共用“此形态是否实际存在”的查询;缺失形态不生成悬空配方。遍历顺序固定,但不构造全部材料×形态的常驻笛卡尔积。 -6. `MaterialPrefixes` 没有 delegate 的名称先分类为外部兼容身份、纯元数据或死条目;只有 07 确认无消费与兼容需求后才能删除。 - -## 独立验证 - -检查集:D、F、J、C、G;API 类型或契约改变加 A,资源或新生成物改变加 B。 - -| 验证域 | 必须通过的断言 | -| --- | --- | -| 属性值 | 无属性、零值、非零值、非法负值分别处理;旧访问器与新属性读取结果一致 | -| flag | 闭包不依赖声明顺序;环/缺必需属性失败;不能产生无数据的加工能力 | -| 燃料 | 固体燃料权威案例保持;多组件输入的热值与灰烬使用同一数量口径 | -| 形态 | 普通金属、石英族、Paper、多组锭/板、显式强制形态和附属请求符合对照 | -| 数量 | 物品与方块重量单位不变;复合形态总量由实际组成而非首材料推算 | -| 游戏生成 | 两节点最终物品/方块身份、可查询形态配方一致;缺形态的负例不生成配方 | - -为代表材料保留具体形态列表,避免只比较全局数量。补一个缺属性的 flag 和一个无效目标形态作为负例,确认诊断能定位材料、属性/prefix 与来源。 - -## 完成与拆分 - -建议按“燃料完整闭环 → 矿石/工具域 → 热学与组成域 → flag → 形态查询”交付。每个域完成时必须删掉原来的独立存储,再进入下一域。 - -阶段完成条件:已迁移属性唯一存储;形态生成和消费者使用同一规则;旧表只剩有明确迁移归属的部分;01 对照差异可解释。公开 API 迁移另列影响,不能因 `GTMaterial` 标记为 Internal 就省略产物契约检查。 - -## 实施结果(2026-11-08) - -- `GTMaterial` 不再保存组成、工具、燃料、矿石副产物、加工目标或倍率字段;这些辅助事实只存于 `MaterialInfoRegistry` 的每材料可变条目,并在定义、附属链接和最终角色处理结束后一次冻结。旧访问器保留签名,只通过现有 `MaterialInfoTool.Host` 读写同一状态;组成中的坩埚权限也已并入组成值,不再另存一份。 -- `FuelRule` 是燃料值与残留的唯一类型化声明。完整组件燃料计划从同一组件集合汇总热值和灰烬;同种灰烬合并,不同灰烬或超过单槽容量的结果拒绝燃烧,不再取首组件或截断。按固定 GT6 提交 `3703e403` 修正 WoodRubber、Bamboo、Livingwood、Dreamwood、Greatwood、Silverwood 的热值和灰烬;补 Bentonite 的 18 份 `SodiumHydroxide + 18U Clay` 组成,并按同源删除 Phosphor 的额外 `MELTING`。 -- 布尔 flag 使用统一、与声明顺序无关的闭包:气体同时为液体,离心/电解权限包含 `DECOMPOSABLE`;`FLAMMABLE` 与 `UNBURNABLE` 冲突失败。附属离心/电解声明没有组成时在 READY 前失败,内置遗留组成的数据迁移仍由 06 负责。 -- 流体 phase 修正已直接写回对应 catalog 声明,不再使用 catalog 外的按材料名二次覆盖表。 -- API 1.7 引入的 typed `MaterialFormRulesView.rules()` 统一投影 item、block、fluid 定义期规则,`MaterialFormRule` 携带种类、默认材料量和显式请求来源;旧的 `forms()`/`allows()` 明确只表示 item 形态。配置了不存在的 process form 会在 READY 前失败。`MaterialFormsView` 在平台注册完成后发布 item、block、fluid 及 `ItemMaterialRegistry` 显式统一物品的实际绑定;binding 出现 kind 冲突时拒绝发布,规则允许与真实注册仍保持为不同事实。 -- `MaterialForms` 改为从规范辅助快照读取,不再维护 ID/名称双轨查询。`MaterialGroups.members/contains` 通过 `MaterialTagsView` 读取组关系,现有 `Any*` 配方、tag、工具和终局材料 consumer 已改为读取该视图;旧符号只保留兼容入口。 -- 常见 form 的 tag 映射继续集中在 `MaterialEquivalence`;`CraftingMaterialForms` 已删除第二份映射并复用该入口。更广的配方/世界生成 tag 仍归原领域,外部 tag 候选裁决留给 04。 -- 补测覆盖 Paper 的全部源表多组板、NetherQuartz 的宝石/宝石板/棒、Iron 的物品/方块重量分离,以及 Tantalum 的强制宝石规则。发布期 form 读取改为使用已冻结的辅助快照,避免定义期视图漏掉源表形态。 -- 检查结果:API 105 个 JUnit、core 131 个 JUnit、API 契约、本轮修改文件 Spotless、双平台生产编译与测试源码编译通过;Forge 1.20.1 和 NeoForge 1.21.1 各在全新目录实际执行 69 个 GameTest 并全部通过。生产资源和发行产物未改变,因此本阶段未执行 B;客户端手工场景不属于本页完成条件,未执行 M。 diff --git a/docs/development/material-system-refactor/04-item-composition.md b/docs/development/material-system-refactor/04-item-composition.md deleted file mode 100644 index 66243b089..000000000 --- a/docs/development/material-system-refactor/04-item-composition.md +++ /dev/null @@ -1,139 +0,0 @@ -# 04:统一物品成分解析 - -本计划让同一物品在生成、查询、回收和展示中得到同一份有来源的成分结果。状态:已实施本页范围;前置 [01](01-baseline.md) 与 [02](02-material-registration.md) 已完成。实现与检查结论见[04 验收记录](../../integration/material-refactor-04-composition.md)。 - -资源 tag 的导入/导出与别名桥接按 [08-C](08-material-data-api.md#c形态视图与资源-tag-桥接) 接线;导入只提交低优先级成分候选,不能把分类、资源 tag 成员关系或“含某材料”直接当作形态等价和回收授权。成分快照参与 08-D 的同版本内容发布。 - -## 当前问题与范围 - -core 的 `engine.material.ItemComposition` 将 prefix、组件、自由文本 source 和 `recoverable` 放在一起;Minecraft 的 `ItemMaterialRegistry.register()` 直接覆盖。`entries()` 只含显式项,`base()` 还查询标签派生,`get()` 再按耐久缩放。`MaterialEquivalence.form()` 对 `MaterialFormItem` 提前返回,使复合物品可能被当作纯材料形态。 - -本阶段统一成分的选择和解释,05 再统一机器回收生成。材料自身的化学组成仍由材料目录管理;物品成分只是“这个物品包含多少哪些材料”。 - -## 实施步骤 - -### 1. 把来源与优先级变成规则 - -1. 候选记录带结构化来源:来源类别、声明 ID/生产端、必要的 GT6 提交或项目规则标识;自由文本只保留说明用途。 -2. 初始优先级采用下表,且对整个成分记录裁决,不把高优先级的组件与低优先级授权无意拼接。 - -| 顺序 | 候选来源 | 适用方式 | -| --- | --- | --- | -| 1 | 显式物品定义、人工审核的现代修正、JSON 成分 | 共同进入显式层;有意覆盖必须指明被替代声明,不依赖加载先后 | -| 2 | 原版/外部物品统一化目标 | 显式层缺失时采用 | -| 3 | 材料形态标签派生 | 前两层缺失时采用;同物品多个不一致标签为冲突 | -| 4 | CR.REV 配方反推 | 仅兜底,注明派生来源,拒绝矛盾与不可确定的循环 | - -3. 同优先级语义相同的候选合并来源;不一致时失败并指出两个声明。显式覆盖必须唯一,检查目标存在及覆盖链无环。 -4. 优先级较低的候选不覆盖较高候选;不同授权也属于冲突语义,不把 `true` 默认当作更可信。 -5. 明确组件集合顺序与主材料是两件事:纯形态要求单一完整材料;确需主材料的显示/工具身份使用显式字段,不再把首组件当通用答案。 - -交付:可在 core JUnit 中测试的候选归一化与冲突裁决;不依赖 `Item`,使用稳定物品键或外层映射。 - -### 2. 收拢生产端并发布一致视图 - -1. 将 JSON、统一化、修正、方块重量、构造器自注册、标签派生和 CR.REV 的写入改为提交候选;逐个生产端撤掉直接 `put`。 -2. JSON 显式给出 prefix,或用结构化声明指定继承的统一化目标;不从“之前碰巧注册的记录”读取 prefix。缺少明确继承目标时报错。 -3. 解析后发布不可变的有效成分快照,按物品稳定 ID 遍历。批量生成与 `base()` 查询使用同一快照;`explicit()` 如保留,明确仅用于诊断和来源查询。 -4. 标签加载和配方反推结束后再发布需要它们的快照。所有派生项有归属和 revision,重载先构建新结果、校验成功再替换,不能累积旧标签候选。 -5. 若派生链需多轮求解,规定有限收敛过程和环检测;不能因遍历顺序不同给出不同结果。组件按来源语义确定,不能从回收配方反推原物品成分形成循环。 -6. 保留“未加载标签”和“该物品无成分”的区别;初始化阶段消费者不得把临时缺失永久缓存。 - -### 3. 独立表达成分与加工准入 - -1. GT6 没有物品级批量回收授权标志。是否存在成分、是否满足某热工艺、具体形态与栈状态是否进入回收行分别判定;legacy `recoverable` 仅保留为兼容输入。 -2. 现有 JSON 键若保持不变,解析时映射到内部语义;若确需改名,提供旧键兼容读取与双键冲突检查,并写明迁移,不静默改变格式。 -3. 栈状态检查统一处理耐久、内容物和实体/流体容器;区分模具形状等纯状态与真实库存,不把所有 NBT/数据组件都视为“含内容物”。基础成分快照不缓存 `ItemStack`,状态缩放在查询时完成。 -4. 损坏比例采用经裁决的整数算法,验证乘法溢出与向下取整。Shredder 从缩放后的成分生成实际输出,不能让静态满额假设直接消费已缩量的物品。 -5. `MaterialEquivalence`、库存形态识别和 tooltip 从有效记录读取;物品实例的 prefix/material 可作为身份信息,但不能覆盖实际复合成分。 -6. `OvenRecipeBridge` 区分“成分可查询”和“应该按材料规则改写熔炼”;描述性成分不能自动授权删除原版配方。 - -### 4. 合并双平台成分安装 - -1. 以 `GregTechNeoForge.finishSharedSetup()` 中的 `registerBlockCompositions()` 与 Forge 的 `MaterialLinkBootstrap`、材料注册入口为对照,列出缺失的方块/植物成分。 -2. 将纯粹的物品/方块成分提交步骤放共享 Minecraft 入口,平台层只负责在对象可解析后调用;不移动所有注册家族或任意改变整个初始化顺序。 -3. 铜块覆盖、Glowtus/BedrockFlowers、普通材料块与石材/半砖逐项裁决。共同存在的物品必须一致,版本独有物品按明确存在条件处理。 - -## 独立验证 - -检查集:D、F、J、C、G;JSON 或成分资源改变加 B,公开契约改变加 A。 - -| 场景 | 通过条件 | -| --- | --- | -| 顺序独立 | 打乱同一组候选提交顺序,有效结果与诊断一致 | -| 冲突 | 同级不同组件/授权失败;显式覆盖唯一且可追踪;同义候选可合并 | -| 查询一致 | 任一有效物品都能从遍历视图与单物品查询取得同一基础成分,含标签派生 | -| 完整组成 | 复合工具头中的 Steel 不丢失;等价形态识别不把它当纯主材料 | -| JSON | 无效材料、非法量、未知 prefix、缺继承目标、互相矛盾的键均失败 | -| 状态 | 完好、部分损坏、耗尽;空桶、装液桶;空容器、有物品/实体容器分别断言 | -| 重载 | 标签成员变更后,新有效视图替换旧视图,revision 与相关缓存失效;重复同数据重载不增加记录 | -| 双平台 | 相同物品的组件、量、prefix 与授权一致;铜块等已知差异有明确处理依据 | - -纯候选测试不需要游戏;物品身份、标签与组件/NBT 检查必须跑两个节点。重载测试不能只比较 map 大小,还要验证被移出标签的物品失去相应派生行为。 - -## 完成与拆分 - -建议交付:纯裁决规则 → 显式来源迁移 → 标签/CR.REV 与快照 → 查询消费者与状态判定 → 双平台安装。每步保留一个权威解析结果,尚未迁移生产端通过适配提交,不能继续绕开冲突检测。 - -完成条件:所有成分消费者可解释“选中了哪条声明、为什么”;批量生成与运行期视图一致;没有无来源的最后写入者覆盖。05 可以直接消费本阶段结果,不再重新推断物品成分或默认授权。 - -## 实施结果(2026-11-09) - -- 纯规则新增 `ItemCompositionSource`、`ItemCompositionCandidate`、`ItemCompositionResolver` 和 `ItemCompositionScaling`。候选按结构化来源优先级整条裁决;同级相同内容合并来源,不同内容或回收授权失败;显式覆盖必须命中现存声明并拒绝覆盖环。 -- `ItemComposition` 保存显式主材料与结构化来源列表;legacy `bulkRecoveryAllowed` 参数在规范构造时归一为 `true`,兼容访问器只保留源码兼容。回收授权由具体工艺和栈状态决定。组件按“主材料优先、其余材料稳定排序”归一化,因此提交顺序不再改变结果。 -- `ItemMaterialRegistry` 改为显式候选与完整 tag 候选两张输入表,单物品查询和稳定 ID 遍历读取同一有效快照。tag 重载先解析完整替换集,失败时不修改有效结果;只有内容变化才推进 revision。 -- JSON、原版统一化、模组统一化、人工修正、物品/方块构造器、木材和肉类生产端均提交带声明 ID 的候选。木材与肉类定义对 JSON 的既有覆盖改为唯一、可追踪的显式替代,不再依赖加载顺序。 -- `MaterialEquivalence.form()` 只接受单一完整材料形态;复合工具头保留全部组件但不再当作纯主材料。耐久缩放使用无乘法溢出的整除算法。铸模空腔归类为纯形状状态,不再阻止熔化或回收。 -- 成分存在、回收工艺准入和炉规则准入已拆开。JSON 中的描述性成分类别不删除原版熔炼行;原生材料形态、统一化与 tag 规则仍可进入炉策略。`OvenRecipeBridge` 通过 `hasMaterialProcessingRule` 使用这一独立判定。 -- 共享 `MaterialItemCompositions` 负责物品形态、普通材料块、石材/半砖重量、机器构造材料、线缆、木板、运输构件和原版绑定;Forge 与 NeoForge 入口只追加各自实际注册对象可解析的矿石、植物和机器注册表成分。 -- 检查集 D、F、J、C、G、B 已执行:core 与 API JUnit、格式和路由检查通过,两节点生产及测试源码编译通过,`assembleBothPlatforms` 通过;Forge 1.20.1 实际执行 73 个 GameTest 全部通过,NeoForge 1.21.1 实际执行 78 个 GameTest 全部通过。JSON 负例覆盖未知材料、非正数量、未知 prefix、缺失继承目标及互相矛盾的键。当前测试环境未安装能提供外部 common-form tag 的模组,因此真实有效 tag-only 物品由纯候选测试覆盖;两节点实际重载覆盖了 420 个 ore-prefix tag 候选、快照 revision 与重复重载不累积。公开 API 和游戏内展示未改,未执行 A、M。 - -## 审查闭合(2026-11-10) - -本轮审查重新区分了 04 自身欠账与后续阶段:失败重载的原子性、结构化来源、加载顺序、JSON 继承、损坏缩放和成分重载断言都属于本页完成条件;05 的发布原子性只覆盖回收/配方行,07 才负责更广泛的旧 API 和内容退出,不能替代这些 04 修复。 - -- 外部 tag 重载在构建和校验新 generation 前不再清空成分快照;失败发布会保留上一份有效成分,成功发布后才整体替换。回收/配方行的完整事务边界仍由 05 负责。 -- `ItemCompositionCandidate` 移除了未消费的 `itemKey`;legacy 来源构造和注册入口明确标记弃用,结构化入口继续作为迁移目标。`recoverable()` 在后续兼容审查中恢复为弃用转发方法。 -- `ItemCompositionSource.reference` 现在承接旧自由文本来源,并在诊断描述中输出;通过结构化注册入口提交时,原来源会保留为引用,不再只留下生产端名称。 -- 显式覆盖允许在目标声明之前注册,最终由 `ItemMaterialRegistry.validateExplicitSnapshot()` 在全部生产端完成后统一严格校验目标存在;注册顺序不再决定覆盖结果。 -- 木料、肉类和现代修正改用 JSON 数据表本身解析声明 ID,不再查询当时的候选快照。`vanilla_compositions.json` 中 88 个使用 `vanilla-unification` 的条目显式写入 `inherit`;无 `prefix`/`inherit` 的其余条目保持无 prefix,不再隐式借用统一化表。 -- 损坏缩放抽取为 `ItemCompositionScaling.scale(ItemComposition, ...)`;主材料缩为 0 而其他组分仍存在时会移除失效主材料身份,不再触发构造异常。 -- GameTest 增加 tag 冲突发布失败不改旧快照、清空 tag 后派生成分消失的断言;真实重载比较完整有效成分映射,不再只比较条目数。 -- 检查结果:本轮定向 core JUnit、双平台生产与测试源码编译、`assembleBothPlatforms`、路由检查和 ratchet Spotless 通过;Forge 1.20.1 在全新目录执行 74 个 GameTest 全部通过,NeoForge 1.21.1 在全新目录执行 79 个 GameTest 全部通过。未执行客户端 tooltip/JEI/EMI 手工验收。 - -### 第二轮审查闭合 - -- `hasMaterialProcessingRule()` 只读取有效成分快照中的胜出来源;vanilla JSON 仅在其声明显式 `inherit: vanilla-unification` 时授权炉策略,被淘汰的低优先级 tag/统一化候选不再改变结果。 -- Panel 材料改为提交最低优先级的 CR.REV 候选,不再读取当时已经发布的 `base()`。构造家族从同批静态规则或 `OriginalDeviceMaterialData` 推导,木板名称按物种声明稳定映射。 -- `ItemCompositionSource` 保存完整覆盖链;同一同级声明被多个候选覆盖时发布前失败,最终来源可直接说明其覆盖了哪些声明。 -- Forge 与 NeoForge 的 vanilla 材料绑定统一调用共享 `MaterialItemCompositions.registerVanillaBindings()`;NeoForge 重复的基础机器成分提交已删除。 -- 复验通过:完整 `:core:test`、双平台生产与测试源码编译、ratchet Spotless;Forge 1.20.1 GameTest 74/74,NeoForge 1.21.1 GameTest 79/79。 - -### 第三轮审查闭合 - -- 主材料的单一组件推断已移出 `ItemComposition` 规范构造器,只保留在 legacy 构造入口;损坏缩放丢失原主材料时继续使用无效主材料,不再把剩余次要组分提升为新的主材料。 -- `ItemMaterialRegistry` 新增 `CompositionLookupState`,区分有效成分、已完成 generation 的明确缺失和 tag 输入尚未发布;首次成功发布 tag generation 会推进 revision,失败发布不改变 readiness。 -- 定向 core JUnit、双平台生产与测试源码编译通过;Forge 1.20.1 GameTest 75/75,NeoForge 1.21.1 GameTest 80/80。新增 GameTest 验证 tag-only 成分能生成 Shredder 行,撤销 tag 后该行不可查询。 - -### 第四轮审查闭合(2026-11-11) - -- `ItemMaterialRegistry` 在全部显式生产端完成最终覆盖校验后关闭显式层;此后显式注册失败,tag generation 仍可按重载生命周期替换。 -- 新增 `declared()` 有效成分视图,用于需要排除外部 tag 回导的消费端。生产代码不再调用仅供诊断的 `explicit()`;原调用已改为读取 `base()` 或 `declared()`。 -- `RecoveryInputProof` 取代分开的 thermal 输入证明,统一校验物品身份、损坏、内容物、催化剂、容器和空流体处理。 -- Forge 1.20.1 GameTest 77/77、NeoForge 1.21.1 GameTest 82/82;双平台生产与测试源码编译、core JUnit 和 ratchet Spotless 通过。 - -### 第五轮审查闭合(2026-11-11) - -- 外部 tag 导入先收集同一物品的全部可识别形态,再交给 `ItemCompositionResolver` 统一合并或报告冲突;歧义项记录物品 ID 和冲突描述后不进入 generation,形态消费者只读取胜出的有效成分。 -- `ItemMaterialRegistry.entries()` 按现有 composition revision 缓存不可变有序快照;同 revision 重复遍历不再复制和排序全量组件。 -- tag generation 内容或 readiness 变化后直接刷新公开形态绑定,查询路径不需要等待下一次平台启动。 -- Forge 1.20.1 GameTest 78/78、NeoForge 1.21.1 GameTest 83/83;双平台生产与测试源码编译通过。 - -### 第六轮审查闭合(2026-11-12) - -- 冲突契约采用受控来源类别:同一优先级内容一致才合并,不同内容继续失败;显式覆盖继续要求命名现存声明并保留完整覆盖链。`ItemCompositionSource.fromLegacy()` 不再分析自由文本,旧来源统一归入 `LEGACY`。 -- 方块重量、CR.REV、机器构造、运输构件、木材、书本、木桶和铁栏杆等内置生产端改为提交结构化来源;`registerDeclared()` 用于接收已有单一结构化来源的候选,弃用的双参数注册入口只服务旧附属。 -- `ItemCompositionResolver.resolveDetailed()` 保留胜出、被覆盖和低优先级候选及原因;`ItemMaterialRegistry.compositionDiagnosis()` 暴露与有效成分同一 generation 的完整裁决记录。 -- 弃用双参数注册保留同一物品重复旧调用的最后写入语义,避免旧附属因重复声明 ID 无法启动;结构化候选之间仍禁止无声覆盖。legacy 多组件构造恢复历史首组件主材料与数量,`recoverable()` 以弃用别名保留。 -- API 保持 `1.8.0`,发布坐标为 `gregtech:gt6ce-api:1.8.0`;本分支累计包含 1.4—1.8 的材料 API 能力,不需另改 groupId 或 artifactId。 -- 复验通过:`:api:check`、`:core:test`、双平台生产与测试源码编译、ratchet Spotless、路由和注释检查;Forge 1.20.1 GameTest 90/90,NeoForge 1.21.1 GameTest 95/95。首轮 Forge 运行发现 CR.REV 单组件被错误改为无主材料,导致 Stone 铸模失去 45U 数量;兼容推断恢复后全量运行通过。 diff --git a/docs/development/material-system-refactor/05-recovery.md b/docs/development/material-system-refactor/05-recovery.md deleted file mode 100644 index a8d063504..000000000 --- a/docs/development/material-system-refactor/05-recovery.md +++ /dev/null @@ -1,121 +0,0 @@ -# 05:统一回收计算与生成 - -本计划把粉碎、砧、热回收和坩埚所需的共同判定与数量计算收敛,保留各机器的真实工艺限制。状态:已实施本页生产侧范围;前置 [02](02-material-registration.md)、[03](03-properties-and-forms.md)、[04](04-item-composition.md) 已完成。验收与剩余边界见[05 验收记录](../../integration/material-refactor-05-recovery.md)。 - -生成与运行期能力确定后,向 [08-D](08-material-data-api.md#d来源与用途索引快照发布) 发布同源关系投影,包括输入状态限制、数量、主/副产物角色及覆盖程度;来源索引不从成分再次计算回收。unit 与动态规则优先投影符号族,不为绘图重新物化所有物理配方。 - -## 当前入口与目标 - -实际生产端包括 `VanillaRecoveryRecipes`、`ShredderRecyclingRecipes`、`AnvilShreddingRecipes`、`SharedThermalRecyclingRows`、`SharedThermalInputRows`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader`、`SourceDustThermalRecipes`、`ExternalOreProcessing`、`StoneVariantRecipes`、`CapsuleCellRecipes` 等。清理和重载还涉及 `MachineRecipeLifecycle`、`MachineRecipeOverlay`、`ExternalOreRecipeLifecycle`、`MoltenMetalUnitRecipes`。 - -目标数据流是“有效成分+栈状态+指定工艺 → 回收计划 → 原生配方或运行期处理”。计划包含输入基准量、完整输出量、耗时/能量、输入限制以及不能执行的原因;计算规则不持有 `ItemStack`,游戏层负责绑定物品、流体与机器槽。 - -## 实施步骤 - -### 1. 建立输入判定与结果模型 - -1. 使用 04 的统一成分和状态判断,分别查询是否有成分、具体回收工艺与形态是否接受、该热工艺是否可处理;不把物品级兼容字段或 `canMelt()` 当作所有回收机器的通行证。 -2. 输入状态包括耐久、带内容物容器、填充桶及其他已核对的阻止条件;静态配方的匹配约束必须与其满额产物假设一致。 -3. 输出分成可执行计划、明确无该工艺、因必要绑定缺失而无法解析。后者必须可定位,不再用静默 `null` 混同“设计上不能回收”。 -4. 附属材料按声明能力和实际绑定参与,不以“非 core”直接否定;缺少相态或产物形态时说明原因,不能给未知材料套上原版默认。 - -交付:纯规则与少量原生绑定适配;没有机器配方注册副作用的计算可单独测试。 - -### 2. 解决数量表达与守恒 - -1. 移除 `MaterialRecoveryRules.pile()` 对 64 的无条件截断,先按材料量计算,再选择可表示的输出形态与批量。 -2. 对 72U 等大数量,优先用已有大形态或等比例批处理;只有机器支持时才拆成多个合法栈。不能生成超过输出槽、最大栈或整型范围的非法配方。 -3. 无法精确表示时明确记录量化余量、工艺允许损耗或拒绝原因。GT6 已规定的取整和损耗保留,不要求任意数量都无损,也不能把 64 截断伪装成既定损耗。 -4. 所有组件都进入计算;加工目标转换、相态转换和灰烬/副产物有各自换算依据。使用有界且可检查的整数计算,验证溢出与上下取整。 -5. `raw_*` 过滤改成明确的矿石/原矿类别规则,分别裁决 raw metal item 与 raw metal block;不能仅删字符串条件就把已有独立矿石工艺重复注册。 - -### 3. 逐工艺替换生产端 - -1. 先迁普通单材料物品的 Shredder,验证查找和输出;再迁复合物品与 Anvil,处理 `rockGt` 等重复归属。 -2. 再迁 Smelter/Melter 的热回收,输入成分、相态和工艺限制共用计算。`phases.size() != 1` 等限制先核对固定 GT6 与槽位能力;按规定拒绝或选择产物,不自动放开全部多组件输入。 -3. 坩埚共用成分解析与数量转换;保留其运行时温度、反应、燃烧和容器规则。它未必适合物化静态配方,不强行套入批量 recipe 表。 -4. 特殊矿物、石材、单元/胶囊等生产端逐族声明归属;工艺确有差异的 handler 保留,成分与授权判定移除重复实现。 -5. 每迁一族即关闭该族旧写入;测试可以对照旧计划,生产不能同时发布新旧两套等待 collision 丢弃。 - -### 4. 统一发布、冲突与重载 - -1. 为通用回收与显式专用配方建立归属表。相同语义的重复候选去重;不同输出的冲突报错;特定配方覆盖通用回收必须有显式规则与理由。 -2. 冲突比较覆盖真实匹配语义:标签重叠、材料等价、催化剂、状态限制和 unit 输入,不能只比较配方 ID。 -3. 与现有 `RecipeMap` 注册、overlay、baseline 恢复、unit 折叠接线;共享冲突策略不要求重写整个配方引擎。 -4. 每个快照 revision 对某工艺只生成一批;重载移除该提供者拥有的旧行后发布新行,保留无关手写配方及数据包覆盖。 -5. 避免中途暴露半套结果:在现有服务端重载生命周期允许的边界校验并替换;失败时沿用当前框架定义的失败处理,不额外引入吞异常降级。 -6. 诊断区分候选数、明确不支持数、不可解析数、重复合并数、冲突数、物理行数、unit 吸收数。最终是否可用通过实际查询验证,不能用候选数减去几个计数代替查询覆盖。 - -## 独立验证 - -检查集:D、F、J、C、G;资源改变加 B;公开契约改变加 A。 - -| 样例 | 核心断言 | -| --- | --- | -| 普通铁物品 | 成分量、加工目标、最终回收量、时长/能量符合依据 | -| 附魔金苹果、末影箱 | 在其获准工艺中检查 72U 是否完整表达或明确拒绝,不静默变 64U | -| 原铜/金/铁块 | 与原矿物品分别查找,工艺归属唯一,不被 `raw_` 名称误排除 | -| 复合工具头 | 每个组件参与;不把整件物品按首材料回收 | -| 损坏物品、容器 | 损坏 Shredder 输入按剩余成分重建实际输出;装内容物的容器不被当空壳消耗 | -| 已凿铸模、压模机模具 | 形状元数据与库存分开;按已裁决工艺进入回收,材料量正确,不因纯形状状态误拒绝 | -| 多组件热输入 | 一种可热处理与一种被工艺限制拒绝的样例,原因和输出明确 | -| 附属材料 | 具备声明和绑定可参与;缺绑定返回可定位结果,不悄悄继承 core 数据 | -| 重复与重载 | `rockGt` 只有一个有效拥有者;重载两次无累积,移除标签成员会撤掉旧回收行为 | - -JUnit 验证计算边界;GameTest 要通过最终 `RecipeMap`/运行期入口查找,并至少选一条批量机器配方执行消耗与产出。坩埚样例验证真实输入接纳和材料入池;带内容物拒绝时输入保持原样。 - -## 完成与拆分 - -建议按“输入/计划模型 → 数量表达 → Shredder/Anvil → 热回收/坩埚 → 特殊族 → 重载与统计”交付。每个小变更只迁一组明确归属,余下生产端列在迁移清单中。 - -完成条件:所有已迁移工艺只消费权威成分;运行期匹配与生成时假设一致;未知冲突为零;缺配方均能区分设计拒绝和数据缺失;全链路代表例在两个节点通过。06 的离心/电解分解仍保留独立的化学配比与工艺职责。 - -## 实施结果(2026-11-10) - -- `MaterialRecoveryRules` 现在从有效 `ItemComposition` 生成 Shredder 计划;每个组件的粉碎目标和数量都进入计划,缺失目标、无法表示的数量、输出槽不足和整数溢出分别报告。72U 变为按 64 上限分组的合法栈,不再保留 64U 截断。 -- 运行期回收准入拆成 `ItemMaterialRegistry.RecoveryRejection`:无成分、空成分、内容物容器和不支持容器可分别诊断。GT6 没有物品级授权门槛;损坏 Shredder 输入按剩余成分缩放,其他固定输出热行继续由各自 `RecoveryInputProof` 保护其满额假设。 -- `ShredderRecyclingRecipes` 的物品形态直接遍历有效成分快照,复合工具头的每个有效组分进入计划;平台方块形态仍通过实际 block delegate 解析物品身份,但成分、授权和输出重新读取同一有效快照,不另算一部组分量。`VanillaRecoveryRecipes`、Anvil、胶囊和石材生产端同样以有效成分为输入,`rockGt` 的普通轮次由 `StoneAndToolSurvivalRecipes` 唯一拥有。 -- 原矿类别由 `VanillaUnificationDefinitions.OreInputKind` 明确区分 ore、raw metal item 和 raw metal block;通用 Vanilla 回收不再依赖 path 的 `raw_` 字符串截断。 -- 热回收候选直接读取有效物品快照,移除了方块与石材重算的重复成分来源;输入行在发布前先构建完整候选集,失败时清理 owned rows,已有重载 generation 继续负责整批替换。 -- 本次没有新增公开 API。现有 `MaterialUnitRecipe`、`ItemComposition`、`RecipeMap` overlay/owned-row 生命周期和热回收纯规则继续承担发布与重载,只新增内部计划与拒绝类型。 -- 08-D 的配方来源/用途投影仍需在 08 阶段按最终 `RecipeMap` 快照发布;本页只提供可投影的输入限制、数量、输出角色和诊断结果,不另建来源表。 - -## 审查闭合(2026-11-10) - -- Shredder 的显式启动行留在静态 baseline;最终来源为 `FORM_TAG` 的行改由 `rebuildTagRows()`/`clearTagRows()` 管理,并接入 `MachineRecipeOverlay`。tag-only 成分加入或移除时会创建/撤回对应配方及动态索引。 -- Shredder duration 直接使用 `MaterialRecoveryRules.planShredder()` 的结果,不再按主材料重算。实际方块形态继续由 block-prefix 解析,但过滤掉 `GTBlocks` 返回的非方块回退项。 -- 通用 Shredder 行写入 `recovery:shredder-generic` 来源标记;同条件不同输出的通用行会报冲突,具体配方仍可显式拥有同一输入。 -- 新增 GameTest 验证 tag-only Shredder 行加入、撤销及重载 owned row 稳定。Forge 1.20.1 GameTest 75/75,NeoForge 1.21.1 GameTest 80/80;双平台生产与测试源码编译通过。 - -## 第二轮审查闭合(2026-11-11) - -- 新增 `ThermalRecoveryOwnership`,审核输入行、特殊审核行和通用热回收行共用一个所有权判断;附属材料由通用声明路径处理,不再因“非 core”被拒绝。 -- 附属材料使用已发布的 `SMELTING` 目标、唯一流体绑定和标准 `SOURCE_UNIT` 比例生成 Melter/Smelter 行;1U 流体按绑定比例输出,缺失或歧义相态进入明确诊断。 -- 删除分开的 thermal 输入证明,统一使用 `RecoveryInputProof`,覆盖损坏、内容物、催化剂、容器和空流体限制。 -- 新增 `RecoveryRecipeConflicts`:通用行之间相同输出去重、不同输出失败;专用行可显式替换通用行;通用行遇到专用所有者时让位。Shredder、Vanilla、Anvil、热输入、热回收、胶囊和石材生产端共用该规则。 -- Forge 1.20.1 GameTest 77/77、NeoForge 1.21.1 GameTest 82/82。新增测试覆盖附属热回收 144 mB/U、generic/specific 冲突和显式注册关闭。 - -## 第三轮审查闭合(2026-11-11) - -- Shredder 的静态与动态材料规则使用运行时解析器;损坏栈在查询时从剩余成分重算输出和时长,guard 固定预期耐久并重新检查准入,完整物品生成时的输出假设不会扩用到缩量状态。 -- Shredder 在发布前按注册 ID 和规范化输入检查静态拥有者,并在发布后复核经 `RecipeMap` 规范化得到的真实输入;同输出 owner 仅保留一个,同时移除对应动态索引。 -- 审计探针在 Forge 和 NeoForge 上均只看到 `recovery:vanilla-generic` 一条铁锭通用回收行;tag-only 动态行、撤销和绑定刷新仍通过。 -- Forge 1.20.1 GameTest 78/78、NeoForge 1.21.1 GameTest 83/83。 - -## PR #374 步骤三闭合(2026-11-12) - -- `MaterialRecoveryRules.dustPlan()` 是完整粉尘输出与余量的权威计算;`dustSlotPlan()` 保留源 `OM.dust()` 的单栈选择规则,并单独报告该栈未表示的余量。`OM.dust()` 返回该兼容单栈,`OM.dustAll()` 返回完整栈列表。能够容纳多输出的分解、零件余料、流化床和外部矿石入口改用完整列表;Dust Funnel 按计划实际表示的 U 数扣减库存。 -- `CapsuleCellRecipes.registerRecycling()` 改用 `planShredderStatic()`,输出形态和时长与静态 Shredder 生产端共用同一计划,不再内联胶囊专用时长公式。 -- 朱砂 9114 的专用 Melter/Smelter 行和块级输入证明已删除,不再绕过常规 `MELTING` 与相态绑定;`bulkRecoveryAllowed` 只作为 legacy 兼容输入归一保留。 -- common form tag 补齐齿轮、小齿轮、环、螺栓、螺丝和箔;`storage_blocks` 与 `cables` 在没有一对 `MaterialPrefix` 身份时直接生成 9U/1/2U 成分候选。 -- `RecoveryRecipePublisher` 取代仅供冲突仲裁的 `RecoveryRecipeConflicts`,作为 Shredder、Anvil 和热回收生产端的统一发布入口。配方族、显式专用行和通用回退行按 typed ownership 区分,不再从 `mSource` 后缀推断。 -- guarded row 的冲突查询复用 `RecipeMap.mRecipeItemMap` 输入索引,只检查候选物品可达的既有行,不再每次发布扫描整张配方表。 -- `RecoveryFormCatalog` 集中维护 Shredder 生成子集、热回收完整 `RECYCLABLE` 集、dirty ore 排除和容器形态,Shredder 与热回收不再各自维护并行的准入表。 -- Forge 1.20.1 GameTest 90/90、NeoForge 1.21.1 GameTest 95/95;新增用例验证 72U 的完整/单栈投影、胶囊行使用共享静态计划和 typed ownership。 - -## PR #374 复核补正(2026-11-12) - -- `SourceDustThermalRecipes`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader` 与 `VanillaStoneMachineRecipes` 遗留的 Melter/Smelter/石质 Shredder 直写全部改经 `RecoveryRecipePublisher`。审核、native 和石材分支使用 explicit ownership,兼容回退使用 generic ownership,不再绕过 typed family 冲突处理。 -- `ItemMaterialRegistry.beginTagGeneration()` 返回上一代检查点;`MachineRecipeOverlay` 失败恢复时回滚标签候选、有效成分、诊断、readiness、tag generation 与 composition revision。上一份 `MaterialPublication` stamp 保持不变。 -- `ThermalRecoveryOwnership` 删除 9114/`Cinnabar` 及其 dust/crushed 前缀硬编码,只保留已审核的 Ti/Fe 粉尘分数组所有者。GameTest 同时覆盖失败代回滚与朱砂普通所有权。 -- 验证通过:双平台生产与测试源码编译、`:minecraft:spotlessCheck`、Forge 1.20.1 GameTest 92/92、NeoForge 1.21.1 GameTest 97/97。 diff --git a/docs/development/material-system-refactor/06-decomposition.md b/docs/development/material-system-refactor/06-decomposition.md deleted file mode 100644 index 3cf685ffc..000000000 --- a/docs/development/material-system-refactor/06-decomposition.md +++ /dev/null @@ -1,106 +0,0 @@ -# 06:统一材料分解 - -本计划让离心/电解分解的权限、化学组成、输入相态和数量换算来自同一个材料定义上下文。状态:已实施;前置为 [02](02-material-registration.md)、[03](03-properties-and-forms.md)、[04](04-item-composition.md),并复用 [05](05-recovery.md) 的发布、冲突和诊断约定。实施与验收记录见[材料重构 06:统一分解验收](../../integration/material-refactor-06-decomposition.md)。 - -与 [08-D](08-material-data-api.md#d来源与用途索引快照发布) 共用有效分解结果:保留全部输入、产物、选择器角色、相态与单位。材料有化学组成不等于已存在可执行分解来源,图查询不能绕过本计划的工艺权限。 - -## 当前入口与目标 - -- `content.material.catalog.*` 中的 `MaterialDefinition.Composition`:规范化学组成与 divider。 -- `content.material.catalog.DecompositionMaterials`:分解路线、各材料的液体/气体绑定及 `sourceUnits → mB` 换算的唯一内容声明;`MaterialDefinitions` 将其作为现有 `MaterialProcessKeys.DECOMPOSITION` 宿主 process 的 `MaterialDecompositionRule` 关联到规范声明。 -- typed rule 是已知分解路线的唯一运行时权威;`DECOMPOSABLE`、`CENTRIFUGE`、`ELECTROLYSER` 只在安装完成后作为 `GTMaterial` 的兼容镜像,不再出现在规范材料的固有属性中。旧附属 feature/flag 仅在附属没有 typed rule 时生成一次兼容规则,不能与显式规则求并集。 -- core `engine.recipe.UnitConversion`、`engine.recipe.MaterialDecompositionPlanner`:共享单位换算与纯计划计算,包括权限、组成、相态候选、批量、EUt、时长、产物顺序和槽位截尾。 -- Minecraft `content.recipe.DecompositionNativeAdapter`、`DecompositionRecipeLoader`:解析已注册物品/流体身份,将计划投影并发布为离心/电解配方。 - -目标是一个材料分解声明配合共享计算器:声明决定允许的 map、组成与相态绑定;计算器产生有单位的计划;游戏适配器只解析已注册形态和流体并发布配方。物品回收不等于材料化学分解,两者共用底层事实,不共用一个不区分工艺的授权开关。 - -## 实施步骤 - -### 1. 合并权限与声明归属 - -1. 把每个活动材料的分解权限、输入相态和固体兜底条件挂到 02 的规范声明;组成与 divider 直接引用同一材料定义。 -2. `DECOMPOSABLE` 与具体 map 权限不能互相猜测;成分里有金属、气体或某元素都不自动推导“可离心/电解”。 -3. 每个绑定写清单位基准、流体身份与参考材料量;不能只存一个模糊的 mB 值,再由各加载器猜 144 或 1000。 -4. 已停注的数据不进入运行分解集。液体/气体绑定是可独立尝试的替代输入,未注册项应逐项诊断后跳过;缺少可表示输入或任一必要输出绑定时不发布截断配方。保留明确无分解能力的材料,不把“无配方”都视为缺陷。 -5. 与已有 parity 对齐:钼钙矿、钼铅矿的分解 map 已有项目决策,不能为追求 GT6 表面一致恢复成离心;矿石加工的离心步骤仍独立。 - -交付:同一材料的分解事实可一次读取;旧表暂存的部分有单一字段所有者,不重复决定权限。 - -### 2. 抽出纯计划计算 - -1. 复用并收敛 `UnitConversion` 中整数换算;其他兼容类只允许引用同一常量并转发算法,不再保存独立数字副本。 -2. 以显式 divider 与组成量计算输入批量,保留必要的公因数约简;区分来源基准单位与当前 `GTValues.U`。 -3. 明确每个绑定的输入向上取整、输出向下取整、不可表示和溢出处理;在最终缩窄到 int 前校验范围。 -4. 固体产物的 pulver 目标、液体/气体/熔融态选择、温度条件和有语义的输出顺序逐项来自已核对规则;不能因统一模型把“一跳目标”递归化。 -5. 槽位上限、输出顺序和截尾先按 GT6 与 parity 确认,再作为 map 能力参数传入。现有分解器按 map 数组长度截尾可能是原版工艺,不得与 05 的 64 栈截断混为同一种缺陷。 -6. 计算器返回明确的可执行/无工艺/绑定缺失/范围不合法结果。表示不了的产物不能转成空输出后继续生成一条表面有效配方。 - -### 3. 迁移原生绑定与输入选择 - -1. 游戏层按声明解析流体和物品,保留实际注册身份,明确 dedicated liquid、gas、molten 与原版 Water 的绑定关系。 -2. 保留液体与气体输入独立尝试的规则;接受流体后是否保留固体 fallback 由声明决定,Glowstone 作为明确案例。 -3. 固体粉末与 blockDust 按实际形态存在性生成;只有 divider 能表示对应块量时才生成块输入,不强制为所有材料创建 dust。 -4. 附属材料使用其声明与实际注册绑定;保留所有权和冲突校验。缺证据时明确拒绝该候选,不把附属存在变成全局禁用原版数据路径的理由。 -5. 电解机选择器按现有规则作为存在性催化输入,放在约简正确的位置;不能被数量约简消掉或运行时消耗。 - -### 4. 切换生成与删除旧权威 - -1. `DecompositionRecipeLoader` 改成遍历规范定义、调用计划器、解析与发布;不再分别猜属性、相态和成分是否同步。 -2. 候选冲突由 05 的发布约定处理,专用分解规则有显式归属,不依赖注册先后。 -3. 逐批删除 `MaterialDecompositionData` 与 `SourceDecompositionData` 中已迁移的重复字段;可复用数学工具保留。旧名字不作为必须删除的理由,删除依据是事实或功能已经被替代。 -4. 接入机器配方重载:分解行作为 overlay-owned rows 每代撤下并重建,连续重载不得累积;保持无关化学配方与矿石流程不变。 - -## 独立验证 - -检查集:D、F、J、C、G;公开声明改变加 A,资源改变加 B。 - -| 案例 | 必须验证的内容 | -| --- | --- | -| 纯固体化合物 | divider、输入批量、固体输出和 map 权限 | -| 液体/气体输入 | 144 与 1000 等声明转换率独立生效,不按材料名猜量 | -| Glowstone | 液/气输入及保留固体 fallback 符合权威规则 | -| 钼钙矿/钼铅矿 | 电解模式 0、产物量、存在性选择器;矿石离心链不被删除 | -| 一跳 pulver 目标 | 产物只做声明的一次目标转换,不追到目标的目标 | -| 边界数量 | 1/72U、非整除、大于 int 的材料量、long 溢出均有明确定义 | -| 输出槽上限 | 顺序与经核对的截尾/拒绝规则正确,不能为“守恒”擅自添加槽 | -| 禁止与缺失 | 无权限材料无配方;未知组件、错误绑定逐项定位;缺必要绑定不生成截断配方 | -| 附属/重载 | 授权附属的声明可用;连续重载无重复、移除权限后旧行不可查 | - -JUnit 验证数学与权限;GameTest 从最终 map 查询并执行至少一个离心和一个电解样例,检查输入消耗、催化剂不消耗、流体量、时长与 EUt。把当前生成器输出直接另存作 expected 不算独立正确性证据。 - -## 完成与拆分 - -建议按“权限声明与负例 → 纯计算器 → 固体绑定 → 流体/气体与附属 → 切换、重载和旧表退出”交付。 - -完成条件:每个分解候选能说明权限、组成、相态和单位依据;活动定义没有静默悬空引用;两个节点代表例通过;现有明确 parity 差异保留。机器的化学处理能力和槽位未获依据前不在重构中扩大。 - -## 实施结果(2026-11-11) - -- API 1.8 新增唯一类型化 `MaterialProcessKeys.DECOMPOSITION` 和 `MaterialDecompositionRule`。规则同时声明离心/电解路线、液体/气体注册身份、`sourceUnits → mB` 换算以及接受流体后是否保留固体输入;没有新增平行材料注册表。附属只能为自己拥有的材料提交该宿主机 process。旧 `MaterialDeclaration` 离心/电解 shortcut 已弃用,只在没有 typed rule 时转换默认规则。 -- 规范目录中的 263 个材料现在发布分解上下文:250 个带至少一个可执行路线,13 个仅提供组件相态;69 个材料带显式流体相态。路线权限仍镜像为兼容的 `CENTRIFUGE`、`ELECTROLYSER`、`DECOMPOSABLE` 属性。 -- 旧 `SourceDecompositionData`、`SourceDecompositionNativeFacts` 已由 `DecompositionMaterials` 声明和 `DecompositionNativeAdapter` 取代。`MaterialDecompositionPlanner` 统一计算约简后的输入数量、EUt、时长、相态选择、按声明的一跳粉化目标、输出顺序、槽位截尾及失败状态;截尾和绑定失败均产生明确诊断。 -- 补齐 22 个已有路线但缺少组成的活动材料;`Ironwood`、`SkyStone`、`VibrantAlloy` 因组成依赖已停注材料,保留为明确无分解能力,不伪造替代组成。 -- Forge 1.20.1 以真实 `RecipeProcessor` 执行附属离心配方并核对消耗、时长、EUt 与两类输出,78/78 通过;NeoForge 1.21.1 为 83/83。详见验收记录。 - -### 审查闭合(2026-11-11) - -- typed decomposition rule 现在是路线唯一权威;旧 route flag/feature 只在其缺失时合成默认规则,显式规则的 route 集合会完整覆盖并回写兼容 flag,不再求并集。 -- `DecompositionRecipeLoader` 记录并暴露 overlay-owned rows,接入 `MachineRecipeOverlay` 的 baseline 排除、逐代重建和失败恢复;真实资源重载增加 owned 数量与电解配方可查询断言。 -- 材料单位以 `GTValues.U` 为唯一常量,换算统一到引擎层 `UnitConversion`;分解表与旧来源表共享的液体/气体 binding 改为读取同一数据。 -- 删除没有消费者的等离子体 API 与表字段;分解表的热学温度字段重新用于拒绝与规范材料物性不一致的数据。 -- 验证:API 108 个 JUnit、core 159 个 JUnit、API 契约、双平台生产及测试源码编译通过;Forge 78/78、NeoForge 83/83 GameTest 通过。 - -## PR #374 步骤五闭合(2026-11-12) - -- 路线、相态和换算声明统一由 `DecompositionMaterials` 持有;规范材料目录不再自行声明 `CENTRIFUGE`、`ELECTROLYSER` 或 `DECOMPOSABLE`。`MaterialDefinitions` 一次生成 typed rule,`MaterialInfoRegistry` 冻结时只把 rule 单向投影为兼容 flag,不再从 flag 反向补全已有 typed rule。 -- `DecompositionMaterials.validateConsumed(...)` 在规范目录装配后按 `(id, name)` 反查每条 `INPUTS`/`AMBIENT` 行和每条路线。重复行、没有规范材料所有者、存在所有者但 typed rule 未保留该行或路线不一致都会终止初始化;确需停用的行必须列入显式停用集合,不能静默留下孤儿数据。 -- 流体内容范围不是 typed 分解声明的定稿前置。`MaterialDecompositionRule` 保存的是固定来源中的候选原生流体身份与单位换算;issue #369 最终若收缩熔融流体,只会让对应运行时绑定缺失并产生既有诊断,不要求重写路线、组成或分解规则。反过来,若决定补配熔化器/EMI,也只改变原生流体与配方投影。两类决定通过 `DecompositionNativeAdapter` 的解析边界解耦。 -- 复验通过:完整 `:core:test` 171 个 JUnit、ratchet Spotless、路由闭合与注释检查;Forge 1.20.1 GameTest 90/90,NeoForge 1.21.1 GameTest 95/95,两个节点均完成真实启动、分解发布和材料重载。 - -## PR #374 步骤六闭合(2026-11-12) - -- 材料定义与显式物品成分是进程内一次性定义,不随世界切换或资源重载再次注册;`MaterialCatalogView.revision()` 返回该材料定义的发布版本。标签成分、有效成分快照和机器配方是平台侧可重新发布的内容;`MaterialPublication` 仅在整代配方发布成功后提交同时包含材料版本、成分 revision 与 overlay generation 的稳定 stamp,失败代不会覆盖上一份成功 stamp。 -- 标签成分状态按发布代次归属:每次 overlay 开始时先递增代次、撤销上一代的标签候选并进入 `TAG_INPUT_NOT_READY`,完整替换发布后才重新变为 ready。服务端停止通过同一入口清理;`explicitClosed` 不复位,因为显式定义在 JVM 生命周期内不可重载。 -- 异常策略按影响范围固定:显式成分同级歧义、静态内置配方所有权冲突和初始化结构损坏终止启动;外部 tag、数据包或附属派生的单条回收候选冲突由 `RecoveryRecipePublisher.publishIsolated(...)` 记录并跳过该行;分解候选缺绑定或不可表示时保留既有逐项诊断;overlay 生产器出现非行级结构性异常时整代回滚并恢复 baseline。 -- 纯计划不再反向读取内容配方类:`MaterialDecompositionPlanner` 使用引擎层 `UnitConversion`;回收计划由 `ItemRecoveryPlanner` 接收 `MaterialFacts`。原版炉处理授权随 `ItemCompositionSource` 提交,方块特定“空内容”判定经 `ItemMaterialRuntimeFacts` 由内容层注入,材料 registry 不再直接识别模具、箱子或原版成分 JSON 类。 -- 删除无消费者的 `MaterialInfoRegistry.compositionDefinition(...)`。需要组成时继续使用公开 `MaterialInfoTool.composition(...)` 或内部当前快照查询,不保留第二份冻结读取入口。 diff --git a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md b/docs/development/material-system-refactor/07-cleanup-and-acceptance.md deleted file mode 100644 index 905cad7e3..000000000 --- a/docs/development/material-system-refactor/07-cleanup-and-acceptance.md +++ /dev/null @@ -1,227 +0,0 @@ -# 07:清理与双平台整体验收 - -本计划在数据与执行路径已收敛后移除旧实现,审计无消费内容,完成用户可见行为与双平台验收。状态:内部清理与 07-E 已实施;[02](02-material-registration.md)—[06](06-decomposition.md) 已合入 master。07-A—E 的实现已完成并通过单元测试、双平台编译和双平台 GameTest;[08](08-material-data-api.md)-D—E 的生产快照和图/viewer 切片现已接入。07-F 仍需执行双平台重载、远程客户端、正式 viewer 与发行包验收,因此不能把全部 07 标为完成。 - -本页原清单按 master `f096a79ee`(2026-11-12)核对源码。2026-11-13 已完成首轮内部迁移:材料事实归入 `content.material.catalog` 的类型化 process 规则,运行时消费者改经材料查询,recipe 包只保留配方模板、特殊工艺和原生适配。下文保留旧类名用于追溯删除对象;实际新入口见“本轮实施结果”。 - -## 本轮实施结果 - -| 原入口 | 新权威入口 | 已迁移消费者 | 结果 | -| --- | --- | --- | --- | -| `ReviewedOreSourceProfile`、`ReviewedMagneticMaterials`、`ReviewedSiftingGemForms` | `ReviewedSourceMaterialFacts` | `OreSourcePolicy`、`FurnaceSmeltingRules`、`SourceFurnaceNativeAdapter`、`SourceGemGradeResolver`、`OreProcessingRecipeLoader` | 旧类删除;磁性正例写入材料 `MAGNETIC` 属性,其余事实写入 `SOURCE_*` process | -| `ReviewedOreInputProfile`、`ReviewedOreShredderFacts`、`ReviewedCrushedFormGeneration` | `ReviewedOreMaterialFacts`、`SourceOreFollowonAdapter`、`SourceCrushedFormAdapter` | 非矿延续、研钵、粉碎、洗矿与输出证明 | 重复资格和逐材料常量删除,原生所有权检查保留 | -| `ReviewedCinnabarFacts`、`ReviewedOreFluidBindings`、`ReviewedOreGeneratedFluids`、`ReviewedCinnabarThermalRecipes` | `ReviewedOreMaterialFacts`、`MaterialFluidUnitFacts`、`SourceCinnabarFollowonAdapter`、`SourceGeneratedFluidAdapter`、`SourceDustThermalRecipes` | 朱砂后续路线、蒸汽裂解、洗矿、离心和 Ti/Fe 热回收 | 朱砂局部蜡集合移入蒸汽裂解 recipe 自身;流体身份与 recipe 发布分开 | -| `SourceRecyclingFacts` | `SourceRecyclingMaterialFacts` 的 `SOURCE_RECYCLING` process | 炉、粉碎、洗矿、离心、酸洗和热回收适配 | 数据归入材料目录;运行时只经 `MaterialFactKeys` 读取,Water/Lava 的仅目标上下文也随 process 发布 | -| `GenerifyingRules.TARGET_IDS` | `GenerifyingMaterialFacts` | `GenerifierRecipeFamily` | 目标由材料 process 提供;prefix 条件和工时仍留在 recipe 同名类 | -| `SourceExtrusionRules.DATA` | `SourceExtrusionMaterialFacts` | `SourceExtruderRecipes`、`MaterialPrefix`、`MaterialPrefixes` | 挤压能力、锻造目标和可锻性归入材料事实;数量计算与配方向 recipe 门面保留 | -| `SourceOreMacerationFacts`、`SourceOreWashingData`、`SourceOreCrushingFacts` | `SourceMacerationMaterialFacts`、`SourceWashingMaterialFacts`、`SourceOreCrushingMaterialFacts`、`OreHostFacts` | 研钵、洗矿、Crusher/Hammer、OilSand | 材料能力与宿主岩石事实分开;Hexorium 产物策略仍留 recipe | -| `SourceLensRoles.ROLES` | `SourceLensMaterialFacts` | `ElectronicsRecipes`、`LaserStoneRecipes` | 透镜颜色角色进入材料 process;原生物品解析留在 `SourceLensRecipeItems` | -| `OriginalMaterialFluidUnits`、`SpecialProcessData.Phase` 的绑定字段、`PurifiedCentrifugeMaterialFacts` 的重复流体字段 | `MaterialFluidUnitFacts` | 分解、酸洗、离心、热回收、洗矿、化学解析 | 流体身份、相态和单位只由 `MATERIAL_FLUID_UNIT` 提供;API 1.9 的 target/reagent typed rules 保留材料选择与工艺配比,不再保存第二份原生字段/单位 | -| `PanelMaterialRegistration`、`TransportMaterialRegistration` | `PanelMaterialCompositions`、`TransportMaterialCompositions` | `MaterialItemCompositions`、`VanillaRecoveryRecipes` | 固定成分安装不再由 recipe 生产类承担 | -| `RegisteredWoodSurvivalRecipes.registerMaterials()`、`VanillaWoodProcessingRecipes.registerMaterials()`、`DiggableRecipes.registerMaterials()`、单物品与空胶囊写入 | `WoodMaterialCompositions`、`MaterialItemCompositions` | 木材、黏土、食物条、化合物和空胶囊回收 | 固定成分在配方发布前显式登记;配方类只发布配方 | -| `MaterialTooltips.appendForeign()` 的失效回收分支 | 04 有效成分快照 | 普通/高级 tooltip | 删除 `composition_nonmaterial`、`composition_descriptive` 及其语言键 | - -### 复核补正 - -- `MaterialFactKeys` 现在是事实值类型的唯一定义点:`Decision`、`Identity` 以及所有内建事实键只定义一次。配方适配器不再在 `ReviewedSourceMaterialFacts`、`SourceRecyclingMaterialFacts`、`SourceWashingMaterialFacts` 之间转换相同枚举。 -- 新增 Java 类已逐个反查:11 个 catalog fact provider 都由 `MaterialDefinitions` 的装配顺序引用,`MaterialFactKeys` 的 21 个内建键都有生产读取方,6 个 recipe 适配器、3 个固定成分安装器和 `SourceLensRoles` 门面均有真实消费者;没有只改包名或只转发一次的残留类。 -- 无消费者的弃用别名 `MaterialDataRules.REPLICATOR_POWER_PER_NUCLEON` 与 `WoodSpecies.zhName()` 已删除。`ItemComposition` 的 legacy 构造/访问器和 `ImportedMaterialData` 仍有明确源码兼容用途,按前置审查结论保留,不把它们当作新的材料事实权威。 -- Reviewed 炉/分级宝石事实表只在声明装配期按 ID+规范化名称投影为 process;生产运行时查询统一走 `MaterialFactKeys`,不再直接读取 `SourceRecyclingMaterialFacts.find()` 或静态流体绑定表。声明期辅助查找保持包内可见。 -- Reviewed 炉授权的源名含空格或连字符时按 `GTMaterial.sanitize` 规范化后与当前规范名校验;否则 `Lithium-6`、`Red Sand` 等 22 条源行会因显示名格式差异永久不命中。 -- `MaterialFluidUnitFacts` 同时覆盖通用流体、酸洗相态、蜂蜜/冰和离心相态;`MaterialFluidBinding`、酸洗和离心适配都从同一材料视图取得字段与比例。 -- `FluidCatalog` 的生成熔融物例外改由 `SOURCE_MOLTEN_FLUID` process 提供;Ti/Fe 的整粉热回收所有权改由 `SOURCE_GENERATED_FLUID` process 判定,不再在 recipe 中复制材料身份。 -- 蒸汽裂解的四个蜡反应物保留 recipe 局部集合,但恢复 ID+名称校验;朱砂副产物声明恢复带 ID 的身份并只挂在 Cinnabar 自身,适配器从这一个规范身份查询,避免同名、别名或相关副产物出现多份同级规则。 -- Ti/Fe 生成流体的材料密度与流体条目密度是两个不同事实:前者与材料密度比较,后者仍要求为 0。 - -## 目标与边界 - -删除的对象必须有“已被替代”或“无实际消费且无保留依据”的证据。材料名、prefix 名、没有 delegate、当前没有调用方都不足以单独证明可删除;还要检查资源引用、附属契约、序列化与存档身份。 - -本阶段不预先承诺删除 chain、minecartWheels 等具体内容。行为减少和纯内部清理分开验收;确需删除注册项时先准备兼容处理和 parity 记录。 - -### material 与 recipe 的分界 - -沿用 [content 包职责](../../architecture/packages/content.md)与[总计划的分层约束](README.md#共同实施约束)。清理的单位是事实和职责;一个混合类可以拆开,不能仅根据 `Reviewed*`、`Source*` 或材料名称整类搬迁。 - -| 内容 | 权威位置与消费者 | -| --- | --- | -| 材料身份、物性、化学组成、粉碎/熔炼目标及比例、通用矿石副产物、形态规则、加工能力 | core `content.material.catalog` 的材料声明,必要时采用同目录的类型化辅助声明;通过既有材料查询提供给配方生成器 | -| 通用加工模板的机器、输入形态、工时、能耗、概率、选择器及输出槽约束 | core `content.recipe`;生成器读取材料事实,通用计算放 `engine.material`/`engine.recipe` | -| 某材料的独立化学反应或特殊机器路线,包括额外反应物、流体与独立产物配比 | `content.recipe` 的显式配方声明;原生配方装配和发布留 Minecraft `content.recipe` | -| 运行期物品/方块/流体存在性、外部覆盖、栈状态和输入证明 | Minecraft 层按材料、流体、配方的实际职责适配;不把 `ItemStack`、原生注册表或 loader 类型搬进 core | -| 原始上游事实、当前默认值指纹、有限审核范围 | 保留适用范围的依据与校验;经裁决的领域事实再归入材料或配方声明,不能把审核白名单直接当全局禁用规则 | - -**朱砂与铝土矿的具体处理:** - -- 朱砂的通用粉碎目标、倍率、副产物顺序等属于材料事实;例如 `OreMaterials` 中已有朱砂组成与 `Redstone → Sulfur → Glowstone → Selenium` 副产物声明。生成粉碎、洗矿等通用路线时读取这些事实,recipe 不再维护一份朱砂属性副本。机器的具体产率、工时和输入形态仍由配方模板决定,化学组成也不能直接替代矿石副产物。 -- 铝土矿的高压釜路线属于特殊配方。当前由共享 Minecraft `content.recipe.generated.GTChemRecipes.autoclaveAndAluminiumElectrolysisRows()` 显式声明 12 条配方,`autoclave(...)` 绑定铝土矿、NaOH/KOH 和蒸汽,输出对应铝酸盐、蒸馏水与概率副产物;`MachineRecipeBootstrap` 调用该配方族。**保留在 recipe,不迁入 `OreMaterials` 或通用分解声明。** 如需拆出纯配方表,声明放 core `content.recipe`,原生装配留游戏层,且单独核验现有声明的来源约束。 -- `AutoclaveRecipeRows`/`AutoclaveRecipes` 是另一条按材料可结晶能力生成的通用宝石生长路线,不是上述铝土矿化学配方的所有者。材料的“可结晶”能力与高压釜模板分工维护,不因共用机器而合并两族配方。 -- 同一材料可以同时具有通用处理与特殊配方;特殊路线是否替换某条通用路线必须有明确工艺依据和所有权,不能见到特殊配方就关闭该材料全部通用处理。08-D—E 从最终有效配方派生铝土矿的来源/用途与处理图,材料目录不再保存一份高压釜路径。 - -### 本轮已清理的 Reviewed/Source 清单 - -以下保留旧文件与旧职责用于追溯,已经完成消费者迁移和回归验证,旧表或旧类不再存在。当前权威实现见上方结果表和代码中的 `MaterialFactKeys`;“材料声明”包括有明确适用范围的加工/形态声明,不等于向 `GTMaterial` 增加字段。 - -| 模块与当前类 | 当前职责及主要消费者 | 07 的具体处理与退出条件 | -| --- | --- | --- | -| core `ReviewedOreSourceProfile` | `FURNACE`、`GRADED_GEM` 的有限 YES/NO/UNKNOWN 表;`OreSourcePolicy`、`SourceGemGradeResolver`、炉配方适配消费 | 将已确认的炉授权和分级宝石能力归入材料加工/形态声明;统一与 `SourceRecyclingFacts` 的重叠查询。所有调用改读同一权威后删除该表;未覆盖身份不能变成 NO | -| core `ReviewedMagneticMaterials` | 磁性正例名单;`OreSourcePolicy.magneticCandidates()` 间接消费 | 磁性分类归回材料声明;核对现有 `MAGNETIC` 与正例名单差异及全部属性消费者。替换 `名单 OR flag` 后删名单;磁选机器的候选筛选和概率仍留 recipe | -| core `ReviewedSiftingGemForms` | Ice 的三个高级宝石形态负例;`SourceGemGradeResolver` 消费 | 将形态事实归入材料形态规则,保留“配方产出不可选”与“旧物品身份仍注册”的区别。外部显式表示仍按现有优先级选择,不能顺手注销 Ice 的旧形态 | -| Minecraft `ReviewedCrushedFormGeneration` | 九种材料的 crushed 系列排除及原生绑定证明;`SourceOreInputForms`、`SourceOreOutputRows`、洗矿适配消费 | 纯材料/形态排除并入规范规则;原生物品所有权、成分和外部覆盖检查留薄适配。统一输入/输出查询后删重复名单;当前是 recipe 局部排除,扩大到注册规则须另列行为影响 | -| Minecraft `ReviewedOreInputProfile` | 非矿输入的有限 ORES 负例及附属形态退让;非矿粉碎与后续路线消费 | 材料的矿物处理资格归入材料声明,外部形态与兼容退让留游戏侧。消除按 ID 的第二张资格表;不能把“没有 ORES”扩张为禁止一切配方或外部形态 | -| Minecraft `ReviewedOreShredderFacts` | 十一种材料的质量、MORTAR/self-pulver 审核范围和物品绑定;`SourceOreFollowonRows`/矿处理 loader 消费 | 材料质量、研钵能力和粉碎目标改读材料规则;形态、成分、外部所有权证明留适配。通用 shredder/研钵模板继续在 recipe;移除逐材料重复常量后再合并该适配器 | -| Minecraft `ReviewedCinnabarFacts` | 朱砂及副产物身份/属性指纹、原生形态和常温状态证明;粉碎、后续处理、蒸汽裂解消费 | 材料事实读 `OreMaterials` 及相关材料声明;本地物品解析留适配,共用配方规则保留。删除仅为断言目录未漂移而重复写出的整组常量,改用目录校验和工艺准入;先处理外部覆盖与 UNKNOWN 退让,不能直接放开所有材料 | -| core `SourceWaxMaterials`/Minecraft `ReviewedCinnabarFacts.sourceWaxes()` | 四种蜡的名单经朱砂类转发给 `SharedMineralSteamCrackingRows` | 去掉蒸汽裂解对朱砂类的依赖。若该集合表示材料分类,用材料 tag/group;若只是此工艺支持的四个反应物,保留 recipe 的局部输入集合。裁决后只有一处成员定义,不为了搬包扩大其他蜡的工艺资格 | -| Minecraft `ReviewedOreFluidBindings`、core `ReviewedOreGeneratedFluids` | 汞/蜡的单位绑定与汞、Ti/Fe 的生成流体指纹;洗矿、离心、热配方和 `OreFluidBindingAdapter` 消费 | 材料相态/单位声明、流体内容定义、原生所有权检查分开:分别复用材料 process、流体目录和薄适配。合并与 05/06 的重复换算及绑定定义;同一流体的声明一致不代表已原生注册,也不能统一假定 144 或 1000 mB/U | -| Minecraft `ReviewedCinnabarThermalRecipes` → `SourceDustThermalRecipes` | `emitIfSupported()` 只走 Ti/Fe 整粉与分数粉 Smelter 路线;`OreProcessingRecipeLoader` 消费 | 已按真实职责更名;氧化物热回收特权未恢复。熔点、密度、熔炼目标及流体单位从材料事实读取,工时/分数粉模板和发布仍在 recipe | -| core `SourceRecyclingFacts` 与 `OreSourcePolicy` | 源版热处理事实、当前端口默认值和炉授权的有界适配 | 逐字段区分源版事实、现行材料事实和工艺策略,再与前述表去重。源版与现行定义冲突时先裁决并评估所有消费者;不能直接把 source flags 全局回写材料,不能仅为了删表去掉外部/变更元数据退让 | - -首轮之外的具体对象见 [recipe 包补充审计](07-recipe-package-audit.md):`GenerifyingRules` 与 `SourceExtrusionRules` 已拆成“材料事实 + recipe 模板”,其余材料表和固定物品成分写入已迁出。机器独有的酸洗反应物、概率、选择器及输出预算继续保留在 recipe。两份清单仍不代表全部配方已经完成 07-E 的注册项去留裁决。 - -当前可跟踪文件中仍未找到已删除审核类所称的 `reviewed-source-policy.json`、`nonore-input-source-profile.json`,也未找到 `RecyclablePrefixes`、`MaterialDataFacts` 注释所称的抽取脚本。已迁移数据按现状保留并进入目录校验;缺失资料仍列为依据缺口,不能假称现有构建可以再生成。 - -## 实施步骤 - -### 1. 建立字段级退出清单,先处理重复事实 - -1. 对上表按字段登记:当前声明、规范声明、读/写调用方、适用工艺、原生绑定、附属覆盖、替代查询、迁移后保留项、删除条件和验收样例。已经与目录重合的常量优先去重;目录尚不能表达的能力先设计类型化声明,不新增无作用域的 boolean 白名单。 -2. 明确 YES/NO/UNKNOWN 的原有语义。未审核、非内置所有者、外部形态和修改后的默认值可能属于 UNKNOWN,不能用普通 boolean 合并后当作 NO;合法不支持与缺绑定分别诊断。 -3. 先以朱砂通用粉碎作为迁移样例,贯通材料声明、通用模板、原生输入证明与最终发布;再迁磁性、炉授权和形态限制等多材料名单。每次只切换一个配方族的写入者,比较最终可查询行为,不能长期双写。 -4. 对铝土矿高压釜作保留对照:确认显式配方未被材料化,也未因通用矿物能力迁移而消失或重复生成。额外碱输入、蒸汽消耗、蒸馏水和概率产出属于配方本身的验收内容。 - -交付:字段级清单、材料事实迁移 diff、保留的特殊配方与运行期适配说明,以及旧/新路径的预期差异。纯搬迁不得悄悄改变工艺资格、产率和原生注册范围。 - -### 2. 清理兼容门面、旧写入与重复发布 - -1. 对 `Materials`、`GT6Materials`、`ImportedMaterialData`、旧属性字段和生成表逐项标明消费者、是否只读转发、被哪个规范声明替代。`Materials` 是当前可读符号入口,应保留;`GT6Materials`、`ImportedMaterialData` 与 `content.material.generated` 已有大量引用,不在本阶段按“旧类”整类删除。 -2. 对已迁移字段和配方族搜索全部写入与调用,确认生产中只有一个决定位置;测试与兼容访问器不得继续暗中初始化旧表。 -3. 删除零消费者的内部表、死方法和重复初始化;保留仍有公共消费者的兼容访问器,并写明废弃版本及迁移方式。 -4. 验证最终生产路径不再出现无理由的 `continue`、`return null` 或 collision 丢弃来隐藏非法引用;合法“不支持此工艺”继续允许,但有明确分类。 - -| 当前入口 | 本阶段必须核对的内容 | 保留/删除条件 | -| --- | --- | --- | -| `Materials`、`GT6Materials`、`ImportedMaterialData`、`content.material.generated` | 静态字段是否只引用规范目录对象、类加载顺序、哨兵与别名、生成区的来源约束 | 保留有效符号与公开兼容;仅迁移确有必要的局部调用,不全仓改名。不得恢复各自安装或后置修改材料事实 | -| `MaterialForms`、`MaterialProcessingTargets`、`MaterialWorkability` | 区分规范目录查询门面与独立常量;检查老工艺是否仍读另一份默认规则 | 当前只读门面可保留;删的是重复事实或已经迁移且无消费者的方法。公开签名按 API 兼容边界处理 | -| `MaterialGroups`、旧 re-registration 入口 | 组成员是否来自规范组视图,匹配是否误改真实材料身份 | 有兼容消费者则保留转发;生产侧不再维护第二份成员或通过重注册合并材料 | -| `RecyclablePrefixes`、`MaterialDataFacts`、`RecoveryFormCatalog` | 回收形态、可扫描形态和实际注册规则之间的重叠与差异 | 同一语义只留一份声明;可扫描不等于可回收,不按集合相似就合并。生成来源不明时先记录缺口 | -| `GTMaterial` 的兼容属性/target、`MaterialInfoRegistry` 发布快照 | 每个已迁移字段的写入时点与单向派生;明确允许的附属回调 | 兼容读不再反写规范声明;不要删除仍承载运行时查询的字段,也不要重新引入 flag/typed rule 往返同步 | -| `bulkRecoveryAllowed` 兼容入口与消费者 | 当前构造已归一为 true,tooltip 和 producer 是否还把它当独立加工权威 | 移除内部失效分支和误导展示;旧参数/访问器如需保留只作兼容,不重新引入物品级回收否决 | -| `OreProcessingRecipeLoader`、Shredder/热回收/分解生产端 | 对照 `RecoveryRecipePublisher`、`ThermalRecoveryOwnership`、`DecompositionRecipeLoader` 的族所有权与重载撤销 | 通用、源版有界、显式特殊、动态/unit 各行只有一个有效发布者;迁出特殊分支时同步退出旧 owner,防止漏行与双发 | - -保留 04—06 已收敛的行为:使用 `ItemRecoveryPlanner` 和类型化分解规则;保留 `MaterialPublication` 的成功代发布、失败代成分与配方整体恢复、标签撤销和单行冲突隔离。它们承担实际生命周期职责,不属于本阶段应删除的“重构脚手架”。 - -交付:逐项清理表和实际删除 diff,能够追溯到前面各阶段的替代能力。 - -### 3. 审计材料与形态的来源和终端 - -1. 从实际注册形态与配方查询结果建立“来源 → 中间转换 → 消费终端”关系,不仅靠 Java 字符串搜索。 -2. 消费端包含机器部件、工具、配方输入、存储/建筑、附属请求和有意展示用途;纯“转成自己再回收”的闭环不算充分消费理由。 -3. chain、minecartWheels 优先核对;billet、gearGt/gearGtSmall、itemCasing 已有消费线索,必须验证实际可达性,不能按名称批量删。 -4. 对无来源或无终端项列出选择:保留并说明用途、停止生成相应配方、停止新注册并保留旧身份读取、删除。注册项删除需额外考虑旧世界中的物品/方块与流体。 -5. 仅在证据和兼容方案完整后实施;材料、物品、流体的有意移除分别更新现有 parity 台账。未完成裁决的候选可以明确保留,但不能宣称审计已全部完成。 - -每项至少记录:材料与形态身份、实际注册对象、获得途径、有效配方输入/输出、终端用途、公开附属契约、存档影响、去留决定和证据。定向注册/查询审计可定位候选,但不能把文本命中数或未执行运行期的快照当最终可达性,也不能声称已经覆盖全部处理图。 - -### 07-E 定向审计记录 - -2026-11-13 使用最终双平台 GameTest 生成的 `reload-items.tsv`、`reload-forms.tsv`、`reload-block-forms.tsv` 与源码配方入口完成全量定向审计。注册数是实际发布对象数,不是 Java 字符串命中数。最终 Forge 与 NeoForge 均为 124 个形态族、31,137 个材料物品和 3,532 个材料方块形态,逐族计数一致;完整清单、九类无静态配方来源项的证据和源码补证见[07-E 材料与形态注册项审计](../../integration/material-refactor-07-roster.md)。 - -| 形态 | 实际注册物品数(Forge/NeoForge) | 已确认获得途径 | 已确认消费终端 | 本轮决定 | -| --- | --- | --- | --- | --- | -| `chain` | 407/407 | `AnvilRecipeDefinitions`:2 ring → 1 chain | `SourceThermalInputRules` 热回收输入、`SourceExtruderRecipes` 特殊输入矩阵、`PolarizerMaterialRecipes`、材料形态组界面 | 保留;有来源和终端,不删除身份 | -| `minecartWheels` | 207/207 | `HandMaterialCraftingRecipes`:2 ring + stick + hammer + wrench → 1 set | 热回收输入、特殊挤压输入、偏振器输入、材料形态组界面 | 保留;不从名称推断无消费者 | -| `billet` | 258/258 | 坩埚/模具、材料形态转换及显式配方 | 工具、研钵、挤压、偏振器和多项机器配方输入 | 保留;继续作为具体形态使用 | -| `gearGt`/`gearGtSmall` | 407/407 | 挤压、木材配方、坩埚模具及材料形态转换 | 旋转动力设备、齿轮箱、工作站建造、纳米制造和配方输入 | 保留;不是可批量注销的兼容形态 | -| `itemCasing` | 407/407 | 挤压与材料形态转换 | Welder、石墨烯路线、电源单元和机器建造输入 | 保留;源版 `casingSmall` 别名仍有实际消费者 | - -审计发现 NeoForge 原先只为 16 个 `oreVanillastone` 物品提交成分,Forge 为 396 个。共享 `MaterialItemCompositions` 现在按实际 `DenseOreBlock`、`VanillaOreBlock` 和非小型 `OreBlock` 统一提交,现有注册 ID 不变,最终两边均为 396。其余 123 个形态族没有找到足以删除的无来源、无终端证据,因此全部保留;没有改变物品 ID、NBT、配方身份或存档兼容性。完整来源/用途边仍由 08-D—E 的最终处理图验收覆盖。 - -### 4. 整理 tooltip 与语言 - -1. 以 04 的有效成分与加工判定为数据源,明确展示组成、具体工艺准入与当前状态;删除“完全损坏工具属于 technical/entity item”这样的错误分类。物品含哪些材料、能否执行当前工艺、损坏后剩余多少必须分别判断。 -2. 从共享 `MaterialTooltips.appendForeign()`、两节点 tooltip 接线和对应语言资源逐项核对。`composition_nonmaterial` 不能只凭主材料 ID 判定所有拒绝原因;`composition_descriptive` 当前依赖已归一的 `bulkRecoveryAllowed()`,核验可达性后清理失效分支与语言键。复用现有状态展示入口,不另造第三套授权。 -3. `zh_cn` 提供实际中文,普通/高级 tooltip 的门槛两平台一致;不把数据源、内部生产端、诊断术语塞进玩家常规流程。 -4. 材料键与 lang 覆盖检查只处理本域,不批量改写或重新排序整份大型语言资源。 - -### 5. 验收初始化、查询、运行与重载 - -按下表执行,使用 01 的归一化输出对照;每个差异都有对应变更、测试和规则依据。 - -| 层次 | 无附属环境 | 测试附属/标签派生环境 | 通过条件 | -| --- | --- | --- | --- | -| 材料 | 身份、别名、属性、形态 | 合并/冲突/所有权、合法链接 | 无重复身份或未裁决漂移 | -| 成分 | 显式物品、JSON、方块与植物 | 标签兜底、CR.REV 与显式覆盖 | 查询与遍历一致,变更顺序不改变结果 | -| 回收 | 粉碎、砧、Smelter/Melter、坩埚 | 附属材料与外部输入 | 授权与数量正确,非法栈不被满额消耗 | -| 分解 | 固/液/气体输入与 map 权限 | 附属绑定与形态 | 配比、单位、选择器、槽位规则正确 | -| 材料 API 与图 | 分类/组、形态、有效来源/用途 | 外部 tag、附属工艺与世界生成 | 图与最终内容同版本,无条件丢失、伪来源或无限展开 | -| 生命周期 | 首次启动、连续两次重载 | 标签增删、候选权限变化 | 无旧行残留、无重复、缓存同步失效 | -| 客户端 | tooltip、配方展示、机器实际交互 | 基础游戏未装可选模组 | 无错字/错误状态、服务端权威不被展示绕过 | - -两个版本共有的材料信息与规则应相同;版本独有物品和原生绑定差异单独说明。配方展示抽样不能代替最终查询与机器执行;服务端 GameTest 也不能代替客户端视觉检查。 - -清理专项至少增加或复用以下断言,按真实测试源码集接入;现有用例不是所有新迁移项已经有覆盖的证明。 - -| 迁移风险 | 必须观察的结果 | 优先复用入口 | -| --- | --- | --- | -| 删表后材料事实漂移 | 材料身份/别名不变;修改一个规范声明即可改变相应通用生成结果;无需同步修改审核名单 | core `MaterialCatalogTest`、`MaterialFormCatalogTest`、`MaterialReferenceAudit` | -| 有限名单被误当全局否决 | 原有正例、负例、未覆盖材料、附属材料、变更元数据和外部显式表示分别验证 | core 工艺规则测试与共享 `MaterialBaselineTests`,补足本次实际迁移范围 | -| 朱砂/Ti/Fe 旧 owner 回归 | 朱砂无专用热回收绕过;Ti/Fe 分数粉不漏行或双发,输入证明与损坏/容器状态仍生效 | `RecoveryRecipePublisherTests`、材料领域 GameTest 与最终 `RecipeMap` 查询 | -| 特殊配方被材料化或挤掉 | 铝土矿高压釜的 NaOH/KOH 两支、等量粉末形态、额外物料与概率输出保持;通用结晶路线仍独立 | 化学配方解析结果、最终高压釜查询;迁移触及该族时补对应执行用例 | -| 清理影响成分和回收 | 铜块 9U、72U 输出、复合工具头、损坏工具、空/满容器及已凿模具的量和拒绝行为不回归 | `MaterialBaselineTests` 与 core `ItemCompositionResolverTest` | -| 重载只撤销了一半状态 | 连续两次真实重载无旧行;移除 tag 后表示与派生行退出;失败代保留上一成功成分和配方 | `MaterialBaselineTests` 的 tag generation、失败恢复与真实资源重载用例 | - -### 6. 核对发行包与维护入口 - -1. 使用 Forge `distributionJar` 和 NeoForge `jar` 的实际产物验收,不把 SDK 或 Forge 中间 JAR 当最终模组。 -2. 检查两种发行包中无 GameTest 类、模板、案例 TSV、原始 dump、导入脚本或任务日志;运行资源与 API 类按既有打包规则各出现正确份数。 -3. 同步 API、content、engine、runtime、platforms 中确有变化的职责与验收条件;新增检查方式或命令时按规则同步 validation 文档和路由。 -4. 将长期数据维护步骤写入开发指南,跨平台验证结论按 integration 模板保存;原始记录继续留 `work/`。本组计划标明哪些阶段已实施、哪些仍待完成,不把计划全文改成未经核验的成功记录。 - -## 独立验证与最终通过条件 - -检查集:D、F、J、A(涉及公开 API 时)、C、G、B、M。检查命令及先后要求见[总计划](README.md#检查的使用方式)和相应检查文档。 - -### 本轮验证记录(2026-11-13) - -执行且通过: - -- D:`python3 tools/validation/route.py check`,路由闭合、检查文档和相对链接通过。 -- J:`./gradlew :core:test`,core 全套 174 tests 通过;新增事实投影计数覆盖全部迁移类别。 -- C:`./gradlew compileBothPlatforms`,Forge 与 NeoForge 节点均编译通过。 -- F(改动范围):`-PspotlessRatchet=HEAD` 的 core 与 Minecraft 格式检查通过;`git diff --check` 与注释引用检查通过。 -- G:当前代码在全新目录 `work/material-system-refactor/07e/gametest-forge` 与 `gametest-neo` 分别运行 Forge/NeoForge `runGameTestServer`,结果为 95/95 与 100/100;两节点均执行 `material_baseline`、`material_baseline_reload`、新增矿石形态遍历和配方发布批次。 -- B(首轮、当前修复前):两个平台当时实际发行 JAR 构建成功;当前 07-E 成分修复后的发行包留待 07-F 重验。 - -执行但失败或阻塞: - -- 不带 ratchet 的 `:core:spotlessJavaCheck` 仍会报告 HEAD 既有的 `OriginalMachineMaterialData`、`RecoveryFormCatalog` 等格式差异;本次没有为通过检查而批量改写这些无关文件。按本次改动路径的 ratchet 检查已通过。 - -尚未执行: - -- 07-F / 08-D—E 的有效来源/用途索引、有界处理图和远程客户端验收。 -- 客户端 tooltip、JEI/EMI 展示及机器实际交互的人工验收。 - -- 新增/修改普通材料只改一处领域声明;组件、燃料、形态和分解不再跨表重复维护同一字段。 -- 同一物品只有一份有效成分解释,冲突可定位,加载顺序不再决定结果。 -- 回收/分解同一配方族只有一个发布者;不支持、缺绑定、量化损耗与真正冲突可区分。 -- 生成量与最终可查询行为都有证据;unit 折叠和显式覆盖可解释,没有用“配方数变少”代替正确性验收。 -- 代表样例覆盖铜块授权、72U 输出、复合工具头、损坏工具、容器、已凿铸模与压模机模具、多组件热输入、附属材料、化合物分解及重载。 -- 双平台检查与客户端确认分别报告,材料信息无未解释的版本漂移;没有把 compile 成功写成游戏行为成功。 -- 所有内容删除都有消费证据、兼容说明和必要的 parity 记录。 - -## 拆分与兼容处理 - -建议按下列小变更实施,每项独立保留可编译、可验证的最终生产路径: - -| 切片 | 内容 | 前置与完成条件 | -| --- | --- | --- | -| 07-A | 字段级清单、朱砂通用事实样例与蜡集合解耦 | 02—06;材料事实只维护一处,铝土矿特殊配方保留,外部/未知范围不被误禁用 | -| 07-B | 磁性、炉授权、形态与流体绑定名单收敛;热类名称/所有权整理 | 按 07-A 的边界逐族迁移;旧表退出、原生证明保留、最终可查询结果可解释 | -| 07-C | 兼容门面、死分支、旧写入和重复发布清理 | 对应消费者已迁移;公开兼容和成功/失败代语义不回归 | -| 07-D | tooltip 与语言清理 | 使用现有有效成分与状态;两个客户端确认普通/高级展示 | -| 07-E | 材料/形态去留与必要迁移 | 定向审计可先开始;删注册项必须单独提供可达性、存档和 parity 依据 | -| 07-F | 全链路、处理图、远程客户端与发行包总验收 | 08-D—E 代码已接入;按本页矩阵执行两个平台、正式 viewer 与远程场景并记录未覆盖项 | - -07-A—E 已完成;08 的有效来源与共享图仍是 07-F 的交付前置,不能用内部清理和 07-E 注册项清单替代。每个切片的检查按实际改动路径与总计划检查集执行,不把纯文档清单的检查结果沿用为实施代码的验收结果。 - -仅删除内部代码时,可回退对应小变更并恢复旧适配器;一旦删除了世界中可持久化的身份,恢复源码不等于恢复已保存的数据,必须在实施删除前选择并验证迁移/保留读取策略。测试世界使用隔离副本,不对真实服务器执行本计划。 diff --git a/docs/development/material-system-refactor/07-recipe-package-audit.md b/docs/development/material-system-refactor/07-recipe-package-audit.md deleted file mode 100644 index eefc36694..000000000 --- a/docs/development/material-system-refactor/07-recipe-package-audit.md +++ /dev/null @@ -1,83 +0,0 @@ -# 07 补充:recipe 包中的材料事实审计 - -本页给出 [07 清理计划](07-cleanup-and-acceptance.md)首轮 Reviewed 清单之外的具体对象。源码核对起点为 master `f096a79ee`(2026-11-12),2026-11-13 已完成下表中的材料事实与固定成分迁移;本页保留原检查和边界,用于追溯新入口和仍需 07-E/07-F 验证的范围。 - -本轮对 core 与共享 Minecraft 的 `content.recipe` 共 258 个 Java 文件、两版本节点的同包共 14 个 Java 文件做文件清点和模式搜索,对疑似项阅读声明、方法和调用方;另外扫描两层 `engine.recipe` 共 44 个 Java 文件的同类特征。检索覆盖材料 ID/名称名单、属性与 target 表、相态单位、成分写入和默认值指纹。该范围不等于对所有配方逐条核验,也不包含 JSON、脚本及第三方模组的完整运行期审计。 - -迁移后逐表复核确认:挤压源表 734 行的 payload 完全一致;回收 seed、研钵正负集合、洗矿行和透镜角色没有在复制时改值;新增 process 投影后,炉授权 198 条与分级宝石 2 条全部命中,其中 22 条源名需经 `GTMaterial.sanitize` 才能对应 `Lithium6`、`RedSand` 等规范名。4 个 Hexorium 透镜角色因当前没有该可选材料而保持未投影,不会被当成普通材料身份。 - -职责判断沿用 [material 与 recipe 的分界](07-cleanup-and-acceptance.md#material-与-recipe-的分界)。以下建议不增加已支持的公共 API;目录缺少表达能力时,在实施切片中设计声明并验证消费者。 - -## 一、需要归入材料声明的新增对象 - -| 当前对象与证据 | 材料事实与当前消费者 | 具体清理方式 | -| --- | --- | --- | -| [GenerifyingMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java) 的 `TARGET_IDS` | 143 对材料 source/target ID;Minecraft `GenerifierRecipeFamily.target()` 据此决定转换目标 | 已迁入 `GENERIFICATION_TARGET` process;配方的适用 prefix、工时、动态查询与显式配方优先级仍在 [GenerifyingRules](../../../core/src/main/java/gregtech/content/recipe/GenerifyingRules.java) | -| [SourceExtrusionMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java) 的 `DATA`/`Profile` | 734 行材料挤压能力、简单挤压、可锻性和 forging target/amount;`SourceExtruderRecipes`、`MaterialPrefix`、`MaterialPrefixes` 消费 | 已迁入 `SOURCE_EXTRUSION` process;[SourceExtrusionRules](../../../core/src/main/java/gregtech/content/recipe/SourceExtrusionRules.java) 只保留数量的取整、工时和原生查询门面 | -| [SourceMacerationMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java) 的 `MORTAR_YES`/`MORTAR_NO` | 两套研钵能力 ID 集合;`SourceOreMacerationAdapter` 使用 | 已迁入 `SOURCE_MACERATION`;适配器仍保留 UNKNOWN、外部形态和原生输入证明 | -| [SourceWashingMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java) 的 `Binding.tags` | 按材料声明 MERCURY/PERSULFATE/FIRESTONE 三种通用洗矿能力;`SharedOreWashingRows` 查询 | 已迁入 `SOURCE_WASHING`;具体反应物、用量、产出与概率留 recipe | -| [SourceOreCrushingMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java) 与 [OreHostFacts](../../../core/src/main/java/gregtech/content/block/stone/OreHostFacts.java) | 特殊粉碎/Hexorium 分类与宿主岩石、脉石、破碎配对 | 材料能力进入 `SOURCE_ORE_CRUSHING`,宿主关系进入石材内容声明;适配器保留原生所有权检查 | -| [SourceLensMaterialFacts](../../../core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java) 的 `ROLES` | 57 条材料透镜颜色角色;`ElectronicsRecipes`、`LaserStoneRecipes` 消费 | 已迁入 `SOURCE_LENS_ROLE`;`SourceLensRecipeItems` 只解析已注册原生物品 | -| Minecraft [BathMaterialRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java) 的 `NOT_ANY_WOOD_DUST` 与 [TreatedWoodRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/TreatedWoodRecipes.java) 的 `NOT_UNTREATED_WOOD` | 两处分别用 WOOD 属性加 `PetrifiedWood` 排除来近似 `AnyWood`/`AnyUntreatedWood`;已有 `MaterialGroups.Wood`/`WoodUntreated` 与规范组目录 | 核对全部现有成员与附属扩展后改读对应组;纸浆配方额外接受 Bark/Paper、处理木材的转换输出仍留 recipe。组替换必须比较行为差异,不能只把条件机械改写后认定等价 | - -其中两个大型目标表现已拆为材料事实和 recipe 模板。首轮 Reviewed 类清单及迁移结果仍见 [07 主计划](07-cleanup-and-acceptance.md#本轮已清理的-reviewedsource-清单)。 - -## 二、混合类中需要拆出的事实和绑定 - -这些类承担有效的配方职责,应按字段/方法拆分,不能整类迁到 material。 - -| 当前对象 | 应收敛的部分 | 仍应保留的职责与删除条件 | -| --- | --- | --- | -| Minecraft [SharedPurifiedCentrifugeRows](../../../minecraft/src/main/java/gregtech/content/recipe/SharedPurifiedCentrifugeRows.java) | 六条相态记录与七条显式无默认相态记录 | 已迁入 `PurifiedCentrifugeMaterialFacts` 的两个材料 process;原生注册字段/所有权、离心槽位、概率、重载发布和兼容分支仍留 recipe | -| [MaterialFluidUnitFacts](../../../core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java) 与 core `engine.recipe.chem.MaterialFluidBinding` | 材料相态/单位/流体身份绑定,后者从材料视图和流体目录建立索引 | 绑定事实进入 `MATERIAL_FLUID_UNIT` process;`UnitConversion` 只保留换算机制 | -| Minecraft [SourceThermalNativeAdapter](../../../minecraft/src/main/java/gregtech/content/recipe/SourceThermalNativeAdapter.java) 的 `nativeBinding()` | Glass、Blaze、Plastic、Ender、Redstone、Lava、CFoam、蜡及熔盐等原生字段/ID | 精确字段和单位从 `MaterialFluidUnitFacts` 查询;特殊原生持有检查与配方适配仍在游戏侧 | -| core [SpecialProcessData](../../../core/src/main/java/gregtech/content/recipe/SpecialProcessData.java) 与 `SpecialProcessMaterialFacts` | 酸洗 `Phase` 的材料选择、固定 target/reagent 规则和动态锰规则 | `Phase` 的原生字段、相态和 1000 mB/U 归入 `MaterialFluidUnitFacts`;酸洗材料列表、共同反应物、配比和尾产物通过 API 1.9 的 `SpecialProcessValue.Target/Reagent` 挂到 typed process。旧 `SourcePurifiedAcidData`、`SourcePurifiedAcidRules` 与 `SharedPurifiedAcidRows` 已删除 | -| core [SourceRollingWireRules](../../../core/src/main/java/gregtech/content/recipe/SourceRollingWireRules.java) 的 `physicalWire()` | Netherite/Naquadah 的额外线材族准入 | 已迁入 `SOURCE_ADDITIONAL_WIRE_FAMILY`;轧制/拉丝模板、工时与实际线材族注册仍留 recipe | -| Minecraft [MaterialFormConversionRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/MaterialFormConversionRecipes.java) 的 `compressor()` | Ice 的 `dust → plateGem` 排除 | 已迁入 `COMPRESSOR_DUST_TO_GEM_PLATE`,与筛矿高级宝石限制保持独立;装箱、拆箱、压缩模板仍留 recipe | -| core `OreHostFacts` 的 `HOSTS`/`BROKEN_SOURCE_PAIRS` | 宿主岩石、矿石 prefix、4U 脉石和破碎矿块表示关系;`SourceOilSandRules` 也消费 | 已位于石材内容声明;原生 host ID 解析和机器对脉石的产出策略仍留 recipe;不写入矿物化学组成 | - -`SourceLatheRules`、`SourceCutterRules`、`SourceFormingRules` 和 `SourceRollingWireRules` 已共同读取包外 `content.material.SourceLatheMaterialProfiles`。这部分结构可复用:recipe 保留工艺模板。后续还要审计该 material helper 与规范 catalog、`MaterialWorkability` 的事实重叠,不能仅因为已经移出 recipe 就宣称材料事实已只维护一处。 - -## 三、应归入游戏侧物品成分接入的对象 - -这是“物品包含什么材料”的事实,目标是 Minecraft `content.material`/现有物品领域声明;不是把这些物品配比写进 core 材料化学组成。 - -| 当前对象 | 证据与迁移范围 | 必须保留的边界 | -| --- | --- | --- | -| [PanelMaterialCompositions](../../../minecraft/src/main/java/gregtech/content/material/PanelMaterialCompositions.java) | 提交基础/彩色/增强混凝土和面板成分,维护回收物品集合 | 已归 `content.material`;`RECIPE_REVERSE` 来源、声明 ID、优先级和回收消费者保持 | -| [TransportMaterialCompositions](../../../minecraft/src/main/java/gregtech/content/material/TransportMaterialCompositions.java) | 提交管道、储罐、物流部件成分及 prefix 绑定 | 已归 `content.material`;规格仍由 transport 领域维护 | -| `DiggableRecipes.registerMaterials()`、`RegisteredWoodSurvivalRecipes.registerMaterials()`、`VanillaWoodProcessingRecipes.registerMaterials()` | 黏土块/球/泥炭、树种、树皮、原木、木板、楼梯和台阶成分 | 已迁到 `MaterialItemCompositions` 与 `WoodMaterialCompositions`;实际加工/合成配方仍留原类,材料量、树皮复合成分和 JSON 显式覆盖来源不变 | -| [SingleItemSourceRecipes](../../../minecraft/src/main/java/gregtech/content/recipe/SingleItemSourceRecipes.java) 中 `register()`/`compounds()`/`meat()` 等成分写入 | dry bark、compound、肉条等固定成分 | 已提前交给 `MaterialItemCompositions`;原版炉、坩埚展示和食物加工路线保留 | -| [CapsuleCellRecipes.registerRecycling()](../../../minecraft/src/main/java/gregtech/content/recipe/CapsuleCellRecipes.java) | 空胶囊 1/9U 成分 | 已在 `MaterialItemCompositions` 安装;回收端只读取有效成分并发布配方,空/满容器状态和共享静态工时保持 | - -迁移后,`MaterialItemCompositions` 不应再为安装固定成分而调用 recipe 生产类;配方发布也不应偷偷创建固定材料事实。接线要在显式成分关闭前完成,并保留当前来源优先级、覆盖关系和注册后才访问原生物品的时点。 - -## 四、经区分应继续留在 recipe 的对象 - -| 对象 | 保留原因与边界 | -| --- | --- | -| `GTChemRecipes` 的铝土矿高压釜、`SpecialProcessData` 的 fixed families | 明确反应物、流体、比例和产物的特殊化学工艺;共用材料不等于材料属性。target/reagent 规则进入 API 1.9,重复身份/单位绑定仍由材料目录提供 | -| `SourceAlloyRecipes`、`SourceOilSandRules`、`SourceOreSiftingRules.specialRows()`、`SourceOreMagneticRules.blockRows()` | 显式合金、油砂事件、特殊筛矿和固定磁选路线;输入/输出/概率就是配方内容,不因含材料名单而整体材料化 | -| `TechnologyIngredients.PISTON_METALS`、`craftingRedstone()` | 工艺局部的原料替代集合和形态选择。可以声明为配方专用组,不能由此推导全局“可做所有机械零件”能力,也不能合并不同语义的 `Any*` 组 | -| `PolarizerMaterialRecipes` 的材料对、`BathMaterialRecipes` 的材料转化与流体、`UtilityProcessingRecipes` 的木材提取产率 | 当前表达具体工艺的输入/输出或用量;应保留为配方关系。若以后确认为跨消费者的通用 target,可另行收敛声明,不能仅凭材料名称硬编码认定应全局化 | -| `SourceCentrifugeOptionalBindings` 及可选物品输出 | 版本、提供模组和实际注册项决定的外部集成适配;不是材料身份或加工能力。保留缺失/未知区别及未装模组时的类加载隔离 | -| `MaterialRecoveryRules`、`SourceThermalInputRules`、`SourceThermalRecyclingRules`、各 `*RecipeRows` 的通用机器模板 | 描述配方族、工时、形态数量和槽位策略。只把重复材料事实移出;纯换算机制是否归 engine 按既有分层另行整理,不将整套生成器搬进 material | - -## 五、实施顺序与验收补充 - -1. 通用目标、挤压、透镜、研钵、洗矿、相态单位和固定成分写入已完成迁移。 -2. `MaterialWorkability`、`SourceLatheMaterialProfiles` 等混合对象仍需在 07-E 定向审计中逐字段裁决去留;特殊处理系列已迁移到 API 1.9,不再保留酸洗专用声明 API。 -3. 对局部工艺例外继续按“材料加工声明”或“显式配方声明”裁决;不能用全局 flag 扩大效果。 - -源码中的数量注释也需要核实:`SourceOreMacerationFacts` 注释写 589 个正例/997 个身份,实际集合为 588 个正例加 408 个负例;`SourceOreWashingData` 注释中的 59/159 等口径与实际 142 个身份行、54 个含正例 tag 的身份不一致。酸洗相态迁移时确认实际枚举为 17 个,旧注释的 18 已修正。 - -实施时在 [07 的清理专项断言](07-cleanup-and-acceptance.md#5-验收初始化查询运行与重载)之外补以下范围: - -- 简化目标:动态查询与枚举得到同一目标,显式配方仍优先,未知/附属身份不误套 ID 表。 -- 挤压:锻造目标和比例、简单/热挤压工时、依赖 smithable 的形态注册同时验证。 -- 透镜:颜色角色与材料显示颜色独立,激光石材和电子配方使用同一角色声明。 -- 木材组:比较两组完整成员、PetrifiedWood、处理/抛光木材以及附属成员;纸浆特许 Bark/Paper 不丢失。 -- 物品成分:不生成任何加工配方时固定成分仍可查;重新发布配方不追加固定声明;树皮、楼梯、面板、运输容器和空/满胶囊的数量与状态不回归。 -- 相态与单位:核对汞 144 mB/U、显式熔盐、气体/普通液体和 source NONE;连续重载、外部覆盖与缺绑定保持可区分。 - -本页没有裁决任何注册项删除或 GT6 行为变化。实际发生行为变更时,仍按主计划提供来源、兼容影响、必要的 parity 记录和双平台验证结果。 diff --git a/docs/development/material-system-refactor/08-material-data-api.md b/docs/development/material-system-refactor/08-material-data-api.md deleted file mode 100644 index 128ad0c8e..000000000 --- a/docs/development/material-system-refactor/08-material-data-api.md +++ /dev/null @@ -1,212 +0,0 @@ -# 08:材料标签、形态、来源与处理图 API - -本计划将独立的材料相关系统通过查询与投影纳入材料 API,保持主材料对象简洁。状态:A—C 已完成;D 已从最终机器配方、有效成分、已发布形态和当前启用世界生成建立同代快照、有界来源/用途查询及客户端重建;E 已接 core 图、生产投影、JEI 和 EMI,并保留未知角色、符号选择器和预算截断。本计划尚未完成最终验收;两平台运行期、远程客户端和人工 viewer 验收仍需按本页清单执行。接口与语义权威见[设计提议 0001](../../decisions/0001-material-data-api.md),本页只维护实施顺序与独立验收。 - -08 是贯穿原计划的集成工作,不是在 07 后重做材料系统。A 在 01 的调查基础上、02 的接口定稿前完成;B 并入 02/03,C 并入 03/04,D 随 05/06 的有效结果发布,E 在 D 后实施;最终由 07 联合验收。07 的内部事实与兼容入口清理可先进行,D—E 是其最终来源/处理图验收的前置,详见 [07 拆分](07-cleanup-and-acceptance.md#拆分与兼容处理)。 - -| 切片 | 当前状态 | 已有入口或交付 | 未完成边界 | -| --- | --- | --- | --- | -| A | 已完成 | 稳定 key、不可变视图、metadata、process 扩展与宿主能力失败语义 | 无 | -| B | 已完成 | 分类 tag、替代组、包含关系与查询;`Any*` 消费者迁移 | 无 | -| C | 已完成 | 定义期 item/block/fluid 规则、实际形态绑定、tag 桥接与外部候选输入 | 外部模组运行期覆盖仍按实际安装环境验收 | -| D | 已实施 | `MaterialProcessSnapshot` 同代发布最终机器配方、活动世界生成和符号选择器;来源/用途共用一个索引 | 双平台重载、独立远程客户端与人工数据验收 | -| E | 已实施 | core 有界图、共享 Minecraft 投影、JEI/EMI 页面、精确跳转和形态来源/用途切换 | 双平台 viewer 截图、点击及未安装 viewer 场景验收 | - -## 当前入口与前置事实 - -- 现有 `GregTechMaterials` 已有只读材料句柄;优先增加视图和适配,不向 `GTMaterial` 追加来源列表。 -- `AddonMaterialContributor` 已覆盖材料、prefix、form、组成、熔炼和世界生成声明;追加能力使用默认方法和侧向 metadata 声明,不复制 SPI。 -- tag 需分别盘点 `MaterialProperty`、`MaterialRoleFlags`、`MaterialGroups`、`MaterialTagAliases`、`MaterialEquivalence` 和 `MaterialTagPack`。 -- 加工来自实际 `RecipeMap`、`RecipeManager` 和动态/unit 提供者;`allRecipes()` 不是可无成本反复读取的完整静态表。 -- 世界生成来源由 `MaterialWorldgenFacts` 只投影活动大矿脉、小矿、岩层和基岩矿事实;`WorldgenInfoData` 的旧 viewer 图标入口只保留兼容展示职责。 -- 用户截图作为处理图信息组织目标;不把截图的具体图标连接当作待硬编码的配方表。 - -## A:确定薄视图与最小公共契约 - -状态:已实施。API 1.5 提供 `MaterialKey`、`DataKey`、`FormKey`、类型化 `PropertyKey`/`MaterialProcessKey`、不可变 `MaterialView`、`MaterialCatalogView`、metadata SPI 和可扩展 process view;游戏侧内容快照仍属于后续 C—E。 - -### 步骤 - -1. 在 01 的清单上标明 tag 的四种语义、每个 form 的规则与注册结果、每类加工关系的实际所有者。 -2. 先只定义稳定材料引用、现有 form 引用、扩展 key、类型化属性与不可变视图;编写纯消费者样例,确认只依赖 API JAR。 -3. 由 `GregTechMaterials` 新入口取得定义视图;游戏侧内容快照入口显式接受 server/level 上下文,公共模型不包含游戏类型。 -4. 制定新服务未绑定、未就绪、旧宿主不支持、未知 key 和已过期引用的失败语义;不可统统返回空集合。 -5. 选定公开类型位置和兼容策略后更新 API 版本说明、实际包职责与测试。实现前不把提议方法写进已支持 API 列表。 - -### 独立验收 - -检查集:D、F、J、A;接入平台入口后加 C。 - -- 仅 API JAR 的消费者能声明 metadata、读取视图签名;不借 core 或 main 输出。 -- 同 key 异类型、内置 metadata 的可变值、非法引用均被拒绝;所有返回集合不可变。自定义 process value 保留扩展性,由 Javadoc 规定注册后不得动态修改,宿主不强制深度冻结。 -- 旧的 `MaterialDeclaration` 构造/builder 和旧只读句柄消费者继续通过;既有宿主实现不会因增加抽象方法直接失效。 -- 主材料视图没有配方表、矿脉列表、资源 tag 成员和 UI 坐标字段。 - -## B:材料分类、能力与替代组 - -状态:已实施本轮范围。规范目录中的分类和组在 READY 后发布为不可变查询;附属可声明自有 namespace 的 tag、tag 包含关系、替代组及组嵌套。未知引用、跨所有者冲突、tag 环和组环均拒绝发布。内置 `Any*` 工艺消费者已迁移到组键查询;旧 `MaterialGroups` 和 re-registration 访问器只保留弃用兼容。 - -### 步骤 - -1. 与 03 的 flag 迁移一起实现分类 tag 和替代组目录;现有 `Any*` 消费者按具体匹配语义迁移,保留必要的旧 re-registration 适配。 -2. 为分类包含关系和组嵌套分别做未知引用/环校验。不能将组成员调用 `setRegistration()` 变成同一个真实材料。 -3. 通过附属默认声明方法提交新 tag、group 和 metadata,核对 key 命名空间、跨附属同义声明和所有权。 -4. 先迁一个有实际消费者的分类与一组替代匹配,再迁其余;无行为消费者的描述性 tag 保持纯查询用途。 - -### 独立验收 - -检查集:D、F、J、A、C;生产替代匹配发生变化时加 G。 - -- 打乱声明顺序,成员与诊断不变;循环包含、悬空材料和冲突声明失败。 -- 为材料增加“金属分类”不会自动获得锭、燃料、回收或电解能力。 -- Iron/Steel 可在经允许的组匹配中替代,但各自 ID、物性、组件与其他配方身份保持区分。 -- 附属能增加自己的分类;未获权限不能改写 core 物性和加工能力。 - -## C:形态视图与资源 tag 桥接 - -状态:已实施本轮内容快照范围。API 1.7 将定义期规则扩展为 item/block/fluid,发布运行期实际绑定并把显式统一物品纳入实际表示;当前 API 1.9 继续提供同一形态快照契约,并增加 cross-material special process 方法、target/reagent 规则和派生标签。规则资源与兼容资源保持区分。平台注册后发布内容快照与资源 tag 桥接声明,外部 tag 成员仍作为 04 的低优先级候选输入。 - -2026-11-11 审查闭合:外部 tag generation 通过统一候选裁决后立即刷新公开形态绑定;冲突项在导入阶段带物品 ID 和声明差异记录。Forge 与 NeoForge 的审计探针均观察到新增 tag 表示进入 `formBindings()`,撤销后退出。 - -### 步骤 - -1. 以 03 的生成判定提供 form 规则视图,实际注册后构建可用表示索引;与 04 的完整成分及首选统一化目标接线。 -2. 把材料 tag 拼写和 form 映射集中到桥接声明;逐项区分导出、导入和显式双向,不迁移无关技术标签的所有权。 -3. 官方资源 tag 从已注册形态和权威成分导出;外部 tag 在加载后向 04 提交兜底候选,不反写生成规则或注册表。 -4. 区分 item/block/fluid tag,同名路径也不混合;两个节点的目录格式与兼容 namespace 留在适配器。 -5. 定义、注册绑定、tag 导入和成分裁决按固定阶段发布,拒绝查询尚未加载的临时结果作为永久事实。 - -### 独立验收 - -检查集:D、F、J、A、C、G;实际资源输出改变加 B。 - -- 可生成但未注册、有表示但无生产配方、规则禁止但保留兼容元数据等状态可区分。 -- 复合工具头的主形态不覆盖完整成分;tag 导入不会按物品数量猜材料量。 -- aluminium/aluminum 等已有兼容映射可查;普通材料分类不产生全材料全形态 tag 展开。 -- 外部 tag 改动能更新候选和绑定,但不会在 reload 时创建/删除原生物品。 -- 同一物品被不一致材料 tag 命中可定位冲突;高优先级显式成分不被覆盖。 -- 两节点对共同材料与形态的语义一致,item/block/fluid 成员分别验证。 - -## D:来源与用途索引、快照发布 - -### 现有接入点 - -- `MaterialPublication.Stamp` 已同时记录材料定义、有效成分和配方 revision;`MachineRecipeOverlay` 只在一整代配方生产成功后发布新戳,失败代保留上一份成功戳。D 应沿用该发布边界,不再增加一套材料内容版本。 -- `ItemMaterialRegistry.compositionState()` 提供有效成分 revision、tag generation 与 readiness;`MaterialViews.publishContent(...)` 发布实际注册形态。索引只能读取已经发布的稳定结果,不能从候选或临时注册表反推。 -- `MachineRecipeOverlay` 已负责静态基线、tag 归属行、数据包删除/添加和最终炉镜像。来源与用途索引必须读取这一最终集合,不能直接遍历 `allRecipes()` 或重复实现 overlay 顺序。 -- `MaterialUnitRecipeIndex` 已按物品或形态保留有界候选与少量生成批次;D 的动态投影应复用该选择语义,不能为索引展开全部物理配方。 -- `WorldgenInfoData` 当前从活动大矿脉、小矿、岩层和基岩矿表构造信息,并把事实与 `ItemStack` 图标混在同一访问器中。D 只投影实际启用事实,图标解析留给游戏/展示适配层,旧入口在迁移期转发。 - -### 快照与引用边界 - -D 的查询结果必须绑定一个完整发布上下文:`MaterialPublication.Stamp`、server/level 会话、活动世界生成配置和任何按世界生效的开关。配方、成分、形态和世界生成事实不得分别从不同代次拼成一个结果。 - -总览对模具、工具等辅助物品只保留步骤条件与原配方跳转,不展开其获取路线;普通消耗原料和产物不得因缺少材料形态而静默省略。 - -来源与用途使用同一份有界索引:来源按目标资源查前驱,用途按已发布关系查后继。每条关系保留步骤身份、共同输入、催化剂、全部输出、批量单位、概率、原生状态限制、覆盖程度和原生配方引用。资源身份至少区分材料、形态、相态与原生状态;同一图标或物品 ID 不构成身份合并。 - -`DataKey` 只表达展示快照内的引用,不是来源索引主键或存档 ID。D 的适配器把原生步骤和资源引用投影成展示引用;跳转时先校验当前发布戳和会话,再重新解析原生配方。旧快照可以服务于尚未结束的查询或展示,但不得跨重载、换服或会话复用。 - -失败重建不得发布部分索引;查询进行中的旧成功快照可继续读取,并在消费者释放后回收。禁止无限保留历史 generation,也不得以全局缓存代替 server/level 归属。 - -### 步骤 - -1. 先为最终静态机器配方建立输入/输出端口投影,保留共同输入、催化剂、单位、概率和原生状态限制;选合金与洗矿各一个闭环。 -2. 接入 05、06 的已发布结果、数据包替换/删除与最终炉配方镜像,来源和用途共用同一索引。 -3. 接入实际启用的世界生成;投影有效维度、高度与岩层,不从材料 `ORES` flag 推测世界里一定有矿。 -4. 接入 unit 及首批动态族的符号投影,保留原生匹配引用和覆盖说明。不能调用全量枚举补齐每一种物品变体。 -5. 盘点完整运行期回调,确定真正的发布时点;内容 generation 同时包含有效 tag、成分、配方与世界生成配置。原生对象不在后台读取中继续变化。 -6. 提供有界来源/用途查询与原生引用解析,禁止跨快照引用混用;旧快照有界保留且保持自洽。 -7. 检查现有客户端同步覆盖;复用已有事实同步,对缺失投影补充会话/generation 绑定。测试独立远程客户端路径,不依赖集成服务器共享内存。 - -### 实施结果 - -- `MaterialProcessSnapshot` 在服务端 `RecipePublication` 最终提交后构建,独立客户端在 overlay 与炉镜像完成后构建;同代、同形态/tag/世界生成 revision 复用索引;失败重建不替换上一成功快照,旧快照只保留一代供进行中的 viewer 回调使用。 -- 机器步骤读取 overlay 完成后的 `RecipeMap.mRecipeList`,保留共同原料、存在性条件、全部输出、物品/U/mB 批量、概率、原生状态与来源说明。模具、工具等物品催化剂保留在步骤说明和原配方中,不扩展为总览资源路线;未分类的普通物品/流体仍保留原生端口。 -- `MaterialWorldgenFacts` 读取当前活动配置,输出维度、高度、岩层、小矿和基岩事实;selection weight 与岩层 roll divisor 保留在说明中,不伪装成掉落概率。 -- `MaterialProcessSnapshot.Store` 在集成服务器和独立客户端分别由同步后的配方/标签重建;登录、断线、重载或换服后,旧 `DataKey` 与导航回调因快照身份变化而失效。 -- 未新增网络协议:客户端使用原版同步的 `RecipeManager`、已同步材料定义和同一 datapack 世界生成配置重建;导航再解析本代原生配方引用。 - -### 独立验收 - -检查集:D、F、J、A、C、G;同步或可选 viewer 接线涉及实际交互时加 M。 - -| 场景 | 通过条件 | -| --- | --- | -| 洗矿副产物 | 索引输出端口的材料、批量、概率和洗涤输入与最终配方一致;无依据的主/副角色标未知 | -| 合金 | Copper 与 Tin 为同一步的共同输入,不能由单一原料推成无条件获取 Bronze | -| 电解/离心 | 产物与 06 一致,选择器不计消耗;未授权材料不凭组成获得来源 | -| 世界生成 | 关闭某矿脉/维度后相应来源撤下;高度使用生成器实际映射,权重不显示为掉落概率 | -| 化学组成 | 含某元素的矿物不直接被记作该元素的纯形态来源 | -| 动态规则 | unit 查询不展开全部物理行;不支持族返回部分覆盖及原因,空结果不伪称完整 | -| 原生状态 | 模具形状、损坏工具和容器等限制不丢失;同物品 ID 不代表同一可匹配资源 | -| 重载 | 删除/替换最终配方后来源与用途同步变化;重复两次无旧边累积;快照版本不混用 | -| 多世界/远程 | 不同 server/配置会话不共享来源缓存;断线/换服丢弃旧引用;远程图与服务器版本一致 | - -## E:有界矿物处理图与消费者迁移 - -已提供 core 有界语义图、材料页直连查询、共享 Minecraft 投影、与 viewer 无关的可平移布局以及 JEI/EMI 分类。构造字段、角色、概率、三区分区、工艺组折叠、交互和生命周期契约统一见[矿物处理图展示接入](../material-process-display.md)。`unbound()` 现在只在没有成功发布快照时作为显式空状态,不再由正式注册路径常驻。 - -### 接入链 - -```text -D 已发布来源/用途索引 - → E core 有界语义图(步骤、端口、关联、覆盖) - → 共享 Minecraft 内容适配(形态、相态、原生配方引用、有限图标) - → MaterialProcessDisplay.Page - → JEI / EMI viewer 适配 -``` - -职责边界: - -- D 决定哪些关系存在及覆盖范围;E 决定如何在预算内查询和截断;展示层只做分区、平移、工艺组折叠、索引与交互,不读取配方表、材料目录或世界生成数据。 -- core 图先按查询预算完成遍历并返回不可变结果,再由内容适配器构造展示值。`MaterialProcessDisplay` 的 64 步、128 条关联、每步每侧 64 个端口和每端口 16 个图标是展示上限,不能代替图遍历的深度、节点、端口和边预算,也不能先枚举完整候选再截断。 -- 一个步骤保存联合输入与全部输出;主路线仅是布局提示,不得从槽位顺序推断主/副角色。未知角色、未知概率、未解析条件和部分覆盖必须继续可见,不能为了画出完整路线改写成确定边。 -- 图边只来自 D 的关系或明确确认的适配关系。显示层不得按相同图标补边,不把 tag/unit 代表图标当成候选全集,也不从显示图反向生成配方或授权。 -- 重载、断线、换服和 session 切换后,旧图、旧 `DataKey` 和旧导航回调都失效。导航适配器重新解析当前原生引用;失败时返回 `false`,不得跳转到新代次中的相似对象。 -- 材料事实投影与原生图标构造分离。`WorldgenInfoData` 的活动事实可以继续由旧 JEI/EMI 入口转发,但新图只消费同一 D 快照中的有效世界生成事实;EMI 原生页复用共享面板和图模型,共用类型不得引用 JEI 类。 - -### 步骤 - -1. 在 core 对 D 的关系做有界前/反向查询,保留步骤节点和端口;处理循环、共同输入、分支与明确截断原因。 -2. 建立材料矿物页:从实际 ore/raw/crushed 形态出发,主加工居中、副产物侧列,点击跳转原始配方或切换材料形态。 -3. 先接入一个 viewer 验证交互,再让另一 viewer 复用同一图模型;颜色、坐标和图标在客户端适配。 -4. `WorldgenInfoData` 的活动事实投影与原生图标构造分开,旧入口可暂时转发;材料来源不再要求 EMI 读取 JEI 的事实汇总类。 -5. 清理被替代的来源列表和展示反推;保留完整性信息,未知工艺不画成无条件可执行的实线。 - -### 实施结果 - -- `MaterialProcessGraph` 在 core 中保留 `SOURCES`、`USES`、`BOTH` 递归遍历,并新增材料级直连查询:覆盖该材料全部形态的直接步骤,但不沿另一材料继续递归,限制步骤、每侧端口和关联数量;循环按步骤访问集终止,稳定保留截断原因。 -- `MaterialProcessProjection` 只把已查询结果转成展示值。物品、流体、tag 和 unit 选择器保持独立引用;tag/unit 只提供有限代表,不展开候选全集。 -- API 1.9 增加 `SpecialProcessMethod`/`SpecialProcessValue`:辅料与目标材料使用同一 typed process key,`Target` 提供配方计划,`Reagent` 标记辅料输入。`SharedSpecialProcessRows` 生成并标记最终配方,`MaterialTagPack` 从相同规则派生 target/reagent 资源 tag。旧 `SourcePurifiedAcidData`、`SourcePurifiedAcidRules` 与 `SharedPurifiedAcidRows` 已删除。 -- JEI 与 EMI 共用 `MaterialProcessPanel` 和同一 `Page` 列表。工艺点击定位当前快照中的原生机器配方,资源左右击重新查询该快照的形态来源/用途。 -- `MaterialProcessPanel` 只折叠携带 method ID 的步骤;原先按步骤名达到阈值折叠的规则已删除,普通配方直接平铺。 -- JEI 与 EMI 的分类仅由客户端注册;`MaterialProcessSnapshot` 与 core 图不引用 viewer 类型,专用服务端可独立构建和查询。 - -### 独立验收 - -检查集:D、F、J、A、C、G、M;新增客户端资源或交付产物时加 B。 - -- 合金/分解/回收形成环时查询终止;深度、节点和输出预算都生效,结果标明截断。 -- 大 tag 或 unit 族的图大小不随全部候选笛卡尔积增长;至少用两档候选规模验证预算和索引复用。 -- ore、crushed、dust、molten 与状态敏感子类型不错误合并;联合输入和随机副产物不丢失。 -- 两 viewer 对同一快照导出的语义图一致,点击能定位对应原始步骤;显示图不反向生成配方。 -- 无 JEI/EMI 的专用服务端可启动、查询并重载;未加载任何客户端/可选模组类。 -- 两节点及远程客户端分别记录实际验证结果,不把纯图模型测试写成截图交互已通过。 - -验证分层: - -- JUnit/core:循环终止、共同输入、分支边、深度/节点/端口/边预算、截断原因、稳定排序、旧快照自洽和失败代不发布。 -- 双平台 GameTest:资源重载、数据包删除/添加、世界生成开关、tag/成分代次、无 JEI/EMI 的专用服务端查询,以及两次重载不累积旧边。 -- 独立远程客户端:只使用同步得到的同代 projection,断线、换服和旧回调拒绝;不得读取集成服务器共享内存。 -- 双平台人工游戏检查:JEI 正式材料页、精确配方跳转、形态来源/用途切换;EMI 接线完成后再单独记录,未安装 viewer 的行为也算独立场景。 - -实现核对、回归命令和未覆盖场景见[材料处理快照与共享图验证](../../integration/material-process-snapshot.md)。 - -## 交付顺序与完成条件 - -每个切片都能独立交付:A 的公共模型不要求先完成全图;B/C 的查询已有直接消费者;E 的展示切片可以独立验证输入校验与布局,但只有 D 提供正式关系后才可验证真实内容。D 先有准确的来源/用途列表和快照语义,再由 E 查询并绘图。每步保持旧 API 可用,迁移完一个消费者后再删除其重复数据。 - -初版完成要求 A—E 覆盖材料分类/组、形态、静态洗矿/合金/电解/离心、有效世界生成、unit 规则及两 viewer 的共享图;E 的未接入说明页不计入 D—E 完成。其他动态族允许明确列为部分覆盖,但不能写成“所有来源完整”。同步、生命周期和权限没有验证的部分不得计为通过。 - -检查代号与命令沿用[总计划](README.md#检查的使用方式)。原始快照、性能采样与截图留 `work/material-system-refactor/`;公共契约、纯图算法和稳定样例进入对应真实测试源码集。落地后同步包索引、API 使用文档和检查文档。 diff --git a/docs/development/material-system-refactor/README.md b/docs/development/material-system-refactor/README.md deleted file mode 100644 index 02ff7ec92..000000000 --- a/docs/development/material-system-refactor/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# 材料系统重构实施计划 - -本组文档用于把 [issue #351](https://github.com/GregTech6CE/GregTech6/issues/351) 拆成可实施、可逐份验收的工作。01 已建立可执行基线,验收范围与已知差异见[基线报告](../../integration/material-baseline.md);02 已完成注册、目录和 08-A/B 的定义与查询切片;03 已完成属性收敛、燃料闭环、08-C 实际形态绑定和资源 tag 桥接声明;04 已完成来源化候选裁决、有效成分快照、状态查询和双平台共享安装;05 已完成成分驱动的回收计划、数量表达、主要生产端迁移和重载诊断;06 已完成类型化分解声明、计划器和双平台执行验收;08-D 已发布同代来源/用途快照,08-E 已接入 core 图、生产投影、JEI 和 EMI。07 的最终整体验收仍需结合这些新入口执行双平台重载、远程客户端与人工 viewer 检查。尚未验证的运行期和平台场景不代表已经通过。阅读顺序为本页、对应分计划、该计划引用的现有架构与检查文档。 - -01—06 当前均已合入 master。07 的内部清理与 [07-E 注册项去留裁决](../../integration/material-refactor-07-roster.md)已实施;[07 清单](07-cleanup-and-acceptance.md)按当前源码列出 Reviewed/Source 类中的材料事实、通用配方模板、特殊配方与原生适配的处理方式,并以朱砂和铝土矿高压釜区分职责。08-D—E 的代码切片现已接入,07 最终整体验收转入运行期检查阶段。 - -[recipe 包补充审计](07-recipe-package-audit.md)记录通用材料转换目标、挤压/研钵/洗矿能力、透镜角色、相态绑定和固定物品成分登记的迁移结果,并区分保留的特殊配方与原生适配。 - -已完成的 01–03 简明范围、权威入口和兼容边界见[实施摘要](01-03-implementation-summary.md)。 - -[PR #374 非文档审查意见整理](pr-374-review-actions.md)汇总代码、行为与架构意见,已去重并按建议处理步骤组织;仅转述审查意见,未核验代码。 - -计划整理于 2026-11-07,代码核对基于 `d0ed1b0e561cd4b8a5e4d5f6028af38832077153`。issue 的调查基线为 `86c331b00`;其中材料数量、漂移数量和配方统计只作调查线索,不能作为当前验收结果。 - -## 问题与目标 - -当前材料注册有不同约束的入口,物品成分采用最后写入者覆盖,批量遍历与运行时查询又不包含相同的数据。回收和分解生产端各自补判定、换算和特殊分支,导致同一事实随注册顺序、查询路径和版本变化。 - -目标是让每类事实只有一处维护位置,让消费者共用解析结果和计算规则: - -```text -材料规范目录 → 注册校验与引用解析 → 材料属性、形态和分解规则 -物品成分声明/派生候选 → 冲突裁决 → 同一版本的成分快照 -材料规则+成分快照+输入状态 → 回收/分解计划 → 机器与版本适配 -``` - -“单一来源”指一个字段只有一个权威定义,可以按材料类别拆文件;物品的成分与材料自身的化学组成是两种事实,不能合成一张表。“统一提供者”允许不同机器的工艺规则不同,但不得各自重新解释成分和回收授权。 - -材料分类/tag、替代组、可成形态、获取途径和矿物处理图一并考虑,主材料保持身份、属性与 flag 的简洁模型。拟议 API 的边界、接口和快照语义见[设计提议 0001](../../decisions/0001-material-data-api.md);来源与图从有效配方及世界生成配置派生,不另建一套产物事实表。 - -## 分计划与依赖 - -| 编号 | 计划 | 前置完成项 | 本阶段可交付结果 | -| --- | --- | --- | --- | -| 01 | [建立基线与正确性对照](01-baseline.md) | 无 | 当前行为快照、已知差异、可运行的材料链路测试入口 | -| 02 | [统一材料注册与规范数据](02-material-registration.md) | 01 | 唯一注册校验、稳定身份、按材料维护的权威数据目录 | -| 03 | [整理属性与形态规则](03-properties-and-forms.md) | 02 | 稀疏属性与 flag 分工、单一形态判定与重量规则 | -| 04 | [统一物品成分解析](04-item-composition.md) | 01;接入材料身份部分需 02 | 显式优先级、冲突检测、查询与遍历一致的成分快照 | -| 05 | [统一回收计算与生成](05-recovery.md) | 02、03、04 | 共用输入判定、数量计算、回收生成和重载生命周期 | -| 06 | [统一材料分解](06-decomposition.md) | 02、03、04;复用 05 的发布与诊断约定 | 权限、配比、相态和单位共同驱动的离心/电解分解 | -| 07 | [清理与双平台整体验收](07-cleanup-and-acceptance.md) | 内部清理需 02—06;最终验收需 08 的接入切片 | 材料事实归位、特殊配方边界、旧数据和重复入口退出、消费端审计、全链路验收 | -| 08 | [材料标签、形态、来源与处理图 API](08-material-data-api.md) | A—E 分别并入 02—06,最后在 07 前整体验收 | 薄视图、领域查询、资源 tag 桥接、有效来源索引与共享处理图 | - -01—06 按前置项实施,04 的纯候选裁决规则可在 01 后先做。08 贯穿这些阶段:A 在 02 的接口定稿前完成,B/C 随 02—04,D 随 05/06,E 在 D 后;07 的内部清理已实施,最终整体验收仍在 08-D—E 后完成。每个分计划可以拆成多个小变更,每个变更都应能编译并通过对应检查;不要求把一整份计划塞进一次大改动。“独立验证”指在前置项成立后,本阶段有自己的输入、断言和完成条件,无需等待 07 才确认正确性。 - -## 共同实施约束 - -1. **正确性依据**:现有 [parity 决策](../../decisions/parity/README.md) 优先;其次是固定 GT6 提交 `3703e40308c8c030763fd6297dea8b210d2a77b1`,再参考本仓库 NeoForge、Forge 实现。当前快照只证明现状,不自动成为正确答案。没有依据的差异保持待裁决,不通过更新快照掩盖。 -2. **源码层**:纯声明和内容事实放 core 的 `content.material`/`content.recipe`;通用计算与解析放 core 的 `engine.material`/`engine.recipe`;`ItemStack`、游戏注册表和原生流体适配留在共享 Minecraft 层。公开契约属于仓库内 `api/`。不新建平行的整套框架。 -3. **身份兼容**:默认保留材料数值 ID、注册名、物品/流体 ID、配方身份和持久化单位。附属材料沿用当前命名、所有权和宿主分配 ID 规则;动态附属 ID 不作为跨环境稳定存档标识。需要改变身份或已公开签名时,先列影响与迁移,再修改。 -4. **生命周期**:计划 02 明确材料定义、链接和定稿的实际调用边界;计划 04、05 单独处理标签/配方重载。不得把可重载的成分和配方永久冻结在首次类初始化中,也不得擅自提前拒绝现有合法附属链接回调。 -5. **渐进替换**:旧门面只转发到新权威,不继续存一份可变事实。允许测试中比较旧/新计算;生产中每个已迁移配方族只能有一个写入者。保留的兼容入口要列消费者和退出条件。 -6. **数据与生成**:选择 Java 类型化声明作为本次规范目录的起点,复用现有构建,避免为第一步额外引入解析器。一次性 GT6 抽取/导入脚本放 `work/local-tools/`;共享目录校验优先使用 JUnit。以后确需长期投影工具时,放 `tools//` 并附 README;其输入为已提交的规范数据,不依赖未记录的本地上游 checkout。详见[文件归属](../repository-layout.md)和[资源指南](../../architecture/resources.md)。 -7. **范围**:形态和材料去留逐项审计;有消费者的内容不会因为“生成量大”自动删除。损坏物品、多组件热回收、燃料灰烬和熔炼授权先核对工艺依据,再确定规则。 - -## 检查的使用方式 - -所有检查从仓库根目录执行,具体命令、注意事项和报告位置引用以下现有文档,不在每份计划重复维护命令: - -| 检查代号 | 当前入口 | 适用情形 | -| --- | --- | --- | -| D | [文档与路由检查](../../../tools/validation/README.md#命令) | 本组文档、路由与检查文档一致性;还需人工检查新增文档的相对链接和锚点 | -| F | [format](../validation/checks/format.md#运行命令) | 每次生产代码或测试代码改动;不得扩大排除范围 | -| J | [junit](../validation/checks/junit.md#运行命令) | 纯计算、目录校验、数据归一化;涉及 API 时包含相应模块 | -| A | [api-contracts](../validation/checks/api-contracts.md#运行命令) | 改变公共签名、异常、契约或生命周期;版本变化还需同步 API 文档与提交说明 | -| C | [compile](../validation/checks/compile.md#运行命令) | 两节点生产编译,含 core 到游戏层的调用变化 | -| G | [gametest](../validation/checks/gametest.md#运行命令) | 两节点运行期注册、查找、拒绝、消耗与重载 | -| B | [assemble](../validation/checks/assemble.md#运行命令) | 生产资源变化与最终交付;检查发行包不含测试和临时文件 | -| M | [manual-ingame](../validation/checks/manual-ingame.md#运行命令) | tooltip、客户端配方展示、实际操作与机器界面 | - -实施时先按[验证与验收流程](../validation/README.md#工作流程)路由实际改动路径,再取该分计划检查集的并集。路由未自动包含某个运行场景不构成省略它的理由。G 应分别执行两个节点,确认实际执行用例数和失败数,不能只看 Gradle 退出码;C 不代替 G。 - -01 已在共享 `minecraft/src/test` 接入材料领域 `MaterialBaselineTests`,复用 `gt6ce` namespace 与现有模板。后续测试继续按领域扩展,不新建 per-issue JavaExec。现有 crafting TSV 只能表达其已有级别,不能直接承载机器回收/重载断言;涉及这类场景时使用材料领域测试,只有模式稳定后才提炼案例表。 - -## 每个阶段的交付记录 - -每个小变更需给出:改动文件、已替代入口及消费者、行为差异和依据、执行检查及结果。原始 dump、日志、对比脚本和截图放 `work/material-system-refactor/`;经人工确认的期望数据才进入相应 `src/test/resources`。跨平台的长期结论按 [integration](../../integration/README.md) 格式整理,GT6 行为偏离写入 parity。 - -验收记录必须分别写“执行且通过”“执行但失败或阻塞”“尚未执行”,标明节点、样例、首次启动/重载/附属环境覆盖。任何未裁决差异不能计为通过;外部环境阻塞时保留具体原因。 - -## 需要事实裁决的项目 - -| 项目 | 裁决所在阶段 | 裁决方式 | -| --- | --- | --- | -| 多组件热回收、输出槽限制与无法表示的余量 | 05、06 | 逐机器核对规则,不要求所有工艺都产出全部成分 | -| chain、minecartWheels 及兼容 prefix 的去留 | 07 | 同时检查实际消费端、外部声明契约和已有存档影响 | - -01 已完成测试与基线采集,并清理形态表的一个无效抽取键;02 已完成唯一安装、规范目录、最终角色定稿、附属 metadata/tag/group/process/定义期 form 快照,以及 API 1.6 的主定义与附属域注册拆分;03 已完成燃料与属性快照、Phosphor `MELTING` 裁决、统一形态规则、`Any*` 消费者迁移、运行期 item/block/fluid 绑定及 API 1.7 的形态视图;04 已完成带来源优先级的成分裁决、查询一致快照、状态与授权拆分和双平台共享安装;05 已完成回收计划、精确数量分组、主要物品/流体生产端与重载闭环;06 已完成 API 1.8 的类型化分解声明、纯计划器、配方切换及双平台执行验收;07 已完成首轮内部清理和 07-E 全量材料/形态去留裁决;08 已完成静态机器配方、活动世界生成、符号选择器和两 viewer 的共享处理图接入,并通过 API 1.9 接入纯化酸 target/reagent 规则与通用特殊工艺 producer。07-F 仍由双平台运行期与人工验收闭合。本页不替代现行架构或已接受的决策。 diff --git a/docs/development/material-system-refactor/pr-374-review-actions.md b/docs/development/material-system-refactor/pr-374-review-actions.md deleted file mode 100644 index bae33a801..000000000 --- a/docs/development/material-system-refactor/pr-374-review-actions.md +++ /dev/null @@ -1,146 +0,0 @@ -# PR #374 非文档审查意见整理 - -本页汇总 [PR #374](https://github.com/GregTech6CE/GregTech6/pull/374) 中与代码、行为、架构和发布决策有关的审查意见,合并重复问题,供后续分步处理。整理日期为 2026-11-12;审查针对的提交为 `a7c03f27759396b8d918ef7186719f0395373aec`。 - -**状态:审查意见已由用户确认属实。步骤三至七均已完成代码修复;2026-11-12 复核补正后通过双平台编译与全量 GameTest(Forge 92/92、NeoForge 97/97)。本页记录各步骤的验收边界,不据此宣称客户端交互、第三方模组联动或整个 PR 已验收。** - -不收录 docs 目录定位、文档迁移、索引、模板、报告、计数、链接、清理表、parity 记录及文档披露要求。混合意见仅保留其中的实现问题与行为选择,例如保留 API 兼容性变化,排除“文档未披露”的要求。 - -## 来源与阅读方式 - -| 代号 | 来源 | 范围 | -| --- | --- | --- | -| C1 | [lombinaxmasson 的复核评论][C1] | 测试导入、分解输入、热回收比例、外部矿石转换 | -| C2 | [takanashisatou 的架构建议][C2] | 成分优先级、注册结构与同级覆盖策略 | -| R | [Tanimodori 的完整审阅][R] | 回收、成分、生命周期、行为差异、兼容性与设计分歧 | - -读取范围包含 PR 讨论评论与正式 review;读取时没有行内审查评论。正式审阅末尾的结论及测试说明已归并到对应问题,不重复列项。 - -以下步骤是建议处理顺序。步骤一可先独立完成;步骤二处理明确提出的行为问题;步骤三至六处理结构与契约;步骤七集中裁决尚未确定的行为。涉及相同决策的项目通过编号引用,避免重复安排。 - -## 步骤一:恢复测试源码编译 - -- **1.1 补齐 JUnit 断言导入(C1 标为 P1)。** 审查指出 `GregTechAddonsTest` 使用了未导入的 `assertEquals`、`assertTrue`,`MaterialViewTest` 缺少 `assertEquals` 导入;所引用的 CI 有 24 个 `cannot find symbol`,后续构建与发布任务被跳过。先修复导入,再由实施任务执行对应检查。[C1][R] - -## 步骤二:处理配方与数量问题 - -- **2.1 无流体绑定时保留固体分解入口(C1 标为 P2)。** 审查指出 `MaterialDecompositionPlanner` 在无 liquid/gas 绑定时推断 `1000 mB/U`,`DecompositionRecipeLoader` 随后认为流体入口已发布并跳过固体入口。示例为 `AluminiumAlloy`:45U 被转换为 45000 mB,原有 45 粉末/5 粉块入口消失。建议取消无声明绑定的通用流体兜底,按实际绑定决定流体入口,否则走固体入口。[C1][R] - -- **2.2 附属材料热回收按声明比例与权限生成(C1 标为 P2)。** `SharedThermalRecyclingRows.planDeclared()` 被指出只使用绑定字段名,再从 `MoltenFluidHandler.ratio()` 取得 144 mB/U,忽略声明的 1000 mB/U;`BaselineThermalAddon` 可触发该差异,`MaterialBaselineTests` 还把 144 写成期望值。另缺少 `MELTING`/`BLACKLISTED_SMELTER` 检查。建议一并修正单位来源、准入判定和相应测试期望。[C1][R] - -- **2.3 恢复外部 ore tag 的手工转换(C1 标为 P2)。** `CraftingMaterialForms.tagged()` 要求成分快照,但 `ExternalOreProcessingRules.COMPOSITION_FORMS` 不含 `ore`,使仅带 `forge:ores/tin`/`c:ores/tin` 等标签的外部矿石无法进入 `nativeAliases()`,矿石到原矿的配方生成与合成校验均受影响。建议补齐外部 ore 形态进入成分与转换链路的路径。[C1] - -- **2.4 区分 Shredder 静态行与动态回退工时。** 审阅指出静态前缀行使用了 2/64/256,而所引用的 GT6 静态倍率为 256/16;2/64/256 属于动态回退公式。同时缺少 `STRETCHY`、`BOUNCY`、`MEAT`、`ROTTEN` 条件,Quartz 仍按名称识别。建议按两种入口分别确定规则,并与 3.2 的工时收口一起实施。[R] - -- **2.5 统一缺失组件或输出时的处理策略。** 审阅多处指出:多组件回收缺少 pulver target、分解产物绑定失败或缺少输出时,会拒绝整条配方;其引用的 GT6 行为是跳过该组件并保留可生成部分。这里合并为一个策略项,分别覆盖 Shredder 与分解器;需要决定恢复部分输出还是保留整条拒绝,并统一相关分支。[R] - -- **2.6 补齐 tag 派生形态的炉配方接替。** 审阅指出 tag 派生的 dust/gem/crushed 没有相应原版炉行,而 `hasMaterialProcessingRule()` 会删除外来炉行,可能出现删除旧配方后没有新配方接替的缺口。建议把删除条件与实际可发布的替代行关联起来。[R] - -## 步骤三:收敛回收计算、发布和所有权 - -- **3.1 材料数量到粉尘栈只保留一套权威。** `MaterialRecoveryRules.dustPlan()` 按栈上限拆分并报告余量,`OM.dust()` 则选择单栈表达,不同消费者可能得到不同结果。建议明确权威计算入口,让另一个入口转发或退出,并明确单栈调用方如何处理多栈与余量。[R] - - **已修复:** `dustPlan()` 是完整输出权威,`dustSlotPlan()` 是同一算法的单栈视图;`OM.dust()` 使用单栈视图,`OM.dustAll()` 保留全部栈。分解、零件余料、流化床和外部矿石等可容纳多输出的入口改用完整列表,Dust Funnel 按单栈计划实际表示量扣减库存。 - -- **3.2 工时计算统一进入共享计划器。** `MaterialRecoveryRules.shredderWork()` 与 `CapsuleCellRecipes.registerRecycling()` 分别维护公式。建议在完成 2.4 的静态/动态规则裁决后,让各生产端读取同一工时规则,避免继续内联另一份公式。[R] - - **已修复:** 胶囊回收改为调用 `planShredderStatic()`,输出形态和时长均来自共享静态计划,不再内联 `(work + 8) / 9`。 - -- **3.3 每个配方族只有一个发布者与一份形态集合。** `CapsuleCellRecipes`、`StoneVariantRecipes`、`OreProcessingRecipeLoader`、`AnvilForgingRecipes` 被指出仍直接写入 Shredder/Anvil 行,`RecoveryRecipeConflicts` 仅做仲裁;热回收的 `RECYCLABLE` 与粉碎使用的 `RecyclablePrefixes` 又并行维护。建议把这些路径纳入按族归属的统一发布入口,并收敛形态集合,防止同一输入由不同路径生成不同数量。[R] - - **已修复:** 上述生产端及热回收、外部矿石、原生矿石回收路径统一经 `RecoveryRecipePublisher` 发布,并声明所属 family。Shredder 与热回收的形态准入集中到 `RecoveryFormCatalog`。 - - **复核补正:** `SourceDustThermalRecipes`、`SourceThermalNativeAdapter` 和 `OreProcessingRecipeLoader` 的兼容热回收路径此前仍直接写 Melter/Smelter,`VanillaStoneMachineRecipes` 的石质 Smelter/Shredder 也仍直接写 map。现在这些路径分别以 explicit/generic ownership 经统一发布器提交,不再绕过 typed ownership、去重和冲突处理。 - -- **3.4 类型化回收行所有权,并建立输入索引。** `RecoveryRecipeConflicts.generic()` 依赖 `mSource` 的 `-generic` 后缀;`guardedCollision` 未命中后扫描全部配方,审阅认为两万余行规模下可能形成 O(N²) 发布成本。建议用结构化所有权替代命名约定,通过按输入建立的索引完成所有者与冲突查询。[R] - - **已修复:** 回收行在 `Recipe` 上携带 typed generic/explicit ownership;`RecoveryRecipePublisher` 不再解析来源字符串,并在 `findCollision()` 未覆盖 guarded rows 时只查询 `RecipeMap.mRecipeItemMap` 的候选输入桶。 - -## 步骤四:明确成分裁决与附属兼容契约 - -- **4.1 显式提交来源与优先级,并裁决同级冲突。** 两位审查者都要求减少隐式推断,但方案不同:C2 建议在 `ItemMaterialRegistry` 用显式整数优先级及默认值,按 `(key, priority)` 存储,同键同级后写覆盖并告警;R 建议显式受控来源类别,保留同层不同内容失败与覆盖链。共同问题是 `ItemCompositionSource.fromLegacy()` 依赖 `block composition`、`cr.rev`、`common form tags` 等文本反推类别,方块重量与 CR.REV 生产端仍提交旧字符串。先确定冲突契约,再迁移生产端、移除文本反推;两种同级处理方案互斥,不能合并为已达成共识的实现要求。[C2][R] - - **已修复:** 采用受控来源类别:同一优先级只有内容与回收授权完全一致时才合并,不同内容继续失败;显式覆盖仍要求命名现存声明并保留覆盖链。`fromLegacy()` 不再从自由文本猜测类别,旧调用统一标为 `LEGACY`。方块重量、CR.REV、机器构造、运输构件、木材及物品构造器自注册已改为提交结构化来源。 - -- **4.2 保留落选候选及原因。** 审阅指出 `ItemCompositionResolver.resolveItem()` 在首个有胜出者的层返回,`EFFECTIVE` 只保留胜出者,低层候选与淘汰原因不可查。建议提供每个物品的完整裁决诊断,包含胜出来源、落选来源及原因。[R] - - **已修复:** `ItemCompositionResolver.resolveDetailed()` 返回 `ItemCompositionResolution`,逐项保留 `SELECTED`、`REPLACED`、`LOWER_PRIORITY` 候选及原因;`ItemMaterialRegistry.compositionDiagnosis()` 发布与有效快照同代的诊断。tag generation 更新和撤销会同步替换或移除诊断。 - -- **4.3 处理旧注册与查询接口的兼容性变化。** `register(Item, ItemComposition)` 被指出从后写覆盖变为同声明 ID 冲突失败,可能使依赖重复注册的附属启动失败;其最终策略依赖 4.1。另有多组分 legacy 行的 `material()`/`amount()` 从首组件及其数量变为 `INVALID`/0,以及 `recoverable()` 被移除。需要分别决定保留旧行为、提供兼容入口或接受契约变化。[R] - - **已修复:** 弃用的 `register(Item, ItemComposition)` 为兼容入口:同一物品的重复旧调用保留最后写入语义,结构化提交仍执行严格冲突检查。legacy 多组件构造恢复首组件主材料及其数量;`recoverable()` 以弃用方法恢复并转发 `bulkRecoveryAllowed()`。 - -- **4.4 确认 API 版本与发布坐标的变更决策。** 审阅要求确认 API 1.7 → 1.8 的批准来源及发布坐标变化。本项仅保留版本与发布决定,不纳入提交说明或文档同步要求;审阅对授权的质疑不代表本次已核实存在未经授权的变更。[R] - - **已确定:** 保留累计功能对应的 API `1.8.0`;API 1.4—1.8 依次承载材料定义目录、解析处理键、材料信息工具、形态视图和 1.8 的类型化分解规则,因此不能只记为 1.7。发布坐标仍为 Maven `gregtech:gt6ce-api:1.8.0`,只递增版本,不改 groupId、artifactId 或 SDK 组成。 - - 验证:`:api:check`、`:core:test`、双平台生产与测试源码编译、ratchet Spotless、路由与注释检查通过;Forge 1.20.1 全量 GameTest 90/90,NeoForge 1.21.1 全量 GameTest 95/95。首轮 Forge 运行暴露 Stone 铸模主材料兼容回归,修复后最终全量运行通过。 - -## 步骤五:收敛分解声明与数据消费 - -- **5.1 明确 typed rule 与 flag 谁是权威,合并派生映射。** 审阅指出 catalog 写入 `CENTRIFUGE`/`ELECTROLYSER` flag,`MaterialDefinitions.attachDecomposition` 据此生成类型化规则,`MaterialInfoRegistry.syncDecompositionFlags` 又回写 flag;属性到分解路线的映射还在两处重复。建议确定唯一声明来源与单向派生关系,消除往返同步和重复默认语义。[R] - - **已修复:** 路线与相态统一由 `DecompositionMaterials` 声明,规范材料目录不再保存三个分解兼容 flag。`MaterialDefinitions` 一次生成 typed rule;冻结期只把 rule 单向镜像到 `GTMaterial`。旧附属 flag 仅在没有 typed rule 时作为兼容兜底。 - -- **5.2 检出未被消费的分解数据行。** `DecompositionMaterials.input()`/`thermal()` 对没有匹配活动声明的 `(id, name)` 返回 null,审阅认为缺少反向检查。建议让每条数据行都明确属于已消费或有意停用,避免孤儿行静默失效。[R] - - **已修复:** 规范目录装配后反向检查全部相态行和路线。重复、无所有者、typed rule 未保留或路线不一致均在初始化时失败;显式停用集合为空,停用行必须登记后才能跳过。 - -- **5.3 确定流体内容范围是否先于绑定定稿。** 审阅指出 [issue #369](https://github.com/GregTech6CE/GregTech6/issues/369) 关于熔融态及 EMI/坩埚/液化炉配方的取舍仍未决,而本次已确定 69 个材料的液体/气体绑定。需要决定该议题是否是绑定与默认规则定稿的前置,避免内容范围收缩后再次重做。[R] - - **已确定:** 不是前置。typed 分解规则保留固定来源的候选流体身份与单位换算;原生流体注册、EMI 展示、坩埚与熔化器配方属于运行时内容投影。issue #369 收缩范围时,对应绑定按既有诊断缺失;扩展展示时也不改分解规则本身。 - - 验证:完整 `:core:test` 171 个 JUnit、ratchet Spotless、路由与注释检查通过;Forge 1.20.1 全量 GameTest 90/90,NeoForge 1.21.1 全量 GameTest 95/95。 - -## 步骤六:明确快照生命周期、失败边界与分层 - -- **6.1 材料、成分与配方使用一致的发布版本。** 审阅指出 `MaterialInfoRegistry.freeze()` 一次性冻结,`MaterialViews.revision()` 恒为 1,成分 revision 与 `MachineRecipeOverlay` generation 分别递增,缺少统一发布点。需要决定在 08-D 前引入共同 stamp/发布服务,还是采用平台侧快照加 core 纯查询的设计,并明确材料定义不可重载是长期契约还是阶段限制。[R] - - **已修复:** 明确材料定义与显式成分是进程内静态契约,标签成分和配方按平台代次重新发布。新增 `MaterialPublication` 稳定 stamp;`MachineRecipeOverlay` 仅在整代成功后提交材料、成分 revision 与 overlay generation,失败代保留上一份成功戳。`MaterialCatalogView.revision()` 返回材料定义版本,配方查询版本同时观察该稳定戳。 - - **复核补正:** `ItemMaterialRegistry.beginTagGeneration()` 现在返回代次检查点。overlay 在开始重建前捕获上一代标签候选、有效成分、诊断、readiness、tag generation 与 composition revision;失败恢复时整体回滚该检查点,再恢复 baseline 与配方 owner。失败代不会留下“旧 stamp 指向已改变成分状态”的不一致。 - -- **6.2 建立 server/level/会话边界。** `ItemMaterialRegistry` 的 `EFFECTIVE`、`COMPOSITION_REVISION`、`explicitClosed`、`tagInputReady` 被指出是全局静态状态,后两个标志只置位不复位。建议明确多服务器、多世界及切换存档时的状态归属、重置与快照获取方式;本项与 6.1 一起确定生命周期。[R] - - **已修复:** `beginTagGeneration()` 在每代 overlay 与服务端停止时递增 tag generation、撤销上一代标签候选并进入未就绪状态,完整发布后原子替换 `EFFECTIVE`。`compositionState()` 暴露 revision、代次、readiness 与显式关闭状态。`explicitClosed` 是有意保持的 JVM 生命周期契约,不在世界或资源重载时复位。 - -- **6.3 统一异常策略与失败影响范围。** 审阅指出成分同级冲突终止启动、分解失败仅告警跳过、回收冲突则可能触发整代 overlay 回滚,单个附属或数据包冲突会波及全部动态行。建议明确何时启动失败、跳过单行或整代回滚,并与 4.1 的冲突契约一致。[R] - - **已修复:** 策略固定为:显式成分歧义、静态内置配方冲突及初始化结构损坏终止启动;外部 tag/数据包/附属派生的单行回收冲突通过 `publishIsolated(...)` 告警并跳过;分解候选保留逐项拒绝诊断;非行级结构性异常整代回滚到 baseline。动态 Shredder、热回收、外部矿石和源矿石适配路径已接入单行隔离。 - -- **6.4 消除新增的 content/engine 双向知识依赖。** 审阅列出 `MaterialRecoveryRules` 依赖 `engine.material.ItemComposition`、`MaterialDecompositionPlanner` 依赖 `content.recipe.SourceDecompositionRules`;另有 `ItemMaterialRegistry.authorizesMaterialProcessingRule()` 直接依赖 `VanillaCompositionLoader.inheritsVanillaUnification()`,使 registry 知晓 MoldBlock、ClayMoldCatalog、LootChestBlock、MetalChestBlock。建议将内容事实留在内容层,以规则或声明输入通用引擎。[R] - - **已修复:** 单位换算移入 `engine.recipe.UnitConversion`;回收计算拆为引擎层 `ItemRecoveryPlanner` 与内容侧 `MaterialFacts` 适配。原版炉授权随 `ItemCompositionSource` 提交,模具与箱子的空内容语义经 `ItemMaterialRuntimeFacts` 注入。材料 registry 不再直接引用 `VanillaCompositionLoader`、`MoldBlock`、`ClayMoldCatalog`、`LootChestBlock` 或 `MetalChestBlock`。 - -- **6.5 清理无消费者 API。** 审阅将 `MaterialInfoRegistry.compositionDefinition` 列为无调用者的死 API,建议在兼容边界明确后处理其去留。[R] - - **已修复:** 删除 `MaterialInfoRegistry.compositionDefinition(...)`;组成读取保留公开 `MaterialInfoTool.composition(...)` 与内部当前快照入口,不保留重复的冻结访问 API。 - - 验证(2026-11-12): - - 执行且通过:`:core:test` 171 个 JUnit;`compileBothPlatforms`;Forge/NeoForge `compileTestJava`;`:minecraft:spotlessCheck`;Forge 1.20.1 全量 GameTest 90/90,NeoForge 1.21.1 全量 GameTest 95/95。GameTest 覆盖两次真实资源重载、标签代次重置、稳定发布戳和单行冲突隔离。 - - 执行但失败:`:core:spotlessCheck` 与节点级 `spotlessCheck` 仍报告本步骤未修改文件的导入顺序问题;未在本步骤顺手改写。 - - 尚未执行:客户端界面手工检查。本步骤没有新增客户端交互或网络格式。 - -## 步骤七:逐项裁决保留或恢复的行为 - -本步骤只列行为选择,不包含新增 parity 文档的要求。2.1、2.2、2.4、2.5、2.6 已收录的差异不再重复;下列项目均已按 GT6 行为修复。 - -| 项目 | 裁决与实现 | -| --- | --- | -| 损坏物品的固定输出回收 | **恢复比例回收。** Shredder 查询从损坏栈的剩余 `ItemComposition` 重新执行共享计划,再生成该次实际输出;静态 prefix 行保留 16/256 规则,动态行保留 2/64/256 规则。`RecipeMap` 为带运行时解析器的行提供执行期配方,guard 固定预期耐久并重新检查回收准入。[R] | -| 朱砂专用热回收与输入证明 | **移除特例。** 删除 9114/`Cinnabar` 的 Melter/Smelter 硬编码及 `captureCinnabarBlock`;`ThermalRecoveryOwnership` 中遗留的 9114/dust/crushed 前缀所有权也已删除,朱砂不再绕过 `MELTING`、`BLACKLISTED_SMELTER` 和常规相态绑定。`emitWholeDustMetal` 的 Ti/Fe 分数组仍按原审核边界保留,并有 GameTest 防止朱砂重新进入特殊所有者集合。[R] | -| 物品级回收授权 | **恢复原行为。** `bulkRecoveryAllowed` 仅作为 legacy 构造参数和兼容访问器输入保留,规范构造时统一归一为 `true`;回收准入改由有效成分、形态、具体工艺与栈状态决定,`canMelt` 继续独立。[R] | -| tag 形态覆盖范围 | **补齐。** common form tag 新增齿轮、小齿轮、环、螺栓、螺丝和箔;`storage_blocks` 与 `cables` 作为没有一对 `MaterialPrefix` 身份的 tag 组直接生成 9U 与 1/2U 成分候选。ore 转换缺口仍由 2.3 的专门路径处理。[R] | -| 胶囊专用回收行 | **保留为平台适配,不另立规则。** `fluid_cell_*` 是端口对 GT6 `capcellcon` 具体材质变体的表示,空壳按 1/9U 输出,时长由 `planShredderStatic()` 的 16/256 静态规则计算;盛装内容物的胶囊仍不回收。[R] | -| 铜块跨平台回收授权 | **统一。** `VanillaMaterialCorrections.copper()` 在两个平台都执行;两平台共同存在的 `minecraft:copper_block` 提交 9U Copper 修正成分,版本独有铜变体按物品存在性跳过。[R] | - -验证(2026-11-12): - -- 执行且通过(复核补正):`compileBothPlatforms`;两节点 `compileTestJava`;`:minecraft:spotlessCheck`;Forge 1.20.1 全量 GameTest 92/92,NeoForge 1.21.1 全量 GameTest 97/97,包含失败代整体回滚与朱砂普通所有权回归。 -- 执行但失败:节点级 `spotlessCheck` 仍报告 `HopperClientModels`、`PipeWireClientModels`、`GTIconSetBlocks`、`GTRemainingIconBlocks` 等本轮未修改文件的既有导入顺序问题;共享 `:minecraft:spotlessCheck` 已通过。 -- 执行但失败:`:core:spotlessJavaCheck` 仍报告本轮未修改的 `NutritionRemovalTest.java` 导入顺序;本轮 core 文件已按同一 Palantir 2.103.0 格式化,未改写该无关文件。 -- 尚未执行:客户端交互与 JEI/EMI 展示手工检查;没有真实第三方模组提供新增 storage block/cable tag 成员,tag 映射由静态表和现有资源加载链路覆盖。 - -[C1]: https://github.com/GregTech6CE/GregTech6/pull/374#issuecomment-6797033166 -[C2]: https://github.com/GregTech6CE/GregTech6/pull/374#issuecomment-6798836766 -[R]: https://github.com/GregTech6CE/GregTech6/pull/374#pullrequestreview-5861956940 diff --git a/docs/development/repository-layout.md b/docs/development/repository-layout.md index 8065491f2..118cfd3cf 100644 --- a/docs/development/repository-layout.md +++ b/docs/development/repository-layout.md @@ -36,16 +36,14 @@ | 检查选择、注意事项和运行命令 | [validation](validation/README.md) | | 分层、系统原理与资源机制 | [architecture](../architecture/README.md) | | 包职责、边界与验收条件 | [architecture/packages](../architecture/packages/README.md) | -| 跨平台、跨模组与上游对照结论 | [integration](../integration/README.md) | -| 交付与实例更新流程、脱敏执行记录 | [operations](../operations/README.md) | | 长期取舍与原版差异 | [decisions](../decisions/README.md) | | 单个开发工具的依赖、参数与输出 | 对应 `tools//README.md` | -顶层文档入口以导航为主;正文放在所属专题,其他页面链接引用。工作过程先留在 `work/<任务名>/`,形成可复用结论后再归档。 +顶层文档入口以导航为主;正文放在所属专题,其他页面链接引用。工作过程、计划、审查和验证报告先留在 `work/<任务名>/`,只有形成长期开发者约定后才提炼回架构、开发、验证或决策文档。 ## 临时内容如何沉淀 -例如排查管道传输问题:一次性分析脚本与完整日志放 `work/fluid-pipe-check/`;可复用的检查器整理到 `tools//` 并在该目录 README 记录用法;跨平台行为结论放 `docs/integration/`;算法边界补到架构文档;若确实执行了实例更新,再写 `docs/operations/records/`。无需给每次小改动建立长期记录。 +例如排查管道传输问题:一次性分析脚本与完整日志放 `work/fluid-pipe-check/`;可复用的检查器整理到 `tools//` 并在该目录 README 记录用法;稳定算法边界补到架构文档,长期兼容取舍补到决策文档。无需给每次小改动建立常驻记录。 开发用探针优先放 `work/`,不会自动参与生产编译;若要长期保留为自动测试,接入合适测试源码集及依赖,并记录运行命令;测试目录与案例表约定见[验证与验收](validation/README.md)。不要把探针改名成业务类混入 `src/main/java/`。 @@ -59,7 +57,7 @@ ## .gitignore 的边界 -规则覆盖构建、运行实例、IDE、本地环境、工具缓存与 `work/`,保留 Wrapper JAR、资源 JSON、生成内容表和 `docs/operations/records/`。历史本地笔记位置继续忽略,新笔记使用 `work/`。 +规则覆盖构建、运行实例、IDE、本地环境、工具缓存与 `work/`,保留 Wrapper JAR、资源 JSON 与生成内容表。历史本地笔记位置继续忽略,新笔记使用 `work/`。 不要用 `*.jar`、`*.json`、`*.md` 或任意 `generated/` 的全局规则掩盖真实输入;也不要随意 `git add -f`。`.gitignore` 不影响已跟踪文件,也不保护秘密;若凭据已经提交,仅新增忽略规则不能消除泄露。 diff --git a/docs/development/validation/README.md b/docs/development/validation/README.md index 91d29e46b..9710ceb07 100644 --- a/docs/development/validation/README.md +++ b/docs/development/validation/README.md @@ -28,7 +28,7 @@ 交付时分别列出“执行且通过”“执行但失败或阻塞”“尚未执行”,写明实际命令、失败原因与未覆盖的平台或场景。编译、打包、自动测试和游戏行为分别判定,不能相互代替。 -长期结论按场景使用“未验证 / 部分验证 / 在下述范围验证通过 / 已知失败”,记录源码状态、环境版本、操作、预期与实际结果。使用[验证结论模板](../../integration/report-template.md)或[执行记录模板](../../operations/records/TEMPLATE.md)保存可复现结论;原始材料的归属见[文件与产物归属](../repository-layout.md#临时内容如何沉淀)。 +按场景使用“未验证 / 部分验证 / 在下述范围验证通过 / 已知失败”,在交付结果中记录源码状态、环境版本、操作、预期与实际结果。原始日志、截图和一次性复现材料放 `work/<任务名>/`;只有会影响后续开发的稳定规则才写回验证或架构文档。 ## CI diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 677c9fb5f..b1f8c3992 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -20,7 +20,7 @@ ### 矿物处理展示页 -接口与测试输入契约见[展示接入](../../material-process-display.md)。生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用展示模型和面板;EMI 从最终可见配方构造视图,JEI 使用 GT 原生快照。 +生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用展示模型和面板;EMI 从最终可见配方构造视图,JEI 使用 GT 原生快照。 EMI 数据源还需核对:工作台压块/拆块、熔炉和已安装第三方机器均进入材料页,GT 机器不重复;包含空网格的有序合成进入加工图,不因占位变成信息卡片;没有实际输入的行不能成为加工来源。通用物品/方块/流体标签及候选浏览页不出现在信息区;GT 材料单位输入说明仍可打开。GT 材料单位模板即使 `supportsRecipeTree=false` 仍保留原生材料单位与概率;工具装配和可读取的第三方非树加工进入图中并使用未确认关系。结构、说明、动态模式与木桶查询别名不产生加工边;缺少输入/输出及不支持 ingredient 类型的条目仅保留为相关信息。零数量工具只作为催化剂,不使整条配方降级。相同 EMI ID,以及同分类下仅注册 ID、槽位顺序或网格占位不同的等价加工行不重复;数量、概率、原生状态或工具不同的行继续保留。关联只取明确主材料/流体绑定,次要成分不带入额外信息卡片;相同非空 EMI ID 的信息页不重复。来源区底部的信息卡片应使用本材料图标并直接打开对应原页面,只有相关信息的材料也能查询;全屏和嵌入视图下均核对点击、tooltip、平移缩放与裁剪。任一不支持槽不能静默消失。超过每侧 128 槽、512 步或 4096 条关联时,确认默认材料页保留全部直接数据且重载可完成;人为指定有限预算时才出现相应截断提示。加入坏记录时应有诊断日志和覆盖提示,其余有效路线仍可查询。tag 的同材料候选保持一个 selector,跨材料候选不归到任一单一材料。隐藏、延迟注册、资源重载与重新入服后页面跟随当前配方,旧导航失效。EMI 初始化和连续重载不能提前构造所有材料图或展开生产者/消费者的连接乘积;日志应出现材料索引完成记录。检索输入、工具及产物不按配方出现次数重复,首次打开才构建详情,仍须保留完整原生批量及概率。未安装 EMI 时确认客户端及专用服务端不加载 EMI 类型;JEI 单独核对其原生快照覆盖范围。 diff --git a/docs/integration/README.md b/docs/integration/README.md deleted file mode 100644 index fa3eae2ba..000000000 --- a/docs/integration/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# 集成、来源与验证结论 - -本目录保存跨平台、跨模组与原 GT6 对照的长期结论,包括来源版本、单位转换、兼容条件、可复现问题及覆盖状态。 - -新报告复制[验证结论模板](report-template.md),命名 `.md` 或 `-.md`,并在下方添加链接。同一主题持续更新原报告;结论与证据要求见[验证与验收](../development/validation/README.md#结果与证据),其他材料按[文档归属](../development/repository-layout.md#文档归属)存放。 - -## 目录 - -- [验证结论模板](report-template.md) -- [材料链路基线与正确性对照](material-baseline.md):材料、引用、形态、成分、回收/分解和资源重载的观察口径与已知差异。 -- [材料重构 04:统一物品成分解析](material-refactor-04-composition.md):来源化候选、有效成分快照、状态缩放和双平台安装。 -- [材料重构 05:统一回收计算与生成](material-refactor-05-recovery.md):成分驱动的回收计划、精确数量、主要生产端和重载诊断。 -- [材料重构 06:统一分解](material-refactor-06-decomposition.md):规则化权限、相态与单位、纯计划、配方发布和执行验收。 -- [材料重构 07-E:材料与形态注册项审计](material-refactor-07-roster.md):124 个形态族的来源、消费者、去留决定和双平台一致性。 - -- [材料处理快照与共享图验证](material-process-snapshot.md):发布时点、端口身份、跨材料查询、预算和 viewer 接入的回归范围与剩余验收。 diff --git a/docs/integration/material-baseline.md b/docs/integration/material-baseline.md deleted file mode 100644 index d3e92b9f8..000000000 --- a/docs/integration/material-baseline.md +++ /dev/null @@ -1,136 +0,0 @@ -# 材料链路基线与正确性对照 - -本页记录[计划 01](../development/material-system-refactor/01-baseline.md)的观察口径、已审阅的历史引用和可重复测试入口。当前行为快照用于发现迁移变化;正确性依据另列,不能通过重录快照认可缺陷。 - -专用的基线快照、独立 JVM 生命周期矩阵和测试附属材料在生产验证后已删除。本页数值与测试名称仅作为历史证据保留,当前代码不再生成这些投影。 - -## 范围与状态 - -源码基线为 `2e5627aa9da706416251ae83538a62cfc07a8783`,调查日期为 2026-11-07。本次新增测试、测试数据和文档,并独立清理形态表误抽取的一个局部变量键;没有改变实际材料、配方、初始化顺序、API 或持久化格式。开工已有未跟踪的重构计划和设计提议,均保留。工作期间外部修改 `.gitignore`,新增 `/docs` 忽略规则,也保留;新增文档因此不会自动出现在 Git 未跟踪列表中。 - -状态:**在下述范围验证通过**。core 的独立 JVM 重复采集、SPI、归一化、引用审计已执行;双平台生产及测试源码已编译。双平台各 79 个 GameTest 已通过,包含材料领域 8 例;初次启动和真实重载分别采集。同平台两次全新启动的成分、物品/方块形态、配方和标签语义投影均逐文件一致;不把数量视为全部内容的正确性结论。游戏客户端展示和真实外部附属不在本阶段自动验收范围。 - -运行环境:Minecraft 1.20.1/Forge 47.4.20 与 Minecraft 1.21.1/NeoForge 21.1.243,GT6CE 1.0.6,Gradle 8.8,Stonecutter 0.7.11。core/Forge 工具链为 Java 17(Dragonwell 17.0.19),NeoForge 为 OpenJDK 21.0.12.1;Gradle 启动 JVM 为 21。 - -02 将原先位于 `MaterialRoleFlags.apply()` 的世界生成和石材最终角色前移到材料 READY 前发布。因此后续 core 材料快照会比本页最初采集多 87 个最终派生属性:79 个 `GENERATE_ORE`、3 个 `GENERATE_ORE`/`GENERATE_ORE_PROCESSING` 组合和 5 个 `STONE`。旧流程同样在物品注册前写入这些 flag;双平台物品、方块形态、配方、tag 和代表案例投影保持逐文件一致,它们不是 01 基线之外的新运行行为。 - -## 三种证据 - -| 类型 | 存放位置 | 用途 | -| --- | --- | --- | -| 当前行为 | 根目录 `work/material-system-refactor/core/`、`runtime//<运行目录>/` | 全量材料、别名、引用、形态、成分、配方及代表案例;不提交原始 dump | -| 权威期望 | 当时基线测试中的断言与现行材料纯规则测试 | 固定 GT6 事实、现有 parity 决策、公开 SPI 契约 | -| 已知差异 | 本页、测试中明确标记的 observation、测试资源中的历史引用清单 | 让后续修改显露差异;不赋予当前错误行为正确性 | - -历史 core 快照在独立 JVM 中各初始化一次。无附属环境连续采集两次,比较材料、prefix、别名和引用四份排序后的 TSV;第三个 JVM 通过临时 ServiceLoader 资源加载测试附属。该入口和游戏测试附属均已移除,避免为一次性审计长期向测试运行注册额外材料。 - -材料投影区分原始对象、`resolve()` 后身份与有效性;内建 ID 保留,附属数值 ID 写为 `dynamic`,用所有者和注册名表示稳定身份。属性、别名和无语义集合排序,化学组成与副产物的顺序保留。物品组件排序前单列主材料;prefix 重量与实际生成物品分开,不生成全部材料与 prefix 的笛卡尔积。 - -配方按 map、槽位、物品/流体 ID 和数量、tag、催化剂/presence、unit 数量与舍入、输出概率、时长、EUt、special 数值和准入标记构造语义签名。保留重复签名的数量,不把规则集合转成去重集合。unit 只记录声明与代表身份,不展开全部替代形态。tag 输入使用 tag 身份与数量,不记录无序集合选出的展示物品;另存所有被配方引用的 tag 的排序成员列表,所以 tag 内容改变仍可见。首次比较中 Forge 的 310 条和 NeoForge 的 400 条 Bath/Mixer 展示代表差异据此消除,没有忽略成分、授权或产量。 - -局限:配方签名不完整序列化任意物品 NBT/组件、任意特殊对象和谓词实现,因而不是通用配方等价判定器。损坏、铸模形状和储存内容的实际准入由定向案例另外验证。形态投影覆盖已生成物品,同时记录已生成 `MaterialBlockLike` 方块的 prefix、单位重量、方块/物品 ID 与可生成性;未生成候选及全部原版替代映射仍需后续形态审计。新增字段须说明验证的外部行为。 - -## 引用审计 - -历史 `MaterialReferenceAudit` 检查已提交的组成声明、分解 ID/name 行、形态表、UUM ID 集合和七类加工目标;该测试工具已删除。下文的分类与数量只记录当时审计结果。 - -首次审阅 4,069 条引用后,移除 1 条误抽取行。最终审计 4,068 条:2,032 条直接有效、1,729 条可映射别名、307 条已解释的历史/停注引用;当前悬空引用与 ID/name 矛盾均为零。这些数量仅描述本次观察;测试不把固定总数当作永久容差。 - -历史分类依据如下: - -- 有数值 ID 的停注材料从[现有移除决策](../decisions/parity/material-removal.md)读取,不能因为查不到就自动允许。 -- 归一化后的 GT6 字段别名与当前注册名分别记录。能识别别名不代表生产 `MaterialForms.of` 一定命中了对应 fallback。 -- 历史 `material-reference-history.tsv` 逐条限定表、owner、字段、目标和 ID,并给出固定 GT6 的 `unused`/`deprecated`、未分配 ID 的 `valgem(0)` 或现有移除决策。该清单已随基线测试删除。 -- `MaterialForms` 的 `rmaterial` 来自 GT6 `MT.create` 的局部变量 `rMaterial`,不是材料。作为独立小清理,仅删除提交表中的该行,然后开启“当前未知错误必须为零”的严格断言;没有用期望文件豁免它。原生成脚本不在仓库,固定 GT6 原始输入已核对,未臆造可再生成流程。此键没有有效材料和 `MaterialForms.count` 生产调用者,不涉及任何材料/物品移除、ID 或存档迁移;后续恢复生成器时须排除局部变量。 - -新增悬空引用、ID/name 矛盾、非法物品组件会失败。负例直接构造缺失材料引用、铁 ID 配铜名和负数材料量;缺失引用异常包含表、材料、字段和目标。另在 `work/` 编译独立负例探针,注入假引用后进程确实以 1 退出;正常输入的完整 core 测试随后恢复通过;负例未改动生产输入。历史清单不豁免这些负例。01 阶段保留的 `MaterialCompositionData` 等生成表因缺少可复现脚本未重写;02 随后将其运行时事实迁入规范目录并删除旧写入入口。 - -## 权威依据与已知差异 - -上游为 [GregTech6/gregtech6 固定提交](https://github.com/GregTech6/gregtech6/tree/3703e40308c8c030763fd6297dea8b210d2a77b1),LGPL-3.0-or-later。原始输入主要为 [MT.java](https://github.com/GregTech6/gregtech6/blob/3703e40308c8c030763fd6297dea8b210d2a77b1/src/main/java/gregapi/data/MT.java) 与 [OP.java](https://github.com/GregTech6/gregtech6/blob/3703e40308c8c030763fd6297dea8b210d2a77b1/src/main/java/gregapi/data/OP.java)。引用的是该提交原始文件行号,不是网页重排后的行号;一次性下载和调查脚本留在 `work/`。 - -| 案例 | 依据/期望 | 当前观察与归属 | -| --- | --- | --- | -| Fe/Cu 身份 | GT6 `MT.Fe`/`MT.Cu`,沿用 260/290;别名指向同一身份 | core 正确性断言;不以材料总量作为通过条件 | -| 石墨熔炼 | [已接受的 1U 碳决策](../decisions/parity/README.md#其他差异)优先于 GT6 的 0.5U | core 断言 1U,避免把旧 GT6 数值当作当前项目期望 | -| 复合钻头 | GT6 `OP.toolHeadDrill` 的 4U 主材,`OP.java:717` 的 4U 钢副组分 | 注册表、实际栈、等价形态和坩埚负载分别检查;形态查询仍只代表主材料 | -| 铁存储块 | GT6 的存储块为 9U;现代 MC 铁块由既有映射承接 | 成分量、回收授权、熔化授权和实际坩埚解析分别采集 | -| 铜存储块 | 现代内容按两平台交集统一为 9U Copper 修正成分 | 两端均 9U Copper、坩埚可用且回收工艺准入一致;版本独有铜变体按物品存在性跳过 | -| 附魔金苹果 | GT6 `LoaderItemData.java:2502` 的 72U Gold;`MaterialRecoveryRules.dust` 是当前规划入口 | 已观察规划 64U,最终 Shredder 也产出 64U;属阶段 05 的待修差异,不是认可丢弃 8U | -| 损坏工具 | 成分按剩余耐久向下取整,Shredder 从剩余成分重建实际输出 | 完好、部分损坏、耗尽逐项观察;原生 GT 工具实例缺少注册表成分另列,不能用原版铁镐代替其验收 | -| 空桶/水桶 | 坩埚不得把有内容的容器当空壳消耗 | 空桶可熔,水桶被拒;未覆盖所有第三方容器 | -| 已凿铸模 | 形状与材料组成是不同事实 | 石铸模成分不变,但形状的 block entity data 被当作储存内容而拒绝;阶段 04/05 承接 #349 | -| 压模机模具 | 注册存在性与回收可用性分别检查 | 小号弹壳模具已注册但成分缺失,承接 #350;不以掉落形状测试代替 | -| 钼钙矿分解 | [#318 已接受电解规则](../decisions/parity/README.md#其他差异) | 用 mode 0 和 6 个粉查询实际配方;水分解另用流体输入查询 | -| SPI 材料 | 公共 `AddonMaterialContributor` 契约 | core 隔离 JVM 与游戏测试夹具分别检查所有权、链接成分、生成 dust 及离心配方 | -| 资源重载 | `MinecraftServer.reloadResources`,由真实 tag 生命周期发布 overlay | 独立顺序批次等待两次真实重载,比较 ExternalOreProcessing/SharedThermalInputRows 的拥有规则数、固定样例和查询;不以直接 `rebuild()` 冒充,也不宣称所有生成器已覆盖 | - -本阶段没有改动 GT6 行为或删除材料,因此没有新增生产 parity 取舍。阶段 03 已按固定 GT6 源裁决 Phosphor 不带 `MELTING`,并修正特殊木材燃料/灰烬;相应回归维护在 `FuelParityTest`。 - - -## 双平台交集与重载差异 - -同名物品按注册 ID 对齐;比较 prefix、主材料、全部组件及数量、授权、两类准入、储存内容判定和实际坩埚负载。来源说明文本、原生耐久上限和版本独有物品不作为成分漂移;它们保留在原始文件中。 - -| 范围 | 观察 | 处理 | -| --- | --- | --- | -| 成分条目 | Forge 35,226,NeoForge 39,043;交集 35,206,单端分别 20/3,837 | 两次同平台启动一致;单端独有只另列,不直接判错 | -| 交集差异 | 421 个物品 | 有限三类:383 个 `gt6ce:ore_*` 的 prefix 元数据、32 个铜材变体、6 种生物桶内容标记;数量不是永久豁免 | -| 矿石 prefix | Forge 为 `oreVanillastone`,NeoForge 未填 prefix | 成分量与坩埚负载相同,留阶段 04 统一元数据 | -| 铜材变体 | 32 个授权不一致,其中 26 个另有成分量/蜡组分差异 | 阶段 04 按现代 MC 规则裁决;不能批量用某一平台覆盖另一平台 | -| 生物桶 | NeoForge 默认 entity 组件使 `hasStoredContents=true`,Forge 为 false | 6 种桶两端均不可熔、不可回收;记录检测路径差异 | -| 物品/方块形态 | 两端均 30,654 个实际物品、3,560 个 MaterialBlockLike 方块 | 同平台初次/重载及重复启动一致;不以总量声称形态完整 | -| tag | 486 个被机器配方引用的 tag | 成员排序后,同平台初次/重载及重复启动一致 | -| 机器配方 | Forge 初次/重载均 155,825;NeoForge 初次 136,982,重载后 136,596 | 同阶段跨独立启动一致;NeoForge 少 386 条 Fermenter 配方需单列生命周期调查,不据此减少期望或宣称全图重载无差异 | - -NeoForge 的 386 条移除全部来自 `gt.recipe.fermenter` 的药水相关行;当前纯签名没有完整表示药水组件,计数不代表 386 种不同药水。这里只确认“初次有、真实重载后无”的现象,不在基线阶段修改发布顺序或复活已移除的药水系统。后续清理须先核对[药水移除决策](../decisions/parity/potion-removal.md)与生产者生命周期。 - -## 复现与执行记录 - -所有命令从仓库根执行,标准命令与注意事项见 [JUnit](../development/validation/checks/junit.md)、[编译](../development/validation/checks/compile.md)、[GameTest](../development/validation/checks/gametest.md)和[格式](../development/validation/checks/format.md)。当前材料纯规则入口为: - -```bash -./gradlew :core:test --tests 'gregtech.engine.material.*' --tests 'gregtech.engine.recipe.MaterialDecompositionPlannerTest' -./gradlew :minecraft:1.20.1-forge:compileTestJava :minecraft:1.21.1-neoforge:compileTestJava -``` - -基线 TSV 不再生成,因此不能继续运行后文的重复采集命令作为当前验收;保留的 `work/material-system-refactor/` 原始文件仅用于追溯历史结论。 - -默认开发环境会加载 JEI/Jade。无可选模组采集仅从 `runtimeOnly` 移除这两个查看器,保留全部编译 API,并核对实际加载列表只有 Minecraft、加载器和 GT6CE。复现时把下面内容保存到本地 `work/material-system-refactor/no-optional.init.gradle`: - -```groovy -gradle.afterProject { project -> - if (project.path.startsWith(':minecraft:')) { - project.configurations.findByName('runtimeOnly')?.dependencies?.removeAll { - it.group == 'mezz.jei' || (it.group == 'maven.modrinth' && it.name == 'jade') - } - } -} -``` - -实际最终采集命令如下;`--offline` 要求依赖已缓存。网络/Java 代理的个人配置按[开发上手](../development/getting-started.md)准备,不写入生产构建: - -```bash -./gradlew :minecraft:1.20.1-forge:runGameTestServer --offline -I work/material-system-refactor/no-optional.init.gradle -PgameTestHeap=4g -PgameTestDirectory=../../../work/material-system-refactor/forge-final-d -./gradlew :minecraft:1.20.1-forge:runGameTestServer --offline -I work/material-system-refactor/no-optional.init.gradle -PgameTestHeap=4g -PgameTestDirectory=../../../work/material-system-refactor/forge-final-e -./gradlew :minecraft:1.21.1-neoforge:runGameTestServer --offline -I work/material-system-refactor/no-optional.init.gradle -PgameTestHeap=4g -PgameTestDirectory=../../../work/material-system-refactor/neo-final-d -./gradlew :minecraft:1.21.1-neoforge:runGameTestServer --offline -I work/material-system-refactor/no-optional.init.gradle -PgameTestHeap=4g -PgameTestDirectory=../../../work/material-system-refactor/neo-final-e -``` - -已有目录不要作为下一次干净启动的目录;改用新名称,不删除他人的配置或世界。最终同平台两次采集的 25 份 TSV(含 15 份代表案例)均逐字节一致。对于同版本两次输出,逐字节比较 `startup`、`reload` 的 `items`、`forms`、`block-forms`、`recipes`、`tags` 五类 TSV,十份均须一致。跨版本则按物品 ID 求交集,比较列 2—9 的 prefix、主材料、成分、授权、两类准入、储存内容判定和坩埚负载;其余版本独有 ID 另列。 - -没有关闭检查或修改生产打包配置。环境、完整命令输出和原始结果保存在 `work/material-system-refactor/`,不随仓库提交。 - -| 检查 | 结果 | 覆盖/限制 | -| --- | --- | --- | -| D 路由与文档 | 已通过路由检查与新增链接复核 | `python tools/validation/route.py check` | -| J core | 已通过完整 93 个 JUnit 测试,包括新增 4 个基线测试 | 独立 JVM 重复采集、测试附属、负例、有效图和源表引用 | -| C | 双平台生产编译及共享测试编译已通过 | GameTest 同时复验最终测试 SPI 夹具 | -| F | 格式化和全仓 spotlessCheck 均通过 | 不扩大排除范围 | -| G Forge | 两次全新启动均 79/79 required tests 通过 | `forge-final-d`/`forge-final-e`;十份投影逐字节相同,包含 SPI 和每次两次真实重载 | -| G NeoForge | 两次全新启动均 79/79 required tests 通过 | `neo-final-d`/`neo-final-e`;十份投影逐字节相同,核对游戏日志实际测试数 | -| M/B | 尚未执行;本阶段未改生产资源或打包配置 | 未宣称客户端或发行包已验收 | - -网络无 Java 代理时首次 Gradle 解析超时;离线缺 EMI 缓存时两平台编译被阻塞,随后通过环境既有代理恢复。另一次复用 Forge 运行目录时 `GT6CE/common.toml` 解析失败,加载器仍返回 Gradle 成功;该次不计为 GameTest 通过,保留日志并使用全新目录复验。 - -验收分类:**执行且通过**为 D、F、J、C、双平台 G、独立负例与重复采集。**执行但失败或阻塞**包括早期在线依赖超时、离线缓存缺失、两处样例选择错误,以及复用目录的配置解析失败;均已用上述最终输入和全新目录复验,不存在未解决的执行阻塞。**尚未执行**为客户端手工操作、真实外部附属环境及发行包检查;本阶段没有改变生产资源或打包配置。已知生产差异不列作“正确性通过”。 diff --git a/docs/integration/material-process-snapshot.md b/docs/integration/material-process-snapshot.md deleted file mode 100644 index d5035d6d2..000000000 --- a/docs/integration/material-process-snapshot.md +++ /dev/null @@ -1,52 +0,0 @@ -# 材料处理快照与共享图验证 - -## 范围与状态 - -本页记录材料来源/用途快照、core 图及 viewer 投影的代码核对与回归方法。状态:部分验证;不能据此把[计划 08](../development/material-system-refactor/08-material-data-api.md)整体标为完成。 - -源码依据:`de16ac298`、`8722ac629` 与其上的工作区修复。当前实现增加 API 1.9 的 cross-material special-process 声明、target/reagent typed rules、派生标签、通用配方 producer 和 method-aware 展示折叠;没有修改注册 ID、存档或网络协议。 - -## 已确认问题与处理 - -| 问题 | 影响与处理 | -| --- | --- | -| overlay 与炉桥接各自构建快照 | 中间行集被提前发布并重复消耗构建时间。服务端改在 `RecipePublication` 提交后发布,独立客户端在 overlay/炉镜像后发布;完整上下文未变时复用索引。失败 overlay 不替换成功快照。 | -| 输入 tag 被用于同槽号输出 | 物品或流体输出会变成输入 tag 的代表。输出只读取自身原生身份,输入的 tag、unit 和取整规则保持独立。 | -| 世界生成物品使用驼峰转下划线名称,查找失败回退石头 | 与实际生成器的小写注册名不符,会把矿物来源画成石头。按实际注册名查找;未注册矿物不作为有效生成来源。 | -| 世界生成端口写死 `ore` | 与注册物品的 `oreVanillastone`、`oreDense` 等形态无法连接。改从原生物品解析真实形态,小矿单独保留身份;优先选择普通矿物而非小矿作为总览根。 | -| 世界生成 revision 漏字段并使用含材料对象的哈希 | 权重或种类改变不能使 revision 改变,跨 JVM 的对象哈希也不表达相同事实。按完整事实字段及稳定材料名计算 revision。 | -| 仅在根材料分桶内遍历 | 分解、合金和副产物进入另一材料后路线停止。改为一个跨材料索引,查询仍受同一深度、步骤、端口和边预算限制。 | -| 预算裁剪后仍输出关联 | 关联可能指向已裁掉的端口,导致展示构造拒绝整个查询。返回边只引用保留下来的端口;深度边界和非展开侧的端口裁剪也报告部分覆盖。根候选不先复制全集再截断。 | -| 资源 `DataKey` 可跨快照复用 | 新代查询可能接受旧资源。资源引用加入每次构建的作用域,原生导航仍校验当前快照;服务器停止和客户端断线清理 Store。 | -| 特殊系列依赖名称与手写生成器 | API 1.9 用 `SpecialProcessMethod` + `MaterialProcessKey` 声明目标材料、辅料、配方表和展示名。Target 规则生成配方并携带 method ID;手工旧行也按同一规则匹配。材料图只折叠带 method ID 的步骤。 | -| target/reagent 标签与配方声明双写 | target/reagent 材料 tag 从 typed process 规则派生,item/fluid tag 再按规则表单生成,避免维护第二份名单。 | -| 普通无形态原料/产物被静默跳过 | 保留原生物品/流体端口及未分类说明,不把单一图标推断成某种材料;带额外原生条件的输入不与无条件资源合并。 | -| EMI 动态查询只显示第一页 | 来源/用途查询改为一种材料一张页;JEI 与 EMI 共用可平移图,不再按两个步骤拆页或维护配方级页码。 | -| 文档状态矛盾与两节点导入顺序错误 | 更新设计状态、人工验收步骤及包入口;修复 Spotless 报告的导入顺序。 | - -模具、工具等辅助物品不扩展为总览资源路线,其数量、状态引用与原配方保留在步骤说明/原生配方中。这与普通消耗原料不能静默消失是两种情况。图不会因为工具没有材料成分而虚构一条工具生产链。 - -JEI 与 EMI 同装时,JEI 提前返回是已有桥接去重约定;本模组的 EMI 原生处理页已经注册。不能仅据 JEI 分支为空认定两 viewer 同装丢失处理页。实际双装交互仍须单独人工确认。 - -## 复现与检查 - -从仓库根目录运行: - -```bash -./gradlew format -PspotlessRatchet=de16ac298^ -./gradlew :core:test --tests gregtech.engine.material.MaterialProcessGraphTest spotlessCheck -PspotlessRatchet=de16ac298^ compileBothPlatforms :minecraft:1.20.1-forge:compileTestJava :minecraft:1.21.1-neoforge:compileTestJava -python tools/validation/route.py check -python tools/comments/check_comment_refs.py --diff HEAD -git diff --check -``` - -`MaterialProcessGraphTest` 包含循环、共同输入、前反向查询、各项预算、深度边界的端口截断及裁剪后的边合法性。展示投影、世界生成形态、物品/流体状态和布局示例不再保留逐场景 GameTest;这些行为按[人工检查](../development/validation/checks/manual-ingame.md#矿物处理展示页)使用真实 JEI/EMI 验收。 - -## 验证结果与剩余事项 - -以下 GameTest 结果是移除一次性展示快照测试前的历史证据,不能代表当前测试数。当前常驻的纯规则入口为 `MaterialProcessGraphTest`,客户端展示仍需人工验收。 - -- 历史执行且通过:`MaterialProcessGraphTest`、API `SpecialProcessValueTest`、`apiContracts`,以及清理前 Forge 99 项、NeoForge 104 项 GameTest。 -- 尚未执行:独立远程客户端、JEI-only/EMI-only/双装实际拖拽、路线折叠、全屏、无 viewer 的独立客户端、附属差异与世界生成开关矩阵。 - -08 的 A—C 已有定义与形态入口;D—E 已有内部来源/用途快照、符号选择器、共享材料页图和 API 1.9 的显式特殊工艺所有权。tag/unit 仍保持符号投影,不能声称枚举了全部动态工艺或完整可执行路线;本轮不新增网络同步协议。远程同代数据、断线/换服、实际 viewer 拖拽/折叠与精确跳转仍需要按[人工检查](../development/validation/checks/manual-ingame.md#矿物处理展示页)记录实际结果。局部图模型通过不能替代这些场景。 diff --git a/docs/integration/material-refactor-01-02-review.md b/docs/integration/material-refactor-01-02-review.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/integration/material-refactor-04-composition.md b/docs/integration/material-refactor-04-composition.md deleted file mode 100644 index 5190eb7e5..000000000 --- a/docs/integration/material-refactor-04-composition.md +++ /dev/null @@ -1,94 +0,0 @@ -# 材料重构 04:统一物品成分解析验收 - -日期:2026-11-09。适用分支:`master`,Stonecutter 节点 `1.20.1-forge` 与 `1.21.1-neoforge`。 - -## 结论 - -04 计划范围内已实施。物品成分现在只有一份有效快照,遍历、单物品查询、状态缩放、回收授权和炉规则准入均从该结果或独立策略判定读取。最后写入者覆盖已由结构化候选和冲突失败替代。 - -## 权威入口 - -| 职责 | 入口 | -| --- | --- | -| 来源与优先级 | `ItemCompositionSource` | -| 单物品候选 | `ItemCompositionCandidate` | -| 纯候选裁决 | `ItemCompositionResolver` | -| 有效值 | `ItemComposition` | -| 损伤缩放 | `ItemCompositionScaling` | -| 运行期快照与生产端提交 | `ItemMaterialRegistry` | -| 双平台共享安装 | `MaterialItemCompositions` | -| 外部 tag 候选 | `ExternalOreProcessing` | - -优先级为显式物品/JSON/修正、统一化目标、材料形态 tag、CR.REV 反推。裁决按整条记录进行,不跨层拼接组件或授权。显式覆盖必须命名现存声明;覆盖环、同级冲突、重复声明和缺失目标在发布前失败。 - -## 行为裁决 - -- 木材与肉的 GT6 显式定义继续覆盖旧 JSON 表,但现在通过声明 ID 显式替代,不依赖加载调用顺序。 -- 组件归一化以显式主材料为首,其余材料稳定排序。JSON 多组件行的主材料由行内首项声明;GT6 定义必须显式提供主材料。 -- 复合形态不再满足 `MaterialEquivalence.form()` 的纯形态条件,但完整组件仍用于 tooltip、熔化、回收和分解。 -- 铸模空腔是与真实库存不同的纯状态;无内容物的带形状铸模继续允许熔化和批量回收。 -- `recoverable` 与 `bulkRecovery` 旧 JSON 键继续做兼容读取和相互冲突校验,但不再形成物品级回收门槛;规范 `ItemComposition` 将该兼容值归一为 `true`。成分存在、熔化准入、具体回收工艺和炉策略互不替代。 -- CR.REV、显式 GT 材料定义、统一化和 tag 规则仍可授权炉策略;vanilla JSON 描述性行与人工描述修正不会单独删除原版熔炼行。 - -## 检查结果 - -执行且通过: - -- `:core:test`:新增候选顺序独立性、同级合并/冲突、唯一覆盖与环、溢出安全损伤缩放测试。 -- `:api:test`。 -- Forge 与 NeoForge 生产源码和测试源码编译。 -- `assembleBothPlatforms`、ratchet Spotless 和验证路由检查。 -- Forge 1.20.1 在全新目录执行 73 个 GameTest,日志为 `All 73 required tests passed`。 -- NeoForge 1.21.1 在全新目录执行 78 个 GameTest,日志为 `All 78 required tests passed`。 -- JSON 负例验证未知材料、非正数量、未知 prefix、缺失继承目标、prefix/inherit 冲突及旧新回收键冲突均给出具体诊断。 -- 两节点实际资源重载两次:每轮产生 420 个 ore-prefix tag 候选,有效快照 revision 单调推进,重复重载不累积条目,固定成分保持一致。 - -2026-11-10 审查闭合后补充: - -- tag 发布失败保持上一份有效成分不变;清空 tag generation 时,依赖该 generation 的物品失去派生成分。回收/配方行的整体事务边界仍按 05 实施。 -- 显式覆盖目标可以晚于覆盖声明注册,最终在全部成分生产端完成后严格校验;木料、肉类和现代修正不再依赖当时已发布的 JSON 候选。 -- 来源引用保留在 `ItemCompositionSource.reference`,候选不再携带未使用的第二份物品键;legacy 构造和通用 `register(Item, ItemComposition)` 入口已标记弃用。 -- 损坏复合物品的主材料缩为 0 时,快照保留仍存在的其余组分和稳定排序,不因主材料字段抛出异常。 -- JSON 中 88 个统一化条目显式声明 `inherit: vanilla-unification`;未声明 `prefix`/`inherit` 的条目不再隐式继承。 -- 复核通过:定向 core JUnit、双平台生产与测试源码编译、`assembleBothPlatforms`、路由检查和 ratchet Spotless;Forge 实际执行 74 个 GameTest、NeoForge 实际执行 79 个 GameTest,均报告全部通过。客户端展示仍未执行手工验收。 - -执行但未通过后已修复: - -- 原版统一化空组件分支一度仍标为显式层,和 JSON 的 4U/9U 紫水晶块冲突;改为统一化来源后按优先级裁决。 -- 木材与肉类 GT6 定义和 JSON 的组件/主材料不同;两处原最后写入行为改为显式声明替代。 -- 初版快照在每个候选提交时全量重建,导致启动近似二次复杂度;改为单物品增量更新,tag generation 仍整批预解析后原子替换。 - -尚未执行: - -- 当前测试实例未安装能提供外部 common-form tag 的模组,因此没有实机 tag-only 物品样例;纯 tag 候选裁决由 core JUnit 覆盖。 -- 本阶段不改公开 API;tooltip、JEI/EMI 和客户端实际显示未执行 A、M。 - -## 第二轮审查闭合(2026-11-10) - -- 炉策略改为只检查有效成分的胜出来源;JSON 的炉授权只由声明显式继承的 vanilla-unification 提供,不再读取被淘汰候选。 -- Panel 材料全部以 CR.REV 候选提交,包含 concrete、玻璃与木板家族;不再以当前 `base()` 决定是否写入。 -- 覆盖关系写入结构化来源并保留完整覆盖链;同一同级声明被多个候选覆盖会直接失败。 -- Forge 与 NeoForge 共用 vanilla 绑定入口;NeoForge 重复的基础机器成分生产者已删除。 -- 完整 `:core:test`、双平台生产与测试源码编译、ratchet Spotless 通过;Forge 74/74、NeoForge 79/79 GameTest 通过。客户端显示仍未做手工验收。 - -## 第三轮审查闭合(2026-11-10) - -- 规范 `ItemComposition` 不再从单一剩余组件推断主材料;legacy 构造器继续为旧声明执行迁移期推断,损伤缩放则保留“原主材料已丢失”的无效状态。 -- `CompositionLookupState` 现在区分 `PRESENT`、`ABSENT` 与 `TAG_INPUT_NOT_READY`。首次成功发布 tag generation 会推进 revision,发布失败仍保留旧 generation。 -- 定向 core JUnit、双平台生产与测试源码编译通过;Forge 1.20.1 GameTest 75/75,NeoForge 1.21.1 GameTest 80/80。新增 tag-only Shredder 加入/撤销运行时断言。 - -## 第四轮审查闭合(2026-11-11) - -- 显式成分层在最终覆盖校验后关闭;后续显式提交明确失败。 -- 新增 `declared()`,过滤外部 tag 赢家;生产消费者不再把诊断用 `explicit()` 当权威输入。 -- 输入证明统一为 `RecoveryInputProof`,移除重复的 thermal 状态检查。 -- 完整 `:core:test`、双平台生产与测试源码编译、GameTest 源码编译和 ratchet Spotless 通过;Forge 1.20.1 GameTest 77/77,NeoForge 1.21.1 GameTest 82/82。 - -## 第五轮审查闭合(2026-11-12) - -- 来源裁决确定为受控类别与显式覆盖链;同一优先级内容不一致失败,自由文本不再反向决定来源类别。方块重量、CR.REV 和其余内置生产端改用结构化来源。 -- `ItemCompositionResolver.resolveDetailed()` 与 `ItemMaterialRegistry.compositionDiagnosis()` 保留胜出、被覆盖和低优先级候选及原因,tag generation 变化时诊断与有效快照同步更新。 -- 弃用双参数注册仅对旧附属保留最后写入兼容;结构化和 tag 候选继续严格校验。legacy 多组件主材料/数量与 `recoverable()` 兼容行为已恢复。 -- API 1.8.0 与 `gregtech:gt6ce-api:1.8.0` 发布坐标作为本轮累计材料 API 变更的最终版本决定。 -- 执行且通过:`:api:check`、`:core:test`、Forge/NeoForge 生产与测试源码编译、ratchet Spotless、验证路由及注释检查;Forge 1.20.1 GameTest 90/90,NeoForge 1.21.1 GameTest 95/95。 -- 首轮 Forge GameTest 发现 CR.REV 单组件的主材料被清除,Stone 铸模因此未保留 45U 构造数量;恢复兼容主材料推断后最终全量通过。 diff --git a/docs/integration/material-refactor-05-recovery.md b/docs/integration/material-refactor-05-recovery.md deleted file mode 100644 index 444287ac8..000000000 --- a/docs/integration/material-refactor-05-recovery.md +++ /dev/null @@ -1,84 +0,0 @@ -# 材料重构 05:统一回收计算与生成验收 - -日期:2026-11-10。适用分支:`master`,Stonecutter 节点 `1.20.1-forge` 与 `1.21.1-neoforge`。 - -## 结论 - -05 的生产侧范围已实施。普通物品粉碎、配方驱动的 Shredder、Anvil、胶囊、石材和热回收不再各自重建物品材料量;最终配方从有效 `ItemComposition` 生成,输入状态、数量、输出槽和不可表示余量分别有明确结果。本轮没有新增公开 API,也没有建立第二套回收框架。 - -08-D 的静态配方来源/用途索引仍属于 08 阶段。本阶段提供的是可被该索引投影的最终输入限制、数量、目标材料、输出角色和拒绝原因。 - -## 权威入口 - -| 职责 | 入口 | -| --- | --- | -| 单个材料的精确粉尘分组 | `MaterialRecoveryRules.dustPlan` | -| 完整成分的 Shredder 计划 | `MaterialRecoveryRules.planShredder` | -| 运行期输入拒绝原因 | `ItemMaterialRegistry.recoveryRejection` | -| 普通物品回收生成 | `VanillaRecoveryRecipes` | -| prefix 驱动 Shredder 生成 | `ShredderRecyclingRecipes` | -| Anvil 生成 | `AnvilShreddingRecipes`、`StoneAndToolSurvivalRecipes` | -| 热回收输入与 native 绑定 | `SharedThermalInputRows`、`SharedThermalRecyclingRows`、`SourceThermalNativeAdapter` | -| 胶囊权威成分与回收 | `CapsuleCellRecipes` | -| 动态行发布与重载 | `MachineRecipeOverlay` 及 owned-row 集合 | - -## 行为裁决 - -- 72U 不再变成 64U。计划按 64 的单栈上限分组为 64U 和 8U 两个合法 dust 栈;更小的余量用 small、tiny、1/72 dust 继续表示。低于 1/72 dust 的不可表示部分不会静默丢弃。 -- Shredder 计划逐组件转换粉碎目标并合并同目标材料;无法解析的组件进入逐项 `skippedComponents` 诊断后跳过,只有全部组件都无法产出时才拒绝整条候选。 -- 配方输出超过机器槽位、计划数量溢出或最终 item 绑定缺失时,生产端拒绝该候选并计入诊断;不会生成超栈、负数量或静默截断配方。 -- `RecoveryRejection` 分开报告 `NO_COMPOSITION`、`NO_COMPONENTS`、`STORED_CONTENTS` 和 `UNSUPPORTED_CONTAINER`;`NOT_BULK_RECOVERABLE` 与 `DAMAGED` 仅保留兼容枚举,不再产生。损坏 Shredder 输入从剩余成分重建输出,其他固定输出热行继续由各自输入证明保护,铸模空腔仍不属于盛装内容。 -- Vanilla ore、raw metal item 和 raw metal block 使用 `VanillaUnificationDefinitions.OreInputKind` 明确分类;原矿物品与块分别进入自己的工艺,不靠 `raw_` 前缀字符串决定。 -- 热回收候选直接读取有效物品成分,方块与石材不再从类对象重算第二份组分量。输入快照和最终查询在同一发布 generation 中构建。 -- `rockGt` 的普通 Anvil 行只由 `StoneAndToolSurvivalRecipes` 声明;`AnvilShreddingRecipes` 不再重复提供同一候选。 -- 胶囊的 `capcellcon` 物品不在通用 MaterialPrefix registry 中,因此由其现有容器规格声明 1/9U 的结构化有效成分;没有伪造新的 prefix 或公开 API。 - -## 检查结果 - -执行且通过: - -- `:core:test --configure-on-demand --offline`:148 个测试通过,包含 72U 精确分组、输出槽拒绝、不可表示余量、原矿类别区分和已有材料基线。 -- `compileBothPlatforms --configure-on-demand --offline`:Forge 1.20.1 与 NeoForge 1.21.1 生产源码编译通过。 -- 两节点生产源码和共享 GameTest 源码编译通过。 -- Forge 1.20.1 实际启动后注册 2775 条成分驱动 Vanilla 回收、超过 2 万条 prefix Shredder、1300 条 Anvil、28 条胶囊回收和 4200 条热回收输入行;NeoForge 1.21.1 对应为 2854、超过 2 万、1300、28 和 4232 条;没有新增 Shredder 重复行。最终候选遍历还显式排除 antimatter forms。 -- 两个节点均真实资源重载两次:热回收 owned row 计数保持节点内稳定值,未累积旧行;有效物品成分 generation 同步更新。 -- 72U 最终 Shredder 查询返回两个合法 Gold dust 栈;原料类别和状态拒绝原因可在运行时分别观察。 -- Forge 1.20.1 实际执行 74 个 GameTest,全部通过;NeoForge 1.21.1 实际执行 79 个 GameTest,全部通过。 - -执行但失败或阻塞: - -- `:core:spotlessCheck`/`:minecraft:spotlessCheck` 无法作为整仓通过项:检查显示 14 个与本轮无关的既有格式违规。本轮文件已用同一 Palantir 2.103.0 版本单独格式化,没有批量修改这些既有文件。 -- 首次完整 Forge GameTest 因多目标耗尽槽位后的空计划调用失败;已增加无剩余槽位立即拒绝。后续运行还暴露胶囊没有权威成分、复合计划与旧 prefix 环不一致;均已修复。 - -尚未执行: - -- 客户端 tooltip、JEI/EMI 展示和机器手动交互尚未执行。 -- 08-D 的来源/用途快照与 08-E 的有界处理图尚未实现。 - -## 剩余边界 - -- Shredder 已按 GT6 恢复损坏物品的比例回收:静态 prefix 和动态成分行在查询时读取缩放后的有效成分并重算输出、时长;低于一个 1/72 dust 的尾部按 `OM.dust` 向下取整丢弃。热回收等仍依赖固定输出量的工艺继续拒绝损坏栈。 -- 21 个源 prefix 在当前端口没有可生成的 item form,相关候选保持缺失诊断;不能用同名猜测物重建它们。 - -## 审查闭合(2026-11-10) - -- Shredder 显式启动行进入静态 baseline;tag-owned 行作为独立 generation,在 `MachineRecipeOverlay` 中重建和清理。`MaterialUnitRecipe` 的动态索引与物理行通过同一个 rule 一起撤销,不会留下旧 tag 查询。 -- Shredder duration 统一取自 `MaterialRecoveryRules.planShredder()`。方块形态仍通过实际的 block delegate 解析,但不再接受 `GTBlocks` 返回的非方块回退项。 -- 通用 Shredder 行带来源标记;相同输入和条件下的不同输出冲突会终止发布,具体配方拥有输入时通用行明确让位。 -- 新增运行时断言:tag-only 成分生成 Shredder 行,清空 tag generation 后该行不可查询;真实资源重载两次时 Shredder owned row 计数保持稳定。 -- Forge 1.20.1 实际执行 75 个 GameTest,NeoForge 1.21.1 实际执行 80 个 GameTest,全部通过。 - -## 第二轮审查闭合(2026-11-11) - -- 热回收所有权改由 `ThermalRecoveryOwnership` 单点判断,附属材料不再因非 core 被排除。 -- 附属材料从已发布 smelting target 与唯一流体绑定生成热回收行;标准绑定 1U 输出 144 mB,小型形态按同一比例换算。 -- `RecoveryInputProof` 统一运行时输入限制;`RecoveryRecipePublisher` 统一 generic/specific 归属、去重和不同输出冲突,所有权记录在配方上,guarded rows 通过输入索引查询冲突。 -- 运行时注册行数:Forge 4142 条热回收输入、NeoForge 4174 条;附加热回收行在两个节点均可查询。 -- Forge 1.20.1 GameTest 77/77,NeoForge 1.21.1 GameTest 82/82;双平台生产与测试源码编译、core JUnit、ratchet Spotless 通过。 - -## PR #374 复核补正(2026-11-12) - -- `SourceDustThermalRecipes`、`SourceThermalNativeAdapter`、`OreProcessingRecipeLoader` 和 `VanillaStoneMachineRecipes` 的 Melter/Smelter/石质 Shredder 写入全部进入 `RecoveryRecipePublisher`,补上材料回收族的直写旁路。 -- 标签代次开始前的成分状态成为可回滚检查点;overlay 失败时恢复上一代标签候选、有效成分、诊断、readiness、generation 与 composition revision,同时保持上一份成功 `MaterialPublication` 不变。 -- `ThermalRecoveryOwnership` 不再包含 9114/`Cinnabar` 前缀特例,只保留 Ti/Fe 审计分数组。 -- 执行且通过:双平台生产与测试源码编译、`:minecraft:spotlessCheck`、Forge 1.20.1 GameTest 92/92、NeoForge 1.21.1 GameTest 97/97。 diff --git a/docs/integration/material-refactor-06-decomposition.md b/docs/integration/material-refactor-06-decomposition.md deleted file mode 100644 index 457ab5753..000000000 --- a/docs/integration/material-refactor-06-decomposition.md +++ /dev/null @@ -1,47 +0,0 @@ -# 材料重构 06:统一分解验收 - -本页记录[计划 06](../development/material-system-refactor/06-decomposition.md)的落地边界、行为差异和验收证据。正确性依据优先使用仓库内 parity 决策,其次为 GT6 固定提交 `3703e40308c8c030763fd6297dea8b210d2a77b1`;旧运行快照只用于发现变化。 - -## 当前实现 - -- `MaterialDecompositionRule` 是唯一公开的分解值对象,`MaterialProcessKeys.DECOMPOSITION` 将它挂入现有 `MaterialInfoDefinition.Processes`。规则保存离心/电解路线、液体/气体原生身份、`sourceUnits → mB` 换算和固体兜底;API 版本为 1.8,版本码 `1008`。 -- `DecompositionMaterials` 是内置材料路线与相态声明的唯一内容来源,并保留固定提交中的材料相态声明。`MaterialDefinitions` 在建立规范声明时生成 typed rule;`CENTRIFUGE`、`ELECTROLYSER`、`DECOMPOSABLE` 只在冻结后作为其单向兼容镜像。旧附属 feature 只在没有 typed rule 时生成默认兼容规则,不能再拓宽显式规则。 -- `MaterialDecompositionPlanner` 是唯一计划入口。它处理 divider、输入批量、整数约简与范围、液体/气体输入、环境相态输出、按声明的一跳粉化目标、EUt、时长、电解选择器、输出顺序及槽位截尾。 -- `DecompositionRecipeLoader` 只负责把计划解析为标准物品/流体,并发布 `Centrifuge`、`Electrolyzer` 配方。其行为 overlay-owned rows,已接入 baseline 排除、逐代重建和失败恢复。`SourceDecompositionData` 和 `SourceDecompositionNativeFacts` 已退出生产路径。 -- 规范目录装配会反向校验全部内置相态行和路线声明。没有规范材料所有者、没有被 typed rule 保留或重复的行会使初始化失败;未来停用行必须显式列出,不能依赖 `input()`/`thermal()` 返回 `null` 静默忽略。 -- issue #369 的熔融流体、EMI、坩埚与熔化器范围不阻塞分解声明。分解规则保存固定来源给出的候选流体身份和换算,原生流体是否注册、是否进入 EMI 或是否有热配方由运行时内容与配方层决定;收缩或扩展该范围不需要重写分解路线和化学组成。 - -## 数据裁决 - -- 规范目录当前发布 263 个分解上下文:250 个材料至少有一条离心/电解路线,13 个只为组成组件提供相态;69 个材料带显式流体相态绑定。 -- 补齐 22 个已有分解路线但缺少组成的材料,声明取自固定 MT 数据。`Ironwood`、`SkyStone`、`VibrantAlloy` 的原组成引用已停注材料,因此保留为明确无分解能力,不创建伪造替代物。 -- 当前发布结果为 243 个材料、258 条离心/电解配方、21 个被拒绝或跳过的路线候选。相比此前快照的 229 个材料、243 条配方,增加来自补齐组成和启用已声明相态输入;减少来自无法表示完整产物或输入绑定的候选。 -- 启动日志逐项报告未解析的输入或输出绑定。当前 9 个候选包含 `EnderPearl`、`FierySteel`、`Fireleaf`、`FlamascusSteel`、`Glowstone`(气体输入)、`Knightmetal`、`LiveRoot`、`Steeleaf`、`Thaumium`;失败候选不会发布截断或伪有效配方。可替代的其他液体/气体输入和固体 fallback 仍可独立发布。 - -## 独立验证 - -### 执行且通过 - -- API 与 core JUnit:API 108 个、core 159 个;新增测试覆盖 typed route 优先于旧 flag、共享流体单位、Powellite、Datolite、Glowstone、槽位截尾、整数溢出和禁止材料。 -- Forge 1.20.1:全新目录 `work/material-system-refactor/fix06-forge`,`All 78 required tests passed`。测试通过共享 `RecipeProcessor` 实际启动、消耗、完成并刷新附属离心分解输出;真实资源重载期间分解 owned rows 保持 258 条,电解配方在两次重建后仍可查询。 -- NeoForge 1.21.1:全新目录 `work/material-system-refactor/fix06-neo`,`All 83 required tests passed`,包含同样的分解重载断言。 -- API 契约通过;两节点生产与测试源码编译通过,`compileBothPlatforms` 成功。 - -### 尚未执行 - -- 未在客户端界面手工检查 JEI/EMI 中的离心、电解配方布局和电解选择器提示。 - -### PR #374 步骤五复验 - -- 执行且通过:完整 `:core:test` 171 个 JUnit、`:core:spotlessCheck` ratchet、验证路由闭合、注释引用检查。 -- 执行且通过:Forge 1.20.1 在 `work/pr374-step5-forge` 运行全量 GameTest 90/90;NeoForge 1.21.1 在 `work/pr374-step5-neoforge` 运行全量 GameTest 95/95。两节点均完成材料启动、分解配方发布和真实资源重载。 -- 尚未执行:客户端 JEI/EMI、坩埚与 EMI 展示范围的手工检查;issue #369 的内容范围裁决仍独立于本步骤。 - -### PR #374 步骤六复验 - -- 执行且通过:`:core:test` 171 个 JUnit;Forge/NeoForge 生产与测试源码编译;`:minecraft:spotlessCheck`。 -- 执行且通过:Forge 1.20.1 全量 GameTest 90/90,NeoForge 1.21.1 全量 GameTest 95/95。运行目录分别为 `work/pr374-step6-forge`、`work/pr374-step6-neoforge`。 -- GameTest 覆盖两次真实资源重载后的稳定发布戳、标签代次撤销与重建、显式定义持续关闭、外部回收冲突单行跳过,以及重载后分解和 Shredder 配方仍可查询。 -- 执行但失败:`:core:spotlessCheck` 与两节点 `spotlessCheck` 仍会命中本步骤未修改文件的导入顺序问题;共享源码格式通过,失败文件未顺手改写。 -- 尚未执行:客户端界面手工检查;本次没有新增客户端交互或网络格式。 - diff --git a/docs/integration/material-refactor-07-roster.md b/docs/integration/material-refactor-07-roster.md deleted file mode 100644 index 66a2f3370..000000000 --- a/docs/integration/material-refactor-07-roster.md +++ /dev/null @@ -1,201 +0,0 @@ -# 材料重构 07-E:材料与形态注册项去留审计 - -## 范围与状态 - -- 主题:按最终运行时注册对象审计材料身份、物品形态、方块形态、获得途径和消费者,完成 [07-E](../development/material-system-refactor/07-cleanup-and-acceptance.md#07-e-定向审计记录) 的去留裁决。 -- 状态:在下述双平台、开发环境、无外部附属内容范围内验证通过。08-D—E 的生产快照与 viewer 代码切片现已接入;07-F 的双平台重载、正式客户端展示、机器手工交互和最终发行包仍未执行。 -- 源码状态:核对基线为 `525a6ecf6`;本报告包含当前工作区尚未提交的 `MaterialItemCompositions` 共享矿石成分修复与对应 GameTest。 -- 平台:Minecraft 1.20.1/Forge 47.4.20/Java 17,Minecraft 1.21.1/NeoForge 21.1.243/Java 21。 - -## 口径与结果 - -审计使用最终 GameTest 写出的 `reload-items.tsv`、`reload-forms.tsv`、`reload-block-forms.tsv`、`reload-recipes.tsv` 和 `reload-tags.tsv`,汇总由 [material 形态审计工具](../../tools/material/audit_roster.py)完成。物品数是实际存在成分快照的原生物品,方块数是实际实现材料方块契约的原生方块;两者都不是 Java 源码字符串命中数。来源和消费者计数来自最终 `RecipeMap.mRecipeList`,并展开配方里的物品 tag;手工配方、世界生成、铸币、化石和特殊行为没有统一静态表,因此按下文点名源码补证。 - -| 对象 | Forge | NeoForge | 结论 | -| --- | ---: | ---: | --- | -| 材料目录 | 815 | 815 | 相同;核心 803 个,另含 12 个测试附属材料(其中 3 个为测试流体身份) | -| 材料物品 | 31,137 | 31,137 | 124 个形态族的逐族计数相同 | -| 材料方块形态 | 3,532 | 3,532 | 13 个方块形态族的逐族计数相同 | -| 有静态配方来源的形态族 | 115 | 115 | 其余 9 族有世界生成、手工、铸币或展示来源 | -| 有静态配方输入的形态族 | 121 | 121 | `coin` 由硬币堆/铸模消费;`oreSmall` 由世界生成和采掘消费 | - -803 个核心材料身份中,734 个生成材料物品;另有 15 个有效但无物品形态的身份(8 个反物质、6 个粒子、1 个隐藏 Magic),以及 54 个 `id=-1` 的组/占位视图。`Empty` 是箭头杆、空弹壳和空玻璃管等物品使用的无效哨兵材料,属于预期身份而不是可删除注册项。12 个测试附属材料只存在于测试运行,不进入核心目录。 - -本轮没有任何材料、物品、方块、流体、NBT、配方或存档身份可依据“无来源、无终端”证明删除,因此全部保留。07-E 只修复了一处双平台成分遗漏:NeoForge 原先只为 16 个 `oreVanillastone` 物品提交成分,而 Forge 为 396 个;共享 `MaterialItemCompositions` 现在通过实际 `OreBlock`/`DenseOreBlock`/`VanillaOreBlock` 类型统一提交,注册 ID 与资源身份不变。最终两边均为 396。 - -## 无静态配方来源的九族 - -| 形态 | 获得途径 | 消费者/保留理由 | -| --- | --- | --- | -| `coin` | 铸币台压印;地牢生成硬币堆 | 硬币堆存取、掉落过期入堆、铸模和世界生成仍消费该身份 | -| `ore` | 世界生成矿石方块 | 破碎、洗矿、离心、金属与石材处理输入 | -| `oreSmall` | 小矿世界生成 | 小矿采掘/掉落终端;GT6 明确不为小矿伪造 RecipeMap 输入 | -| `oreDense` | 现有晶体/岩石矿石方块和地层生成 | 按 2U 进入矿石处理、热配方和坩埚输入 | -| `oreVanillastone` | 现有普通矿石方块身份 | 按标准矿石进入处理、熔炼和坩埚输入;本轮修复 NeoForge 缺失成分 | -| `pipeRestrictiveMedium` | 中型物品管道的手工配方 | 限制型物流路由与热回收输入 | -| `pipeRestrictiveLarge` | 大型物品管道的手工配方 | 限制型物流路由与热回收输入 | -| `pipeRestrictiveHuge` | 巨型物品管道的手工配方 | 限制型物流路由与热回收输入 | -| `unit` | 不是可获取的物理材料 | 查看器材料单位占位;挤压、熔炼和坩埚只把对应 289 个身份作为显示/配方单位,不把全部 745 个误当物理燃料 | - -## 全量形态清单 - -“来源”为静态配方输出数,“消费者”为静态配方输入数;括号内分别记录物品/方块。未列入上述九族的形态都至少同时具有实际获得路径和实际输入终端。全部决定均为保留,故本阶段没有兼容迁移、存档迁移或 parity 删除记录。 - -| 形态 | 物品 | 方块 | 来源(物品/方块) | 消费者(物品/方块) | -| --- | ---: | ---: | ---: | ---: | -| `arrowGtPlastic` | 437 | 0 | 272 / 0 | 372 / 0 | -| `arrowGtWood` | 437 | 0 | 272 / 0 | 315 / 0 | -| `billet` | 258 | 0 | 258 / 0 | 258 / 0 | -| `blockDust` | 0 | 685 | 680 / 680 | 682 / 682 | -| `blockGem` | 0 | 154 | 149 / 149 | 154 / 154 | -| `blockIngot` | 0 | 258 | 254 / 254 | 258 / 258 | -| `blockPlate` | 0 | 350 | 350 / 350 | 350 / 350 | -| `blockPlateGem` | 0 | 151 | 151 / 151 | 151 / 151 | -| `blockRaw` | 0 | 420 | 420 / 420 | 420 / 420 | -| `blockSolid` | 0 | 258 | 223 / 223 | 258 / 258 | -| `bolt` | 473 | 0 | 473 / 0 | 473 / 0 | -| `bouleGt` | 11 | 0 | 11 / 0 | 11 / 0 | -| `bulletGtLarge` | 437 | 0 | 433 / 0 | 437 / 0 | -| `bulletGtMedium` | 437 | 0 | 433 / 0 | 437 / 0 | -| `bulletGtSmall` | 437 | 0 | 433 / 0 | 437 / 0 | -| `casingMachine` | 0 | 124 | 121 / 121 | 124 / 124 | -| `casingMachineDense` | 0 | 124 | 121 / 121 | 124 / 124 | -| `casingMachineDouble` | 0 | 124 | 121 / 121 | 124 / 124 | -| `casingMachineQuadruple` | 0 | 124 | 121 / 121 | 124 / 124 | -| `chain` | 407 | 0 | 407 / 0 | 407 / 0 | -| `chunkGt` | 258 | 0 | 184 / 0 | 258 / 0 | -| `coin` | 351 | 0 | 0 / 0 | 0 / 0 | -| `crushed` | 420 | 0 | 420 / 0 | 420 / 0 | -| `crushedCentrifuged` | 420 | 0 | 420 / 0 | 420 / 0 | -| `crushedCentrifugedTiny` | 420 | 0 | 420 / 0 | 420 / 0 | -| `crushedPurified` | 420 | 0 | 420 / 0 | 420 / 0 | -| `crushedPurifiedTiny` | 420 | 0 | 420 / 0 | 420 / 0 | -| `crushedTiny` | 420 | 0 | 420 / 0 | 420 / 0 | -| `dust` | 693 | 0 | 688 / 0 | 693 / 0 | -| `dustDiv72` | 688 | 0 | 688 / 0 | 688 / 0 | -| `dustSmall` | 688 | 0 | 688 / 0 | 688 / 0 | -| `dustTiny` | 688 | 0 | 687 / 0 | 688 / 0 | -| `foil` | 258 | 0 | 217 / 0 | 258 / 0 | -| `gearGt` | 407 | 0 | 253 / 0 | 407 / 0 | -| `gearGtSmall` | 407 | 0 | 253 / 0 | 407 / 0 | -| `gem` | 164 | 0 | 153 / 0 | 164 / 0 | -| `gemChipped` | 154 | 0 | 153 / 0 | 154 / 0 | -| `gemExquisite` | 150 | 0 | 150 / 0 | 150 / 0 | -| `gemFlawed` | 153 | 0 | 153 / 0 | 153 / 0 | -| `gemFlawless` | 150 | 0 | 150 / 0 | 150 / 0 | -| `gemLegendary` | 150 | 0 | 138 / 0 | 150 / 0 | -| `ingot` | 265 | 0 | 253 / 0 | 265 / 0 | -| `ingotDouble` | 220 | 0 | 203 / 0 | 220 / 0 | -| `ingotQuadruple` | 220 | 0 | 203 / 0 | 220 / 0 | -| `ingotQuintuple` | 220 | 0 | 203 / 0 | 220 / 0 | -| `ingotTriple` | 220 | 0 | 203 / 0 | 220 / 0 | -| `itemCasing` | 407 | 0 | 407 / 0 | 407 / 0 | -| `lens` | 108 | 0 | 108 / 0 | 108 / 0 | -| `minecartWheels` | 207 | 0 | 7 / 0 | 207 / 0 | -| `nugget` | 260 | 0 | 258 / 0 | 260 / 0 | -| `ore` | 0 | 380 | 0 / 0 | 380 / 380 | -| `oreDense` | 21 | 0 | 0 / 0 | 21 / 0 | -| `oreRaw` | 420 | 0 | 420 / 0 | 420 / 0 | -| `oreSmall` | 0 | 380 | 0 / 0 | 0 / 0 | -| `oreVanillastone` | 396 | 0 | 0 / 0 | 396 / 0 | -| `pipeHuge` | 50 | 0 | 49 / 0 | 50 / 0 | -| `pipeLarge` | 50 | 0 | 49 / 0 | 50 / 0 | -| `pipeMedium` | 50 | 0 | 50 / 0 | 50 / 0 | -| `pipeNonuple` | 31 | 0 | 31 / 0 | 31 / 0 | -| `pipeQuadruple` | 31 | 0 | 31 / 0 | 31 / 0 | -| `pipeRestrictiveHuge` | 19 | 0 | 0 / 0 | 19 / 0 | -| `pipeRestrictiveLarge` | 19 | 0 | 0 / 0 | 19 / 0 | -| `pipeRestrictiveMedium` | 19 | 0 | 0 / 0 | 19 / 0 | -| `pipeSmall` | 31 | 0 | 31 / 0 | 31 / 0 | -| `pipeTiny` | 31 | 0 | 30 / 0 | 31 / 0 | -| `plate` | 377 | 0 | 375 / 0 | 377 / 0 | -| `plateCurved` | 350 | 0 | 267 / 0 | 350 / 0 | -| `plateDense` | 222 | 0 | 219 / 0 | 222 / 0 | -| `plateDouble` | 220 | 0 | 206 / 0 | 220 / 0 | -| `plateGem` | 151 | 0 | 150 / 0 | 151 / 0 | -| `plateGemTiny` | 151 | 0 | 151 / 0 | 151 / 0 | -| `plateQuadruple` | 220 | 0 | 206 / 0 | 220 / 0 | -| `plateQuintuple` | 220 | 0 | 206 / 0 | 220 / 0 | -| `plateTiny` | 351 | 0 | 351 / 0 | 351 / 0 | -| `plateTriple` | 220 | 0 | 206 / 0 | 220 / 0 | -| `railGt` | 25 | 0 | 25 / 0 | 25 / 0 | -| `ring` | 407 | 0 | 361 / 0 | 407 / 0 | -| `rockGt` | 449 | 0 | 22 / 0 | 449 / 0 | -| `rotor` | 407 | 0 | 205 / 0 | 407 / 0 | -| `round` | 383 | 0 | 231 / 0 | 383 / 0 | -| `scrapGt` | 688 | 0 | 207 / 0 | 688 / 0 | -| `screw` | 473 | 0 | 473 / 0 | 473 / 0 | -| `spring` | 407 | 0 | 209 / 0 | 407 / 0 | -| `springSmall` | 407 | 0 | 209 / 0 | 407 / 0 | -| `stick` | 475 | 0 | 473 / 0 | 475 / 0 | -| `stickLong` | 473 | 0 | 286 / 0 | 473 / 0 | -| `toolHeadArrow` | 271 | 0 | 271 / 0 | 271 / 0 | -| `toolHeadAxe` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadAxeDouble` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadBuilderwand` | 185 | 0 | 8 / 0 | 185 / 0 | -| `toolHeadBuzzSaw` | 185 | 0 | 8 / 0 | 185 / 0 | -| `toolHeadChainsaw` | 185 | 0 | 8 / 0 | 17 / 0 | -| `toolHeadChisel` | 185 | 0 | 185 / 0 | 185 / 0 | -| `toolHeadConstructionPickaxe` | 275 | 0 | 8 / 0 | 275 / 0 | -| `toolHeadDrill` | 185 | 0 | 8 / 0 | 17 / 0 | -| `toolHeadFile` | 185 | 0 | 117 / 0 | 185 / 0 | -| `toolHeadHammer` | 266 | 0 | 147 / 0 | 266 / 0 | -| `toolHeadHoe` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadPickaxe` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadPickaxeGem` | 154 | 0 | 1 / 0 | 153 / 0 | -| `toolHeadPlow` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadRawArrow` | 271 | 0 | 10 / 0 | 271 / 0 | -| `toolHeadRawAxe` | 275 | 0 | 155 / 0 | 275 / 0 | -| `toolHeadRawAxeDouble` | 275 | 0 | 8 / 0 | 275 / 0 | -| `toolHeadRawChisel` | 185 | 0 | 8 / 0 | 185 / 0 | -| `toolHeadRawHoe` | 275 | 0 | 155 / 0 | 275 / 0 | -| `toolHeadRawPickaxe` | 275 | 0 | 155 / 0 | 275 / 0 | -| `toolHeadRawPlow` | 275 | 0 | 10 / 0 | 275 / 0 | -| `toolHeadRawSaw` | 185 | 0 | 117 / 0 | 185 / 0 | -| `toolHeadRawSense` | 275 | 0 | 10 / 0 | 275 / 0 | -| `toolHeadRawShovel` | 275 | 0 | 155 / 0 | 275 / 0 | -| `toolHeadRawSpade` | 275 | 0 | 10 / 0 | 275 / 0 | -| `toolHeadRawSword` | 275 | 0 | 155 / 0 | 275 / 0 | -| `toolHeadRawUniversalSpade` | 185 | 0 | 8 / 0 | 185 / 0 | -| `toolHeadSaw` | 185 | 0 | 185 / 0 | 185 / 0 | -| `toolHeadScrewdriver` | 185 | 0 | 8 / 0 | 185 / 0 | -| `toolHeadSense` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadShovel` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadSpade` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadSword` | 275 | 0 | 275 / 0 | 275 / 0 | -| `toolHeadUniversalSpade` | 185 | 0 | 185 / 0 | 185 / 0 | -| `toolHeadWrench` | 185 | 0 | 8 / 0 | 17 / 0 | -| `unit` | 745 | 0 | 0 / 0 | 289 / 0 | -| `wireFine` | 216 | 0 | 214 / 0 | 216 / 0 | - -## 修复与回归 - -`MaterialItemCompositions.registerOreBlockComposition(Block)` 统一识别三类实际矿石方块: - -- `DenseOreBlock` → `oreDense` -- `VanillaOreBlock` → `oreVanillastone` -- 非小型 `OreBlock` → `oreVanillastone` - -共享 `registerCommon()` 遍历 `GTBlocks`,Forge 和 NeoForge 的平台图标方块注册器复用同一函数。这样平台注册位置仍由各自加载器决定,材料成分事实不再由 Forge 专属代码单独补齐。 - -新增 GameTest `oreBlocksUseTheirDeclaredMaterialForm` 遍历当前平台实际注册的所有上述矿石方块,检查其物品成分存在、形态正确且材料与方块声明一致。最终双平台快照中 `oreVanillastone` 均为 396,124 个形态族的物品和方块计数全部一致。 - -## 验证 - -执行且通过: - -- `compileBothPlatforms`:Forge 与 NeoForge 生产源码编译通过。 -- 定向 Spotless:四个改动源码文件输出 `IS CLEAN`。 -- Forge `runGameTestServer`:`All 95 required tests passed`。 -- NeoForge `runGameTestServer`:`All 100 required tests passed`。 -- 双平台最终运行时快照:124 个形态族、31,137 个材料物品、3,532 个材料方块形态,逐族计数一致;`oreVanillastone` 均为 396。 - -执行但失败或阻塞:无。 - -尚未执行: - -- 07-F 的完整来源/用途索引、有界处理图、远程客户端 tooltip/JEI/EMI 和机器手工交互。 -- 最终 Forge `distributionJar`/NeoForge `jar` 的发行包内容检查。 -- 真实外部附属材料与可选模组环境。 - -本报告证明的是 07-E 的材料/形态去留清单和本轮必要迁移,不等同于 07-F 的完整处理图验收。08-D—E 已把静态配方、活动世界生成和符号单位选择器接入同一快照,但动态族不展开为全体物理候选;完整边集合仍须按运行期清单确认覆盖范围。 diff --git a/docs/integration/report-template.md b/docs/integration/report-template.md deleted file mode 100644 index 0f4806c38..000000000 --- a/docs/integration/report-template.md +++ /dev/null @@ -1,26 +0,0 @@ -# 验证结论模板 - -复制为有意义的主题文件并挂到[目录](README.md)。删除不适用项,不能将本模板当真实验证结果。状态表述、证据要求与记录格式见[验证与验收](../development/validation/README.md#结果与证据)。 - -## 范围与状态 - -- 主题、目标行为、排除范围:待填。 -- 状态:未验证 / 部分验证 / 在下述范围验证通过 / 已知失败。 -- 源码依据:提交号;无提交或有本地修改时说明源码状态,必要时关联构建校验值。 -- 平台:MC、加载器、JDK、GT6CE 构建及可选模组精确版本。 - -## 来源与差异 - -记录上游仓库、版本/提交、文件/符号、适用许可及转换依据。说明数量、温度、能源、方向或概率等语义如何对应;区分已确认事实和推断。 - -## 复现与观察 - -| 场景 | 前置条件与操作 | 预期 | 实际 | 平台与判定 | -| --- | --- | --- | --- | --- | -| 待填 | 待填 | 待填 | 未执行 | 待填 | - -列出实际执行命令、关键观察与最小必要日志摘录。原始证据如只在本地 `work/`,注明它不随仓库提交;复现步骤及关键结论必须自含,不能只写一个他人无法访问的本机路径。 - -## 结论与剩余事项 - -说明通过范围、未执行场景、已知差异、风险与后续工作。只有确实需要长期取舍时链接[决策](../decisions/README.md),实际部署另链接[执行记录](../operations/records/README.md)。 diff --git a/docs/operations/README.md b/docs/operations/README.md deleted file mode 100644 index e5b282aea..000000000 --- a/docs/operations/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# 发布、实例更新与执行记录 - -本项目的可交付物是模组 JAR,不存在本文隐含的生产发布服务。这里维护可重复执行的构建/更新流程;真正操作实例需在用户授权范围内进行。 - -本页负责构建交付与实例更新流程;检查选择见[验证与验收](../development/validation/README.md),执行后使用[执行记录模板](records/TEMPLATE.md)。 - -## 准备产物 - -1. 记录源码状态;正式可追踪构建使用提交号,有本地改动或无初始提交时如实标注,不能伪造版本来源。 -2. 按[组装检查](../development/validation/checks/assemble.md)构建目标平台并选择最终模组 JAR。 -3. 核对平台、版本和 JAR 内容,记录 SHA-256(如 `sha256sum <实际文件>`)。 -4. 按[验证与验收](../development/validation/README.md)完成相关检查,明确编译、打包、启动和玩法验证各自的状态。 - -## 更新隔离实例 - -先完整备份世界、配置和脚本,保留旧模组与匹配依赖清单;将更新放在隔离测试实例验证。停止实例后替换为匹配 MC/加载器的 JAR,避免目录内同时存在两个 GT6CE 版本,再启动检查加载日志、注册、关键机器/配方及客户端连接。 - -具体目标目录、访问凭据和完整配置放本地 `work/<任务名>/` 或合适的秘密管理位置;公共记录只保留“隔离 NeoForge 测试实例”等非敏感目标别名。不要从文档中的示例自动推断服务器路径或发布渠道,也不要替操作者接受 EULA。 - -## 恢复与归档 - -存档不保证跨开发构建兼容。新版改写过存档后,不能仅换回旧 JAR 充当恢复;应从更新前一致的世界、配置、脚本及模组快照恢复,在隔离实例验证。记录是否实际执行/验证恢复,未验证就明确写出。 - -执行结束后,按[记录目录](records/README.md)归档来源、产物校验值、操作、结果与恢复信息。只完成交付构建时记录“仅构建,未部署”;普通开发编译无需建立记录。长期兼容结论另存 [integration](../integration/README.md)。 diff --git a/docs/operations/records/README.md b/docs/operations/records/README.md deleted file mode 100644 index 145fd7964..000000000 --- a/docs/operations/records/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# 执行记录 - -本目录收录实际执行后的构建交付、发布或实例更新记录。流程见[发布、实例更新与执行记录](../README.md),新记录复制[模板](TEMPLATE.md),完成后在下方添加链接。目前只有模板。 - -文件命名为 `YYYY-MM-DD--.md`,同日多次增加后缀,正文写明时区。公共记录须脱敏;私有参数与原始日志按[文件与产物归属](../../development/repository-layout.md#临时内容如何沉淀)保存。普通开发编译和文档修改无需建立记录。 - -## 目录 - -- [执行记录模板](TEMPLATE.md) diff --git a/docs/operations/records/TEMPLATE.md b/docs/operations/records/TEMPLATE.md deleted file mode 100644 index d7191d434..000000000 --- a/docs/operations/records/TEMPLATE.md +++ /dev/null @@ -1,28 +0,0 @@ -# 执行记录模板 - -此文件仅作模板,复制并填入实际观察后才是执行记录,入口见[执行记录目录](README.md)。状态表述、证据要求与“未验证/部分验证/在下述范围验证通过/已知失败”的写法见[验证与验收](../../development/validation/README.md#结果与证据)。 - -## 基本信息 - -- 时间与时区:待填。 -- 操作者、任务/变更链接:仅填写适合公开的信息。 -- 目标别名与平台:MC、加载器、JDK、依赖模组版本;不填写私有地址或凭据。 -- 源码提交/工作区状态:待填;未提交变更必须说明。 -- 模组版本、产物文件名、SHA-256:待填。 -- 操作状态:仅构建 / 未开始更新 / 更新失败 / 已更新待验证 / 已在下述范围验证。 - -## 前置检查 - -记录实际执行的构建命令和结果、产物检查、更新前备份标识及恢复材料是否齐备。若不涉及部署,写“不适用,未部署”;不要勾选未执行步骤。 - -## 执行与验证 - -| 步骤/场景 | 命令或操作(脱敏) | 实际观察 | 判定 | -| --- | --- | --- | --- | -| 待填 | 待填 | 未执行 | 未验证 | - -补充已覆盖的平台/客户端/服务端/关键功能,以及明确未覆盖的场景。日志只摘必要信息;原始材料如果仅在本地保留,要说明公共记录不包含它们。 - -## 异常、恢复与后续 - -记录问题、处理、是否实际恢复、恢复所用的一致快照和恢复验证结果。单纯替换回旧 JAR 不证明存档已恢复。写明当前实例状态和待办,必要时链接集成结论或决策。 diff --git a/docs/roadmap/v1.0.md b/docs/roadmap/v1.0.md deleted file mode 100644 index 10a4596f5..000000000 --- a/docs/roadmap/v1.0.md +++ /dev/null @@ -1,51 +0,0 @@ -# GT6CE v1.0 路线图 - -## 方针 - -- **非侵入式**:不删除或替换其他模组的配方、世界生成、方块与物品,不通过加载顺序或全局事件改写他人内容。 -- **奥卡姆剃刀**:不做无意义的内容和玩法。优先使用原版或联动模组本身的内容。 -- **自洽性**:材料、配方、进度与世界生成形成闭环。未安装联动时本体完整可玩。 -- **联动附属化**:可选玩法、联动兼容与非核心系统移出本体,本体只保留核心玩法与基础内容。 -- **可配置**:尽可能使用可配置项来提供不同的游戏体验。 - -## 架构 - -- **API**:包含接入接口、系统运行规则。 -- **本体**:包含核心玩法与基础内容。 -- **附属**:包含联动兼容、非核心玩法与可选内容。 - -## 主要玩法系统变更 - -### 新增 - -(待社区商议决定) - -### 重做 - -(待社区商议决定) - -### 迁出 - -(待社区商议决定) - -### 删除 - -(待社区商议决定) - -## 路线图 - -- **1.0**:发布 -- **1.1**:API 稳定,汉化项目迁移且稳定,CI 诊断与构建稳定 -- **1.2**:无缺陷,基本自洽,联动附属化 -- **1.3**:首个小内容更新 -- **2.0**:首个大内容更新 - -## 项目管理 - -- **汇报问题**:写清问题、复现步骤、预期结果与实际结果,并附上相关日志。 -- **提交建议**:描述立意、修改内容,确认提议符合设计准则。 -- **PR**:说明立意、修改内容和范围、实际测试结果。 -- **RFC**:重大更改需要先建立 RFC issue,公开讨论并经维护者合议后决定,通过 RFC PR 合入。 -- **文档管理**:遵循项目内已有的规范,将应该记录的事项记录在规定位置。 -- **行为差异**:与 GT6 的行为差异需要记录原始行为、差异、原因与影响。 -- **可更改性**:方针与路线图不是固定的,社区可以通过 RFC 讨论、维护者合议后修改。 diff --git a/tools/material/README.md b/tools/material/README.md index 5cc7bcb62..dbae8f1ff 100644 --- a/tools/material/README.md +++ b/tools/material/README.md @@ -36,4 +36,4 @@ python3 tools/material/audit_roster.py \ ## 维护 -快照列格式变化时同步修改 `recipe_items`、物品 prefix 读取和方块形态读取。最终清单口径变化时应同时更新 [07-E 验收报告](../../docs/integration/material-refactor-07-roster.md)。 +快照列格式变化时同步修改 `recipe_items`、物品 prefix 读取和方块形态读取。若重新建立常驻快照入口,长期字段口径应写入对应的架构或验证文档。 From b577d8a14a0ba44ad6c7cb16c81bf8ae727aa6dd Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Mon, 16 Nov 2026 09:18:15 +0800 Subject: [PATCH 12/17] revert remove roadmap docs --- docs/roadmap/v1.0.md | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 docs/roadmap/v1.0.md diff --git a/docs/roadmap/v1.0.md b/docs/roadmap/v1.0.md new file mode 100644 index 000000000..10a4596f5 --- /dev/null +++ b/docs/roadmap/v1.0.md @@ -0,0 +1,51 @@ +# GT6CE v1.0 路线图 + +## 方针 + +- **非侵入式**:不删除或替换其他模组的配方、世界生成、方块与物品,不通过加载顺序或全局事件改写他人内容。 +- **奥卡姆剃刀**:不做无意义的内容和玩法。优先使用原版或联动模组本身的内容。 +- **自洽性**:材料、配方、进度与世界生成形成闭环。未安装联动时本体完整可玩。 +- **联动附属化**:可选玩法、联动兼容与非核心系统移出本体,本体只保留核心玩法与基础内容。 +- **可配置**:尽可能使用可配置项来提供不同的游戏体验。 + +## 架构 + +- **API**:包含接入接口、系统运行规则。 +- **本体**:包含核心玩法与基础内容。 +- **附属**:包含联动兼容、非核心玩法与可选内容。 + +## 主要玩法系统变更 + +### 新增 + +(待社区商议决定) + +### 重做 + +(待社区商议决定) + +### 迁出 + +(待社区商议决定) + +### 删除 + +(待社区商议决定) + +## 路线图 + +- **1.0**:发布 +- **1.1**:API 稳定,汉化项目迁移且稳定,CI 诊断与构建稳定 +- **1.2**:无缺陷,基本自洽,联动附属化 +- **1.3**:首个小内容更新 +- **2.0**:首个大内容更新 + +## 项目管理 + +- **汇报问题**:写清问题、复现步骤、预期结果与实际结果,并附上相关日志。 +- **提交建议**:描述立意、修改内容,确认提议符合设计准则。 +- **PR**:说明立意、修改内容和范围、实际测试结果。 +- **RFC**:重大更改需要先建立 RFC issue,公开讨论并经维护者合议后决定,通过 RFC PR 合入。 +- **文档管理**:遵循项目内已有的规范,将应该记录的事项记录在规定位置。 +- **行为差异**:与 GT6 的行为差异需要记录原始行为、差异、原因与影响。 +- **可更改性**:方针与路线图不是固定的,社区可以通过 RFC 讨论、维护者合议后修改。 From 94a47639a40dc74192ca371eab51f5dd36e83d80 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Mon, 16 Nov 2026 14:59:43 +0800 Subject: [PATCH 13/17] bugfix --- .../addon/material/SpecialProcessValue.java | 3 +- .../addon/material/SpecialProcessesView.java | 12 - .../content/material/MaterialFactKeys.java | 16 +- .../catalog/GenerifyingMaterialFacts.java | 3 +- .../catalog/MaterialFluidUnitFacts.java | 3 +- .../PurifiedCentrifugeMaterialFacts.java | 11 +- .../catalog/ReviewedOreMaterialFacts.java | 32 ++- .../catalog/ReviewedSourceMaterialFacts.java | 5 +- .../catalog/SourceExtrusionMaterialFacts.java | 3 +- .../catalog/SourceLensMaterialFacts.java | 3 +- .../SourceMacerationMaterialFacts.java | 2 +- .../SourceOreCrushingMaterialFacts.java | 2 +- .../catalog/SourceRecyclingMaterialFacts.java | 5 +- .../catalog/SourceWashingMaterialFacts.java | 2 +- .../content/recipe/SpecialProcessMethods.java | 4 +- .../material/MaterialItemDefinitions.java | 1 - .../engine/material/MaterialProcessGraph.java | 5 +- .../engine/material/MaterialPublication.java | 33 ++- .../resources/assets/gt6ce/lang/en_us.json | 67 +++++- .../resources/assets/gt6ce/lang/zh_cn.json | 9 +- .../material/MaterialProcessGraphTest.java | 27 ++- .../material/MaterialProcessLanguageTest.java | 35 +++ docs/ADDON_API.zh-CN.md | 10 +- docs/architecture/packages/api.md | 2 +- docs/architecture/packages/content.md | 4 +- docs/architecture/packages/engine.md | 2 +- docs/architecture/packages/runtime.md | 4 +- docs/decisions/material-system/README.md | 2 +- .../data-api-and-publication.md | 17 +- .../development/validation/checks/gametest.md | 2 +- .../validation/checks/manual-ingame.md | 4 +- docs/development/validation/routes.yaml | 5 + .../MaterialProcessOverview.java | 21 +- .../gregtech/client/MaterialProcessPanel.java | 8 +- .../client/MultiblockPreviewPanel.java | 1 + .../compat/common/MaterialProcessDisplay.java | 9 + .../common/MaterialProcessProjection.java | 13 +- .../{jei => common}/PreviewViewport.java | 2 +- .../{jei => common}/RecipeMachines.java | 2 +- .../compat/common/RecipeViewerIcons.java | 17 +- .../{jei => common}/WorldgenInfoData.java | 6 +- .../gregtech/compat/emi/EmiWidgetInput.java | 2 +- .../compat/emi/GregTechEMIPlugin.java | 2 +- .../compat/emi/StructureEmiRecipe.java | 1 + .../compat/emi/WorldgenEmiRecipe.java | 2 +- .../compat/jei/GregTechJEIPlugin.java | 32 ++- .../compat/jei/MaterialProcessJeiRecipes.java | 227 ++++++++++++++++++ .../compat/jei/MultiblockInfoCategory.java | 1 + .../compat/jei/RecipeMapCategory.java | 1 + .../gregtech/compat/jei/StructurePreview.java | 1 + .../compat/jei/WorldgenInfoCategories.java | 2 + .../content/recipe/MachineRecipeOverlay.java | 2 +- .../recipe/MaterialProcessSnapshot.java | 78 +++++- .../recipe/SharedSpecialProcessRows.java | 27 ++- .../worldgen/MaterialWorldgenFacts.java | 87 +++++-- .../resources/gregtech-neoforge.mixins.json | 2 + tools/README.md | 1 + 57 files changed, 712 insertions(+), 170 deletions(-) create mode 100644 core/src/test/java/gregtech/engine/material/MaterialProcessLanguageTest.java rename minecraft/src/main/java/gregtech/{compat/common => client}/MaterialProcessOverview.java (98%) rename minecraft/src/main/java/gregtech/compat/{jei => common}/PreviewViewport.java (97%) rename minecraft/src/main/java/gregtech/compat/{jei => common}/RecipeMachines.java (99%) rename minecraft/src/main/java/gregtech/compat/{jei => common}/WorldgenInfoData.java (98%) create mode 100644 minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java diff --git a/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessValue.java b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessValue.java index ede56dd3c..5bbfc90ac 100644 --- a/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessValue.java +++ b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessValue.java @@ -27,8 +27,7 @@ record Target( if (inputCounts.isEmpty()) throw new IllegalArgumentException("Special process target has no input form"); for (var entry : inputCounts.entrySet()) { Objects.requireNonNull(entry.getKey(), "input form"); - if (entry.getValue() == null || entry.getValue() < 1) - throw new IllegalArgumentException("Invalid special process input count"); + if (entry.getValue() < 1) throw new IllegalArgumentException("Invalid special process input count"); } itemOutputs = List.copyOf(itemOutputs); fluidOutputs = List.copyOf(fluidOutputs); diff --git a/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessesView.java b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessesView.java index d4754d418..d7e40caa7 100644 --- a/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessesView.java +++ b/api/common/src/main/java/gregtech/api/addon/material/SpecialProcessesView.java @@ -7,18 +7,6 @@ /** Immutable special-process method declarations from the current material publication. */ public interface SpecialProcessesView { - SpecialProcessesView NONE = new SpecialProcessesView() { - @Override - public List methods() { - return List.of(); - } - - @Override - public Optional find(DataKey id) { - return Optional.empty(); - } - }; - List methods(); Optional find(DataKey id); diff --git a/core/src/main/java/gregtech/content/material/MaterialFactKeys.java b/core/src/main/java/gregtech/content/material/MaterialFactKeys.java index f886fd99d..5cadcd1ff 100644 --- a/core/src/main/java/gregtech/content/material/MaterialFactKeys.java +++ b/core/src/main/java/gregtech/content/material/MaterialFactKeys.java @@ -1,14 +1,14 @@ package gregtech.content.material; -import gregtech.api.addon.material.DataKey; -import gregtech.api.addon.material.MaterialInfoTool; -import gregtech.api.addon.material.MaterialKey; -import gregtech.api.addon.material.MaterialProcessKey; +import gregtech.api.addon.material.*; import gregtech.api.material.GTMaterial; import gregtech.content.material.catalog.SourceExtrusionMaterialFacts; import gregtech.content.material.catalog.SourceLensMaterialFacts; import gregtech.content.material.catalog.SourceRecyclingMaterialFacts; import gregtech.content.material.catalog.SourceWashingMaterialFacts; + +import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; @@ -16,6 +16,14 @@ public final class MaterialFactKeys { private MaterialFactKeys() {} + public static void put( + Map, List>> rules, + MaterialProcessKey key, + List> values) { + if (rules.putIfAbsent(key, List.copyOf(values)) != null) + throw new IllegalArgumentException("Duplicate material process fact " + key.id()); + } + public enum Decision { YES, NO, diff --git a/core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java index 225de9944..8051db51d 100644 --- a/core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/GenerifyingMaterialFacts.java @@ -58,7 +58,8 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (target == null || target == declaration.id()) return declaration; var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); - rules.put( + MaterialFactKeys.put( + rules, MaterialFactKeys.GENERIFICATION_TARGET, List.of(MaterialProcessRule.anyForm(new MaterialFactKeys.GenerificationTarget(target)))); return new MaterialDefinition.Declaration( diff --git a/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java b/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java index d454d0164..bdec71aba 100644 --- a/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/MaterialFluidUnitFacts.java @@ -166,7 +166,8 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (values.isEmpty()) return declaration; var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); - rules.put( + MaterialFactKeys.put( + rules, MaterialFactKeys.MATERIAL_FLUID_UNIT, List.of(MaterialProcessRule.anyForm(new MaterialFactKeys.MaterialFluidUnits(Set.copyOf(values))))); return new MaterialDefinition.Declaration( diff --git a/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java index f442cfe7d..8606beabe 100644 --- a/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/PurifiedCentrifugeMaterialFacts.java @@ -44,10 +44,15 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); if (phase != null) - rules.put(MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_PHASE, List.of(MaterialProcessRule.anyForm(phase))); + MaterialFactKeys.put( + rules, + MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_PHASE, + List.of(MaterialProcessRule.anyForm(phase))); if (none != null) - rules.put( - MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT, List.of(MaterialProcessRule.anyForm(none))); + MaterialFactKeys.put( + rules, + MaterialFactKeys.SOURCE_PURIFIED_CENTRIFUGE_NO_DEFAULT, + List.of(MaterialProcessRule.anyForm(none))); return new MaterialDefinition.Declaration( declaration.material(), new MaterialInfoDefinition( diff --git a/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java index b3bcdfe5e..2eb631965 100644 --- a/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/ReviewedOreMaterialFacts.java @@ -106,38 +106,50 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio var rules = new LinkedHashMap<>(info.processes().rules()); String name = declaration.name(); if (name.equals(ORE_INPUT_NO.get(declaration.id()))) { - rules.put( + MaterialFactKeys.put( + rules, MaterialFactKeys.SOURCE_ORE_INPUT, List.of(MaterialProcessRule.anyForm(MaterialFactKeys.Decision.NO))); } var shredder = SHREDDER.get(declaration.id()); if (shredder != null && shredder.name().equals(name)) { - rules.put(MaterialFactKeys.SOURCE_ORE_SHREDDER, List.of(MaterialProcessRule.anyForm(shredder.profile()))); + MaterialFactKeys.put( + rules, + MaterialFactKeys.SOURCE_ORE_SHREDDER, + List.of(MaterialProcessRule.anyForm(shredder.profile()))); } if (name.equals(CRUSHED_SOURCE_MATERIALS.get(declaration.id()))) { - rules.put( + MaterialFactKeys.put( + rules, MaterialFactKeys.SOURCE_CRUSHED_EXCLUSIONS, List.of(MaterialProcessRule.anyForm(new MaterialFactKeys.PrefixExclusions(CRUSHED_EXCLUSIONS)))); } if (declaration.id() == 9114 && name.equals("Cinnabar")) { - rules.put( - MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON, List.of(MaterialProcessRule.anyForm(CINNABAR_FOLLOWON))); + MaterialFactKeys.put( + rules, + MaterialFactKeys.SOURCE_CINNABAR_FOLLOWON, + List.of(MaterialProcessRule.anyForm(CINNABAR_FOLLOWON))); } var generatedFluid = generatedFluid(declaration.id(), name); if (generatedFluid != null) { - rules.put( + MaterialFactKeys.put( + rules, MaterialFactKeys.SOURCE_GENERATED_FLUID, List.of(MaterialProcessRule.anyForm( new MaterialFactKeys.GeneratedFluidRules(Set.of(generatedFluid))))); } if (declaration.id() == 8745 && name.equals("Netherite") || declaration.id() == 1740 && name.equals("Naquadah")) { - rules.put( - MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY, List.of(MaterialProcessRule.anyForm(Boolean.TRUE))); + MaterialFactKeys.put( + rules, + MaterialFactKeys.SOURCE_ADDITIONAL_WIRE_FAMILY, + List.of(MaterialProcessRule.anyForm(Boolean.TRUE))); } if (declaration.id() == 9802 && name.equals("Ice")) { - rules.put( - MaterialFactKeys.COMPRESSOR_DUST_TO_GEM_PLATE, List.of(MaterialProcessRule.anyForm(Boolean.FALSE))); + MaterialFactKeys.put( + rules, + MaterialFactKeys.COMPRESSOR_DUST_TO_GEM_PLATE, + List.of(MaterialProcessRule.anyForm(Boolean.FALSE))); } if (rules.equals(info.processes().rules())) return declaration; return new MaterialDefinition.Declaration( diff --git a/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java index 68d94b0dc..5f196eb15 100644 --- a/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java @@ -290,10 +290,11 @@ public static MaterialDefinition.Declaration applyOne(MaterialDefinition.Declara for (var entry : ENTRIES) { if (entry.id != declaration.id() || !GTMaterial.sanitize(entry.name).equals(declaration.name())) continue; var key = entry.rule == Rule.FURNACE ? MaterialFactKeys.SOURCE_FURNACE : MaterialFactKeys.SOURCE_GRADED_GEM; - rules.put(key, List.of(MaterialProcessRule.anyForm(entry.decision))); + MaterialFactKeys.put(rules, key, List.of(MaterialProcessRule.anyForm(entry.decision))); } if (declaration.id() == 9802 && declaration.name().equals("Ice")) { - rules.put( + MaterialFactKeys.put( + rules, MaterialFactKeys.SOURCE_SIFTING_EXCLUSIONS, List.of(MaterialProcessRule.anyForm(new MaterialFactKeys.PrefixExclusions(SIFTING_ABSENT)))); } diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java index 46e060ae4..93b22d98c 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceExtrusionMaterialFacts.java @@ -779,7 +779,8 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (row == null || !sameName(row.name(), declaration.name())) return declaration; var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); - rules.put(MaterialFactKeys.SOURCE_EXTRUSION, List.of(MaterialProcessRule.anyForm(row.profile()))); + MaterialFactKeys.put( + rules, MaterialFactKeys.SOURCE_EXTRUSION, List.of(MaterialProcessRule.anyForm(row.profile()))); return new MaterialDefinition.Declaration( declaration.material(), new MaterialInfoDefinition( diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java index 180f29d48..d3424e72e 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceLensMaterialFacts.java @@ -93,7 +93,8 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (!materialNameMatches(role.name, declaration.name())) continue; var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); - rules.put(MaterialFactKeys.SOURCE_LENS_ROLE, List.of(MaterialProcessRule.anyForm(role.color))); + MaterialFactKeys.put( + rules, MaterialFactKeys.SOURCE_LENS_ROLE, List.of(MaterialProcessRule.anyForm(role.color))); return new MaterialDefinition.Declaration( declaration.material(), new MaterialInfoDefinition( diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java index 76c999121..7cad09eb2 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceMacerationMaterialFacts.java @@ -100,7 +100,7 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (decision == MaterialFactKeys.Decision.UNKNOWN) return declaration; var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); - rules.put(MaterialFactKeys.SOURCE_MACERATION, List.of(MaterialProcessRule.anyForm(decision))); + MaterialFactKeys.put(rules, MaterialFactKeys.SOURCE_MACERATION, List.of(MaterialProcessRule.anyForm(decision))); return new MaterialDefinition.Declaration( declaration.material(), new MaterialInfoDefinition( diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java index 977693e1b..bde99a792 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceOreCrushingMaterialFacts.java @@ -19,7 +19,7 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio pulverizing(declaration.id(), declaration.name(), hexorium), hexorium); var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); - rules.put(MaterialFactKeys.SOURCE_ORE_CRUSHING, List.of(MaterialProcessRule.anyForm(fact))); + MaterialFactKeys.put(rules, MaterialFactKeys.SOURCE_ORE_CRUSHING, List.of(MaterialProcessRule.anyForm(fact))); return new MaterialDefinition.Declaration( declaration.material(), new MaterialInfoDefinition( diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java index 8d3196376..e59d22047 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java @@ -161,9 +161,10 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (facts == null) return declaration; var info = declaration.info(); var rules = new java.util.LinkedHashMap<>(info.processes().rules()); - rules.put(MaterialFactKeys.SOURCE_RECYCLING, List.of(MaterialProcessRule.anyForm(facts))); + MaterialFactKeys.put(rules, MaterialFactKeys.SOURCE_RECYCLING, List.of(MaterialProcessRule.anyForm(facts))); if (declaration.name().equals(SOURCE_MOLTEN_FLUIDS.get(declaration.id()))) { - rules.put(MaterialFactKeys.SOURCE_MOLTEN_FLUID, List.of(MaterialProcessRule.anyForm(Boolean.TRUE))); + MaterialFactKeys.put( + rules, MaterialFactKeys.SOURCE_MOLTEN_FLUID, List.of(MaterialProcessRule.anyForm(Boolean.TRUE))); } return new MaterialDefinition.Declaration( declaration.material(), diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java index f515616e1..b81fdd123 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceWashingMaterialFacts.java @@ -194,7 +194,7 @@ public static MaterialDefinition.Declaration apply(MaterialDefinition.Declaratio if (binding == null) return declaration; var info = declaration.info(); var rules = new LinkedHashMap<>(info.processes().rules()); - rules.put(MaterialFactKeys.SOURCE_WASHING, List.of(MaterialProcessRule.anyForm(binding))); + MaterialFactKeys.put(rules, MaterialFactKeys.SOURCE_WASHING, List.of(MaterialProcessRule.anyForm(binding))); return new MaterialDefinition.Declaration( declaration.material(), new MaterialInfoDefinition( diff --git a/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java index 269cfde22..61ee4d361 100644 --- a/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessMethods.java @@ -35,9 +35,7 @@ public static void install() { private static SpecialProcessMethod method(MaterialProcessKey process) { return new SpecialProcessMethod( - process, - "gt.recipe.bath", - "gt6ce.special_process." + process.id().path().replace('/', '.')); + process, "gt.recipe.bath", "gt6ce." + process.id().path().replace('/', '.')); } private static MaterialProcessKey process(String path) { diff --git a/core/src/main/java/gregtech/engine/material/MaterialItemDefinitions.java b/core/src/main/java/gregtech/engine/material/MaterialItemDefinitions.java index 47b1e0c2b..4b568781d 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialItemDefinitions.java +++ b/core/src/main/java/gregtech/engine/material/MaterialItemDefinitions.java @@ -5,7 +5,6 @@ import gregtech.engine.addon.AddonMaterials; import gregtech.engine.mod.GregTechIdentity; import gregtech.engine.prefix.PrefixRegistry; - import java.util.*; /** diff --git a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java index 6e3f9625a..0b05df187 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java +++ b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java @@ -149,9 +149,8 @@ public long connectionCount() { public record Budgets(int maxDepth, int maxSteps, int maxPortsPerSide, int maxEdges) { public static final Budgets DEFAULT = new Budgets(8, 64, 64, 128); - /** Explicit expansion budget; viewer pages use {@link MaterialProcessGraph#queryMaterial(DataKey)} instead. */ - public static final Budgets MATERIAL_PAGE = - new Budgets(0, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); + /** Material pages keep every direct row only until a configured presentation limit is reached. */ + public static final Budgets MATERIAL_PAGE = new Budgets(0, 512, 128, 4096); public Budgets { if (maxDepth < 0 || maxSteps <= 0 || maxPortsPerSide <= 0 || maxEdges < 0) diff --git a/core/src/main/java/gregtech/engine/material/MaterialPublication.java b/core/src/main/java/gregtech/engine/material/MaterialPublication.java index eab9b06bf..a51b57bef 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialPublication.java +++ b/core/src/main/java/gregtech/engine/material/MaterialPublication.java @@ -31,20 +31,39 @@ public static synchronized Stamp materialDefinitionsPublished(long materialRevis return published; } + /** Allocates a generation stamp for a build that has not reached its final publication boundary. */ + public static synchronized Stamp candidatePlatformGeneration(long compositionRevision, long recipeRevision) { + Stamp previous = requirePlatformGeneration(compositionRevision, recipeRevision); + return new Stamp( + NEXT_REVISION.incrementAndGet(), previous.materialRevision(), compositionRevision, recipeRevision); + } + /** Publishes one complete platform generation after compositions and recipe rows are final. */ public static synchronized Stamp platformGenerationPublished(long compositionRevision, long recipeRevision) { + return commit(candidatePlatformGeneration(compositionRevision, recipeRevision)); + } + + /** Commits a candidate only after every derived publication built from it has succeeded. */ + public static synchronized Stamp commit(Stamp candidate) { + java.util.Objects.requireNonNull(candidate, "candidate"); Stamp previous = current; - if (previous.materialRevision() == 0) - throw new IllegalStateException("Material definitions must be published first"); - if (recipeRevision <= 0) throw new IllegalArgumentException("Recipe revision must be positive"); - Stamp published = new Stamp( - NEXT_REVISION.incrementAndGet(), previous.materialRevision(), compositionRevision, recipeRevision); - current = published; - return published; + if (candidate.materialRevision() != previous.materialRevision()) + throw new IllegalStateException("Published generation belongs to another material definition"); + if (candidate.revision() <= previous.revision()) return previous; + current = candidate; + return candidate; } /** The last fully successful publication; an in-progress or failed generation leaves it unchanged. */ public static Stamp current() { return current; } + + private static Stamp requirePlatformGeneration(long compositionRevision, long recipeRevision) { + Stamp previous = current; + if (previous.materialRevision() == 0) + throw new IllegalStateException("Material definitions must be published first"); + if (recipeRevision <= 0) throw new IllegalArgumentException("Recipe revision must be positive"); + return previous; + } } diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index 3904ba1b2..3515514e5 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -1,4 +1,67 @@ { + "gt6ce.jei.material_process.title": "Material Processing", + "gt6ce.jei.material_process.section.sources": "Sources", + "gt6ce.jei.material_process.section.internal": "Internal Conversion", + "gt6ce.jei.material_process.section.recovery": "Recovery", + "gt6ce.jei.material_process.section.uses": "Uses", + "gt6ce.jei.material_process.cluster": "%s ×%s", + "gt6ce.jei.material_process.group_count": "This group contains %s steps.", + "gt6ce.jei.material_process.group_expand": "Left-click to expand.", + "gt6ce.jei.material_process.group_collapse": "Left-click to collapse.", + "gt6ce.special_process.sulfuric_acid_leaching": "Sulfuric Acid Leaching", + "gt6ce.special_process.aqua_regia_leaching": "Aqua Regia Leaching", + "gt6ce.special_process.hydrofluoric_acid_leaching": "Hydrofluoric Acid Leaching", + "gt6ce.special_process.hydrochloric_acid_manganese_leaching": "Hydrochloric Acid Manganese Leaching", + "gt6ce.jei.material_process.pan": "Hover to highlight equal items | Drag empty space to pan | Scroll to zoom around the cursor", + "gt6ce.jei.material_process.reset": "Reset", + "gt6ce.jei.material_process.zoom_hint": "Scroll to zoom around the cursor, or click −/+.", + "gt6ce.jei.material_process.resource_hint": "Left-click: recipes | Right-click: uses; hover a machine for amounts and additional items.", + "gt6ce.jei.material_process.variants": "This route contains %s recipes", + "gt6ce.jei.material_process.copy": "Local display copy of this resource (↗); hovering also highlights its other copies.", + "gt6ce.jei.material_process.return": "Return loop (↩); this does not imply an additional source.", + "gt6ce.jei.material_process.fullscreen": "Browse Material Processing in fullscreen", + "gt6ce.jei.material_process.exit_fullscreen": "Return to the recipe viewer", + "gt6ce.jei.material_process.reset_hint": "Restore 100% scale and center the queried item or fluid.", + "gt6ce.jei.material_process.empty": "This query has no processing steps.", + "gt6ce.jei.material_process.unbound": "Processing data is not available yet.", + "gt6ce.jei.material_process.controls": "Left-click process: original recipe | Left/right-click resource: sources/uses", + "gt6ce.jei.material_process.open_recipe": "Click a process to open its original recipe when supported.", + "gt6ce.jei.material_process.unresolved": "Relationship or native constraint is unresolved", + "gt6ce.jei.material_process.confirmed": "Confirmed relationship", + "gt6ce.jei.material_process.chance_unknown": "Output chance: unknown", + "gt6ce.jei.material_process.more": "+%s ports (hover to view)", + "gt6ce.jei.material_process.links": "%s relationships", + "gt6ce.jei.material_process.connection": "%s → %s | %s | %s", + "gt6ce.jei.material_process.role.consumed": "Shared input (consumed)", + "gt6ce.jei.material_process.role.catalyst": "Catalyst (not consumed)", + "gt6ce.jei.material_process.role.presence": "Presence condition (not consumed)", + "gt6ce.jei.material_process.role.primary": "Primary output", + "gt6ce.jei.material_process.role.byproduct": "Byproduct", + "gt6ce.jei.material_process.role.unknown": "Output role: unknown", + "gt6ce.jei.material_process.material_title": "%s Processing", + "gt6ce.jei.material_process.port_name": "%s / %s", + "gt6ce.jei.material_process.amount.items": "Amount: %s items", + "gt6ce.jei.material_process.amount.units": "Amount: %s U", + "gt6ce.jei.material_process.amount.mb": "Amount: %s mB", + "gt6ce.jei.material_process.amount.unknown": "Amount: unknown", + "gt6ce.jei.material_process.partial_unknown": "Coverage: partial; unsupported families are not shown.", + "gt6ce.jei.material_process.coverage.final_recipes": "Recipes: final published GT machine rows provide the authoritative native values.", + "gt6ce.jei.material_process.information": "Related Information", + "gt6ce.jei.material_process.open_information": "Click to open the original page", + "gt6ce.jei.material_process.information_hint": "Reference only; this entry is not a processing route.", + "gt6ce.jei.material_process.coverage.viewer_recipes": "Recipes: final visible JEI/EMI crafting, machine, and third-party rows are included.", + "gt6ce.jei.material_process.coverage.viewer_exclusions": "%s viewer entries were not imported as routes; related entries remain in Related Information, and cross-material selectors are not assigned to one material.", + "gt6ce.jei.material_process.coverage.active_worldgen": "World generation: only currently enabled configuration is included.", + "gt6ce.jei.material_process.coverage.dynamic_selectors": "Tags and material-unit selectors remain symbolic and are not expanded into every candidate.", + "gt6ce.jei.material_process.coverage.unknown_roles": "Roles remain unknown when the source does not distinguish primary and secondary outputs.", + "gt6ce.jei.material_process.coverage.node_limit": "The node budget omitted %s remaining steps.", + "gt6ce.jei.material_process.coverage.depth_limit": "The depth budget omitted %s remaining steps.", + "gt6ce.jei.material_process.coverage.port_limit": "The port budget omitted %s ports.", + "gt6ce.jei.material_process.coverage.edge_limit": "The relationship budget omitted %s relationships.", + "gt6ce.jei.material_process.coverage.invalid_data": "Discarded %s invalid processing entries; see the log for details.", + "gt6ce.jei.material_process.no_sources": "There are no published sources in this query.", + "gt6ce.jei.material_process.no_uses": "There are no published uses in this query.", + "gt6ce.jei.material_process.no_both": "There are no connected published sources or uses in this query.", "fluid_type.gt6ce.watergeothermal": "Hot Spring Water", "fluid.gt6ce.watergeothermal": "Hot Spring Water", "block.gt6ce.watergeothermal": "Geothermal Water", @@ -12657,8 +12720,6 @@ "tooltip.gt6ce.bush.set_output": "Right-click with a berry to set the output", "tooltip.gt6ce.chemical_battery.packet": "EU packet size: %s–%s", "tooltip.gt6ce.chemical_battery.place": "Sneak to place; stored charge is retained when picked up", - "tooltip.gt6ce.composition_descriptive": "Composition reference only; not enabled for bulk recovery", - "tooltip.gt6ce.composition_nonmaterial": "No recoverable bulk material (technical/entity item)", "tooltip.gt6ce.contained_materials": "Contained Materials:", "tooltip.gt6ce.crucible.acidproof": "Acid Proof!", "tooltip.gt6ce.crucible.contact_damage": "Causes Damage when touched while active!", @@ -13717,4 +13778,4 @@ "enchantment.gt6ce.gt_haste": "Efficiency", "enchantment.gt6ce.sharpness_multi": "Sharpness", "enchantment.gt6ce.smite_multi": "Smite" -} \ No newline at end of file +} diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index 77e2eb7e3..3baea9c1b 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -110,12 +110,13 @@ "gt6ce.jei.material_process.information": "相关信息", "gt6ce.jei.material_process.open_information": "点击查看原始页面", "gt6ce.jei.material_process.information_hint": "仅供参考,此条目不构成加工路线。", - "gt6ce.jei.material_process.coverage.viewer_recipes": "配方:EMI 最终加工配方,包含工作台与其他模组。", - "gt6ce.jei.material_process.coverage.viewer_exclusions": "%s 条 EMI 条目未作为加工路线导入;其中相关条目保留在信息区,跨材料候选原料不归为单一材料。", + "gt6ce.jei.material_process.coverage.viewer_recipes": "配方:最终可见的 JEI/EMI 工作台、机器与第三方加工配方。", + "gt6ce.jei.material_process.coverage.viewer_exclusions": "%s 条查看器条目未作为加工路线导入;其中相关条目保留在信息区,跨材料候选原料不归为单一材料。", "gt6ce.jei.material_process.coverage.active_worldgen": "世界生成:仅包含当前启用的配置。", "gt6ce.jei.material_process.coverage.dynamic_selectors": "tag 与材料单位选择器保持符号形式,不展开候选全集。", "gt6ce.jei.material_process.coverage.unknown_roles": "来源未明确主/副角色时保持未知。", - "gt6ce.jei.material_process.coverage.node_limit": "达到深度或节点预算,省略了 %s 个后续步骤。", + "gt6ce.jei.material_process.coverage.node_limit": "达到节点预算,省略了 %s 个后续步骤。", + "gt6ce.jei.material_process.coverage.depth_limit": "达到深度预算,省略了 %s 个后续步骤。", "gt6ce.jei.material_process.coverage.port_limit": "达到端口预算,省略了 %s 个端口。", "gt6ce.jei.material_process.coverage.edge_limit": "达到关联预算,省略了 %s 条关联。", "gt6ce.jei.material_process.coverage.invalid_data": "已剔除 %s 条无效加工数据,详情见日志。", @@ -96421,8 +96422,6 @@ "tooltip.gt6ce.bush.set_output": "Right-click with a berry to set the output", "tooltip.gt6ce.chemical_battery.packet": "EU packet size: %s–%s", "tooltip.gt6ce.chemical_battery.place": "Sneak to place; stored charge is retained when picked up", - "tooltip.gt6ce.composition_descriptive": "Composition reference only; not enabled for bulk recovery", - "tooltip.gt6ce.composition_nonmaterial": "No recoverable bulk material (technical/entity item)", "tooltip.gt6ce.contained_materials": "含有材料:", "tooltip.gt6ce.crucible.acidproof": "Acid Proof!", "tooltip.gt6ce.crucible.contact_damage": "当它在运作的时候接触会受伤!", diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java index 1285155ec..53d93b4e2 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java @@ -184,11 +184,28 @@ void materialPageKeepsLargeRecipesAndDenseConnections() { List.of(port(resource("local_" + index), Role.UNKNOWN, "local_" + index)))); var graph = builder.build(); var query = graph.queryMaterial(common, Budgets.MATERIAL_PAGE); - assertEquals(741, query.steps().size()); - assertEquals(4970, query.edges().size()); - assertEquals(160, query.steps().get(0).outputs().size()); - assertFalse(query.truncated()); - assertTrue(query.notices().isEmpty()); + assertEquals(512, query.steps().size()); + assertEquals(4096, query.edges().size()); + assertEquals(128, query.steps().get(0).outputs().size()); + assertTrue(query.truncated()); + assertEquals( + 874, + query.notices().stream() + .filter(notice -> notice.code().equals("edge_limit")) + .mapToInt(Notice::omitted) + .sum()); + assertEquals( + 229, + query.notices().stream() + .filter(notice -> notice.code().equals("node_limit")) + .mapToInt(Notice::omitted) + .sum()); + assertEquals( + 32, + query.notices().stream() + .filter(notice -> notice.code().equals("port_limit")) + .mapToInt(Notice::omitted) + .sum()); } @Test diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessLanguageTest.java b/core/src/test/java/gregtech/engine/material/MaterialProcessLanguageTest.java new file mode 100644 index 000000000..9eacbf254 --- /dev/null +++ b/core/src/test/java/gregtech/engine/material/MaterialProcessLanguageTest.java @@ -0,0 +1,35 @@ +package gregtech.engine.material; + +import org.junit.jupiter.api.Test; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashSet; +import java.util.Set; +import java.util.regex.Pattern; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class MaterialProcessLanguageTest { + private static final Pattern PROCESS_KEYS = + Pattern.compile("\"(gt6ce\\.(?:jei\\.material_process|special_process)\\.[^\"]+)\"\\s*:"); + + @Test + void materialProcessLanguagesHaveTheSameKeys() throws Exception { + var english = keys("en_us.json"); + var chinese = keys("zh_cn.json"); + assertEquals(english, chinese); + for (var method : gregtech.content.recipe.SpecialProcessMethods.methods()) + assertTrue(english.contains(method.displayNameKey()), method.displayNameKey()); + } + + private static Set keys(String language) throws Exception { + var text = + Files.readString(Path.of("src/main/resources/assets/gt6ce/lang").resolve(language)); + var keys = new HashSet(); + var matcher = PROCESS_KEYS.matcher(text); + while (matcher.find()) keys.add(matcher.group(1)); + return keys; + } +} diff --git a/docs/ADDON_API.zh-CN.md b/docs/ADDON_API.zh-CN.md index 90048ab02..f801a7e80 100644 --- a/docs/ADDON_API.zh-CN.md +++ b/docs/ADDON_API.zh-CN.md @@ -39,9 +39,9 @@ | 产物坐标 | 内容与输出 | | --- | --- | -| `gregtech:gt6ce-api:1.8.0` | Java 17 公共协议、模型、声明和宿主服务接口;`api/common/build/libs/` | -| `gregtech:gt6ce-addon-sdk-1.20.1-forge:1.8.0` | Java 17、Mojang 名称的 Forge 游戏侧 API;对应节点 `build/addon-sdk/` | -| `gregtech:gt6ce-addon-sdk-1.21.1-neoforge:1.8.0` | Java 21 的 NeoForge 游戏侧 API;对应节点 `build/addon-sdk/` | +| `gregtech:gt6ce-api:1.9.0` | Java 17 公共协议、模型、声明和宿主服务接口;`api/common/build/libs/` | +| `gregtech:gt6ce-addon-sdk-1.20.1-forge:1.9.0` | Java 17、Mojang 名称的 Forge 游戏侧 API;对应节点 `build/addon-sdk/` | +| `gregtech:gt6ce-addon-sdk-1.21.1-neoforge:1.9.0` | Java 21 的 NeoForge 游戏侧 API;对应节点 `build/addon-sdk/` | 这些是构建配置中的坐标,不表示已发布到公共 Maven 仓库。版本规则见下节[API 版本](#api-版本)。 @@ -55,7 +55,9 @@ ## API 版本 -当前分支使用 API `1.8.0`,与模组版本独立;以 [api/common/build.gradle](../api/common/build.gradle) 为准。`GregTechAddons.apiVersion()` 返回 `major * 1000 + minor`,1.8 为 `1008`,不能据此推断某个模组构建兼容。修改内联 API 时同步构建配置与 `GregTechAddons` 的版本。 +当前分支使用 API `1.9.0`,与模组版本独立;以 [api/common/build.gradle](../api/common/build.gradle) 为准。`GregTechAddons.apiVersion()` 返回 `major * 1000 + minor`,1.9 为 `1009`,不能据此推断某个模组构建兼容。修改内联 API 时同步构建配置与 `GregTechAddons` 的版本。 + +API 1.9 新增 `SpecialProcessMethod`、`SpecialProcessValue` 与 `SpecialProcessesView`。附属通过 `MaterialInfoTool.Registrar.registerSpecialProcess(...)` 声明 typed target/reagent 规则,再通过 `MaterialCatalogView.specialProcesses()` 当前发布快照读取;target 和 reagent 必须绑定同一个 `MaterialProcessKey`。 宿主专用的 `StructureGrid` 与 `RecipeMapSpec` 不属于附属契约:它们分别位于 `gregtech.content.multiblock` 与 `gregtech.content.recipe`,编码内置多方块几何和配方表,附属不应依赖。 diff --git a/docs/architecture/packages/api.md b/docs/architecture/packages/api.md index 9102448b2..84be04eee 100644 --- a/docs/architecture/packages/api.md +++ b/docs/architecture/packages/api.md @@ -10,7 +10,7 @@ | --- | --- | --- | | `api` | API 包的总体契约说明 | `package-info.java` | | `api.addon` | 附属发现、身份、生命周期、命名限制与 SPI | `GregTechAddon`、`GregTechAddons`、`AddonRuntime`;声明失败应有上下文 | -| `api.addon.material` | 材料、前缀、成分、形态、类型化 metadata、分类 tag、替代组、分解和特殊处理声明 | `MaterialDeclaration`、`MaterialMetadata`、`MaterialTagDeclaration`、`MaterialGroupDeclaration`、`MaterialDecompositionRule`、`SpecialProcessMethod`、`SpecialProcessValue`、`GregTechMaterials` | +| `api.addon.material` | 材料、前缀、成分、形态、类型化 metadata、分类 tag、替代组、分解和特殊处理声明 | `MaterialDeclaration`、`MaterialMetadata`、`MaterialTagDeclaration`、`MaterialGroupDeclaration`、`MaterialDecompositionRule`、`SpecialProcessMethod`、`SpecialProcessValue`、`SpecialProcessesView`、`GregTechMaterials` | | `api.addon.machine` | 机器、行为、部件、布局及参数声明 | `AddonMachine.withStructure` 显式绑定;`MultiblockMachine`、`BehaviorMachine`、`LayoutPart`、`AddonMachineContributor` | | `api.addon.recipe` | 配方表、坩埚反应、模具、保留输入与概率声明,以及 `gt6ce:machine` 数据包文档 | `RecipeMachine`、`CrucibleReactionDeclaration`、`RecipeOutputChances`、`MachineRecipeDocument`、`MachineRecipeDocuments`、`MachineRecipeDocumentType` | | `api.addon.pipe` | 附属物品/流体管道的定义 | `ItemPipeDeclaration`、`FluidPipeDeclaration` | diff --git a/docs/architecture/packages/content.md b/docs/architecture/packages/content.md index 59b08440c..8706b3590 100644 --- a/docs/architecture/packages/content.md +++ b/docs/architecture/packages/content.md @@ -10,7 +10,7 @@ core 的 content 描述“有什么”,Minecraft 的 content 将其变为游 | --- | --- | --- | | `content` | 内容层总体职责说明 | `package-info.java` | | `content.material` | 材料目录入口、物性规则和稳定符号门面 | `MaterialDefinitions`、`Materials`;读取符号不触发注册 | -| `content.material.catalog` | 元素、化合物、矿石、石材、木材、特殊材料和组的规范声明 | `ElementMaterials`、`CompoundMaterials`、`GroupMaterials`;每项材料事实只在这里维护 | +| `content.material.catalog` | 元素、化合物、矿石、石材、木材、特殊材料和组的规范声明 | `ElementMaterials`、`CompoundMaterials`、`GroupMaterials`;材料目录事实在这里维护,游戏侧桥接事实经 typed key 汇入 | | `content.material.generated` | 既有 GT6 字段符号门面 | `ElementMaterials`、`CompoundMaterials`;引用规范目录中的已安装对象 | | `content.data` | 原版参数、跨领域内容事实与标识表 | `FluidCatalog`、`MaterialGroups`;仅跨领域事实放这里 | | `content.data.generated` | 尚留存的兼容查询门面和历史字段映射 | `MaterialForms`、`MaterialProcessingTargets`;权威材料事实位于 `content.material.catalog` | @@ -99,7 +99,7 @@ core 的 content 描述“有什么”,Minecraft 的 content 将其变为游 - 线缆、管道、轴、电池、覆盖板与储罐的实际传输、断开与方向变化。 - 材料物品/方块注册与统一化;矿脉或结构的注册存在性。 - 现有测试集 - - `MaterialBaselineTest` 与共享 `MaterialBaselineTests` 提供材料源表引用审计、独立 JVM 快照、测试材料 SPI、成分与回收/分解及真实重载入口;契约与不变量见[材料系统设计](../../decisions/material-system/README.md)。 + - `MaterialRegistrationTest`、`MaterialCatalogTest` 与 `MaterialProcessGraphTest` 提供材料目录、附属合并、处理图预算与查询回归;契约与不变量见[材料系统设计](../../decisions/material-system/README.md)。 - core 静态 TSV 与 GameTest TSV 由对应 JUnit/GameTest 维护;用例覆盖物品管道路由与调度回归。 - `core/src/test` 的材料目录、标签名翻译、熔融浇筑与配方引擎测试;`api/common` 的材料、机器、能源模型测试。 - 机器 tick、多方块、能源网络、物流、世界生成完整流程等仍是待补范围。 diff --git a/docs/architecture/packages/engine.md b/docs/architecture/packages/engine.md index f03f79296..9b62a9bb8 100644 --- a/docs/architecture/packages/engine.md +++ b/docs/architecture/packages/engine.md @@ -11,7 +11,7 @@ | `engine` | 执行层总体说明 | `package-info.java`;不继续使用旧 internal 命名扩张实现 | | `engine.addon` | 附属声明收集、校验、物化与共享服务绑定 | `AddonCoreServices`、`AddonMaterials`、`AddonMachines`、`AddonPipes` | | `engine.definition` | 定义目录的组织与查询机制 | `DefinitionCatalog`;内容行放 content | -| `engine.material` | 材料原子安装(`MaterialRegistryState`)、引用与组校验(`MaterialLinker`)、附属事实冻结、物品成分与回收纯裁决、多代发布版本号(`MaterialPublication`)及不可变视图 | `GTMaterialRegistry`、`MaterialRegistryState`、`MaterialLinker`、`MaterialInfoRegistry`、`ItemCompositionResolver`、`ItemRecoveryPlanner`、`MaterialPublication`、`MaterialViews` | +| `engine.material` | 材料原子安装(`MaterialRegistryState`)、引用与组校验(`MaterialLinker`)、附属事实冻结、物品成分与回收纯裁决、多代发布版本号(`MaterialPublication`)、不可变视图与有界处理图 | `GTMaterialRegistry`、`MaterialRegistryState`、`MaterialLinker`、`MaterialInfoRegistry`、`ItemCompositionResolver`、`ItemRecoveryPlanner`、`MaterialPublication`、`MaterialViews`、`MaterialProcessGraph` | | `engine.prefix` | 材料形态/前缀的注册与解析 | `PrefixRegistry`、`BlockPrefixRegistry` | | `engine.recipe` | 配方成本、并行与输出空间拟合、燃料批次、精确单位换算与材料分解纯计划、可合成性和界面坐标等共享机制 | `MachineWorkCost`、`ParallelFit`、`FluidFuelChargeMath`、`UnitConversion`、`MaterialDecompositionPlanner`;不能夹带游戏栈 | | `engine.recipe.data` | 配方文档模型、组件、解析及校验 | `MachineRecipeDocuments`、`ItemComponent`、`FluidComponent` | diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index 783bb5d11..cd3cd27a0 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,11 +70,11 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理由 `content.recipe.MaterialProcessSnapshot` 从最终配方提交点绑定机器配方与活动世界生成,`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 再构造 JEI/EMI 共用的展示页。`compat.common.MaterialProcessOverview` 负责按可见机器及完整共同输入或输出集合合并相似路线、原生端口实例、可见拓扑层级、连续链、局部副本、输入/产物网格、独立路线紧凑排布、端口产量角标、排线、配方浅色边界及同物品匹配,`client.MaterialProcessPanel` 负责带绿色目标外框的 100% 查询聚焦、窗口自适应视口、副本/回流标记与原生交互;`client.MaterialProcessScreen` 承载全屏浏览与返回原查看器;EMI 的 `MaterialProcessEmiStacks` 把显示流体代理还原为原生索引和查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、仅限页面材料的索引和事件适配;EMI 索引按完整原生状态去重,注册时不构造全部页面,实际打开时再查询完整步骤与按资源压缩的 `Flow` 关联;EMI 查询目标由客户端可选的 `EmiMaterialProcessFocusMixin` 传入。调用契约与预算以这些类型的 JavaDoc 和本包职责为准;它们不能成为第二套材料目录或配方事实表。 +矿物处理由 `content.recipe.MaterialProcessSnapshot` 保存权威 GT 原生事实与活动世界生成;JEI 在 runtime 枚举最终可见分类与配方,EMI 在最终 bake 后枚举可见配方,两者都通过 `ViewerBuilder` 追加工作台、机器与第三方行。可见的 GT machine row 优先复用原生单位、概率和回收归属;`viewer(false)` 的 GT 配方与世界生成由快照补充。`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 构造两 viewer 共用的展示页。`client.MaterialProcessOverview` 负责布局与路线折叠,`client.MaterialProcessPanel`/`MaterialProcessScreen` 负责视口和原生交互;`MaterialProcessEmiStacks` 把显示流体代理还原为原生索引与查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、仅限页面材料的索引和事件适配。 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 -EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理:在 `EmiMaterialProcessRecipesMixin` 取得最终可见配方后,统一接入 GT、工作台及其他模组的完整加工关系;GT 行优先复用原生单位、概率及回收归属,材料单位模板不受自动配方树开关影响。可读取的非树加工以未确认关系接入;说明、结构和动态模式页保留为信息。加工行按 EMI ID 和完整端口语义去重。合成网格空位不阻止完整配方进入加工图;通用标签/候选浏览页不进入信息区。其他相关信息和无法完整读取的条目按主材料关联、按 EMI ID 去重,保留在来源区底部的信息卡片,通过原页面跳转查看,不生成加工边。`MaterialProcessSnapshot.ViewerBuilder` 只构造本次客户端视图,不更改服务端配方。JEI 仍使用原生 GT 快照;具体覆盖、候选原料和生命周期边界按[游戏内人工验收](../../development/validation/checks/manual-ingame.md#矿物处理展示页)核对。 +EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理,JEI 由 `compat.jei.MaterialProcessJeiRecipes` 处理。两者都读取所属 viewer 的最终可见分类、配方与工作台;JEI 在 `onRuntimeAvailable` 注册材料页,避免过早读取尚未完成筛选的配方。GT 行优先复用原生单位、概率及回收归属,材料单位模板不受自动配方树开关影响;`viewer(false)` 配方由快照补充。可读取的非树加工以未确认关系接入;说明、结构和动态模式页保留为信息。`MaterialProcessSnapshot.ViewerBuilder` 只构造本次客户端视图,不更改服务端配方。具体覆盖、候选原料和生命周期边界按[游戏内人工验收](../../development/validation/checks/manual-ingame.md#矿物处理展示页)核对。 ## 验收 diff --git a/docs/decisions/material-system/README.md b/docs/decisions/material-system/README.md index 6dd3f9a3d..72b8b6e3f 100644 --- a/docs/decisions/material-system/README.md +++ b/docs/decisions/material-system/README.md @@ -51,4 +51,4 @@ 3. [物品成分解析与运行时准入](item-composition.md):结构化来源优先级、同级冲突与显式替换链、显式层封闭与 Tag 代次原子重载、耐久缩放及容器/模具形状区分。 4. [统一回收计划与配方发布仲裁](recovery.md):基于有效成分的纯粉碎/热回收计划、大份量拆栈与精度表达、生产端输入证明、所有权与冲突发布仲裁。 5. [统一材料分解规则与计划](decomposition.md):`MaterialDecompositionRule` 唯一权威、规范组成与精确单位计算、液/气替代相态与固体兜底、原生适配器与重载隔离。 -6. [公共数据 API 与多代发布契约](data-api-and-publication.md):已实现的只读视图(目录、元数据、分类/组、形态规则与实际绑定)、`MaterialPublication.Stamp` 一致性保证,以及明确标为`提议`的多快照来源图规划。 +6. [公共数据 API 与多代发布契约](data-api-and-publication.md):已实现的只读视图(目录、元数据、分类/组、形态规则与实际绑定)、`MaterialPublication.Stamp` 一致性保证,以及当前作为内部 viewer 数据层实现、尚未进入公共 API 的来源用途图。 diff --git a/docs/decisions/material-system/data-api-and-publication.md b/docs/decisions/material-system/data-api-and-publication.md index d5e222a56..1cc00cf03 100644 --- a/docs/decisions/material-system/data-api-and-publication.md +++ b/docs/decisions/material-system/data-api-and-publication.md @@ -7,7 +7,7 @@ - **稳定键与模型隔离**:公共查询全部基于不可变键(`MaterialKey`、`DataKey`、`FormKey`、`MaterialGroupKey`)和只读视图接口,不把内部可变模型 `GTMaterial`、游戏物品栈 `ItemStack` 或 `RecipeMap` 暴露为协议字段。 - **明确失败语义**:对于宿主服务未绑定、材料系统未就绪、旧版本宿主不支持或查询未知键等场景,公开接口须明确抛出异常或区分状态,禁止统统返回空集掩盖故障。 -## 已实现的公共视图(API 1.4–1.8) +## 已实现的公共视图(API 1.4–1.9) 附属接入手册与 Gradle 坐标细节详见[附属 API 文档](../../ADDON_API.zh-CN.md)。已交付能力划分如下: @@ -27,14 +27,11 @@ 2. **平台代次提交**:每次启动装配或热重载在全部 Tag 候选裁决、有效成分构建、`MaterialFormContent` 绑定刷新以及回收/分解配方重建均成功后,才由平台层推进 `platformGenerationPublished(compositionRevision, recipeRevision)`。 3. **失败回滚不动旧印记**:重载任一环节报错触发回滚时,`MaterialPublication.current()` 维持上一成功 `Stamp` 不变,保证下游观测不到“成分切至新代但配方仍留旧代”的跨代撕裂。 -## `提议`:来源用途索引与有界处理图(尚未实施) +## 来源用途索引与有界处理图 -> [!NOTE] -> 本节规划尚处于**提议**状态,尚未进入公共 `api` 产物,不构成当前可调用 API 承诺。 +来源用途索引与有界处理图当前作为内部运行时与 viewer 数据层实现,尚未提升为公共 `api` 契约。`MaterialProcessSnapshot` 负责服务器会话与 viewer 行代次,`MaterialProcessGraph` 负责有界查询;JEI/EMI 仅消费同一展示投影。 -- **会话化版本快照(`MaterialDataSnapshot` / `SnapshotStamp`)**: - - 配方来源、用途与动态世界生成信息随具体服务端世界和数据包配置变化,拟引入显式接收服务端或会话上下文的快照入口,每次重载生成绑定唯一 `SnapshotStamp` 的自洽索引,避免跨服、断线或热重载后旧引用混用; - - 来源与用途索引从最终 `RecipeMap`、原版炉镜像、已发布的回收/分解结果及真实生效矿脉配置直接投影(而非从化学成分表猜测或对 `Unit` 族做笛卡尔积展开)。 -- **有界材料处理图(`ProcessGraph`)**: - - 拟在核心层基于来源/用途快照支持有限深度、节点与分支预算的前/反向图检索,精确保留合金/分解/回收闭环中的共同输入、概率分支与状态条件,并在到达预算时诚实标注截断; - - 客户端颜色、图标与坐标映射留在接入层,由 JEI 与 EMI 共用同一图语义模型与世界生成事实投影,解除彼此间的内部类耦合,同时确保专用服务端在无客户端可选模组时独立运行。 +- **会话化版本快照**:`MaterialProcessSnapshot` 绑定发布戳、配方 revision、会话代次、形态 revision、tag 代次与世界生成 revision;旧页面的 `DataKey` 在服务端停止、客户端断线或重载后失效。 +- **最终 viewer 行与权威快照合成**:JEI 在 runtime 枚举最终可见分类和配方,EMI 在最终 bake 后枚举可见配方;两者都追加工作台、机器和第三方加工行。GT machine row 复用原生单位、概率与回收归属,`viewer(false)` 配方和真实生效矿脉配置由权威快照补充。 +- **有界材料处理图**:核心层 `MaterialProcessGraph` 支持显式深度、步骤、端口与关联预算,保留共同输入、概率分支、状态条件和确认关系,并在达到预算时输出独立截断原因。 +- **共用展示投影**:服务器只构建 viewer 中立的 `MaterialProcessSnapshot` 与图;JEI/EMI 适配器分别提供最终可见配方和原生槽位,颜色、布局、图标与坐标映射留在客户端接入层。 diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index 95627f2e7..5e9023eac 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -36,7 +36,7 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe ### 配方回归案例表 -材料领域的 `MaterialBaselineTests` 验证存储块的成分与两类准入、72U 附魔金苹果的规划和实际回收输出、复合钻头、耐久缩放、容器与有形状铸模、压模机模具、固体/流体分解、形态绑定刷新及 test-source 材料 SPI。`material_baseline_reload` 为仅含一个测试的独立批次,等待两次真实资源重载;拥有规则数和固定样例必须稳定。已知错误行为明确标为观察,不能当作正确性依据;材料成分、回收与分解契约见[材料系统设计](../../../decisions/material-system/README.md)。 +材料领域的运行时回归已不再依赖 `MaterialBaselineTests` 和一次性 TSV 快照。材料成分、回收与分解的纯规则由 JUnit 覆盖;资源重载、旧 viewer 引用拒绝、JEI/EMI 最终可见配方汇入与双平台客户端行为仍按[游戏内人工验收](manual-ingame.md#矿物处理展示页)执行。材料契约见[材料系统设计](../../../decisions/material-system/README.md)。 `decompositionRespectsFormsAndExactFluidIdentities` 通过测试 SPI 声明 dust-only、blockDust-only、liquid-only 和 gas-only 分解,检查形态限制、流体输入不会错误抑制允许的固体兜底、本体完整 ID、附属完整 ID/旧裸路径、外部原版流体 ID、未知及非法 ID,以及附属流体输出的身份和数量。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 158a3b0e1..647db090f 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -20,9 +20,9 @@ ### 矿物处理展示页 -生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用展示模型和面板;EMI 从最终可见配方构造视图,JEI 使用 GT 原生快照。 +生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用展示模型和面板。两者都从 viewer 最终可见的工作台、机器与第三方配方构造材料行;权威快照补充 `viewer(false)` GT 机器配方、原生单位/概率和活动世界生成。 -EMI 数据源还需核对:工作台压块/拆块、熔炉和已安装第三方机器均进入材料页,GT 机器不重复;包含空网格的有序合成进入加工图,不因占位变成信息卡片;没有实际输入的行不能成为加工来源。通用物品/方块/流体标签及候选浏览页不出现在信息区;GT 材料单位输入说明仍可打开。GT 材料单位模板即使 `supportsRecipeTree=false` 仍保留原生材料单位与概率;工具装配和可读取的第三方非树加工进入图中并使用未确认关系。结构、说明、动态模式与木桶查询别名不产生加工边;缺少输入/输出及不支持 ingredient 类型的条目仅保留为相关信息。零数量工具只作为催化剂,不使整条配方降级。相同 EMI ID,以及同分类下仅注册 ID、槽位顺序或网格占位不同的等价加工行不重复;数量、概率、原生状态或工具不同的行继续保留。关联只取明确主材料/流体绑定,次要成分不带入额外信息卡片;相同非空 EMI ID 的信息页不重复。来源区底部的信息卡片应使用本材料图标并直接打开对应原页面,只有相关信息的材料也能查询;全屏和嵌入视图下均核对点击、tooltip、平移缩放与裁剪。任一不支持槽不能静默消失。超过每侧 128 槽、512 步或 4096 条关联时,确认默认材料页保留全部直接数据且重载可完成;人为指定有限预算时才出现相应截断提示。加入坏记录时应有诊断日志和覆盖提示,其余有效路线仍可查询。tag 的同材料候选保持一个 selector,跨材料候选不归到任一单一材料。隐藏、延迟注册、资源重载与重新入服后页面跟随当前配方,旧导航失效。EMI 初始化和连续重载不能提前构造所有材料图或展开生产者/消费者的连接乘积;日志应出现材料索引完成记录。检索输入、工具及产物不按配方出现次数重复,首次打开才构建详情,仍须保留完整原生批量及概率。未安装 EMI 时确认客户端及专用服务端不加载 EMI 类型;JEI 单独核对其原生快照覆盖范围。 +JEI 与 EMI 数据源分别核对:工作台压块/拆块、熔炉、已安装机器和第三方加工都进入各自材料页;GT machine row 不重复;`viewer(false)` 的切割机、真空冷冻机、组装机、CNC 与坩埚合金化等在两页均存在。包含空网格的有序合成进入加工图;没有实际输入的行不能成为加工来源。通用标签/候选浏览页不进入信息区;GT 材料单位输入说明仍可打开。GT 材料单位模板即使 `supportsRecipeTree=false` 仍保留原生材料单位与概率;工具装配和可读取的第三方非树加工进入图中并使用未确认关系。零数量工具只作为催化剂,不使整条配方降级。相同原配方 ID,以及同分类下仅槽位顺序或网格占位不同的等价加工行不重复;数量、概率、原生状态或工具不同的行继续保留。超过每侧 128 槽、512 步或 4096 条关联时,页面应显示相应正文中的截断提示。加入坏记录时应有诊断日志和覆盖提示,其余有效路线仍可查询。tag 的同材料候选保持一个 selector,候选集合不同的 selector 不得因首个图标相同而合并。隐藏、延迟注册、资源重载与重新入服后页面跟随当前 viewer 配方,旧导航失效。检索输入、工具及产物不按配方出现次数重复,首次打开才构建详情,仍须保留完整原生批量及概率。分别核对 JEI-only、EMI-only、双装和无 viewer 专用服务端。 1. 在 JEI/EMI 中打开真实材料的“矿物处理”。页面应直接显示同一张画布上有内容的来源/内部转换/回收/去向区域、区标题与相邻区域分割线,空区域不留占位;世界生成和泉进入来源区;无切换或分页。连续链水平向右,替代路线和分叉就近分行;未分类步骤、无外部入口环及自环不能消失。不同 GUI 缩放下右侧、底部裁剪正确。 2. 切割机三种润滑剂相同机器图标和完整可见输入或输出时只显示一条路线;仅首产物相同而其他可见产物不同、输入又不同的路线保持独立,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。EMI 物品和机器使用原生槽位,确认自定义来源/用途绑定、点击释放、R/U、收藏及拖动物品均与普通 EMI 槽位一致,不精确锁定原配方;JEI 沿用普通来源/用途 focus;EMI 使用原生 tooltip,JEI 常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。非 1 件产量、U/mB 和非必然概率在图标上可见,精度保留至原生百分比;确定的 1 件产出不加数量/概率角标,未知概率显示 `?%`。共享资源采用生产端口的量,多个变体的不同量显示多值/省略号并可悬停查看;时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 diff --git a/docs/development/validation/routes.yaml b/docs/development/validation/routes.yaml index 02fd802ec..e9439c90f 100644 --- a/docs/development/validation/routes.yaml +++ b/docs/development/validation/routes.yaml @@ -118,3 +118,8 @@ routes: - "minecraft/versions/*/src/main/java/gregtech/network/**" packages: [runtime] checks: [manual-ingame] + - paths: + - "minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java" + - "minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java" + packages: [runtime] + checks: [manual-ingame, gametest] diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java b/minecraft/src/main/java/gregtech/client/MaterialProcessOverview.java similarity index 98% rename from minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java rename to minecraft/src/main/java/gregtech/client/MaterialProcessOverview.java index 776592159..7734b602f 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessOverview.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessOverview.java @@ -1,6 +1,7 @@ -package gregtech.compat.common; +package gregtech.client; import gregtech.api.addon.material.DataKey; +import gregtech.compat.common.MaterialProcessDisplay; import gregtech.compat.common.MaterialProcessDisplay.Connection; import gregtech.compat.common.MaterialProcessDisplay.Page; import gregtech.compat.common.MaterialProcessDisplay.Port; @@ -293,8 +294,8 @@ private MaterialProcessOverview(Page page, boolean partition) { var endpoint = new Endpoint(step, output, index, port); machine.endpoints.add(endpoint); String instance = output && step.genericRecovery() - ? "recovery:" + machine.key + ":" + port.identity() - : "resource:" + port.identity(); + ? "recovery:" + machine.key + ":" + port.semanticIdentity() + : "resource:" + port.semanticIdentity(); Node resource = resources.computeIfAbsent(instance, identity -> { var node = new Node(identity, null); node.feedbackCopy = output && step.genericRecovery(); @@ -325,9 +326,9 @@ private MaterialProcessOverview(Page page, boolean partition) { // Each pass detaches at least one shared port; copies themselves are never split again. while (splitLongEdges()) layout(); Map counts = new HashMap<>(); - for (Node node : nodes) if (!node.machine()) counts.merge(node.port().identity(), 1, Integer::sum); + for (Node node : nodes) if (!node.machine()) counts.merge(node.port().semanticIdentity(), 1, Integer::sum); for (Node node : nodes) - if (!node.machine()) node.copy = counts.get(node.port().identity()) > 1; + if (!node.machine()) node.copy = counts.get(node.port().semanticIdentity()) > 1; route(); anchor = nodes.stream() .filter(node -> !node.machine() && node.port().material().equals(page.material())) @@ -560,9 +561,9 @@ private void partition(Page page) { offset += bandWidth; } var instances = new HashMap(); - for (Node node : nodes) if (!node.machine()) instances.merge(node.port().identity(), 1, Integer::sum); + for (Node node : nodes) if (!node.machine()) instances.merge(node.port().semanticIdentity(), 1, Integer::sum); for (Node node : nodes) - if (!node.machine()) node.copy |= instances.get(node.port().identity()) > 1; + if (!node.machine()) node.copy |= instances.get(node.port().semanticIdentity()) > 1; applyConfirmation(); route(); height = Math.max( @@ -700,7 +701,7 @@ private static List visible(List ports, String material, boolean out } private static List identities(List ports) { - return ports.stream().map(Port::identity).distinct().sorted().toList(); + return ports.stream().map(Port::semanticIdentity).distinct().sorted().toList(); } private Node resource(Edge edge) { @@ -1063,10 +1064,10 @@ private static boolean fits(Map> cells, Map> neighbors) { - if (!start.machine()) return start.port().identity(); + if (!start.machine()) return start.port().semanticIdentity(); return neighbors.getOrDefault(start, List.of()).stream() .filter(node -> !node.machine()) - .map(node -> node.port().identity()) + .map(node -> node.port().semanticIdentity()) .sorted() .findFirst() .orElse(start.key); diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java index 678cf40ac..e9fa01ebd 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java @@ -1,11 +1,10 @@ package gregtech.client; import com.mojang.math.Axis; +import gregtech.client.MaterialProcessOverview.Node; import gregtech.compat.common.MaterialProcessDisplay.Page; import gregtech.compat.common.MaterialProcessDisplay.Port; -import gregtech.compat.common.MaterialProcessOverview; -import gregtech.compat.common.MaterialProcessOverview.Node; -import gregtech.compat.jei.PreviewViewport; +import gregtech.compat.common.PreviewViewport; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -322,6 +321,9 @@ public List tooltip(double mouseX, double mouseY) { } lines.addAll(names.values().stream().limit(12).toList()); if (names.size() > 12) lines.add(Component.literal("…")); + var step = selected(node); + step.specialProcess().ifPresent(process -> lines.add(process.name())); + lines.addAll(step.details().stream().limit(8).toList()); return List.copyOf(lines); } diff --git a/minecraft/src/main/java/gregtech/client/MultiblockPreviewPanel.java b/minecraft/src/main/java/gregtech/client/MultiblockPreviewPanel.java index 84e7cd656..aebd2545e 100644 --- a/minecraft/src/main/java/gregtech/client/MultiblockPreviewPanel.java +++ b/minecraft/src/main/java/gregtech/client/MultiblockPreviewPanel.java @@ -1,5 +1,6 @@ package gregtech.client; +import gregtech.compat.common.RecipeMachines; import gregtech.compat.jei.*; import gregtech.util.PreviewCamera; import java.util.*; diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java index 543ef3a9b..b12d0d054 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java @@ -137,6 +137,15 @@ public List tooltip() { lines.addAll(details); return List.copyOf(lines); } + + /** + * Structural identity for topology and folding. Concrete native states compare by display + * identity, while selectors retain their producer-assigned resource key even when their + * first icon is also the representative of another selector. + */ + public String semanticIdentity() { + return resource.path().startsWith("resource/native/selector/") ? resource.toString() : identity; + } } /** Explicit edges from the producer, including branches and cycles. Unconfirmed edges are drawn dashed. */ diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java index 1e0fc3df9..2f38723cd 100644 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java +++ b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java @@ -90,7 +90,7 @@ private static List pages( DataKey root, MaterialProcessDisplay.Navigation navigation, java.util.Map workstations) { - var query = snapshot.queryMaterial(root); + var query = snapshot.queryMaterial(root, MaterialProcessGraph.Budgets.MATERIAL_PAGE); var steps = new ArrayList(); for (Step step : query.steps()) { try { @@ -99,8 +99,10 @@ private static List pages( LOGGER.warn("Discarded invalid material process display step {}", step.reference(), failure); } } - var flows = query.flows().stream() - .map(flow -> new MaterialProcessDisplay.Flow(flow.resource(), flow.sources(), flow.targets())) + List flows = List.of(); + var connections = query.edges().stream() + .map(edge -> new MaterialProcessDisplay.Connection( + edge.source(), edge.target(), edge.resource(), edge.confirmed())) .toList(); List notices = new ArrayList<>(query.notices().stream().map(MaterialProcessProjection::notice).toList()); if (steps.size() != query.steps().size()) @@ -109,7 +111,8 @@ private static List pages( Resource resource = snapshot.resource(query.root()).orElse(null); Component title = title(query.root(), resource); String material = resource == null ? "" : resource.material(); - return List.of(new MaterialProcessDisplay.Page(title, material, steps, List.of(), notices, 1, 1, navigation, List.of(), flows)); + return List.of(new MaterialProcessDisplay.Page( + title, material, steps, connections, notices, 1, 1, navigation, List.of(), flows)); } private static MaterialProcessDisplay.Step step(MaterialProcessSnapshot snapshot, Step step, @@ -399,7 +402,7 @@ private static Component notice(Notice notice) { case "edge_limit" -> Component.translatable("gt6ce.jei.material_process.coverage.edge_limit", notice.omitted()); case "depth_limit" -> - Component.translatable("gt6ce.jei.material_process.coverage.node_limit", notice.omitted()); + Component.translatable("gt6ce.jei.material_process.coverage.depth_limit", notice.omitted()); case "no_sources" -> Component.translatable("gt6ce.jei.material_process.no_sources"); case "no_uses" -> Component.translatable("gt6ce.jei.material_process.no_uses"); case "no_both" -> Component.translatable("gt6ce.jei.material_process.no_both"); diff --git a/minecraft/src/main/java/gregtech/compat/jei/PreviewViewport.java b/minecraft/src/main/java/gregtech/compat/common/PreviewViewport.java similarity index 97% rename from minecraft/src/main/java/gregtech/compat/jei/PreviewViewport.java rename to minecraft/src/main/java/gregtech/compat/common/PreviewViewport.java index 623412c58..a15f47f7a 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/PreviewViewport.java +++ b/minecraft/src/main/java/gregtech/compat/common/PreviewViewport.java @@ -1,4 +1,4 @@ -package gregtech.compat.jei; +package gregtech.compat.common; import org.joml.Matrix4fc; import org.joml.Vector3f; diff --git a/minecraft/src/main/java/gregtech/compat/jei/RecipeMachines.java b/minecraft/src/main/java/gregtech/compat/common/RecipeMachines.java similarity index 99% rename from minecraft/src/main/java/gregtech/compat/jei/RecipeMachines.java rename to minecraft/src/main/java/gregtech/compat/common/RecipeMachines.java index a024f92e1..e86fa9011 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/RecipeMachines.java +++ b/minecraft/src/main/java/gregtech/compat/common/RecipeMachines.java @@ -1,4 +1,4 @@ -package gregtech.compat.jei; +package gregtech.compat.common; import gregtech.content.data.MachineRecipeMaps; import gregtech.content.registry.BehaviorMachineRegistration; diff --git a/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java b/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java index 82c14d459..704485e9f 100644 --- a/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java +++ b/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java @@ -15,6 +15,8 @@ /** Category identities shared by the two viewers, independent of workstation ordering. */ public final class RecipeViewerIcons { + private static volatile java.util.Map cachedCategories; + private RecipeViewerIcons() {} public static ItemStack item(String path) { @@ -47,10 +49,17 @@ public static ItemStack category(RecipeMap map, java.util.Map categories() { - var machines = gregtech.compat.jei.RecipeMachines.collect(); - var icons = new java.util.HashMap(); - for (RecipeMap map : RecipeMap.RECIPE_MAP_LIST) icons.put(map, category(map, machines)); - return icons; + var cached = cachedCategories; + if (cached != null) return cached; + synchronized (RecipeViewerIcons.class) { + if (cachedCategories == null) { + var machines = RecipeMachines.collect(); + var icons = new java.util.HashMap(); + for (RecipeMap map : RecipeMap.RECIPE_MAP_LIST) icons.put(map, category(map, machines)); + cachedCategories = java.util.Map.copyOf(icons); + } + return cachedCategories; + } } public static ItemStack map(RecipeMap map) { diff --git a/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoData.java b/minecraft/src/main/java/gregtech/compat/common/WorldgenInfoData.java similarity index 98% rename from minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoData.java rename to minecraft/src/main/java/gregtech/compat/common/WorldgenInfoData.java index e2325c11d..2ccc649a1 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoData.java +++ b/minecraft/src/main/java/gregtech/compat/common/WorldgenInfoData.java @@ -1,4 +1,4 @@ -package gregtech.compat.jei; +package gregtech.compat.common; import gregtech.api.addon.worldgen.OreVeinDeclaration; import gregtech.api.addon.worldgen.SmallOreDeclaration; @@ -69,6 +69,7 @@ public static ItemStack smallOreStack(GTMaterial material) { } public static List buildVeins() { + if (!gregtech.GregTechConfig.Worldgen.GEOLOGY.enabled()) return List.of(); List out = new ArrayList<>(); var overworld = GTOreVeins.activeOverworldVeins(); int overworldWeight = @@ -380,6 +381,7 @@ public static List stratumCaptions(VeinInfo vein) { } public static List buildSmallOres() { + if (!gregtech.GregTechConfig.Worldgen.GEOLOGY.enabled()) return List.of(); List out = new ArrayList<>(); for (GTOreVeins.SmallOre o : GTOreVeins.activeOverworldSmallOres()) { out.add(new SmallOreInfo( @@ -405,6 +407,7 @@ public static List buildSmallOres() { } public static List buildLayers() { + if (!gregtech.GregTechConfig.Worldgen.GEOLOGY.enabled()) return List.of(); List out = new ArrayList<>(); java.util.Set seen = new java.util.HashSet<>(); for (GTStoneLayersGen.LayerDef def : GTStoneLayersGen.LAYERS) { @@ -442,6 +445,7 @@ public static List buildLayers() { public record BedrockInfo(String name, GTMaterial material, int chance, ItemStack flower) {} public static List buildBedrockOres() { + if (!gregtech.GregTechConfig.Worldgen.BEDROCK_ORES.enabled()) return List.of(); List out = new ArrayList<>(); for (gregtech.content.worldgen.GTBedrockOres.BedrockOre ore : gregtech.content.worldgen.GTBedrockOres.OVERWORLD) { diff --git a/minecraft/src/main/java/gregtech/compat/emi/EmiWidgetInput.java b/minecraft/src/main/java/gregtech/compat/emi/EmiWidgetInput.java index 09d11b31c..bca5abed2 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/EmiWidgetInput.java +++ b/minecraft/src/main/java/gregtech/compat/emi/EmiWidgetInput.java @@ -1,6 +1,6 @@ package gregtech.compat.emi; -import gregtech.compat.jei.PreviewViewport; +import gregtech.compat.common.PreviewViewport; import java.util.*; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index 05f10583c..34918693a 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -6,7 +6,7 @@ import dev.emi.emi.api.recipe.EmiRecipe; import dev.emi.emi.api.recipe.EmiRecipeCategory; import dev.emi.emi.api.stack.EmiStack; -import gregtech.compat.jei.RecipeMachines; +import gregtech.compat.common.RecipeMachines; import gregtech.content.item.GTToolItem; import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.engine.recipe.RecipeMap; diff --git a/minecraft/src/main/java/gregtech/compat/emi/StructureEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/StructureEmiRecipe.java index 34b298ed8..27817d224 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/StructureEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/StructureEmiRecipe.java @@ -4,6 +4,7 @@ import dev.emi.emi.api.recipe.*; import dev.emi.emi.api.stack.*; import dev.emi.emi.api.widget.*; +import gregtech.compat.common.PreviewViewport; import gregtech.compat.jei.*; import java.util.*; import net.minecraft.core.registries.BuiltInRegistries; diff --git a/minecraft/src/main/java/gregtech/compat/emi/WorldgenEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/WorldgenEmiRecipe.java index ccd7146cf..c76f44ed9 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/WorldgenEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/WorldgenEmiRecipe.java @@ -4,7 +4,7 @@ import dev.emi.emi.api.recipe.*; import dev.emi.emi.api.stack.*; import dev.emi.emi.api.widget.WidgetHolder; -import gregtech.compat.jei.WorldgenInfoData; +import gregtech.compat.common.WorldgenInfoData; import gregtech.content.worldgen.GTWorldgenScale; import java.util.*; import net.minecraft.client.Minecraft; diff --git a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java index 9b1c11b7d..967133856 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java @@ -1,6 +1,7 @@ package gregtech.compat.jei; import gregtech.content.recipe.MaterialProcessSnapshot; +import gregtech.compat.common.RecipeMachines; import gregtech.engine.recipe.Recipe; import gregtech.engine.recipe.RecipeMap; import gregtech.platform.Mc; @@ -33,6 +34,15 @@ public final class GregTechJEIPlugin implements IModPlugin { @Override public void onRuntimeAvailable(mezz.jei.api.runtime.IJeiRuntime runtime) { this.runtime = runtime; + if (!emiLoaded() && processCategory != null) { + var source = MaterialProcessSnapshot.Store.current(); + var snapshot = MaterialProcessJeiRecipes.capture(source, runtime); + processSnapshot = snapshot; + var navigation = new ProcessNavigation(source, snapshot); + runtime.getRecipeManager().addRecipes( + MaterialProcessCategory.TYPE, + gregtech.compat.common.MaterialProcessProjection.initialPages(snapshot, navigation)); + } gregtech.client.gui.RecipeViewerNavigation.registerJei(map -> { if (!categories.containsKey(map)) return false; runtime.getRecipesGui().showTypes(java.util.List.of(RecipeMapCategory.recipeType(map))); @@ -239,10 +249,6 @@ public void registerRecipes(IRecipeRegistration registration) { //?} registration.addRecipes(MoldChiselCategory.TYPE, gregtech.compat.common.MoldChiselDisplay.recipes()); - processSnapshot = MaterialProcessSnapshot.Store.current(); - var processNavigation = new ProcessNavigation(processSnapshot); - registration.addRecipes(MaterialProcessCategory.TYPE, - gregtech.compat.common.MaterialProcessProjection.initialPages(processSnapshot, processNavigation)); var unitTags = gregtech.compat.common.MaterialUnitTagDisplay.entries(); for (var family : MaterialUnitTagCategory.FAMILIES) registration.addRecipes(MaterialUnitTagCategory.type(family), MaterialUnitTagCategory.pages(family, unitTags)); @@ -283,20 +289,22 @@ private ItemStack iconFor(RecipeMap map) { } private final class ProcessNavigation implements gregtech.compat.common.MaterialProcessDisplay.Navigation { + private final MaterialProcessSnapshot source; private final MaterialProcessSnapshot snapshot; - private ProcessNavigation(MaterialProcessSnapshot snapshot) { + private ProcessNavigation(MaterialProcessSnapshot source, MaterialProcessSnapshot snapshot) { + this.source = source; this.snapshot = snapshot; } @Override public boolean valid() { - return MaterialProcessSnapshot.Store.current(snapshot); + return processSnapshot == snapshot && MaterialProcessSnapshot.Store.current(source); } @Override public boolean openStack(ItemStack stack, boolean uses) { - if (runtime == null || !MaterialProcessSnapshot.Store.current(snapshot) || stack.isEmpty()) return false; + if (runtime == null || !valid() || stack.isEmpty()) return false; var role = uses ? mezz.jei.api.recipe.RecipeIngredientRole.INPUT : mezz.jei.api.recipe.RecipeIngredientRole.OUTPUT; var factory = runtime.getJeiHelpers().getFocusFactory(); var focuses = new ArrayList>(); @@ -316,10 +324,18 @@ public boolean openStack(ItemStack stack, boolean uses) { @Override public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { - if (runtime == null || !MaterialProcessSnapshot.Store.current(snapshot)) return false; + if (runtime == null || !valid()) return false; var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, resource, this); runtime.getRecipesGui().showRecipes(processCategory, pages, List.of()); return true; } } + + private static boolean emiLoaded() { +//? if >=1.21.1 { + /*return net.neoforged.fml.ModList.get().isLoaded("emi"); +*///?} else { + return net.minecraftforge.fml.ModList.get().isLoaded("emi"); +//?} + } } diff --git a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java new file mode 100644 index 000000000..6bbd87ade --- /dev/null +++ b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java @@ -0,0 +1,227 @@ +package gregtech.compat.jei; + +import gregtech.content.recipe.MaterialProcessSnapshot; +import gregtech.engine.material.MaterialProcessGraph.Port; +import gregtech.engine.material.MaterialProcessGraph.Role; +import gregtech.engine.recipe.Recipe; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.Set; +import java.util.stream.Stream; +import mezz.jei.api.gui.IRecipeLayoutDrawable; +import mezz.jei.api.gui.ingredient.IRecipeSlotView; +import mezz.jei.api.ingredients.IIngredientType; +import mezz.jei.api.ingredients.ITypedIngredient; +import mezz.jei.api.recipe.IFocus; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.IRecipeManager; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.category.IRecipeCategory; +import mezz.jei.api.constants.VanillaTypes; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +//? if >=1.21.1 { +/*import mezz.jei.api.neoforge.NeoForgeTypes; +import net.neoforged.neoforge.fluids.FluidStack; +*///?} else { +import mezz.jei.api.forge.ForgeTypes; +import net.minecraftforge.fluids.FluidStack; +//?} + +/** Captures JEI's final visible recipe rows into the same material-page view model used by EMI. */ +final class MaterialProcessJeiRecipes { + private static final IFocusGroup NO_FOCUS = new IFocusGroup() { + @Override + public boolean isEmpty() { + return true; + } + + @Override + public List> getAllFocuses() { + return List.of(); + } + + @Override + public Stream> getFocuses(RecipeIngredientRole role) { + return Stream.empty(); + } + + @Override + public Stream> getFocuses(IIngredientType type) { + return Stream.empty(); + } + + @Override + public Stream> getFocuses(IIngredientType type, RecipeIngredientRole role) { + return Stream.empty(); + } + }; + + private MaterialProcessJeiRecipes() {} + + static MaterialProcessSnapshot capture( + MaterialProcessSnapshot source, mezz.jei.api.runtime.IJeiRuntime runtime) { + var builder = source.viewerBuilder(); + var manager = runtime.getRecipeManager(); + var categories = manager.createRecipeCategoryLookup().get() + .filter(category -> !informationOnly(category.getRecipeType())) + .toList(); + var ids = new HashSet(); + var counters = new Counters(); + for (var category : categories) captureCategory(manager, category, builder, ids, counters); + gregtech.platform.Mc.logger() + .info("[gregtech] JEI material process index: {} visible categories, {} recipes, {} rows, {} omitted", + categories.size(), counters.recipes, counters.rows, counters.omitted); + return builder.build(); + } + + private static boolean informationOnly(mezz.jei.api.recipe.RecipeType type) { + if (type.equals(MaterialProcessCategory.TYPE) + || type.equals(MultiblockInfoCategory.TYPE) + || type.equals(MoldChiselCategory.TYPE) + || type.equals(LootInfoCategories.LOOT) + || type.equals(LootInfoCategories.MOBS) + || type.equals(WorldgenInfoCategories.VEIN_TYPE) + || type.equals(WorldgenInfoCategories.SMALL_ORE_TYPE) + || type.equals(WorldgenInfoCategories.LAYER_TYPE) + || type.equals(WorldgenInfoCategories.BEDROCK_TYPE)) return true; + for (var family : MaterialUnitTagCategory.FAMILIES) + if (type.equals(MaterialUnitTagCategory.type(family))) return true; + return false; + } + + private static void captureCategory( + IRecipeManager manager, + IRecipeCategory category, + MaterialProcessSnapshot.ViewerBuilder builder, + Set ids, + Counters counters) { + var recipes = manager.createRecipeLookup(category.getRecipeType()).get().toList(); + counters.recipes += recipes.size(); + for (int index = 0; index < recipes.size(); index++) { + T recipe = recipes.get(index); + ResourceLocation id = category.getRegistryName(recipe); + if (id != null && !ids.add(category.getRecipeType().getUid() + "/" + id)) continue; + if (category instanceof RecipeMapCategory mapCategory + && recipe instanceof Recipe nativeRecipe + && builder.machine(mapCategory.recipeMap(), nativeRecipe)) { + counters.rows++; + continue; + } + captureRecipe(manager, category, recipe, index, builder, counters); + } + } + + private static void captureRecipe( + IRecipeManager manager, + IRecipeCategory category, + T recipe, + int index, + MaterialProcessSnapshot.ViewerBuilder builder, + Counters counters) { + Optional> drawable = + manager.createRecipeLayoutDrawable(category, recipe, NO_FOCUS); + if (drawable.isEmpty()) { + builder.omitted(); + counters.omitted++; + return; + } + var inputs = new ArrayList(); + var outputs = new ArrayList(); + for (IRecipeSlotView slot : drawable.get().getRecipeSlotsView().getSlotViews()) { + if (slot.isEmpty() || slot.getRole() == RecipeIngredientRole.RENDER_ONLY) continue; + Port port = port(builder, slot); + if (port == null) { + builder.omitted(); + counters.omitted++; + return; + } + switch (slot.getRole()) { + case INPUT, CATALYST -> inputs.add(port); + case OUTPUT -> outputs.add(port); + default -> { + builder.omitted(); + counters.omitted++; + return; + } + } + } + if (inputs.isEmpty() || outputs.isEmpty()) { + builder.omitted(); + counters.omitted++; + return; + } + ItemStack machine = manager.createRecipeCatalystLookup(category.getRecipeType()).getItemStack() + .findFirst().orElseGet(() -> new ItemStack(Items.ANVIL)); + ResourceLocation type = category.getRecipeType().getUid(); + ResourceLocation registryName = category.getRegistryName(recipe); + gregtech.api.addon.material.DataKey reference = new gregtech.api.addon.material.DataKey( + "gt6ce", + "process/jei/" + type.getNamespace() + "/" + type.getPath() + "/" + index + "/" + + Long.toUnsignedString( + builder.publicationRevision(), 36) + + "/" + + Long.toUnsignedString(builder.sessionGeneration(), 36)); + var details = new ArrayList(); + details.add("viewer category: " + type); + if (registryName != null) details.add("viewer recipe: " + registryName); + details.add("matching constraints and remainders: see original recipe"); + builder.recipe( + reference, + type.toString(), + category.getTitle().getString(), + machine, + List.copyOf(inputs), + List.copyOf(outputs), + List.copyOf(details), + true); + counters.rows++; + } + + private static Port port(MaterialProcessSnapshot.ViewerBuilder builder, IRecipeSlotView slot) { + var fluids = new ArrayList(); + var items = new ArrayList(); + for (ITypedIngredient typed : slot.getAllIngredients().toList()) { + if (typed == null) continue; +//? if >=1.21.1 { + /*typed.getIngredient(NeoForgeTypes.FLUID_STACK) + .filter(fluid -> !fluid.isEmpty()) + .ifPresent(fluids::add); +*///?} else { + typed.getIngredient(ForgeTypes.FLUID_STACK) + .filter(fluid -> !fluid.isEmpty()) + .ifPresent(fluids::add); +//?} + typed.getIngredient(VanillaTypes.ITEM_STACK) + .filter(stack -> !stack.isEmpty()) + .ifPresent(items::add); + } + Role role = switch (slot.getRole()) { + case INPUT -> Role.CONSUMED; + case CATALYST -> Role.CATALYST; + case OUTPUT -> Role.UNKNOWN; + default -> null; + }; + if (role == null) return null; + var candidates = new ArrayList(); + // Fluid renderers may also expose an item proxy. The native fluid is the authoritative slot value. + if (!fluids.isEmpty()) { + for (FluidStack fluid : fluids) + candidates.add(builder.fluid(fluid, role, fluid.getAmount(), OptionalInt.empty())); + } else { + for (ItemStack stack : items) + candidates.add(builder.item(stack, role, stack.getCount(), OptionalInt.empty())); + } + return candidates.isEmpty() ? null : builder.alternatives(candidates); + } + + private static final class Counters { + private int recipes; + private int rows; + private int omitted; + } +} diff --git a/minecraft/src/main/java/gregtech/compat/jei/MultiblockInfoCategory.java b/minecraft/src/main/java/gregtech/compat/jei/MultiblockInfoCategory.java index f37bafe4f..785b0575c 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/MultiblockInfoCategory.java +++ b/minecraft/src/main/java/gregtech/compat/jei/MultiblockInfoCategory.java @@ -1,5 +1,6 @@ package gregtech.compat.jei; +import gregtech.compat.common.PreviewViewport; import gregtech.engine.multiblock.*; import java.util.*; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; diff --git a/minecraft/src/main/java/gregtech/compat/jei/RecipeMapCategory.java b/minecraft/src/main/java/gregtech/compat/jei/RecipeMapCategory.java index ed6c5b0ed..b1269f003 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/RecipeMapCategory.java +++ b/minecraft/src/main/java/gregtech/compat/jei/RecipeMapCategory.java @@ -47,6 +47,7 @@ public RecipeMapCategory(IGuiHelper helper,RecipeMap map,ItemStack icon) { this.icon=helper.createDrawableItemStack(icon); } + public RecipeMap recipeMap() { return map; } /** JEI fixes dimensions per category; choose the smallest bounds containing its actual rows. */ public void fitRecipes(java.util.List recipes) { int width = 140, height = 26; diff --git a/minecraft/src/main/java/gregtech/compat/jei/StructurePreview.java b/minecraft/src/main/java/gregtech/compat/jei/StructurePreview.java index c95b9190a..7e172f3aa 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/StructurePreview.java +++ b/minecraft/src/main/java/gregtech/compat/jei/StructurePreview.java @@ -3,6 +3,7 @@ import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.math.Axis; +import gregtech.compat.common.PreviewViewport; import gregtech.util.PreviewCamera; import java.util.Map; import net.minecraft.client.Minecraft; diff --git a/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoCategories.java b/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoCategories.java index 9c41ec719..97952f908 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoCategories.java +++ b/minecraft/src/main/java/gregtech/compat/jei/WorldgenInfoCategories.java @@ -1,4 +1,6 @@ package gregtech.compat.jei; + +import gregtech.compat.common.WorldgenInfoData; import gregtech.engine.mod.GregTechIdentity; diff --git a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java index 87816aefa..4eef2f9af 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java @@ -169,7 +169,7 @@ private static Result applyGeneration(RecipeManager manager, long current) { baselineRows(), restoreMillis, producersMillis, moved, tally.removed, removeMillis, tally.added, installMillis, tally.priority, tally.rejected); if (generation != current) return lastResult; - lastPublication = MaterialPublication.platformGenerationPublished( + lastPublication = MaterialPublication.candidatePlatformGeneration( ItemMaterialRegistry.compositionRevision(), current); lastResult = new Result(tally.removed, tally.added, tally.rejected, restoreMillis, baselineRows(), false, false); applications++; diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java index a5949fec4..8df87dfd5 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java @@ -301,7 +301,8 @@ static MaterialProcessSnapshot build( if (recipe.mFakeRecipe && !hasMaterialUnitInput(recipe)) continue; BuiltStep built; try { - built = recipeStep(map, recipe, index, publication.revision(), sessionGeneration); + built = recipeStep( + map, recipe, index, publication.revision(), sessionGeneration, resourceGeneration); } catch (RuntimeException failure) { LOGGER.warn("Discarded invalid material process recipe in {} at index {}", map.mNameInternal, index, failure); invalid++; @@ -333,7 +334,12 @@ static MaterialProcessSnapshot build( } private static BuiltStep recipeStep( - RecipeMap map, Recipe recipe, int index, long publication, long session) { + RecipeMap map, + Recipe recipe, + int index, + long publication, + long session, + long resourceGeneration) { var inputs = new ArrayList(); var outputs = new ArrayList(); var materials = new LinkedHashSet(); @@ -344,7 +350,9 @@ private static BuiltStep recipeStep( ItemStack stack = recipe.mInputs[input]; if (stack == null || stack.isEmpty()) continue; if (recipe.isCatalystInput(input)) { - auxiliaryInputs.add("auxiliary catalyst: " + BuiltInRegistries.ITEM.getKey(stack.getItem()) + Port port = itemPort(stack, recipe, input, false, false, nativeStep); + if (port != null) inputs.add(port); + else auxiliaryInputs.add("unresolved catalyst: " + BuiltInRegistries.ITEM.getKey(stack.getItem()) + itemStateSuffix(stack) + " x" + stack.getCount()); continue; } @@ -360,9 +368,13 @@ private static BuiltStep recipeStep( Port port = fluidPort(stack, recipe, input, false, !mainInput); if (port == null) continue; inputs.add(port); - addMaterial(materials, port); + if (port.role() == Role.CONSUMED) addMaterial(materials, port); mainInput |= port.main(); } + for (ItemStack catalyst : gregtech.engine.recipe.RecipeSpecialItems.display(recipe.mSpecialItems)) { + Port port = catalystPort(catalyst, publication, resourceGeneration); + if (port != null) inputs.add(port); + } boolean mainOutput = false; for (int output = 0; output < recipe.mOutputs.length; output++) { ItemStack stack = recipe.mOutputs[output]; @@ -393,6 +405,8 @@ private static BuiltStep recipeStep( details.add("map: " + map.mNameInternal); details.add("duration: " + recipe.mDuration + " ticks"); details.add("energy: " + recipe.mEUt + " EU/t"); + if (gregtech.engine.addon.ExclusiveOutputMaps.enabled(map)) + details.add("exclusive output group: the first chance selects one item output"); if (!recipe.mSource.isBlank()) details.add("source: " + recipe.mSource); if (recipe.mFakeRecipe) details.add("symbolic unit template"); if (recipe.mExactItemInputs) details.add("exact item-state matching"); @@ -419,6 +433,21 @@ private static BuiltStep recipeStep( materials); } + private static Port catalystPort(ItemStack stack, long publication, long resourceGeneration) { + if (stack == null || stack.isEmpty()) return null; + var form = MaterialEquivalence.form(stack); + GTMaterial material = form == null ? material(stack) : form.material().resolve(); + String state = itemDisplayState(stack); + String prefix = form == null ? "item" : form.prefix().getName(); + Resource resource = material == null + ? new Resource(nativeResourceKey("item", state), "unknown", "item", "solid", state) + : itemResource(material, prefix, state); + return scoped( + new Port(resource, Role.CATALYST, new Amount(stack.getCount(), AmountUnit.ITEM), + OptionalInt.empty(), false, List.of("native special catalyst")), + publication, resourceGeneration); + } + private static Port itemPort( ItemStack stack, Recipe recipe, int index, boolean output, boolean mainCandidate, String nativeStep) { String prefix; @@ -804,15 +833,32 @@ private ViewerBuilder(MaterialProcessSnapshot source) { this.source = source; source.nativeRecipes.forEach((reference, row) -> nativeReferences .computeIfAbsent(row.map(), ignored -> new java.util.IdentityHashMap<>()).put(row.recipe(), reference)); - source.steps.values().stream().filter(step -> source.worldgen.containsKey(step.reference())) + source.steps.values().stream() + .filter(step -> source.worldgen.containsKey(step.reference()) + || Optional.ofNullable(source.nativeRecipes.get(step.reference())) + .map(NativeRecipe::map) + .map(map -> !map.mViewerAllowed) + .orElse(false)) .sorted(Comparator.comparing(step -> step.reference().toString())) - .forEach(this::add); + .forEach(step -> { + add(step); + Optional.ofNullable(source.nativeRecipes.get(step.reference())) + .ifPresent(recipe -> recipes.put(step.reference(), recipe)); + }); } public void omitted() { omitted++; } + public long publicationRevision() { + return source.snapshot.publication().revision(); + } + + public long sessionGeneration() { + return source.snapshot.sessionGeneration(); + } + /** Reuses GT matching, unit quantities and recovery ownership, once per visible native row. */ public boolean machine(RecipeMap map, Recipe recipe) { if (!recipe.mEnabled || recipe.mHidden || recipe.mFakeRecipe && !hasMaterialUnitInput(recipe)) return false; @@ -826,8 +872,13 @@ public boolean machine(RecipeMap map, Recipe recipe) { return true; } int index = map.mRecipeList.size() + recipes.size(); - BuiltStep built = recipeStep(map, recipe, index, - source.snapshot.publication().revision(), source.snapshot.sessionGeneration()); + BuiltStep built = recipeStep( + map, + recipe, + index, + source.snapshot.publication().revision(), + source.snapshot.sessionGeneration(), + source.resourceGeneration); if (built == null) return false; built = scoped(built, source.snapshot.publication().revision(), source.resourceGeneration); addStep(buckets, built.step, built.materials); @@ -945,10 +996,9 @@ public MaterialProcessSnapshot build() { } } - /** Bounded current/previous publication retained for in-flight viewer callbacks. */ + /** Current publication retained for lifecycle-bound viewer callbacks. */ public static final class Store { private static volatile MaterialProcessSnapshot current = EMPTY; - private static volatile MaterialProcessSnapshot previous; private Store() {} @@ -970,11 +1020,14 @@ public static synchronized MaterialProcessSnapshot publish( && current.snapshot.sessionGeneration() == sessionGeneration && current.snapshot.formRevision() == gregtech.engine.material.MaterialViews.contentRevision() && current.snapshot.tagGeneration() == ItemMaterialRegistry.compositionState().tagGeneration() - && current.snapshot.worldgenRevision() == worldgen.revision()) return current; + && current.snapshot.worldgenRevision() == worldgen.revision()) { + gregtech.engine.material.MaterialPublication.commit(publication); + return current; + } MaterialProcessSnapshot built = MaterialProcessSnapshot.build(publication, sessionGeneration, worldgen); - previous = current; current = built; + gregtech.engine.material.MaterialPublication.commit(publication); LOGGER.info( "[gregtech] Material process snapshot {} published with {} material roots, " + "{} recipe refs in {} ms", @@ -996,7 +1049,6 @@ public static synchronized MaterialProcessSnapshot publish( public static synchronized void clear(MaterialProcessSnapshot expected) { if (current != expected) return; current = EMPTY; - previous = null; } } } diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java index 5c777bdab..35c12c0d3 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java @@ -66,6 +66,7 @@ public static void rebuild() { var catalog = MaterialViews.catalog(); var methods = methodRules(catalog); var resolver = new Resolver(); + int omitted = 0; for (var methodRules : methods) { var method = methodRules.method(); RecipeMap map = RecipeMap.RECIPE_MAP_LIST.stream() @@ -84,8 +85,11 @@ public static void rebuild() { var built = build( target.material(), inputEntry.getKey(), inputEntry.getValue(), target.plan(), reagent, resolver); - if (built == null) continue; - Recipe accepted = map.addRecipe(built); + if (built.recipe() == null) { + omitted++; + continue; + } + Recipe accepted = map.addRecipe(built.recipe()); if (accepted != null) { accepted.withSpecialProcess(method.process().id()); OWNED.add(accepted); @@ -94,6 +98,10 @@ public static void rebuild() { } } } + if (omitted > 0) + com.mojang.logging.LogUtils.getLogger() + .warn("[gregtech] Omitted {} special-process rows whose material forms or reagent did not resolve", + omitted); annotateExistingRows(methods); } @@ -173,7 +181,9 @@ private static boolean sameFluidMaterial(FluidStack stack, MaterialKey material, return value.isValid() && value.getName().equals(material.name()) && entry.gas() == form.name().equals("gas"); } - private static Recipe build( + private record BuildResult(Recipe recipe) {} + + private static BuildResult build( MaterialKey target, FormKey inputForm, int inputCount, @@ -181,11 +191,12 @@ private static Recipe build( ReagentSelector reagent, Resolver resolver) { ItemStack input = resolver.item(target, inputForm, inputCount); - if (input.isEmpty()) return null; + if (input.isEmpty()) return new BuildResult(null); var itemInputs = new ArrayList(); itemInputs.add(input); var fluidInputs = new ArrayList(); - if (!addReagent(reagent, plan.reagentAmount(), itemInputs, fluidInputs, resolver)) return null; + if (!addReagent(reagent, plan.reagentAmount(), itemInputs, fluidInputs, resolver)) + return new BuildResult(null); var itemOutputs = new ArrayList(); var chances = new ArrayList(); @@ -200,8 +211,8 @@ private static Recipe build( FluidStack stack = firstFluid(output, resolver); if (!stack.isEmpty()) fluidOutputs.add(stack); } - if (itemOutputs.isEmpty() && fluidOutputs.isEmpty()) return null; - return new Recipe( + if (itemOutputs.isEmpty() && fluidOutputs.isEmpty()) return new BuildResult(null); + return new BuildResult(new Recipe( itemInputs.toArray(ItemStack[]::new), itemOutputs.toArray(ItemStack[]::new), null, @@ -210,7 +221,7 @@ private static Recipe build( fluidOutputs.toArray(FluidStack[]::new), plan.duration(), plan.euPerTick(), - 0); + 0)); } private static boolean addReagent( diff --git a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java index 6a377b065..a0ca0a63c 100644 --- a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java +++ b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java @@ -1,5 +1,10 @@ package gregtech.content.worldgen; +import gregtech.api.addon.material.FormKey; +import gregtech.api.addon.material.GregTechMaterials; +import gregtech.api.addon.material.MaterialFormBinding; +import gregtech.api.addon.material.MaterialFormKind; +import gregtech.api.addon.material.MaterialKey; import gregtech.api.addon.worldgen.OreVeinDeclaration; import gregtech.api.addon.worldgen.SmallOreDeclaration; import gregtech.api.material.GTMaterial; @@ -104,10 +109,12 @@ private MaterialWorldgenFacts() {} public static Snapshot capture() { var facts = new ArrayList(); - appendLargeVeins(facts); - appendSmallOres(facts); - appendStoneLayers(facts); - appendBedrock(facts); + if (gregtech.GregTechConfig.Worldgen.GEOLOGY.enabled()) { + appendLargeVeins(facts); + appendSmallOres(facts); + appendStoneLayers(facts); + } + if (gregtech.GregTechConfig.Worldgen.BEDROCK_ORES.enabled()) appendBedrock(facts); return new Snapshot(facts); } @@ -208,18 +215,34 @@ private static void appendStoneLayers(List facts) { if (layer.noDeep()) min = Math.max(min, GTWorldgenScale.remapY(24)); int max = Math.min(GTWorldgenScale.BAND_TOP - 1, GTWorldgenScale.remapY(definition.maxY())); if (min > max) continue; - Item item = explicitItem(material, rule); - if (item == Items.AIR) continue; - ores.add(new Ore( - material, - itemState(item), - min, - max, - 1, - Math.max(1, definition.chanceDiv()), - rule.biomes().isEmpty() - ? List.of("stone-layer roll") - : List.of("stone-layer roll; biomes: " + rule.biomes()))); + List oreDetails = rule.biomes().isEmpty() + ? List.of("stone-layer roll") + : List.of("stone-layer roll; biomes: " + rule.biomes()); + Item explicit = explicitItem(material, rule); + if (explicit != Items.AIR) { + ores.add(new Ore( + material, + itemState(explicit), + min, + max, + 1, + Math.max(1, definition.chanceDiv()), + oreDetails)); + } else { + // Layer interiors use normal ore in the core and small ore at the edges; contacts + // choose between both. Keep both real resources rather than collapsing to ore_. + for (Item item : List.of(oreItem(material), smallOreItem(material))) { + if (item == Items.AIR) continue; + ores.add(new Ore( + material, + itemState(item), + min, + max, + 1, + Math.max(1, definition.chanceDiv()), + oreDetails)); + } + } } if (ores.isEmpty()) continue; int minY = ores.stream().mapToInt(Ore::minY).min().orElse(0); @@ -243,11 +266,15 @@ private static void appendBedrock(List facts) { } private static void appendBedrock(List facts, List rows, String dimension) { + long totalWeight = rows.stream() + .mapToLong(row -> MineralWorldgenRules.bedrockWeight(row.chance())) + .sum(); for (GTBedrockOres.BedrockOre row : rows) { GTMaterial material = row.material().resolve(); if (!material.isValid()) continue; Item item = oreItem(material); if (item == Items.AIR) continue; + int weight = (int) MineralWorldgenRules.bedrockWeight(row.chance()); facts.add(new Fact( "bedrock/" + dimension + "/" + row.name(), row.name(), @@ -255,8 +282,8 @@ private static void appendBedrock(List facts, List facts, List Date: Mon, 16 Nov 2026 15:53:10 +0800 Subject: [PATCH 14/17] bugfix --- .../content/material/MaterialFactKeys.java | 1 - .../engine/material/MaterialInfoRegistry.java | 21 ++++++- .../material/MaterialRegistrationTest.java | 21 +++++++ docs/decisions/material-system/README.md | 2 +- .../data-api-and-publication.md | 2 +- docs/development/validation/checks/junit.md | 2 +- .../gregtech/client/MaterialProcessPanel.java | 5 ++ .../client/MaterialProcessScreen.java | 8 +++ .../compat/jei/MaterialProcessJeiRecipes.java | 43 +++----------- .../content/recipe/MachineRecipeOverlay.java | 1 + .../recipe/SharedSpecialProcessRows.java | 56 +++++++++---------- .../worldgen/MaterialWorldgenFacts.java | 7 ++- .../mixin/EmiMaterialProcessFocusMixin.java | 1 + 13 files changed, 97 insertions(+), 73 deletions(-) diff --git a/core/src/main/java/gregtech/content/material/MaterialFactKeys.java b/core/src/main/java/gregtech/content/material/MaterialFactKeys.java index 5cadcd1ff..3585162fd 100644 --- a/core/src/main/java/gregtech/content/material/MaterialFactKeys.java +++ b/core/src/main/java/gregtech/content/material/MaterialFactKeys.java @@ -6,7 +6,6 @@ import gregtech.content.material.catalog.SourceLensMaterialFacts; import gregtech.content.material.catalog.SourceRecyclingMaterialFacts; import gregtech.content.material.catalog.SourceWashingMaterialFacts; - import java.util.List; import java.util.Map; import java.util.Optional; diff --git a/core/src/main/java/gregtech/engine/material/MaterialInfoRegistry.java b/core/src/main/java/gregtech/engine/material/MaterialInfoRegistry.java index d87719f64..19ee9857e 100644 --- a/core/src/main/java/gregtech/engine/material/MaterialInfoRegistry.java +++ b/core/src/main/java/gregtech/engine/material/MaterialInfoRegistry.java @@ -387,7 +387,26 @@ private static Set normalizeProcessForms( static MaterialProcessRule normalizeProcessRule( String source, MaterialProcessKey process, MaterialProcessRule rule) { - return new MaterialProcessRule<>(normalizeProcessForms(source, process, rule.forms()), rule.value()); + var forms = normalizeProcessForms(source, process, rule.forms()); + if (rule.value() instanceof SpecialProcessValue.Target target) { + var counts = new LinkedHashMap(); + target.inputCounts().forEach((form, count) -> { + var normalized = normalizeProcessForms(source, process, Set.of(form)) + .iterator() + .next(); + if (counts.putIfAbsent(normalized, count) != null) + throw new IllegalArgumentException("Duplicate normalized special process input form " + normalized); + }); + var normalized = new SpecialProcessValue.Target( + counts, + target.itemOutputs(), + target.fluidOutputs(), + target.reagentAmount(), + target.duration(), + target.euPerTick()); + return new MaterialProcessRule<>(forms, normalized); + } + return new MaterialProcessRule<>(forms, rule.value()); } @Override diff --git a/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java b/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java index 18cb3bc2e..09af0def8 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java @@ -16,6 +16,27 @@ import static org.junit.jupiter.api.Assertions.*; class MaterialRegistrationTest { + @Test + void specialProcessInputCountsFollowFormAliases() { + var alias = new FormKey("casingSmall"); + var canonical = new FormKey("itemCasing"); + var process = new MaterialProcessKey<>( + new DataKey("test_addon", "special"), SpecialProcessValue.class, MaterialProcessCardinality.MULTIPLE); + var output = new SpecialProcessValue.ItemOutput( + new MaterialKey("Iron"), List.of(new SpecialProcessValue.FormCount(new FormKey("dust"), 1)), 10000); + var target = new SpecialProcessValue.Target(Map.of(alias, 2), List.of(output), List.of(), 100, 20, 2); + var normalized = MaterialInfoRegistry.normalizeProcessRule( + "test", process, new MaterialProcessRule<>(Set.of(alias), target)); + assertEquals(Set.of(canonical), normalized.forms()); + assertEquals(Map.of(canonical, 2), ((SpecialProcessValue.Target) normalized.value()).inputCounts()); + var duplicate = + new SpecialProcessValue.Target(Map.of(alias, 2, canonical, 3), List.of(output), List.of(), 100, 20, 2); + assertThrows( + IllegalArgumentException.class, + () -> MaterialInfoRegistry.normalizeProcessRule( + "test", process, new MaterialProcessRule<>(Set.of(alias, canonical), duplicate))); + } + @Test void singleValuedProcessesRejectMultipleRulesDuringConstruction() { var process = new MaterialProcessKey<>( diff --git a/docs/decisions/material-system/README.md b/docs/decisions/material-system/README.md index 72b8b6e3f..ed176c174 100644 --- a/docs/decisions/material-system/README.md +++ b/docs/decisions/material-system/README.md @@ -40,7 +40,7 @@ 原生资源 Tag 导入 / 数据包变更 │ beginTagGeneration() → 构建新代 Tag 候选 → ItemCompositionResolver ▼ 刷新 MaterialFormContent 绑定 → 回收/分解 RecipeMap overlay 重建 - 成功:提交 MaterialPublication.platformGenerationPublished(compRev, recipeRev) + 成功:candidatePlatformGeneration(compRev, recipeRev) → 快照构建成功后 commit(candidate) 失败:按检查点回滚成分快照与机器配方,保持上一完整 Stamp 不变 ``` diff --git a/docs/decisions/material-system/data-api-and-publication.md b/docs/decisions/material-system/data-api-and-publication.md index 1cc00cf03..618721220 100644 --- a/docs/decisions/material-system/data-api-and-publication.md +++ b/docs/decisions/material-system/data-api-and-publication.md @@ -24,7 +24,7 @@ 由于材料目录定义在进程内一次定稿,而 Tag 成分、形态绑定与机器配方随世界或数据包重载多代替换,`MaterialPublication` 维护原子发布的版本戳 `Stamp(revision, materialRevision, compositionRevision, recipeRevision)`: 1. **进程定义提交**:`GTMaterialRegistry.init()` 到达 `READY` 时调用 `materialDefinitionsPublished(materialRevision)` 唯一一次写定基础材料版本,不允许二次改写。 -2. **平台代次提交**:每次启动装配或热重载在全部 Tag 候选裁决、有效成分构建、`MaterialFormContent` 绑定刷新以及回收/分解配方重建均成功后,才由平台层推进 `platformGenerationPublished(compositionRevision, recipeRevision)`。 +2. **平台代次提交**:每次启动装配或热重载在全部 Tag 候选裁决、有效成分构建、`MaterialFormContent` 绑定刷新以及回收/分解配方重建均成功后,先生成 `candidatePlatformGeneration(compositionRevision, recipeRevision)` 候选,再在展示快照构建成功后调用 `commit(candidate)`。 3. **失败回滚不动旧印记**:重载任一环节报错触发回滚时,`MaterialPublication.current()` 维持上一成功 `Stamp` 不变,保证下游观测不到“成分切至新代但配方仍留旧代”的跨代撕裂。 ## 来源用途索引与有界处理图 diff --git a/docs/development/validation/checks/junit.md b/docs/development/validation/checks/junit.md index 2adffd64f..91f4504db 100644 --- a/docs/development/validation/checks/junit.md +++ b/docs/development/validation/checks/junit.md @@ -54,4 +54,4 @@ issue source kind target expected JUnit XML 在 `/build/test-results/test/TEST-*.xml`,HTML 报告在 `/build/reports/tests/test/`。 -材料纯规则的常驻入口是 `MaterialRegistrationTest`、`ItemCompositionResolverTest`、`MaterialDecompositionPlannerTest` 和 `MaterialProcessGraphTest`。一次性的基线快照、独立 JVM 生命周期矩阵和测试附属注入已移除;长期行为应落入可直接重复运行、不会向运行时注册测试内容的定向测试。 +材料纯规则的常驻入口是 `MaterialRegistrationTest`、`ItemCompositionResolverTest`、`MaterialDecompositionPlannerTest` 、`MaterialProcessGraphTest` 和 `MaterialProcessLanguageTest`。一次性的基线快照、独立 JVM 生命周期矩阵和测试附属注入已移除;长期行为应落入可直接重复运行、不会向运行时注册测试内容的定向测试。 diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java index e9fa01ebd..df1ccfab5 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java @@ -327,7 +327,12 @@ public List tooltip(double mouseX, double mouseY) { return List.copyOf(lines); } + public boolean valid() { + return page.navigation().valid(); + } + public boolean click(double mouseX, double mouseY, int button) { + if (!valid()) return false; if (clickControls(mouseX, mouseY, button)) return true; if (button != 0 && button != 1) return false; Node node = hit(mouseX, mouseY); diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java b/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java index 4f7ff2cf4..db1110b3a 100644 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java +++ b/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java @@ -56,6 +56,10 @@ public Rect2i stackArea(double x, double y) { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + if (!panel.valid()) { + onClose(); + return; + } graphics.fill(0, 0, width, height, 0xff303030); graphics.pose().pushPose(); try { @@ -74,6 +78,10 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { @Override public boolean mouseClicked(double x, double y, int button) { + if (!panel.valid()) { + onClose(); + return true; + } if (panel.clickControls(x - MARGIN, y - MARGIN, button)) return true; if (panel.press(x - MARGIN, y - MARGIN, button)) { dragButton = button; diff --git a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java index 6bbd87ade..bab6c952d 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java +++ b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java @@ -10,12 +10,9 @@ import java.util.Optional; import java.util.OptionalInt; import java.util.Set; -import java.util.stream.Stream; import mezz.jei.api.gui.IRecipeLayoutDrawable; import mezz.jei.api.gui.ingredient.IRecipeSlotView; -import mezz.jei.api.ingredients.IIngredientType; import mezz.jei.api.ingredients.ITypedIngredient; -import mezz.jei.api.recipe.IFocus; import mezz.jei.api.recipe.IFocusGroup; import mezz.jei.api.recipe.IRecipeManager; import mezz.jei.api.recipe.RecipeIngredientRole; @@ -34,33 +31,6 @@ /** Captures JEI's final visible recipe rows into the same material-page view model used by EMI. */ final class MaterialProcessJeiRecipes { - private static final IFocusGroup NO_FOCUS = new IFocusGroup() { - @Override - public boolean isEmpty() { - return true; - } - - @Override - public List> getAllFocuses() { - return List.of(); - } - - @Override - public Stream> getFocuses(RecipeIngredientRole role) { - return Stream.empty(); - } - - @Override - public Stream> getFocuses(IIngredientType type) { - return Stream.empty(); - } - - @Override - public Stream> getFocuses(IIngredientType type, RecipeIngredientRole role) { - return Stream.empty(); - } - }; - private MaterialProcessJeiRecipes() {} static MaterialProcessSnapshot capture( @@ -72,7 +42,8 @@ static MaterialProcessSnapshot capture( .toList(); var ids = new HashSet(); var counters = new Counters(); - for (var category : categories) captureCategory(manager, category, builder, ids, counters); + for (var category : categories) captureCategory(manager, category, builder, ids, counters, + runtime.getJeiHelpers().getFocusFactory().getEmptyFocusGroup()); gregtech.platform.Mc.logger() .info("[gregtech] JEI material process index: {} visible categories, {} recipes, {} rows, {} omitted", categories.size(), counters.recipes, counters.rows, counters.omitted); @@ -99,7 +70,8 @@ private static void captureCategory( IRecipeCategory category, MaterialProcessSnapshot.ViewerBuilder builder, Set ids, - Counters counters) { + Counters counters, + IFocusGroup focus) { var recipes = manager.createRecipeLookup(category.getRecipeType()).get().toList(); counters.recipes += recipes.size(); for (int index = 0; index < recipes.size(); index++) { @@ -112,7 +84,7 @@ private static void captureCategory( counters.rows++; continue; } - captureRecipe(manager, category, recipe, index, builder, counters); + captureRecipe(manager, category, recipe, index, builder, counters, focus); } } @@ -122,9 +94,10 @@ private static void captureRecipe( T recipe, int index, MaterialProcessSnapshot.ViewerBuilder builder, - Counters counters) { + Counters counters, + IFocusGroup focus) { Optional> drawable = - manager.createRecipeLayoutDrawable(category, recipe, NO_FOCUS); + manager.createRecipeLayoutDrawable(category, recipe, focus); if (drawable.isEmpty()) { builder.omitted(); counters.omitted++; diff --git a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java index 4eef2f9af..5b634ca13 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java @@ -112,6 +112,7 @@ public static Result apply(RecipeManager manager) { // previous world's rows. Restore every map and drop the tag-owned producers instead of // publishing a partial generation. LOGGER.error("[gregtech] Machine recipe overlay generation {} failed; restoring the baseline", current, failure); + MaterialProcessSnapshot.Store.clear(MaterialProcessSnapshot.Store.current()); recover(checkpoint); lastResult = new Result(0, 0, 0, 0, baselineRows(), false, true); return lastResult; diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java index 35c12c0d3..6500f6f08 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java @@ -8,7 +8,6 @@ import gregtech.api.addon.material.MaterialProcessKey; import gregtech.api.addon.material.SpecialProcessMethod; import gregtech.api.addon.material.SpecialProcessValue; -import gregtech.api.material.GTValues; import gregtech.content.data.FluidCatalog; import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.content.registry.GTFluids; @@ -73,9 +72,12 @@ public static void rebuild() { .filter(candidate -> candidate.mNameInternal.equals(method.recipeMap())) .findFirst() .orElse(null); - if (map == null) - throw new IllegalArgumentException( - "Special process " + method.process().id() + " names unknown recipe map " + method.recipeMap()); + if (map == null) { + com.mojang.logging.LogUtils.getLogger().warn( + "[gregtech] Skipping special process {} with unknown recipe map {}", + method.process().id(), method.recipeMap()); + continue; + } if (methodRules.reagents().isEmpty()) continue; for (var target : methodRules.targets()) { for (var inputEntry : target.inputCounts().entrySet().stream() @@ -119,10 +121,11 @@ private static void annotateExistingRows(List methods) { var candidates = byMap.getOrDefault(map.mNameInternal, List.of()); if (candidates.isEmpty()) continue; for (var recipe : map.mRecipeList) { + if (recipe.specialProcess() != null) continue; var matches = candidates.stream().filter(rules -> matches(recipe, rules)).toList(); if (matches.size() > 1) - throw new IllegalArgumentException("Recipe belongs to multiple special process methods in " - + map.mNameInternal); + com.mojang.logging.LogUtils.getLogger().warn( + "[gregtech] Skipping ambiguous special-process annotation in {}", map.mNameInternal); if (matches.size() == 1) recipe.withSpecialProcess(matches.get(0).method().process().id()); } @@ -130,31 +133,23 @@ private static void annotateExistingRows(List methods) { } private static boolean matches(Recipe recipe, MethodRules rules) { - boolean target = false; - boolean reagent = false; - for (var selector : rules.targets()) { - for (var input : selector.inputCounts().entrySet()) { - if (containsItem(recipe, selector.material(), input.getKey(), input.getValue())) { - target = true; - break; - } - } + for (var target : rules.targets()) { + boolean hasTarget = target.inputCounts().entrySet().stream() + .anyMatch(input -> containsItem(recipe, target.material(), input.getKey(), input.getValue())); + if (!hasTarget) continue; + for (var reagent : rules.reagents()) + for (var form : reagent.forms()) + if (containsInput(recipe, reagent.material(), form, target.plan().reagentAmount())) return true; } - for (var selector : rules.reagents()) { - for (var form : selector.forms()) - if (containsInput(recipe, selector.material(), form)) { - reagent = true; - break; - } - } - return target && reagent; + return false; } - private static boolean containsInput(Recipe recipe, MaterialKey material, FormKey form) { + private static boolean containsInput(Recipe recipe, MaterialKey material, FormKey form, long amount) { return isFluid(form) ? java.util.Arrays.stream(recipe.mFluidInputs) - .anyMatch(stack -> sameFluidMaterial(stack, material, form)) - : java.util.Arrays.stream(recipe.mInputs).anyMatch(stack -> sameItemForm(stack, material, form)); + .anyMatch(stack -> sameFluidMaterial(stack, material, form) && stack.getAmount() == amount) + : java.util.Arrays.stream(recipe.mInputs) + .anyMatch(stack -> sameItemForm(stack, material, form) && stack.getCount() == amount); } private static boolean containsItem(Recipe recipe, MaterialKey material, FormKey form, int count) { @@ -202,14 +197,15 @@ private static BuildResult build( var chances = new ArrayList(); for (var output : plan.itemOutputs()) { ItemStack stack = firstItem(output, resolver); - if (stack.isEmpty()) continue; + if (stack.isEmpty()) return new BuildResult(null); itemOutputs.add(stack); chances.add((long) output.chance()); } var fluidOutputs = new ArrayList(); for (var output : plan.fluidOutputs()) { FluidStack stack = firstFluid(output, resolver); - if (!stack.isEmpty()) fluidOutputs.add(stack); + if (stack.isEmpty()) return new BuildResult(null); + fluidOutputs.add(stack); } if (itemOutputs.isEmpty() && fluidOutputs.isEmpty()) return new BuildResult(null); return new BuildResult(new Recipe( @@ -338,9 +334,7 @@ private FluidStack resolveFluid(MaterialKey materialKey, FormKey form, long amou var material = GTMaterialRegistry.get(materialKey.name()).resolve(); if (material == null || !material.isValid()) return FluidStack.EMPTY; var binding = MaterialFluidUnitFacts.binding(material, form.name()); - if (binding == null - || binding.referenceSourceUnits() != GTValues.U - || binding.referenceMillibuckets() != 1000) return FluidStack.EMPTY; + if (binding == null) return FluidStack.EMPTY; var entry = FluidCatalog.get(binding.fluidField()); if (entry == null || entry.gas() != form.name().equals("gas")) return FluidStack.EMPTY; FluidStack stack = GTFluids.stack(binding.fluidField(), (int) amount); diff --git a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java index a0ca0a63c..0f552a12b 100644 --- a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java +++ b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java @@ -228,10 +228,13 @@ private static void appendStoneLayers(List facts) { 1, Math.max(1, definition.chanceDiv()), oreDetails)); - } else { + } + if (explicit == Items.AIR || explicit == oreItem(material)) { // Layer interiors use normal ore in the core and small ore at the edges; contacts // choose between both. Keep both real resources rather than collapsing to ore_. - for (Item item : List.of(oreItem(material), smallOreItem(material))) { + for (Item item : explicit == Items.AIR + ? List.of(oreItem(material), smallOreItem(material)) + : List.of(smallOreItem(material))) { if (item == Items.AIR) continue; ores.add(new Ore( material, diff --git a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java index 289953367..30c8a0173 100644 --- a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java +++ b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java @@ -28,6 +28,7 @@ public abstract class EmiMaterialProcessFocusMixin { // EMI opens lookups only from its recipe/tree screens or a container screen. if (recipes.values().stream().anyMatch(rows -> !rows.isEmpty()) && Minecraft.getInstance().screen instanceof MaterialProcessScreen screen) screen.onClose(); + if (ingredient.isEmpty()) return; for (var recipe : recipes.getOrDefault(MaterialProcessEmiRecipe.category(), List.of())) if (recipe instanceof MaterialProcessEmiRecipe process) process.focus(ingredient); } From 4ab8f64302b3868df40dcc9fe9c7a344e9096d8b Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Tue, 17 Nov 2026 01:25:27 +0800 Subject: [PATCH 15/17] remove MaterialProcessGraph --- .../engine/material/MaterialProcessGraph.java | 673 ---------- .../resources/assets/gt6ce/lang/en_us.json | 59 - .../resources/assets/gt6ce/lang/zh_cn.json | 59 - .../material/MaterialProcessGraphTest.java | 485 -------- ...t.java => SpecialProcessLanguageTest.java} | 7 +- docs/architecture/packages/content.md | 2 +- docs/architecture/packages/engine.md | 2 +- docs/architecture/packages/runtime.md | 6 - docs/decisions/material-system/README.md | 2 +- .../data-api-and-publication.md | 11 +- .../development/validation/checks/gametest.md | 2 +- docs/development/validation/checks/junit.md | 2 +- .../validation/checks/manual-ingame.md | 19 - docs/development/validation/routes.yaml | 5 - .../gregtech/client/MachineRecipeClient.java | 12 +- .../client/MaterialProcessArrows.java | 24 - .../client/MaterialProcessOverview.java | 1095 ----------------- .../gregtech/client/MaterialProcessPanel.java | 522 -------- .../client/MaterialProcessScreen.java | 123 -- .../compat/common/MaterialProcessDisplay.java | 572 --------- .../common/MaterialProcessProjection.java | 412 ------- .../compat/common/RecipeViewerIcons.java | 18 +- .../compat/common/WorldgenInfoData.java | 2 +- .../compat/emi/GregTechEMIPlugin.java | 120 -- .../gregtech/compat/emi/MachineEmiRecipe.java | 2 - .../compat/emi/MaterialProcessEmiRecipe.java | 242 ---- .../compat/emi/MaterialProcessEmiRecipes.java | 263 ---- .../compat/emi/MaterialProcessEmiStacks.java | 21 - .../compat/jei/GregTechJEIPlugin.java | 116 -- .../compat/jei/MaterialProcessCategory.java | 150 --- .../compat/jei/MaterialProcessJeiRecipes.java | 200 --- .../compat/jei/RecipeMapCategory.java | 1 - .../content/recipe/MachineRecipeOverlay.java | 2 - .../recipe/MaterialProcessSnapshot.java | 1054 ---------------- .../content/recipe/RecipePublication.java | 10 +- .../recipe/SharedSpecialProcessRows.java | 73 -- .../worldgen/MaterialWorldgenFacts.java | 346 ------ .../java/gregtech/engine/recipe/Recipe.java | 11 - .../mixin/EmiMaterialProcessFocusMixin.java | 35 - .../mixin/EmiMaterialProcessRecipesMixin.java | 26 - .../src/main/resources/gregtech.mixins.json | 2 - .../resources/gregtech-neoforge.mixins.json | 2 - 42 files changed, 16 insertions(+), 6774 deletions(-) delete mode 100644 core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java delete mode 100644 core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java rename core/src/test/java/gregtech/engine/material/{MaterialProcessLanguageTest.java => SpecialProcessLanguageTest.java} (79%) delete mode 100644 minecraft/src/main/java/gregtech/client/MaterialProcessArrows.java delete mode 100644 minecraft/src/main/java/gregtech/client/MaterialProcessOverview.java delete mode 100644 minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java delete mode 100644 minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java delete mode 100644 minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java delete mode 100644 minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java delete mode 100644 minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java delete mode 100644 minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java delete mode 100644 minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiStacks.java delete mode 100644 minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java delete mode 100644 minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java delete mode 100644 minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java delete mode 100644 minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java delete mode 100644 minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java delete mode 100644 minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessRecipesMixin.java diff --git a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java b/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java deleted file mode 100644 index 0b05df187..000000000 --- a/core/src/main/java/gregtech/engine/material/MaterialProcessGraph.java +++ /dev/null @@ -1,673 +0,0 @@ -package gregtech.engine.material; - -import gregtech.api.addon.material.DataKey; -import java.util.*; - -/** - * Immutable semantic process graph for one published material generation. - * - *

The graph owns no native recipe or world-generation objects. Queries traverse only their - * published ports and return immutable rows for a viewer adapter to project, with optional query budgets.

- */ -public final class MaterialProcessGraph { - private static final System.Logger LOGGER = System.getLogger("gt6ce.material.process"); - - /** One transaction boundary with the form, tag and active worldgen revisions used by the rows. */ - public record Snapshot( - MaterialPublication.Stamp publication, - long sessionGeneration, - long formRevision, - long tagGeneration, - long worldgenRevision) { - public Snapshot { - Objects.requireNonNull(publication); - if (sessionGeneration <= 0 || formRevision < 0 || tagGeneration < 0 || worldgenRevision < 0) - throw new IllegalArgumentException("Invalid process graph snapshot"); - } - } - - public enum Direction { - SOURCES, - USES, - BOTH - } - - public enum Role { - CONSUMED, - CATALYST, - PRESENCE, - PRIMARY, - BYPRODUCT, - UNKNOWN - } - - public enum AmountUnit { - ITEM, - MATERIAL_UNIT, - MILLIBUCKET, - UNKNOWN - } - - /** Resource identity keeps material, form, phase and native selector/state separate. */ - public record Resource(DataKey key, String material, String form, String phase, String state) { - public Resource { - Objects.requireNonNull(key); - requireText(material, "material"); - requireText(form, "form"); - requireText(phase, "phase"); - requireText(state, "state"); - } - } - - public record Amount(long value, AmountUnit unit) { - public Amount { - if (value < 0) throw new IllegalArgumentException("Negative process amount"); - Objects.requireNonNull(unit); - } - - public static Amount unknown() { - return new Amount(0, AmountUnit.UNKNOWN); - } - } - - public record Port( - Resource resource, Role role, Amount amount, OptionalInt chance, boolean main, List details) { - public Port { - Objects.requireNonNull(resource); - Objects.requireNonNull(role); - Objects.requireNonNull(amount); - Objects.requireNonNull(chance); - if (chance.isPresent() && (chance.getAsInt() < 1 || chance.getAsInt() > 10_000)) - throw new IllegalArgumentException("Invalid process chance"); - details = List.copyOf(details); - } - - public boolean output() { - return role == Role.PRIMARY || role == Role.BYPRODUCT || role == Role.UNKNOWN; - } - } - - public record Step( - DataKey reference, - String name, - List inputs, - List outputs, - List details, - Optional specialProcess, - boolean resolved) { - public Step { - Objects.requireNonNull(reference); - requireText(name, "process step name"); - inputs = List.copyOf(inputs); - outputs = List.copyOf(outputs); - var validInputs = inputs.stream().filter(port -> !port.output()).toList(); - var validOutputs = outputs.stream().filter(Port::output).toList(); - if (validInputs.size() != inputs.size() || validOutputs.size() != outputs.size()) { - LOGGER.log( - System.Logger.Level.WARNING, - "Discarded ports on the wrong side of process step {0}", - reference); - resolved = false; - } - inputs = validInputs; - outputs = validOutputs; - details = List.copyOf(details); - Objects.requireNonNull(specialProcess); - } - - public Step( - DataKey reference, - String name, - List inputs, - List outputs, - List details, - boolean resolved) { - this(reference, name, inputs, outputs, details, Optional.empty(), resolved); - } - } - - public record Edge(DataKey source, DataKey target, DataKey resource, boolean confirmed) { - public Edge { - Objects.requireNonNull(source); - Objects.requireNonNull(target); - Objects.requireNonNull(resource); - } - } - - /** Exact resource incidence; each source/target pair is implicit instead of allocated as an edge. */ - public record Flow(DataKey resource, List sources, List targets) { - public Flow { - Objects.requireNonNull(resource); - sources = List.copyOf(sources); - targets = List.copyOf(targets); - } - - public long connectionCount() { - return (long) sources.size() * targets.size(); - } - } - - public record Budgets(int maxDepth, int maxSteps, int maxPortsPerSide, int maxEdges) { - public static final Budgets DEFAULT = new Budgets(8, 64, 64, 128); - /** Material pages keep every direct row only until a configured presentation limit is reached. */ - public static final Budgets MATERIAL_PAGE = new Budgets(0, 512, 128, 4096); - - public Budgets { - if (maxDepth < 0 || maxSteps <= 0 || maxPortsPerSide <= 0 || maxEdges < 0) - throw new IllegalArgumentException("Invalid process graph budget"); - } - } - - public record Notice(String code, int omitted) { - public Notice { - requireText(code, "process notice code"); - if (omitted < 0) throw new IllegalArgumentException("Negative process notice count"); - } - } - - public record Query( - Snapshot snapshot, - DataKey root, - Direction direction, - List steps, - List edges, - List notices, - boolean truncated) { - public Query { - Objects.requireNonNull(snapshot); - Objects.requireNonNull(root); - Objects.requireNonNull(direction); - steps = List.copyOf(steps); - edges = List.copyOf(edges); - notices = List.copyOf(notices); - } - } - - /** A complete material page whose storage follows port occurrences, not producer/consumer products. */ - public record MaterialQuery( - Snapshot snapshot, DataKey root, List steps, List flows, List notices) { - public MaterialQuery { - Objects.requireNonNull(snapshot); - Objects.requireNonNull(root); - steps = List.copyOf(steps); - flows = List.copyOf(flows); - notices = List.copyOf(notices); - } - } - - private record IndexedStep(int order, Step step, boolean genericRecovery) {} - - private record Node(DataKey reference, int depth) {} - - private final Snapshot snapshot; - private final Map steps; - private final Map resources; - private final Map> resourcesByMaterial; - private final Map> inputs; - private final Map> outputs; - private final List notices; - - private MaterialProcessGraph(Builder builder) { - snapshot = builder.snapshot; - steps = Map.copyOf(builder.steps); - resources = Map.copyOf(builder.resources); - var byMaterial = new HashMap>(); - resources - .values() - .forEach(resource -> byMaterial - .computeIfAbsent(resource.material(), ignored -> new ArrayList<>()) - .add(resource)); - var frozenByMaterial = new HashMap>(byMaterial.size()); - byMaterial.forEach((material, values) -> frozenByMaterial.put( - material, - values.stream() - .sorted(Comparator.comparing(resource -> resource.key().toString())) - .toList())); - resourcesByMaterial = Map.copyOf(frozenByMaterial); - inputs = freezeOccurrences(builder.inputs); - outputs = freezeOccurrences(builder.outputs); - notices = List.copyOf(builder.notices); - } - - public static Builder builder(Snapshot snapshot) { - return new Builder(snapshot); - } - - public Snapshot snapshot() { - return snapshot; - } - - public Optional step(DataKey reference) { - IndexedStep indexed = steps.get(reference); - return indexed == null ? Optional.empty() : Optional.of(indexed.step()); - } - - public List resources() { - return resources.values().stream() - .sorted(Comparator.comparing(resource -> resource.key().toString())) - .toList(); - } - - public List materialSteps(DataKey root) { - Resource resource = resources.get(Objects.requireNonNull(root)); - return resource == null - ? List.of() - : selectMaterial(resource).stream().map(IndexedStep::step).toList(); - } - - /** Keeps every direct row and association without enumerating a resource's source/target cross-product. */ - public MaterialQuery queryMaterial(DataKey root) { - Objects.requireNonNull(root); - Resource resource = resources.get(root); - if (resource == null) return new MaterialQuery(snapshot, root, List.of(), List.of(), notices); - var selected = selectMaterial(resource); - var references = new HashSet(); - selected.forEach(indexed -> references.add(indexed.step().reference())); - var flows = new ArrayList(); - for (Resource local : materialResources(resource)) { - var sources = outputs.getOrDefault(local.key(), List.of()).stream() - .map(indexed -> indexed.step().reference()) - .filter(references::contains) - .toList(); - var targets = inputs.getOrDefault(local.key(), List.of()).stream() - .map(indexed -> indexed.step().reference()) - .filter(references::contains) - .toList(); - if (!sources.isEmpty() && !targets.isEmpty()) flows.add(new Flow(local.key(), sources, targets)); - } - var resultNotices = new ArrayList<>(notices); - if (selected.isEmpty() - && resultNotices.stream().noneMatch(notice -> notice.code().equals("no_both"))) - resultNotices.add(new Notice("no_both", 0)); - return new MaterialQuery( - snapshot, root, selected.stream().map(IndexedStep::step).toList(), flows, resultNotices); - } - - private List materialResources(Resource root) { - return root.material().equals("unknown") - ? List.of(root) - : resourcesByMaterial.getOrDefault(root.material(), List.of()); - } - - private List selectMaterial(Resource root) { - var selected = new TreeSet( - Comparator.comparing(IndexedStep::genericRecovery).thenComparingInt(IndexedStep::order)); - for (Resource resource : materialResources(root)) { - selected.addAll(inputs.getOrDefault(resource.key(), List.of())); - selected.addAll(sources(resource.key())); - } - return List.copyOf(selected); - } - - /** - * Traverse from one resource occurrence. The adjacency index is already published; this method - * never enumerates unrelated steps or expands a selector into its member matrix. - */ - public Query query(DataKey root, Direction direction, Budgets budgets) { - Objects.requireNonNull(root); - Objects.requireNonNull(direction); - Objects.requireNonNull(budgets); - if (!resources.containsKey(root)) - return new Query(snapshot, root, direction, List.of(), List.of(), notices, false); - - var queue = new ArrayDeque(); - var queued = new HashSet(); - boolean startsSources = direction != Direction.USES; - boolean startsUses = direction != Direction.SOURCES; - int omittedSteps = enqueue(root, startsSources, startsUses, 0, budgets, queue, queued); - var visited = new LinkedHashMap(); - var edges = new LinkedHashMap(); - var truncations = new LinkedHashMap(); - int omittedPorts = 0; - int omittedEdges = 0; - int omittedDepth = 0; - boolean stopped = false; - - while (!queue.isEmpty() && !stopped) { - Node node = queue.removeFirst(); - if (visited.containsKey(node.reference)) continue; - if (visited.size() >= budgets.maxSteps()) { - addNotice(truncations, "node_limit", 1); - break; - } - visited.put(node.reference, node.depth); - IndexedStep indexed = steps.get(node.reference); - if (indexed == null) continue; - omittedPorts += Math.max(0, indexed.step.inputs().size() - budgets.maxPortsPerSide()); - omittedPorts += Math.max(0, indexed.step.outputs().size() - budgets.maxPortsPerSide()); - if (node.depth >= budgets.maxDepth()) { - if (direction != Direction.USES) - omittedDepth += indexed.step.inputs().stream() - .limit(budgets.maxPortsPerSide()) - .map(port -> sources(port.resource().key())) - .mapToInt(occurrences -> unseen(occurrences, visited, queued)) - .sum(); - if (direction != Direction.SOURCES) - omittedDepth += indexed.step.outputs().stream() - .limit(budgets.maxPortsPerSide()) - .map(port -> inputs.getOrDefault(port.resource().key(), List.of())) - .mapToInt(occurrences -> unseen(occurrences, visited, queued)) - .sum(); - continue; - } - - boolean expandInputs = direction != Direction.USES; - boolean expandOutputs = direction != Direction.SOURCES; - if (expandInputs) { - int available = Math.min(indexed.step.inputs().size(), budgets.maxPortsPerSide()); - for (int index = 0; index < available && !stopped; index++) { - Port port = indexed.step.inputs().get(index); - for (IndexedStep source : sources(port.resource().key())) { - Edge edge = new Edge( - source.step.reference(), - node.reference, - port.resource().key(), - confirmed(source, indexed)); - if (edges.putIfAbsent(edge, Boolean.TRUE) == null && edges.size() > budgets.maxEdges()) { - edges.remove(edge); - omittedEdges++; - stopped = true; - break; - } - if (stopped) break; - if (!visited.containsKey(source.step.reference()) - && !queued.contains(source.step.reference())) { - if (queued.size() >= budgets.maxSteps()) { - omittedSteps++; - continue; - } - queue.addLast(new Node(source.step.reference(), node.depth + 1)); - queued.add(source.step.reference()); - } - } - } - } - if (expandOutputs && !stopped) { - int available = Math.min(indexed.step.outputs().size(), budgets.maxPortsPerSide()); - for (int index = 0; index < available && !stopped; index++) { - Port port = indexed.step.outputs().get(index); - for (IndexedStep target : - inputs.getOrDefault(port.resource().key(), List.of())) { - Edge edge = new Edge( - node.reference, - target.step.reference(), - port.resource().key(), - confirmed(indexed, target)); - if (edges.putIfAbsent(edge, Boolean.TRUE) == null && edges.size() > budgets.maxEdges()) { - edges.remove(edge); - omittedEdges++; - stopped = true; - break; - } - if (stopped) break; - if (!visited.containsKey(target.step.reference()) - && !queued.contains(target.step.reference())) { - if (queued.size() >= budgets.maxSteps()) { - omittedSteps++; - continue; - } - queue.addLast(new Node(target.step.reference(), node.depth + 1)); - queued.add(target.step.reference()); - } - } - } - } - } - - addNotice(truncations, "node_limit", omittedSteps); - addNotice(truncations, "port_limit", omittedPorts); - addNotice(truncations, "edge_limit", omittedEdges); - addNotice(truncations, "depth_limit", omittedDepth); - var resultSteps = visited.entrySet().stream() - .sorted(Map.Entry.comparingByValue()) - .map(entry -> boundedStep(steps.get(entry.getKey()).step, budgets.maxPortsPerSide())) - .toList(); - var retained = new HashMap(); - resultSteps.forEach(step -> retained.put(step.reference(), step)); - var resultEdges = edges.keySet().stream() - .filter(edge -> visited.containsKey(edge.source()) && visited.containsKey(edge.target())) - .filter(edge -> retained.get(edge.source()).outputs().stream() - .anyMatch(port -> port.resource().key().equals(edge.resource()))) - .filter(edge -> retained.get(edge.target()).inputs().stream() - .anyMatch(port -> port.resource().key().equals(edge.resource()))) - .toList(); - var resultNotices = new ArrayList<>(notices); - truncations.forEach((code, omitted) -> resultNotices.add(new Notice(code, omitted))); - if (resultSteps.isEmpty() - && resultNotices.stream() - .noneMatch(notice -> - notice.code().equals("no_" + direction.name().toLowerCase()))) - resultNotices.add(new Notice("no_" + direction.name().toLowerCase(), 0)); - return new Query( - snapshot, - root, - direction, - resultSteps, - resultEdges, - List.copyOf(resultNotices), - !truncations.isEmpty()); - } - - /** - * Return every step directly adjacent to any form of the root's material. Unlike {@link #query}, this - * does not recurse through another material, so a common reagent cannot pull unrelated downstream chains - * into the page. Internal form conversions, immediate sources and immediate uses share this one result. - */ - public Query queryMaterial(DataKey root, Budgets budgets) { - Objects.requireNonNull(root); - Objects.requireNonNull(budgets); - Resource rootResource = resources.get(root); - if (rootResource == null) - return new Query(snapshot, root, Direction.BOTH, List.of(), List.of(), notices, false); - - var selected = selectMaterial(rootResource); - var retained = new ArrayList(Math.min(selected.size(), budgets.maxSteps())); - int omittedSteps = 0; - for (IndexedStep indexed : selected) { - if (retained.size() >= budgets.maxSteps()) { - omittedSteps++; - continue; - } - retained.add(indexed); - } - - int omittedPorts = 0; - for (IndexedStep indexed : retained) { - omittedPorts += Math.max(0, indexed.step.inputs().size() - budgets.maxPortsPerSide()); - omittedPorts += Math.max(0, indexed.step.outputs().size() - budgets.maxPortsPerSide()); - } - var resultSteps = retained.stream() - .map(indexed -> boundedStep(indexed.step, budgets.maxPortsPerSide())) - .toList(); - var retainedByReference = new HashMap(); - resultSteps.forEach(step -> retainedByReference.put(step.reference(), step)); - var retainedInputs = new HashMap>(); - resultSteps.forEach(step -> { - var keys = new HashSet(); - step.inputs().forEach(port -> keys.add(port.resource().key())); - retainedInputs.put(step.reference(), keys); - }); - - var resultEdges = new LinkedHashSet(); - int omittedEdges = 0; - for (IndexedStep source : retained) { - for (Port port : retainedByReference.get(source.step.reference()).outputs()) { - if (!port.resource().material().equals(rootResource.material())) continue; - for (IndexedStep target : inputs.getOrDefault(port.resource().key(), List.of())) { - if (!retainedInputs - .getOrDefault(target.step.reference(), Set.of()) - .contains(port.resource().key())) continue; - Edge edge = new Edge( - source.step.reference(), - target.step.reference(), - port.resource().key(), - confirmed(source, target)); - if (resultEdges.contains(edge)) continue; - if (resultEdges.size() >= budgets.maxEdges()) { - omittedEdges++; - continue; - } - resultEdges.add(edge); - } - } - } - - var truncations = new LinkedHashMap(); - addNotice(truncations, "node_limit", omittedSteps); - addNotice(truncations, "port_limit", omittedPorts); - addNotice(truncations, "edge_limit", omittedEdges); - var resultNotices = new ArrayList<>(notices); - truncations.forEach((code, omitted) -> resultNotices.add(new Notice(code, omitted))); - if (resultSteps.isEmpty() - && resultNotices.stream().noneMatch(notice -> notice.code().equals("no_both"))) - resultNotices.add(new Notice("no_both", 0)); - return new Query( - snapshot, - root, - Direction.BOTH, - resultSteps, - List.copyOf(resultEdges), - List.copyOf(resultNotices), - !truncations.isEmpty()); - } - - private int enqueue( - DataKey root, - boolean sources, - boolean uses, - int depth, - Budgets budgets, - ArrayDeque queue, - Set queued) { - int omitted = 0; - for (List starts : List.of( - sources ? sources(root) : List.of(), - uses ? inputs.getOrDefault(root, List.of()) : List.of())) { - for (int index = 0; index < starts.size(); index++) { - if (queued.size() >= budgets.maxSteps()) { - omitted += starts.size() - index; - break; - } - IndexedStep start = starts.get(index); - if (queued.add(start.step.reference())) queue.addLast(new Node(start.step.reference(), depth)); - } - } - return omitted; - } - - private Step boundedStep(Step step, int maxPorts) { - if (step.inputs().size() <= maxPorts && step.outputs().size() <= maxPorts) return step; - return new Step( - step.reference(), - step.name(), - boundedPorts(step.inputs(), maxPorts), - boundedPorts(step.outputs(), maxPorts), - step.details(), - step.specialProcess(), - step.resolved()); - } - - private List sources(DataKey resource) { - return outputs.getOrDefault(resource, List.of()).stream() - .filter(indexed -> !indexed.genericRecovery()) - .toList(); - } - - private static List boundedPorts(List ports, int maxPorts) { - return ports.size() <= maxPorts ? ports : List.copyOf(ports.subList(0, maxPorts)); - } - - private static boolean confirmed(IndexedStep source, IndexedStep target) { - return source.step.resolved() && target.step.resolved(); - } - - private static int unseen(List occurrences, Map visited, Set queued) { - int count = 0; - for (IndexedStep occurrence : occurrences) - if (!visited.containsKey(occurrence.step.reference()) && !queued.contains(occurrence.step.reference())) - count++; - return count; - } - - private static void addNotice(Map notices, String code, int count) { - if (count > 0) notices.merge(code, count, Math::addExact); - } - - private static Map> freezeOccurrences(Map> source) { - var frozen = new HashMap>(source.size()); - source.forEach((key, values) -> frozen.put(key, List.copyOf(values))); - return Map.copyOf(frozen); - } - - private static void requireText(String value, String name) { - if (value == null || value.isBlank()) throw new IllegalArgumentException("Missing " + name); - } - - public static final class Builder { - private final Snapshot snapshot; - private final Map steps = new LinkedHashMap<>(); - private final Map resources = new LinkedHashMap<>(); - private final Map> inputs = new HashMap<>(); - private final Map> outputs = new HashMap<>(); - private final List notices = new ArrayList<>(); - - private Builder(Snapshot snapshot) { - this.snapshot = Objects.requireNonNull(snapshot); - } - - public Builder notice(String code, int omitted) { - notices.add(new Notice(code, omitted)); - return this; - } - - public Builder add(Step step) { - return add(step, false); - } - - /** Generic recovery remains a use of its input, without advertising every reclaimable item as a source. */ - public Builder add(Step step, boolean genericRecovery) { - Objects.requireNonNull(step); - if (steps.containsKey(step.reference())) { - LOGGER.log(System.Logger.Level.WARNING, "Discarded duplicate process step {0}", step.reference()); - return notice("invalid_process_data", 1); - } - // Validate the whole row before changing any index; a rejected row must leave no partial resources. - var additions = new HashMap(); - for (List ports : List.of(step.inputs(), step.outputs())) - for (Port port : ports) { - Resource resource = port.resource(); - Resource previous = additions.putIfAbsent(resource.key(), resource); - if (previous == null) previous = resources.get(resource.key()); - if (previous != null && !previous.equals(resource)) { - LOGGER.log( - System.Logger.Level.WARNING, - "Discarded process step {0}: conflicting resource identity {1}", - step.reference(), - resource.key()); - return notice("invalid_process_data", 1); - } - } - int order = steps.size(); - IndexedStep indexed = new IndexedStep(order, step, genericRecovery); - steps.put(step.reference(), indexed); - resources.putAll(additions); - var inputResources = new HashSet(); - for (Port port : step.inputs()) { - if (inputResources.add(port.resource().key())) - inputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) - .add(indexed); - } - var outputResources = new HashSet(); - for (Port port : step.outputs()) { - if (outputResources.add(port.resource().key())) - outputs.computeIfAbsent(port.resource().key(), ignored -> new ArrayList<>()) - .add(indexed); - } - return this; - } - - public MaterialProcessGraph build() { - return new MaterialProcessGraph(this); - } - } -} diff --git a/core/src/main/resources/assets/gt6ce/lang/en_us.json b/core/src/main/resources/assets/gt6ce/lang/en_us.json index 3515514e5..f7264e624 100644 --- a/core/src/main/resources/assets/gt6ce/lang/en_us.json +++ b/core/src/main/resources/assets/gt6ce/lang/en_us.json @@ -1,67 +1,8 @@ { - "gt6ce.jei.material_process.title": "Material Processing", - "gt6ce.jei.material_process.section.sources": "Sources", - "gt6ce.jei.material_process.section.internal": "Internal Conversion", - "gt6ce.jei.material_process.section.recovery": "Recovery", - "gt6ce.jei.material_process.section.uses": "Uses", - "gt6ce.jei.material_process.cluster": "%s ×%s", - "gt6ce.jei.material_process.group_count": "This group contains %s steps.", - "gt6ce.jei.material_process.group_expand": "Left-click to expand.", - "gt6ce.jei.material_process.group_collapse": "Left-click to collapse.", "gt6ce.special_process.sulfuric_acid_leaching": "Sulfuric Acid Leaching", "gt6ce.special_process.aqua_regia_leaching": "Aqua Regia Leaching", "gt6ce.special_process.hydrofluoric_acid_leaching": "Hydrofluoric Acid Leaching", "gt6ce.special_process.hydrochloric_acid_manganese_leaching": "Hydrochloric Acid Manganese Leaching", - "gt6ce.jei.material_process.pan": "Hover to highlight equal items | Drag empty space to pan | Scroll to zoom around the cursor", - "gt6ce.jei.material_process.reset": "Reset", - "gt6ce.jei.material_process.zoom_hint": "Scroll to zoom around the cursor, or click −/+.", - "gt6ce.jei.material_process.resource_hint": "Left-click: recipes | Right-click: uses; hover a machine for amounts and additional items.", - "gt6ce.jei.material_process.variants": "This route contains %s recipes", - "gt6ce.jei.material_process.copy": "Local display copy of this resource (↗); hovering also highlights its other copies.", - "gt6ce.jei.material_process.return": "Return loop (↩); this does not imply an additional source.", - "gt6ce.jei.material_process.fullscreen": "Browse Material Processing in fullscreen", - "gt6ce.jei.material_process.exit_fullscreen": "Return to the recipe viewer", - "gt6ce.jei.material_process.reset_hint": "Restore 100% scale and center the queried item or fluid.", - "gt6ce.jei.material_process.empty": "This query has no processing steps.", - "gt6ce.jei.material_process.unbound": "Processing data is not available yet.", - "gt6ce.jei.material_process.controls": "Left-click process: original recipe | Left/right-click resource: sources/uses", - "gt6ce.jei.material_process.open_recipe": "Click a process to open its original recipe when supported.", - "gt6ce.jei.material_process.unresolved": "Relationship or native constraint is unresolved", - "gt6ce.jei.material_process.confirmed": "Confirmed relationship", - "gt6ce.jei.material_process.chance_unknown": "Output chance: unknown", - "gt6ce.jei.material_process.more": "+%s ports (hover to view)", - "gt6ce.jei.material_process.links": "%s relationships", - "gt6ce.jei.material_process.connection": "%s → %s | %s | %s", - "gt6ce.jei.material_process.role.consumed": "Shared input (consumed)", - "gt6ce.jei.material_process.role.catalyst": "Catalyst (not consumed)", - "gt6ce.jei.material_process.role.presence": "Presence condition (not consumed)", - "gt6ce.jei.material_process.role.primary": "Primary output", - "gt6ce.jei.material_process.role.byproduct": "Byproduct", - "gt6ce.jei.material_process.role.unknown": "Output role: unknown", - "gt6ce.jei.material_process.material_title": "%s Processing", - "gt6ce.jei.material_process.port_name": "%s / %s", - "gt6ce.jei.material_process.amount.items": "Amount: %s items", - "gt6ce.jei.material_process.amount.units": "Amount: %s U", - "gt6ce.jei.material_process.amount.mb": "Amount: %s mB", - "gt6ce.jei.material_process.amount.unknown": "Amount: unknown", - "gt6ce.jei.material_process.partial_unknown": "Coverage: partial; unsupported families are not shown.", - "gt6ce.jei.material_process.coverage.final_recipes": "Recipes: final published GT machine rows provide the authoritative native values.", - "gt6ce.jei.material_process.information": "Related Information", - "gt6ce.jei.material_process.open_information": "Click to open the original page", - "gt6ce.jei.material_process.information_hint": "Reference only; this entry is not a processing route.", - "gt6ce.jei.material_process.coverage.viewer_recipes": "Recipes: final visible JEI/EMI crafting, machine, and third-party rows are included.", - "gt6ce.jei.material_process.coverage.viewer_exclusions": "%s viewer entries were not imported as routes; related entries remain in Related Information, and cross-material selectors are not assigned to one material.", - "gt6ce.jei.material_process.coverage.active_worldgen": "World generation: only currently enabled configuration is included.", - "gt6ce.jei.material_process.coverage.dynamic_selectors": "Tags and material-unit selectors remain symbolic and are not expanded into every candidate.", - "gt6ce.jei.material_process.coverage.unknown_roles": "Roles remain unknown when the source does not distinguish primary and secondary outputs.", - "gt6ce.jei.material_process.coverage.node_limit": "The node budget omitted %s remaining steps.", - "gt6ce.jei.material_process.coverage.depth_limit": "The depth budget omitted %s remaining steps.", - "gt6ce.jei.material_process.coverage.port_limit": "The port budget omitted %s ports.", - "gt6ce.jei.material_process.coverage.edge_limit": "The relationship budget omitted %s relationships.", - "gt6ce.jei.material_process.coverage.invalid_data": "Discarded %s invalid processing entries; see the log for details.", - "gt6ce.jei.material_process.no_sources": "There are no published sources in this query.", - "gt6ce.jei.material_process.no_uses": "There are no published uses in this query.", - "gt6ce.jei.material_process.no_both": "There are no connected published sources or uses in this query.", "fluid_type.gt6ce.watergeothermal": "Hot Spring Water", "fluid.gt6ce.watergeothermal": "Hot Spring Water", "block.gt6ce.watergeothermal": "Geothermal Water", diff --git a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json index 3baea9c1b..404a035af 100644 --- a/core/src/main/resources/assets/gt6ce/lang/zh_cn.json +++ b/core/src/main/resources/assets/gt6ce/lang/zh_cn.json @@ -60,69 +60,10 @@ "gt.material.Sculk": "幽匿", "material.gt6ce.redstonealloy": "红石合金", "material.gt6ce.sculk": "幽匿", - "gt6ce.jei.material_process.title": "矿物处理", - "gt6ce.jei.material_process.section.sources": "来源", - "gt6ce.jei.material_process.section.internal": "内部转换", - "gt6ce.jei.material_process.section.recovery": "回收", - "gt6ce.jei.material_process.section.uses": "去向", - "gt6ce.jei.material_process.cluster": "%s ×%s", - "gt6ce.jei.material_process.group_count": "本组包含 %s 个步骤。", - "gt6ce.jei.material_process.group_expand": "左击展开。", - "gt6ce.jei.material_process.group_collapse": "左击折叠。", "gt6ce.special_process.sulfuric_acid_leaching": "硫酸浸出", "gt6ce.special_process.aqua_regia_leaching": "王水浸出", "gt6ce.special_process.hydrofluoric_acid_leaching": "氢氟酸浸出", "gt6ce.special_process.hydrochloric_acid_manganese_leaching": "盐酸锰矿浸出", - "gt6ce.jei.material_process.pan": "悬停高亮相同物品|拖拽空白区域平移|滚轮以鼠标为中心缩放", - "gt6ce.jei.material_process.reset": "复位", - "gt6ce.jei.material_process.zoom_hint": "滚轮以鼠标为中心缩放;也可点击 −/+。", - "gt6ce.jei.material_process.resource_hint": "左击:配方|右击:用途;数量与额外物品请悬停机器查看。", - "gt6ce.jei.material_process.variants": "此路线包含 %s 个配方", - "gt6ce.jei.material_process.copy": "此资源的局部展示副本(↗);悬停同步突出其他副本。", - "gt6ce.jei.material_process.return": "回流(↩);不表示新增来源。", - "gt6ce.jei.material_process.fullscreen": "全屏浏览材料总览", - "gt6ce.jei.material_process.exit_fullscreen": "返回配方查看器", - "gt6ce.jei.material_process.reset_hint": "恢复 100% 缩放并居中显示查询的物品或流体。", - "gt6ce.jei.material_process.empty": "此查询结果中没有加工步骤。", - "gt6ce.jei.material_process.unbound": "尚未接入加工数据。", - "gt6ce.jei.material_process.controls": "左击工艺:原配方|左/右击资源:来源/用途", - "gt6ce.jei.material_process.open_recipe": "点击工艺可在支持时打开原始配方。", - "gt6ce.jei.material_process.unresolved": "关系或原生约束尚未解析", - "gt6ce.jei.material_process.confirmed": "已确认的关系", - "gt6ce.jei.material_process.chance_unknown": "产出概率:未知", - "gt6ce.jei.material_process.more": "+%s 个端口(悬停查看)", - "gt6ce.jei.material_process.links": "%s 条关联", - "gt6ce.jei.material_process.connection": "%s → %s|%s|%s", - "gt6ce.jei.material_process.role.consumed": "共同输入(消耗)", - "gt6ce.jei.material_process.role.catalyst": "催化剂(不消耗)", - "gt6ce.jei.material_process.role.presence": "存在性条件(不消耗)", - "gt6ce.jei.material_process.role.primary": "主产物", - "gt6ce.jei.material_process.role.byproduct": "副产物", - "gt6ce.jei.material_process.role.unknown": "产物角色:未知", - "gt6ce.jei.material_process.material_title": "%s 加工", - "gt6ce.jei.material_process.port_name": "%s/%s", - "gt6ce.jei.material_process.amount.items": "数量:%s 件", - "gt6ce.jei.material_process.amount.units": "数量:%s U", - "gt6ce.jei.material_process.amount.mb": "数量:%s mB", - "gt6ce.jei.material_process.amount.unknown": "数量:未知", - "gt6ce.jei.material_process.partial_unknown": "覆盖范围:部分;未支持的族未显示。", - "gt6ce.jei.material_process.coverage.final_recipes": "配方:最终发布的机器配方行。", - "gt6ce.jei.material_process.information": "相关信息", - "gt6ce.jei.material_process.open_information": "点击查看原始页面", - "gt6ce.jei.material_process.information_hint": "仅供参考,此条目不构成加工路线。", - "gt6ce.jei.material_process.coverage.viewer_recipes": "配方:最终可见的 JEI/EMI 工作台、机器与第三方加工配方。", - "gt6ce.jei.material_process.coverage.viewer_exclusions": "%s 条查看器条目未作为加工路线导入;其中相关条目保留在信息区,跨材料候选原料不归为单一材料。", - "gt6ce.jei.material_process.coverage.active_worldgen": "世界生成:仅包含当前启用的配置。", - "gt6ce.jei.material_process.coverage.dynamic_selectors": "tag 与材料单位选择器保持符号形式,不展开候选全集。", - "gt6ce.jei.material_process.coverage.unknown_roles": "来源未明确主/副角色时保持未知。", - "gt6ce.jei.material_process.coverage.node_limit": "达到节点预算,省略了 %s 个后续步骤。", - "gt6ce.jei.material_process.coverage.depth_limit": "达到深度预算,省略了 %s 个后续步骤。", - "gt6ce.jei.material_process.coverage.port_limit": "达到端口预算,省略了 %s 个端口。", - "gt6ce.jei.material_process.coverage.edge_limit": "达到关联预算,省略了 %s 条关联。", - "gt6ce.jei.material_process.coverage.invalid_data": "已剔除 %s 条无效加工数据,详情见日志。", - "gt6ce.jei.material_process.no_sources": "查询范围内没有已发布的来源。", - "gt6ce.jei.material_process.no_uses": "查询范围内没有已发布的用途。", - "gt6ce.jei.material_process.no_both": "查询范围内没有相连的已发布来源或用途。", "gt6ce.jei.category.mold_chisel": "模具凿刻", "gt6ce.jei.mold_chisel.note": "深灰色格子为凿除部分", "gt6ce.jei.mold_chisel.carved": "凿除这个格子", diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java b/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java deleted file mode 100644 index 53d93b4e2..000000000 --- a/core/src/test/java/gregtech/engine/material/MaterialProcessGraphTest.java +++ /dev/null @@ -1,485 +0,0 @@ -package gregtech.engine.material; - -import gregtech.api.addon.material.DataKey; -import gregtech.engine.material.MaterialProcessGraph.*; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.OptionalInt; - -import static org.junit.jupiter.api.Assertions.*; - -final class MaterialProcessGraphTest { - private static final Snapshot SNAPSHOT = new Snapshot(new MaterialPublication.Stamp(4, 1, 2, 3), 5, 6, 7, 8); - - @Test - void traversalKeepsCoInputsAndAllOutputsForACycle() { - DataKey ore = resource("ore"); - DataKey dust = resource("dust"); - DataKey ingot = resource("ingot"); - DataKey fluid = resource("fluid"); - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .notice("partial_dynamic", 0) - .add(step( - "wash", - List.of(port(ore, Role.CONSUMED, "ore"), port(fluid, Role.CATALYST, "fluid")), - List.of(port(dust, Role.UNKNOWN, "dust"), port(ingot, Role.UNKNOWN, "ingot")))) - .add(step( - "melt", - List.of(port(dust, Role.CONSUMED, "dust"), port(ingot, Role.CONSUMED, "ingot")), - List.of(port(ore, Role.UNKNOWN, "ore")))) - .build(); - - var result = graph.query(ore, Direction.BOTH, Budgets.DEFAULT); - - assertEquals(2, result.steps().size()); - assertEquals(3, result.edges().size()); - assertTrue(result.edges().stream().allMatch(MaterialProcessGraphTest::edgeIsConfirmed)); - assertFalse(result.truncated()); - assertTrue(result.notices().stream().anyMatch(notice -> notice.code().equals("partial_dynamic"))); - } - - @Test - void everyTraversalBudgetReportsItsOwnTruncation() { - var builder = MaterialProcessGraph.builder(SNAPSHOT); - DataKey previous = resource("r0"); - for (int index = 0; index < 8; index++) { - DataKey next = resource("r" + (index + 1)); - builder.add(step( - "s" + index, - List.of(port(previous, Role.CONSUMED, "dust")), - List.of(port(next, Role.UNKNOWN, "dust")))); - previous = next; - } - var graph = builder.build(); - - var depth = graph.query(resource("r0"), Direction.USES, new Budgets(1, 64, 64, 64)); - var nodes = graph.query(resource("r0"), Direction.USES, new Budgets(20, 3, 64, 64)); - var fan = MaterialProcessGraph.builder(SNAPSHOT) - .add(step( - "fan", - List.of(port(resource("source"), Role.CONSUMED, "source")), - List.of( - port(resource("one"), Role.UNKNOWN, "one"), - port(resource("two"), Role.UNKNOWN, "two")))) - .build(); - var ports = fan.query(resource("one"), Direction.BOTH, new Budgets(20, 64, 1, 64)); - var edges = graph.query(resource("r0"), Direction.USES, new Budgets(20, 64, 64, 0)); - - assertEquals(2, depth.steps().size()); - assertTrue(depth.truncated()); - assertTrue(depth.notices().stream().anyMatch(notice -> notice.code().equals("depth_limit"))); - assertTrue(nodes.truncated()); - assertTrue(nodes.notices().stream().anyMatch(notice -> notice.code().equals("node_limit"))); - assertEquals(1, ports.steps().get(0).outputs().size()); - assertTrue(ports.truncated()); - assertTrue(ports.notices().stream().anyMatch(notice -> notice.code().equals("port_limit"))); - assertTrue(edges.truncated()); - assertTrue(edges.notices().stream().anyMatch(notice -> notice.code().equals("edge_limit"))); - } - - @Test - void selectorExpansionStaysOutOfTheGraph() { - DataKey ore = new DataKey("gt6ce", "resource/ore"); - DataKey unit = new DataKey("gt6ce", "resource/unit"); - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(step( - "unit", - List.of(port(unit, Role.CONSUMED, "unit:gt6ce:iron_ingot")), - List.of(port(ore, Role.UNKNOWN, "concrete")))) - .build(); - - var result = graph.query(unit, Direction.USES, Budgets.DEFAULT); - - assertEquals(1, result.steps().size()); - assertTrue(result.steps().get(0).inputs().get(0).resource().state().startsWith("unit:")); - assertTrue(result.steps().get(0).inputs().get(0).amount().unit() == AmountUnit.MATERIAL_UNIT); - } - - @Test - void forwardAndReverseQueriesUseTheSamePortIndex() { - DataKey dust = resource("dust"); - DataKey ingot = resource("ingot"); - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(step( - "cast", - List.of(port(dust, Role.CONSUMED, "dust")), - List.of(port(ingot, Role.UNKNOWN, "ingot")))) - .add(step( - "melt", - List.of(port(ingot, Role.CONSUMED, "ingot")), - List.of(port(dust, Role.UNKNOWN, "dust")))) - .build(); - - var immediate = new Budgets(0, 64, 64, 128); - var sources = graph.query(dust, Direction.SOURCES, immediate); - var uses = graph.query(dust, Direction.USES, immediate); - - assertEquals(1, sources.steps().size()); - assertEquals("melt", sources.steps().get(0).name()); - assertEquals(1, uses.steps().size()); - assertEquals("cast", uses.steps().get(0).name()); - } - - @Test - void materialQueryKeepsEveryDirectFormAndStopsAtAnotherMaterial() { - DataKey ore = new DataKey("gt6ce", "resource/iron/ore"); - DataKey crushed = new DataKey("gt6ce", "resource/iron/crushed"); - DataKey dust = new DataKey("gt6ce", "resource/iron/dust"); - DataKey sourceMaterial = new DataKey("gt6ce", "resource/copper/ore"); - DataKey productMaterial = new DataKey("gt6ce", "resource/copper/ingot"); - DataKey farther = new DataKey("gt6ce", "resource/gold/ingot"); - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(step( - "source", - List.of(port(sourceMaterial, Role.CONSUMED, "copper ore", "Copper")), - List.of(port(ore, Role.UNKNOWN, "iron ore", "Iron")))) - .add(step( - "crush", - List.of(port(ore, Role.CONSUMED, "iron ore", "Iron")), - List.of(port(crushed, Role.UNKNOWN, "iron crushed", "Iron")))) - .add(step( - "grind", - List.of(port(crushed, Role.CONSUMED, "iron crushed", "Iron")), - List.of(port(dust, Role.UNKNOWN, "iron dust", "Iron")))) - .add(step( - "use", - List.of(port(dust, Role.CONSUMED, "iron dust", "Iron")), - List.of(port(productMaterial, Role.UNKNOWN, "copper ingot", "Copper")))) - .add(step( - "transitive", - List.of(port(productMaterial, Role.CONSUMED, "copper ingot", "Copper")), - List.of(port(farther, Role.UNKNOWN, "gold ingot", "Gold")))) - .build(); - - var result = graph.queryMaterial(ore, new Budgets(0, 64, 64, 128)); - - assertEquals( - List.of("source", "crush", "grind", "use"), - result.steps().stream().map(Step::name).toList()); - assertEquals(3, result.edges().size()); - assertFalse(result.truncated()); - } - - private static boolean edgeIsConfirmed(MaterialProcessGraph.Edge edge) { - return edge.confirmed(); - } - - @Test - void materialPageKeepsLargeRecipesAndDenseConnections() { - var builder = MaterialProcessGraph.builder(SNAPSHOT); - var common = resource("common"); - var outputs = new java.util.ArrayList(); - for (int index = 0; index < 160; index++) - outputs.add(port(resource("product_" + index), Role.UNKNOWN, "product_" + index)); - builder.add(step("large", List.of(port(common, Role.CONSUMED, "common")), outputs)); - for (int index = 0; index < 70; index++) { - builder.add(step("producer_" + index, List.of(), List.of(port(common, Role.UNKNOWN, "common")))); - builder.add(step("consumer_" + index, List.of(port(common, Role.CONSUMED, "common")), List.of())); - } - for (int index = 0; index < 600; index++) - builder.add(step( - "route_" + index, - List.of(), - List.of(port(resource("local_" + index), Role.UNKNOWN, "local_" + index)))); - var graph = builder.build(); - var query = graph.queryMaterial(common, Budgets.MATERIAL_PAGE); - assertEquals(512, query.steps().size()); - assertEquals(4096, query.edges().size()); - assertEquals(128, query.steps().get(0).outputs().size()); - assertTrue(query.truncated()); - assertEquals( - 874, - query.notices().stream() - .filter(notice -> notice.code().equals("edge_limit")) - .mapToInt(Notice::omitted) - .sum()); - assertEquals( - 229, - query.notices().stream() - .filter(notice -> notice.code().equals("node_limit")) - .mapToInt(Notice::omitted) - .sum()); - assertEquals( - 32, - query.notices().stream() - .filter(notice -> notice.code().equals("port_limit")) - .mapToInt(Notice::omitted) - .sum()); - } - - @Test - void compactMaterialQueryStoresDenseAndCyclicAssociationsAsPortIncidence() { - var builder = MaterialProcessGraph.builder(SNAPSHOT); - var common = resource("dense_common"); - var input = port(common, Role.CONSUMED, "common"); - var output = port(common, Role.UNKNOWN, "common"); - for (int index = 0; index < 10_000; index++) { - builder.add(step("dense_source_" + index, List.of(), List.of(output))); - builder.add(step("dense_use_" + index, List.of(input), List.of())); - } - builder.add(step("dense_loop", List.of(input), List.of(output))); - var graph = builder.build(); - var query = graph.queryMaterial(common); - assertEquals(20_001, query.steps().size()); - assertEquals(query.steps(), graph.materialSteps(common)); - assertEquals(1, query.flows().size()); - var flow = query.flows().get(0); - assertEquals(10_001, flow.sources().size()); - assertEquals(10_001, flow.targets().size()); - assertEquals(100_020_001L, flow.connectionCount()); - assertTrue(flow.sources().contains(new DataKey("gt6ce", "step/dense_loop"))); - assertTrue(flow.targets().contains(new DataKey("gt6ce", "step/dense_loop"))); - assertTrue(query.notices().isEmpty()); - } - - @Test - void compactFlowsPreserveExactResourcesAndConfirmationWithoutInventingSelectorLinks() { - var first = resource("selector_first"); - var second = resource("selector_second"); - var produced = port(first, Role.UNKNOWN, "same_display"); - var used = port(first, Role.CONSUMED, "same_display"); - var other = port(second, Role.CONSUMED, "same_display"); - var source = new Step( - new DataKey("gt6ce", "step/unconfirmed"), - "unconfirmed", - List.of(), - List.of(produced), - List.of(), - false); - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(source) - .add(step("local_loop", List.of(used), List.of(produced))) - .add(step("independent_selector", List.of(other), List.of())) - .build(); - var compact = graph.queryMaterial(first); - var expanded = graph.queryMaterial(first, new Budgets(0, 32, 32, 128)); - var restored = new java.util.HashSet(); - for (Flow flow : compact.flows()) - for (DataKey from : flow.sources()) - for (DataKey to : flow.targets()) - restored.add(new Edge( - from, - to, - flow.resource(), - graph.step(from).orElseThrow().resolved() - && graph.step(to).orElseThrow().resolved())); - assertEquals(expanded.steps(), compact.steps()); - assertEquals(new java.util.HashSet<>(expanded.edges()), restored); - assertEquals(1, compact.flows().size()); - assertEquals( - List.of(new DataKey("gt6ce", "step/local_loop")), - compact.flows().get(0).targets()); - assertTrue(restored.stream().anyMatch(edge -> !edge.confirmed())); - } - - @Test - void invalidRowsDoNotPoisonPublishedIndexesOrDiscardValidRows() { - var ore = resource("ore"); - var dust = resource("dust"); - var valid = step("valid", List.of(port(ore, Role.CONSUMED, "ore")), List.of(port(dust, Role.UNKNOWN, "dust"))); - var conflict = step( - "conflict", - List.of(port(resource("partial"), Role.CONSUMED, "partial")), - List.of(port(ore, Role.UNKNOWN, "another_state"))); - var intraRow = step( - "intra_row", - List.of(port(resource("intra"), Role.CONSUMED, "one")), - List.of(port(resource("intra"), Role.UNKNOWN, "two"))); - var next = step("next", List.of(port(dust, Role.CONSUMED, "dust")), List.of()); - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(valid) - .add(valid) - .add(conflict) - .add(intraRow) - .add(next) - .build(); - assertEquals( - List.of(valid, next), - graph.queryMaterial(ore, Budgets.MATERIAL_PAGE).steps()); - assertEquals( - List.of(ore, dust).stream() - .sorted(java.util.Comparator.comparing(DataKey::toString)) - .toList(), - graph.resources().stream().map(Resource::key).toList()); - assertTrue(graph.step(conflict.reference()).isEmpty()); - assertTrue(graph.step(intraRow.reference()).isEmpty()); - assertEquals( - 3, - graph.queryMaterial(ore, Budgets.MATERIAL_PAGE).notices().stream() - .filter(notice -> notice.code().equals("invalid_process_data")) - .mapToInt(Notice::omitted) - .sum()); - } - - @Test - void mainHintsMayRepeatAndWrongSidePortsAreRemovedWithoutConfirmingTheRow() { - var first = port(resource("first"), Role.CONSUMED, "first"); - var second = port(resource("second"), Role.CONSUMED, "second"); - first = new Port(first.resource(), first.role(), first.amount(), first.chance(), true, first.details()); - second = new Port(second.resource(), second.role(), second.amount(), second.chance(), true, second.details()); - var row = step("hints", List.of(first, second), List.of(first)); - assertEquals(2, row.inputs().size()); - assertTrue(row.outputs().isEmpty()); - assertFalse(row.resolved()); - } - - @Test - void portsTruncatedAtTheDepthBoundaryStillReportPartialCoverage() { - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(step( - "split", - List.of(port(resource("ore"), Role.CONSUMED, "ore")), - List.of( - port(resource("one"), Role.UNKNOWN, "dust"), - port(resource("two"), Role.UNKNOWN, "dust")))) - .build(); - for (Direction direction : Direction.values()) { - DataKey root = direction == Direction.USES ? resource("ore") : resource("one"); - var result = graph.query(root, direction, new Budgets(0, 8, 1, 8)); - assertTrue(result.truncated()); - assertTrue( - result.notices().stream().anyMatch(notice -> notice.code().equals("port_limit"))); - } - } - - @Test - void edgesNeverReferToPortsDiscardedByTheBudget() { - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(step( - "split", - List.of(port(resource("ore"), Role.CONSUMED, "ore")), - List.of( - port(resource("one"), Role.UNKNOWN, "dust"), - port(resource("two"), Role.UNKNOWN, "dust")))) - .add(step( - "use", - List.of(port(resource("two"), Role.CONSUMED, "dust")), - List.of(port(resource("end"), Role.UNKNOWN, "dust")))) - .build(); - var result = graph.query(resource("two"), Direction.BOTH, new Budgets(4, 8, 1, 8)); - assertEquals(2, result.steps().size()); - assertTrue(result.edges().isEmpty()); - assertTrue(result.truncated()); - } - - @Test - void materialEdgesUseTheRetainedPortsBeforeSpendingTheEdgeBudget() { - var first = resource("first"); - var second = resource("second"); - var third = resource("third"); - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(step( - "producer", - List.of(port(resource("raw"), Role.CONSUMED, "raw")), - List.of( - port(first, Role.UNKNOWN, "first"), - port(second, Role.UNKNOWN, "second"), - port(third, Role.UNKNOWN, "third")))) - .add(step( - "consumer", - List.of( - port(third, Role.CONSUMED, "third"), - port(first, Role.CONSUMED, "first"), - port(second, Role.CONSUMED, "second")), - List.of(port(resource("end"), Role.UNKNOWN, "end")))) - .build(); - for (int ports = 1; ports <= 3; ports++) { - for (int edges : List.of(0, 1, 3)) { - var result = graph.queryMaterial(first, new Budgets(0, 8, ports, edges)); - int available = ports == 1 ? 0 : ports == 2 ? 1 : 3; - assertEquals(Math.min(available, edges), result.edges().size()); - for (Edge edge : result.edges()) { - var source = result.steps().stream() - .filter(row -> row.reference().equals(edge.source())) - .findFirst() - .orElseThrow(); - var target = result.steps().stream() - .filter(row -> row.reference().equals(edge.target())) - .findFirst() - .orElseThrow(); - assertTrue(source.outputs().stream() - .anyMatch(port -> port.resource().key().equals(edge.resource()))); - assertTrue(target.inputs().stream() - .anyMatch(port -> port.resource().key().equals(edge.resource()))); - } - int omittedPorts = 2 * (3 - ports); - assertEquals( - omittedPorts, - result.notices().stream() - .filter(notice -> notice.code().equals("port_limit")) - .mapToInt(Notice::omitted) - .sum()); - assertEquals( - Math.max(0, available - edges), - result.notices().stream() - .filter(notice -> notice.code().equals("edge_limit")) - .mapToInt(Notice::omitted) - .sum()); - } - } - } - - private static DataKey resource(String name) { - return new DataKey("gt6ce", "resource/" + name); - } - - @Test - void genericRecoveryIsAnInputUseAndDoesNotSpendTheSourceBudget() { - var iron = resource("iron"); - var copper = resource("copper"); - var dust = resource("iron_dust"); - var reclaim = step( - "reclaim", - List.of(port(copper, Role.CONSUMED, "copper", "Copper")), - List.of(port(dust, Role.UNKNOWN, "dust", "Iron"))); - var internal = step( - "internal_recovery", - List.of(port(iron, Role.CONSUMED, "iron")), - List.of(port(dust, Role.UNKNOWN, "dust"))); - var source = step( - "ordinary_source", - List.of(port(copper, Role.CONSUMED, "copper", "Copper")), - List.of(port(iron, Role.UNKNOWN, "iron"))); - var graph = MaterialProcessGraph.builder(SNAPSHOT) - .add(reclaim, true) - .add(internal, true) - .add(source) - .build(); - var material = graph.queryMaterial(dust, new Budgets(0, 2, 16, 16)); - assertEquals(List.of(source, internal), material.steps()); - assertEquals( - List.of(source), - graph.queryMaterial(dust, new Budgets(0, 1, 16, 16)).steps()); - assertFalse(material.truncated()); - assertTrue(graph.query(dust, Direction.SOURCES, Budgets.DEFAULT).steps().isEmpty()); - assertEquals( - List.of(reclaim), - graph.query(copper, Direction.USES, new Budgets(0, 1, 16, 16)).steps()); - assertEquals( - List.of(source), - graph.query(iron, Direction.SOURCES, Budgets.DEFAULT).steps()); - assertEquals( - List.of(internal), - graph.query(iron, Direction.USES, new Budgets(0, 8, 16, 16)).steps()); - } - - private static Port port(DataKey key, Role role, String state) { - return port(key, role, state, "Iron"); - } - - private static Port port(DataKey key, Role role, String state, String material) { - boolean output = role == Role.PRIMARY || role == Role.BYPRODUCT || role == Role.UNKNOWN; - return new Port( - new Resource(key, material, "dust", "solid", state), - role, - new Amount(1, state.startsWith("unit:") ? AmountUnit.MATERIAL_UNIT : AmountUnit.ITEM), - output ? OptionalInt.of(10_000) : OptionalInt.empty(), - false, - List.of()); - } - - private static Step step(String name, List inputs, List outputs) { - return new Step(new DataKey("gt6ce", "step/" + name), name, inputs, outputs, List.of(), true); - } -} diff --git a/core/src/test/java/gregtech/engine/material/MaterialProcessLanguageTest.java b/core/src/test/java/gregtech/engine/material/SpecialProcessLanguageTest.java similarity index 79% rename from core/src/test/java/gregtech/engine/material/MaterialProcessLanguageTest.java rename to core/src/test/java/gregtech/engine/material/SpecialProcessLanguageTest.java index 9eacbf254..e57dc6763 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialProcessLanguageTest.java +++ b/core/src/test/java/gregtech/engine/material/SpecialProcessLanguageTest.java @@ -11,12 +11,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -class MaterialProcessLanguageTest { - private static final Pattern PROCESS_KEYS = - Pattern.compile("\"(gt6ce\\.(?:jei\\.material_process|special_process)\\.[^\"]+)\"\\s*:"); +class SpecialProcessLanguageTest { + private static final Pattern PROCESS_KEYS = Pattern.compile("\"(gt6ce\\.special_process\\.[^\"]+)\"\\s*:"); @Test - void materialProcessLanguagesHaveTheSameKeys() throws Exception { + void specialProcessLanguagesHaveTheSameKeys() throws Exception { var english = keys("en_us.json"); var chinese = keys("zh_cn.json"); assertEquals(english, chinese); diff --git a/docs/architecture/packages/content.md b/docs/architecture/packages/content.md index 8706b3590..cd8bb97f6 100644 --- a/docs/architecture/packages/content.md +++ b/docs/architecture/packages/content.md @@ -99,7 +99,7 @@ core 的 content 描述“有什么”,Minecraft 的 content 将其变为游 - 线缆、管道、轴、电池、覆盖板与储罐的实际传输、断开与方向变化。 - 材料物品/方块注册与统一化;矿脉或结构的注册存在性。 - 现有测试集 - - `MaterialRegistrationTest`、`MaterialCatalogTest` 与 `MaterialProcessGraphTest` 提供材料目录、附属合并、处理图预算与查询回归;契约与不变量见[材料系统设计](../../decisions/material-system/README.md)。 + - `MaterialRegistrationTest` 与 `MaterialCatalogTest` 提供材料目录与附属合并回归;契约与不变量见[材料系统设计](../../decisions/material-system/README.md)。 - core 静态 TSV 与 GameTest TSV 由对应 JUnit/GameTest 维护;用例覆盖物品管道路由与调度回归。 - `core/src/test` 的材料目录、标签名翻译、熔融浇筑与配方引擎测试;`api/common` 的材料、机器、能源模型测试。 - 机器 tick、多方块、能源网络、物流、世界生成完整流程等仍是待补范围。 diff --git a/docs/architecture/packages/engine.md b/docs/architecture/packages/engine.md index 9b62a9bb8..fe935ff15 100644 --- a/docs/architecture/packages/engine.md +++ b/docs/architecture/packages/engine.md @@ -11,7 +11,7 @@ | `engine` | 执行层总体说明 | `package-info.java`;不继续使用旧 internal 命名扩张实现 | | `engine.addon` | 附属声明收集、校验、物化与共享服务绑定 | `AddonCoreServices`、`AddonMaterials`、`AddonMachines`、`AddonPipes` | | `engine.definition` | 定义目录的组织与查询机制 | `DefinitionCatalog`;内容行放 content | -| `engine.material` | 材料原子安装(`MaterialRegistryState`)、引用与组校验(`MaterialLinker`)、附属事实冻结、物品成分与回收纯裁决、多代发布版本号(`MaterialPublication`)、不可变视图与有界处理图 | `GTMaterialRegistry`、`MaterialRegistryState`、`MaterialLinker`、`MaterialInfoRegistry`、`ItemCompositionResolver`、`ItemRecoveryPlanner`、`MaterialPublication`、`MaterialViews`、`MaterialProcessGraph` | +| `engine.material` | 材料原子安装(`MaterialRegistryState`)、引用与组校验(`MaterialLinker`)、附属事实冻结、物品成分与回收纯裁决、多代发布版本号(`MaterialPublication`)、不可变视图 | `GTMaterialRegistry`、`MaterialRegistryState`、`MaterialLinker`、`MaterialInfoRegistry`、`ItemCompositionResolver`、`ItemRecoveryPlanner`、`MaterialPublication`、`MaterialViews` | | `engine.prefix` | 材料形态/前缀的注册与解析 | `PrefixRegistry`、`BlockPrefixRegistry` | | `engine.recipe` | 配方成本、并行与输出空间拟合、燃料批次、精确单位换算与材料分解纯计划、可合成性和界面坐标等共享机制 | `MachineWorkCost`、`ParallelFit`、`FluidFuelChargeMath`、`UnitConversion`、`MaterialDecompositionPlanner`;不能夹带游戏栈 | | `engine.recipe.data` | 配方文档模型、组件、解析及校验 | `MachineRecipeDocuments`、`ItemComponent`、`FluidComponent` | diff --git a/docs/architecture/packages/runtime.md b/docs/architecture/packages/runtime.md index cd3cd27a0..ccb876a76 100644 --- a/docs/architecture/packages/runtime.md +++ b/docs/architecture/packages/runtime.md @@ -70,12 +70,8 @@ Block 处理放置、形状和交互分发;BlockEntity 保存实例状态、 GUI 模板、碎片图标与 JEI/EMI 的布局接入见[GUI 开发指南](../../development/gui-templates.md),平台差异见[平台包](platforms.md)。 -矿物处理由 `content.recipe.MaterialProcessSnapshot` 保存权威 GT 原生事实与活动世界生成;JEI 在 runtime 枚举最终可见分类与配方,EMI 在最终 bake 后枚举可见配方,两者都通过 `ViewerBuilder` 追加工作台、机器与第三方行。可见的 GT machine row 优先复用原生单位、概率和回收归属;`viewer(false)` 的 GT 配方与世界生成由快照补充。`engine.material.MaterialProcessGraph` 提供有界查询,`compat.common.MaterialProcessProjection` 构造两 viewer 共用的展示页。`client.MaterialProcessOverview` 负责布局与路线折叠,`client.MaterialProcessPanel`/`MaterialProcessScreen` 负责视口和原生交互;`MaterialProcessEmiStacks` 把显示流体代理还原为原生索引与查询句柄。`compat.jei.MaterialProcessCategory` 与 `compat.emi.MaterialProcessEmiRecipe` 只做原生槽位、仅限页面材料的索引和事件适配。 - 第三方集成沿配置与现有入口条件加载,`compileOnly` 只说明编译依赖形态,不能保证类加载安全。 -EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理,JEI 由 `compat.jei.MaterialProcessJeiRecipes` 处理。两者都读取所属 viewer 的最终可见分类、配方与工作台;JEI 在 `onRuntimeAvailable` 注册材料页,避免过早读取尚未完成筛选的配方。GT 行优先复用原生单位、概率及回收归属,材料单位模板不受自动配方树开关影响;`viewer(false)` 配方由快照补充。可读取的非树加工以未确认关系接入;说明、结构和动态模式页保留为信息。`MaterialProcessSnapshot.ViewerBuilder` 只构造本次客户端视图,不更改服务端配方。具体覆盖、候选原料和生命周期边界按[游戏内人工验收](../../development/validation/checks/manual-ingame.md#矿物处理展示页)核对。 - ## 验收 - 初始化改动核对[装配顺序](#装配顺序)与[内容注册](#内容注册),包括静态字段首次访问引起的加载。 @@ -83,8 +79,6 @@ EMI 材料页的数据准入由 `compat.emi.MaterialProcessEmiRecipes` 处理, - 客户端只负责展示与交互入口;真实槽位、库存、权限与配方由服务端 Menu 和服务端状态决定。修改 GUI 模板后先做静态预览,再在客户端与专用服务端分别确认。 - 网络包检查方向、解码上限、执行线程、目标实体有效性与请求者权限;Mixin 检查两个节点的配置、目标签名、注入点与未命中行为。 - 可选集成沿配置与现有入口条件加载;分别验证未安装目标模组与安装匹配版本。 -- 矿物处理页按[专用场景](../../development/validation/checks/manual-ingame.md#矿物处理展示页)确认联合输入、角色、概率、端口副本、显式关联与跳转;前端未接线时不记作真实来源或远程快照验收通过。 -- EMI 数据源改动还需确认工作台与第三方加工可见、原生机器不重复、信息页位于来源区底部且点击打开原页面、信息页不生成加工边、延迟注册和配方隐藏生效,以及重载与断线后的旧导航失效。 - 运输网络快照只在布局变化时失效,空闲电线/管道不执行 tick;外部 fill/drain、覆盖板、扳手、邻居变化和区块加载都必须接到失效或唤醒钩子。 - 共享 Minecraft 输入遵循 Stonecutter 条件与版本资源路径;渲染、GUI、网络与 Mixin 的结论不能用单平台结果推出另一平台。 diff --git a/docs/decisions/material-system/README.md b/docs/decisions/material-system/README.md index ed176c174..4cea3d664 100644 --- a/docs/decisions/material-system/README.md +++ b/docs/decisions/material-system/README.md @@ -51,4 +51,4 @@ 3. [物品成分解析与运行时准入](item-composition.md):结构化来源优先级、同级冲突与显式替换链、显式层封闭与 Tag 代次原子重载、耐久缩放及容器/模具形状区分。 4. [统一回收计划与配方发布仲裁](recovery.md):基于有效成分的纯粉碎/热回收计划、大份量拆栈与精度表达、生产端输入证明、所有权与冲突发布仲裁。 5. [统一材料分解规则与计划](decomposition.md):`MaterialDecompositionRule` 唯一权威、规范组成与精确单位计算、液/气替代相态与固体兜底、原生适配器与重载隔离。 -6. [公共数据 API 与多代发布契约](data-api-and-publication.md):已实现的只读视图(目录、元数据、分类/组、形态规则与实际绑定)、`MaterialPublication.Stamp` 一致性保证,以及当前作为内部 viewer 数据层实现、尚未进入公共 API 的来源用途图。 +6. [公共数据 API 与多代发布契约](data-api-and-publication.md):已实现的只读视图(目录、元数据、分类/组、形态规则与实际绑定)、`MaterialPublication.Stamp` 一致性保证。 diff --git a/docs/decisions/material-system/data-api-and-publication.md b/docs/decisions/material-system/data-api-and-publication.md index 618721220..c2ef3cab6 100644 --- a/docs/decisions/material-system/data-api-and-publication.md +++ b/docs/decisions/material-system/data-api-and-publication.md @@ -24,14 +24,5 @@ 由于材料目录定义在进程内一次定稿,而 Tag 成分、形态绑定与机器配方随世界或数据包重载多代替换,`MaterialPublication` 维护原子发布的版本戳 `Stamp(revision, materialRevision, compositionRevision, recipeRevision)`: 1. **进程定义提交**:`GTMaterialRegistry.init()` 到达 `READY` 时调用 `materialDefinitionsPublished(materialRevision)` 唯一一次写定基础材料版本,不允许二次改写。 -2. **平台代次提交**:每次启动装配或热重载在全部 Tag 候选裁决、有效成分构建、`MaterialFormContent` 绑定刷新以及回收/分解配方重建均成功后,先生成 `candidatePlatformGeneration(compositionRevision, recipeRevision)` 候选,再在展示快照构建成功后调用 `commit(candidate)`。 +2. **平台代次提交**:每次启动装配或热重载在全部 Tag 候选裁决、有效成分构建、`MaterialFormContent` 绑定刷新以及回收/分解配方重建均成功后,先生成 `candidatePlatformGeneration(compositionRevision, recipeRevision)` 候选,再在服务端运行时配方发布完成(客户端为炉配方桥应用完成)后调用 `commit(candidate)`。 3. **失败回滚不动旧印记**:重载任一环节报错触发回滚时,`MaterialPublication.current()` 维持上一成功 `Stamp` 不变,保证下游观测不到“成分切至新代但配方仍留旧代”的跨代撕裂。 - -## 来源用途索引与有界处理图 - -来源用途索引与有界处理图当前作为内部运行时与 viewer 数据层实现,尚未提升为公共 `api` 契约。`MaterialProcessSnapshot` 负责服务器会话与 viewer 行代次,`MaterialProcessGraph` 负责有界查询;JEI/EMI 仅消费同一展示投影。 - -- **会话化版本快照**:`MaterialProcessSnapshot` 绑定发布戳、配方 revision、会话代次、形态 revision、tag 代次与世界生成 revision;旧页面的 `DataKey` 在服务端停止、客户端断线或重载后失效。 -- **最终 viewer 行与权威快照合成**:JEI 在 runtime 枚举最终可见分类和配方,EMI 在最终 bake 后枚举可见配方;两者都追加工作台、机器和第三方加工行。GT machine row 复用原生单位、概率与回收归属,`viewer(false)` 配方和真实生效矿脉配置由权威快照补充。 -- **有界材料处理图**:核心层 `MaterialProcessGraph` 支持显式深度、步骤、端口与关联预算,保留共同输入、概率分支、状态条件和确认关系,并在达到预算时输出独立截断原因。 -- **共用展示投影**:服务器只构建 viewer 中立的 `MaterialProcessSnapshot` 与图;JEI/EMI 适配器分别提供最终可见配方和原生槽位,颜色、布局、图标与坐标映射留在客户端接入层。 diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index 5e9023eac..ddeb01b61 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -36,7 +36,7 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe ### 配方回归案例表 -材料领域的运行时回归已不再依赖 `MaterialBaselineTests` 和一次性 TSV 快照。材料成分、回收与分解的纯规则由 JUnit 覆盖;资源重载、旧 viewer 引用拒绝、JEI/EMI 最终可见配方汇入与双平台客户端行为仍按[游戏内人工验收](manual-ingame.md#矿物处理展示页)执行。材料契约见[材料系统设计](../../../decisions/material-system/README.md)。 +材料领域的运行时回归已不再依赖 `MaterialBaselineTests` 和一次性 TSV 快照。材料成分、回收与分解的纯规则由 JUnit 覆盖;资源重载、JEI/EMI 配方显示与双平台客户端行为仍按[游戏内人工验收](manual-ingame.md)执行。材料契约见[材料系统设计](../../../decisions/material-system/README.md)。 `decompositionRespectsFormsAndExactFluidIdentities` 通过测试 SPI 声明 dust-only、blockDust-only、liquid-only 和 gas-only 分解,检查形态限制、流体输入不会错误抑制允许的固体兜底、本体完整 ID、附属完整 ID/旧裸路径、外部原版流体 ID、未知及非法 ID,以及附属流体输出的身份和数量。 diff --git a/docs/development/validation/checks/junit.md b/docs/development/validation/checks/junit.md index 91f4504db..8fc5d85f1 100644 --- a/docs/development/validation/checks/junit.md +++ b/docs/development/validation/checks/junit.md @@ -54,4 +54,4 @@ issue source kind target expected JUnit XML 在 `/build/test-results/test/TEST-*.xml`,HTML 报告在 `/build/reports/tests/test/`。 -材料纯规则的常驻入口是 `MaterialRegistrationTest`、`ItemCompositionResolverTest`、`MaterialDecompositionPlannerTest` 、`MaterialProcessGraphTest` 和 `MaterialProcessLanguageTest`。一次性的基线快照、独立 JVM 生命周期矩阵和测试附属注入已移除;长期行为应落入可直接重复运行、不会向运行时注册测试内容的定向测试。 +材料纯规则的常驻入口是 `MaterialRegistrationTest`、`ItemCompositionResolverTest`、`MaterialDecompositionPlannerTest` 和 `SpecialProcessLanguageTest`。一次性的基线快照、独立 JVM 生命周期矩阵和测试附属注入已移除;长期行为应落入可直接重复运行、不会向运行时注册测试内容的定向测试。 diff --git a/docs/development/validation/checks/manual-ingame.md b/docs/development/validation/checks/manual-ingame.md index 647db090f..e5e4c445e 100644 --- a/docs/development/validation/checks/manual-ingame.md +++ b/docs/development/validation/checks/manual-ingame.md @@ -16,25 +16,6 @@ 具体到机器、配方、流体、能源、网络与可选集成的勾选项写在对应 package 文档的验收章节里。 -## 验证原理 - -### 矿物处理展示页 - -生产页已连接 `MaterialProcessSnapshot`,JEI 与 EMI 复用展示模型和面板。两者都从 viewer 最终可见的工作台、机器与第三方配方构造材料行;权威快照补充 `viewer(false)` GT 机器配方、原生单位/概率和活动世界生成。 - -JEI 与 EMI 数据源分别核对:工作台压块/拆块、熔炉、已安装机器和第三方加工都进入各自材料页;GT machine row 不重复;`viewer(false)` 的切割机、真空冷冻机、组装机、CNC 与坩埚合金化等在两页均存在。包含空网格的有序合成进入加工图;没有实际输入的行不能成为加工来源。通用标签/候选浏览页不进入信息区;GT 材料单位输入说明仍可打开。GT 材料单位模板即使 `supportsRecipeTree=false` 仍保留原生材料单位与概率;工具装配和可读取的第三方非树加工进入图中并使用未确认关系。零数量工具只作为催化剂,不使整条配方降级。相同原配方 ID,以及同分类下仅槽位顺序或网格占位不同的等价加工行不重复;数量、概率、原生状态或工具不同的行继续保留。超过每侧 128 槽、512 步或 4096 条关联时,页面应显示相应正文中的截断提示。加入坏记录时应有诊断日志和覆盖提示,其余有效路线仍可查询。tag 的同材料候选保持一个 selector,候选集合不同的 selector 不得因首个图标相同而合并。隐藏、延迟注册、资源重载与重新入服后页面跟随当前 viewer 配方,旧导航失效。检索输入、工具及产物不按配方出现次数重复,首次打开才构建详情,仍须保留完整原生批量及概率。分别核对 JEI-only、EMI-only、双装和无 viewer 专用服务端。 - -1. 在 JEI/EMI 中打开真实材料的“矿物处理”。页面应直接显示同一张画布上有内容的来源/内部转换/回收/去向区域、区标题与相邻区域分割线,空区域不留占位;世界生成和泉进入来源区;无切换或分页。连续链水平向右,替代路线和分叉就近分行;未分类步骤、无外部入口环及自环不能消失。不同 GUI 缩放下右侧、底部裁剪正确。 -2. 切割机三种润滑剂相同机器图标和完整可见输入或输出时只显示一条路线;仅首产物相同而其他可见产物不同、输入又不同的路线保持独立,全部原生步骤仍保留,辅料不生成图节点,通过右上角 `+` 和 tooltip 查看。EMI 物品和机器使用原生槽位,确认自定义来源/用途绑定、点击释放、R/U、收藏及拖动物品均与普通 EMI 槽位一致,不精确锁定原配方;JEI 沿用普通来源/用途 focus;EMI 使用原生 tooltip,JEI 常规 tooltip 只显示名称;`+` 区域只列合并配方数与辅料名。非 1 件产量、U/mB 和非必然概率在图标上可见,精度保留至原生百分比;确定的 1 件产出不加数量/概率角标,未知概率显示 `?%`。共享资源采用生产端口的量,多个变体的不同量显示多值/省略号并可悬停查看;时间、能量和 native guard 仍保存在原生配方。锤子加工应使用 EMI 同分类已有图标,其他工具/多方块类别也应一致。 -3. 资源局部副本带 `↗`,回流带 `↩`。悬停只突出相同物品的全部实例,机器图标也按真实物品匹配;其他资源、机器和连线均不跟随高亮,移到空白清除。不同 NBT/组件状态分开,流体副本按完整显示身份匹配。查询目标持续显示淡绿色外框,移开鼠标后仍保留。每条配方有较浅外框,独立小配方容易区分,共享端口与网格不能使边框包住相邻机器。连接为单段直线,分支斜连,输入无箭头、输出有箭头;回流不占顶部通道,确认关系不因循环改为虚线。 -4. 对带 NBT/组件物品与真实流体,逐个副本检查左/右击、R/U、tooltip 和 EMI ingredient provider;流体代理应查询实际流体。各节点使用实际显示的完整物品/流体状态查询,无法恢复时保留符号,不用无数据假栈。 -5. 来源/内部转换/回收/去向决定横向分区,不依据机器名称分组;“本材料+辅料 → 本材料其他形态+副产物”仍属内部转换。工具、存在条件及额外辅料/副产物均不扩展生产路线。主材料的多输入、多输出分支仍保留。同机器图标下,完整共同可见输入加工成多个产物,以及完整可见产物相同的替代输入应折叠为三列网格;完整共同输入不同不能仅因其中一个原料相同就按输入折叠。不能将 A→X、A→Y、B→Y 连锁合并而暗示不存在的 B→X;工艺 ID、翻译标题和 method 等隐藏信息不应阻止相同可见路线折叠;机器图标的原生状态不同或缺少可靠图标时保持独立。网格共用一根输入或输出线;用多种木材产树皮的路线确认隐藏辅料、批量和概率不同不阻止折叠;本材料的次要产物必须参与完整输出集合比较,差异可在普通配方查询中查看。透镜或螺栓加工等本材料多输出按端口顺序紧邻排成至多三列网格,共用输出箭头;共享资源也不能把产物挤到其他配方之外。逐格验证原生查询、悬停和 EMI 命中;同一组矩形内部不能插入其他路线的节点或连线。通用研磨/熔化回收配方同时核对 GENERIC 归属及 Shredder/Melter/Smelter 配方表,砧敲碎等普通加工不得进入回收区或被从材料来源中隐藏;回收途径在内部转换后、去向前的独立回收区展示,不能因产出少量粉末就铺成粉末来源;显式来源配方仍应存在。 -6. 独立路线应紧凑排列成多列,局部副本不在远处预留依赖列,短配方也不被其他路线的宽网格撑开。分别查询原料、粉末、锭、零件与真实流体,材料总览只匹配页面所属材料,不能因另一材料配方使用了该物品作辅料、催化剂或外来副产物而出现。每次查询打开与复位均为 100%,查询的具体物品/流体节点位于视口中心;无目标时定位代表链。先平移、缩放再查询另一形态及同一形态,确认缓存视图也会重新定位;不同 NBT/组件状态分别确认。滚轮围绕鼠标缩放,顶部 `−/+` 缩放;空白处左右、上下拖动有效。在 100%、25% 和约 8% 比例下确认线宽、虚线间距及箭头与图标同比缩小,不出现盖住整图的固定尺寸箭头。缩放和平移后,图标、`+`、tooltip、点击及 EMI 悬停命中一致。 调整窗口尺寸及 GUI 缩放后,视口、按钮、裁剪与原生命中应一起变化;右上角全屏按钮展开到窗口,Esc 或按钮返回原查看器。全屏、返回及窗口变化均保留中心世界坐标和缩放;验证全屏中的 JEI/EMI 来源/用途、快捷键、收藏及拖拽,流体仍查询真实流体。 -7. 连续重载两次后确认配方增删同步、旧引用拒绝跳转;断线/换服不沿用回调。布局副本数不改变配方数量或原生 viewer 索引;方法标签只来自 API target/reagent 声明。 -8. 两平台分别检查 JEI-only、EMI-only 和双装环境,双装沿既有去重规则。另验无 viewer 的专用服务端与独立远程客户端;未实际执行的场景不能用编译或集成服务器静态表代替。 - -材料展示页不再维护逐布局场景的示例 GameTest。原状态、辅料隐藏、路线折叠、连续链、循环、副本、排布和关联保留必须直接按上述步骤做真实查看器验收;core 的图测试只证明纯数据与查询预算,不证明投影布局或鼠标手感。 - ## 注意事项 - 使用隔离实例;EULA 由操作者自行处理;完整日志、截图与实例配置放 `work/<任务名>/`,公共记录只保留脱敏结论。 diff --git a/docs/development/validation/routes.yaml b/docs/development/validation/routes.yaml index e9439c90f..02fd802ec 100644 --- a/docs/development/validation/routes.yaml +++ b/docs/development/validation/routes.yaml @@ -118,8 +118,3 @@ routes: - "minecraft/versions/*/src/main/java/gregtech/network/**" packages: [runtime] checks: [manual-ingame] - - paths: - - "minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java" - - "minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java" - packages: [runtime] - checks: [manual-ingame, gametest] diff --git a/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java b/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java index 211dec2e8..efadee4a5 100644 --- a/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java +++ b/minecraft/src/main/java/gregtech/client/MachineRecipeClient.java @@ -2,7 +2,6 @@ import gregtech.engine.mod.GregTechIdentity; import gregtech.content.recipe.MachineRecipeOverlay; -import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.content.recipe.OvenRecipeBridge; import net.minecraft.client.Minecraft; import net.minecraft.world.item.crafting.RecipeManager; @@ -12,13 +11,11 @@ import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.ModList; import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent; import net.neoforged.neoforge.client.event.RecipesUpdatedEvent; import net.neoforged.neoforge.event.TagsUpdatedEvent; import net.neoforged.neoforge.server.ServerLifecycleHooks; *///?} else { import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.ClientPlayerNetworkEvent; import net.minecraftforge.client.event.RecipesUpdatedEvent; import net.minecraftforge.event.TagsUpdatedEvent; import net.minecraftforge.eventbus.api.EventPriority; @@ -42,12 +39,6 @@ public static void recipes(RecipesUpdatedEvent event) { apply(event.getRecipeManager()); } - /** A viewer callback must not survive a disconnect even if the next recipe sync is delayed. */ - @SubscribeEvent - public static void logout(ClientPlayerNetworkEvent.LoggingOut event) { - MaterialProcessSnapshot.Store.clear(MaterialProcessSnapshot.Store.current()); - } - /** On login the server sends recipes before tags, so tag inputs only expand once the tags arrive. */ /** Tag inputs only expand against the tags the server sent, which can arrive after the recipes. */ @@ -66,8 +57,7 @@ private static void apply(RecipeManager recipes) { // exist after it runs, and the synced recipe list alone does not recreate them locally. var connection = Minecraft.getInstance().getConnection(); if (connection != null) OvenRecipeBridge.apply(recipes, connection.registryAccess()); - MaterialProcessSnapshot.Store.publish( - MachineRecipeOverlay.lastPublication(), MachineRecipeOverlay.generation()); + gregtech.engine.material.MaterialPublication.commit(MachineRecipeOverlay.lastPublication()); // The row set is final now; build on the task queue so the sync thread is not blocked. // A newer tag update supersedes this pass and its queued build. long generation = MachineRecipeOverlay.generation(); diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessArrows.java b/minecraft/src/main/java/gregtech/client/MaterialProcessArrows.java deleted file mode 100644 index fffcd228e..000000000 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessArrows.java +++ /dev/null @@ -1,24 +0,0 @@ -package gregtech.client; - -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.renderer.RenderType; - -/** Filled geometry avoids the disconnected bars produced by a rotated pixel-chevron head. */ -public final class MaterialProcessArrows { - private MaterialProcessArrows() {} - - public static void head(GuiGraphics graphics, int color) { - var vertices = graphics.bufferSource().getBuffer(RenderType.gui()); - var matrix = graphics.pose().last().pose(); - float[][] points = {{0, 0}, {-4, -2.2f}, {-4, 2.2f}, {-4, 2.2f}}; - for (float[] point : points) { -//? if >=1.21.1 { - /*vertices.addVertex(matrix, point[0], point[1], 0) - .setColor((color >> 16) & 255, (color >> 8) & 255, color & 255, (color >>> 24) & 255); -*///?} else { - vertices.vertex(matrix, point[0], point[1], 0) - .color((color >> 16) & 255, (color >> 8) & 255, color & 255, (color >>> 24) & 255).endVertex(); -//?} - } - } -} diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessOverview.java b/minecraft/src/main/java/gregtech/client/MaterialProcessOverview.java deleted file mode 100644 index 7734b602f..000000000 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessOverview.java +++ /dev/null @@ -1,1095 +0,0 @@ -package gregtech.client; - -import gregtech.api.addon.material.DataKey; -import gregtech.compat.common.MaterialProcessDisplay; -import gregtech.compat.common.MaterialProcessDisplay.Connection; -import gregtech.compat.common.MaterialProcessDisplay.Page; -import gregtech.compat.common.MaterialProcessDisplay.Port; -import gregtech.compat.common.MaterialProcessDisplay.Role; -import gregtech.compat.common.MaterialProcessDisplay.Section; -import gregtech.compat.common.MaterialProcessDisplay.Step; -import gregtech.engine.stack.StackCompat; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Predicate; -import net.minecraft.world.item.ItemStack; - -/** A layout of material-local native steps; resource copies never introduce recipe facts. */ -public final class MaterialProcessOverview { - /** The original port, including its side and slot, survives sharing and local copying. */ - public record Endpoint(Step step, boolean output, int index, Port port) { - public String key() { - return step.reference() + (output ? ":out:" : ":in:") + index + ":" + port.resource(); - } - } - - public static final class Node { - public final String key; - public final Section section; - public final List endpoints = new ArrayList<>(); - public final List steps = new ArrayList<>(); - public int x, y, layer; - public boolean copy, returning; - private Grid grid; - private boolean feedbackCopy; - - private Node(String key, Section section) { - this.key = key; - this.section = section; - } - - public boolean machine() { - return !steps.isEmpty(); - } - - public Port port() { - return endpoints.get(0).port(); - } - - /** Producers determine the badge on a shared resource; consumption amounts stay on native ports. */ - public List badgePorts() { - boolean produced = endpoints.stream().anyMatch(Endpoint::output); - return endpoints.stream() - .filter(endpoint -> endpoint.output() == produced) - .map(Endpoint::port) - .toList(); - } - - public String quantityBadge() { - List values = badgePorts().stream() - .map(port -> port.quantity().getString()) - .distinct() - .sorted() - .toList(); - if (values.size() == 1) return values.get(0); - if (values.size() > 3) return "…"; - return String.join( - "/", - values.stream().map(value -> value.isEmpty() ? "1" : value).toList()); - } - - public String chanceBadge() { - if (endpoints.stream().noneMatch(Endpoint::output)) return ""; - List values = badgePorts().stream() - .map(port -> port.chance().isPresent() - ? java.math.BigDecimal.valueOf(port.chance().getAsInt(), 2) - .stripTrailingZeros() - .toPlainString() - + "%" - : "?%") - .distinct() - .sorted() - .toList(); - return values.equals(List.of("100%")) ? "" : values.size() > 3 ? "…%" : String.join("/", values); - } - - public boolean extra() { - return steps.size() > 1 - || !auxiliaries.isEmpty() - || steps.stream() - .anyMatch(step -> java.util.stream.Stream.concat( - step.inputs().stream(), step.outputs().stream()) - .anyMatch(port -> port.iconCount() > 1)); - } - - public final List auxiliaries = new ArrayList<>(); - } - - /** One inventory-like display box; each cell retains its own native ports and navigation. */ - public static final class Grid { - public final List members; - private final Node root; - - private Grid(List members) { - this.members = List.copyOf(members); - root = members.get(0); - members.forEach(node -> node.grid = this); - } - - public int left() { - return root.x - 12; - } - - public int right() { - return left() + Math.min(3, members.size()) * 24; - } - - public int top() { - return root.y - 12; - } - - public int bottom() { - return top() + ((members.size() + 2) / 3) * 24; - } - - public int centerY() { - return (top() + bottom()) / 2; - } - } - - public record Point(int x, int y) {} - - public static final class Edge { - private Node from, to; - private final Endpoint endpoint; - private final boolean primary; - private final List endpoints = new ArrayList<>(); - private boolean confirmed; - private boolean feedback; - private List path = List.of(); - - private Edge(Node from, Node to, Endpoint endpoint, boolean primary) { - this.from = from; - this.to = to; - this.endpoint = endpoint; - this.primary = primary; - endpoints.add(endpoint); - confirmed = endpoint.step().resolved(); - } - - public Node from() { - return from; - } - - public Node to() { - return to; - } - - public Endpoint endpoint() { - return endpoint; - } - - public List endpoints() { - return List.copyOf(endpoints); - } - - public boolean confirmed() { - return confirmed; - } - - public boolean feedback() { - return feedback; - } - - public List path() { - return path; - } - } - - private static final class IconKey { - private final ItemStack icon; - - private IconKey(ItemStack icon) { - this.icon = icon; - } - - @Override - public boolean equals(Object other) { - return other instanceof IconKey key && StackCompat.sameItem(icon, key.icon); - } - - @Override - public int hashCode() { - return icon.getItem().hashCode(); - } - } - - private record RouteKey(IconKey machine, boolean output, List resources) {} - - private record VisiblePorts(List inputs, List outputs) {} - - private record EdgeKey(Node from, Node to) {} - - public record RecipeFrame(Node machine, int left, int top, int right, int bottom) {} - - private record Arc(Node from, Node to, Edge edge) {} - - private record Occupancy(BitSet positive, BitSet negative) { - private Occupancy() { - this(new BitSet(), new BitSet()); - } - - private void add(int lane) { - (lane >= 0 ? positive : negative).set(lane >= 0 ? lane : -lane - 1); - } - - private boolean contains(int lane) { - return (lane >= 0 ? positive : negative).get(lane >= 0 ? lane : -lane - 1); - } - } - - private final List nodes = new ArrayList<>(); - private final List edges = new ArrayList<>(); - private final List grids = new ArrayList<>(); - - public record Band(Section section, int left, int right) {} - - public record InformationCard( - MaterialProcessDisplay.Information information, int left, int top, int right, int bottom) {} - - private final List bands = new ArrayList<>(); - private final List information = new ArrayList<>(); - private final List connections; - private final List flows; - private final Set unresolved = new HashSet<>(); - private final Map next = new HashMap<>(), previous = new HashMap<>(); - private final Set feedback = new HashSet<>(); - private final List frames = new ArrayList<>(); - private int width, height; - private Node anchor; - - public MaterialProcessOverview(Page page) { - this(page, true); - frameRecipes(); - } - - private MaterialProcessOverview(Page page, boolean partition) { - flows = page.flows(); - for (Step step : page.steps()) if (!step.resolved()) unresolved.add(step.reference()); - connections = page.connections().stream() - .sorted(Comparator.comparing( - connection -> connection.source() + ":" + connection.target() + ":" + connection.resource())) - .toList(); - if (partition && (!page.steps().isEmpty() || !page.information().isEmpty())) { - partition(page); - return; - } - var resources = new LinkedHashMap(); - var ordered = page.steps().stream() - .sorted(Comparator.comparing(value -> value.reference().toString())) - .toList(); - var visibility = new HashMap(); - for (Step step : ordered) - visibility.put( - step.reference(), - new VisiblePorts( - visible(step.inputs(), page.material(), false), - visible(step.outputs(), page.material(), true))); - var routes = routes(ordered, visibility, page.material()); - var wires = new LinkedHashMap(); - for (Step step : ordered) { - Node machine = routes.get(step.reference()); - machine.steps.add(step); - for (boolean output : List.of(false, true)) { - List ports = output ? step.outputs() : step.inputs(); - List visible = output - ? visibility.get(step.reference()).outputs() - : visibility.get(step.reference()).inputs(); - Set shown = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); - shown.addAll(visible); - for (int index = 0; index < ports.size(); index++) { - Port port = ports.get(index); - if (!shown.contains(port)) { - machine.auxiliaries.add(port); - continue; - } - var endpoint = new Endpoint(step, output, index, port); - machine.endpoints.add(endpoint); - String instance = output && step.genericRecovery() - ? "recovery:" + machine.key + ":" + port.semanticIdentity() - : "resource:" + port.semanticIdentity(); - Node resource = resources.computeIfAbsent(instance, identity -> { - var node = new Node(identity, null); - node.feedbackCopy = output && step.genericRecovery(); - nodes.add(node); - return node; - }); - if (port.hasIcons() - && !resource.endpoints.isEmpty() - && !resource.port().hasIcons()) resource.endpoints.add(0, endpoint); - else resource.endpoints.add(endpoint); - Node from = output ? machine : resource, to = output ? resource : machine; - Edge edge = wires.get(new EdgeKey(from, to)); - if (edge == null) { - edge = new Edge(from, to, endpoint, port == visible.get(0)); - wires.put(new EdgeKey(from, to), edge); - edges.add(edge); - } else { - edge.endpoints.add(endpoint); - edge.confirmed &= step.resolved(); - } - } - } - } - applyConfirmation(); - // Detect returns before detaching shared resources into inventory grids. - layout(); - if (localizeGrids()) layout(); - // Each pass detaches at least one shared port; copies themselves are never split again. - while (splitLongEdges()) layout(); - Map counts = new HashMap<>(); - for (Node node : nodes) if (!node.machine()) counts.merge(node.port().semanticIdentity(), 1, Integer::sum); - for (Node node : nodes) - if (!node.machine()) node.copy = counts.get(node.port().semanticIdentity()) > 1; - route(); - anchor = nodes.stream() - .filter(node -> !node.machine() && node.port().material().equals(page.material())) - .min(Comparator.comparingInt(node -> -chainLength(node)).thenComparing(node -> node.key)) - .orElse(nodes.isEmpty() ? null : nodes.get(0)); - } - - private Map routes(List ordered, Map visibility, String material) { - var candidates = new LinkedHashMap>(); - for (Step step : ordered) { - ItemStack icon = step.icon(); - if (icon.isEmpty()) continue; - var machine = new IconKey(icon); - List inputs = visibility.get(step.reference()).inputs(); - List outputs = visibility.get(step.reference()).outputs(); - if (!inputs.isEmpty()) - candidates - .computeIfAbsent(new RouteKey(machine, false, identities(inputs)), ignored -> new ArrayList<>()) - .add(step); - if (!outputs.isEmpty()) - candidates - .computeIfAbsent(new RouteKey(machine, true, identities(outputs)), ignored -> new ArrayList<>()) - .add(step); - } - var groups = candidates.entrySet().stream() - .sorted(Comparator.>>comparingInt( - entry -> -entry.getValue().size()) - .thenComparing(entry -> !entry.getKey().output()) - .thenComparing( - entry -> entry.getValue().get(0).reference().toString())) - .toList(); - var result = new HashMap(); - // Fold one shared side at a time. Transitive input/output unions would invent a cross-product of routes. - for (var group : groups) { - var available = group.getValue().stream() - .filter(step -> !result.containsKey(step.reference())) - .toList(); - if (available.size() < 2) continue; - Node machine = machine(available.get(0), material); - for (Step step : available) result.put(step.reference(), machine); - } - for (Step step : ordered) - if (!result.containsKey(step.reference())) result.put(step.reference(), machine(step, material)); - return result; - } - - private Node machine(Step step, String material) { - var node = new Node( - "step:" + step.reference(), - MaterialProcessDisplay.section(step, material).orElse(null)); - nodes.add(node); - return node; - } - - public List nodes() { - return List.copyOf(nodes); - } - - public List bands() { - return List.copyOf(bands); - } - - public List information() { - return List.copyOf(information); - } - - public List grids() { - return List.copyOf(grids); - } - - private Map> producers() { - var result = new HashMap>(); - for (Edge edge : edges) - if (edge.endpoint.output()) - result.computeIfAbsent(edge.to, ignored -> new HashSet<>()).add(edge.from); - return result; - } - - private Map> machineEdges() { - var result = new HashMap>(); - for (Edge edge : edges) - result.computeIfAbsent(edge.endpoint.output() ? edge.from : edge.to, ignored -> new ArrayList<>()) - .add(edge); - return result; - } - - private boolean localizeGrids() { - boolean changed = false; - var producers = producers(); - var machineEdges = machineEdges(); - var counts = new HashMap(); - for (Edge edge : edges) counts.merge(resource(edge), 1, Integer::sum); - for (Node machine : List.copyOf(nodes)) { - if (!machine.machine()) continue; - for (boolean output : List.of(false, true)) { - List side = machineEdges.getOrDefault(machine, List.of()).stream() - .filter(edge -> edge.endpoint.output() == output) - .toList(); - if (side.size() < 2) continue; - for (Edge edge : side) { - Node resource = resource(edge); - if (counts.get(resource) < 2) continue; - // Keep a product's downstream chain when this is its only visible producer. - if (output && producers.getOrDefault(resource, Set.of()).size() == 1) continue; - split(edge); - counts.merge(resource, -1, Integer::sum); - changed = true; - } - } - } - return changed; - } - - private Node representative(Node node) { - return node.grid == null ? node : node.grid.root; - } - - private int rows(Node node) { - return node.grid == null ? 1 : (node.grid.members.size() + 2) / 3; - } - - private void buildGrids(Map degree) { - var producers = producers(); - var machineEdges = machineEdges(); - grids.clear(); - nodes.forEach(node -> node.grid = null); - for (Node machine : nodes) { - if (!machine.machine()) continue; - for (boolean output : List.of(false, true)) { - List members = machineEdges.getOrDefault(machine, List.of()).stream() - .filter(edge -> edge.endpoint.output() == output && !edge.feedback) - .map(this::resource) - .filter(node -> degree.get(node) == 1 - || output - && node.layer == machine.layer + 1 - && producers - .getOrDefault(node, Set.of()) - .size() - == 1) - .sorted(Comparator.comparingInt( - (Node node) -> node.endpoints.get(0).index()) - .thenComparing(node -> node.key)) - .toList(); - if (members.size() > 1) grids.add(new Grid(members)); - } - } - } - - private void applyConfirmation() { - Set uncertain = new HashSet<>(); - for (Connection connection : connections) - if (!connection.confirmed()) uncertain.add(connection.target() + ":" + connection.resource()); - for (var flow : flows) - if (flow.sources().stream().anyMatch(unresolved::contains)) - for (DataKey target : flow.targets()) uncertain.add(target + ":" + flow.resource()); - for (Edge edge : edges) - if (edge.endpoints.stream() - .anyMatch(endpoint -> !endpoint.output() - && uncertain.contains(endpoint.step().reference() + ":" - + endpoint.port().resource()))) edge.confirmed = false; - } - - private void partition(Page page) { - int offset = 0; - for (Section section : Section.values()) { - List steps = page.steps().stream() - .filter(step -> MaterialProcessDisplay.section(step, page.material()) - .orElse(Section.INTERNAL) - == section) - .toList(); - boolean hasInformation = - section == Section.SOURCES && !page.information().isEmpty(); - if (steps.isEmpty() && !hasInformation) continue; - Set references = new HashSet<>(); - steps.forEach(step -> references.add(step.reference())); - var local = new Page( - page.title(), - page.material(), - steps, - connections.stream() - .filter(connection -> references.contains(connection.source()) - && references.contains(connection.target())) - .toList(), - page.notices(), - 1, - 1, - page.navigation()); - var graph = new MaterialProcessOverview(local, false); - var copies = new HashMap(); - for (Node original : graph.nodes) { - var node = new Node("band:" + section.name() + ":" + original.key, original.section); - node.endpoints.addAll(original.endpoints); - node.steps.addAll(original.steps); - node.auxiliaries.addAll(original.auxiliaries); - node.x = original.x + offset; - node.y = original.y + 28; - node.layer = original.layer + offset / 52; - node.returning = original.returning; - node.copy = original.copy; - copies.put(original, node); - nodes.add(node); - } - for (Grid original : graph.grids) - grids.add(new Grid(original.members.stream().map(copies::get).toList())); - for (Edge original : graph.edges) { - var edge = new Edge( - copies.get(original.from), copies.get(original.to), original.endpoint, original.primary); - edge.endpoints.clear(); - edge.endpoints.addAll(original.endpoints); - edge.confirmed = original.confirmed; - edge.feedback = original.feedback; - edges.add(edge); - } - graph.next.forEach((from, to) -> next.put(copies.get(from), copies.get(to))); - if (graph.anchor != null && (anchor == null || section == Section.INTERNAL)) - anchor = copies.get(graph.anchor); - int bandWidth = Math.max(hasInformation ? 176 : 72, graph.width); - if (hasInformation) { - int top = Math.max( - 48, - graph.nodes.stream().mapToInt(node -> node.y + 64).max().orElse(48)); - int columns = Math.max(1, Math.min(3, (bandWidth - 16) / 160)); - for (int index = 0; index < page.information().size(); index++) { - int left = offset + 8 + index % columns * 160; - int y = top + index / columns * 28; - information.add(new InformationCard(page.information().get(index), left, y, left + 152, y + 24)); - } - } - bands.add(new Band(section, offset, offset + bandWidth)); - offset += bandWidth; - } - var instances = new HashMap(); - for (Node node : nodes) if (!node.machine()) instances.merge(node.port().semanticIdentity(), 1, Integer::sum); - for (Node node : nodes) - if (!node.machine()) node.copy |= instances.get(node.port().semanticIdentity()) > 1; - applyConfirmation(); - route(); - height = Math.max( - height, - information.stream().mapToInt(card -> card.bottom() + 12).max().orElse(0)); - width = offset; - } - - public List edges() { - return List.copyOf(edges); - } - - public List connections() { - return connections; - } - - public List flows() { - return flows; - } - - public Node anchor() { - return anchor; - } - - /** Find a visible native port without treating equal item icons as equal native states. */ - public Node find(Predicate matches) { - return nodes.stream() - .filter(node -> - !node.machine() && node.endpoints.stream().anyMatch(endpoint -> matches.test(endpoint.port()))) - .min(Comparator.comparing(node -> node.returning) - .thenComparingInt(node -> -chainLength(node)) - .thenComparing(node -> node.key)) - .orElse(null); - } - - public List frames() { - return List.copyOf(frames); - } - - /** Hover synchronizes equal displayed resources and machine items, including their full native state. */ - public Set matchingNodes(Node hovered) { - if (hovered == null) return Set.of(); - ItemStack icon = icon(hovered); - var matches = new HashSet(); - for (Node node : nodes) { - if (node == hovered - || !node.machine() - && !hovered.machine() - && node.port().identity().equals(hovered.port().identity()) - || !icon.isEmpty() && StackCompat.sameItem(icon, icon(node))) matches.add(node); - } - return Set.copyOf(matches); - } - - private static ItemStack icon(Node node) { - return node.machine() ? node.steps.get(0).icon() : node.port().icon(); - } - - private void frameRecipes() { - var owners = new HashMap(); - for (Edge edge : edges) { - Node resource = representative(resource(edge)), machine = edge.from.machine() ? edge.from : edge.to; - Node previous = owners.get(resource); - if (previous == null - || distance(resource, machine) < distance(resource, previous) - || distance(resource, machine) == distance(resource, previous) - && machine.key.compareTo(previous.key) < 0) owners.put(resource, machine); - } - var local = new HashMap>(); - owners.forEach((resource, machine) -> - local.computeIfAbsent(machine, ignored -> new ArrayList<>()).add(resource)); - var columns = new java.util.TreeMap>(); - for (Node node : nodes) - columns.computeIfAbsent(node.x, ignored -> new ArrayList<>()).add(node); - for (Node machine : nodes) { - if (!machine.machine()) continue; - int left = machine.x - 12, right = machine.x + 12, top = machine.y - 14, bottom = machine.y + 14; - for (Node resource : local.getOrDefault(machine, List.of()).stream() - .sorted(Comparator.comparingLong((Node node) -> distance(node, machine)) - .thenComparing(node -> node.key)) - .toList()) { - int l = Math.min(left, resource.grid == null ? resource.x - 12 : resource.grid.left()); - int r = Math.max(right, resource.grid == null ? resource.x + 12 : resource.grid.right()); - int t = Math.min(top, resource.grid == null ? resource.y - 14 : resource.grid.top() - 2); - int b = Math.max(bottom, resource.grid == null ? resource.y + 14 : resource.grid.bottom() + 2); - boolean clear = columns.subMap(l - 12, true, r + 12, true).values().stream() - .flatMap(List::stream) - .noneMatch(node -> node != machine - && owners.get(representative(node)) != machine - && node.x + 12 > l - && node.x - 12 < r - && node.y + 14 > t - && node.y - 14 < b); - if (clear) { - left = l; - right = r; - top = t; - bottom = b; - } - } - frames.add(new RecipeFrame(machine, left - 1, top - 1, right + 1, bottom + 1)); - } - } - - private static long distance(Node resource, Node machine) { - long dx = resource.x - machine.x, dy = resource.y - machine.y; - return dx * dx + dy * dy; - } - - public int width() { - return width; - } - - public int height() { - return height; - } - - private static List visible(List ports, String material, boolean output) { - List candidates = ports.stream() - .filter(port -> output || port.role() == Role.CONSUMED) - .toList(); - List local = candidates.stream() - .filter(port -> port.material().equals(material)) - .toList(); - if (!local.isEmpty()) return local; - // Foreign co-inputs and tools stay in the + details. The main hint never changes port roles. - return candidates.stream() - .filter(Port::main) - .findFirst() - .or(() -> candidates.stream() - .filter(port -> !output || port.role() != Role.BYPRODUCT) - .findFirst()) - .map(List::of) - .orElse(List.of()); - } - - private static List identities(List ports) { - return ports.stream().map(Port::semanticIdentity).distinct().sorted().toList(); - } - - private Node resource(Edge edge) { - return edge.from.machine() ? edge.to : edge.from; - } - - private void split(Edge edge) { - Node original = resource(edge); - Node local = new Node("copy:" + edge.endpoint.key(), null); - local.feedbackCopy = edge.feedback || original.returning || original.feedbackCopy; - local.endpoints.addAll(edge.endpoints); - nodes.add(local); - original.endpoints.removeAll(edge.endpoints); - if (edge.from == original) edge.from = local; - else edge.to = local; - } - - private static boolean primary(Edge edge) { - return edge.primary; - } - - private boolean splitLongEdges() { - boolean changed = false; - var counts = new HashMap(); - for (Edge edge : edges) counts.merge(resource(edge), 1, Integer::sum); - var columns = new java.util.TreeMap>(); - for (Node node : nodes) - columns.computeIfAbsent(node.x, ignored -> new java.util.TreeMap<>()) - .put(node.y, node); - for (Edge edge : edges) { - Node resource = resource(edge); - if (counts.get(resource) < 2) continue; - int fromY = edge.from.grid == null ? edge.from.y : edge.from.grid.centerY(); - int toY = edge.to.grid == null ? edge.to.y : edge.to.grid.centerY(); - int distanceY = Math.abs(toY - fromY); - if (!edge.feedback - && edge.to.layer - edge.from.layer <= 3 - && distanceY <= 128 - && (!edge.endpoint.output() || primary(edge) || distanceY <= 64) - && !crossesNode(edge, columns)) continue; - split(edge); - counts.merge(resource, -1, Integer::sum); - changed = true; - } - return changed; - } - - private boolean crossesNode( - Edge edge, java.util.NavigableMap> columns) { - Node from = representative(edge.from), to = representative(edge.to); - double sx = from.grid == null ? from.x + 12 : from.grid.right(); - double tx = to.grid == null ? to.x - 12 : to.grid.left(); - double sy = from.grid == null ? from.y : from.grid.centerY(); - double ty = to.grid == null ? to.y : to.grid.centerY(); - if (tx <= sx) return true; - for (var column : - columns.subMap((int) sx - 12, true, (int) tx + 12, true).entrySet()) { - double left = Math.max(sx, column.getKey() - 12), right = Math.min(tx, column.getKey() + 12); - if (left > right) continue; - double ly = sy + (ty - sy) * (left - sx) / (tx - sx); - double ry = sy + (ty - sy) * (right - sx) / (tx - sx); - int low = (int) Math.ceil(Math.min(ly, ry) - 14), high = (int) Math.floor(Math.max(ly, ry) + 14); - for (Node node : column.getValue().subMap(low, true, high, true).values()) - if (representative(node) != from && representative(node) != to) return true; - } - return false; - } - - private List arcs() { - var result = new ArrayList(); - // A local copy ends the visible dependency; retained facts must not reserve invisible columns. - for (Edge edge : edges) result.add(new Arc(edge.from, edge.to, edge)); - result.sort(Comparator.comparing((Arc arc) -> arc.from.key) - .thenComparing(arc -> arc.to.key) - .thenComparing(arc -> arc.edge.endpoint.key())); - return result; - } - - private void layout() { - next.clear(); - previous.clear(); - feedback.clear(); - List arcs = arcs(); - var outgoing = new HashMap>(); - var indegree = new HashMap(); - for (Node node : nodes) { - node.layer = 0; - node.returning = node.feedbackCopy; - } - for (Edge edge : edges) edge.feedback = false; - for (Arc arc : arcs) { - outgoing.computeIfAbsent(arc.from, ignored -> new ArrayList<>()).add(arc); - indegree.merge(arc.to, 1, Integer::sum); - } - // Iterative DFS cuts only feedback constraints, including pure cycles and self loops. - var state = new HashMap(); - record Frame(Node node, java.util.Iterator iterator) {} - var roots = new ArrayList<>(nodes); - roots.sort(Comparator.comparingInt(node -> indegree.getOrDefault(node, 0) == 0 ? 0 : 1) - .thenComparing(node -> node.key)); - for (Node root : roots) { - if (state.containsKey(root)) continue; - var stack = new ArrayDeque(); - state.put(root, 1); - stack.push(new Frame(root, outgoing.getOrDefault(root, List.of()).iterator())); - while (!stack.isEmpty()) { - Frame frame = stack.peek(); - if (!frame.iterator.hasNext()) { - state.put(frame.node, 2); - stack.pop(); - continue; - } - Arc arc = frame.iterator.next(); - if (state.getOrDefault(arc.to, 0) == 1) { - feedback.add(arc); - indegree.merge(arc.to, -1, Integer::sum); - arc.edge.feedback = true; - resource(arc.edge).returning = true; - } else if (!state.containsKey(arc.to)) { - state.put(arc.to, 1); - stack.push(new Frame( - arc.to, outgoing.getOrDefault(arc.to, List.of()).iterator())); - } - } - } - var ready = new java.util.PriorityQueue(Comparator.comparing(node -> node.key)); - for (Node node : roots) if (indegree.getOrDefault(node, 0) == 0) ready.add(node); - while (!ready.isEmpty()) { - Node node = ready.remove(); - for (Arc arc : outgoing.getOrDefault(node, List.of())) - if (!feedback.contains(arc)) { - arc.to.layer = Math.max(arc.to.layer, node.layer + 1); - if (indegree.merge(arc.to, -1, Integer::sum) == 0) ready.add(arc.to); - } - } - var nearestConsumer = new HashMap(); - for (Edge edge : edges) - if (!edge.endpoint.output()) nearestConsumer.merge(edge.from, edge.to.layer - 1, Math::min); - for (Node node : nodes) - if (!node.machine() && node.endpoints.stream().noneMatch(Endpoint::output)) - node.layer = Math.max(0, nearestConsumer.getOrDefault(node, node.layer)); - var degree = new HashMap(); - var neighbors = new HashMap>(); - for (Edge edge : edges) { - degree.merge(edge.from, 1, Integer::sum); - degree.merge(edge.to, 1, Integer::sum); - neighbors.computeIfAbsent(edge.from, ignored -> new ArrayList<>()).add(edge.to); - neighbors.computeIfAbsent(edge.to, ignored -> new ArrayList<>()).add(edge.from); - } - buildGrids(degree); - for (Grid grid : grids) - for (Node member : grid.members) - if (member != grid.root) - neighbors - .computeIfAbsent(grid.root, ignored -> new ArrayList<>()) - .addAll(neighbors.getOrDefault(member, List.of())); - var ordered = new ArrayList<>(edges); - var before = new HashMap(); - var after = new HashMap(); - var forwards = edges.stream() - .filter(edge -> !edge.feedback && edge.to.layer > edge.from.layer) - .sorted(Comparator.comparingInt(edge -> edge.from.layer)) - .toList(); - for (Edge edge : forwards) before.merge(edge.to, before.getOrDefault(edge.from, 0) + 1, Math::max); - for (int index = forwards.size() - 1; index >= 0; index--) { - Edge edge = forwards.get(index); - after.merge(edge.from, after.getOrDefault(edge.to, 0) + 1, Math::max); - } - ordered.sort(Comparator.comparingInt(edge -> primary(edge) ? 0 : 1) - .thenComparingInt(edge -> edge.endpoint.index()) - .thenComparingInt(edge -> degree.get(edge.from) + degree.get(edge.to)) - .thenComparingInt(edge -> -before.getOrDefault(edge.from, 0) - after.getOrDefault(edge.to, 0)) - .thenComparing(edge -> edge.endpoint.key())); - for (Edge edge : ordered) - if (!edge.feedback - && primary(edge) - && edge.to.layer == edge.from.layer + 1 - && representative(edge.from) == edge.from - && representative(edge.to) == edge.to - && !next.containsKey(edge.from) - && !previous.containsKey(edge.to)) { - next.put(edge.from, edge.to); - previous.put(edge.to, edge.from); - } - var starts = nodes.stream() - .filter(node -> !previous.containsKey(node)) - .filter(node -> representative(node) == node) - .sorted(Comparator.comparingInt(node -> -chainLength(node)) - .thenComparingInt(node -> node.layer) - .thenComparing(node -> family(node, neighbors)) - .thenComparing(node -> node.key)) - .toList(); - var lanes = new HashMap(); - var chains = new ArrayList>(); - for (Node start : starts) { - var chain = new ArrayList(); - for (Node node = start; node != null; node = next.get(node)) chain.add(node); - chains.add(chain); - } - var chainRows = new HashMap(); - for (List chain : chains) { - int size = chain.stream().mapToInt(this::rows).max().orElse(1); - chain.forEach(node -> chainRows.put(node, size)); - } - var order = new ArrayList(); - for (int index = 0; index < chains.size(); index++) order.add(index); - for (int pass = 0; pass < 4; pass++) { - var prior = new HashMap<>(lanes); - if (pass > 0) - order.sort(Comparator.comparingDouble(index -> chains.get(index).stream() - .flatMap(node -> neighbors.getOrDefault(node, List.of()).stream()) - .filter(prior::containsKey) - .mapToInt(prior::get) - .average() - .orElse(0)) - .thenComparingInt(Integer::intValue)); - lanes.clear(); - var occupied = new HashMap(); - for (int index : order) { - List chain = chains.get(index); - double center = chain.stream() - .flatMap(node -> neighbors.getOrDefault(node, List.of()).stream()) - .filter(node -> !chain.contains(node)) - .filter(node -> lanes.containsKey(node) || prior.containsKey(node)) - .mapToInt(node -> lanes.containsKey(node) ? lanes.get(node) : prior.get(node)) - .average() - .orElse(0); - var cells = new HashMap>(); - int first = chain.stream().mapToInt(node -> node.layer).min().orElse(0); - int last = chain.stream().mapToInt(node -> node.layer).max().orElse(first); - int blockRows = chain.stream().mapToInt(this::rows).max().orElse(1); - // Reserve the whole recipe block, including the space between its icons. - for (int layer = first; layer <= last; layer++) - for (int row = 0; row < blockRows; row++) - cells.computeIfAbsent(layer, ignored -> new HashSet<>()).add(row); - int desired = (int) Math.round(center), lane = desired; - for (int distance = 0; ; distance++) { - if (fits(cells, occupied, desired + distance)) { - lane = desired + distance; - break; - } - if (fits(cells, occupied, desired - distance)) { - lane = desired - distance; - break; - } - } - for (var cell : cells.entrySet()) - for (int offset : cell.getValue()) - occupied.computeIfAbsent(cell.getKey(), ignored -> new Occupancy()) - .add(lane + offset); - for (Node node : chain) lanes.put(node, lane); - } - } - int minimum = lanes.values().stream().mapToInt(Integer::intValue).min().orElse(0); - for (Node node : nodes) { - Node root = representative(node); - int index = node.grid == null ? 0 : node.grid.members.indexOf(node); - node.y = 24 + (lanes.get(root) - minimum) * 32 + (chainRows.get(root) - rows(root)) * 12 + index / 3 * 24; - } - packComponents(); - } - - private record Block(List members, int width, int height) {} - - private record Shelf(int top, int height, int right) {} - - private void packComponents() { - var neighbors = new HashMap>(); - for (Edge edge : edges) { - neighbors.computeIfAbsent(edge.from, ignored -> new ArrayList<>()).add(edge.to); - neighbors.computeIfAbsent(edge.to, ignored -> new ArrayList<>()).add(edge.from); - } - var visited = new HashSet(); - var blocks = new ArrayList(); - for (Node start : nodes) { - if (!visited.add(start)) continue; - var members = new ArrayList(); - var queue = new ArrayDeque(); - queue.add(start); - while (!queue.isEmpty()) { - Node node = queue.removeFirst(); - members.add(node); - for (Node neighbor : neighbors.getOrDefault(node, List.of())) - if (visited.add(neighbor)) queue.addLast(neighbor); - } - var widths = new java.util.TreeMap(); - for (Node node : members) { - Node root = representative(node); - int size = root.grid == null ? 24 : Math.min(3, root.grid.members.size()) * 24; - widths.merge(root.layer, size, Math::max); - } - var positions = new HashMap(); - int x = 12; - for (var column : widths.entrySet()) { - positions.put(column.getKey(), x); - x += column.getValue() + 20; - } - // Remove empty strips without changing a grid's cell spacing or a chain's alignment. - var intervals = members.stream() - .map(node -> new int[] {node.y - 14, node.y + 14}) - .sorted(Comparator.comparingInt(interval -> interval[0])) - .toList(); - var shifts = new java.util.TreeMap(); - int bottom = intervals.get(0)[0], removed = 0; - for (int[] interval : intervals) { - removed += Math.max(0, interval[0] - bottom - 4); - shifts.put(interval[0], removed); - bottom = Math.max(bottom, interval[1]); - } - for (Node node : members) { - Node root = representative(node); - int index = node.grid == null ? 0 : node.grid.members.indexOf(node); - node.x = positions.get(root.layer) + index % 3 * 24; - node.y -= shifts.floorEntry(node.y).getValue(); - } - int top = members.stream().mapToInt(node -> node.y - 14).min().orElseThrow(); - int width = members.stream().mapToInt(node -> node.x + 12).max().orElseThrow(); - int height = members.stream().mapToInt(node -> node.y + 14).max().orElseThrow() - top; - members.forEach(node -> node.y -= top); - blocks.add(new Block(members, width, height)); - } - blocks.sort(Comparator.comparingInt(block -> -block.height) - .thenComparingInt(block -> -block.width) - .thenComparing(block -> block.members.get(0).key)); - long area = blocks.stream() - .mapToLong(block -> (long) (block.width + 16) * (block.height + 16)) - .sum(); - int target = Math.max(blocks.stream().mapToInt(Block::width).max().orElse(0), (int) Math.ceil(Math.sqrt(area))); - var shelves = new ArrayList(); - int bottom = 10; - for (Block block : blocks) { - int selected = -1; - for (int index = 0; index < shelves.size(); index++) { - Shelf shelf = shelves.get(index); - if (block.height <= shelf.height && shelf.right + block.width <= target) { - selected = index; - break; - } - } - if (selected < 0) { - selected = shelves.size(); - shelves.add(new Shelf(bottom, block.height, 0)); - bottom += block.height + 16; - } - Shelf shelf = shelves.get(selected); - block.members.forEach(node -> { - node.x += shelf.right + 12; - node.y += shelf.top; - }); - shelves.set(selected, new Shelf(shelf.top, shelf.height, shelf.right + block.width + 16)); - } - } - - private static boolean fits(Map> cells, Map occupied, int lane) { - for (var cell : cells.entrySet()) { - Occupancy values = occupied.get(cell.getKey()); - if (values != null) for (int offset : cell.getValue()) if (values.contains(lane + offset)) return false; - } - return true; - } - - private static String family(Node start, Map> neighbors) { - if (!start.machine()) return start.port().semanticIdentity(); - return neighbors.getOrDefault(start, List.of()).stream() - .filter(node -> !node.machine()) - .map(node -> node.port().semanticIdentity()) - .sorted() - .findFirst() - .orElse(start.key); - } - - private int chainLength(Node start) { - int count = 0; - for (Node node = start; node != null; node = next.get(node)) count++; - return count; - } - - private void route() { - for (Edge edge : edges) { - Node from = edge.from, to = edge.to; - edge.path = List.of( - new Point( - from.grid == null ? from.x + 12 : from.grid.right(), - from.grid == null ? from.y : from.grid.centerY()), - new Point( - to.grid == null ? to.x - 12 : to.grid.left(), to.grid == null ? to.y : to.grid.centerY())); - } - width = nodes.stream().mapToInt(node -> node.x + 24).max().orElse(48); - height = nodes.stream().mapToInt(node -> node.y + 24).max().orElse(48); - } -} diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java b/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java deleted file mode 100644 index df1ccfab5..000000000 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessPanel.java +++ /dev/null @@ -1,522 +0,0 @@ -package gregtech.client; - -import com.mojang.math.Axis; -import gregtech.client.MaterialProcessOverview.Node; -import gregtech.compat.common.MaterialProcessDisplay.Page; -import gregtech.compat.common.MaterialProcessDisplay.Port; -import gregtech.compat.common.PreviewViewport; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.ItemStack; - -/** A readable viewport onto the cached topology layout and its native port instances. */ -public final class MaterialProcessPanel { - public static final int WIDTH = 280, HEIGHT = 216; - private static final int BODY_TOP = 17; - private static final int TEXT = 0xff383838, MUTED = 0xff777777, GOLD = 0xffffcc44; - private static final double MIN_ZOOM = 0.0001, MAX_ZOOM = 3; - private final Page page; - private final MaterialProcessOverview overview; - private Node focused, hovered; - private Set highlight = Set.of(); - private int width = WIDTH, height = HEIGHT; - private boolean fullscreen; - private double zoom, panX, panY; - - public MaterialProcessPanel(Page page) { - this.page = page; - overview = new MaterialProcessOverview(page); - resetView(); - } - - public void focus(Predicate matches) { - focused = overview.find(matches); - resetView(); - } - - public static int preferredWidth() { - return Math.max(200, Minecraft.getInstance().getWindow().getGuiScaledWidth() - 160); - } - - public static int preferredHeight() { - return Math.max(80, Minecraft.getInstance().getWindow().getGuiScaledHeight() - 110); - } - - public int width() { - return width; - } - - public int height() { - return height; - } - - private int footer() { - return height - 13; - } - - /** Resizing keeps the same world point at the center, including when entering or leaving fullscreen. */ - public void resize(int width, int height) { - int nextWidth = Math.max(160, width), nextHeight = Math.max(64, height); - panX += (nextWidth - this.width) / 2.0; - panY += (nextHeight - this.height) / 2.0; - this.width = nextWidth; - this.height = nextHeight; - } - - void fullscreen(boolean fullscreen) { - this.fullscreen = fullscreen; - } - - Component title() { - return page.title(); - } - - public PreviewViewport.Bounds boundsAt(double x, double y) { - Node node = hit(x, y); - return node == null ? new PreviewViewport.Bounds(0, 0, 0, 0) : bounds(node); - } - - private void drawFullscreenButton(GuiGraphics graphics) { - int x = width - 16, y = 3; - for (int dx : new int[] {0, 8}) - for (int dy : new int[] {0, 8}) { - graphics.fill(x + dx, y + dy, x + dx + 4, y + dy + 1, TEXT); - graphics.fill( - x + dx + (dx == 0 ? 0 : 3), - y + (dy == 0 ? 0 : dy - 3), - x + dx + (dx == 0 ? 1 : 4), - y + (dy == 0 ? 4 : dy + 1), - TEXT); - } - } - - private static void outline(GuiGraphics graphics, int left, int top, int right, int bottom, int color) { - graphics.fill(left, top, right, top + 1, color); - graphics.fill(left, bottom - 1, right, bottom, color); - graphics.fill(left, top, left + 1, bottom, color); - graphics.fill(right - 1, top, right, bottom, color); - } - - public void draw(GuiGraphics graphics, double mouseX, double mouseY) { - graphics.fill(0, 0, width, height, 0xffc6c6c6); - text(graphics, page.title(), 4, 2, width - 148, TEXT); - text(graphics, Component.literal("−"), width - 138, 2, 12, TEXT); - text( - graphics, - Component.literal(java.math.BigDecimal.valueOf(zoom * 100) - .setScale(zoom < 0.01 ? 2 : 0, java.math.RoundingMode.HALF_UP) - .stripTrailingZeros() - .toPlainString() - + "%"), - width - 120, - 2, - 33, - MUTED); - text(graphics, Component.literal("+"), width - 82, 2, 12, TEXT); - text(graphics, Component.translatable("gt6ce.jei.material_process.reset"), width - 58, 2, 35, MUTED); - drawFullscreenButton(graphics); - graphics.flush(); - var viewport = PreviewViewport.screenBounds(graphics.pose().last().pose(), 0, BODY_TOP, width, footer()); - graphics.enableScissor(viewport.left(), viewport.top(), viewport.right(), viewport.bottom()); - Node hit = hit(mouseX, mouseY); - if (hit != hovered) { - hovered = hit; - highlight = overview.matchingNodes(hovered); - } - try { - graphics.pose().pushPose(); - try { - graphics.pose().translate(panX, BODY_TOP + panY, 0); - graphics.pose().scale((float) zoom, (float) zoom, 1); - for (var band : overview.bands()) { - graphics.fill(band.left() + 2, 2, band.right() - 2, 24, 0xffb8b8b8); - text(graphics, band.section().label(), band.left() + 6, 8, band.right() - band.left() - 12, TEXT); - if (band.left() > 0) graphics.fill(band.left(), 2, band.left() + 1, overview.height(), 0xff999999); - } - for (var frame : overview.frames()) { - graphics.fill(frame.left(), frame.top(), frame.right(), frame.bottom(), 0xffcacaca); - outline(graphics, frame.left(), frame.top(), frame.right(), frame.bottom(), 0xffe4e4e4); - } - drawEdges(graphics); - if (!overview.information().isEmpty()) { - var first = overview.information().get(0); - var hoveredInformation = informationHit(mouseX, mouseY); - text( - graphics, - Component.translatable("gt6ce.jei.material_process.information"), - first.left(), - first.top() - 12, - 152, - MUTED); - for (var card : overview.information()) { - if (card.right() < worldX(0) - || card.left() > worldX(width) - || card.bottom() < worldY(BODY_TOP) - || card.top() > worldY(footer())) continue; - boolean hover = card == hoveredInformation; - graphics.fill( - card.left(), card.top(), card.right(), card.bottom(), hover ? 0xffe0d6b5 : 0xffcfcbc0); - outline(graphics, card.left(), card.top(), card.right(), card.bottom(), 0xff9c9274); - if (!card.information().icon().isEmpty()) - graphics.renderItem(card.information().icon(), card.left() + 4, card.top() + 4); - text(graphics, card.information().name(), card.left() + 24, card.top() + 7, 122, TEXT); - } - } - for (var grid : overview.grids()) { - graphics.fill(grid.left(), grid.top(), grid.right(), grid.bottom(), 0xff777777); - for (int y = grid.top(); y < grid.bottom(); y += 24) - for (int x = grid.left(); x < grid.right(); x += 24) - graphics.fill(x + 1, y + 1, x + 23, y + 23, 0xffb0b0b0); - } - for (Node node : overview.nodes()) { - if (!visible(node)) continue; - if (highlight.contains(node)) - graphics.fill(node.x - 11, node.y - 11, node.x + 12, node.y + 12, 0xffe4e4e4); - if (node == focused) { - outline(graphics, node.x - 13, node.y - 13, node.x + 14, node.y + 14, 0xffa7dba0); - outline(graphics, node.x - 12, node.y - 12, node.x + 13, node.y + 13, 0xffbce7b6); - } - ItemStack icon = - node.machine() ? selected(node).icon() : node.port().icon(); - if (icon.isEmpty()) text(graphics, Component.literal("?"), node.x - 3, node.y - 4, 10, MUTED); - else graphics.renderItem(icon, node.x - 8, node.y - 8); - if (!node.machine()) { - smallText(graphics, node.quantityBadge(), node.x + 10, node.y + 3, 0xffffffff, true); - smallText(graphics, node.chanceBadge(), node.x - 10, node.y - 10, GOLD, false); - } - if (node.machine() && node.extra()) smallText(graphics, "+", node.x + 9, node.y - 12, GOLD, false); - if (!node.machine() && (node.copy || node.returning)) - smallText(graphics, node.returning ? "↩" : "↗", node.x + 8, node.y - 12, MUTED, false); - } - } finally { - graphics.pose().popPose(); - } - } finally { - graphics.flush(); - graphics.disableScissor(); - } - if (overview.nodes().isEmpty() && overview.information().isEmpty()) - graphics.drawWordWrap( - Minecraft.getInstance().font, - Component.translatable("gt6ce.jei.material_process.empty"), - 12, - BODY_TOP + 28, - width - 24, - MUTED); - text(graphics, Component.literal("i"), 4, footer() + 3, 12, MUTED); - } - - private gregtech.compat.common.MaterialProcessDisplay.Step selected(Node node) { - return node.steps.get(0); - } - - private boolean visible(Node node) { - return node.x + 12 >= worldX(0) - && node.x - 12 <= worldX(width) - && node.y + 12 >= worldY(BODY_TOP) - && node.y - 14 <= worldY(footer()); - } - - private Node hit(double mouseX, double mouseY) { - if (mouseX < 0 || mouseX >= width || mouseY < BODY_TOP || mouseY >= footer()) return null; - double x = worldX(mouseX), y = worldY(mouseY); - for (Node node : overview.nodes()) - if (x >= node.x - 11 && x < node.x + 12 && y >= node.y - 12 && y < node.y + 12) return node; - return null; - } - - private MaterialProcessOverview.InformationCard informationHit(double mouseX, double mouseY) { - if (mouseX < 0 || mouseX >= width || mouseY < BODY_TOP || mouseY >= footer()) return null; - double x = worldX(mouseX), y = worldY(mouseY); - for (var card : overview.information()) - if (x >= card.left() && x < card.right() && y >= card.top() && y < card.bottom()) return card; - return null; - } - - public List stacksAt(double mouseX, double mouseY) { - Node node = hit(mouseX, mouseY); - return node == null ? List.of() : stacks(node); - } - - public List nodes() { - return overview.nodes(); - } - - public PreviewViewport.Bounds bounds(Node node) { - return new PreviewViewport.Bounds( - (int) Math.max(0, Math.floor(panX + (node.x - 11) * zoom)), - (int) Math.max(BODY_TOP, Math.floor(BODY_TOP + panY + (node.y - 12) * zoom)), - (int) Math.min(width, Math.ceil(panX + (node.x + 12) * zoom)), - (int) Math.min(footer(), Math.ceil(BODY_TOP + panY + (node.y + 12) * zoom))); - } - - public List stacks(Node node) { - if (!page.navigation().valid()) return List.of(); - if (node.machine()) - return selected(node).icon().isEmpty() - ? List.of() - : List.of(selected(node).icon()); - return node.port().hasIcons() ? List.of(node.port().icon()) : List.of(); - } - - public List tooltip(double mouseX, double mouseY) { - if (mouseY >= 0 && mouseY < BODY_TOP && mouseX >= width - 144) - return List.of(Component.translatable( - mouseX >= width - 20 - ? fullscreen - ? "gt6ce.jei.material_process.exit_fullscreen" - : "gt6ce.jei.material_process.fullscreen" - : mouseX >= width - 63 - ? "gt6ce.jei.material_process.reset_hint" - : "gt6ce.jei.material_process.zoom_hint")); - if (mouseY >= footer()) { - var lines = new ArrayList<>(page.notices()); - lines.add(Component.translatable("gt6ce.jei.material_process.pan")); - return List.copyOf(lines); - } - var information = informationHit(mouseX, mouseY); - if (information != null) { - var lines = new ArrayList(); - lines.add(information.information().name()); - lines.addAll(information.information().details()); - lines.add(Component.translatable("gt6ce.jei.material_process.open_information")); - return List.copyOf(lines); - } - Node node = hit(mouseX, mouseY); - if (node == null) return List.of(); - ItemStack icon = node.machine() ? selected(node).icon() : node.port().icon(); - Component name = icon.isEmpty() - ? (node.machine() ? selected(node).name() : node.port().name()) - : icon.getHoverName(); - if (!node.machine()) { - List> variants = node.badgePorts().stream() - .map(port -> List.of( - port.amount(), - port.chance().isPresent() - ? Component.translatable( - "gt6ce.jei.chance", port.chance().getAsInt() / 100.0) - : Component.translatable("gt6ce.jei.material_process.chance_unknown"))) - .distinct() - .toList(); - if (variants.size() <= 1) return List.of(name); - var lines = new ArrayList(); - lines.add(name); - variants.forEach(lines::addAll); - return List.copyOf(lines); - } - if (!node.extra() || worldX(mouseX) < node.x + 6 || worldY(mouseY) > node.y - 6) return List.of(name); - var lines = new ArrayList(); - lines.add(name); - if (node.steps.size() > 1) - lines.add(Component.translatable("gt6ce.jei.material_process.variants", node.steps.size())); - var names = new java.util.LinkedHashMap(); - for (var port : node.auxiliaries) { - Component label = port.hasIcons() ? port.icon().getHoverName() : port.name(); - names.putIfAbsent(label.getString(), label); - } - lines.addAll(names.values().stream().limit(12).toList()); - if (names.size() > 12) lines.add(Component.literal("…")); - var step = selected(node); - step.specialProcess().ifPresent(process -> lines.add(process.name())); - lines.addAll(step.details().stream().limit(8).toList()); - return List.copyOf(lines); - } - - public boolean valid() { - return page.navigation().valid(); - } - - public boolean click(double mouseX, double mouseY, int button) { - if (!valid()) return false; - if (clickControls(mouseX, mouseY, button)) return true; - if (button != 0 && button != 1) return false; - Node node = hit(mouseX, mouseY); - if (node == null) return false; - if (!node.machine()) return page.navigation().openPort(node.port(), button == 1); - return page.navigation().openStack(selected(node).icon(), button == 1); - } - - public boolean clickControls(double mouseX, double mouseY, int button) { - if (button != 0 && button != 1) return false; - var information = informationHit(mouseX, mouseY); - if (information != null) - return page.navigation().valid() - && page.navigation() - .openInformation(information.information().reference()); - if (button == 0 && mouseY >= 0 && mouseY < 14) { - if (mouseX >= width - 20 && mouseX < width) { - MaterialProcessScreen.toggle(this); - return true; - } - if (mouseX >= width - 63 && mouseX < width - 22) { - resetView(); - return true; - } - if (mouseX >= width - 144 && mouseX < width - 123) { - zoomAt(width / 2.0, (BODY_TOP + footer()) / 2.0, zoom / 1.25); - return true; - } - if (mouseX >= width - 87 && mouseX < width - 65) { - zoomAt(width / 2.0, (BODY_TOP + footer()) / 2.0, zoom * 1.25); - return true; - } - } - return false; - } - - public boolean press(double mouseX, double mouseY, int button) { - return (button == 0 || button == 1) - && mouseX >= 0 - && mouseX < width - && mouseY >= BODY_TOP - && mouseY < footer() - && informationHit(mouseX, mouseY) == null - && hit(mouseX, mouseY) == null; - } - - public boolean drag(int button, double dx, double dy) { - if (button != 0 && button != 1) return false; - panX += dx; - panY += dy; - return true; - } - - public boolean scroll(double mouseX, double mouseY, double delta) { - if (mouseX < 0 || mouseX >= width || mouseY < BODY_TOP || mouseY >= footer() || delta == 0) return false; - zoomAt(mouseX, mouseY, zoom * Math.pow(1.15, Math.max(-8, Math.min(8, delta)))); - return true; - } - - private double worldX(double x) { - return (x - panX) / zoom; - } - - private double worldY(double y) { - return (y - BODY_TOP - panY) / zoom; - } - - private void zoomAt(double x, double y, double requested) { - double wx = worldX(x), wy = worldY(y); - zoom = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, requested)); - panX = x - wx * zoom; - panY = y - BODY_TOP - wy * zoom; - } - - private void resetView() { - zoom = 1; - Node anchor = focused == null ? overview.anchor() : focused; - if (anchor == null && !overview.information().isEmpty()) { - var first = overview.information().get(0); - panX = width / 2.0 - (first.left() + first.right()) / 2.0; - panY = (footer() - BODY_TOP) / 2.0 - (first.top() + first.bottom()) / 2.0; - return; - } - panX = width / 2.0 - (anchor == null ? overview.width() / 2.0 : anchor.x); - panY = (footer() - BODY_TOP) / 2.0 - (anchor == null ? overview.height() / 2.0 : anchor.y); - } - - private void drawEdges(GuiGraphics graphics) { - record Wire(List path, boolean output) {} - var wires = new java.util.LinkedHashMap>(); - for (var edge : overview.edges()) - wires.computeIfAbsent(new Wire(edge.path(), edge.endpoint().output()), ignored -> new ArrayList<>()) - .add(edge); - for (var entry : wires.entrySet()) { - boolean confirmed = entry.getValue().stream().allMatch(MaterialProcessOverview.Edge::confirmed); - int color = TEXT; - var path = entry.getKey().path(); - for (int index = 1; index < path.size(); index++) { - var from = path.get(index - 1); - var to = path.get(index); - segment( - graphics, - from.x(), - from.y(), - to.x(), - to.y(), - !confirmed, - entry.getKey().output() && index == path.size() - 1, - color); - } - } - } - - private void segment( - GuiGraphics graphics, - double sx, - double sy, - double tx, - double ty, - boolean dashed, - boolean arrow, - int color) { - stroke(graphics, sx, sy, tx, ty, color, dashed); - if (!arrow || tx < worldX(0) || tx >= worldX(width) || ty < worldY(BODY_TOP) || ty >= worldY(footer())) return; - double angle = Math.atan2(ty - sy, tx - sx); - graphics.pose().pushPose(); - try { - graphics.pose().translate(tx, ty, 0); - graphics.pose().mulPose(Axis.ZP.rotationDegrees((float) Math.toDegrees(angle))); - MaterialProcessArrows.head(graphics, color); - } finally { - graphics.pose().popPose(); - } - } - - private static void smallText(GuiGraphics graphics, String value, int x, int y, int color, boolean right) { - if (value.isEmpty()) return; - var font = Minecraft.getInstance().font; - float scale = Math.min(0.65F, 22F / Math.max(1, font.width(value))); - graphics.pose().pushPose(); - graphics.pose().translate(x, y, 200); - graphics.pose().scale(scale, scale, 1); - graphics.drawString(font, value, right ? -font.width(value) : 0, 0, color, true); - graphics.pose().popPose(); - } - - private static void text(GuiGraphics graphics, Component value, int x, int y, int width, int color) { - if (width <= 0) return; - var font = Minecraft.getInstance().font; - graphics.drawString( - font, - net.minecraft.locale.Language.getInstance().getVisualOrder(font.substrByWidth(value, width)), - x, - y, - color, - false); - } - - private void stroke(GuiGraphics graphics, double x1, double y1, double x2, double y2, int color, boolean dashed) { - double dx = x2 - x1, dy = y2 - y1, from = 0, to = 1; - double[] p = {-dx, dx, -dy, dy}, - q = {x1 - worldX(-1), worldX(width + 1) - x1, y1 - worldY(BODY_TOP - 1), worldY(footer() + 1) - y1}; - for (int side = 0; side < 4; side++) { - if (p[side] == 0) { - if (q[side] < 0) return; - } else { - double ratio = q[side] / p[side]; - if (p[side] < 0) from = Math.max(from, ratio); - else to = Math.min(to, ratio); - if (from > to) return; - } - } - double length = Math.hypot(dx, dy), visible = (to - from) * length; - if (visible < 0.1) return; - graphics.pose().pushPose(); - try { - graphics.pose().translate(x1 + from * dx, y1 + from * dy, 0); - graphics.pose().mulPose(Axis.ZP.rotationDegrees((float) Math.toDegrees(Math.atan2(dy, dx)))); - if (!dashed) graphics.fill(0, 0, (int) Math.ceil(visible), 1, color); - else - for (int x = 0; x < visible; x += 6) - graphics.fill(x, 0, Math.min(x + 3, (int) Math.ceil(visible)), 1, color); - } finally { - graphics.pose().popPose(); - } - } -} diff --git a/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java b/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java deleted file mode 100644 index db1110b3a..000000000 --- a/minecraft/src/main/java/gregtech/client/MaterialProcessScreen.java +++ /dev/null @@ -1,123 +0,0 @@ -package gregtech.client; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.renderer.Rect2i; -import net.minecraft.world.item.ItemStack; - -/** Full-window host for the same graph, camera and query target used by the recipe viewer. */ -public final class MaterialProcessScreen extends Screen { - private static final int MARGIN = 6; - private final MaterialProcessPanel panel; - private final Screen parent; - private int dragButton = -1; - - private MaterialProcessScreen(MaterialProcessPanel panel, Screen parent) { - super(panel.title()); - this.panel = panel; - this.parent = parent; - } - - public static void toggle(MaterialProcessPanel panel) { - var client = Minecraft.getInstance(); - if (client.screen instanceof MaterialProcessScreen screen && screen.panel == panel) screen.onClose(); - else client.setScreen(new MaterialProcessScreen(panel, client.screen)); - } - - @Override - protected void init() { - dragButton = -1; - panel.fullscreen(true); - panel.resize(width - MARGIN * 2, height - MARGIN * 2); - } - - @Override - public void removed() { - dragButton = -1; - panel.fullscreen(false); - panel.resize(MaterialProcessPanel.preferredWidth(), MaterialProcessPanel.preferredHeight()); - } - - @Override - public void onClose() { - Minecraft.getInstance().setScreen(parent); - } - - public ItemStack stackAt(double x, double y) { - return panel.stacksAt(x - MARGIN, y - MARGIN).stream().findFirst().orElse(ItemStack.EMPTY); - } - - public Rect2i stackArea(double x, double y) { - var bounds = panel.boundsAt(x - MARGIN, y - MARGIN); - return new Rect2i(MARGIN + bounds.left(), MARGIN + bounds.top(), - Math.max(0, bounds.right() - bounds.left()), Math.max(0, bounds.bottom() - bounds.top())); - } - - @Override - public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - if (!panel.valid()) { - onClose(); - return; - } - graphics.fill(0, 0, width, height, 0xff303030); - graphics.pose().pushPose(); - try { - graphics.pose().translate(MARGIN, MARGIN, 0); - panel.draw(graphics, mouseX - MARGIN, mouseY - MARGIN); - } finally { - graphics.pose().popPose(); - } - var tooltip = panel.tooltip(mouseX - MARGIN, mouseY - MARGIN); -//? if >=1.21.1 { - /*if (!tooltip.isEmpty()) graphics.renderTooltip(font, tooltip, java.util.Optional.empty(), mouseX, mouseY); -*///?} else { - if (!tooltip.isEmpty()) graphics.renderComponentTooltip(font, tooltip, mouseX, mouseY); -//?} - } - - @Override - public boolean mouseClicked(double x, double y, int button) { - if (!panel.valid()) { - onClose(); - return true; - } - if (panel.clickControls(x - MARGIN, y - MARGIN, button)) return true; - if (panel.press(x - MARGIN, y - MARGIN, button)) { - dragButton = button; - return true; - } - return panel.click(x - MARGIN, y - MARGIN, button) || super.mouseClicked(x, y, button); - } - - @Override - public boolean mouseReleased(double x, double y, int button) { - if (dragButton == button) { - dragButton = -1; - return true; - } - return super.mouseReleased(x, y, button); - } - - @Override - public boolean mouseDragged(double x, double y, int button, double dx, double dy) { - return dragButton == button && panel.drag(button, dx, dy) || super.mouseDragged(x, y, button, dx, dy); - } - -//? if >=1.21.1 { - /*@Override - public boolean mouseScrolled(double x, double y, double dx, double dy) { - return panel.scroll(x - MARGIN, y - MARGIN, dy) || super.mouseScrolled(x, y, dx, dy); - } -*///?} else { - @Override - public boolean mouseScrolled(double x, double y, double delta) { - return panel.scroll(x - MARGIN, y - MARGIN, delta) || super.mouseScrolled(x, y, delta); - } -//?} - - @Override - public boolean isPauseScreen() { - return false; - } -} diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java deleted file mode 100644 index b12d0d054..000000000 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessDisplay.java +++ /dev/null @@ -1,572 +0,0 @@ -package gregtech.compat.common; - -import com.mojang.logging.LogUtils; -import gregtech.api.addon.material.DataKey; -import gregtech.api.addon.recipe.RecipeOutputChances; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Objects; -import java.util.OptionalInt; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.ItemStack; -import org.slf4j.Logger; - -/** - * Client presentation values for a material process query. This is not a source index or an execution model. - * No material catalog, native recipe enumeration, or viewer API is accessed here. - */ -public final class MaterialProcessDisplay { - private static final Logger LOGGER = LogUtils.getLogger(); - /** Only limits automatic icon sampling from selectors, never steps, ports or supplied representatives. */ - public static final int MAX_ICONS = 16; - - /** Roles come from the producer; neither slot order nor quantity establishes a primary output. */ - public enum Role { - CONSUMED, - CATALYST, - PRESENCE, - PRIMARY, - BYPRODUCT, - UNKNOWN - } - - /** - * A snapshot-local resource reference, including form and native state. Icons are bounded display representatives, - * not an expansion of a tag or unit family. Empty icons describe a symbolic selector. - * Amount includes its unit; quantity is the producer-supplied compact badge, never parsed from amount. - * Chance uses {@link RecipeOutputChances#CERTAIN}, or is explicitly unknown. - */ - public record Port( - DataKey resource, - String material, - Component name, - List icons, - Role role, - boolean main, - Component amount, - Component quantity, - OptionalInt chance, - List details, - String identity) { - public Port { - Objects.requireNonNull(resource); - Objects.requireNonNull(identity); - if (material == null || material.isBlank()) { - LOGGER.warn("Missing material for process resource {}; retaining it as unknown", resource); - material = "unknown"; - } - name = name.copy(); - amount = amount.copy(); - quantity = quantity.copy(); - Objects.requireNonNull(role); - Objects.requireNonNull(chance); - var validIcons = icons.stream() - .filter(Objects::nonNull) - .filter(stack -> !stack.isEmpty()) - .toList(); - if (validIcons.size() != icons.size()) - LOGGER.warn("Discarded {} empty display icons for {}", icons.size() - validIcons.size(), resource); - icons = validIcons.stream().map(ItemStack::copy).toList(); - if (chance.isPresent() && (chance.getAsInt() < 1 || chance.getAsInt() > RecipeOutputChances.CERTAIN)) { - LOGGER.warn( - "Invalid display chance {} for {}; retaining an unknown chance", chance.getAsInt(), resource); - chance = OptionalInt.empty(); - } - details = copyText(details); - } - - public Port( - DataKey resource, - String material, - Component name, - List icons, - Role role, - boolean main, - Component amount, - Component quantity, - OptionalInt chance, - List details) { - this(resource, material, name, icons, role, main, amount, quantity, chance, details, resource.toString()); - } - - public Port( - DataKey resource, - String material, - Component name, - List icons, - Role role, - boolean main, - Component amount, - OptionalInt chance, - List details) { - this(resource, material, name, icons, role, main, amount, Component.empty(), chance, details); - } - - @Override - public List icons() { - return icons.stream().map(ItemStack::copy).toList(); - } - - public boolean hasIcons() { - return !icons.isEmpty(); - } - - public int iconCount() { - return icons.size(); - } - - public ItemStack icon() { - return icons.isEmpty() ? ItemStack.EMPTY : icons.get(0).copy(); - } - - public List tooltip() { - var lines = new ArrayList(); - lines.add(name); - lines.add(amount); - lines.add(Component.translatable( - "gt6ce.jei.material_process.role." + role.name().toLowerCase(java.util.Locale.ROOT))); - if (isOutput(role)) { - lines.add( - chance.isPresent() - ? Component.translatable("gt6ce.jei.chance", chance.getAsInt() / 100.0) - : Component.translatable("gt6ce.jei.material_process.chance_unknown")); - } - lines.addAll(details); - return List.copyOf(lines); - } - - /** - * Structural identity for topology and folding. Concrete native states compare by display - * identity, while selectors retain their producer-assigned resource key even when their - * first icon is also the representative of another selector. - */ - public String semanticIdentity() { - return resource.path().startsWith("resource/native/selector/") ? resource.toString() : identity; - } - } - - /** Explicit edges from the producer, including branches and cycles. Unconfirmed edges are drawn dashed. */ - public record Connection(DataKey source, DataKey target, DataKey resource, boolean confirmed) { - public Connection { - Objects.requireNonNull(source); - Objects.requireNonNull(target); - Objects.requireNonNull(resource); - } - } - - /** All exact source/target associations for one resource, stored without allocating their cross-product. */ - public record Flow(DataKey resource, List sources, List targets) { - public Flow { - Objects.requireNonNull(resource); - sources = List.copyOf(sources); - targets = List.copyOf(targets); - } - - public long connectionCount() { - return (long) sources.size() * targets.size(); - } - } - - /** All ports belong to one step. Process is the producer's stable category, independent of the translated name. */ - public record Step( - DataKey reference, - Component name, - ItemStack icon, - List inputs, - List outputs, - List details, - java.util.Optional specialProcess, - boolean resolved, - boolean worldGenerated, - boolean genericRecovery, - String process) { - public Step { - Objects.requireNonNull(reference); - name = name.copy(); - icon = icon.copy(); - var validInputs = validPorts(inputs, false, reference); - var validOutputs = validPorts(outputs, true, reference); - resolved &= validInputs.size() == inputs.size() && validOutputs.size() == outputs.size(); - inputs = validInputs; - outputs = validOutputs; - details = copyText(details); - Objects.requireNonNull(specialProcess); - Objects.requireNonNull(process); - } - - @Override - public ItemStack icon() { - return icon.copy(); - } - - public Step( - DataKey reference, - Component name, - ItemStack icon, - List inputs, - List outputs, - List details, - java.util.Optional specialProcess, - boolean resolved, - boolean worldGenerated, - boolean genericRecovery) { - this( - reference, - name, - icon, - inputs, - outputs, - details, - specialProcess, - resolved, - worldGenerated, - genericRecovery, - name.getString()); - } - - public Step( - DataKey reference, - Component name, - ItemStack icon, - List inputs, - List outputs, - List details, - java.util.Optional specialProcess, - boolean resolved, - boolean worldGenerated) { - this(reference, name, icon, inputs, outputs, details, specialProcess, resolved, worldGenerated, false); - } - - public Step( - DataKey reference, - Component name, - ItemStack icon, - List inputs, - List outputs, - List details, - java.util.Optional specialProcess, - boolean resolved) { - this(reference, name, icon, inputs, outputs, details, specialProcess, resolved, false); - } - - public Step( - DataKey reference, - Component name, - List inputs, - List outputs, - List details, - java.util.Optional specialProcess, - boolean resolved) { - this(reference, name, ItemStack.EMPTY, inputs, outputs, details, specialProcess, resolved, false); - } - - public Step( - DataKey reference, - Component name, - List inputs, - List outputs, - List details, - boolean resolved) { - this( - reference, - name, - ItemStack.EMPTY, - inputs, - outputs, - details, - java.util.Optional.empty(), - resolved, - false); - } - } - - /** Categories describe consumed material flow; catalysts and presence conditions cannot establish it. */ - public enum Section { - SOURCES("gt6ce.jei.material_process.section.sources"), - INTERNAL("gt6ce.jei.material_process.section.internal"), - RECOVERY("gt6ce.jei.material_process.section.recovery"), - USES("gt6ce.jei.material_process.section.uses"); - - private final String label; - - Section(String label) { - this.label = label; - } - - public Component label() { - return Component.translatable(label); - } - } - - public static java.util.Optional
section(Step step, String material) { - if (step.genericRecovery()) return java.util.Optional.of(Section.RECOVERY); - boolean input = step.inputs().stream() - .anyMatch( - port -> port.role() == Role.CONSUMED && port.material().equals(material)); - boolean output = - step.outputs().stream().anyMatch(port -> port.material().equals(material)); - if (input && output) return java.util.Optional.of(Section.INTERNAL); - boolean otherInput = step.inputs().stream() - .anyMatch( - port -> port.role() == Role.CONSUMED && !port.material().equals(material)); - if (output && !input && (step.worldGenerated() || otherInput)) return java.util.Optional.of(Section.SOURCES); - boolean otherOutput = - step.outputs().stream().anyMatch(port -> !port.material().equals(material)); - if (input && !output && otherOutput) return java.util.Optional.of(Section.USES); - return java.util.Optional.empty(); - } - - /** Stable method identity plus its translated display name. */ - public record SpecialProcess(DataKey id, Component name) { - public SpecialProcess { - Objects.requireNonNull(id); - name = name.copy(); - } - } - - /** Related viewer pages are navigation targets, with no processing ports or graph edges. */ - public record Information( - DataKey reference, Component name, ItemStack icon, List details, List index) { - public Information { - Objects.requireNonNull(reference); - name = name.copy(); - icon = icon.copy(); - details = copyText(details); - index = List.copyOf(index); - } - - @Override - public ItemStack icon() { - return icon.copy(); - } - } - - /** - * Bind callbacks to the same query session/generation as the page. Revalidate before resolving native references; - * return false for expired or unsupported targets. Implementations run on the client thread. - */ - public interface Navigation { - default boolean valid() { - return true; - } - - Navigation NONE = new Navigation() { - @Override - public boolean openForm(DataKey resource, boolean uses) { - return false; - } - }; - - default boolean openPort(Port port, boolean uses) { - return port.hasIcons() && openStack(port.icon(), uses); - } - - default boolean openStack(ItemStack stack, boolean uses) { - return false; - } - - default boolean openInformation(DataKey reference) { - return false; - } - - boolean openForm(DataKey resource, boolean uses); - } - - /** Coverage and truncation reasons are always visible through the footer tooltip, including for empty queries. */ - public record Page( - Component title, - String material, - List steps, - List connections, - List notices, - int number, - int total, - Navigation navigation, - List information, - List flows) { - public Page { - title = title.copy(); - material = Objects.requireNonNullElse(material, ""); - int suppliedSteps = steps.size(), suppliedConnections = connections.size(), suppliedFlows = flows.size(); - steps = validSteps(steps); - var ports = new PortIndex(steps); - connections = validConnections(connections, ports); - flows = validFlows(flows, ports); - notices = copyText(notices); - if (notices.isEmpty()) - notices = List.of(Component.translatable("gt6ce.jei.material_process.partial_unknown")); - int discarded = suppliedSteps - - steps.size() - + suppliedConnections - - connections.size() - + suppliedFlows - - flows.size(); - if (discarded > 0) { - var coverage = new ArrayList<>(notices); - coverage.add(Component.translatable("gt6ce.jei.material_process.coverage.invalid_data", discarded)); - notices = List.copyOf(coverage); - } - information = List.copyOf(information); - Objects.requireNonNull(navigation); - number = Math.max(1, number); - total = Math.max(number, total); - } - - public Page( - Component title, - String material, - List steps, - List connections, - List notices, - int number, - int total, - Navigation navigation, - List information) { - this(title, material, steps, connections, notices, number, total, navigation, information, List.of()); - } - - public Page( - Component title, - String material, - List steps, - List connections, - List notices, - int number, - int total, - Navigation navigation) { - this(title, material, steps, connections, notices, number, total, navigation, List.of()); - } - - public Page withInformation(List information) { - return new Page( - title, material, steps, connections, notices, number, total, navigation, information, flows); - } - - /** Foreign reagents and byproducts belong to the recipe, not to this material's viewer index. */ - public List indexedPorts() { - return java.util.stream.Stream.concat( - steps.stream() - .flatMap(step -> java.util.stream.Stream.concat( - step.inputs().stream(), step.outputs().stream())), - information.stream().flatMap(entry -> entry.index().stream())) - .filter(port -> port.material().equals(material) && port.hasIcons()) - .toList(); - } - } - - private MaterialProcessDisplay() {} - - /** Build one material page without dropping steps. Panning belongs to the viewer, not to data paging. */ - public static List pages( - Component title, - String material, - List steps, - List connections, - List notices, - Navigation navigation) { - return List.of(new Page(title, material, steps, connections, notices, 1, 1, navigation)); - } - - public static List unbound() { - return pages( - Component.translatable("gt6ce.jei.material_process.title"), - "", - List.of(), - List.of(), - List.of(Component.translatable("gt6ce.jei.material_process.unbound")), - Navigation.NONE); - } - - private static boolean isOutput(Role role) { - return role == Role.PRIMARY || role == Role.BYPRODUCT || role == Role.UNKNOWN; - } - - private static List validPorts(List ports, boolean output, DataKey reference) { - var valid = ports.stream() - .filter(Objects::nonNull) - .filter(port -> isOutput(port.role()) == output) - .toList(); - if (valid.size() != ports.size()) - LOGGER.warn( - "Discarded {} invalid {} ports for {}", - ports.size() - valid.size(), - output ? "output" : "input", - reference); - return valid; - } - - private static List validSteps(List steps) { - var references = new LinkedHashMap(); - for (Step step : steps) { - if (step == null) { - LOGGER.warn("Discarded null material process step"); - } else if (references.putIfAbsent(step.reference(), step) != null) { - LOGGER.warn("Discarded duplicate material process step {}", step.reference()); - } - } - return List.copyOf(references.values()); - } - - private static final class PortIndex { - private final java.util.Map> inputs = new HashMap<>(), - outputs = new HashMap<>(); - - private PortIndex(List steps) { - for (Step step : steps) { - inputs.put(step.reference(), resources(step.inputs())); - outputs.put(step.reference(), resources(step.outputs())); - } - } - - private boolean contains(DataKey step, DataKey resource, boolean output) { - return (output ? outputs : inputs) - .getOrDefault(step, java.util.Set.of()) - .contains(resource); - } - } - - private static List validConnections(List connections, PortIndex ports) { - var unique = new HashSet(); - var valid = new ArrayList(); - for (Connection connection : connections) { - if (connection == null - || !ports.contains(connection.source(), connection.resource(), true) - || !ports.contains(connection.target(), connection.resource(), false)) { - LOGGER.warn("Discarded material process connection with missing endpoint ports: {}", connection); - } else if (unique.add(connection)) valid.add(connection); - } - return List.copyOf(valid); - } - - private static List validFlows(List flows, PortIndex ports) { - var valid = new ArrayList(); - for (Flow flow : flows) { - var sources = flow.sources().stream() - .filter(source -> ports.contains(source, flow.resource(), true)) - .distinct() - .toList(); - var targets = flow.targets().stream() - .filter(target -> ports.contains(target, flow.resource(), false)) - .distinct() - .toList(); - if (sources.size() != flow.sources().size() - || targets.size() != flow.targets().size()) - LOGGER.warn("Discarded invalid material process flow endpoints for {}", flow.resource()); - if (!sources.isEmpty() && !targets.isEmpty()) valid.add(new Flow(flow.resource(), sources, targets)); - } - return List.copyOf(valid); - } - - private static java.util.Set resources(List ports) { - var result = new HashSet(); - ports.forEach(port -> result.add(port.resource())); - return result; - } - - private static List copyText(List lines) { - return lines.stream().map(line -> (Component) line.copy()).toList(); - } -} diff --git a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java b/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java deleted file mode 100644 index 2f38723cd..000000000 --- a/minecraft/src/main/java/gregtech/compat/common/MaterialProcessProjection.java +++ /dev/null @@ -1,412 +0,0 @@ -package gregtech.compat.common; - -import com.mojang.logging.LogUtils; -import gregtech.api.addon.material.DataKey; -import gregtech.api.addon.material.MaterialCatalogView; -import gregtech.api.addon.material.MaterialKey; -import gregtech.api.addon.material.MaterialView; -import gregtech.content.recipe.MaterialProcessSnapshot; -import gregtech.engine.material.MaterialProcessGraph; -import gregtech.engine.material.MaterialProcessGraph.AmountUnit; -import gregtech.engine.material.MaterialProcessGraph.Notice; -import gregtech.engine.material.MaterialProcessGraph.Port; -import gregtech.engine.material.MaterialProcessGraph.Resource; -import gregtech.engine.material.MaterialProcessGraph.Step; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Optional; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.material.Fluid; -//? if >=1.21.1 { -/*import net.neoforged.neoforge.fluids.FluidStack; -*///?} else { -import net.minecraftforge.fluids.FluidStack; -//?} - -/** Converts one material-local semantic query into native viewer values. */ -public final class MaterialProcessProjection { - private static final org.slf4j.Logger LOGGER = LogUtils.getLogger(); - - private MaterialProcessProjection() {} - - public static List initialPages( - MaterialProcessSnapshot snapshot, MaterialProcessDisplay.Navigation navigation) { - var pages = new ArrayList(); - var workstations = RecipeViewerIcons.categories(); - for (MaterialProcessSnapshot.Root root : snapshot.roots()) { - var rootPages = pages(snapshot, root.resource(), navigation, workstations); - pages.addAll(rootPages); - } - return pages.isEmpty() ? MaterialProcessDisplay.unbound() : List.copyOf(pages); - } - - public static List pages( - MaterialProcessSnapshot snapshot, - DataKey root, - MaterialProcessDisplay.Navigation navigation) { - return pages(snapshot, root, navigation, RecipeViewerIcons.categories()); - } - - private record IndexPort(DataKey resource, MaterialProcessGraph.Role role) {} - - /** Viewer registration needs unique material resource/role representatives, without any graph or layout. */ - public static List indexedPorts(MaterialProcessSnapshot snapshot, DataKey root) { - Resource resource = snapshot.resource(root).orElse(null); - if (resource == null) return List.of(); - var ports = new java.util.LinkedHashMap(); - for (Step step : snapshot.materialSteps(root)) { - var recipe = snapshot.recipe(step.reference()).orElse(null); - for (List side : List.of(step.inputs(), step.outputs())) - for (Port port : side) { - if (!port.resource().material().equals(resource.material())) continue; - var key = new IndexPort(port.resource().key(), port.role()); - var existing = ports.get(key); - if (existing != null && existing.hasIcons()) continue; - try { - ports.put(key, port(snapshot, port, recipe)); - } catch (RuntimeException failure) { - LOGGER.warn("Discarded invalid material process index resource {}", port.resource().key(), failure); - } - } - } - return List.copyOf(ports.values()); - } - - public static MaterialProcessDisplay.Page informationPage(String material, - List information, MaterialProcessDisplay.Navigation navigation) { - return new MaterialProcessDisplay.Page( - Component.translatable("gt6ce.jei.material_process.material_title", materialName(material)), material, - List.of(), List.of(), List.of(Component.translatable("gt6ce.jei.material_process.information_hint")), - 1, 1, navigation, information); - } - - private static List pages( - MaterialProcessSnapshot snapshot, - DataKey root, - MaterialProcessDisplay.Navigation navigation, - java.util.Map workstations) { - var query = snapshot.queryMaterial(root, MaterialProcessGraph.Budgets.MATERIAL_PAGE); - var steps = new ArrayList(); - for (Step step : query.steps()) { - try { - steps.add(step(snapshot, step, workstations)); - } catch (RuntimeException failure) { - LOGGER.warn("Discarded invalid material process display step {}", step.reference(), failure); - } - } - List flows = List.of(); - var connections = query.edges().stream() - .map(edge -> new MaterialProcessDisplay.Connection( - edge.source(), edge.target(), edge.resource(), edge.confirmed())) - .toList(); - List notices = new ArrayList<>(query.notices().stream().map(MaterialProcessProjection::notice).toList()); - if (steps.size() != query.steps().size()) - notices.add(Component.translatable("gt6ce.jei.material_process.coverage.invalid_data", query.steps().size() - steps.size())); - if (notices.isEmpty()) notices = List.of(Component.translatable("gt6ce.jei.material_process.partial_unknown")); - Resource resource = snapshot.resource(query.root()).orElse(null); - Component title = title(query.root(), resource); - String material = resource == null ? "" : resource.material(); - return List.of(new MaterialProcessDisplay.Page( - title, material, steps, connections, notices, 1, 1, navigation, List.of(), flows)); - } - - private static MaterialProcessDisplay.Step step(MaterialProcessSnapshot snapshot, Step step, - java.util.Map workstations) { - Optional specialProcess = step.specialProcess() - .flatMap(id -> specialMethod(id).map(method -> new MaterialProcessDisplay.SpecialProcess( - id, Component.translatable(method.displayNameKey())))); - return new MaterialProcessDisplay.Step( - step.reference(), - Component.literal(step.name()), - snapshot.recipe(step.reference()) - .map(recipe -> workstations.getOrDefault(recipe.map(), new ItemStack(net.minecraft.world.item.Items.ANVIL))) - .orElseGet(() -> snapshot.worldgen(step.reference()).isPresent() - ? new ItemStack(net.minecraft.world.item.Items.IRON_PICKAXE) : snapshot.viewerMachine(step.reference())), - step.inputs().stream().map(port -> port(snapshot, port, snapshot.recipe(step.reference()).orElse(null))).toList(), - step.outputs().stream().map(port -> port(snapshot, port, snapshot.recipe(step.reference()).orElse(null))).toList(), - step.details().stream().map(MaterialProcessProjection::literal).toList(), - specialProcess, - step.resolved(), - snapshot.worldgen(step.reference()).isPresent(), - snapshot.recipe(step.reference()) - .map(MaterialProcessSnapshot.NativeRecipe::genericRecovery) - .orElse(false), - snapshot.process(step.reference())); - } - - private static Optional specialMethod( - DataKey id) { - MaterialCatalogView catalog; - try { - catalog = gregtech.engine.material.MaterialViews.catalog(); - } catch (IllegalStateException notReady) { - return Optional.empty(); - } - return catalog.specialProcesses().find(id); - } - - private static MaterialProcessDisplay.Port port(MaterialProcessSnapshot snapshot, Port port, MaterialProcessSnapshot.NativeRecipe nativeRecipe) { - List icons = snapshot.viewerIcons(port.resource().key()); - if (icons.isEmpty()) icons = nativeIcons(port.resource(), nativeRecipe); - String identity = port.resource().state(); - if (!icons.isEmpty()) { - ItemStack representative = icons.get(0); - if (gregtech.engine.fluid.FluidDisplayBinding.hasPayload(representative)) { -//? if >=1.21.1 { - /*var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolveCurrent(representative); -*///?} else { - var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolve(representative); -//?} - if (!fluid.isEmpty()) identity = MaterialProcessSnapshot.fluidDisplayState(fluid); - } else identity = MaterialProcessSnapshot.itemDisplayState(representative); - } - return new MaterialProcessDisplay.Port( - port.resource().key(), - port.resource().material(), - name(port.resource()), - icons, - role(port.role()), - port.main(), - amount(port.amount().value(), port.amount().unit()), - quantity(port.amount().value(), port.amount().unit()), - port.chance(), - port.details().stream().map(MaterialProcessProjection::literal).toList(), - identity); - } - - private static Component title(DataKey root, Resource resource) { - String material = resource == null ? pathMaterial(root) : resource.material(); - return Component.translatable("gt6ce.jei.material_process.material_title", materialName(material)); - } - - private static String pathMaterial(DataKey key) { - String[] path = key.path().split("/"); - return path.length > 2 ? path[2].replace('_', ' ') : "unknown"; - } - - private static Component name(Resource resource) { - String form = switch (resource.form()) { - case "ore" -> "ore"; - case "oreRaw" -> "raw"; - case "crushed" -> "crushed"; - case "unit" -> "unit"; - case "fluid" -> resource.phase(); - default -> resource.form(); - }; - return Component.translatable( - "gt6ce.jei.material_process.port_name", materialName(resource.material()), form); - } - - private static Component materialName(String material) { - MaterialCatalogView catalog; - try { - catalog = gregtech.engine.material.MaterialViews.catalog(); - } catch (IllegalStateException notReady) { - return Component.literal(material); - } - Optional view = catalog.find(new MaterialKey(material)); - if (view.isEmpty()) return Component.literal(material); - return Component.translatable(view.get().info().translationKey()); - } - - private static Component literal(String value) { - return Component.literal(value); - } - - private static List nativeIcons(Resource resource, MaterialProcessSnapshot.NativeRecipe row) { - String state = resource.state(); - if (row != null) { - var recipe = row.recipe(); - if (state.startsWith("tag:")) { - String tag = state.substring("tag:".length()); - if (resource.form().equals("fluid")) { - for (int index = 0; index < recipe.mFluidInputs.length; index++) { - var key = recipe.fluidTag(index); - var stack = recipe.mFluidInputs[index]; - if (key != null && key.location().toString().equals(tag) && stack != null && !stack.isEmpty() - && MaterialProcessSnapshot.fluidDisplayState(stack).contains("#")) { - var display = fluidDisplay(stack); - return display.isEmpty() ? List.of() : List.of(display); - } - } - } else { - for (int index = 0; index < recipe.mInputs.length; index++) { - var key = recipe.itemTag(index); - var stack = recipe.mInputs[index]; - if (key != null && key.location().toString().equals(tag) && stack != null && !stack.isEmpty() - && MaterialProcessSnapshot.itemDisplayState(stack).contains("#")) - return List.of(stack.copyWithCount(1)); - } - } - } - if (state.startsWith("fluid:")) { - for (FluidStack stack : java.util.stream.Stream.concat( - java.util.Arrays.stream(recipe.mFluidInputs), java.util.Arrays.stream(recipe.mFluidOutputs)).toList()) - if (stack != null && !stack.isEmpty() && MaterialProcessSnapshot.fluidDisplayState(stack).equals(state)) { - ItemStack display = fluidDisplay(stack); - return display.isEmpty() ? List.of() : List.of(display); - } - } - if (state.startsWith("item:") || state.startsWith("unit:")) { - var candidates = new ArrayList(); - candidates.addAll(java.util.Arrays.asList(recipe.mInputs)); - candidates.addAll(java.util.Arrays.asList(recipe.mOutputs)); - if (state.startsWith("unit:")) - for (int index = 0; index < recipe.mInputs.length; index++) { - var display = recipe.materialInputDisplay(index); - if (display != null) candidates.addAll(display.alternatives()); - } - var result = new ArrayList(); - for (ItemStack stack : candidates) { - if (stack == null || stack.isEmpty()) continue; - boolean matches = state.startsWith("item:") ? MaterialProcessSnapshot.itemDisplayState(stack).equals(state) - : java.util.Arrays.asList(state.substring(state.lastIndexOf('|') + 1).split(",")) - .contains(BuiltInRegistries.ITEM.getKey(stack.getItem()).toString()); - if (matches && result.stream().noneMatch(existing -> gregtech.engine.stack.StackCompat.sameItem(existing, stack))) { - result.add(stack.copyWithCount(1)); - if (result.size() >= MaterialProcessDisplay.MAX_ICONS) break; - } - } - if (!result.isEmpty()) return List.copyOf(result); - } - } - // A fingerprint is not a serialized stack. Never replace a stateful value with an untagged look-alike. - if ((state.startsWith("item:") || state.startsWith("fluid:")) && state.contains("#")) return List.of(); - return icons(resource); - } - - private static List icons(Resource resource) { - var icons = new LinkedHashSet(); - String state = resource.state(); - if (state.startsWith("item:")) { - String id = state.substring("item:".length()); - int suffix = id.indexOf('#'); - if (suffix >= 0) id = id.substring(0, suffix); - item(id).ifPresent(item -> icons.add(new ItemStack(item))); - } else if (state.startsWith("unit:")) { - String alternatives = state.substring("unit:".length()); - int separator = alternatives.lastIndexOf('|'); - if (separator >= 0) alternatives = alternatives.substring(separator + 1); - for (String value : alternatives.split(",")) { - if (icons.size() >= MaterialProcessDisplay.MAX_ICONS) break; - item(value).ifPresent(item -> icons.add(new ItemStack(item))); - } - } else if (state.startsWith("tag:")) { - ResourceLocation tag = ResourceLocation.tryParse(state.substring("tag:".length())); - if (tag != null) { - if (resource.form().equals("fluid")) { - var key = - net.minecraft.tags.TagKey.create(net.minecraft.core.registries.Registries.FLUID, tag); - for (var holder : BuiltInRegistries.FLUID.getTagOrEmpty(key)) { - if (icons.size() >= MaterialProcessDisplay.MAX_ICONS) break; - if (holder.value() == net.minecraft.world.level.material.Fluids.EMPTY) continue; - ItemStack display = fluidDisplay(new FluidStack(holder.value(), 1000)); - if (!display.isEmpty()) icons.add(display); - } - } else { - var key = net.minecraft.tags.TagKey.create(net.minecraft.core.registries.Registries.ITEM, tag); - for (var holder : BuiltInRegistries.ITEM.getTagOrEmpty(key)) { - if (icons.size() >= MaterialProcessDisplay.MAX_ICONS) break; - icons.add(new ItemStack(holder.value())); - } - } - } - } else if (state.startsWith("fluid:")) { - String value = state.substring("fluid:".length()); - int suffix = value.indexOf('#'); - if (suffix >= 0) value = value.substring(0, suffix); - ResourceLocation id = ResourceLocation.tryParse(value); - if (id != null) { - Fluid fluid = BuiltInRegistries.FLUID.get(id); - if (fluid != net.minecraft.world.level.material.Fluids.EMPTY) { - ItemStack display = fluidDisplay(new FluidStack(fluid, 1000)); - if (!display.isEmpty()) icons.add(display); - } - } - } - return List.copyOf(icons); - } - - private static Optional item(String id) { - ResourceLocation location = ResourceLocation.tryParse(id); - if (location == null) return Optional.empty(); - Item item = BuiltInRegistries.ITEM.get(location); - return item == net.minecraft.world.item.Items.AIR ? Optional.empty() : Optional.of(item); - } - -//? if >=1.21.1 { - /*private static ItemStack fluidDisplay(FluidStack stack) { - var lookup = gregtech.engine.fluid.FluidDisplayBinding.currentLookup(); - return lookup == null ? ItemStack.EMPTY : gregtech.engine.fluid.FluidDisplayBinding.display(lookup, stack); - } -*///?} else { - private static ItemStack fluidDisplay(FluidStack stack) { - return gregtech.engine.fluid.FluidDisplayBinding.display(stack); - } -//?} - - private static MaterialProcessDisplay.Role role(MaterialProcessGraph.Role role) { - return switch (role) { - case CONSUMED -> MaterialProcessDisplay.Role.CONSUMED; - case CATALYST -> MaterialProcessDisplay.Role.CATALYST; - case PRESENCE -> MaterialProcessDisplay.Role.PRESENCE; - case PRIMARY -> MaterialProcessDisplay.Role.PRIMARY; - case BYPRODUCT -> MaterialProcessDisplay.Role.BYPRODUCT; - case UNKNOWN -> MaterialProcessDisplay.Role.UNKNOWN; - }; - } - - private static Component quantity(long value, AmountUnit unit) { - return Component.literal(switch (unit) { - case ITEM -> value == 1 ? "" : Long.toString(value); - case MATERIAL_UNIT -> value + "U"; - case MILLIBUCKET -> value + "mB"; - case UNKNOWN -> "?"; - }); - } - - private static Component amount(long value, AmountUnit unit) { - return switch (unit) { - case ITEM -> Component.translatable("gt6ce.jei.material_process.amount.items", value); - case MATERIAL_UNIT -> Component.translatable("gt6ce.jei.material_process.amount.units", value); - case MILLIBUCKET -> Component.translatable("gt6ce.jei.material_process.amount.mb", value); - case UNKNOWN -> Component.translatable("gt6ce.jei.material_process.amount.unknown"); - }; - } - - private static Component notice(Notice notice) { - return switch (notice.code()) { - case "coverage_final_recipes" -> - Component.translatable("gt6ce.jei.material_process.coverage.final_recipes"); - case "coverage_active_worldgen" -> - Component.translatable("gt6ce.jei.material_process.coverage.active_worldgen"); - case "coverage_viewer_recipes" -> - Component.translatable("gt6ce.jei.material_process.coverage.viewer_recipes"); - case "partial_viewer_recipes" -> - Component.translatable("gt6ce.jei.material_process.coverage.viewer_exclusions", notice.omitted()); - case "partial_dynamic_selectors" -> - Component.translatable("gt6ce.jei.material_process.coverage.dynamic_selectors"); - case "partial_unknown_roles" -> - Component.translatable("gt6ce.jei.material_process.coverage.unknown_roles"); - case "invalid_process_data" -> - Component.translatable("gt6ce.jei.material_process.coverage.invalid_data", notice.omitted()); - case "node_limit" -> - Component.translatable("gt6ce.jei.material_process.coverage.node_limit", notice.omitted()); - case "port_limit" -> - Component.translatable("gt6ce.jei.material_process.coverage.port_limit", notice.omitted()); - case "edge_limit" -> - Component.translatable("gt6ce.jei.material_process.coverage.edge_limit", notice.omitted()); - case "depth_limit" -> - Component.translatable("gt6ce.jei.material_process.coverage.depth_limit", notice.omitted()); - case "no_sources" -> Component.translatable("gt6ce.jei.material_process.no_sources"); - case "no_uses" -> Component.translatable("gt6ce.jei.material_process.no_uses"); - case "no_both" -> Component.translatable("gt6ce.jei.material_process.no_both"); - default -> Component.literal(notice.code()); - }; - } -} diff --git a/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java b/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java index 704485e9f..060a13ac0 100644 --- a/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java +++ b/minecraft/src/main/java/gregtech/compat/common/RecipeViewerIcons.java @@ -15,8 +15,6 @@ /** Category identities shared by the two viewers, independent of workstation ordering. */ public final class RecipeViewerIcons { - private static volatile java.util.Map cachedCategories; - private RecipeViewerIcons() {} public static ItemStack item(String path) { @@ -38,7 +36,7 @@ public static ItemStack bedrockOre() { return stack; } - /** Use the same category identity for the process graph and the native viewer. */ + /** Resolves the preferred category icon, falling back to a workstation. */ public static ItemStack category(RecipeMap map, java.util.Map> machines) { ItemStack preferred = map(map); if (!preferred.isEmpty()) return preferred; @@ -48,20 +46,6 @@ public static ItemStack category(RecipeMap map, java.util.Map categories() { - var cached = cachedCategories; - if (cached != null) return cached; - synchronized (RecipeViewerIcons.class) { - if (cachedCategories == null) { - var machines = RecipeMachines.collect(); - var icons = new java.util.HashMap(); - for (RecipeMap map : RecipeMap.RECIPE_MAP_LIST) icons.put(map, category(map, machines)); - cachedCategories = java.util.Map.copyOf(icons); - } - return cachedCategories; - } - } - public static ItemStack map(RecipeMap map) { if (map == MachineRecipeMaps.ByProductList) return GTItems.getStack(MaterialPrefix.dust, GTMaterialRegistry.get("Platinum")); diff --git a/minecraft/src/main/java/gregtech/compat/common/WorldgenInfoData.java b/minecraft/src/main/java/gregtech/compat/common/WorldgenInfoData.java index 2ccc649a1..f6978ad34 100644 --- a/minecraft/src/main/java/gregtech/compat/common/WorldgenInfoData.java +++ b/minecraft/src/main/java/gregtech/compat/common/WorldgenInfoData.java @@ -16,7 +16,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -/** Legacy icon-bearing worldgen viewer projection; process facts come from {@code MaterialWorldgenFacts}. */ +/** Icon-bearing worldgen data shared by the recipe viewers. */ public class WorldgenInfoData { protected WorldgenInfoData() {} diff --git a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java index 34918693a..ef74690ad 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/emi/GregTechEMIPlugin.java @@ -8,7 +8,6 @@ import dev.emi.emi.api.stack.EmiStack; import gregtech.compat.common.RecipeMachines; import gregtech.content.item.GTToolItem; -import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.engine.recipe.RecipeMap; import java.util.Locale; import net.minecraft.network.chat.Component; @@ -19,7 +18,6 @@ @EmiEntrypoint public final class GregTechEMIPlugin implements EmiPlugin { private static int overlayGeneration; - private static MaterialProcessSnapshot processSnapshot; @Override public void initialize(dev.emi.emi.api.EmiInitRegistry registry) { @@ -29,7 +27,6 @@ public void initialize(dev.emi.emi.api.EmiInitRegistry registry) { /** The client overlay calls this before EMI re-registers, so this pass reads the live maps. */ public static void overlayChanged() { overlayGeneration++; - processSnapshot = null; } public static int overlayGeneration() { @@ -38,8 +35,6 @@ public static int overlayGeneration() { @Override public void register(EmiRegistry registry) { - processSnapshot = null; - registry.addCategory(MaterialProcessEmiRecipe.category()); gregtech.client.gui.RecipeViewerNavigation.registerEmi(map -> { var id = ResourceLocation.fromNamespaceAndPath("gt6ce", map.mNameInternal.toLowerCase(Locale.ROOT)); var manager = dev.emi.emi.api.EmiApi.getRecipeManager(); @@ -52,8 +47,6 @@ public void register(EmiRegistry registry) { return false; }); registry.addGenericExclusionArea((screen, areas) -> { - if (screen instanceof gregtech.client.MaterialProcessScreen) - areas.accept(new dev.emi.emi.api.widget.Bounds(0, 0, screen.width, screen.height)); if (screen instanceof gregtech.client.gui.MachineContainerScreen machine) { var tab = machine.titleBounds(); if (tab.getWidth() > 0) @@ -64,12 +57,6 @@ public void register(EmiRegistry registry) { gregtech.engine.fluid.FluidContainerDisplayBinding.invalidate(); FluidScreenStackProvider.register(registry); registry.addGenericStackProvider(EmiWidgetInput::stackAt); - registry.addStackProvider(gregtech.client.MaterialProcessScreen.class, (screen, x, y) -> { - var stack = MaterialProcessEmiStacks.of(screen.stackAt(x, y)); - return stack.isEmpty() - ? dev.emi.emi.api.stack.EmiStackInteraction.EMPTY - : new dev.emi.emi.api.stack.EmiStackInteraction(stack); - }); WoodenBucketLookupRecipe.register(registry); FormConversionEmiRecipe.register(registry); registry.addRecipeHandler( @@ -172,111 +159,4 @@ private static boolean repairedGtTool(EmiRecipe recipe) { } return false; } - - /** Called after EMI has registered deferred rows and applied every recipe filter. */ - public static java.util.List addMaterialProcesses( - java.util.List recipes, - java.util.Map> workstations) { - long started = System.nanoTime(); - // A repeated bake replaces our previous pages instead of retaining their snapshots and indexes. - recipes = recipes.stream() - .filter(recipe -> !(recipe instanceof MaterialProcessEmiRecipe)) - .toList(); - var source = MaterialProcessSnapshot.Store.current(); - var captured = MaterialProcessEmiRecipes.capture(source, recipes, workstations); - var snapshot = captured.snapshot(); - processSnapshot = snapshot; - var navigation = new ProcessNavigation(snapshot, source, captured.information(), captured.links()); - var result = new java.util.ArrayList<>(recipes); - var materials = new java.util.HashSet(); - for (var root : snapshot.roots()) { - var information = captured.information().getOrDefault(root.material(), java.util.List.of()); - var indexedPorts = new java.util.ArrayList<>( - gregtech.compat.common.MaterialProcessProjection.indexedPorts(snapshot, root.resource())); - information.forEach(entry -> indexedPorts.addAll(entry.index())); - result.add(new MaterialProcessEmiRecipe( - root.material(), - () -> navigation.valid() - ? gregtech.compat.common.MaterialProcessProjection.pages( - snapshot, root.resource(), navigation) - .get(0) - .withInformation(information) - : gregtech.compat.common.MaterialProcessDisplay.unbound() - .get(0), - indexedPorts)); - materials.add(root.material()); - } - captured.information().forEach((material, entries) -> { - if (!materials.contains(material)) - result.add( - new MaterialProcessEmiRecipe(gregtech.compat.common.MaterialProcessProjection.informationPage( - material, entries, navigation))); - }); - com.mojang.logging.LogUtils.getLogger() - .info( - "[gregtech] EMI material process index: {} materials from {} viewer recipes in {} ms; pages build on demand", - result.size() - recipes.size(), - recipes.size(), - (System.nanoTime() - started) / 1_000_000L); - return java.util.List.copyOf(result); - } - - private static final class ProcessNavigation implements gregtech.compat.common.MaterialProcessDisplay.Navigation { - private final MaterialProcessSnapshot snapshot; - private final MaterialProcessSnapshot source; - private final java.util.Map> - information; - private final java.util.Map informationLinks; - - private ProcessNavigation( - MaterialProcessSnapshot snapshot, - MaterialProcessSnapshot source, - java.util.Map> - information, - java.util.Map informationLinks) { - this.snapshot = snapshot; - this.source = source; - this.information = information; - this.informationLinks = informationLinks; - } - - @Override - public boolean valid() { - return processSnapshot == snapshot - && MaterialProcessSnapshot.Store.current(source) - && net.minecraft.client.Minecraft.getInstance().level != null; - } - - @Override - public boolean openStack(ItemStack stack, boolean uses) { - if (!valid() || stack.isEmpty()) return false; - var ingredient = MaterialProcessEmiStacks.of(stack); - if (ingredient.isEmpty()) return false; - if (uses) dev.emi.emi.api.EmiApi.displayUses(ingredient); - else dev.emi.emi.api.EmiApi.displayRecipes(ingredient); - return true; - } - - @Override - public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { - if (!valid()) return false; - var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, resource, this); - if (pages.isEmpty()) return false; - var page = pages.get(0); - dev.emi.emi.api.EmiApi.displayRecipe(new MaterialProcessEmiRecipe( - page.withInformation(information.getOrDefault(page.material(), java.util.List.of())))); - return true; - } - - @Override - public boolean openInformation(gregtech.api.addon.material.DataKey reference) { - if (!valid()) return false; - var recipe = informationLinks.get(reference); - if (recipe == null) return false; - if (net.minecraft.client.Minecraft.getInstance().screen - instanceof gregtech.client.MaterialProcessScreen screen) screen.onClose(); - dev.emi.emi.api.EmiApi.displayRecipe(recipe); - return true; - } - } } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MachineEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MachineEmiRecipe.java index 9b09f0f0a..70486eaf5 100644 --- a/minecraft/src/main/java/gregtech/compat/emi/MachineEmiRecipe.java +++ b/minecraft/src/main/java/gregtech/compat/emi/MachineEmiRecipe.java @@ -87,8 +87,6 @@ private static EmiStack displayFluid(net.minecraftforge.fluids.FluidStack stack) @Override public List getInputs() { return inputs; } @Override public List getCatalysts() { return catalysts; } @Override public List getOutputs() { return outputs; } - RecipeMap recipeMap() { return map; } - Recipe nativeRecipe() { return recipe; } @Override public boolean supportsRecipeTree() { return !recipe.mFakeRecipe; } @Override public int getDisplayWidth() { return new RecipeGuiLayout(map,recipe).width(); } @Override public int getDisplayHeight() { return new RecipeGuiLayout(map,recipe).height(); } diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java deleted file mode 100644 index 91cfddd73..000000000 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipe.java +++ /dev/null @@ -1,242 +0,0 @@ -package gregtech.compat.emi; - -import dev.emi.emi.api.EmiRegistry; -import dev.emi.emi.api.recipe.EmiRecipe; -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.Comparison; -import dev.emi.emi.api.stack.EmiIngredient; -import dev.emi.emi.api.stack.EmiStack; -import dev.emi.emi.api.widget.Bounds; -import dev.emi.emi.api.widget.WidgetHolder; -import gregtech.client.MaterialProcessPanel; -import gregtech.compat.common.MaterialProcessDisplay; -import gregtech.compat.common.RecipeViewerIcons; -import gregtech.content.recipe.MaterialProcessSnapshot; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.function.Supplier; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; - -/** EMI adapter over the same single-page, pannable process graph used by JEI. */ -public final class MaterialProcessEmiRecipe implements EmiRecipe { - private static final EmiRecipeCategory CATEGORY = - new EmiRecipeCategory( - ResourceLocation.fromNamespaceAndPath("gt6ce", "material_process"), - EmiStack.of(RecipeViewerIcons.item("ore_iridium"))) { - @Override - public Component getName() { - return Component.translatable("gt6ce.jei.material_process.title"); - } - }; - - private final Supplier pageFactory; - private MaterialProcessDisplay.Page page; - private MaterialProcessPanel panel; - private List focus = List.of(); - private final ResourceLocation id; - private final List inputs; - private final List catalysts; - private final List outputs; - - public MaterialProcessEmiRecipe(MaterialProcessDisplay.Page page) { - this(page.material(), () -> page, page.indexedPorts()); - this.page = page; - } - - /** Index getters never resolve the page; EMI calls them for every recipe during each bake. */ - public MaterialProcessEmiRecipe(String material, Supplier pageFactory, - List indexedPorts) { - this.pageFactory = Objects.requireNonNull(pageFactory); - id = ResourceLocation.fromNamespaceAndPath("gt6ce", "/material_process/" + path(material)); - var inputs = new LinkedHashMap(); - var catalysts = new LinkedHashMap(); - var outputs = new LinkedHashMap(); - for (var port : indexedPorts) add(port, inputs, catalysts, outputs); - this.inputs = List.copyOf(inputs.values()); - this.catalysts = List.copyOf(catalysts.values()); - this.outputs = List.copyOf(outputs.values()); - } - - private static String path(String material) { - String path = material.toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9/._-]", "_"); - return path.isBlank() ? "unbound" : path; - } - - private static void add( - MaterialProcessDisplay.Port port, - Map inputs, - Map catalysts, - Map outputs) { - var index = switch (port.role()) { - case CONSUMED -> inputs; - case CATALYST, PRESENCE -> catalysts; - case PRIMARY, BYPRODUCT, UNKNOWN -> outputs; - }; - for (var icon : port.icons()) { - String state = MaterialProcessSnapshot.itemDisplayState(icon); - if (index.containsKey(state)) continue; - var stack = MaterialProcessEmiStacks.of(icon); - if (!stack.isEmpty()) index.put(state, stack); - } - } - - public static void register(EmiRegistry registry, List pages) { - registry.addCategory(CATEGORY); - for (var page : pages) registry.addRecipe(new MaterialProcessEmiRecipe(page)); - } - - public static EmiRecipeCategory category() { - return CATEGORY; - } - - public void focus(EmiIngredient ingredient) { - focus = ingredient.getEmiStacks().stream().map(EmiStack::copy).toList(); - if (panel != null) focusPanel(); - } - - private void focusPanel() { - // Strict focus matching follows EMI's native state model: components on 1.21, NBT on 1.20. -//? if >=1.21.1 { - /*var comparison = Comparison.compareComponents(); -*///?} else { - var comparison = Comparison.compareNbt(); -//?} - panel.focus(port -> port.icons().stream().anyMatch(icon -> { - var stack = MaterialProcessEmiStacks.of(icon); - return !stack.isEmpty() && focus.stream().anyMatch(target -> stack.isEqual(target, comparison)); - })); - } - - @Override - public EmiRecipeCategory getCategory() { - return CATEGORY; - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public List getInputs() { - return inputs; - } - - @Override - public List getCatalysts() { - return catalysts; - } - - @Override - public List getOutputs() { - return outputs; - } - - @Override - public boolean supportsRecipeTree() { - return false; - } - - @Override - public boolean hideCraftable() { - return true; - } - - @Override - public int getDisplayWidth() { - return MaterialProcessPanel.preferredWidth(); - } - - @Override - public int getDisplayHeight() { - return MaterialProcessPanel.preferredHeight(); - } - - @Override - public void addWidgets(WidgetHolder widgets) { - if (panel == null) { - if (page == null) page = pageFactory.get(); - panel = new MaterialProcessPanel(page); - focusPanel(); - } - panel.resize(Math.min(getDisplayWidth(), widgets.getWidth()), Math.min(getDisplayHeight(), widgets.getHeight())); - widgets.add(new EmiInteractiveWidget() { - @Override - public Bounds getBounds() { - return new Bounds(0, 0, panel.width(), panel.height()); - } - - @Override - public void render(GuiGraphics graphics, int x, int y, float delta) { - EmiWidgetInput.rendered(this, graphics); - panel.draw(graphics, x, y); - } - - @Override - public boolean mouseClicked(int x, int y, int button) { - return panel.clickControls(x, y, button); - } - - @Override - public boolean pressed(double x, double y, int button) { - return panel.press(x, y, button); - } - - @Override - public boolean dragged(int button, double dx, double dy) { - return panel.drag(button, dx, dy); - } - - @Override - public boolean scrolled(double x, double y, double delta) { - return panel.scroll(x, y, delta); - } - - @Override - public List getTooltip(int x, int y) { - return panel.tooltip(x, y).stream() - .map(line -> ClientTooltipComponent.create(line.getVisualOrderText())) - .toList(); - } - }); - for (var node : panel.nodes()) { - var icons = panel.stacks(node); - if (icons.isEmpty()) continue; - widgets.add(new dev.emi.emi.api.widget.SlotWidget(MaterialProcessEmiStacks.of(icons.get(0)), 0, 0) { - @Override - public Bounds getBounds() { - var bounds = panel.bounds(node); - return new Bounds( - bounds.left(), - bounds.top(), - Math.max(0, bounds.right() - bounds.left()), - Math.max(0, bounds.bottom() - bounds.top())); - } - - @Override - public EmiIngredient getStack() { - return page.navigation().valid() ? super.getStack() : EmiStack.EMPTY; - } - - @Override - public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {} - - @Override - public List getTooltip(int x, int y) { - var details = panel.tooltip(x, y); - return details.size() > 1 - ? details.stream() - .map(line -> ClientTooltipComponent.create(line.getVisualOrderText())) - .toList() - : super.getTooltip(x, y); - } - }); - } - } -} diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java deleted file mode 100644 index 46b6523f6..000000000 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiRecipes.java +++ /dev/null @@ -1,263 +0,0 @@ -package gregtech.compat.emi; - -import com.mojang.logging.LogUtils; -import dev.emi.emi.api.recipe.EmiCraftingRecipe; -import dev.emi.emi.api.recipe.EmiIngredientRecipe; -import dev.emi.emi.api.recipe.EmiInfoRecipe; -import dev.emi.emi.api.recipe.EmiPatternCraftingRecipe; -import dev.emi.emi.api.recipe.EmiRecipe; -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.recipe.VanillaEmiRecipeCategories; -import dev.emi.emi.api.stack.EmiIngredient; -import dev.emi.emi.api.stack.EmiStack; -import gregtech.api.addon.material.DataKey; -import gregtech.compat.common.MaterialProcessDisplay; -import gregtech.content.registry.GTFluids; -import gregtech.content.recipe.MaterialProcessSnapshot; -import gregtech.engine.fluid.FluidVisualPolicy; -import gregtech.engine.material.ItemMaterialRegistry; -import gregtech.engine.material.MaterialProcessGraph.Port; -import gregtech.engine.material.MaterialProcessGraph.AmountUnit; -import gregtech.engine.material.MaterialProcessGraph.Resource; -import gregtech.engine.material.MaterialProcessGraph.Role; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.OptionalInt; -import java.util.Set; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.material.Fluid; -//? if >=1.21.1 { -/*import net.neoforged.neoforge.fluids.FluidStack; -*///?} else { -import net.minecraftforge.fluids.FluidStack; -//?} - -/** Processing rows and related information share a source, but never share graph semantics. */ -final class MaterialProcessEmiRecipes { - private static final org.slf4j.Logger LOGGER = LogUtils.getLogger(); - - private MaterialProcessEmiRecipes() {} - - record Captured(MaterialProcessSnapshot snapshot, Map> information, - Map links) {} - - private record SlotKey(Resource resource, Role role, AmountUnit unit, OptionalInt chance, long stochasticBatch) {} - - private record ProcessKey(ResourceLocation category, Map inputs, Map outputs) {} - - static Captured capture(MaterialProcessSnapshot source, List recipes, - Map> workstations) { - var builder = source.viewerBuilder(); - var information = new LinkedHashMap>(); - var links = new LinkedHashMap(); - var informationIds = new HashSet(); - var processIds = new HashSet(); - var processes = new HashSet(); - var seen = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap()); - for (int index = 0; index < recipes.size(); index++) { - EmiRecipe recipe = recipes.get(index); - try { - if (recipe instanceof MaterialProcessEmiRecipe || !seen.add(recipe)) continue; - // Ingredient disambiguation lists tag members, not material-specific guidance. - if (recipe instanceof EmiIngredientRecipe && !(recipe instanceof MaterialUnitTagEmiRecipe)) continue; - // JEMI wraps JEI tag browsers as plain recipes, retaining the registry's tag_recipes category. - if (recipe.getCategory().getId().getPath().startsWith("tag_recipes/")) continue; - // Unit templates opt out of automatic crafting, but carry GT's complete processing semantics. - if (recipe instanceof MachineEmiRecipe machine - && builder.machine(machine.recipeMap(), machine.nativeRecipe())) continue; - if (informationOnly(recipe) || recipe.getInputs().isEmpty() || recipe.getOutputs().isEmpty()) { - builder.omitted(); - information(source, recipe, index, information, links, informationIds); - continue; - } - boolean crafting = recipe instanceof EmiCraftingRecipe - || recipe.getCategory().getId().equals(VanillaEmiRecipeCategories.CRAFTING.getId()); - var inputs = ports(builder, recipe.getInputs(), Role.CONSUMED, crafting); - var catalysts = ports(builder, recipe.getCatalysts(), Role.CATALYST, false); - var outputs = ports(builder, recipe.getOutputs(), Role.UNKNOWN, false); - // Dropping an unsupported slot would turn a partial recipe into an invented route. - if (inputs == null || catalysts == null || outputs == null || inputs.isEmpty() || outputs.isEmpty()) { - builder.omitted(); - information(source, recipe, index, information, links, informationIds); - continue; - } - inputs.addAll(catalysts); - var category = recipe.getCategory(); - // IDs catch repeated registrations; slot multisets also catch equivalent synthetic wrappers. - var id = recipe.getId(); - if (id != null && processIds.contains(id)) continue; - boolean remainders = java.util.stream.Stream.concat(recipe.getInputs().stream(), recipe.getCatalysts().stream()) - .flatMap(ingredient -> ingredient.getEmiStacks().stream()).anyMatch(stack -> !stack.getRemainder().isEmpty()); - var process = remainders ? null : new ProcessKey(category.getId(), slots(inputs), slots(outputs)); - if (process != null && processes.contains(process)) continue; - var machine = workstations.getOrDefault(category, List.of()).stream() - .flatMap(ingredient -> ingredient.getEmiStacks().stream()) - .map(EmiStack::getItemStack).filter(stack -> !stack.isEmpty()) - .findFirst().orElseGet(() -> category.getId().equals(VanillaEmiRecipeCategories.CRAFTING.getId()) - ? new ItemStack(Items.CRAFTING_TABLE) : ItemStack.EMPTY); - var reference = new DataKey("gt6ce", "process/emi/" + index + "/" - + Long.toUnsignedString(source.snapshot().publication().revision(), 36) + "/" - + Long.toUnsignedString(source.snapshot().sessionGeneration(), 36)); - builder.recipe(reference, category.getId().toString(), category.getName().getString(), machine, inputs, outputs, - List.of("EMI category: " + category.getId(), "EMI recipe: " + recipe.getId(), - "matching constraints and remainders: see original recipe"), recipe.supportsRecipeTree()); - if (id != null) processIds.add(id); - if (process != null) processes.add(process); - } catch (RuntimeException failure) { - builder.omitted(); - LOGGER.warn("Discarded invalid EMI material process entry at index {}", index, failure); - } - } - information.replaceAll((material, entries) -> List.copyOf(entries)); - return new Captured(builder.build(), Map.copyOf(information), Map.copyOf(links)); - } - - private static boolean informationOnly(EmiRecipe recipe) { - return recipe instanceof MachineEmiRecipe - || recipe instanceof EmiInfoRecipe - || recipe instanceof EmiPatternCraftingRecipe - || recipe instanceof StructureEmiRecipe - || recipe instanceof WorldgenEmiRecipe - || recipe instanceof LootEmiRecipe - || recipe instanceof MaterialUnitTagEmiRecipe - || recipe instanceof MoldChiselEmiRecipe - || recipe instanceof WoodenBucketLookupRecipe - || recipe.getCategory().getId().equals(VanillaEmiRecipeCategories.INFO.getId()); - } - - private static Map slots(List ports) { - var result = new HashMap(); - for (Port port : ports) { - // Two independent random output slots are not one double-sized random batch. - long batch = port.output() && port.chance().orElse(0) != 10_000 ? port.amount().value() : 0; - result.merge(new SlotKey(port.resource(), port.role(), port.amount().unit(), port.chance(), batch), - BigInteger.valueOf(port.amount().value()), BigInteger::add); - } - return Map.copyOf(result); - } - - private static void information(MaterialProcessSnapshot source, EmiRecipe recipe, int index, - Map> information, Map links, - Set informationIds) { - var inputs = informationIcons(java.util.stream.Stream.concat(recipe.getInputs().stream(), recipe.getCatalysts().stream()).toList()); - var outputs = informationIcons(recipe.getOutputs()); - var materials = new java.util.LinkedHashSet<>(inputs.keySet()); - materials.addAll(outputs.keySet()); - if (materials.isEmpty()) return; - // EMI IDs identify pages, even when plugins register a fresh object for the same page. - if (recipe.getId() != null && !informationIds.add(recipe.getId())) return; - var reference = new DataKey("gt6ce", "process/emi_information/" + index + "/" - + Long.toUnsignedString(source.snapshot().publication().revision(), 36) + "/" - + Long.toUnsignedString(source.snapshot().sessionGeneration(), 36)); - Component name = recipe.getCategory().getName(); - int materialIndex = 0; - for (String material : materials) { - var ports = new ArrayList(); - var materialIcons = outputs.getOrDefault(material, inputs.getOrDefault(material, Map.of())); - ItemStack icon = materialIcons.values().iterator().next(); - for (boolean output : List.of(false, true)) { - var icons = (output ? outputs : inputs).getOrDefault(material, Map.of()).values().stream().toList(); - if (icons.isEmpty()) continue; - var key = new DataKey(reference.namespace(), reference.path() + "/index/" + materialIndex + "/" + output); - ports.add(new MaterialProcessDisplay.Port(key, material, icons.get(0).getHoverName(), icons, - output ? MaterialProcessDisplay.Role.UNKNOWN : MaterialProcessDisplay.Role.PRESENCE, - false, Component.empty(), Component.empty(), OptionalInt.empty(), List.of())); - } - var entry = new MaterialProcessDisplay.Information(reference, name, icon, - List.of(icon.getHoverName(), Component.translatable("gt6ce.jei.material_process.information_hint")), ports); - information.computeIfAbsent(material, ignored -> new ArrayList<>()).add(entry); - materialIndex++; - } - links.put(reference, recipe); - } - - private static Map> informationIcons(List ingredients) { - var result = new LinkedHashMap>(); - for (EmiIngredient ingredient : ingredients) { - if (ingredient == null) continue; - for (EmiStack stack : ingredient.getEmiStacks()) { - if (stack == null || stack.isEmpty()) continue; - if (stack.getKey() instanceof Item) { - var item = stack.getItemStack(); - ItemMaterialRegistry.get(item).ifPresent(composition -> { - var material = composition.primaryMaterial().resolve(); - if (material.isValid()) informationIcon(result, material.getName(), item); - }); - } else if (stack.getKey() instanceof Fluid fluid) { - var entry = GTFluids.entryForFluid(fluid); - if (entry == null) continue; - var material = FluidVisualPolicy.material(entry).resolve(); - if (!material.isValid()) continue; - var nativeFluid = fluid(stack, fluid); -//? if >=1.21.1 { - /*var lookup = gregtech.engine.fluid.FluidDisplayBinding.currentLookup(); - if (lookup != null) informationIcon(result, material.getName(), gregtech.engine.fluid.FluidDisplayBinding.display(lookup, nativeFluid)); -*///?} else { - informationIcon(result, material.getName(), gregtech.engine.fluid.FluidDisplayBinding.display(nativeFluid)); -//?} - } - } - } - return result; - } - - private static void informationIcon(Map> icons, String material, ItemStack stack) { - if (stack.isEmpty()) return; - var values = icons.computeIfAbsent(material, ignored -> new LinkedHashMap<>()); - if (values.size() < MaterialProcessDisplay.MAX_ICONS) - values.putIfAbsent(MaterialProcessSnapshot.itemDisplayState(stack), stack.copyWithCount(1)); - } - - private static List ports(MaterialProcessSnapshot.ViewerBuilder builder, - List ingredients, Role role, boolean padding) { - var ports = new ArrayList(); - for (EmiIngredient ingredient : ingredients) { - // Shaped crafting pads its grid with EMPTY. An unresolved nonempty ingredient is not padding. - if (padding && ingredient == EmiStack.EMPTY) continue; - if (role == Role.CATALYST && ingredient != null && ingredient.getAmount() == 0) - ingredient = ingredient.copy().setAmount(1); - if (ingredient == null || ingredient.isEmpty() || ingredient.getAmount() < 0 - || ingredient.getAmount() == 0 && role != Role.CATALYST) return null; - var candidates = new ArrayList(); - for (EmiStack stack : ingredient.getEmiStacks()) { - if (stack == null || stack.isEmpty()) return null; - if (role == Role.UNKNOWN && (!Float.isFinite(stack.getChance()) || stack.getChance() <= 0 || stack.getChance() > 1)) - return null; - long amount = Math.max(1, ingredient.getAmount()); - var chance = role == Role.UNKNOWN ? chance(stack.getChance()) : OptionalInt.empty(); - if (stack.getKey() instanceof Item) { - var item = stack.copy().setAmount(1).getItemStack(); - if (item.isEmpty()) return null; - candidates.add(builder.item(item, role, amount, chance)); - } else if (stack.getKey() instanceof Fluid fluid) { - candidates.add(builder.fluid(fluid(stack, fluid), role, amount, chance)); - } else return null; - } - if (candidates.isEmpty()) return null; - ports.add(builder.alternatives(candidates)); - } - return ports; - } - - private static FluidStack fluid(EmiStack stack, Fluid fluid) { -//? if >=1.21.1 { - /*return new FluidStack(fluid.builtInRegistryHolder(), 1, stack.getComponentChanges()); -*///?} else { - return new FluidStack(fluid, 1, stack.getNbt()); -//?} - } - - private static OptionalInt chance(float chance) { - if (!Float.isFinite(chance) || chance <= 0 || chance > 1) return OptionalInt.empty(); - return OptionalInt.of(Math.max(1, Math.round(chance * 10_000))); - } -} diff --git a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiStacks.java b/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiStacks.java deleted file mode 100644 index 5c9d22a8b..000000000 --- a/minecraft/src/main/java/gregtech/compat/emi/MaterialProcessEmiStacks.java +++ /dev/null @@ -1,21 +0,0 @@ -package gregtech.compat.emi; - -import dev.emi.emi.api.stack.EmiStack; -import gregtech.engine.fluid.FluidDisplayBinding; -import net.minecraft.world.item.ItemStack; - -/** The overview's display item is never the lookup handle for a native fluid. */ -public final class MaterialProcessEmiStacks { - private MaterialProcessEmiStacks() {} - - public static EmiStack of(ItemStack icon) { - if (!FluidDisplayBinding.hasPayload(icon)) return EmiStack.of(icon); -//? if >=1.21.1 { - /*var fluid = FluidDisplayBinding.resolveCurrent(icon); - return fluid.isEmpty() ? EmiStack.EMPTY : EmiStack.of(fluid.getFluid(), fluid.getComponentsPatch(), 1); -*///?} else { - var fluid = FluidDisplayBinding.resolve(icon); - return fluid.isEmpty() ? EmiStack.EMPTY : EmiStack.of(fluid.getFluid(), fluid.getTag(), 1); -//?} - } -} diff --git a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java index 967133856..f5c92eb7b 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java +++ b/minecraft/src/main/java/gregtech/compat/jei/GregTechJEIPlugin.java @@ -1,6 +1,5 @@ package gregtech.compat.jei; -import gregtech.content.recipe.MaterialProcessSnapshot; import gregtech.compat.common.RecipeMachines; import gregtech.engine.recipe.Recipe; import gregtech.engine.recipe.RecipeMap; @@ -28,21 +27,7 @@ */ @JeiPlugin public final class GregTechJEIPlugin implements IModPlugin { - private mezz.jei.api.runtime.IJeiRuntime runtime; - private MaterialProcessSnapshot processSnapshot; - private MaterialProcessCategory processCategory; - @Override public void onRuntimeAvailable(mezz.jei.api.runtime.IJeiRuntime runtime) { - this.runtime = runtime; - if (!emiLoaded() && processCategory != null) { - var source = MaterialProcessSnapshot.Store.current(); - var snapshot = MaterialProcessJeiRecipes.capture(source, runtime); - processSnapshot = snapshot; - var navigation = new ProcessNavigation(source, snapshot); - runtime.getRecipeManager().addRecipes( - MaterialProcessCategory.TYPE, - gregtech.compat.common.MaterialProcessProjection.initialPages(snapshot, navigation)); - } gregtech.client.gui.RecipeViewerNavigation.registerJei(map -> { if (!categories.containsKey(map)) return false; runtime.getRecipesGui().showTypes(java.util.List.of(RecipeMapCategory.recipeType(map))); @@ -55,60 +40,11 @@ public final class GregTechJEIPlugin implements IModPlugin { } @Override public void onRuntimeUnavailable() { - runtime = null; - processSnapshot = null; gregtech.client.gui.RecipeViewerNavigation.clearJei(); } @Override public void registerGuiHandlers(mezz.jei.api.registration.IGuiHandlerRegistration registration) { - registration.addGuiScreenHandler(gregtech.client.MaterialProcessScreen.class, screen -> - new mezz.jei.api.gui.handlers.IGuiProperties() { - // JEI 19 renamed GUI property accessors; the occupied full-window rectangle is identical. -//? if >=1.21.1 { - /*@Override public Class screenClass() { - return gregtech.client.MaterialProcessScreen.class; - } - @Override public int guiLeft() { return 0; } - @Override public int guiTop() { return 0; } - @Override public int guiXSize() { return screen.width; } - @Override public int guiYSize() { return screen.height; } - @Override public int screenWidth() { return screen.width; } - @Override public int screenHeight() { return screen.height; } -*///?} else { - @Override public Class getScreenClass() { - return gregtech.client.MaterialProcessScreen.class; - } - @Override public int getGuiLeft() { return 0; } - @Override public int getGuiTop() { return 0; } - @Override public int getGuiXSize() { return screen.width; } - @Override public int getGuiYSize() { return screen.height; } - @Override public int getScreenWidth() { return screen.width; } - @Override public int getScreenHeight() { return screen.height; } -//?} - }); - registration.addGlobalGuiHandler(new mezz.jei.api.gui.handlers.IGlobalGuiHandler() { - @Override - public java.util.Optional> getClickableIngredientUnderMouse( - double x, double y) { - if (runtime == null || !(net.minecraft.client.Minecraft.getInstance().screen - instanceof gregtech.client.MaterialProcessScreen screen)) return java.util.Optional.empty(); - var stack = screen.stackAt(x, y); - if (stack.isEmpty()) return java.util.Optional.empty(); - Object ingredient = stack; - if (gregtech.engine.fluid.FluidDisplayBinding.hasPayload(stack)) { -//? if >=1.21.1 { - /*var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolveCurrent(stack); -*///?} else { - var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolve(stack); -//?} - if (fluid.isEmpty()) return java.util.Optional.empty(); - ingredient = fluid; - } - return runtime.getIngredientManager().createClickableIngredient(ingredient, screen.stackArea(x, y), false) - .map(value -> (mezz.jei.api.runtime.IClickableIngredient) value); - } - }); registration.addGenericGuiContainerHandler(gregtech.client.gui.MachineContainerScreen.class, new mezz.jei.api.gui.handlers.IGuiContainerHandler>() { @Override public java.util.List getGuiExtraAreas( @@ -159,8 +95,6 @@ public void registerCategories(IRecipeCategoryRegistration registration) { registration.addRecipeCategories(new MultiblockInfoCategory(guiHelper)); registration.addRecipeCategories(new ToolAssemblyCategory.Category(guiHelper)); registration.addRecipeCategories(new MoldChiselCategory(guiHelper)); - processCategory = new MaterialProcessCategory(guiHelper); - registration.addRecipeCategories(processCategory); registration.addRecipeCategories( new WorldgenInfoCategories.VeinCategory(guiHelper), new WorldgenInfoCategories.SmallOreCategory(guiHelper), @@ -288,54 +222,4 @@ private ItemStack iconFor(RecipeMap map) { return new ItemStack(Items.ANVIL); } - private final class ProcessNavigation implements gregtech.compat.common.MaterialProcessDisplay.Navigation { - private final MaterialProcessSnapshot source; - private final MaterialProcessSnapshot snapshot; - - private ProcessNavigation(MaterialProcessSnapshot source, MaterialProcessSnapshot snapshot) { - this.source = source; - this.snapshot = snapshot; - } - - @Override - public boolean valid() { - return processSnapshot == snapshot && MaterialProcessSnapshot.Store.current(source); - } - - @Override - public boolean openStack(ItemStack stack, boolean uses) { - if (runtime == null || !valid() || stack.isEmpty()) return false; - var role = uses ? mezz.jei.api.recipe.RecipeIngredientRole.INPUT : mezz.jei.api.recipe.RecipeIngredientRole.OUTPUT; - var factory = runtime.getJeiHelpers().getFocusFactory(); - var focuses = new ArrayList>(); - if (gregtech.engine.fluid.FluidDisplayBinding.hasPayload(stack)) { -//? if >=1.21.1 { - /*var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolveCurrent(stack); - if (!fluid.isEmpty()) focuses.add(factory.createFocus(role, mezz.jei.api.neoforge.NeoForgeTypes.FLUID_STACK, fluid)); -*///?} else { - var fluid = gregtech.engine.fluid.FluidDisplayBinding.resolve(stack); - if (!fluid.isEmpty()) focuses.add(factory.createFocus(role, mezz.jei.api.forge.ForgeTypes.FLUID_STACK, fluid)); -//?} - } else focuses.add(factory.createFocus(role, mezz.jei.api.constants.VanillaTypes.ITEM_STACK, stack)); - if (focuses.isEmpty()) return false; - runtime.getRecipesGui().show(focuses); - return true; - } - - @Override - public boolean openForm(gregtech.api.addon.material.DataKey resource, boolean uses) { - if (runtime == null || !valid()) return false; - var pages = gregtech.compat.common.MaterialProcessProjection.pages(snapshot, resource, this); - runtime.getRecipesGui().showRecipes(processCategory, pages, List.of()); - return true; - } - } - - private static boolean emiLoaded() { -//? if >=1.21.1 { - /*return net.neoforged.fml.ModList.get().isLoaded("emi"); -*///?} else { - return net.minecraftforge.fml.ModList.get().isLoaded("emi"); -//?} - } } diff --git a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java deleted file mode 100644 index 97bbeff1d..000000000 --- a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessCategory.java +++ /dev/null @@ -1,150 +0,0 @@ -package gregtech.compat.jei; - -import gregtech.client.MaterialProcessPanel; -import gregtech.compat.common.MaterialProcessDisplay.Page; -import gregtech.compat.common.MaterialProcessDisplay.Port; -import gregtech.content.recipe.MaterialProcessSnapshot; -import gregtech.engine.fluid.FluidDisplayBinding; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.Map; -import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; -import mezz.jei.api.gui.builder.ITooltipBuilder; -import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.gui.ingredient.IRecipeSlotsView; -import mezz.jei.api.gui.inputs.IJeiGuiEventListener; -import mezz.jei.api.gui.widgets.IRecipeExtrasBuilder; -import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.recipe.IFocusGroup; -import mezz.jei.api.recipe.RecipeIngredientRole; -import mezz.jei.api.recipe.RecipeType; -import mezz.jei.api.recipe.category.IRecipeCategory; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.navigation.ScreenRectangle; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; - -/** JEI adapter only; producers register bounded pages through the normal JEI recipe registration/runtime API. */ -public final class MaterialProcessCategory implements IRecipeCategory { - public static final RecipeType TYPE = RecipeType.create("gt6ce", "material_process", Page.class); - private final IDrawable icon; - private final Map views = new IdentityHashMap<>(); - private final Map viewFocuses = new IdentityHashMap<>(); - - public MaterialProcessCategory(IGuiHelper helper) { - icon = helper.createDrawableItemStack(new ItemStack(Items.MAP)); - } - - @Override - public RecipeType getRecipeType() { - return TYPE; - } - - @Override - public Component getTitle() { - return Component.translatable("gt6ce.jei.material_process.title"); - } - - @Override - public IDrawable getIcon() { - return icon; - } - - @Override - public int getWidth() { - return MaterialProcessPanel.preferredWidth(); - } - - @Override - public int getHeight() { - return MaterialProcessPanel.preferredHeight(); - } - - @Override - public void setRecipe(IRecipeLayoutBuilder builder, Page page, IFocusGroup focuses) { - for (var port : page.indexedPorts()) { - var ingredients = builder.addInvisibleIngredients(role(port)); - for (var icon : port.icons()) { - if (!FluidDisplayBinding.hasPayload(icon)) ingredients.addItemStack(icon); - else { -//? if >=1.21.1 { - /*var fluid = FluidDisplayBinding.resolveCurrent(icon); - if (!fluid.isEmpty()) ingredients.addIngredient(mezz.jei.api.neoforge.NeoForgeTypes.FLUID_STACK, fluid); -*///?} else { - var fluid = FluidDisplayBinding.resolve(icon); - if (!fluid.isEmpty()) ingredients.addIngredient(mezz.jei.api.forge.ForgeTypes.FLUID_STACK, fluid); -//?} - } - } - } - } - - private static RecipeIngredientRole role(Port port) { - return switch (port.role()) { - case CONSUMED -> RecipeIngredientRole.INPUT; - case CATALYST, PRESENCE -> RecipeIngredientRole.CATALYST; - case PRIMARY, BYPRODUCT, UNKNOWN -> RecipeIngredientRole.OUTPUT; - }; - } - - @Override - public void createRecipeExtras(IRecipeExtrasBuilder builder, Page page, IFocusGroup focuses) { - var panel = view(page); - var identities = new HashSet(); - focuses.getItemStackFocuses().forEach(focus -> identities.add( - MaterialProcessSnapshot.itemDisplayState(focus.getTypedValue().getIngredient()))); -//? if >=1.21.1 { - /*focuses.getFocuses(mezz.jei.api.neoforge.NeoForgeTypes.FLUID_STACK).forEach(focus -> identities.add( - MaterialProcessSnapshot.fluidDisplayState(focus.getTypedValue().getIngredient()))); -*///?} else { - focuses.getFocuses(mezz.jei.api.forge.ForgeTypes.FLUID_STACK).forEach(focus -> identities.add( - MaterialProcessSnapshot.fluidDisplayState(focus.getTypedValue().getIngredient()))); -//?} - if (viewFocuses.put(page, focuses) != focuses) panel.focus(port -> identities.contains(port.identity())); - builder.addGuiEventListener(new IJeiGuiEventListener() { - @Override - public ScreenRectangle getArea() { - return new ScreenRectangle(0, 0, panel.width(), panel.height()); - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - return panel.click(mouseX, mouseY, button) || panel.press(mouseX, mouseY, button); - } - - @Override - public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) { - return panel.drag(button, dragX, dragY); - } - -//? if >=1.21.1 { - /*@Override - public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { - return panel.scroll(mouseX, mouseY, scrollY); - } -*///?} else { - @Override - public boolean mouseScrolled(double mouseX, double mouseY, double delta) { - return panel.scroll(mouseX, mouseY, delta); - } -//?} - }); - } - - @Override - public void draw(Page page, IRecipeSlotsView slots, GuiGraphics graphics, double mouseX, double mouseY) { - view(page).draw(graphics, mouseX, mouseY); - } - - @Override - public void getTooltip(ITooltipBuilder tooltip, Page page, IRecipeSlotsView slots, double mouseX, double mouseY) { - tooltip.addAll(view(page).tooltip(mouseX, mouseY)); - } - - private MaterialProcessPanel view(Page page) { - var panel = views.computeIfAbsent(page, MaterialProcessPanel::new); - panel.resize(getWidth(), getHeight()); - return panel; - } -} diff --git a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java b/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java deleted file mode 100644 index bab6c952d..000000000 --- a/minecraft/src/main/java/gregtech/compat/jei/MaterialProcessJeiRecipes.java +++ /dev/null @@ -1,200 +0,0 @@ -package gregtech.compat.jei; - -import gregtech.content.recipe.MaterialProcessSnapshot; -import gregtech.engine.material.MaterialProcessGraph.Port; -import gregtech.engine.material.MaterialProcessGraph.Role; -import gregtech.engine.recipe.Recipe; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.Set; -import mezz.jei.api.gui.IRecipeLayoutDrawable; -import mezz.jei.api.gui.ingredient.IRecipeSlotView; -import mezz.jei.api.ingredients.ITypedIngredient; -import mezz.jei.api.recipe.IFocusGroup; -import mezz.jei.api.recipe.IRecipeManager; -import mezz.jei.api.recipe.RecipeIngredientRole; -import mezz.jei.api.recipe.category.IRecipeCategory; -import mezz.jei.api.constants.VanillaTypes; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -//? if >=1.21.1 { -/*import mezz.jei.api.neoforge.NeoForgeTypes; -import net.neoforged.neoforge.fluids.FluidStack; -*///?} else { -import mezz.jei.api.forge.ForgeTypes; -import net.minecraftforge.fluids.FluidStack; -//?} - -/** Captures JEI's final visible recipe rows into the same material-page view model used by EMI. */ -final class MaterialProcessJeiRecipes { - private MaterialProcessJeiRecipes() {} - - static MaterialProcessSnapshot capture( - MaterialProcessSnapshot source, mezz.jei.api.runtime.IJeiRuntime runtime) { - var builder = source.viewerBuilder(); - var manager = runtime.getRecipeManager(); - var categories = manager.createRecipeCategoryLookup().get() - .filter(category -> !informationOnly(category.getRecipeType())) - .toList(); - var ids = new HashSet(); - var counters = new Counters(); - for (var category : categories) captureCategory(manager, category, builder, ids, counters, - runtime.getJeiHelpers().getFocusFactory().getEmptyFocusGroup()); - gregtech.platform.Mc.logger() - .info("[gregtech] JEI material process index: {} visible categories, {} recipes, {} rows, {} omitted", - categories.size(), counters.recipes, counters.rows, counters.omitted); - return builder.build(); - } - - private static boolean informationOnly(mezz.jei.api.recipe.RecipeType type) { - if (type.equals(MaterialProcessCategory.TYPE) - || type.equals(MultiblockInfoCategory.TYPE) - || type.equals(MoldChiselCategory.TYPE) - || type.equals(LootInfoCategories.LOOT) - || type.equals(LootInfoCategories.MOBS) - || type.equals(WorldgenInfoCategories.VEIN_TYPE) - || type.equals(WorldgenInfoCategories.SMALL_ORE_TYPE) - || type.equals(WorldgenInfoCategories.LAYER_TYPE) - || type.equals(WorldgenInfoCategories.BEDROCK_TYPE)) return true; - for (var family : MaterialUnitTagCategory.FAMILIES) - if (type.equals(MaterialUnitTagCategory.type(family))) return true; - return false; - } - - private static void captureCategory( - IRecipeManager manager, - IRecipeCategory category, - MaterialProcessSnapshot.ViewerBuilder builder, - Set ids, - Counters counters, - IFocusGroup focus) { - var recipes = manager.createRecipeLookup(category.getRecipeType()).get().toList(); - counters.recipes += recipes.size(); - for (int index = 0; index < recipes.size(); index++) { - T recipe = recipes.get(index); - ResourceLocation id = category.getRegistryName(recipe); - if (id != null && !ids.add(category.getRecipeType().getUid() + "/" + id)) continue; - if (category instanceof RecipeMapCategory mapCategory - && recipe instanceof Recipe nativeRecipe - && builder.machine(mapCategory.recipeMap(), nativeRecipe)) { - counters.rows++; - continue; - } - captureRecipe(manager, category, recipe, index, builder, counters, focus); - } - } - - private static void captureRecipe( - IRecipeManager manager, - IRecipeCategory category, - T recipe, - int index, - MaterialProcessSnapshot.ViewerBuilder builder, - Counters counters, - IFocusGroup focus) { - Optional> drawable = - manager.createRecipeLayoutDrawable(category, recipe, focus); - if (drawable.isEmpty()) { - builder.omitted(); - counters.omitted++; - return; - } - var inputs = new ArrayList(); - var outputs = new ArrayList(); - for (IRecipeSlotView slot : drawable.get().getRecipeSlotsView().getSlotViews()) { - if (slot.isEmpty() || slot.getRole() == RecipeIngredientRole.RENDER_ONLY) continue; - Port port = port(builder, slot); - if (port == null) { - builder.omitted(); - counters.omitted++; - return; - } - switch (slot.getRole()) { - case INPUT, CATALYST -> inputs.add(port); - case OUTPUT -> outputs.add(port); - default -> { - builder.omitted(); - counters.omitted++; - return; - } - } - } - if (inputs.isEmpty() || outputs.isEmpty()) { - builder.omitted(); - counters.omitted++; - return; - } - ItemStack machine = manager.createRecipeCatalystLookup(category.getRecipeType()).getItemStack() - .findFirst().orElseGet(() -> new ItemStack(Items.ANVIL)); - ResourceLocation type = category.getRecipeType().getUid(); - ResourceLocation registryName = category.getRegistryName(recipe); - gregtech.api.addon.material.DataKey reference = new gregtech.api.addon.material.DataKey( - "gt6ce", - "process/jei/" + type.getNamespace() + "/" + type.getPath() + "/" + index + "/" - + Long.toUnsignedString( - builder.publicationRevision(), 36) - + "/" - + Long.toUnsignedString(builder.sessionGeneration(), 36)); - var details = new ArrayList(); - details.add("viewer category: " + type); - if (registryName != null) details.add("viewer recipe: " + registryName); - details.add("matching constraints and remainders: see original recipe"); - builder.recipe( - reference, - type.toString(), - category.getTitle().getString(), - machine, - List.copyOf(inputs), - List.copyOf(outputs), - List.copyOf(details), - true); - counters.rows++; - } - - private static Port port(MaterialProcessSnapshot.ViewerBuilder builder, IRecipeSlotView slot) { - var fluids = new ArrayList(); - var items = new ArrayList(); - for (ITypedIngredient typed : slot.getAllIngredients().toList()) { - if (typed == null) continue; -//? if >=1.21.1 { - /*typed.getIngredient(NeoForgeTypes.FLUID_STACK) - .filter(fluid -> !fluid.isEmpty()) - .ifPresent(fluids::add); -*///?} else { - typed.getIngredient(ForgeTypes.FLUID_STACK) - .filter(fluid -> !fluid.isEmpty()) - .ifPresent(fluids::add); -//?} - typed.getIngredient(VanillaTypes.ITEM_STACK) - .filter(stack -> !stack.isEmpty()) - .ifPresent(items::add); - } - Role role = switch (slot.getRole()) { - case INPUT -> Role.CONSUMED; - case CATALYST -> Role.CATALYST; - case OUTPUT -> Role.UNKNOWN; - default -> null; - }; - if (role == null) return null; - var candidates = new ArrayList(); - // Fluid renderers may also expose an item proxy. The native fluid is the authoritative slot value. - if (!fluids.isEmpty()) { - for (FluidStack fluid : fluids) - candidates.add(builder.fluid(fluid, role, fluid.getAmount(), OptionalInt.empty())); - } else { - for (ItemStack stack : items) - candidates.add(builder.item(stack, role, stack.getCount(), OptionalInt.empty())); - } - return candidates.isEmpty() ? null : builder.alternatives(candidates); - } - - private static final class Counters { - private int recipes; - private int rows; - private int omitted; - } -} diff --git a/minecraft/src/main/java/gregtech/compat/jei/RecipeMapCategory.java b/minecraft/src/main/java/gregtech/compat/jei/RecipeMapCategory.java index b1269f003..ed6c5b0ed 100644 --- a/minecraft/src/main/java/gregtech/compat/jei/RecipeMapCategory.java +++ b/minecraft/src/main/java/gregtech/compat/jei/RecipeMapCategory.java @@ -47,7 +47,6 @@ public RecipeMapCategory(IGuiHelper helper,RecipeMap map,ItemStack icon) { this.icon=helper.createDrawableItemStack(icon); } - public RecipeMap recipeMap() { return map; } /** JEI fixes dimensions per category; choose the smallest bounds containing its actual rows. */ public void fitRecipes(java.util.List recipes) { int width = 140, height = 26; diff --git a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java index 5b634ca13..0293003ef 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java +++ b/minecraft/src/main/java/gregtech/content/recipe/MachineRecipeOverlay.java @@ -112,7 +112,6 @@ public static Result apply(RecipeManager manager) { // previous world's rows. Restore every map and drop the tag-owned producers instead of // publishing a partial generation. LOGGER.error("[gregtech] Machine recipe overlay generation {} failed; restoring the baseline", current, failure); - MaterialProcessSnapshot.Store.clear(MaterialProcessSnapshot.Store.current()); recover(checkpoint); lastResult = new Result(0, 0, 0, 0, baselineRows(), false, true); return lastResult; @@ -162,7 +161,6 @@ private static Result applyGeneration(RecipeManager manager, long current) { long removeMillis = (System.nanoTime() - removeStarted) / 1_000_000L; var installStarted = System.nanoTime(); for (var marker : markers) if (marker.addition() != null) install(marker.id(), marker.addition(), tally); - SharedSpecialProcessRows.annotateCurrent(); long installMillis = (System.nanoTime() - installStarted) / 1_000_000L; rememberFurnaceChanges(furnaceBefore); LOGGER.info("[gregtech] Machine recipe overlay baseline {} rows, restore {} ms, producers {} ms, moved {}, " diff --git a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java b/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java deleted file mode 100644 index 8df87dfd5..000000000 --- a/minecraft/src/main/java/gregtech/content/recipe/MaterialProcessSnapshot.java +++ /dev/null @@ -1,1054 +0,0 @@ -package gregtech.content.recipe; - -import com.mojang.logging.LogUtils; -import gregtech.api.addon.material.DataKey; -import gregtech.api.addon.recipe.RecipeOutputChances; -import gregtech.api.material.GTMaterial; -import gregtech.content.block.OreBlock; -import gregtech.content.data.RegisteredFluids; -import gregtech.content.registry.GTFluids; -import gregtech.content.worldgen.MaterialWorldgenFacts; -import gregtech.engine.fluid.FluidVisualPolicy; -import gregtech.engine.material.GTMaterialRegistry; -import gregtech.engine.material.ItemComposition; -import gregtech.engine.material.ItemMaterialRegistry; -import gregtech.engine.material.MaterialEquivalence; -import gregtech.engine.material.MaterialProcessGraph; -import gregtech.engine.material.MaterialProcessGraph.Amount; -import gregtech.engine.material.MaterialProcessGraph.AmountUnit; -import gregtech.engine.material.MaterialProcessGraph.Budgets; -import gregtech.engine.material.MaterialProcessGraph.Direction; -import gregtech.engine.material.MaterialProcessGraph.Notice; -import gregtech.engine.material.MaterialProcessGraph.Port; -import gregtech.engine.material.MaterialProcessGraph.Query; -import gregtech.engine.material.MaterialProcessGraph.Resource; -import gregtech.engine.material.MaterialProcessGraph.Role; -import gregtech.engine.material.MaterialProcessGraph.Step; -import gregtech.engine.material.MaterialPublication; -import gregtech.engine.recipe.Recipe; -import gregtech.engine.recipe.RecipeMap; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.ItemStack; -//? if >=1.21.1 { -/*import net.neoforged.neoforge.fluids.FluidStack; -*///?} else { -import net.minecraftforge.fluids.FluidStack; -//?} -import org.slf4j.Logger; - -/** - * One complete material process generation projected from the final machine maps and active - * world generation facts. Native recipe objects stay behind opaque step references. - */ -public final class MaterialProcessSnapshot { - private static final Logger LOGGER = LogUtils.getLogger(); - private static final char[] HEX = "0123456789abcdef".toCharArray(); - private static final AtomicLong RESOURCE_GENERATIONS = new AtomicLong(); - - public record NativeRecipe(RecipeMap map, Recipe recipe, int index) { - public NativeRecipe { - Objects.requireNonNull(map); - Objects.requireNonNull(recipe); - if (index < 0) throw new IllegalArgumentException("Invalid native recipe index"); - } - - /** Publication fallback ownership also covers ordinary processing such as anvil crushing. */ - public boolean genericRecovery() { - return RecoveryRecipePublisher.generic(recipe) - && (map == gregtech.content.data.MachineRecipeMaps.Shredder - || map == gregtech.content.data.MachineRecipeMaps.Melter - || map == gregtech.content.data.MachineRecipeMaps.Smelter); - } - } - - public record NativeWorldgen(MaterialWorldgenFacts.Fact fact) { - public NativeWorldgen { - Objects.requireNonNull(fact); - } - } - - public record Root(String material, String form, DataKey resource) { - public Root { - if (material == null || material.isBlank() || form == null || form.isBlank()) - throw new IllegalArgumentException("Invalid material process root"); - Objects.requireNonNull(resource); - } - } - - private static final List COVERAGE = List.of( - new Notice("coverage_final_recipes", 0), - new Notice("coverage_active_worldgen", 0), - new Notice("partial_dynamic_selectors", 0), - new Notice("partial_unknown_roles", 0)); - private static final MaterialProcessSnapshot EMPTY = empty(); - - private record Bucket(List steps, Map roots) {} - - private final MaterialProcessGraph.Snapshot snapshot; - private final long resourceGeneration; - private final Map steps; - private final Map resources; - private final MaterialProcessGraph graph; - private final List roots; - private final Map nativeRecipes; - private final Map worldgen; - private final Map> viewerIcons; - private record ViewerRecipe(String process, ItemStack machine) {} - - private final Map viewerRecipes; - - private MaterialProcessSnapshot( - MaterialProcessGraph.Snapshot snapshot, - long resourceGeneration, - Map buckets, - List roots, - Map nativeRecipes, - Map worldgen) { - this(snapshot, resourceGeneration, buckets, roots, nativeRecipes, worldgen, Map.of(), Map.of(), COVERAGE); - } - - private MaterialProcessSnapshot( - MaterialProcessGraph.Snapshot snapshot, - long resourceGeneration, - Map buckets, - List roots, - Map nativeRecipes, - Map worldgen, - Map> viewerIcons, - Map viewerRecipes, - List coverage) { - this.snapshot = snapshot; - this.resourceGeneration = resourceGeneration; - var resources = new LinkedHashMap(); - var steps = new LinkedHashMap(); - buckets.values().forEach(bucket -> bucket.steps.forEach(step -> steps.putIfAbsent(step.reference(), step))); - var builder = MaterialProcessGraph.builder(snapshot); - coverage.forEach(notice -> builder.notice(notice.code(), notice.omitted())); - for (Step step : steps.values()) { - NativeRecipe nativeRecipe = nativeRecipes.get(step.reference()); - builder.add(step, nativeRecipe != null && nativeRecipe.genericRecovery()); - } - this.graph = builder.build(); - int suppliedSteps = steps.size(); - steps.entrySet().removeIf(entry -> graph.step(entry.getKey()).isEmpty()); - for (Step step : steps.values()) { - step.inputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); - step.outputs().forEach(port -> resources.putIfAbsent(port.resource().key(), port.resource())); - } - this.resources = Map.copyOf(resources); - this.steps = Map.copyOf(steps); - this.roots = suppliedSteps == steps.size() ? List.copyOf(roots) : roots.stream().map(root -> { - var candidates = new LinkedHashMap(); - for (Resource resource : buckets.get(root.material()).roots().values()) { - Resource retained = resources.get(resource.key()); - if (retained != null && retained.material().equals(root.material())) - candidates.put(retained.key().toString(), retained); - } - return candidates.isEmpty() ? null : bestRoot(root.material(), candidates); - }).filter(Objects::nonNull).toList(); - var retainedNative = new LinkedHashMap(); - nativeRecipes.forEach((key, value) -> { - if (steps.containsKey(key)) retainedNative.put(key, value); - }); - this.nativeRecipes = Map.copyOf(retainedNative); - var retainedWorldgen = new LinkedHashMap(); - worldgen.forEach((key, value) -> { - if (steps.containsKey(key)) retainedWorldgen.put(key, value); - }); - this.worldgen = Map.copyOf(retainedWorldgen); - var retainedIcons = new LinkedHashMap>(); - viewerIcons.forEach((key, value) -> { - if (resources.containsKey(key)) retainedIcons.put(key, value); - }); - this.viewerIcons = Map.copyOf(retainedIcons); - var retainedRecipes = new LinkedHashMap(); - viewerRecipes.forEach((key, value) -> { - if (steps.containsKey(key)) retainedRecipes.put(key, value); - }); - this.viewerRecipes = Map.copyOf(retainedRecipes); - } - - public List viewerIcons(DataKey resource) { - return viewerIcons.getOrDefault(resource, List.of()).stream().map(ItemStack::copy).toList(); - } - - public ItemStack viewerMachine(DataKey step) { - var recipe = viewerRecipes.get(step); - return recipe == null ? ItemStack.EMPTY : recipe.machine().copy(); - } - - public String process(DataKey step) { - var recipe = nativeRecipes.get(step); - if (recipe != null) return recipe.map().mNameInternal; - var viewer = viewerRecipes.get(step); - var value = steps.get(step); - return viewer != null ? viewer.process() : value == null ? "" : value.name(); - } - - /** Starts a client-local view whose processing rows come exclusively from the viewer. */ - public ViewerBuilder viewerBuilder() { - return new ViewerBuilder(this); - } - - public MaterialProcessGraph.Snapshot snapshot() { - return snapshot; - } - - public List roots() { - return roots; - } - - public Optional resource(DataKey key) { - return Optional.ofNullable(resources.get(key)); - } - - public Query query(DataKey root, Direction direction, Budgets budgets) { - Optional resource = resource(root); - if (resource.isEmpty()) return new Query(snapshot, root, direction, List.of(), List.of(), COVERAGE, false); - return graph.query(root, direction, budgets); - } - - public Query queryMaterial(DataKey root, Budgets budgets) { - if (resource(root).isEmpty()) - return new Query(snapshot, root, Direction.BOTH, List.of(), List.of(), COVERAGE, false); - return graph.queryMaterial(root, budgets); - } - - public MaterialProcessGraph.MaterialQuery queryMaterial(DataKey root) { - return graph.queryMaterial(root); - } - - public List materialSteps(DataKey root) { - return graph.materialSteps(root); - } - - public Optional recipe(DataKey reference) { - return Optional.ofNullable(nativeRecipes.get(reference)); - } - - public Optional worldgen(DataKey reference) { - return Optional.ofNullable(worldgen.get(reference)); - } - - public boolean samePublication(MaterialPublication.Stamp publication) { - return snapshot.publication().equals(publication); - } - - private static MaterialProcessSnapshot empty() { - var stamp = MaterialPublication.current(); - return new MaterialProcessSnapshot( - new MaterialProcessGraph.Snapshot(stamp, 1, 0, 0, 0), - 0, - Map.of(), - List.of(), - Map.of(), - Map.of()); - } - - static MaterialProcessSnapshot build( - MaterialPublication.Stamp publication, - long sessionGeneration, - MaterialWorldgenFacts.Snapshot worldgenFacts) { - return build(publication, sessionGeneration, worldgenFacts, RecipeMap.RECIPE_MAP_LIST); - } - - static MaterialProcessSnapshot build( - MaterialPublication.Stamp publication, - long sessionGeneration, - MaterialWorldgenFacts.Snapshot worldgenFacts, - Iterable maps) { - Objects.requireNonNull(publication); - Objects.requireNonNull(worldgenFacts); - long resourceGeneration = RESOURCE_GENERATIONS.incrementAndGet(); - var graphSnapshot = new MaterialProcessGraph.Snapshot( - publication, - sessionGeneration, - gregtech.engine.material.MaterialViews.contentRevision(), - ItemMaterialRegistry.compositionState().tagGeneration(), - worldgenFacts.revision()); - var mutable = new LinkedHashMap(); - var nativeRecipes = new LinkedHashMap(); - var nativeWorldgen = new LinkedHashMap(); - int invalid = 0; - for (RecipeMap map : maps) { - var rows = new ArrayList(map.mRecipeList); - for (int index = 0; index < rows.size(); index++) { - Recipe recipe = rows.get(index); - if (recipe == null) { - LOGGER.warn("Discarded null material process recipe in {} at index {}", map.mNameInternal, index); - invalid++; - continue; - } - if (!recipe.mEnabled || recipe.mHidden) continue; - if (recipe.mFakeRecipe && !hasMaterialUnitInput(recipe)) continue; - BuiltStep built; - try { - built = recipeStep( - map, recipe, index, publication.revision(), sessionGeneration, resourceGeneration); - } catch (RuntimeException failure) { - LOGGER.warn("Discarded invalid material process recipe in {} at index {}", map.mNameInternal, index, failure); - invalid++; - continue; - } - if (built == null) continue; - built = scoped(built, publication.revision(), resourceGeneration); - addStep(mutable, built.step, built.materials); - nativeRecipes.put(built.step.reference(), new NativeRecipe(map, recipe, index)); - } - } - for (MaterialWorldgenFacts.Fact fact : worldgenFacts.facts()) { - var built = worldgenStep(fact, publication.revision(), sessionGeneration); - if (built == null) continue; - built = scoped(built, publication.revision(), resourceGeneration); - addStep(mutable, built.step, built.materials); - nativeWorldgen.put(built.step.reference(), new NativeWorldgen(fact)); - } - var buckets = new LinkedHashMap(); - mutable.forEach((material, bucket) -> buckets.put(material, bucket.freeze())); - var roots = buckets.entrySet().stream() - .map(entry -> bestRoot(entry.getKey(), entry.getValue().roots)) - .sorted(Comparator.comparing(Root::material, String.CASE_INSENSITIVE_ORDER)) - .toList(); - var coverage = new ArrayList<>(COVERAGE); - if (invalid > 0) coverage.add(new Notice("invalid_process_data", invalid)); - return new MaterialProcessSnapshot( - graphSnapshot, resourceGeneration, buckets, roots, nativeRecipes, nativeWorldgen, Map.of(), Map.of(), coverage); - } - - private static BuiltStep recipeStep( - RecipeMap map, - Recipe recipe, - int index, - long publication, - long session, - long resourceGeneration) { - var inputs = new ArrayList(); - var outputs = new ArrayList(); - var materials = new LinkedHashSet(); - var auxiliaryInputs = new ArrayList(); - String nativeStep = path(map.mNameInternal) + "/" + index; - boolean mainInput = false; - for (int input = 0; input < recipe.mInputs.length; input++) { - ItemStack stack = recipe.mInputs[input]; - if (stack == null || stack.isEmpty()) continue; - if (recipe.isCatalystInput(input)) { - Port port = itemPort(stack, recipe, input, false, false, nativeStep); - if (port != null) inputs.add(port); - else auxiliaryInputs.add("unresolved catalyst: " + BuiltInRegistries.ITEM.getKey(stack.getItem()) - + itemStateSuffix(stack) + " x" + stack.getCount()); - continue; - } - Port port = itemPort(stack, recipe, input, false, !mainInput, nativeStep); - if (port == null) continue; - inputs.add(port); - addMaterial(materials, port); - mainInput |= port.main(); - } - for (int input = 0; input < recipe.mFluidInputs.length; input++) { - FluidStack stack = recipe.mFluidInputs[input]; - if (stack == null || stack.isEmpty()) continue; - Port port = fluidPort(stack, recipe, input, false, !mainInput); - if (port == null) continue; - inputs.add(port); - if (port.role() == Role.CONSUMED) addMaterial(materials, port); - mainInput |= port.main(); - } - for (ItemStack catalyst : gregtech.engine.recipe.RecipeSpecialItems.display(recipe.mSpecialItems)) { - Port port = catalystPort(catalyst, publication, resourceGeneration); - if (port != null) inputs.add(port); - } - boolean mainOutput = false; - for (int output = 0; output < recipe.mOutputs.length; output++) { - ItemStack stack = recipe.mOutputs[output]; - if (stack == null || stack.isEmpty()) continue; - Port port = itemPort(stack, recipe, output, true, !mainOutput, nativeStep); - if (port == null) continue; - outputs.add(port); - addMaterial(materials, port); - mainOutput |= port.main(); - } - for (int output = 0; output < recipe.mFluidOutputs.length; output++) { - FluidStack stack = recipe.mFluidOutputs[output]; - if (stack == null || stack.isEmpty()) continue; - Port port = fluidPort(stack, recipe, output, true, !mainOutput); - if (port == null) continue; - outputs.add(port); - addMaterial(materials, port); - mainOutput |= port.main(); - } - if (materials.isEmpty()) return null; - String mapPath = path(map.mNameInternal); - DataKey reference = new DataKey( - "gt6ce", - "process/machine/" + mapPath + "/" + index + "/" + Long.toUnsignedString(publication, 36) - + "/" + Long.toUnsignedString(session, 36)); - var details = new ArrayList(); - details.addAll(auxiliaryInputs); - details.add("map: " + map.mNameInternal); - details.add("duration: " + recipe.mDuration + " ticks"); - details.add("energy: " + recipe.mEUt + " EU/t"); - if (gregtech.engine.addon.ExclusiveOutputMaps.enabled(map)) - details.add("exclusive output group: the first chance selects one item output"); - if (!recipe.mSource.isBlank()) details.add("source: " + recipe.mSource); - if (recipe.mFakeRecipe) details.add("symbolic unit template"); - if (recipe.mExactItemInputs) details.add("exact item-state matching"); - if (recipe.mExplicitCatalystsOnly) details.add("only explicit catalysts are retained"); - if (recipe.mNeedsEmptyOutput) details.add("empty output slots required"); - if (recipe.mRequiresEmptyContainerInputs) details.add("empty container inputs required"); - var special = gregtech.engine.recipe.RecipeSpecialItems.display(recipe.mSpecialItems); - if (!special.isEmpty()) - details.add("special catalysts: " + special.stream() - .limit(8) - .map(ItemStack::getItem) - .map(BuiltInRegistries.ITEM::getKey) - .map(ResourceLocation::toString) - .toList()); - return new BuiltStep( - new Step( - reference, - map.mNameInternal, - inputs, - outputs, - details, - Optional.ofNullable(recipe.specialProcess()), - true), - materials); - } - - private static Port catalystPort(ItemStack stack, long publication, long resourceGeneration) { - if (stack == null || stack.isEmpty()) return null; - var form = MaterialEquivalence.form(stack); - GTMaterial material = form == null ? material(stack) : form.material().resolve(); - String state = itemDisplayState(stack); - String prefix = form == null ? "item" : form.prefix().getName(); - Resource resource = material == null - ? new Resource(nativeResourceKey("item", state), "unknown", "item", "solid", state) - : itemResource(material, prefix, state); - return scoped( - new Port(resource, Role.CATALYST, new Amount(stack.getCount(), AmountUnit.ITEM), - OptionalInt.empty(), false, List.of("native special catalyst")), - publication, resourceGeneration); - } - - private static Port itemPort( - ItemStack stack, Recipe recipe, int index, boolean output, boolean mainCandidate, String nativeStep) { - String prefix; - GTMaterial material; - String state; - Amount amount; - Recipe.MaterialInputDisplay display = recipe.materialInputDisplay(index); - TagKey tag = output ? null : recipe.itemTag(index); - String nativeSuffix = itemStateSuffix(stack); - if (!output && display != null) { - var representative = material(stack); - if (representative == null) return nativeItemPort(stack, recipe, index, output, mainCandidate, nativeStep); - material = representative; - prefix = "unit"; - var alternatives = display.alternatives().stream() - .filter(candidate -> !candidate.isEmpty()) - .map(ItemStack::getItem) - .map(BuiltInRegistries.ITEM::getKey) - .distinct() - .map(ResourceLocation::toString) - .limit(8) - .sorted() - .toList(); - tag = display.tag() == null ? tag : display.tag(); - state = "unit:" + "rounding=" + display.rounding().name() + "|" - + (tag == null ? "" : "tag=" + tag.location() + "|") + String.join(",", alternatives); - amount = new Amount(display.amount(), AmountUnit.MATERIAL_UNIT); - } else { - var equivalent = MaterialEquivalence.form(stack); - if (equivalent == null) return nativeItemPort(stack, recipe, index, output, mainCandidate, nativeStep); - material = equivalent.material().resolve(); - if (!material.isValid()) return null; - prefix = equivalent.prefix().getName(); - state = tag == null - ? "item:" + BuiltInRegistries.ITEM.getKey(stack.getItem()) + nativeSuffix - : "tag:" + tag.location(); - amount = new Amount(stack.getCount(), AmountUnit.ITEM); - } - OptionalInt chance; - if (output) { - chance = OptionalInt.of(recipe.getOutputChance(index)); - } else { - chance = OptionalInt.empty(); - } - Role role; - if (output) role = Role.UNKNOWN; - else if (recipe.isCatalystInput(index)) role = Role.CATALYST; - else role = Role.CONSUMED; - var details = new ArrayList(); - if (tag != null) details.add("item tag: " + tag.location()); - if (tag == null && !nativeSuffix.isEmpty()) details.add("native stack data is present"); - if (!output && recipe.hasItemInputGuard(index)) details.add("native item-input guard"); - if (!output && recipe.hasSameItemInputPredicate(index)) details.add("native item-state predicate"); - if (!output && recipe.viewerInputNote(index).length() > 0) - details.add(recipe.viewerInputNote(index)); - return new Port( - itemSelector(itemResource(material, prefix, state), recipe, index, output, nativeStep), - role, amount, chance, mainCandidate, details); - } - - private static Port fluidPort( - FluidStack stack, Recipe recipe, int index, boolean output, boolean mainCandidate) { - RegisteredFluids.FluidEntry entry = GTFluids.entryForFluid(stack.getFluid()); - GTMaterial material = entry == null ? null : FluidVisualPolicy.material(entry).resolve(); - if (material != null && !material.isValid()) material = null; - TagKey tag = output ? null : recipe.fluidTag(index); - String nativeSuffix = fluidStateSuffix(stack); - String state = tag == null - ? "fluid:" + BuiltInRegistries.FLUID.getKey(stack.getFluid()) + nativeSuffix - : "tag:" + tag.location(); - String phase = entry != null && entry.gas() ? "gas" : "liquid"; - Role role; - if (output) role = Role.UNKNOWN; - else if (recipe.isCatalystFluidInput(index)) role = Role.CATALYST; - else if (recipe.isPresenceFluidInput(index)) role = Role.PRESENCE; - else role = Role.CONSUMED; - var details = new ArrayList(); - if (tag != null) details.add("fluid tag: " + tag.location()); - if (tag == null && !nativeSuffix.isEmpty()) details.add("native fluid data is present"); - return new Port( - new Resource( - material == null ? nativeResourceKey("fluid", state) : resourceKey("fluid", material, "fluid", phase, state), - material == null ? "unknown" : material.getName(), - "fluid", - phase, - state), - role, - new Amount(stack.getAmount(), AmountUnit.MILLIBUCKET), - output ? OptionalInt.of(RecipeOutputChances.CERTAIN) : OptionalInt.empty(), - mainCandidate, - details); - } - - private static BuiltStep worldgenStep( - MaterialWorldgenFacts.Fact fact, long publication, long session) { - var merged = new LinkedHashMap(); - var materials = new LinkedHashSet(); - for (MaterialWorldgenFacts.Ore ore : fact.ores()) { - Resource resource = worldgenResource(ore); - var details = new ArrayList<>(ore.details()); - details.add("dimension: " + fact.dimension()); - details.add("height: " + ore.minY() + ".." + ore.maxY()); - if (ore.chanceDivisor() > 0) details.add("native roll divisor: " + ore.chanceDivisor()); - Port port = new Port( - resource, - Role.UNKNOWN, - new Amount(Math.max(1, ore.amount()), AmountUnit.ITEM), - OptionalInt.empty(), - merged.isEmpty(), - details); - Port previous = merged.putIfAbsent(resource.key(), port); - if (previous != null) { - var combined = new ArrayList<>(previous.details()); - combined.addAll(port.details()); - merged.put( - resource.key(), - new Port( - resource, - previous.role(), - new Amount( - Math.max(previous.amount().value(), port.amount().value()), - previous.amount().unit()), - previous.chance(), - previous.main(), - combined)); - } - materials.add(ore.material().getName()); - } - if (materials.isEmpty()) return null; - DataKey reference = new DataKey( - "gt6ce", - "process/worldgen/" + path(fact.id()) + "/" + Long.toUnsignedString(publication, 36) + "/" - + Long.toUnsignedString(session, 36)); - var details = new ArrayList(); - details.add("worldgen: " + fact.name()); - details.add("kind: " + fact.kind().name().toLowerCase(Locale.ROOT)); - details.add("dimension: " + fact.dimension()); - details.add("height: " + fact.minY() + ".." + fact.maxY()); - if (fact.weight() > 0) { - details.add("selection weight: " + fact.weight()); - if (fact.totalWeight() > 0) details.add("total selection weight: " + fact.totalWeight()); - } - return new BuiltStep( - new Step(reference, fact.name(), List.of(), List.copyOf(merged.values()), details, true), - materials); - } - - private static Resource itemResource(GTMaterial material, String prefix, String state) { - return new Resource( - resourceKey("item", material, prefix, "solid", state), - material.resolve().getName(), - prefix, - "solid", - state); - } - - private static void addMaterial(Set materials, Port port) { - if (!port.resource().material().equals("unknown")) materials.add(port.resource().material()); - } - - private static Port nativeItemPort( - ItemStack stack, Recipe recipe, int index, boolean output, boolean main, String nativeStep) { - GTMaterial material = material(stack); - String state = "item:" + BuiltInRegistries.ITEM.getKey(stack.getItem()) + itemStateSuffix(stack); - String form = "item"; - if (stack.getItem() instanceof BlockItem block - && block.getBlock() instanceof OreBlock ore) { - material = ore.material().resolve(); - form = ore.isSmall() ? "oreSmall" : "oreVanillastone"; - } - var tag = output ? null : recipe.itemTag(index); - if (tag != null) state = "tag:" + tag.location(); - Resource resource = material == null - ? new Resource( - nativeResourceKey("item", state), - "unknown", "item", "solid", state) - : itemResource(material, form, state); - var details = new ArrayList(); - details.add("native item: " + BuiltInRegistries.ITEM.getKey(stack.getItem())); - details.add("material form is not classified; see the original recipe for matching conditions"); - if (!output && recipe.hasItemInputGuard(index)) details.add("native item-input guard"); - if (!output && recipe.hasSameItemInputPredicate(index)) details.add("native item-state predicate"); - if (!output && !recipe.viewerInputNote(index).isEmpty()) details.add(recipe.viewerInputNote(index)); - return new Port(itemSelector(resource, recipe, index, output, nativeStep), output ? Role.UNKNOWN : Role.CONSUMED, - new Amount(stack.getCount(), AmountUnit.ITEM), - output ? OptionalInt.of(recipe.getOutputChance(index)) : OptionalInt.empty(), main, details); - } - - private static Resource itemSelector(Resource resource, Recipe recipe, int index, boolean output, String nativeStep) { - if (output || recipe.materialInputDisplay(index) == null - && !recipe.hasItemInputGuard(index) && !recipe.hasSameItemInputPredicate(index)) return resource; - var key = new DataKey(resource.key().namespace(), resource.key().path() + "/selector/" + nativeStep + "/" + index); - return new Resource(key, resource.material(), resource.form(), resource.phase(), resource.state()); - } - - private static DataKey nativeResourceKey(String kind, String state) { - return new DataKey("gt6ce", "resource/native/" + kind + "/" + path(state) + "/" - + Integer.toUnsignedString(state.hashCode(), 36)); - } - - private static Resource worldgenResource(MaterialWorldgenFacts.Ore ore) { - String state = ore.itemState(); - if (state.startsWith("item:")) { - ResourceLocation id = ResourceLocation.tryParse(state.substring("item:".length())); - if (id != null) { - var form = MaterialEquivalence.form(new ItemStack(BuiltInRegistries.ITEM.get(id))); - if (form != null && form.material().resolve() == ore.material().resolve()) - return itemResource(ore.material(), form.prefix().getName(), state); - var item = BuiltInRegistries.ITEM.get(id); - if (item instanceof BlockItem block - && block.getBlock() instanceof OreBlock nativeOre - && nativeOre.material().resolve() == ore.material().resolve()) - return itemResource(ore.material(), nativeOre.isSmall() ? "oreSmall" : "oreVanillastone", state); - } - } - return itemResource(ore.material(), "worldgen", state); - } - - private static BuiltStep scoped(BuiltStep built, long publication, long session) { - Step step = built.step; - return new BuiltStep(new Step(step.reference(), step.name(), - step.inputs().stream().map(port -> scoped(port, publication, session)).toList(), - step.outputs().stream().map(port -> scoped(port, publication, session)).toList(), - step.details(), step.specialProcess(), step.resolved()), built.materials); - } - - private static Port scoped(Port port, long publication, long session) { - Resource resource = port.resource(); - var key = new DataKey(resource.key().namespace(), resource.key().path() + "/generation/" - + Long.toUnsignedString(publication, 36) + "/" + Long.toUnsignedString(session, 36)); - return new Port(new Resource(key, resource.material(), resource.form(), resource.phase(), resource.state()), - port.role(), port.amount(), port.chance(), port.main(), port.details()); - } - - private static DataKey resourceKey( - String kind, GTMaterial material, String form, String phase, String state) { - return new DataKey( - "gt6ce", - "resource/" + kind + "/" + path(material.resolve().getName()) + "/" + path(form) + "/" - + path(phase) + "/" + path(state) + "/" + Integer.toUnsignedString(state.hashCode(), 36)); - } - - private static GTMaterial material(ItemStack stack) { - Optional composition = ItemMaterialRegistry.get(stack); - if (composition.isEmpty()) return null; - var row = composition.get(); - if (row.components().size() != 1) return null; - return row.components().get(0).material().resolve(); - } - - private static boolean hasMaterialUnitInput(Recipe recipe) { - for (int index = 0; index < recipe.mInputs.length; index++) - if (recipe.materialInputDisplay(index) != null) return true; - return false; - } - - private static void addStep( - Map buckets, Step step, Set materials) { - for (String material : materials) { - var bucket = buckets.computeIfAbsent(material, ignored -> new MutableBucket()); - bucket.steps.putIfAbsent(step.reference(), step); - for (Port port : step.inputs()) - if (port.resource().material().equals(material)) - bucket.resource(port.resource()); - for (Port port : step.outputs()) - if (port.resource().material().equals(material)) - bucket.resource(port.resource()); - } - } - - private static Root bestRoot(String material, Map resources) { - Resource best = null; - int bestRank = Integer.MAX_VALUE; - for (Resource resource : resources.values()) { - int rank = rootRank(resource.form()); - if (best == null - || rank < bestRank - || (rank == bestRank - && resource.key().toString().compareTo(best.key().toString()) < 0)) { - best = resource; - bestRank = rank; - } - } - return new Root(material, best.form(), best.key()); - } - - private static int rootRank(String form) { - return switch (form) { - case "ore", "oreVanillastone" -> 0; - case "oreRaw", "oreDense" -> 1; - case "crushed" -> 2; - case "dust" -> 3; - case "oreSmall" -> 5; - case "fluid" -> 6; - default -> 4; - }; - } - - private static String path(String value) { - String path = value.toLowerCase(Locale.ROOT) - .replace(':', '/') - .replace(',', '/') - .replaceAll("[^a-z0-9/._-]", "_"); - return path.isBlank() ? "unknown" : path; - } - - /** State-sensitive display identity, independent of query scopes and per-recipe selectors. */ - public static String itemDisplayState(ItemStack stack) { - return "item:" + BuiltInRegistries.ITEM.getKey(stack.getItem()) + itemStateSuffix(stack); - } - - public static String fluidDisplayState(FluidStack stack) { - return "fluid:" + BuiltInRegistries.FLUID.getKey(stack.getFluid()) + fluidStateSuffix(stack); - } - - private static String itemStateSuffix(ItemStack stack) { - var suffix = new StringBuilder(); - if (stack.isDamaged()) suffix.append("#damaged").append(stack.getDamageValue()); -//? if >=1.21.1 { - /*if (!stack.getComponentsPatch().isEmpty()) - suffix.append("#components").append(fingerprint(stack.getComponentsPatch().toString())); -*///?} else { - if (stack.hasTag()) suffix.append("#tag").append(fingerprint(stack.getTag().toString())); -//?} - return suffix.toString(); - } - - private static String fluidStateSuffix(FluidStack stack) { -//? if >=1.21.1 { - /*return stack.getComponentsPatch().isEmpty() - ? "" - : "#components" + fingerprint(stack.getComponentsPatch().toString()); -*///?} else { - return stack.hasTag() ? "#tag" + fingerprint(stack.getTag().toString()) : ""; -//?} - } - - private static String fingerprint(String value) { - try { - byte[] digest = MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8)); - var hex = new StringBuilder(16); - for (int index = 0; index < 8; index++) { - int bits = digest[index] & 0xff; - hex.append(HEX[bits >>> 4]).append(HEX[bits & 0x0f]); - } - return hex.toString(); - } catch (NoSuchAlgorithmException impossible) { - throw new IllegalStateException("SHA-256 is unavailable", impossible); - } - } - - private record BuiltStep(Step step, Set materials) { - private BuiltStep { - materials = Set.copyOf(materials); - } - } - - private static final class MutableBucket { - private final LinkedHashMap steps = new LinkedHashMap<>(); - private final LinkedHashMap roots = new LinkedHashMap<>(); - - private void resource(Resource resource) { - roots.putIfAbsent(resource.key().toString(), resource); - } - - private Bucket freeze() { - return new Bucket(List.copyOf(steps.values()), Map.copyOf(roots)); - } - } - - /** Native stacks and semantic rows for one viewer reload; never published as server recipes. */ - public static final class ViewerBuilder { - private final MaterialProcessSnapshot source; - private final Map buckets = new LinkedHashMap<>(); - private final Map recipes = new LinkedHashMap<>(); - private final Map> icons = new LinkedHashMap<>(); - private final Map viewerRecipes = new LinkedHashMap<>(); - private final Map> selected = new java.util.IdentityHashMap<>(); - private final Map> nativeReferences = new java.util.IdentityHashMap<>(); - private int omitted; - - private ViewerBuilder(MaterialProcessSnapshot source) { - this.source = source; - source.nativeRecipes.forEach((reference, row) -> nativeReferences - .computeIfAbsent(row.map(), ignored -> new java.util.IdentityHashMap<>()).put(row.recipe(), reference)); - source.steps.values().stream() - .filter(step -> source.worldgen.containsKey(step.reference()) - || Optional.ofNullable(source.nativeRecipes.get(step.reference())) - .map(NativeRecipe::map) - .map(map -> !map.mViewerAllowed) - .orElse(false)) - .sorted(Comparator.comparing(step -> step.reference().toString())) - .forEach(step -> { - add(step); - Optional.ofNullable(source.nativeRecipes.get(step.reference())) - .ifPresent(recipe -> recipes.put(step.reference(), recipe)); - }); - } - - public void omitted() { - omitted++; - } - - public long publicationRevision() { - return source.snapshot.publication().revision(); - } - - public long sessionGeneration() { - return source.snapshot.sessionGeneration(); - } - - /** Reuses GT matching, unit quantities and recovery ownership, once per visible native row. */ - public boolean machine(RecipeMap map, Recipe recipe) { - if (!recipe.mEnabled || recipe.mHidden || recipe.mFakeRecipe && !hasMaterialUnitInput(recipe)) return false; - var rows = selected.computeIfAbsent(map, ignored -> java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>())); - if (rows.contains(recipe)) return true; - DataKey reference = nativeReferences.getOrDefault(map, Map.of()).get(recipe); - if (reference != null) { - add(source.steps.get(reference)); - recipes.put(reference, source.nativeRecipes.get(reference)); - rows.add(recipe); - return true; - } - int index = map.mRecipeList.size() + recipes.size(); - BuiltStep built = recipeStep( - map, - recipe, - index, - source.snapshot.publication().revision(), - source.snapshot.sessionGeneration(), - source.resourceGeneration); - if (built == null) return false; - built = scoped(built, source.snapshot.publication().revision(), source.resourceGeneration); - addStep(buckets, built.step, built.materials); - recipes.put(built.step.reference(), new NativeRecipe(map, recipe, index)); - rows.add(recipe); - return true; - } - - public Port item(ItemStack stack, Role role, long amount, OptionalInt chance) { - String state = itemDisplayState(stack); - var form = MaterialEquivalence.form(stack); - GTMaterial material = form == null ? material(stack) : form.material().resolve(); - String prefix = form == null ? "item" : form.prefix().getName(); - if (stack.getItem() instanceof BlockItem block && block.getBlock() instanceof OreBlock ore) { - material = ore.material().resolve(); - prefix = ore.isSmall() ? "oreSmall" : "oreVanillastone"; - } - Resource resource = material == null - ? new Resource(nativeResourceKey("item", state), "unknown", "item", "solid", state) - : itemResource(material, prefix, state); - return port(resource, role, new Amount(amount, AmountUnit.ITEM), chance, stack.copyWithCount(1)); - } - - public Port fluid(FluidStack stack, Role role, long amount, OptionalInt chance) { - var entry = GTFluids.entryForFluid(stack.getFluid()); - GTMaterial material = entry == null ? null : FluidVisualPolicy.material(entry).resolve(); - if (material != null && !material.isValid()) material = null; - String state = fluidDisplayState(stack); - String phase = entry != null && entry.gas() ? "gas" : "liquid"; - var resource = new Resource( - material == null ? nativeResourceKey("fluid", state) : resourceKey("fluid", material, "fluid", phase, state), - material == null ? "unknown" : material.getName(), "fluid", phase, state); -//? if >=1.21.1 { - /*var lookup = gregtech.engine.fluid.FluidDisplayBinding.currentLookup(); - var icon = lookup == null ? ItemStack.EMPTY : gregtech.engine.fluid.FluidDisplayBinding.display(lookup, stack); -*///?} else { - var icon = gregtech.engine.fluid.FluidDisplayBinding.display(stack); -//?} - return port(resource, role, new Amount(amount, AmountUnit.MILLIBUCKET), chance, icon); - } - - private Port port(Resource resource, Role role, Amount amount, OptionalInt chance, ItemStack icon) { - var port = scoped(new Port(resource, role, amount, chance, false, List.of()), - source.snapshot.publication().revision(), source.resourceGeneration); - if (!icon.isEmpty()) icons.putIfAbsent(port.resource().key(), List.of(icon.copyWithCount(1))); - return port; - } - - /** Alternatives remain one selector, never a list of simultaneously consumed inputs. */ - public Port alternatives(List candidates) { - if (candidates.isEmpty()) throw new IllegalArgumentException("Empty viewer selector"); - Port first = candidates.get(0); - if (candidates.size() == 1) return first; - Resource representative = first.resource(); - boolean sameMaterial = candidates.stream().allMatch(port -> port.resource().material().equals(representative.material())); - boolean sameForm = candidates.stream().allMatch(port -> port.resource().form().equals(representative.form())); - boolean samePhase = candidates.stream().allMatch(port -> port.resource().phase().equals(representative.phase())); - String state = "selector:" + fingerprint(candidates.stream() - .map(port -> port.resource().state()).distinct().sorted().collect(java.util.stream.Collectors.joining("|"))); - Resource resource = new Resource(nativeResourceKey("selector", state), - sameMaterial ? representative.material() : "unknown", - sameForm ? representative.form() : "selector", samePhase ? representative.phase() : "unknown", state); - Amount amount = candidates.stream().allMatch(port -> port.amount().equals(first.amount())) - ? first.amount() : Amount.unknown(); - OptionalInt chance = !first.output() && candidates.stream().allMatch(port -> port.chance().equals(first.chance())) - ? first.chance() : OptionalInt.empty(); - var result = scoped(new Port(resource, first.role(), amount, chance, false, - List.of("viewer alternatives: " + candidates.size(), "matching constraints: see original recipe")), - source.snapshot.publication().revision(), source.resourceGeneration); - var representatives = new LinkedHashMap(); - for (Port candidate : candidates) - for (ItemStack icon : icons.getOrDefault(candidate.resource().key(), List.of())) { - if (representatives.size() >= 16) break; - representatives.putIfAbsent(itemDisplayState(icon), icon.copyWithCount(1)); - } - icons.put(result.resource().key(), List.copyOf(representatives.values())); - return result; - } - - public void recipe(DataKey reference, String name, ItemStack machine, - List inputs, List outputs, List details) { - recipe(reference, name, machine, inputs, outputs, details, true); - } - - public void recipe(DataKey reference, String name, ItemStack machine, - List inputs, List outputs, List details, boolean resolved) { - recipe(reference, name, name, machine, inputs, outputs, details, resolved); - } - - public void recipe(DataKey reference, String process, String name, ItemStack machine, - List inputs, List outputs, List details, boolean resolved) { - resolved &= java.util.stream.Stream.concat(inputs.stream(), outputs.stream()) - .noneMatch(port -> port.resource().state().startsWith("selector:")); - add(new Step(reference, name, inputs, outputs, details, resolved)); - viewerRecipes.put(reference, new ViewerRecipe(process, machine.copyWithCount(1))); - } - - private void add(Step step) { - var materials = new LinkedHashSet(); - step.inputs().forEach(port -> addMaterial(materials, port)); - step.outputs().forEach(port -> addMaterial(materials, port)); - addStep(buckets, step, materials); - } - - public MaterialProcessSnapshot build() { - var frozen = new LinkedHashMap(); - buckets.forEach((material, bucket) -> frozen.put(material, bucket.freeze())); - var roots = frozen.entrySet().stream().map(entry -> bestRoot(entry.getKey(), entry.getValue().roots)) - .sorted(Comparator.comparing(Root::material, String.CASE_INSENSITIVE_ORDER)).toList(); - var coverage = new ArrayList<>(COVERAGE); - coverage.add(new Notice("coverage_viewer_recipes", 0)); - coverage.add(new Notice("partial_viewer_recipes", omitted)); - return new MaterialProcessSnapshot(source.snapshot, source.resourceGeneration, frozen, roots, recipes, - source.worldgen, icons, viewerRecipes, coverage); - } - } - - /** Current publication retained for lifecycle-bound viewer callbacks. */ - public static final class Store { - private static volatile MaterialProcessSnapshot current = EMPTY; - - private Store() {} - - public static MaterialProcessSnapshot current() { - return current; - } - - public static boolean current(MaterialProcessSnapshot snapshot) { - return current == snapshot; - } - - public static synchronized MaterialProcessSnapshot publish( - MaterialPublication.Stamp publication, long sessionGeneration) { - if (sessionGeneration <= 0 || MachineRecipeOverlay.lastResult().failed()) return current; - try { - long started = System.nanoTime(); - var worldgen = MaterialWorldgenFacts.capture(); - if (current.samePublication(publication) - && current.snapshot.sessionGeneration() == sessionGeneration - && current.snapshot.formRevision() == gregtech.engine.material.MaterialViews.contentRevision() - && current.snapshot.tagGeneration() == ItemMaterialRegistry.compositionState().tagGeneration() - && current.snapshot.worldgenRevision() == worldgen.revision()) { - gregtech.engine.material.MaterialPublication.commit(publication); - return current; - } - MaterialProcessSnapshot built = - MaterialProcessSnapshot.build(publication, sessionGeneration, worldgen); - current = built; - gregtech.engine.material.MaterialPublication.commit(publication); - LOGGER.info( - "[gregtech] Material process snapshot {} published with {} material roots, " - + "{} recipe refs in {} ms", - publication.revision(), - built.roots.size(), - built.nativeRecipes.size(), - (System.nanoTime() - started) / 1_000_000L); - return built; - } catch (RuntimeException failure) { - LOGGER.error( - "[gregtech] Material process snapshot {} rebuild failed; retaining revision {}", - publication.revision(), - current.snapshot.publication().revision(), - failure); - return current; - } - } - - public static synchronized void clear(MaterialProcessSnapshot expected) { - if (current != expected) return; - current = EMPTY; - } - } -} diff --git a/minecraft/src/main/java/gregtech/content/recipe/RecipePublication.java b/minecraft/src/main/java/gregtech/content/recipe/RecipePublication.java index a566d743d..de6ca8c27 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/RecipePublication.java +++ b/minecraft/src/main/java/gregtech/content/recipe/RecipePublication.java @@ -45,8 +45,8 @@ public static void publish(MinecraftServer server) { Collection current = manager.getRecipes(); var applied = APPLIED.get(manager); if (applied != null && applied.size() == current.size() && applied.containsAll(current)) { - MaterialProcessSnapshot.Store.publish( - MachineRecipeOverlay.lastPublication(), MachineRecipeOverlay.generation()); + if (MachineRecipeOverlay.generation() > 0 && !MachineRecipeOverlay.lastResult().failed()) + gregtech.engine.material.MaterialPublication.commit(MachineRecipeOverlay.lastPublication()); return; } RegistryAccess access = server.registryAccess(); @@ -61,9 +61,8 @@ public static void publish(MinecraftServer server) { OvenRecipeBridge.apply(working, access); dedup(working, access); manager.replaceRecipes(working.getRecipes()); - if (!MachineRecipeOverlay.lastResult().failed()) - MaterialProcessSnapshot.Store.publish( - MachineRecipeOverlay.lastPublication(), MachineRecipeOverlay.generation()); + if (MachineRecipeOverlay.generation() > 0 && !MachineRecipeOverlay.lastResult().failed()) + gregtech.engine.material.MaterialPublication.commit(MachineRecipeOverlay.lastPublication()); //? if >=1.21.1 { /*ShapelessRecipeTooltipIndex.rebuild(manager, access); *///?} else { @@ -105,7 +104,6 @@ private static void dedup(RecipeManager manager, RegistryAccess access) { /** Drops the generation snapshot after the server stops; the next world starts fresh. */ public static void clear() { - MaterialProcessSnapshot.Store.clear(MaterialProcessSnapshot.Store.current()); APPLIED.clear(); } } diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java index 6500f6f08..f2e78052b 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java @@ -11,7 +11,6 @@ import gregtech.content.data.FluidCatalog; import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.content.registry.GTFluids; -import gregtech.engine.material.MaterialEquivalence; import gregtech.engine.material.GTMaterialRegistry; import gregtech.engine.material.MaterialViews; import gregtech.engine.prefix.PrefixRegistry; @@ -50,7 +49,6 @@ public static void clear() { map.unlink(recipe); })); OWNED.clear(); - RecipeMap.RECIPE_MAP_LIST.forEach(map -> map.mRecipeList.forEach(recipe -> recipe.withSpecialProcess(null))); } public static Set owned() { @@ -93,7 +91,6 @@ public static void rebuild() { } Recipe accepted = map.addRecipe(built.recipe()); if (accepted != null) { - accepted.withSpecialProcess(method.process().id()); OWNED.add(accepted); } } @@ -104,76 +101,6 @@ public static void rebuild() { com.mojang.logging.LogUtils.getLogger() .warn("[gregtech] Omitted {} special-process rows whose material forms or reagent did not resolve", omitted); - annotateExistingRows(methods); - } - - /** Marks rows installed after static/addon producers, including datapack recipe documents. */ - public static void annotateCurrent() { - if (!initialized) return; - annotateExistingRows(methodRules(MaterialViews.catalog())); - } - - private static void annotateExistingRows(List methods) { - var byMap = methods.stream() - .collect(java.util.stream.Collectors.groupingBy( - rules -> rules.method().recipeMap(), LinkedHashMap::new, java.util.stream.Collectors.toList())); - for (var map : RecipeMap.RECIPE_MAP_LIST) { - var candidates = byMap.getOrDefault(map.mNameInternal, List.of()); - if (candidates.isEmpty()) continue; - for (var recipe : map.mRecipeList) { - if (recipe.specialProcess() != null) continue; - var matches = candidates.stream().filter(rules -> matches(recipe, rules)).toList(); - if (matches.size() > 1) - com.mojang.logging.LogUtils.getLogger().warn( - "[gregtech] Skipping ambiguous special-process annotation in {}", map.mNameInternal); - if (matches.size() == 1) - recipe.withSpecialProcess(matches.get(0).method().process().id()); - } - } - } - - private static boolean matches(Recipe recipe, MethodRules rules) { - for (var target : rules.targets()) { - boolean hasTarget = target.inputCounts().entrySet().stream() - .anyMatch(input -> containsItem(recipe, target.material(), input.getKey(), input.getValue())); - if (!hasTarget) continue; - for (var reagent : rules.reagents()) - for (var form : reagent.forms()) - if (containsInput(recipe, reagent.material(), form, target.plan().reagentAmount())) return true; - } - return false; - } - - private static boolean containsInput(Recipe recipe, MaterialKey material, FormKey form, long amount) { - return isFluid(form) - ? java.util.Arrays.stream(recipe.mFluidInputs) - .anyMatch(stack -> sameFluidMaterial(stack, material, form) && stack.getAmount() == amount) - : java.util.Arrays.stream(recipe.mInputs) - .anyMatch(stack -> sameItemForm(stack, material, form) && stack.getCount() == amount); - } - - private static boolean containsItem(Recipe recipe, MaterialKey material, FormKey form, int count) { - return java.util.Arrays.stream(recipe.mInputs) - .anyMatch(stack -> stack != null - && !stack.isEmpty() - && stack.getCount() == count - && sameItemForm(stack, material, form)); - } - - private static boolean sameItemForm(ItemStack stack, MaterialKey material, FormKey form) { - if (stack == null || stack.isEmpty()) return false; - var equivalent = MaterialEquivalence.form(stack); - return equivalent != null - && equivalent.material().resolve().getName().equals(material.name()) - && equivalent.prefix().getName().equals(form.name()); - } - - private static boolean sameFluidMaterial(FluidStack stack, MaterialKey material, FormKey form) { - if (stack == null || stack.isEmpty() || !isFluid(form)) return false; - var entry = GTFluids.entryForFluid(stack.getFluid()); - if (entry == null) return false; - var value = gregtech.engine.fluid.FluidVisualPolicy.material(entry).resolve(); - return value.isValid() && value.getName().equals(material.name()) && entry.gas() == form.name().equals("gas"); } private record BuildResult(Recipe recipe) {} diff --git a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java b/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java deleted file mode 100644 index 0f552a12b..000000000 --- a/minecraft/src/main/java/gregtech/content/worldgen/MaterialWorldgenFacts.java +++ /dev/null @@ -1,346 +0,0 @@ -package gregtech.content.worldgen; - -import gregtech.api.addon.material.FormKey; -import gregtech.api.addon.material.GregTechMaterials; -import gregtech.api.addon.material.MaterialFormBinding; -import gregtech.api.addon.material.MaterialFormKind; -import gregtech.api.addon.material.MaterialKey; -import gregtech.api.addon.worldgen.OreVeinDeclaration; -import gregtech.api.addon.worldgen.SmallOreDeclaration; -import gregtech.api.material.GTMaterial; -import gregtech.engine.material.GTMaterialRegistry; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Locale; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; - -/** Fact-only world-generation projection used by the material process snapshot. */ -public final class MaterialWorldgenFacts { - public enum Kind { - LARGE_VEIN, - SMALL_ORE, - STONE_LAYER, - BEDROCK - } - - public record Ore( - GTMaterial material, - String itemState, - int minY, - int maxY, - int amount, - int chanceDivisor, - List details) { - public Ore { - itemState = requireState(itemState); - details = List.copyOf(details); - } - } - - public record Fact( - String id, - String name, - Kind kind, - String dimension, - int minY, - int maxY, - int weight, - int totalWeight, - List ores) { - public Fact { - if (id == null || id.isBlank() || name == null || name.isBlank() || kind == null) - throw new IllegalArgumentException("Invalid worldgen process fact"); - dimension = dimension == null || dimension.isBlank() ? "unknown" : dimension; - ores = List.copyOf(ores); - } - } - - public static final class Snapshot { - private final List facts; - private final long revision; - - public Snapshot(List facts) { - this.facts = List.copyOf(facts); - long hash = 1_125_899_906_842_589L; - for (Fact fact : facts) { - hash = hash(hash, fact.id()); - hash = hash(hash, fact.name()); - hash = hash(hash, fact.kind().name()); - hash = hash(hash, fact.dimension()); - hash = hash(hash, Integer.toString(fact.minY())); - hash = hash(hash, Integer.toString(fact.maxY())); - hash = hash(hash, Integer.toString(fact.weight())); - hash = hash(hash, Integer.toString(fact.totalWeight())); - hash = hash(hash, Integer.toString(fact.ores().size())); - for (Ore ore : fact.ores()) { - hash = hash(hash, ore.material().resolve().getName()); - hash = hash(hash, ore.itemState()); - hash = hash(hash, Integer.toString(ore.minY())); - hash = hash(hash, Integer.toString(ore.maxY())); - hash = hash(hash, Integer.toString(ore.amount())); - hash = hash(hash, Integer.toString(ore.chanceDivisor())); - hash = hash(hash, Integer.toString(ore.details().size())); - for (String detail : ore.details()) hash = hash(hash, detail); - } - } - revision = hash & Long.MAX_VALUE; - } - - private static long hash(long hash, String value) { - hash = 31 * hash + value.length(); - for (int index = 0; index < value.length(); index++) hash = 31 * hash + value.charAt(index); - return hash; - } - - public List facts() { - return facts; - } - - public long revision() { - return revision; - } - } - - private MaterialWorldgenFacts() {} - - public static Snapshot capture() { - var facts = new ArrayList(); - if (gregtech.GregTechConfig.Worldgen.GEOLOGY.enabled()) { - appendLargeVeins(facts); - appendSmallOres(facts); - appendStoneLayers(facts); - } - if (gregtech.GregTechConfig.Worldgen.BEDROCK_ORES.enabled()) appendBedrock(facts); - return new Snapshot(facts); - } - - private static void appendLargeVeins(List facts) { - var dimensions = new LinkedHashSet(); - dimensions.add(OreVeinDeclaration.OVERWORLD); - dimensions.add(OreVeinDeclaration.END); - dimensions.addAll(AddonOreVeins.veinDimensions()); - for (String dimension : dimensions) { - var veins = GTOreVeins.activeVeins(dimension); - boolean remapped = OreVeinDeclaration.OVERWORLD.equals(dimension); - int totalWeight = OreVeinDeclaration.END.equals(dimension) - ? GTOreVeins.endSelectionWeight(veins) - : veins.stream().mapToInt(GTOreVeins.OreVein::weight).sum(); - for (GTOreVeins.OreVein vein : veins) { - int minY = remapped ? GTWorldgenScale.remapY(vein.minY()) : vein.minY(); - int maxY = remapped ? GTWorldgenScale.remapY(vein.maxY()) : vein.maxY(); - var ores = new ArrayList(); - addVeinOre(ores, vein.top(), minY, maxY, "top"); - addVeinOre(ores, vein.bottom(), minY, maxY, "bottom"); - addVeinOre(ores, vein.between(), minY, maxY, "between"); - addVeinOre(ores, vein.spread(), minY, maxY, "spread"); - if (ores.isEmpty()) continue; - facts.add(new Fact( - "large/" + dimension + "/" + vein.name(), - vein.name(), - Kind.LARGE_VEIN, - dimension, - minY, - maxY, - vein.weight(), - totalWeight, - ores)); - } - } - } - - private static void addVeinOre(List out, GTMaterial material, int minY, int maxY, String layer) { - if (material == null || !material.resolve().isValid()) return; - Item item = oreItem(material.resolve()); - if (item == Items.AIR) return; - out.add(new Ore(material.resolve(), itemState(item), minY, maxY, 1, 0, List.of("vein layer: " + layer))); - } - - private static void appendSmallOres(List facts) { - var dimensions = new LinkedHashSet(); - dimensions.add(SmallOreDeclaration.OVERWORLD); - dimensions.add(SmallOreDeclaration.NETHER); - dimensions.add(SmallOreDeclaration.END); - dimensions.addAll(AddonOreVeins.smallOreDimensions()); - for (String dimension : dimensions) { - boolean remapped = SmallOreDeclaration.OVERWORLD.equals(dimension); - for (GTOreVeins.SmallOre ore : GTOreVeins.activeSmallOres(dimension)) { - GTMaterial material = ore.material().resolve(); - if (!material.isValid()) continue; - Item item = smallOreItem(material); - if (item == Items.AIR) continue; - int minY = remapped ? GTWorldgenScale.remapY(ore.minY()) : ore.minY(); - int maxY = remapped ? GTWorldgenScale.remapY(ore.maxY()) : ore.maxY(); - facts.add(new Fact( - "small/" + dimension + "/" + ore.name(), - ore.name(), - Kind.SMALL_ORE, - dimension, - minY, - maxY, - 0, - 0, - List.of(new Ore( - material, itemState(item), minY, maxY, ore.amount(), 0, List.of("blocks per chunk"))))); - } - } - } - - private static void appendStoneLayers(List facts) { - if (!GTWorldgenDefaults.STONE_LAYERS) return; - var layers = new ArrayList(); - layers.addAll(GTStoneLayersGen.LAYERS); - for (GTStoneLayersGen.ContactDef contact : GTStoneLayersGen.CONTACTS) { - layers.add(new GTStoneLayersGen.LayerDef( - null, null, contact.materialA() + "/" + contact.materialB(), false, contact.ores())); - if (contact.bothSides()) { - layers.add(new GTStoneLayersGen.LayerDef( - null, null, contact.materialB() + "/" + contact.materialA(), false, contact.ores())); - } - } - int sequence = 0; - for (GTStoneLayersGen.LayerDef layer : layers) { - int layerIndex = sequence++; - var ores = new ArrayList(); - for (GTStoneLayersGen.OreDef definition : layer.ores()) { - var rule = StoneLayerOreRules.rule(definition); - if (!StoneLayerOrePlacement.enabled(rule)) continue; - GTMaterial material = GTMaterialRegistry.get(definition.material()); - if (material == null || !material.resolve().isValid()) continue; - material = material.resolve(); - int min = Math.max(GTWorldgenScale.WORLD_FLOOR + 1, GTWorldgenScale.stoneLayerOreMinY(definition)); - if (layer.noDeep()) min = Math.max(min, GTWorldgenScale.remapY(24)); - int max = Math.min(GTWorldgenScale.BAND_TOP - 1, GTWorldgenScale.remapY(definition.maxY())); - if (min > max) continue; - List oreDetails = rule.biomes().isEmpty() - ? List.of("stone-layer roll") - : List.of("stone-layer roll; biomes: " + rule.biomes()); - Item explicit = explicitItem(material, rule); - if (explicit != Items.AIR) { - ores.add(new Ore( - material, - itemState(explicit), - min, - max, - 1, - Math.max(1, definition.chanceDiv()), - oreDetails)); - } - if (explicit == Items.AIR || explicit == oreItem(material)) { - // Layer interiors use normal ore in the core and small ore at the edges; contacts - // choose between both. Keep both real resources rather than collapsing to ore_. - for (Item item : explicit == Items.AIR - ? List.of(oreItem(material), smallOreItem(material)) - : List.of(smallOreItem(material))) { - if (item == Items.AIR) continue; - ores.add(new Ore( - material, - itemState(item), - min, - max, - 1, - Math.max(1, definition.chanceDiv()), - oreDetails)); - } - } - } - if (ores.isEmpty()) continue; - int minY = ores.stream().mapToInt(Ore::minY).min().orElse(0); - int maxY = ores.stream().mapToInt(Ore::maxY).max().orElse(0); - facts.add(new Fact( - "stratum/" + layerIndex + "/" + layer.material(), - layer.material(), - Kind.STONE_LAYER, - "minecraft:overworld", - minY, - maxY, - 0, - 0, - ores)); - } - } - - private static void appendBedrock(List facts) { - appendBedrock(facts, GTBedrockOres.OVERWORLD, "minecraft:overworld"); - appendBedrock(facts, GTBedrockOres.NETHER, "minecraft:the_nether"); - } - - private static void appendBedrock(List facts, List rows, String dimension) { - long totalWeight = rows.stream() - .mapToLong(row -> MineralWorldgenRules.bedrockWeight(row.chance())) - .sum(); - for (GTBedrockOres.BedrockOre row : rows) { - GTMaterial material = row.material().resolve(); - if (!material.isValid()) continue; - Item item = oreItem(material); - if (item == Items.AIR) continue; - int weight = (int) MineralWorldgenRules.bedrockWeight(row.chance()); - facts.add(new Fact( - "bedrock/" + dimension + "/" + row.name(), - row.name(), - Kind.BEDROCK, - dimension, - GTWorldgenScale.WORLD_FLOOR, - GTWorldgenScale.WORLD_FLOOR + 2, - weight, - Math.toIntExact(totalWeight), - List.of(new Ore( - material, - itemState(item), - GTWorldgenScale.WORLD_FLOOR, - GTWorldgenScale.WORLD_FLOOR + 2, - 1, - 0, - List.of("bedrock rarity: 1 in " + row.chance()))))); - } - } - - private static Item explicitItem(GTMaterial material, StoneLayerOreRules.Rule rule) { - var state = StoneLayerOrePlacement.explicitState(rule); - return state == null ? oreItem(material) : state.getBlock().asItem(); - } - - private static Item oreItem(GTMaterial material) { - Item bound = boundItem(material, "ore", "oreVanillastone"); - if (bound != null) return bound; - String path = material.getName().toLowerCase(Locale.ROOT); - return BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath("gt6ce", "ore_" + path)); - } - - private static Item smallOreItem(GTMaterial material) { - Item bound = boundItem(material, "oreSmall"); - if (bound != null) return bound; - String path = material.getName().toLowerCase(Locale.ROOT); - return BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath("gt6ce", "ore_small_" + path)); - } - - private static Item boundItem(GTMaterial material, String... forms) { - try { - for (String name : forms) - for (MaterialFormBinding binding : - GregTechMaterials.formBindings().find(new MaterialKey(material.getName()), new FormKey(name))) - if (binding.kind() == MaterialFormKind.ITEM) { - ResourceLocation id = ResourceLocation.tryParse(binding.id()); - if (id != null) { - Item item = BuiltInRegistries.ITEM.get(id); - if (item != Items.AIR) return item; - } - } - } catch (IllegalStateException notReady) { - // Naming fallback below remains valid during early publication. - } - return null; - } - - private static String itemState(Item item) { - return "item:" + BuiltInRegistries.ITEM.getKey(item); - } - - private static String requireState(String state) { - if (state == null || state.isBlank()) throw new IllegalArgumentException("Missing worldgen item state"); - return state; - } -} diff --git a/minecraft/src/main/java/gregtech/engine/recipe/Recipe.java b/minecraft/src/main/java/gregtech/engine/recipe/Recipe.java index c5dcd76b4..5a52627f4 100644 --- a/minecraft/src/main/java/gregtech/engine/recipe/Recipe.java +++ b/minecraft/src/main/java/gregtech/engine/recipe/Recipe.java @@ -14,7 +14,6 @@ * and fluids, processing duration, energy cost, and output chances.

*/ public class Recipe { - private gregtech.api.addon.material.DataKey specialProcess; private static final ItemStack[] NO_ITEMS = new ItemStack[0]; private static final FluidStack[] NO_FLUIDS = new FluidStack[0]; private static final long[] NO_CHANCES = new long[0]; @@ -144,16 +143,6 @@ public enum Scope { */ public String mSource = ""; - /** Explicit special-process method ownership; ordinary rows stay null. */ - public Recipe withSpecialProcess(gregtech.api.addon.material.DataKey process) { - specialProcess = process; - return this; - } - - public gregtech.api.addon.material.DataKey specialProcess() { - return specialProcess; - } - /** * Map-assigned publication order. Used only as the deterministic tie-breaker between rows of * equal priority, replacing the accidental ordering of the backing collection. diff --git a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java deleted file mode 100644 index 30c8a0173..000000000 --- a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessFocusMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package gregtech.mixin; - -import dev.emi.emi.api.recipe.EmiRecipe; -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.EmiIngredient; -import gregtech.client.MaterialProcessScreen; -import gregtech.compat.emi.MaterialProcessEmiRecipe; -import java.util.List; -import java.util.Map; -import net.minecraft.client.Minecraft; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -/** EMI does not expose the lookup ingredient to recipe widgets; retain it before constructing their pages. */ -@Pseudo -@Mixin(targets = "dev.emi.emi.api.EmiApi", remap = false) -public abstract class EmiMaterialProcessFocusMixin { - @Inject( - method = "setPages(Ljava/util/Map;Ldev/emi/emi/api/stack/EmiIngredient;)V", - at = @At("HEAD"), - require = 1, - remap = false) - private static void gregtech$focusMaterialProcess( - Map> recipes, EmiIngredient ingredient, CallbackInfo callback) { - // EMI opens lookups only from its recipe/tree screens or a container screen. - if (recipes.values().stream().anyMatch(rows -> !rows.isEmpty()) - && Minecraft.getInstance().screen instanceof MaterialProcessScreen screen) screen.onClose(); - if (ingredient.isEmpty()) return; - for (var recipe : recipes.getOrDefault(MaterialProcessEmiRecipe.category(), List.of())) - if (recipe instanceof MaterialProcessEmiRecipe process) process.focus(ingredient); - } -} diff --git a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessRecipesMixin.java b/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessRecipesMixin.java deleted file mode 100644 index 5ca9ef221..000000000 --- a/minecraft/src/main/java/gregtech/mixin/EmiMaterialProcessRecipesMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package gregtech.mixin; - -import dev.emi.emi.api.recipe.EmiRecipe; -import dev.emi.emi.api.recipe.EmiRecipeCategory; -import dev.emi.emi.api.stack.EmiIngredient; -import gregtech.compat.emi.GregTechEMIPlugin; -import java.util.List; -import java.util.Map; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -/** EMI's deferred registration API runs before recipe filters and exposes no final row list. */ -@Pseudo -@Mixin(targets = "dev.emi.emi.registry.EmiRecipes", remap = false) -public abstract class EmiMaterialProcessRecipesMixin { - @Shadow - private static Map> workstations; - - @ModifyVariable(method = "bake", at = @At("STORE"), ordinal = 0, require = 1, allow = 1, remap = false) - private static List gregtech$includeMaterialProcesses(List filtered) { - return GregTechEMIPlugin.addMaterialProcesses(filtered, workstations); - } -} diff --git a/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json b/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json index 764932d5a..1787c88f2 100644 --- a/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json +++ b/minecraft/versions/1.20.1-forge/src/main/resources/gregtech.mixins.json @@ -56,8 +56,6 @@ "BlockPaintColorMixin", "ColoredBookLecternScreenMixin", "ColoredBookOpenPacketMixin", - "EmiMaterialProcessFocusMixin", - "EmiMaterialProcessRecipesMixin", "EmiMaterialUsesMixin", "EmiStructureFocusMixin", "FluidAlphaConfigMixin", diff --git a/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json b/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json index 1bb7bebbe..07415a5d1 100644 --- a/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json +++ b/minecraft/versions/1.21.1-neoforge/src/main/resources/gregtech-neoforge.mixins.json @@ -54,8 +54,6 @@ }, "client": [ "BlockPaintColorMixin", - "EmiMaterialProcessFocusMixin", - "EmiMaterialProcessRecipesMixin", "EmiMaterialUsesMixin", "EmiStructureFocusMixin", "FluidAlphaConfigMixin", From 827502632b492c643ab9067add5ba3c4f8267e5a Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Tue, 17 Nov 2026 01:25:53 +0800 Subject: [PATCH 16/17] spotlessApply --- .../gregtech/content/block/stone/OreHostFacts.java | 8 ++++---- .../catalog/ReviewedSourceMaterialFacts.java | 5 ++--- .../catalog/SourceRecyclingMaterialFacts.java | 9 ++++----- .../gregtech/content/recipe/SourceOilSandRules.java | 13 ++++++------- .../content/recipe/SourceOreCrushingRules.java | 11 +++++------ .../content/recipe/SourceOreShreddingRules.java | 7 +++---- .../content/recipe/SourceThermalInputRules.java | 5 ++--- .../gregtech/content/recipe/SpecialProcessData.java | 4 ++-- .../content/recipe/SpecialProcessMaterialFacts.java | 7 +++---- .../engine/recipe/MaterialDecompositionPlanner.java | 5 ++--- .../java/gregtech/content/data/CoinRemovalTest.java | 6 +++--- .../gregtech/content/food/NutritionRemovalTest.java | 7 +++---- .../content/material/MaterialCatalogTest.java | 4 ++-- .../content/recipe/FamilyRowTablesTest.java | 7 +++---- .../content/worldgen/StoneLayerScanTest.java | 4 ++-- .../content/worldgen/SurfaceRockRulesTest.java | 5 ++--- .../gregtech/engine/energy/BatteryBoxStateTest.java | 7 +++---- .../material/ItemCompositionResolverTest.java | 9 ++++----- .../engine/material/MaterialIconIntegrityTest.java | 11 +++++------ .../engine/material/MaterialRegistrationTest.java | 7 +++---- .../engine/material/SpecialProcessLanguageTest.java | 7 +++---- .../recipe/MaterialDecompositionPlannerTest.java | 7 +++---- .../engine/recipe/chem/MaterialAmountTest.java | 4 ++-- .../java/gregtech/client/HopperClientModels.java | 5 ++--- .../java/gregtech/client/PipeWireClientModels.java | 3 +-- .../gregtech/content/registry/GTIconSetBlocks.java | 7 +++---- .../content/registry/GTMaterialRegistration.java | 4 ++-- .../gregtech/content/registry/GTMiscBlocks.java | 7 +++---- .../java/gregtech/client/BurningBoxClientSetup.java | 3 +-- .../gregtech/client/FluidTransportClientSetup.java | 3 +-- .../content/registry/GTRemainingIconBlocks.java | 7 +++---- .../content/registry/GTSpecialOreBlocks.java | 11 +++++------ 32 files changed, 92 insertions(+), 117 deletions(-) diff --git a/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java b/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java index 05f026451..5da8580f5 100644 --- a/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java +++ b/core/src/main/java/gregtech/content/block/stone/OreHostFacts.java @@ -1,14 +1,14 @@ package gregtech.content.block.stone; +import static gregtech.api.material.GTValues.U; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; + import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Set; -import static gregtech.api.material.GTValues.U; -import static gregtech.content.material.MaterialFactKeys.Decision; -import static gregtech.content.material.MaterialFactKeys.Identity; - /** Source ore-host prefixes, gangue composition and broken-ore pairing. */ public final class OreHostFacts { private OreHostFacts() {} diff --git a/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java index 5f196eb15..c25de4c33 100644 --- a/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/ReviewedSourceMaterialFacts.java @@ -1,16 +1,15 @@ package gregtech.content.material.catalog; +import static gregtech.content.material.MaterialFactKeys.Decision; + import gregtech.api.addon.material.MaterialProcessRule; import gregtech.api.material.GTMaterial; import gregtech.api.material.MaterialProperty; import gregtech.content.material.MaterialFactKeys; import gregtech.engine.material.MaterialDefinition; import gregtech.engine.material.MaterialInfoDefinition; - import java.util.*; -import static gregtech.content.material.MaterialFactKeys.Decision; - /** Bounded source facts whose scope is an exact built-in material identity. */ public final class ReviewedSourceMaterialFacts { private ReviewedSourceMaterialFacts() {} diff --git a/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java b/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java index e59d22047..9d6009919 100644 --- a/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java +++ b/core/src/main/java/gregtech/content/material/catalog/SourceRecyclingMaterialFacts.java @@ -1,16 +1,15 @@ package gregtech.content.material.catalog; +import static gregtech.api.material.GTValues.U; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; + import gregtech.api.addon.material.MaterialProcessRule; import gregtech.content.material.MaterialFactKeys; import gregtech.engine.material.MaterialDefinition; import gregtech.engine.material.MaterialInfoDefinition; - import java.util.*; -import static gregtech.api.material.GTValues.U; -import static gregtech.content.material.MaterialFactKeys.Decision; -import static gregtech.content.material.MaterialFactKeys.Identity; - /** * Finite facts for the existing dust-or-ingot 1U thermal recycling producer, not global material metadata. * Original GT6: 3703e40308c8c030763fd6297dea8b210d2a77b1, MT declarations and factory closure diff --git a/core/src/main/java/gregtech/content/recipe/SourceOilSandRules.java b/core/src/main/java/gregtech/content/recipe/SourceOilSandRules.java index 40b491075..faee6b320 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOilSandRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceOilSandRules.java @@ -1,18 +1,17 @@ package gregtech.content.recipe; -import gregtech.content.block.stone.OreHostFacts; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - import static gregtech.api.material.GTValues.U; import static gregtech.content.material.MaterialFactKeys.Decision; import static gregtech.content.material.MaterialFactKeys.Identity; import static gregtech.content.recipe.SourceOreCrushingRules.*; import static gregtech.content.recipe.SourceOreWashingRules.Availability; +import gregtech.content.block.stone.OreHostFacts; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + /** * The OilSand ore-registration Centrifuge event, not generic material decomposition. * Pinned GT6 3703e40308c8c030763fd6297dea8b210d2a77b1: Loader_OreProcessing 196-197/296-303, diff --git a/core/src/main/java/gregtech/content/recipe/SourceOreCrushingRules.java b/core/src/main/java/gregtech/content/recipe/SourceOreCrushingRules.java index d8731c025..7142bfde1 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOreCrushingRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceOreCrushingRules.java @@ -1,17 +1,16 @@ package gregtech.content.recipe; -import gregtech.content.material.MaterialFactKeys.HexoriumKind; +import static gregtech.api.material.GTValues.U; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.material.MaterialFactKeys.Identity; +import static gregtech.content.recipe.SourceOreWashingRules.Availability; +import gregtech.content.material.MaterialFactKeys.HexoriumKind; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; -import static gregtech.api.material.GTValues.U; -import static gregtech.content.material.MaterialFactKeys.Decision; -import static gregtech.content.material.MaterialFactKeys.Identity; -import static gregtech.content.recipe.SourceOreWashingRules.Availability; - /** Pinned GT6 3703e40308c8c030763fd6297dea8b210d2a77b1, * RecipeMapHandlerCrushing 50-140 / RecipeMapHammer 88-118 / OM 460-467. * Caller proves native identity, source prefix/host classification, and relevant source tag. diff --git a/core/src/main/java/gregtech/content/recipe/SourceOreShreddingRules.java b/core/src/main/java/gregtech/content/recipe/SourceOreShreddingRules.java index 564173b76..969cdefae 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceOreShreddingRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceOreShreddingRules.java @@ -1,15 +1,14 @@ package gregtech.content.recipe; +import static gregtech.content.material.MaterialFactKeys.Decision; +import static gregtech.content.recipe.SourceOreWashingRules.Availability; + import gregtech.api.material.GTValues; import gregtech.content.data.MaterialPrefix; - import java.math.BigInteger; import java.util.List; import java.util.Objects; -import static gregtech.content.material.MaterialFactKeys.Decision; -import static gregtech.content.recipe.SourceOreWashingRules.Availability; - /** * The six explicit Shredder handlers, original GT6 3703e40308c8c030763fd6297dea8b210d2a77b1, * Loader_Recipes_Handlers 138-150 and RecipeMapHandlerPrefix 204-226. diff --git a/core/src/main/java/gregtech/content/recipe/SourceThermalInputRules.java b/core/src/main/java/gregtech/content/recipe/SourceThermalInputRules.java index 424739918..625bea23e 100644 --- a/core/src/main/java/gregtech/content/recipe/SourceThermalInputRules.java +++ b/core/src/main/java/gregtech/content/recipe/SourceThermalInputRules.java @@ -1,12 +1,11 @@ package gregtech.content.recipe; -import gregtech.content.data.MaterialPrefix; +import static gregtech.content.recipe.SourceThermalRecyclingRules.*; +import gregtech.content.data.MaterialPrefix; import java.util.List; import java.util.stream.Stream; -import static gregtech.content.recipe.SourceThermalRecyclingRules.*; - /** * Eighty-five single-component item-input contracts for source RecyclingProcessing, not the complete * listener and not a global prefix policy. Pinned GT6 3703e40308c8c030763fd6297dea8b210d2a77b1: diff --git a/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java index ab32efe75..67f830a3a 100644 --- a/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessData.java @@ -1,9 +1,9 @@ package gregtech.content.recipe; -import java.util.List; - import static gregtech.content.material.MaterialFactKeys.Identity; +import java.util.List; + /** * Finite purified-acid families from GT6 3703e40308c8c030763fd6297dea8b210d2a77b1, * Loader_Recipes_Ores 108-159. Canonical identities come from the pinned MT declarations; diff --git a/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java b/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java index edd59dc33..925d1a72f 100644 --- a/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java +++ b/core/src/main/java/gregtech/content/recipe/SpecialProcessMaterialFacts.java @@ -1,14 +1,13 @@ package gregtech.content.recipe; +import static gregtech.content.recipe.SpecialProcessData.Phase; +import static gregtech.content.recipe.SpecialProcessData.Tail; + import gregtech.api.addon.material.*; import gregtech.engine.material.MaterialDefinition; import gregtech.engine.material.MaterialInfoDefinition; - import java.util.*; -import static gregtech.content.recipe.SpecialProcessData.Phase; -import static gregtech.content.recipe.SpecialProcessData.Tail; - /** Attaches built-in purified-acid methods as ordinary typed material process rules. */ public final class SpecialProcessMaterialFacts { private static final FormKey PURIFIED = form("crushedPurified"); diff --git a/core/src/main/java/gregtech/engine/recipe/MaterialDecompositionPlanner.java b/core/src/main/java/gregtech/engine/recipe/MaterialDecompositionPlanner.java index e14e77586..3e49b3bbd 100644 --- a/core/src/main/java/gregtech/engine/recipe/MaterialDecompositionPlanner.java +++ b/core/src/main/java/gregtech/engine/recipe/MaterialDecompositionPlanner.java @@ -1,5 +1,7 @@ package gregtech.engine.recipe; +import static gregtech.api.material.GTValues.U; + import gregtech.api.addon.material.GregTechMaterials; import gregtech.api.addon.material.MaterialDecompositionRule; import gregtech.api.addon.material.MaterialKey; @@ -7,13 +9,10 @@ import gregtech.api.material.GTMaterial; import gregtech.api.material.MaterialComponent; import gregtech.api.material.MaterialProperty; - import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import static gregtech.api.material.GTValues.U; - /** Pure decomposition planning shared by recipe publication and content-source projections. */ public final class MaterialDecompositionPlanner { public static final long ENVIRONMENT_TEMPERATURE = 293; diff --git a/core/src/test/java/gregtech/content/data/CoinRemovalTest.java b/core/src/test/java/gregtech/content/data/CoinRemovalTest.java index 2b02690b5..a341540e1 100644 --- a/core/src/test/java/gregtech/content/data/CoinRemovalTest.java +++ b/core/src/test/java/gregtech/content/data/CoinRemovalTest.java @@ -1,14 +1,14 @@ package gregtech.content.data; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import gregtech.api.material.GTValues; import gregtech.content.material.MaterialTestFixture; import gregtech.engine.material.GTMaterialRegistry; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - /** Guards that plateTiny keeps its U9 weight and its predicate for tiny-plate materials such as Iron. */ class CoinRemovalTest { @BeforeAll diff --git a/core/src/test/java/gregtech/content/food/NutritionRemovalTest.java b/core/src/test/java/gregtech/content/food/NutritionRemovalTest.java index 82cc404d6..01a4a7b52 100644 --- a/core/src/test/java/gregtech/content/food/NutritionRemovalTest.java +++ b/core/src/test/java/gregtech/content/food/NutritionRemovalTest.java @@ -1,19 +1,18 @@ package gregtech.content.food; +import static org.junit.jupiter.api.Assertions.*; + import gregtech.content.data.FluidCatalog; import gregtech.content.data.generated.GTBottlesGen; import gregtech.content.data.generated.GTDrinksGen; import gregtech.content.data.generated.GTFoodItemsGen; -import org.junit.jupiter.api.Test; - import java.lang.reflect.RecordComponent; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** Guards the RFC #363 removal: five statistics are gone, radiation and the bottle items stay. */ class NutritionRemovalTest { diff --git a/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java b/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java index 0cf350bd8..284b5ada2 100644 --- a/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java +++ b/core/src/test/java/gregtech/content/material/MaterialCatalogTest.java @@ -1,5 +1,7 @@ package gregtech.content.material; +import static org.junit.jupiter.api.Assertions.*; + import gregtech.api.addon.material.GregTechMaterials; import gregtech.api.addon.material.MaterialKey; import gregtech.content.fluid.FluidDefinitions; @@ -8,8 +10,6 @@ import gregtech.engine.material.GTMaterialRegistry; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - class MaterialCatalogTest { @Test void reviewedRecipeFactsAreFullyProjectedIntoMaterialDeclarations() { diff --git a/core/src/test/java/gregtech/content/recipe/FamilyRowTablesTest.java b/core/src/test/java/gregtech/content/recipe/FamilyRowTablesTest.java index ef0d6aa5f..8e6ed6db5 100644 --- a/core/src/test/java/gregtech/content/recipe/FamilyRowTablesTest.java +++ b/core/src/test/java/gregtech/content/recipe/FamilyRowTablesTest.java @@ -1,15 +1,14 @@ package gregtech.content.recipe; +import static org.junit.jupiter.api.Assertions.*; + import gregtech.api.material.GTValues; import gregtech.content.data.MaterialPrefix; import gregtech.content.data.generated.RecyclablePrefixes; import gregtech.engine.machine.PipeSpec; import gregtech.engine.recipe.chem.MaterialAmount; -import org.junit.jupiter.api.Test; - import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** Pins the hand-written family tables to the original {@code Loader_Recipes_Handlers} rows. */ final class FamilyRowTablesTest { diff --git a/core/src/test/java/gregtech/content/worldgen/StoneLayerScanTest.java b/core/src/test/java/gregtech/content/worldgen/StoneLayerScanTest.java index ecbf6141d..b959e879f 100644 --- a/core/src/test/java/gregtech/content/worldgen/StoneLayerScanTest.java +++ b/core/src/test/java/gregtech/content/worldgen/StoneLayerScanTest.java @@ -1,9 +1,9 @@ package gregtech.content.worldgen; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + /** Locks GT6 {@code WorldgenStoneLayers}' 7-entry window and section-based scan bounds. */ class StoneLayerScanTest { private static final String A = "A"; diff --git a/core/src/test/java/gregtech/content/worldgen/SurfaceRockRulesTest.java b/core/src/test/java/gregtech/content/worldgen/SurfaceRockRulesTest.java index 298619f7d..feb41d3ca 100644 --- a/core/src/test/java/gregtech/content/worldgen/SurfaceRockRulesTest.java +++ b/core/src/test/java/gregtech/content/worldgen/SurfaceRockRulesTest.java @@ -1,10 +1,9 @@ package gregtech.content.worldgen; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; import java.util.function.UnaryOperator; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** Locks GT6 {@code WorldgenStoneLayers}' {@code tLastRock}/{@code tLastOre} state. */ class SurfaceRockRulesTest { diff --git a/core/src/test/java/gregtech/engine/energy/BatteryBoxStateTest.java b/core/src/test/java/gregtech/engine/energy/BatteryBoxStateTest.java index 6ff77c922..995f26ee5 100644 --- a/core/src/test/java/gregtech/engine/energy/BatteryBoxStateTest.java +++ b/core/src/test/java/gregtech/engine/energy/BatteryBoxStateTest.java @@ -1,12 +1,11 @@ package gregtech.engine.energy; -import org.junit.jupiter.api.Test; - -import java.util.List; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.List; +import org.junit.jupiter.api.Test; + /** Guards battery-box item charging: a sink cell charges at matched voltage and refuses overvoltage. */ class BatteryBoxStateTest { diff --git a/core/src/test/java/gregtech/engine/material/ItemCompositionResolverTest.java b/core/src/test/java/gregtech/engine/material/ItemCompositionResolverTest.java index 28ec77eaa..9d0271d0d 100644 --- a/core/src/test/java/gregtech/engine/material/ItemCompositionResolverTest.java +++ b/core/src/test/java/gregtech/engine/material/ItemCompositionResolverTest.java @@ -1,17 +1,16 @@ package gregtech.engine.material; +import static org.junit.jupiter.api.Assertions.*; + import gregtech.api.material.MaterialComponent; import gregtech.content.material.MaterialTestFixture; import gregtech.content.material.Materials; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; class ItemCompositionResolverTest { @BeforeAll diff --git a/core/src/test/java/gregtech/engine/material/MaterialIconIntegrityTest.java b/core/src/test/java/gregtech/engine/material/MaterialIconIntegrityTest.java index 6d71dead6..15ca76e0c 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialIconIntegrityTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialIconIntegrityTest.java @@ -1,21 +1,20 @@ package gregtech.engine.material; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import gregtech.api.material.GTMaterial; import gregtech.api.material.MaterialTextureSet; import gregtech.content.cover.MaterialCoverRules; import gregtech.content.data.MaterialPrefix; import gregtech.content.material.MaterialTestFixture; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Guards the generated material icon tree: every material resolves to a modeled texture set, and diff --git a/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java b/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java index 09af0def8..ba7cf8362 100644 --- a/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java +++ b/core/src/test/java/gregtech/engine/material/MaterialRegistrationTest.java @@ -1,19 +1,18 @@ package gregtech.engine.material; +import static org.junit.jupiter.api.Assertions.*; + import gregtech.api.addon.material.*; import gregtech.api.material.GTMaterial; import gregtech.api.material.MaterialProperty; import gregtech.api.material.MaterialSentinels; import gregtech.content.material.MaterialDefinitions; -import org.junit.jupiter.api.Test; - import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.Map; import java.util.Set; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; class MaterialRegistrationTest { @Test diff --git a/core/src/test/java/gregtech/engine/material/SpecialProcessLanguageTest.java b/core/src/test/java/gregtech/engine/material/SpecialProcessLanguageTest.java index e57dc6763..a9d94389a 100644 --- a/core/src/test/java/gregtech/engine/material/SpecialProcessLanguageTest.java +++ b/core/src/test/java/gregtech/engine/material/SpecialProcessLanguageTest.java @@ -1,15 +1,14 @@ package gregtech.engine.material; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashSet; import java.util.Set; import java.util.regex.Pattern; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; class SpecialProcessLanguageTest { private static final Pattern PROCESS_KEYS = Pattern.compile("\"(gt6ce\\.special_process\\.[^\"]+)\"\\s*:"); diff --git a/core/src/test/java/gregtech/engine/recipe/MaterialDecompositionPlannerTest.java b/core/src/test/java/gregtech/engine/recipe/MaterialDecompositionPlannerTest.java index ae0025c9d..3e483c36c 100644 --- a/core/src/test/java/gregtech/engine/recipe/MaterialDecompositionPlannerTest.java +++ b/core/src/test/java/gregtech/engine/recipe/MaterialDecompositionPlannerTest.java @@ -1,5 +1,7 @@ package gregtech.engine.recipe; +import static org.junit.jupiter.api.Assertions.*; + import gregtech.api.addon.material.MaterialDecompositionRule; import gregtech.api.addon.material.MaterialKey; import gregtech.api.addon.material.MaterialProcessKeys; @@ -10,13 +12,10 @@ import gregtech.content.material.catalog.DecompositionMaterials; import gregtech.content.material.catalog.MaterialFluidUnitFacts; import gregtech.engine.material.MaterialInfoRegistry; +import java.util.List; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - class MaterialDecompositionPlannerTest { @BeforeAll static void init() { diff --git a/core/src/test/java/gregtech/engine/recipe/chem/MaterialAmountTest.java b/core/src/test/java/gregtech/engine/recipe/chem/MaterialAmountTest.java index 24efc933a..0d82fa51e 100644 --- a/core/src/test/java/gregtech/engine/recipe/chem/MaterialAmountTest.java +++ b/core/src/test/java/gregtech/engine/recipe/chem/MaterialAmountTest.java @@ -1,11 +1,11 @@ package gregtech.engine.recipe.chem; +import static org.junit.jupiter.api.Assertions.*; + import gregtech.api.material.GTValues; import gregtech.content.material.catalog.MaterialFluidUnitFacts; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - /** Material units are exact and only material fluids cross a reviewed millibucket boundary. */ final class MaterialAmountTest { @Test diff --git a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/client/HopperClientModels.java b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/client/HopperClientModels.java index 6303c7043..70c1ab6c6 100644 --- a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/client/HopperClientModels.java +++ b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/client/HopperClientModels.java @@ -4,6 +4,8 @@ import gregtech.GregTech; import gregtech.content.registry.GTHoppers; import gregtech.content.registry.RegisteredBlock; +import java.util.EnumMap; +import java.util.Map; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -13,9 +15,6 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; -import java.util.EnumMap; -import java.util.Map; - /** * Hopper / queuehopper shared model registration and bake-time aliasing. * Follows the same pattern as {@link MachineBlockClientModels} for burning boxes. diff --git a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/client/PipeWireClientModels.java b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/client/PipeWireClientModels.java index b61c706f0..0b49b924e 100644 --- a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/client/PipeWireClientModels.java +++ b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/client/PipeWireClientModels.java @@ -13,6 +13,7 @@ import gregtech.engine.energy.WireSpec; import gregtech.engine.machine.ItemPipeSpec; import gregtech.engine.machine.PipeSpec; +import java.util.Locale; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; @@ -21,8 +22,6 @@ import net.minecraftforge.registries.ForgeRegistries; import org.slf4j.Logger; -import java.util.Locale; - /** * Replaces every pipe/wire/cable blockstate variant with the dynamic * {@link PipeWireBakedModel} (GT6 thin-into-thick connection rendering). diff --git a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTIconSetBlocks.java b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTIconSetBlocks.java index a008532e7..f32fb72cc 100644 --- a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTIconSetBlocks.java +++ b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTIconSetBlocks.java @@ -1,16 +1,15 @@ package gregtech.content.registry; +import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; + import gregtech.content.block.IconSetBlock; +import java.util.*; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; -import java.util.*; - -import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; - /** * Registers placeable icon-set blocks; renderer-only textures are not blocks. Registry ids are the plain * icon name ({@code asphalt}, {@code planks_maple}, ...) — {@code ore_*} icons get a diff --git a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMaterialRegistration.java b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMaterialRegistration.java index 9f38eaebf..c1e15bbc5 100644 --- a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMaterialRegistration.java +++ b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMaterialRegistration.java @@ -1,5 +1,7 @@ package gregtech.content.registry; +import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; + import gregtech.GregTech; import gregtech.api.material.GTValues; import gregtech.content.material.MaterialItemCompositions; @@ -8,8 +10,6 @@ import net.minecraft.world.level.block.Block; import net.minecraftforge.registries.ForgeRegistries; -import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; - /** Forge-only block families after the shared item and block composition pass. */ public final class GTMaterialRegistration { private GTMaterialRegistration() {} diff --git a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMiscBlocks.java b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMiscBlocks.java index 3a5f48728..e32a542c4 100644 --- a/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMiscBlocks.java +++ b/minecraft/versions/1.20.1-forge/src/main/java/gregtech/content/registry/GTMiscBlocks.java @@ -1,14 +1,13 @@ package gregtech.content.registry; +import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; + import gregtech.content.block.misc.PanelBlock; +import java.util.function.Supplier; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.MapColor; -import java.util.function.Supplier; - -import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; - /** N10: decorative panels. */ public final class GTMiscBlocks { // N10: Decorative panels (6 types) diff --git a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/client/BurningBoxClientSetup.java b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/client/BurningBoxClientSetup.java index 73c5c77a5..86b4914d6 100644 --- a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/client/BurningBoxClientSetup.java +++ b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/client/BurningBoxClientSetup.java @@ -1,13 +1,12 @@ package gregtech.client; import gregtech.content.registry.GTBurningBoxes; +import java.util.List; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; -import java.util.List; - /** Original facing/lit shell selection and material tint adapted to native baking. */ @EventBusSubscriber( modid = gregtech.engine.mod.GregTechIdentity.MOD_ID, diff --git a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/client/FluidTransportClientSetup.java b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/client/FluidTransportClientSetup.java index f80b77f7f..96042ebe2 100644 --- a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/client/FluidTransportClientSetup.java +++ b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/client/FluidTransportClientSetup.java @@ -3,6 +3,7 @@ import gregtech.content.registry.GTBlockEntities; import gregtech.content.registry.GTFluidPipes; import gregtech.content.registry.GTTanks; +import java.util.Locale; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.resources.ResourceLocation; import net.neoforged.api.distmarker.Dist; @@ -12,8 +13,6 @@ import net.neoforged.neoforge.client.event.ModelEvent; import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; -import java.util.Locale; - /** Original dynamic thin-to-thick pipe geometry, cover plates and material tint, client only. */ @EventBusSubscriber( modid = gregtech.engine.mod.GregTechIdentity.MOD_ID, diff --git a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTRemainingIconBlocks.java b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTRemainingIconBlocks.java index 4aad68b41..cf8fb74cb 100644 --- a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTRemainingIconBlocks.java +++ b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTRemainingIconBlocks.java @@ -1,6 +1,9 @@ package gregtech.content.registry; +import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; + import gregtech.content.block.IconSetBlock; +import java.util.*; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; @@ -9,10 +12,6 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.neoforged.neoforge.registries.DeferredRegister; -import java.util.*; - -import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; - /** Complete remaining original icon identities. Existing typed registrations retain ownership. */ public final class GTRemainingIconBlocks { private GTRemainingIconBlocks() {} diff --git a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTSpecialOreBlocks.java b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTSpecialOreBlocks.java index f68e56f29..f9e235c49 100644 --- a/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTSpecialOreBlocks.java +++ b/minecraft/versions/1.21.1-neoforge/src/main/java/gregtech/content/registry/GTSpecialOreBlocks.java @@ -1,21 +1,20 @@ package gregtech.content.registry; +import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; + import gregtech.content.block.*; import gregtech.content.data.MaterialPrefix; import gregtech.content.material.MaterialItemCompositions; import gregtech.engine.material.ItemMaterialRegistry; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static gregtech.engine.mod.GregTechIdentity.REGISTRY_NAMESPACE; - /** Actual original crystal/rock/vanilla ore blocks from GTIconSetBlocks; no decorative substitutes. */ public final class GTSpecialOreBlocks { private static final List> ALL = new ArrayList<>(); From adad4bd459172bbc977fdd6ee1d8196033fa8e92 Mon Sep 17 00:00:00 2001 From: kuzuanpa Date: Tue, 17 Nov 2026 04:11:27 +0800 Subject: [PATCH 17/17] bugfix --- docs/ADDON_API.zh-CN.md | 2 + docs/architecture/packages/content.md | 8 + .../development/validation/checks/gametest.md | 2 + .../content/recipe/BathMaterialRecipes.java | 4 +- .../recipe/SharedSpecialProcessRows.java | 76 +++++--- .../recipe/generated/GTOreRecipes.java | 12 +- .../engine/material/MaterialFormContent.java | 12 ++ .../recipe/SpecialProcessRecipeTests.java | 169 ++++++++++++++++++ 8 files changed, 246 insertions(+), 39 deletions(-) create mode 100644 minecraft/src/test/java/gregtech/content/recipe/SpecialProcessRecipeTests.java diff --git a/docs/ADDON_API.zh-CN.md b/docs/ADDON_API.zh-CN.md index f801a7e80..324a319fd 100644 --- a/docs/ADDON_API.zh-CN.md +++ b/docs/ADDON_API.zh-CN.md @@ -59,6 +59,8 @@ API 1.9 新增 `SpecialProcessMethod`、`SpecialProcessValue` 与 `SpecialProcessesView`。附属通过 `MaterialInfoTool.Registrar.registerSpecialProcess(...)` 声明 typed target/reagent 规则,再通过 `MaterialCatalogView.specialProcesses()` 当前发布快照读取;target 和 reagent 必须绑定同一个 `MaterialProcessKey`。 +特殊工艺试剂与产物按 `MaterialCatalogView.formBindings()` 已发布的实际形态解析。流体试剂的 `reagentAmount` 和流体产物的 `millibuckets` 直接使用 mB;水和岩浆的原版流体身份也发布为材料形态,不要求内部 `MATERIAL_FLUID_UNIT` 换算条目;`anyForm(new SpecialProcessValue.Reagent())` 从该材料已发布的形态中选择可解析的试剂。任一必需产物无法解析时整行拒绝,日志按输入、试剂、物品产物、流体产物分类汇总,避免发布缺少产物的配方。 + 宿主专用的 `StructureGrid` 与 `RecipeMapSpec` 不属于附属契约:它们分别位于 `gregtech.content.multiblock` 与 `gregtech.content.recipe`,编码内置多方块几何和配方表,附属不应依赖。 公共 API 的契约检查、SDK 与平台检查见[验证与验收](development/validation/README.md)。移动到 API 包的可变模型或内部辅助类不自动获得长期兼容保证。 diff --git a/docs/architecture/packages/content.md b/docs/architecture/packages/content.md index cd8bb97f6..3470209f4 100644 --- a/docs/architecture/packages/content.md +++ b/docs/architecture/packages/content.md @@ -76,6 +76,14 @@ core 的 content 描述“有什么”,Minecraft 的 content 将其变为游 涉及跨模组联动时的来源、单位转换与冲突处理提炼到 [integration](../../integration/README.md);材料目录、形态、成分、回收与分解的系统设计见[材料系统设计](../../decisions/material-system/README.md),偏离原 GT6 的有意差异登记到 [parity](../../decisions/parity/README.md)。不要因 `Original*` 名字而声称完整还原。生成表来源缺失时先记录局限,参见[生成物说明](../resources.md)。验收与自动化测试范围见下。 +### 浸泡槽的特殊处理 + +`SharedSpecialProcessRows` 统一生成声明式酸浸配方,包括金、铜、锡、锡石的八条王水配方;`generated/GTOreRecipes` 不再重复注册这八条静态行。该表的原始转换工具未随仓库保存,本次按固定 GT6 提交的 `Loader_Recipes_Ores` 与现存 typed target 局部收口,未重新生成整表。王水仍接收 1 份洁净矿或 9 份小份洁净矿,保留原有用量、流体产物和五个独立的 50% 副产物槽。 + +过硫酸钠/钾、汞和火石浸洗仍由 `SharedOreWashingRows` 根据洗矿事实生成;它们处理碎矿并产出洁净矿,酸浸处理洁净矿并产出离心矿,属于不同阶段。过硫酸盐保留四种投料组合、900/100 mB 水和 144/16 tick 比例,不产生蒸汽。浸泡槽造纸继续接收所有具有 `WOOD` 属性的已注册材料粉末,以及树皮和纸粉,不以 `AnyWood` 固定成员缩小输入范围。 + +`SpecialProcessRecipeTests` 覆盖平台发布的附属流体绑定、不限形态的物品/流体试剂、缺失流体产物整行拒绝、王水完整产物与单一归属、过硫酸盐投料比例,以及竹/橡胶木/处理木粉末的造纸输入。 + ## 验收 - 新内容按[源码分层](../README.md#第一层源码与依赖)检查依赖,跨版本输入按[跨版本指南](../versions.md)处理。 diff --git a/docs/development/validation/checks/gametest.md b/docs/development/validation/checks/gametest.md index ddeb01b61..6da7261d3 100644 --- a/docs/development/validation/checks/gametest.md +++ b/docs/development/validation/checks/gametest.md @@ -40,6 +40,8 @@ GameTest 不接入 `check` 或 CI,只在本地通过两个节点的 `runGameTe `decompositionRespectsFormsAndExactFluidIdentities` 通过测试 SPI 声明 dust-only、blockDust-only、liquid-only 和 gas-only 分解,检查形态限制、流体输入不会错误抑制允许的固体兜底、本体完整 ID、附属完整 ID/旧裸路径、外部原版流体 ID、未知及非法 ID,以及附属流体输出的身份和数量。 +`SpecialProcessRecipeTests` 检查特殊工艺的已发布流体绑定与不限形态试剂、缺失产物拒绝、王水配方完整发布和唯一归属、过硫酸盐四种投料组合,以及竹/橡胶木/处理木粉的造纸标签。 + 针对性回归用数据表维护,不为每个 issue 新建测试类、namespace 或结构模板。GameTest 表是运行时权威,只保留 R 级运行时行;静态源检查由 core 的 `crafting-issue-static-cases.tsv` 维护。 引擎契约不属于某个配方 issue,例如 `RecipeMap` 的注册、删除与碰撞判定,直接放在 `minecraft/src/test` 的独立测试类里,参考 `RecipeMapRegistrationTests`。 diff --git a/minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java index 2837b723a..75ac55a30 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/BathMaterialRecipes.java @@ -72,7 +72,9 @@ public static int register() { } private void paper() { - Set sources = new LinkedHashSet<>(MaterialGroups.members(MaterialGroups.Wood)); + Set sources = new LinkedHashSet<>(); + for (GTMaterial material : GTMaterialRegistry.allMaterials()) + if (material.isValid() && material.has(MaterialProperty.WOOD)) sources.add(material.resolve()); for (String name : new String[] {"Bark", "Paper"}) { GTMaterial material = GTMaterialRegistry.get(name); if (material.isValid()) sources.add(material); diff --git a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java index f2e78052b..b1ee65fb2 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java +++ b/minecraft/src/main/java/gregtech/content/recipe/SharedSpecialProcessRows.java @@ -4,13 +4,12 @@ import static gregtech.content.recipe.SourceOreWashingRules.Availability; import gregtech.api.addon.material.FormKey; +import gregtech.api.addon.material.MaterialFormKind; +import gregtech.api.addon.material.MaterialFormsView; import gregtech.api.addon.material.MaterialKey; import gregtech.api.addon.material.MaterialProcessKey; import gregtech.api.addon.material.SpecialProcessMethod; import gregtech.api.addon.material.SpecialProcessValue; -import gregtech.content.data.FluidCatalog; -import gregtech.content.material.catalog.MaterialFluidUnitFacts; -import gregtech.content.registry.GTFluids; import gregtech.engine.material.GTMaterialRegistry; import gregtech.engine.material.MaterialViews; import gregtech.engine.prefix.PrefixRegistry; @@ -25,6 +24,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.material.Fluids; //? if >=1.21.1 { @@ -63,7 +64,7 @@ public static void rebuild() { var catalog = MaterialViews.catalog(); var methods = methodRules(catalog); var resolver = new Resolver(); - int omitted = 0; + var omitted = new LinkedHashMap(); for (var methodRules : methods) { var method = methodRules.method(); RecipeMap map = RecipeMap.RECIPE_MAP_LIST.stream() @@ -86,7 +87,11 @@ public static void rebuild() { target.material(), inputEntry.getKey(), inputEntry.getValue(), target.plan(), reagent, resolver); if (built.recipe() == null) { - omitted++; + omitted.merge(built.reason(), 1, Integer::sum); + com.mojang.logging.LogUtils.getLogger().debug( + "[gregtech] Omitted special process {} for {}/{} with {}: {}", + method.process().id(), target.material().name(), inputEntry.getKey().name(), + reagent.material().name(), built.reason()); continue; } Recipe accepted = map.addRecipe(built.recipe()); @@ -97,15 +102,15 @@ public static void rebuild() { } } } - if (omitted > 0) + if (!omitted.isEmpty()) com.mojang.logging.LogUtils.getLogger() - .warn("[gregtech] Omitted {} special-process rows whose material forms or reagent did not resolve", + .warn("[gregtech] Omitted special-process rows by unresolved requirement: {}", omitted); } - private record BuildResult(Recipe recipe) {} + record BuildResult(Recipe recipe, String reason) {} - private static BuildResult build( + static BuildResult build( MaterialKey target, FormKey inputForm, int inputCount, @@ -113,28 +118,28 @@ private static BuildResult build( ReagentSelector reagent, Resolver resolver) { ItemStack input = resolver.item(target, inputForm, inputCount); - if (input.isEmpty()) return new BuildResult(null); + if (input.isEmpty()) return new BuildResult(null, "input-form"); var itemInputs = new ArrayList(); itemInputs.add(input); var fluidInputs = new ArrayList(); if (!addReagent(reagent, plan.reagentAmount(), itemInputs, fluidInputs, resolver)) - return new BuildResult(null); + return new BuildResult(null, "reagent"); var itemOutputs = new ArrayList(); var chances = new ArrayList(); for (var output : plan.itemOutputs()) { ItemStack stack = firstItem(output, resolver); - if (stack.isEmpty()) return new BuildResult(null); + if (stack.isEmpty()) return new BuildResult(null, "item-output"); itemOutputs.add(stack); chances.add((long) output.chance()); } var fluidOutputs = new ArrayList(); for (var output : plan.fluidOutputs()) { FluidStack stack = firstFluid(output, resolver); - if (stack.isEmpty()) return new BuildResult(null); + if (stack.isEmpty()) return new BuildResult(null, "fluid-output"); fluidOutputs.add(stack); } - if (itemOutputs.isEmpty() && fluidOutputs.isEmpty()) return new BuildResult(null); + if (itemOutputs.isEmpty() && fluidOutputs.isEmpty()) return new BuildResult(null, "empty-outputs"); return new BuildResult(new Recipe( itemInputs.toArray(ItemStack[]::new), itemOutputs.toArray(ItemStack[]::new), @@ -144,7 +149,7 @@ private static BuildResult build( fluidOutputs.toArray(FluidStack[]::new), plan.duration(), plan.euPerTick(), - 0)); + 0), null); } private static boolean addReagent( @@ -153,7 +158,11 @@ private static boolean addReagent( List itemInputs, List fluidInputs, Resolver resolver) { - for (var form : reagent.forms().stream() + var forms = reagent.forms().isEmpty() + ? resolver.bindings.find(reagent.material()).stream() + .map(binding -> binding.form()).collect(java.util.stream.Collectors.toSet()) + : reagent.forms(); + for (var form : forms.stream() .sorted(Comparator.comparing(FormKey::name)) .toList()) { if (isFluid(form)) { @@ -197,7 +206,7 @@ private static boolean isFluid(FormKey form) { private record TargetSelector(MaterialKey material, Map inputCounts, SpecialProcessValue.Target plan) {} - private record ReagentSelector(MaterialKey material, Set forms) {} + record ReagentSelector(MaterialKey material, Set forms) {} private record MethodRules( SpecialProcessMethod method, List targets, List reagents) {} @@ -230,7 +239,17 @@ private record ItemKey(MaterialKey material, FormKey form, int count) {} private record FluidKey(MaterialKey material, FormKey form, long amount) {} - private static final class Resolver { + static final class Resolver { + private final MaterialFormsView bindings; + + Resolver() { + this(MaterialViews.catalog().formBindings()); + } + + Resolver(MaterialFormsView bindings) { + this.bindings = bindings; + } + private final SharedOreWashingRows.Snapshot forms = new SharedOreWashingRows.Snapshot(); private final Map items = new HashMap<>(); private final Map fluids = new HashMap<>(); @@ -257,16 +276,17 @@ private ItemStack resolveItem(MaterialKey materialKey, FormKey form, int count) private FluidStack resolveFluid(MaterialKey materialKey, FormKey form, long amount) { if (!isFluid(form) || amount < 1 || amount > Integer.MAX_VALUE) return FluidStack.EMPTY; - if (materialKey.name().equals("Water")) return new FluidStack(Fluids.WATER, (int) amount); - var material = GTMaterialRegistry.get(materialKey.name()).resolve(); - if (material == null || !material.isValid()) return FluidStack.EMPTY; - var binding = MaterialFluidUnitFacts.binding(material, form.name()); - if (binding == null) return FluidStack.EMPTY; - var entry = FluidCatalog.get(binding.fluidField()); - if (entry == null || entry.gas() != form.name().equals("gas")) return FluidStack.EMPTY; - FluidStack stack = GTFluids.stack(binding.fluidField(), (int) amount); - if (stack == null || stack.isEmpty() || stack.getAmount() != amount) return FluidStack.EMPTY; - return stack; + // Special-process quantities are already mB; material-unit conversion is unrelated. + for (var binding : bindings.find(materialKey, form).stream() + .filter(value -> value.kind() == MaterialFormKind.FLUID) + .sorted(Comparator.comparing(value -> value.id())) + .toList()) { + var id = ResourceLocation.tryParse(binding.id()); + if (id == null) continue; + var fluid = BuiltInRegistries.FLUID.get(id); + if (fluid != Fluids.EMPTY) return new FluidStack(fluid, (int) amount); + } + return FluidStack.EMPTY; } } } diff --git a/minecraft/src/main/java/gregtech/content/recipe/generated/GTOreRecipes.java b/minecraft/src/main/java/gregtech/content/recipe/generated/GTOreRecipes.java index aca269e3a..b525c00a2 100644 --- a/minecraft/src/main/java/gregtech/content/recipe/generated/GTOreRecipes.java +++ b/minecraft/src/main/java/gregtech/content/recipe/generated/GTOreRecipes.java @@ -37,8 +37,8 @@ public static void register(boolean easyU235Extraction) { } ChemRecipeResolver.exclude(SOURCE + "owned", "magnetic-separator block dust and purified sifter rows are owned by their reviewed producers"); - ChemRecipeResolver.exclude(SOURCE + "108-159", - "the purified-acid vitriol loops are owned by SharedSpecialProcessRows"); + ChemRecipeResolver.exclude(SOURCE + "31-38/108-159", + "the purified-acid vitriol and gold/copper/tin aqua-regia rows are owned by SharedSpecialProcessRows"); ChemRecipeResolver.exclude(SOURCE + "54-57/174-190", "bedrock, moon and end rows need retired materials; Cryotheum/Pyrotheum loops need retired fluids"); ChemRecipeResolver.exclude(SOURCE + "63", @@ -85,14 +85,6 @@ private static void sourceRows(List rows) { row(SOURCE, "Centrifuge", 64, 16, 28).item(form("dust", "SoulSand", 1)).out(form("dust", "Sand", 1), 8000).out(form("dustTiny", "Niter", 1), 1000).out(form("dustTiny", "Coal", 1), 1000).out(form("dustTiny", "Bone", 1), 1000).out(nativeFluid("Oil_Soulsand", 5)).add(rows); row(SOURCE, "Centrifuge", true, 64, 144, 29).item(blockDust("Netherrack", 1)).out(form("dust", "Stone", 9), 8000).out(form("dustTiny", "S", 18), 1000).out(form("dustTiny", "Redstone", 9), 500).out(form("dustTiny", "Coal", 9), 500).out(form("dustTiny", "Au", 9), 100).add(rows); row(SOURCE, "Centrifuge", 64, 16, 30).item(form("dust", "Netherrack", 1)).out(form("dust", "Stone", 1), 8000).out(form("dustTiny", "S", 2), 1000).out(form("dustTiny", "Redstone", 1), 500).out(form("dustTiny", "Coal", 1), 500).out(form("dustTiny", "Au", 1), 100).add(rows); - row(SOURCE, "Bath", 0, 256, 31).item(form("crushedPurified", "Au", 1)).fluid(liquid("AquaRegia", thousandths(6500), CEIL)).out(form("crushedCentrifuged", "Au", 1), 10000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(liquid("ChloroauricAcid", thousandths(3000), CEIL)).out(gas("NO", thousandths(1000), CEIL)).out(water(waterUnits(3000), FLOOR)).add(rows); - row(SOURCE, "Bath", 0, 256, 32).item(form("crushedPurifiedTiny", "Au", 9)).fluid(liquid("AquaRegia", thousandths(6500), CEIL)).out(form("crushedCentrifuged", "Au", 1), 10000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(form("crushedCentrifugedTiny", "Cu", 2), 5000).out(liquid("ChloroauricAcid", thousandths(3000), CEIL)).out(gas("NO", thousandths(1000), CEIL)).out(water(waterUnits(3000), FLOOR)).add(rows); - row(SOURCE, "Bath", 0, 256, 33).item(form("crushedPurified", "Cu", 1)).fluid(liquid("AquaRegia", thousandths(6500), CEIL)).out(form("crushedCentrifuged", "Cu", 1), 10000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(liquid("ChloroauricAcid", thousandths(3000), CEIL)).out(gas("NO", thousandths(1000), CEIL)).out(water(waterUnits(3000), FLOOR)).add(rows); - row(SOURCE, "Bath", 0, 256, 34).item(form("crushedPurifiedTiny", "Cu", 9)).fluid(liquid("AquaRegia", thousandths(6500), CEIL)).out(form("crushedCentrifuged", "Cu", 1), 10000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(form("crushedCentrifugedTiny", "Co", 2), 5000).out(liquid("ChloroauricAcid", thousandths(3000), CEIL)).out(gas("NO", thousandths(1000), CEIL)).out(water(waterUnits(3000), FLOOR)).add(rows); - row(SOURCE, "Bath", 0, 256, 35).item(form("crushedPurified", "Sn", 1)).fluid(liquid("AquaRegia", thousandths(13000), CEIL)).out(form("crushedCentrifuged", "Sn", 1), 10000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(liquid("StannicChloride", thousandths(2500), CEIL)).out(gas("HCl", thousandths(4000), CEIL)).out(gas("NO2", thousandths(3000), CEIL)).add(rows); - row(SOURCE, "Bath", 0, 256, 36).item(form("crushedPurifiedTiny", "Sn", 9)).fluid(liquid("AquaRegia", thousandths(13000), CEIL)).out(form("crushedCentrifuged", "Sn", 1), 10000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(liquid("StannicChloride", thousandths(2500), CEIL)).out(gas("HCl", thousandths(4000), CEIL)).out(gas("NO2", thousandths(3000), CEIL)).add(rows); - row(SOURCE, "Bath", 0, 256, 37).item(form("crushedPurified", "Cassiterite", 1)).fluid(liquid("AquaRegia", thousandths(13000), CEIL)).out(form("crushedCentrifuged", "Cassiterite", 1), 10000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(liquid("StannicChloride", thousandths(2500), CEIL)).out(gas("HCl", thousandths(4000), CEIL)).out(gas("NO2", thousandths(3000), CEIL)).add(rows); - row(SOURCE, "Bath", 0, 256, 38).item(form("crushedPurifiedTiny", "Cassiterite", 9)).fluid(liquid("AquaRegia", thousandths(13000), CEIL)).out(form("crushedCentrifuged", "Cassiterite", 1), 10000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(form("crushedCentrifugedTiny", "Zn", 2), 5000).out(liquid("StannicChloride", thousandths(2500), CEIL)).out(gas("HCl", thousandths(4000), CEIL)).out(gas("NO2", thousandths(3000), CEIL)).add(rows); row(SOURCE, "Sifting", 16, 144, 39).item(tech("bop_grass_smoldering", 1)).out(vanilla("dirt", 1), 8000).out(dust("Ash", thousandths(250)), 2000).add(rows); row(SOURCE, "Sifting", 16, 144, 40).item(vanilla("dirt", 1)).out(dust("Sand", thousandths(1000)), 4500).out(dust("Stone", thousandths(1000)), 3000).out(dust("ClayBrown", thousandths(1000)), 250).out(tech("clay_ball_brown", 1), 100).add(rows); row(SOURCE, "Sifting", 16, 144, 41).item(tech("salt_dirt_1", 1)).out(dust("Sand", thousandths(1000)), 4500).out(dust("Stone", thousandths(1000)), 3000).out(dust("ClayBrown", thousandths(1000)), 250).out(tech("clay_ball_brown", 1), 100).out(form("dust", "NaCl", 1), 4500).add(rows); diff --git a/minecraft/src/main/java/gregtech/engine/material/MaterialFormContent.java b/minecraft/src/main/java/gregtech/engine/material/MaterialFormContent.java index 2ff944cb7..2dc09ea7a 100644 --- a/minecraft/src/main/java/gregtech/engine/material/MaterialFormContent.java +++ b/minecraft/src/main/java/gregtech/engine/material/MaterialFormContent.java @@ -75,6 +75,18 @@ public static synchronized void publish() { entry.getKey().toString(), 0)); } + // These material phases reuse vanilla fluids and have no GT fluid registration entry. + for (String name : List.of("Water", "Lava")) { + var fluid = name.equals("Water") + ? net.minecraft.world.level.material.Fluids.WATER + : net.minecraft.world.level.material.Fluids.LAVA; + bindings.add(new MaterialFormBinding( + new MaterialKey(name), + new FormKey("liquid"), + MaterialFormKind.FLUID, + BuiltInRegistries.FLUID.getKey(fluid).toString(), + 0)); + } MaterialViews.publishContent(List.copyOf(bindings)); } } diff --git a/minecraft/src/test/java/gregtech/content/recipe/SpecialProcessRecipeTests.java b/minecraft/src/test/java/gregtech/content/recipe/SpecialProcessRecipeTests.java new file mode 100644 index 000000000..ebf9a241a --- /dev/null +++ b/minecraft/src/test/java/gregtech/content/recipe/SpecialProcessRecipeTests.java @@ -0,0 +1,169 @@ +package gregtech.content.recipe; + +import gregtech.api.addon.material.FormKey; +import gregtech.api.addon.material.MaterialFormBinding; +import gregtech.api.addon.material.MaterialFormKind; +import gregtech.api.addon.material.MaterialFormsView; +import gregtech.api.addon.material.MaterialKey; +import gregtech.api.addon.material.SpecialProcessValue; +import gregtech.content.data.MachineRecipeMaps; +import gregtech.content.data.MaterialPrefix; +import gregtech.content.registry.GTItems; +import gregtech.engine.material.GTMaterialRegistry; +import gregtech.engine.material.MaterialViews; +import gregtech.engine.recipe.Recipe; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; +import net.minecraft.gametest.framework.GameTest; +import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.material.Fluids; +//? if >=1.21.1 { +/*import net.neoforged.neoforge.gametest.GameTestHolder; +import net.neoforged.neoforge.gametest.PrefixGameTestTemplate; +*///?} else { +import net.minecraftforge.gametest.GameTestHolder; +import net.minecraftforge.gametest.PrefixGameTestTemplate; +//?} + +@GameTestHolder("gt6ce") +@PrefixGameTestTemplate(false) +public final class SpecialProcessRecipeTests { + private SpecialProcessRecipeTests() {} + + @GameTest(template = "test_empty", batch = "material_baseline", timeoutTicks = 200) + public static void publishedFluidsAndAnyFormReagentsNeedNoUnitFacts(GameTestHelper helper) { + var custom = new MaterialKey("AddonProcessFluid"); + var liquid = new FormKey("liquid"); + var delegate = MaterialViews.catalog().formBindings(); + // A platform-published addon binding is sufficient; there is no internal unit-table entry. + MaterialFormsView forms = material -> material.equals(custom) + ? Set.of(new MaterialFormBinding(custom, liquid, MaterialFormKind.FLUID, "minecraft:lava", 0)) + : delegate.find(material); + var target = new MaterialKey("Gold"); + var input = new FormKey("crushedPurified"); + var itemOutput = new SpecialProcessValue.ItemOutput(target, + List.of(new SpecialProcessValue.FormCount(new FormKey("crushedCentrifuged"), 1)), 5000); + var fluidOutput = new SpecialProcessValue.FluidOutput(custom, + List.of(new SpecialProcessValue.FormCount(liquid, 1)), 123); + var plan = new SpecialProcessValue.Target(Map.of(input, 1), List.of(itemOutput), List.of(fluidOutput), 37, 256, 0); + var result = SharedSpecialProcessRows.build(target, input, 1, plan, + new SharedSpecialProcessRows.ReagentSelector(custom, Set.of()), new SharedSpecialProcessRows.Resolver(forms)); + helper.assertTrue(result.recipe() != null, "anyForm fluid reagent resolves: " + result.reason()); + var recipe = result.recipe(); + helper.assertTrue(recipe.mFluidInputs[0].getFluid() == Fluids.LAVA && recipe.mFluidInputs[0].getAmount() == 37, + "reagent uses the published identity and exact mB"); + helper.assertTrue(recipe.mFluidOutputs[0].getFluid() == Fluids.LAVA && recipe.mFluidOutputs[0].getAmount() == 123, + "output uses the published identity and exact mB"); + helper.assertTrue(recipe.mChances[0] == 5000, "item chance is preserved"); + + var missingOutput = new SpecialProcessValue.FluidOutput(custom, + List.of(new SpecialProcessValue.FormCount(new FormKey("gas"), 1)), 123); + var invalid = new SpecialProcessValue.Target(Map.of(input, 1), List.of(itemOutput), List.of(missingOutput), 37, 256, 0); + result = SharedSpecialProcessRows.build(target, input, 1, invalid, + new SharedSpecialProcessRows.ReagentSelector(custom, Set.of(liquid)), new SharedSpecialProcessRows.Resolver(forms)); + helper.assertTrue(result.recipe() == null && "fluid-output".equals(result.reason()), + "missing output rejects the whole row without substituting its phase"); + + var itemPlan = new SpecialProcessValue.Target(Map.of(input, 1), List.of(itemOutput), List.of(), 2, 256, 0); + result = SharedSpecialProcessRows.build(target, input, 1, itemPlan, + new SharedSpecialProcessRows.ReagentSelector(new MaterialKey("SodiumPersulfate"), Set.of()), + new SharedSpecialProcessRows.Resolver()); + helper.assertTrue(result.recipe() != null && result.recipe().mInputs[1].getCount() == 2, + "anyForm also resolves a registered item reagent"); + for (String name : List.of("Water", "Lava", "Mercury")) { + result = SharedSpecialProcessRows.build(target, input, 1, itemPlan, + new SharedSpecialProcessRows.ReagentSelector(new MaterialKey(name), Set.of(liquid)), + new SharedSpecialProcessRows.Resolver()); + helper.assertTrue(result.recipe() != null && result.recipe().mFluidInputs.length == 1 + && result.recipe().mFluidInputs[0].getAmount() == 2, + name + " resolves exact mB through its published native form"); + } + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_baseline", timeoutTicks = 200) + public static void aquaRegiaRowsHaveOneOwnerAndAllOutputs(GameTestHelper helper) { + var catalog = MaterialViews.catalog(); + for (String name : List.of("Gold", "Copper", "Tin", "Cassiterite", "Platinum", "Nickel")) { + var material = new MaterialKey(name); + var plan = (SpecialProcessValue.Target) catalog.processes().find(material, SpecialProcessMethods.AQUA_REGIA_LEACHING) + .stream().map(rule -> rule.value()).filter(SpecialProcessValue.Target.class::isInstance).findFirst().orElseThrow(); + boolean platinum = name.equals("Platinum") || name.equals("Nickel"); + boolean tin = name.equals("Tin") || name.equals("Cassiterite"); + long[] sourceFluidAmounts = platinum ? new long[] {4500, 1500, 4125} + : tin ? new long[] {2500, 4000, 3000} : new long[] {3000, 1000, 3000}; + helper.assertTrue(plan.reagentAmount() == (platinum ? 9750 : tin ? 13000 : 6500), "source acid amount"); + helper.assertTrue(plan.inputCounts().equals(Map.of(new FormKey("crushedPurified"), 1, + new FormKey("crushedPurifiedTiny"), 9)), "source purified input ratios"); + for (var input : plan.inputCounts().entrySet()) { + var result = SharedSpecialProcessRows.build(material, input.getKey(), input.getValue(), plan, + new SharedSpecialProcessRows.ReagentSelector(new MaterialKey("AquaRegia"), Set.of(new FormKey("liquid"))), + new SharedSpecialProcessRows.Resolver()); + helper.assertTrue(result.recipe() != null, name + "/" + input.getKey() + ": " + result.reason()); + var built = result.recipe(); + helper.assertTrue(built.mOutputs.length == 6 && built.mFluidOutputs.length == 3, "all aqua-regia outputs resolve"); + for (int i = 0; i < 6; i++) helper.assertTrue(built.mChances[i] == (i == 0 ? 10000 : 5000), "source output chances"); + for (int i = 0; i < 3; i++) helper.assertTrue(built.mFluidOutputs[i].getAmount() == sourceFluidAmounts[i], "source fluid amounts"); + var published = MachineRecipeMaps.Bath.mRecipeList.stream().filter(row -> sameInputs(row, built)).toList(); + helper.assertTrue(published.size() == 1, name + "/" + input.getKey() + " publishes exactly once, got " + published.size()); + helper.assertTrue(SharedSpecialProcessRows.owned().contains(published.get(0)), "declarative producer owns the published row"); + helper.assertTrue(published.get(0).mFluidOutputs.length == 3, "published row retains every fluid output"); + } + } + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_baseline", timeoutTicks = 200) + public static void persulfateBathKeepsSourceRatiosAndByproducts(GameTestHelper helper) { + var copper = GTMaterialRegistry.get("Copper"); + var rows = SharedOreWashingRows.definitions(List.of(copper), new SharedOreWashingRows.Snapshot()); + helper.assertTrue(SourceOreWashingRules.bathShapes().stream().map(shape -> shape.input().getName() + + "/" + shape.inputCount() + "/" + shape.reagent().getName() + "/" + shape.reagentCount()).toList() + .equals(List.of("crushed/1/dust/1", "crushedTiny/9/dust/1", "crushed/1/dustTiny/9", "crushedTiny/1/dustTiny/1")), + "all four source input/reagent ratios"); + for (String reagent : List.of("SodiumPersulfate", "PotassiumPersulfate")) { + for (var shape : SourceOreWashingRules.bathShapes()) { + var input = GTItems.getStack(shape.input(), copper, shape.inputCount()); + var dust = GTItems.getStack(shape.reagent(), GTMaterialRegistry.get(reagent), shape.reagentCount()); + var matches = rows.stream().filter(row -> row.map() == MachineRecipeMaps.Bath && row.inputs().length == 2 + && ItemStack.matches(row.inputs()[0], input) && ItemStack.matches(row.inputs()[1], dust)).toList(); + helper.assertTrue(matches.size() == 3, "each persulfate shape has three supported waters"); + for (var row : matches) { + boolean whole = shape.outputSize() == SourceOreWashingRules.Size.WHOLE; + helper.assertTrue(row.fluidInputs()[0].getAmount() == (whole ? 900 : 100), "source water amount"); + helper.assertTrue(row.duration() == (whole ? 144 : 16) && row.power() == 0, "source time and power"); + helper.assertTrue(row.fluidOutputs().length == 0, "persulfate produces no steam"); + helper.assertTrue(row.outputs().length == (whole ? 6 : 2), "source byproduct slot count"); + for (int i = 1; i < row.outputs().length; i++) helper.assertTrue(row.outputs()[i].getCount() == (whole && i < 5 ? 2 : 1), "source byproduct count"); + } + } + } + helper.succeed(); + } + + @GameTest(template = "test_empty", batch = "material_baseline", timeoutTicks = 200) + public static void woodDustsStillMakePaper(GameTestHelper helper) { + for (String name : List.of("Bamboo", "WoodRubber", "WoodTreated")) { + for (var prefix : List.of(MaterialPrefix.dust, MaterialPrefix.dustSmall, MaterialPrefix.dustTiny)) { + var stack = GTItems.getStack(prefix, GTMaterialRegistry.get(name), 1); + if (stack.isEmpty()) continue; + helper.assertTrue(MachineRecipeMaps.Bath.mRecipeList.stream().anyMatch(row -> row.mInputs.length == 1 + && row.itemTag(0) != null && stack.is(row.itemTag(0)) + && Arrays.stream(row.mOutputs).anyMatch(output -> output.is(Items.PAPER))), + name + "/" + prefix.getName() + " remains in the paper input tag"); + } + } + helper.succeed(); + } + + private static boolean sameInputs(Recipe row, Recipe expected) { + return row.mInputs.length == 1 && row.mFluidInputs.length == 1 + && ItemStack.matches(row.mInputs[0], expected.mInputs[0]) + && row.mFluidInputs[0].getFluid() == expected.mFluidInputs[0].getFluid() + && row.mFluidInputs[0].getAmount() == expected.mFluidInputs[0].getAmount(); + } +}