Skip to content

Commit

Permalink
fix worldgen with terralith (and maybe others)
Browse files Browse the repository at this point in the history
fixes #5039
  • Loading branch information
SiverDX authored and TheBv committed Dec 26, 2023
1 parent 2b8aac0 commit 4f360c7
Show file tree
Hide file tree
Showing 30 changed files with 389 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:cyclops_cave",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:fire_dragon_cave",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:fire_dragon_roost",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"feature": "iceandfire:fire_lily",
"placement": [
{
"type": "minecraft:rarity_filter",
"chance": 32
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:heightmap",
"heightmap": "MOTION_BLOCKING"
},
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"feature": "iceandfire:lightning_lily",
"placement": [
{
"type": "minecraft:rarity_filter",
"chance": 32
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:heightmap",
"heightmap": "MOTION_BLOCKING"
},
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:hydra_cave",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:ice_dragon_cave",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:ice_dragon_roost",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:lightning_dragon_cave",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:lightning_dragon_roost",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"feature": "iceandfire:frost_lily",
"placement": [
{
"type": "minecraft:rarity_filter",
"chance": 32
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:heightmap",
"heightmap": "MOTION_BLOCKING"
},
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:myrmex_hive_desert",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:myrmex_hive_jungle",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:pixie_village",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:siren_island",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:spawn_death_worm",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:spawn_dragon_skeleton_fire",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:spawn_dragon_skeleton_ice",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:spawn_dragon_skeleton_lightning",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:spawn_hippocampus",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:spawn_sea_serpent",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:spawn_stymphalian_bird",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"feature": "iceandfire:spawn_wandering_cyclops",
"placement": [
{
"type": "iceandfire:biome_custom"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.github.alexthe666.iceandfire.message.*;
import com.github.alexthe666.iceandfire.recipe.IafRecipeRegistry;
import com.github.alexthe666.iceandfire.recipe.IafRecipeSerializers;
import com.github.alexthe666.iceandfire.world.IafPlacementFilterRegistry;
import com.github.alexthe666.iceandfire.world.IafProcessors;
import com.github.alexthe666.iceandfire.world.IafWorldRegistry;
import net.minecraft.core.Registry;
Expand Down Expand Up @@ -115,6 +116,7 @@ public IceAndFire() {
IafBlockRegistry.BLOCKS.register(modBus);
IafEntityRegistry.ENTITIES.register(modBus);
IafTileEntityRegistry.TYPES.register(modBus);
IafPlacementFilterRegistry.PLACEMENT_MODIFIER_TYPES.register(modBus);
IafWorldRegistry.FEATURES.register(modBus);
IafWorldRegistry.STRUCTURES.register(modBus);
IafContainerRegistry.CONTAINERS.register(modBus);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.github.alexthe666.iceandfire.datagen;

import com.github.alexthe666.iceandfire.IceAndFire;
import com.github.alexthe666.iceandfire.world.CustomBiomeFilter;
import com.google.gson.JsonElement;
import net.minecraft.core.Registry;
import net.minecraft.data.worldgen.placement.PlacementUtils;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.placement.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class IafPlacedFeatures {
public static final ResourceKey<PlacedFeature> PLACED_FIRE_DRAGON_ROOST = registerKey("fire_dragon_roost");
public static final ResourceKey<PlacedFeature> PLACED_ICE_DRAGON_ROOST = registerKey("ice_dragon_roost");
public static final ResourceKey<PlacedFeature> PLACED_LIGHTNING_DRAGON_ROOST = registerKey("lightning_dragon_roost");
public static final ResourceKey<PlacedFeature> PLACED_FIRE_DRAGON_CAVE = registerKey("fire_dragon_cave");
public static final ResourceKey<PlacedFeature> PLACED_ICE_DRAGON_CAVE = registerKey("ice_dragon_cave");
public static final ResourceKey<PlacedFeature> PLACED_LIGHTNING_DRAGON_CAVE = registerKey("lightning_dragon_cave");
public static final ResourceKey<PlacedFeature> PLACED_CYCLOPS_CAVE = registerKey("cyclops_cave");
public static final ResourceKey<PlacedFeature> PLACED_PIXIE_VILLAGE = registerKey("pixie_village");
public static final ResourceKey<PlacedFeature> PLACED_SIREN_ISLAND = registerKey("siren_island");
public static final ResourceKey<PlacedFeature> PLACED_HYDRA_CAVE = registerKey("hydra_cave");
public static final ResourceKey<PlacedFeature> PLACED_MYRMEX_HIVE_DESERT = registerKey("myrmex_hive_desert");
public static final ResourceKey<PlacedFeature> PLACED_MYRMEX_HIVE_JUNGLE = registerKey("myrmex_hive_jungle");
public static final ResourceKey<PlacedFeature> PLACED_SPAWN_DEATH_WORM = registerKey("spawn_death_worm");
public static final ResourceKey<PlacedFeature> PLACED_SPAWN_DRAGON_SKELETON_L = registerKey("spawn_dragon_skeleton_lightning");
public static final ResourceKey<PlacedFeature> PLACED_SPAWN_DRAGON_SKELETON_F = registerKey("spawn_dragon_skeleton_fire");
public static final ResourceKey<PlacedFeature> PLACED_SPAWN_DRAGON_SKELETON_I = registerKey("spawn_dragon_skeleton_ice");
public static final ResourceKey<PlacedFeature> PLACED_SPAWN_HIPPOCAMPUS = registerKey("spawn_hippocampus");
public static final ResourceKey<PlacedFeature> PLACED_SPAWN_SEA_SERPENT = registerKey("spawn_sea_serpent");
public static final ResourceKey<PlacedFeature> PLACED_SPAWN_STYMPHALIAN_BIRD = registerKey("spawn_stymphalian_bird");
public static final ResourceKey<PlacedFeature> PLACED_SPAWN_WANDERING_CYCLOPS = registerKey("spawn_wandering_cyclops");
public static final ResourceKey<PlacedFeature> PLACED_SILVER_ORE = registerKey("silver_ore");
public static final ResourceKey<PlacedFeature> PLACED_SAPPHIRE_ORE = registerKey("sapphire_ore");
public static final ResourceKey<PlacedFeature> PLACED_FIRE_LILY = registerKey("fire_lily");
public static final ResourceKey<PlacedFeature> PLACED_LIGHTNING_LILY = registerKey("lightning_lily");
public static final ResourceKey<PlacedFeature> PLACED_FROST_LILY = registerKey("frost_lily");

public static ResourceKey<PlacedFeature> registerKey(String name) {
return ResourceKey.create(Registry.PLACED_FEATURE_REGISTRY, new ResourceLocation(IceAndFire.MODID, name));
}

private static List<PlacementModifier> orePlacement(PlacementModifier pCountPlacement, PlacementModifier pHeightRange) {
return List.of(pCountPlacement, InSquarePlacement.spread(), pHeightRange, BiomeFilter.biome());
}

private static List<PlacementModifier> commonOrePlacement(int pCount, PlacementModifier pHeightRange) {
return orePlacement(CountPlacement.of(pCount), pHeightRange);
}

public static Map<ResourceLocation, PlacedFeature> gather(RegistryOps<JsonElement> registryOps) {
Map<ResourceLocation, PlacedFeature> entries = new HashMap<>();

// Referencing the previously gathered Configured Features causes their data to also appear in the Placed Feature .json
entries.put(PLACED_FIRE_DRAGON_ROOST.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.FIRE_DRAGON_ROOST), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_ICE_DRAGON_ROOST.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.ICE_DRAGON_ROOST), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_LIGHTNING_DRAGON_ROOST.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.LIGHTNING_DRAGON_ROOST), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_FIRE_DRAGON_CAVE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.FIRE_DRAGON_CAVE), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_ICE_DRAGON_CAVE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.ICE_DRAGON_CAVE), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_LIGHTNING_DRAGON_CAVE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.LIGHTNING_DRAGON_CAVE), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_CYCLOPS_CAVE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.CYCLOPS_CAVE), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_PIXIE_VILLAGE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.PIXIE_VILLAGE), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SIREN_ISLAND.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SIREN_ISLAND), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_HYDRA_CAVE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.HYDRA_CAVE), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_MYRMEX_HIVE_DESERT.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.MYRMEX_HIVE_DESERT), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_MYRMEX_HIVE_JUNGLE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.MYRMEX_HIVE_JUNGLE), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SPAWN_DEATH_WORM.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SPAWN_DEATH_WORM), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SPAWN_DRAGON_SKELETON_L.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SPAWN_DRAGON_SKELETON_L), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SPAWN_DRAGON_SKELETON_F.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SPAWN_DRAGON_SKELETON_F), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SPAWN_DRAGON_SKELETON_I.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SPAWN_DRAGON_SKELETON_I), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SPAWN_HIPPOCAMPUS.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SPAWN_HIPPOCAMPUS), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SPAWN_SEA_SERPENT.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SPAWN_SEA_SERPENT), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SPAWN_STYMPHALIAN_BIRD.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SPAWN_STYMPHALIAN_BIRD), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SPAWN_WANDERING_CYCLOPS.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SPAWN_WANDERING_CYCLOPS), List.of(CustomBiomeFilter.biome())));
entries.put(PLACED_SILVER_ORE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SILVER_ORE), commonOrePlacement(16, HeightRangePlacement.triangle(VerticalAnchor.absolute(-16), VerticalAnchor.absolute(112)))));
entries.put(PLACED_SAPPHIRE_ORE.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.SAPPHIRE_ORE), commonOrePlacement(4, HeightRangePlacement.triangle(VerticalAnchor.absolute(-16), VerticalAnchor.absolute(112)))));
entries.put(PLACED_FIRE_LILY.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.FIRE_LILY), List.of(RarityFilter.onAverageOnceEvery(32), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, CustomBiomeFilter.biome())));
entries.put(PLACED_LIGHTNING_LILY.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.FROST_LILY), List.of(RarityFilter.onAverageOnceEvery(32), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, CustomBiomeFilter.biome())));
entries.put(PLACED_FROST_LILY.location(), new PlacedFeature(registryOps.registry(Registry.CONFIGURED_FEATURE_REGISTRY).get().getOrCreateHolderOrThrow(IafConfiguredFeatures.LIGHTNING_LILY), List.of(RarityFilter.onAverageOnceEvery(32), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, CustomBiomeFilter.biome())));

return entries;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.resources.ResourceLocation;

public class IafTagRegistry {
public class IafTagRegistry { // FIXME :: Clean up
public static final ResourceLocation DRAGON_ARROWS = new ResourceLocation("iceandfire", "dragon_arrows");
public static final ResourceLocation MYRMEX_HARVESTABLES = new ResourceLocation("iceandfire", "myrmex_harvestables");
public static final ResourceLocation CHICKENS = new ResourceLocation("iceandfire", "chickens");
Expand Down

0 comments on commit 4f360c7

Please sign in to comment.