@@ -47,6 +47,20 @@ import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvi
4747 </#if >
4848 </#list >
4949</#if >
50+ <#assign placementPattern = r'\$([^$ ]+)\$'>
51+ <#assign placementMatches = placementcode?matches(placementPattern) >
52+ <#assign placementHardcodedElements = [ ]>
53+ <#list placementMatches as match >
54+ <#assign placementHardcodedElements = placementHardcodedElements + [match?groups[1 ]]>
55+ </#list >
56+ <#assign nonHardcodedPlacement = placementcode?replace(placementPattern, "", "r") >
57+ <#assign configurationMatches = configurationcode?matches(placementPattern) >
58+ <#assign configurationHardcodedElements = [ ]>
59+ <#list configurationMatches as match >
60+ <#assign configurationHardcodedElements = configurationHardcodedElements + [match?groups[1 ]]>
61+ </#list >
62+ <#assign nonHardcodedConfiguration = configurationcode?replace(placementPattern, "", "r") >
63+ <#assign allHardcodedElements = placementHardcodedElements + configurationHardcodedElements >
5064<#compress >
5165public class ${name} Feature extends ${generator.map(featuretype, "features") } {
5266 private static ${name} Feature FEATURE = null;
@@ -59,9 +73,9 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
5973
6074 public static Feature<?> feature() {
6175 FEATURE = new ${name} Feature();
62- CONFIGURED_FEATURE = <#if featuretype == "configured_feature_reference" >${configurationcode } <#else >FeatureUtils.register("${modid} :${registryname} ", FEATURE, ${configurationcode } )</#if >;
76+ CONFIGURED_FEATURE = <#if featuretype == "configured_feature_reference" >${nonHardcodedConfiguration } <#else >FeatureUtils.register("${modid} :${registryname} ", FEATURE, ${nonHardcodedConfiguration } )</#if >;
6377 PLACED_FEATURE = PlacementUtils.register("${modid} :${registryname} ", CONFIGURED_FEATURE,
64- List.of(<#if data.hasPlacedFeature() >${placementcode ?remove_ending(",") } </#if >));
78+ List.of(<#if data.hasPlacedFeature() >${nonHardcodedPlacement ?remove_ending(",") } </#if >));
6579 return FEATURE;
6680 }
6781
@@ -98,7 +112,7 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
98112 );
99113 </#if >
100114
101- <#if data.hasPlacedFeature() && ((data.restrictionBiomes?has_content && cond) || data.hasGenerationConditions()) >
115+ <#if data.hasPlacedFeature() && ((( data.restrictionBiomes?has_content && cond) || data.hasGenerationConditions()) || (allHardcodedElements?size > 0 ))>
102116 @Override public boolean place(FeaturePlaceContext<${configuration} > context) {
103117 <#-- #4781 - we need to use WorldGenLevel instead of Level, or one can run incompatible procedures in condition -->
104118 WorldGenLevel world = context.level();
@@ -115,6 +129,12 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
115129 return false;
116130 </#if >
117131
132+ <#if (allHardcodedElements?size > 0)>
133+ <#list allHardcodedElements as element >
134+ ${element}
135+ </#list >
136+ </#if >
137+
118138 return super.place(context);
119139 }
120140 </#if >
0 commit comments