@@ -49,11 +49,18 @@ import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvi
4949</#if >
5050<#assign placementPattern = r'\$([^$ ]+)\$'>
5151<#assign placementMatches = placementcode?matches(placementPattern) >
52- <#assign hardcodedElements = [ ]>
52+ <#assign placementHardcodedElements = [ ]>
5353<#list placementMatches as match >
54- <#assign hardcodedElements = hardcodedElements + [match?groups[1 ]]>
54+ <#assign placementHardcodedElements = placementHardcodedElements + [match?groups[1 ]]>
5555</#list >
56- <#assign nonHardcodedElements = placementcode?replace(placementPattern, "", "r") >
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 >
5764<#compress >
5865public class ${name} Feature extends ${generator.map(featuretype, "features") } {
5966 private static ${name} Feature FEATURE = null;
@@ -64,8 +71,9 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
6471 }
6572
6673 public static Feature<?> feature() {
74+ Random random = new Random();
6775 FEATURE = new ${name} Feature();
68- CONFIGURED_FEATURE = <#if featuretype == "configured_feature_reference" >${configurationcode } <#else >FEATURE.configured(<#if configurationcode == "" >NoneFeatureConfiguration.INSTANCE<#else >${configurationcode } </#if >)</#if ><#if data.hasPlacedFeature() >${nonHardcodedElements } </#if >;
76+ CONFIGURED_FEATURE = <#if featuretype == "configured_feature_reference" >${nonHardcodedConfiguration } <#else >FEATURE.configured(<#if nonHardcodedConfiguration == "" >NoneFeatureConfiguration.INSTANCE<#else >${nonHardcodedConfiguration } </#if >)</#if ><#if data.hasPlacedFeature() >${nonHardcodedPlacement } </#if >;
6977
7078 Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation("${modid} :${registryname} "), CONFIGURED_FEATURE);
7179
@@ -105,7 +113,7 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
105113 );
106114 </#if >
107115
108- <#if data.hasPlacedFeature() && ((data.restrictionBiomes?has_content && cond) || data.hasGenerationConditions() || (hardcodedElements ?size > 0))>
116+ <#if data.hasPlacedFeature() && ((data.restrictionBiomes?has_content && cond) || data.hasGenerationConditions() || (allHardcodedElements ?size > 0))>
109117 @Override public boolean place(FeaturePlaceContext<${configuration} > context) {
110118 <#-- #4781 - we need to use WorldGenLevel instead of Level, or one can run incompatible procedures in condition -->
111119 WorldGenLevel world = context.level();
@@ -123,13 +131,13 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
123131 return false;
124132 </#if >
125133
126- <#if data.hasPlacedFeature() && (hardcodedElements ?size > 0)>
127- <#list hardcodedElements as element >
134+ <#if data.hasPlacedFeature() && (allHardcodedElements ?size > 0)>
135+ <#list allHardcodedElements as element >
128136 ${element}
129137 </#list >
130138 </#if >
131139
132- return super.place(<#if (hardcodedElements ?size > 0)>new FeaturePlaceContext<> (world, context.chunkGenerator(), context.random(), origin, context.config())<#else >context</#if >);
140+ return super.place(<#if (allHardcodedElements ?size > 0)>new FeaturePlaceContext<> (world, context.chunkGenerator(), context.random(), origin, context.config())<#else >context</#if >);
133141 }
134142 </#if >
135143}</#compress >
@@ -178,4 +186,4 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
178186 <#assign result = "minecraft:" + noHash / >
179187 <#return input?starts_with("#")?then("#" + result, result)/ >
180188 </#if >
181- </#function >
189+ </#function >
0 commit comments