@@ -268,9 +268,12 @@ private static BakedOres bakeOres(JsonObject profile, BakedGeomeConfig config) {
268268 if (ruleId == null ) ruleId = oreId ;
269269 outputBundles .put (ruleId .toString (), new BakedOutputBundle (
270270 output .defaultBlockState (), deepOutput , deepOutputMaxY , outputs ));
271- if (!oreEnabled || (nativeGeneration && !manageVanillaOres )) continue ;
271+ boolean importedVanilla = !nativeGeneration && isImportedVanillaOre (ruleId , output , oreJson );
272+ // Keep imported settings, but let vanilla place its own ores while management is off.
273+ if (!oreEnabled || (!manageVanillaOres && (nativeGeneration || importedVanilla ))) continue ;
272274 Identifier material = OreSourcePolicies .material (profile , oreJson , output );
273- BakedOreRule rule = new BakedOreRule (output , manageVanillaOres && suppressVanilla );
275+ BakedOreRule rule = new BakedOreRule (ruleId , output ,
276+ manageVanillaOres && (importedVanilla || suppressVanilla ), nativeGeneration , importedVanilla );
274277
275278 for (Entry <String , JsonElement > dimensionEntry : dimensions .entrySet ()) {
276279 Identifier dimensionId = resource (dimensionEntry .getKey ());
@@ -333,10 +336,11 @@ private static BakedOres bakeOres(JsonObject profile, BakedGeomeConfig config) {
333336 rule .selector , dimension );
334337 if (selected != null ) {
335338 combined .add (selected );
336- if (rule .suppressVanilla ) suppressed . add ( rule .output );
339+ if (rule .suppressVanilla ) rule .addSuppressedOutputs ( suppressed );
337340 }
338341 }
339342 combined = arbitrate (profile , combined , outputBundles );
343+ combined = preferImportedVanilla (rules , combined );
340344 result .put (dimension , combined .toArray (new BakedOre [combined .size ()]));
341345 vanillaOutputs .put (dimension , Collections .unmodifiableSet (suppressed ));
342346 }
@@ -345,9 +349,10 @@ private static BakedOres bakeOres(JsonObject profile, BakedGeomeConfig config) {
345349 for (BakedOreRule rule : rules ) {
346350 if (rule .selector == null ) continue ;
347351 selectorList .add (rule .selector );
348- if (rule .suppressVanilla ) selectorOutputs . add ( rule .output );
352+ if (rule .suppressVanilla ) rule .addSuppressedOutputs ( selectorOutputs );
349353 }
350354 selectorList = arbitrate (profile , selectorList , outputBundles );
355+ selectorList = preferImportedVanilla (rules , selectorList );
351356 BakedOre [] selectorResult = selectorList .toArray (new BakedOre [selectorList .size ()]);
352357 LOGGER .info ("Baked {} OreSpawn-managed ore definitions across {} dimensions" ,
353358 rules .size (), result .size ());
@@ -360,6 +365,35 @@ private static BakedOres bakeOres(JsonObject profile, BakedGeomeConfig config) {
360365 Collections .unmodifiableSet (selectorOutputs ));
361366 }
362367
368+ static boolean isImportedVanillaOre (Identifier ruleId , Block output , JsonObject ore ) {
369+ return (ruleId != null && ruleId .getPath ().startsWith ("legacy/" )
370+ || "legacy" .equals (string (ore , "source_mod" , "" )))
371+ && VanillaOreFeatureGate .vanillaOreFamily (output ) != null ;
372+ }
373+
374+ private static List <BakedOre > preferImportedVanilla (List <BakedOreRule > rules , List <BakedOre > selected ) {
375+ Map <Identifier , BakedOreRule > byId = new HashMap <>();
376+ for (BakedOreRule rule : rules ) byId .put (rule .ruleId , rule );
377+ Set <Block > importedFamilies = Collections .newSetFromMap (new IdentityHashMap <>());
378+ for (BakedOre ore : selected ) {
379+ BakedOreRule rule = byId .get (ore .ruleId );
380+ if (rule != null && rule .importedVanilla ) {
381+ importedFamilies .add (VanillaOreFeatureGate .vanillaOreFamily (rule .output ));
382+ }
383+ }
384+ if (importedFamilies .isEmpty ()) return selected ;
385+ List <BakedOre > result = new ArrayList <>();
386+ for (BakedOre ore : selected ) {
387+ BakedOreRule rule = byId .get (ore .ruleId );
388+ // Apply this after Ore Sources so an explicit saved placement choice wins.
389+ if (rule == null || !rule .nativeGeneration
390+ || !importedFamilies .contains (VanillaOreFeatureGate .vanillaOreFamily (rule .output ))) {
391+ result .add (ore );
392+ }
393+ }
394+ return result ;
395+ }
396+
363397 private static List <BakedOre > arbitrate (JsonObject profile , List <BakedOre > original ,
364398 Map <String , BakedOutputBundle > outputBundles ) {
365399 if (!profile .has (OreSourcePolicies .SECTION )
@@ -842,15 +876,27 @@ boolean acceptsBiome(ResourceKey<Biome> biome) {
842876 }
843877
844878 private static final class BakedOreRule {
879+ final Identifier ruleId ;
845880 final Block output ;
846881 final boolean suppressVanilla ;
882+ final boolean nativeGeneration ;
883+ final boolean importedVanilla ;
847884 final Map <ResourceKey <Level >, BakedOre > explicit = new HashMap <>();
848885 final Set <ResourceKey <Level >> explicitDimensions = new HashSet <>();
849886 BakedOre selector ;
850887
851- BakedOreRule (Block output , boolean suppressVanilla ) {
888+ BakedOreRule (Identifier ruleId , Block output , boolean suppressVanilla ,
889+ boolean nativeGeneration , boolean importedVanilla ) {
890+ this .ruleId = ruleId ;
852891 this .output = output ;
853892 this .suppressVanilla = suppressVanilla ;
893+ this .nativeGeneration = nativeGeneration ;
894+ this .importedVanilla = importedVanilla ;
895+ }
896+
897+ void addSuppressedOutputs (Set <Block > outputs ) {
898+ outputs .add (output );
899+ if (importedVanilla ) outputs .add (VanillaOreFeatureGate .vanillaOreFamily (output ));
854900 }
855901 }
856902
0 commit comments