Skip to content

Commit 3e68d90

Browse files
committed
Merge branch 'ore_datagen_dimension' into ore_datagen_additions
# Conflicts: # src/client/java/aztech/modern_industrialization/textures/PartTextureGenerator.java # src/main/java/aztech/modern_industrialization/compat/kubejs/material/PartJsonCreator.java # src/main/java/aztech/modern_industrialization/materials/part/OrePart.java
2 parents 2848438 + a1bf50c commit 3e68d90

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

src/client/java/aztech/modern_industrialization/textures/PartTextureGenerator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ private void processHotIngot() {
157157
private void processOre(ResourceLocation stoneType, MaterialOreSet oreSet) throws IOException {
158158
String template = String.format("modern_industrialization:textures/materialsets/ores/%s.png", oreSet.name);
159159
String stoneId = stoneType.getPath();
160-
String prefix = "";
160+
String prefix;
161+
if (stoneId.equals("stone")) {
162+
prefix = "";
163+
} else {
164+
prefix = stoneId + "_";
165+
}
161166

162167
String from = switch (oreSet) {
163168
case IRON -> "%siron_ore".formatted(prefix);

src/main/java/aztech/modern_industrialization/compat/kubejs/material/PartJsonCreator.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@
3333
import aztech.modern_industrialization.materials.set.MaterialRawSet;
3434
import aztech.modern_industrialization.nuclear.NuclearConstant;
3535
import com.google.gson.JsonObject;
36+
import net.minecraft.core.registries.Registries;
3637
import net.minecraft.resources.ResourceLocation;
38+
import net.minecraft.tags.BiomeTags;
39+
import net.minecraft.tags.TagKey;
3740
import net.minecraft.util.valueproviders.UniformInt;
41+
import net.minecraft.world.level.biome.Biome;
3842

3943
public class PartJsonCreator {
4044

@@ -132,10 +136,14 @@ public PartTemplate orePart(JsonObject json, ResourceLocation stoneType) {
132136
}
133137

134138
if (generate) {
139+
TagKey<Biome> biomeTag = BiomeTags.IS_OVERWORLD;
140+
if (json.has("biome_tag")) {
141+
biomeTag = TagKey.create(Registries.BIOME, ResourceLocation.parse(json.get("biome_tag").getAsString()));
142+
}
135143
int veinSize = json.get("vein_size").getAsInt();
136144
int veinPerChunk = json.get("veins_per_chunk").getAsInt();
137145
int maxY = json.get("max_y").getAsInt();
138-
return act.of(UniformInt.of(minXp, maxXp), veinSize, veinPerChunk, maxY, oreSet);
146+
return act.of(UniformInt.of(minXp, maxXp), veinSize, veinPerChunk, maxY, oreSet, biomeTag);
139147
} else {
140148
return act.of(UniformInt.of(minXp, maxXp), oreSet);
141149
}

src/main/java/aztech/modern_industrialization/materials/part/OrePart.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@
4545
import net.minecraft.resources.ResourceLocation;
4646
import net.minecraft.tags.BiomeTags;
4747
import net.minecraft.tags.BlockTags;
48+
import net.minecraft.tags.TagKey;
4849
import net.minecraft.util.valueproviders.UniformInt;
50+
import net.minecraft.world.level.biome.Biome;
4951
import net.minecraft.world.level.levelgen.GenerationStep;
5052
import net.minecraft.world.level.levelgen.VerticalAnchor;
5153
import net.minecraft.world.level.levelgen.feature.Feature;
5254
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
5355
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
56+
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockMatchTest;
57+
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest;
5458
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;
5559
import net.neoforged.neoforge.common.Tags;
5660
import net.neoforged.neoforge.common.world.BiomeModifiers;
@@ -67,6 +71,10 @@ public PartKey key() {
6771
return key;
6872
}
6973

74+
public PartTemplate of(UniformInt xpProvider, int veinsPerChunk, int veinSize, int maxYLevel, MaterialOreSet set, TagKey<Biome> biomeTag) {
75+
return of(new OrePartParams(xpProvider, set, veinsPerChunk, veinSize, maxYLevel, biomeTag));
76+
}
77+
7078
public PartTemplate of(int veinsPerChunk, int veinSize, int maxYLevel, MaterialOreSet set) {
7179
return of(new OrePartParams(UniformInt.of(0, 2), set, veinsPerChunk, veinSize, maxYLevel));
7280
}
@@ -151,13 +159,13 @@ public PartTemplate of(OrePartParams oreParams) {
151159
var modifierKey = ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, oreGenId);
152160

153161
DynamicRegistryDatagen.addAction(() -> {
154-
TagMatchTest ruleTest;
162+
RuleTest ruleTest;
155163
if (stoneId.equals("stone")) {
156164
ruleTest = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES);
157165
} else if (stoneId.equals("deepslate")) {
158166
ruleTest = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);
159167
} else {
160-
return;
168+
ruleTest = new BlockMatchTest(BuiltInRegistries.BLOCK.get(stoneType));
161169
}
162170
var target = List.of(
163171
OreConfiguration.target(ruleTest, oreBlockBlockDefinition.asBlock().defaultBlockState()));
@@ -176,7 +184,7 @@ public PartTemplate of(OrePartParams oreParams) {
176184

177185
DynamicRegistryDatagen.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, context -> {
178186
var modifier = new BiomeModifiers.AddFeaturesBiomeModifier(
179-
context.lookup(Registries.BIOME).getOrThrow(BiomeTags.IS_OVERWORLD),
187+
context.lookup(Registries.BIOME).getOrThrow(oreParams.biomeTag),
180188
HolderSet.direct(context.lookup(Registries.PLACED_FEATURE).getOrThrow(placedFeatureKey)),
181189
GenerationStep.Decoration.UNDERGROUND_ORES);
182190
context.register(modifierKey, modifier);
@@ -207,27 +215,35 @@ public static class OrePartParams {
207215
public final MaterialOreSet set;
208216
public final boolean generate;
209217

218+
public final TagKey<Biome> biomeTag;
210219
public final int veinsPerChunk;
211220
public final int veinSize;
212221
public final int maxYLevel;
213222

214-
private OrePartParams(UniformInt xpDropped, MaterialOreSet set, boolean generate, int veinsPerChunk, int veinSize, int maxYLevel) {
223+
private OrePartParams(UniformInt xpDropped, MaterialOreSet set, boolean generate, int veinsPerChunk, int veinSize, int maxYLevel,
224+
TagKey<Biome> biomeTag) {
215225
this.xpDropped = xpDropped;
216226
this.set = set;
217227
this.generate = generate;
218228

229+
this.biomeTag = biomeTag;
219230
this.veinsPerChunk = veinsPerChunk;
220231
this.veinSize = veinSize;
221232
this.maxYLevel = maxYLevel;
222233
}
223234

224235
public OrePartParams(UniformInt xpDropped, MaterialOreSet set) {
225-
this(xpDropped, set, false, 0, 0, 0);
236+
this(xpDropped, set, false, 0, 0, 0, BiomeTags.IS_OVERWORLD);
226237
}
227238

228239
public OrePartParams(UniformInt xpDropped, MaterialOreSet set, int veinsPerChunk, int veinSize, int maxYLevel) {
229-
this(xpDropped, set, true, veinsPerChunk, veinSize, maxYLevel);
240+
this(xpDropped, set, true, veinsPerChunk, veinSize, maxYLevel, BiomeTags.IS_OVERWORLD);
230241
}
242+
243+
public OrePartParams(UniformInt xpDropped, MaterialOreSet set, int veinsPerChunk, int veinSize, int maxYLevel, TagKey<Biome> biomeTag) {
244+
this(xpDropped, set, true, veinsPerChunk, veinSize, maxYLevel, biomeTag);
245+
}
246+
231247
}
232248

233249
}

0 commit comments

Comments
 (0)