Skip to content

Commit

Permalink
Structure Datagen Start (I am very proud of myself for this)
Browse files Browse the repository at this point in the history
  • Loading branch information
JT122406 committed Nov 28, 2023
1 parent d200e61 commit 9dd410c
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "minecraft:jigsaw",
"biomes": "#generations_structures:has_structure/loot_balloon",
"max_distance_from_center": 80,
"size": 1,
"spawn_overrides": {},
"start_height": {
"above_bottom": 150
},
"start_pool": "generations_structures:loot_balloon/beast_balloon",
"step": "surface_structures",
"use_expansion_hack": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "minecraft:jigsaw",
"biomes": "#generations_structures:has_structure/loot_balloon",
"max_distance_from_center": 80,
"size": 1,
"spawn_overrides": {},
"start_height": {
"above_bottom": 150
},
"start_pool": "generations_structures:loot_balloon/great_balloon",
"step": "surface_structures",
"use_expansion_hack": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "minecraft:jigsaw",
"biomes": "#generations_structures:has_structure/loot_balloon",
"max_distance_from_center": 80,
"size": 1,
"spawn_overrides": {},
"start_height": {
"above_bottom": 150
},
"start_pool": "generations_structures:loot_balloon/master_balloon",
"step": "surface_structures",
"use_expansion_hack": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "minecraft:jigsaw",
"biomes": "#generations_structures:has_structure/loot_balloon",
"max_distance_from_center": 80,
"size": 1,
"spawn_overrides": {},
"start_height": {
"above_bottom": 150
},
"start_pool": "generations_structures:loot_balloon/meowth_balloon",
"step": "surface_structures",
"use_expansion_hack": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "minecraft:jigsaw",
"biomes": "#generations_structures:has_structure/loot_balloon",
"max_distance_from_center": 80,
"size": 1,
"spawn_overrides": {},
"start_height": {
"above_bottom": 150
},
"start_pool": "generations_structures:loot_balloon/normal_balloon",
"step": "surface_structures",
"use_expansion_hack": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "minecraft:jigsaw",
"biomes": "#generations_structures:has_structure/loot_balloon",
"max_distance_from_center": 80,
"size": 1,
"spawn_overrides": {},
"start_height": {
"above_bottom": 150
},
"start_pool": "generations_structures:loot_balloon/ultra_balloon",
"step": "surface_structures",
"use_expansion_hack": false
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,70 @@
package generations.gg.generations.structures.generationsstructures.structures;

import generations.gg.generations.structures.generationsstructures.tags.GenerationsBiomeTags;
import generations.gg.generations.structures.generationsstructures.worldgen.template_pool.GenerationsTemplatePools;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.heightproviders.ConstantHeight;
import net.minecraft.world.level.levelgen.heightproviders.HeightProvider;
import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.structure.TerrainAdjustment;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
import net.minecraft.world.level.levelgen.structure.structures.JigsawStructure;

import java.util.Map;
import java.util.Optional;

public class GenerationsStructureSettings {

public static void bootstrap(BootstapContext<Structure> context) {
HolderGetter<Biome> biomeHolderGetter = context.lookup(Registries.BIOME);
HolderGetter<StructureTemplatePool> poolHolderGetter = context.lookup(Registries.TEMPLATE_POOL);

registerJigsaw(context, GenerationsStructuresKeys.BEAST_BALLOON, balloonJigsawStructure(poolHolderGetter.getOrThrow(GenerationsTemplatePools.BEAST_BALLOON), biomeHolderGetter.getOrThrow(GenerationsBiomeTags.HAS_LOOT_BALLOON)));
registerJigsaw(context, GenerationsStructuresKeys.GREAT_BALLOON, balloonJigsawStructure(poolHolderGetter.getOrThrow(GenerationsTemplatePools.GREAT_BALLOON), biomeHolderGetter.getOrThrow(GenerationsBiomeTags.HAS_LOOT_BALLOON)));
registerJigsaw(context, GenerationsStructuresKeys.MASTER_BALLOON, balloonJigsawStructure(poolHolderGetter.getOrThrow(GenerationsTemplatePools.MASTER_BALLOON), biomeHolderGetter.getOrThrow(GenerationsBiomeTags.HAS_LOOT_BALLOON)));
registerJigsaw(context, GenerationsStructuresKeys.NORMAL_BALLOON, balloonJigsawStructure(poolHolderGetter.getOrThrow(GenerationsTemplatePools.NORMAL_BALLOON), biomeHolderGetter.getOrThrow(GenerationsBiomeTags.HAS_LOOT_BALLOON)));
registerJigsaw(context, GenerationsStructuresKeys.ULTRA_BALLOON, balloonJigsawStructure(poolHolderGetter.getOrThrow(GenerationsTemplatePools.ULTRA_BALLOON), biomeHolderGetter.getOrThrow(GenerationsBiomeTags.HAS_LOOT_BALLOON)));
registerJigsaw(context, GenerationsStructuresKeys.MEOWTH_BALLOON, balloonJigsawStructure(poolHolderGetter.getOrThrow(GenerationsTemplatePools.MEOWTH_BALLOON), biomeHolderGetter.getOrThrow(GenerationsBiomeTags.HAS_LOOT_BALLOON)));
}

private static void registerJigsaw(BootstapContext<Structure> context, ResourceKey<Structure> structureResourceKey, Structure structure){
context.register(structureResourceKey, structure);
}

private static JigsawStructure createJigsaw(Structure.StructureSettings settings,
Holder<StructureTemplatePool> startPool,
Optional<ResourceLocation> startJigsawName,
int maxDepth,
HeightProvider startHeight,
boolean useExpansionHack,
Optional<Heightmap.Types> projectStartToHeightmap,
int maxDistanceToCenter){
return new JigsawStructure(settings, startPool, startJigsawName, maxDepth, startHeight, useExpansionHack, projectStartToHeightmap, maxDistanceToCenter);
}

private static void registerJigsaw(BootstapContext<Structure> context, ResourceKey<Structure> structure, Structure.StructureSettings settings, ResourceKey<StructureTemplatePool> pool, int min, int mac){
context.register(structure, new JigsawStructure(settings, context.lookup(Registries.TEMPLATE_POOL).getOrThrow(pool)));
private static JigsawStructure balloonJigsawStructure(Holder<StructureTemplatePool> poolHolderGetter, HolderSet<Biome> biomeHolderGetter){
return new JigsawStructure(new Structure.StructureSettings(
biomeHolderGetter,
Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE
),
poolHolderGetter,
Optional.empty(),
1,
ConstantHeight.of(VerticalAnchor.aboveBottom(150)),
false,
Optional.empty(),
80);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public GenerationsStructuresForge() {
GenerationsStructures.init(integration);
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
bus.addListener(this::commonSetup);
bus.addListener(this::aboutToStartEvent);

//bus.addListener(this::aboutToStartEvent);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public static void gatherData(GatherDataEvent event) {
}

private static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
.add(Registries.TEMPLATE_POOL, GenerationsTemplatePools::bootstrap);
//.add(Registries.STRUCTURE, GenerationsStructureSettings::bootstrap)
//.add(Registries.STRUCTURE_SET, GenerationsStructureSets::bootstrap);
.add(Registries.TEMPLATE_POOL, GenerationsTemplatePools::bootstrap)
.add(Registries.STRUCTURE, GenerationsStructureSettings::bootstrap)
.add(Registries.STRUCTURE_SET, GenerationsStructureSets::bootstrap);

private static class GenerationsStructuresBiomeTagsProvider extends BiomeTagsProvider {

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ maven_group=generations.gg.generations.structures.generationsstructures
fabric_loader_version=0.14.25
fabric_api_version=0.91.0

forge_version=47.2.5
forge_version=47.2.8

parchment=2023.09.03

Expand Down

0 comments on commit 9dd410c

Please sign in to comment.