Skip to content

Commit 18ee1f6

Browse files
committed
Some fixes
1 parent 857b21c commit 18ee1f6

File tree

7 files changed

+29
-42
lines changed

7 files changed

+29
-42
lines changed

forge-1.18.2/block.definition.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,15 @@ templates:
362362
writer: json
363363
name: "@MODASSETSROOT/models/block/@registryname_inventory.json"
364364

365-
global_templates:
366-
- template: elementinits/features.java.ftl
367-
condition: generateFeature
368-
name: "@SRCROOT/@BASEPACKAGEPATH/init/@JavaModNameFeatures.java"
369-
370365
localizationkeys:
371366
- key: block.@modid.@registryname
372367
mapto: name
373368

369+
global_templates:
370+
- template: elementinits/features.java.ftl
371+
condition: '${w.getGElementsOfType("block")?filter(e -> e.generateFeature )?size != 0}'
372+
name: "@SRCROOT/@BASEPACKAGEPATH/init/@JavaModNameFeatures.java"
373+
374374
tags:
375375
- tag: BLOCKS:minecraft:mineable/pickaxe
376376
condition: "${data.destroyTool == 'pickaxe'}"

forge-1.18.2/plant.definition.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ templates:
7474
condition: "plantType %= double"
7575
name: "@MODASSETSROOT/blockstates/@registryname.json"
7676

77-
global_templates:
78-
- template: elementinits/features.java.ftl
79-
condition: generateFeature
80-
name: "@SRCROOT/@BASEPACKAGEPATH/init/@JavaModNameFeatures.java"
81-
8277
localizationkeys:
8378
- key: block.@modid.@registryname
84-
mapto: name
79+
mapto: name
80+
81+
global_templates:
82+
- template: elementinits/features.java.ftl
83+
condition: '${w.getGElementsOfType("plant")?filter(e -> e.generateFeature )?size != 0}'
84+
name: "@SRCROOT/@BASEPACKAGEPATH/init/@JavaModNameFeatures.java"

forge-1.18.2/templates/block/oregen.java.ftl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ package ${package}.world.features.ores;
3535
<#assign cond = false>
3636
<#if data.restrictionBiomes?has_content>
3737
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
38-
<#if restrictionBiome?contains(":is_")>
38+
<#if restrictionBiome == "#minecraft:is_overworld" || restrictionBiome == "#minecraft:is_end">
3939
<#assign cond = true>
4040
<#break>
4141
</#if>
@@ -71,7 +71,7 @@ public class ${name}Feature extends OreFeature {
7171
<#if data.restrictionBiomes?has_content && !cond>
7272
Set.of(
7373
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
74-
new ResourceLocation("${restrictionBiome}")<#sep>,
74+
new ResourceLocation("${restrictionBiome?replace("#", "")}")<#sep>,
7575
</#list>
7676
);
7777
<#else>
@@ -83,13 +83,8 @@ public class ${name}Feature extends OreFeature {
8383
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
8484
<#if restrictionBiome == "#minecraft:is_overworld">
8585
Level.OVERWORLD
86-
<#elseif restrictionBiome == "#minecraft:is_nether">
87-
Level.NETHER
8886
<#elseif restrictionBiome == "#minecraft:is_end">
8987
Level.END
90-
<#else>
91-
ResourceKey.create(Registry.DIMENSION_REGISTRY,
92-
new ResourceLocation("${modid}:${restrictionBiome?keep_after("is_")}"))
9388
</#if><#sep>,
9489
</#list>
9590
);

forge-1.18.2/templates/elementinits/features.java.ftl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,32 @@ package ${package}.init;
4040

4141
private static final List<FeatureRegistration> FEATURE_REGISTRATIONS = new ArrayList<>();
4242

43-
<#list features as feature>
44-
<#if feature.getModElement().getTypeString() == "block">
43+
<#list w.getGElementsOfType("feature") as feature>
4544
public static final RegistryObject<Feature<?>> ${feature.getModElement().getRegistryNameUpper()} =
4645
register("${feature.getModElement().getRegistryName()}", ${feature.getModElement().getName()}Feature::feature,
47-
new FeatureRegistration(GenerationStep.Decoration.UNDERGROUND_ORES,
46+
new FeatureRegistration(GenerationStep.Decoration.${generator.map(feature.generationStep, "generationsteps")},
4847
${feature.getModElement().getName()}Feature.GENERATE_BIOMES,
4948
${feature.getModElement().getName()}Feature::placedFeature)
5049
);
51-
<#elseif feature.getModElement().getTypeString() == "plant">
50+
</#list>
51+
52+
<#list w.getGElementsOfType("block")?filter(e -> e.generateFeature) as feature>
5253
public static final RegistryObject<Feature<?>> ${feature.getModElement().getRegistryNameUpper()} =
5354
register("${feature.getModElement().getRegistryName()}", ${feature.getModElement().getName()}Feature::feature,
54-
new FeatureRegistration(GenerationStep.Decoration.VEGETAL_DECORATION,
55+
new FeatureRegistration(GenerationStep.Decoration.UNDERGROUND_ORES,
5556
${feature.getModElement().getName()}Feature.GENERATE_BIOMES,
5657
${feature.getModElement().getName()}Feature::placedFeature)
5758
);
58-
<#elseif feature.getModElement().getTypeString() == "feature">
59+
</#list>
60+
61+
<#list w.getGElementsOfType("plant")?filter(e -> e.generateFeature) as feature>
5962
public static final RegistryObject<Feature<?>> ${feature.getModElement().getRegistryNameUpper()} =
6063
register("${feature.getModElement().getRegistryName()}", ${feature.getModElement().getName()}Feature::feature,
61-
new FeatureRegistration(GenerationStep.Decoration.${generator.map(feature.generationStep, "generationsteps")},
64+
new FeatureRegistration(GenerationStep.Decoration.VEGETAL_DECORATION,
6265
${feature.getModElement().getName()}Feature.GENERATE_BIOMES,
6366
${feature.getModElement().getName()}Feature::placedFeature)
6467
);
65-
</#if>
66-
</#list>
68+
</#list>
6769

6870
private static RegistryObject<Feature<?>> register(String registryname, Supplier<Feature<?>> feature, FeatureRegistration featureRegistration) {
6971
FEATURE_REGISTRATIONS.add(featureRegistration);

forge-1.18.2/templates/feature/feature.java.ftl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvi
4040
<#assign cond = false>
4141
<#if data.restrictionBiomes?has_content>
4242
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
43-
<#if restrictionBiome?contains(":is_")>
43+
<#if restrictionBiome == "#minecraft:is_overworld" || restrictionBiome == "#minecraft:is_end">
4444
<#assign cond = true>
4545
<#break>
4646
</#if>
@@ -69,7 +69,7 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
6969
<#if data.restrictionBiomes?has_content && !cond>
7070
Set.of(
7171
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
72-
new ResourceLocation("${restrictionBiome}")<#sep>,
72+
new ResourceLocation("${restrictionBiome?replace("#", "")}")<#sep>,
7373
</#list>
7474
);
7575
<#else>
@@ -81,13 +81,8 @@ public class ${name}Feature extends ${generator.map(featuretype, "features")} {
8181
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
8282
<#if restrictionBiome == "#minecraft:is_overworld">
8383
Level.OVERWORLD
84-
<#elseif restrictionBiome == "#minecraft:is_nether">
85-
Level.NETHER
8684
<#elseif restrictionBiome == "#minecraft:is_end">
8785
Level.END
88-
<#else>
89-
ResourceKey.create(Registry.DIMENSION_REGISTRY,
90-
new ResourceLocation("${modid}:${restrictionBiome?keep_after("is_")}"))
9186
</#if><#sep>,
9287
</#list>
9388
);

forge-1.18.2/templates/modbase/mod.java.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import org.apache.logging.log4j.Logger;
2222
<#if w.hasElementsOfBaseType("item")>${JavaModName}Items.REGISTRY.register(bus);</#if>
2323
<#if w.hasElementsOfBaseType("entity")>${JavaModName}Entities.REGISTRY.register(bus);</#if>
2424
<#if w.hasElementsOfBaseType("blockentity")>${JavaModName}BlockEntities.REGISTRY.register(bus);</#if>
25-
<#if features?has_content>${JavaModName}Features.REGISTRY.register(bus);</#if>
25+
<#if w.getGElementsOfType("block")?filter(e -> e.generateFeature )?size != 0 || w.getGElementsOfType("plant")?filter(e -> e.generateFeature )?size != 0 || w.hasElementsOfType("feature")>${JavaModName}Features.REGISTRY.register(bus);</#if>
2626
<#if w.getElementsOfType("feature")?filter(e -> e.getMetadata("has_nbt_structure")??)?size != 0>StructureFeature.REGISTRY.register(bus);</#if>
2727
<#if w.hasElementsOfType("enchantment")>${JavaModName}Enchantments.REGISTRY.register(bus);</#if>
2828
<#if w.hasElementsOfType("potioneffect")>${JavaModName}MobEffects.REGISTRY.register(bus);</#if>

forge-1.18.2/templates/plant/plantgen.java.ftl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ package ${package}.world.features.plants;
3535
<#assign cond = false>
3636
<#if data.restrictionBiomes?has_content>
3737
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
38-
<#if restrictionBiome?contains(":is_")>
38+
<#if restrictionBiome == "#minecraft:is_overworld" || restrictionBiome == "#minecraft:is_end">
3939
<#assign cond = true>
4040
<#break>
4141
</#if>
@@ -93,7 +93,7 @@ public class ${name}Feature extends RandomPatchFeature {
9393
<#if data.restrictionBiomes?has_content && !cond>
9494
Set.of(
9595
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
96-
new ResourceLocation("${restrictionBiome}")<#sep>,
96+
new ResourceLocation("${restrictionBiome?replace("#", "")}")<#sep>,
9797
</#list>
9898
);
9999
<#else>
@@ -105,13 +105,8 @@ public class ${name}Feature extends RandomPatchFeature {
105105
<#list w.filterBrokenReferences(data.restrictionBiomes) as restrictionBiome>
106106
<#if restrictionBiome == "#minecraft:is_overworld">
107107
Level.OVERWORLD
108-
<#elseif restrictionBiome == "#minecraft:is_nether">
109-
Level.NETHER
110108
<#elseif restrictionBiome == "#minecraft:is_end">
111109
Level.END
112-
<#else>
113-
ResourceKey.create(Registry.DIMENSION_REGISTRY,
114-
new ResourceLocation("${modid}:${restrictionBiome?keep_after("is_")}"))
115110
</#if><#sep>,
116111
</#list>
117112
);

0 commit comments

Comments
 (0)