Skip to content

Commit

Permalink
Relic_Structure Addition
Browse files Browse the repository at this point in the history
  • Loading branch information
RS-gty committed Sep 8, 2024
1 parent a592713 commit 896724a
Show file tree
Hide file tree
Showing 32 changed files with 952 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// 1.20.4 2024-09-08T20:21:52.127306 Registries
// 1.20.4 2024-09-09T00:59:44.9842061 Registries
477b95f83609ea2dd8482f82a4f56c4042d89de8 data/enhancedstonebricks/worldgen/structure/mod_desert_relic_structure.json
d50999a6a95e11bb9cad8aec620930eb3070282c data/enhancedstonebricks/worldgen/structure/mod_end_relic_structure.json
5db3f100eafa46928bdd7e00df605a7253661164 data/enhancedstonebricks/worldgen/structure/mod_nether_relic_structure.json
50cceb240ed48390865fc3cb6fd93e31cd8ad610 data/enhancedstonebricks/worldgen/structure/mod_ocean_relic_structure.json
5db3f100eafa46928bdd7e00df605a7253661164 data/enhancedstonebricks/worldgen/structure/mod_soul_relic_structure.json
32e1b6be17e0534660d235c27886abc933c37ea5 data/enhancedstonebricks/worldgen/structure/mod_vitality_relic_structure.json
9bd304efc7a5d834dd1ee6fb1a2e76e8ca34c747 data/enhancedstonebricks/worldgen/structure_set/mod_desert_relic_structure.json
357a30f14d144bd9046eec07e8b6a5a3ebe3c148 data/enhancedstonebricks/worldgen/structure_set/mod_end_relic_structure.json
46d9684c8d5de3d70294ed4ec096d3020dcc4ebd data/enhancedstonebricks/worldgen/structure_set/mod_nether_relic_structure.json
a04a27f7b76f34c43ba6543542dfc86b78d310be data/enhancedstonebricks/worldgen/structure_set/mod_ocean_relic_structure.json
13e2453e7afa368c62bae5fdb61137b000b1f84e data/enhancedstonebricks/worldgen/structure_set/mod_soul_relic_structure.json
e121c9154b99f141d6e22eee9308f900b98e2e64 data/enhancedstonebricks/worldgen/structure_set/mod_vitality_relic_structure.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "enhancedstonebricks:mod_desert_relic_structure",
"biomes": "#forge:is_cold/end",
"spawn_overrides": {},
"step": "surface_structures"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "enhancedstonebricks:mod_desert_relic_structure",
"biomes": "#forge:is_dry/nether",
"spawn_overrides": {},
"step": "surface_structures"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "enhancedstonebricks:mod_desert_relic_structure",
"biomes": "#minecraft:has_structure/ruined_portal_ocean",
"spawn_overrides": {},
"step": "surface_structures"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "enhancedstonebricks:mod_desert_relic_structure",
"biomes": "#forge:is_dry/nether",
"spawn_overrides": {},
"step": "surface_structures"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "enhancedstonebricks:mod_desert_relic_structure",
"biomes": "#minecraft:is_forest",
"spawn_overrides": {},
"step": "surface_structures"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"placement": {
"type": "minecraft:random_spread",
"salt": 98715357,
"separation": 8,
"spacing": 28
},
"structures": [
{
"structure": "enhancedstonebricks:mod_end_relic_structure",
"weight": 1
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"placement": {
"type": "minecraft:random_spread",
"salt": 65423147,
"separation": 8,
"spacing": 28
},
"structures": [
{
"structure": "enhancedstonebricks:mod_nether_relic_structure",
"weight": 1
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"placement": {
"type": "minecraft:random_spread",
"salt": 15489653,
"separation": 8,
"spacing": 28
},
"structures": [
{
"structure": "enhancedstonebricks:mod_ocean_relic_structure",
"weight": 1
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"placement": {
"type": "minecraft:random_spread",
"salt": 78435694,
"separation": 8,
"spacing": 28
},
"structures": [
{
"structure": "enhancedstonebricks:mod_soul_relic_structure",
"weight": 1
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"placement": {
"type": "minecraft:random_spread",
"salt": 87364230,
"separation": 8,
"spacing": 28
},
"structures": [
{
"structure": "enhancedstonebricks:mod_vitality_relic_structure",
"weight": 1
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public class ModStructurePieceTypes {

public static final DeferredRegister<StructurePieceType> STRUCTURE_PIECE_TYPES = DeferredRegister.create(Registries.STRUCTURE_PIECE, ExampleMod.MODID);
public static final DeferredHolder<StructurePieceType, StructurePieceType> MOD_DESERT_RELIC_STRUCTURE_PIECE = registerPieceType("mod_desert_relic_structure_piece", ModDesertRelicStructurePieces.ModDesertRelicStructurePiece::new);
public static final DeferredHolder<StructurePieceType, StructurePieceType> MOD_END_RELIC_STRUCTURE_PIECE = registerPieceType("mod_end_relic_structure_piece", ModDesertRelicStructurePieces.ModDesertRelicStructurePiece::new);
public static final DeferredHolder<StructurePieceType, StructurePieceType> MOD_NETHER_RELIC_STRUCTURE_PIECE = registerPieceType("mod_nether_relic_structure_piece", ModDesertRelicStructurePieces.ModDesertRelicStructurePiece::new);
public static final DeferredHolder<StructurePieceType, StructurePieceType> MOD_OCEAN_RELIC_STRUCTURE_PIECE = registerPieceType("mod_ocean_relic_structure_piece", ModDesertRelicStructurePieces.ModDesertRelicStructurePiece::new);
public static final DeferredHolder<StructurePieceType, StructurePieceType> MOD_SOUL_RELIC_STRUCTURE_PIECE = registerPieceType("mod_soul_relic_structure_piece", ModDesertRelicStructurePieces.ModDesertRelicStructurePiece::new);
public static final DeferredHolder<StructurePieceType, StructurePieceType> MOD_VITALITY_RELIC_STRUCTURE_PIECE = registerPieceType("mod_vitality_relic_structure_piece", ModDesertRelicStructurePieces.ModDesertRelicStructurePiece::new);
private static DeferredHolder<StructurePieceType, StructurePieceType> registerPieceType(String name, StructurePieceType.StructureTemplateType structurePieceType) {
return STRUCTURE_PIECE_TYPES.register(name.toLowerCase(Locale.ROOT), () -> structurePieceType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,43 @@
public class ModStructureSets {
public static final ResourceKey<StructureSet> DESERT_RELIC_STRUCTURE_SET = register("mod_desert_relic_structure");

public static final ResourceKey<StructureSet> END_RELIC_STRUCTURE_SET = register("mod_end_relic_structure");

public static final ResourceKey<StructureSet> NETHER_RELIC_STRUCTURE_SET = register("mod_nether_relic_structure");

public static final ResourceKey<StructureSet> OCEAN_RELIC_STRUCTURE_SET = register("mod_ocean_relic_structure");

public static final ResourceKey<StructureSet> SOUL_RELIC_STRUCTURE_SET = register("mod_soul_relic_structure");

public static final ResourceKey<StructureSet> VITALITY_RELIC_STRUCTURE_SET = register("mod_vitality_relic_structure");

public static void bootstap(BootstapContext<StructureSet> pContext) {
HolderGetter<Structure> holdergetter = pContext.lookup(Registries.STRUCTURE);

pContext.register(
ModStructureSets.DESERT_RELIC_STRUCTURE_SET,
new StructureSet(holdergetter.getOrThrow(ModStructures.MOD_DESERT_RELIC_STRUCTURE), new RandomSpreadStructurePlacement(28, 8, RandomSpreadType.LINEAR, 14357619))
);
pContext.register(
ModStructureSets.END_RELIC_STRUCTURE_SET,
new StructureSet(holdergetter.getOrThrow(ModStructures.MOD_END_RELIC_STRUCTURE), new RandomSpreadStructurePlacement(28, 8, RandomSpreadType.LINEAR, 98715357))
);
pContext.register(
ModStructureSets.NETHER_RELIC_STRUCTURE_SET,
new StructureSet(holdergetter.getOrThrow(ModStructures.MOD_NETHER_RELIC_STRUCTURE), new RandomSpreadStructurePlacement(28, 8, RandomSpreadType.LINEAR, 65423147))
);
pContext.register(
ModStructureSets.OCEAN_RELIC_STRUCTURE_SET,
new StructureSet(holdergetter.getOrThrow(ModStructures.MOD_OCEAN_RELIC_STRUCTURE), new RandomSpreadStructurePlacement(28, 8, RandomSpreadType.LINEAR, 15489653))
);
pContext.register(
ModStructureSets.SOUL_RELIC_STRUCTURE_SET,
new StructureSet(holdergetter.getOrThrow(ModStructures.MOD_SOUL_RELIC_STRUCTURE), new RandomSpreadStructurePlacement(28, 8, RandomSpreadType.LINEAR, 78435694))
);
pContext.register(
ModStructureSets.VITALITY_RELIC_STRUCTURE_SET,
new StructureSet(holdergetter.getOrThrow(ModStructures.MOD_VITALITY_RELIC_STRUCTURE), new RandomSpreadStructurePlacement(28, 8, RandomSpreadType.LINEAR, 87364230))
);
}

private static ResourceKey<StructureSet> register(String pName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.rswfb.enhancedstonebricks.world.structure.structure.ModDesertRelicStructure;
import net.rswfb.enhancedstonebricks.world.structure.structure.*;

import java.util.function.Supplier;

Expand All @@ -16,6 +16,16 @@ public class ModStructureType<S extends Structure> {

public static final DeferredHolder<StructureType<?>, StructureType<ModDesertRelicStructure>> MOD_DESERT_RELIC_STRUCTURE = registerType("mod_desert_relic_structure", () -> () -> ModDesertRelicStructure.CODEC);

public static final DeferredHolder<StructureType<?>, StructureType<ModEndRelicStructure>> MOD_END_RELIC_STRUCTURE = registerType("mod_end_relic_structure", () -> () -> ModEndRelicStructure.CODEC);

public static final DeferredHolder<StructureType<?>, StructureType<ModNetherRelicStructure>> MOD_NETHER_RELIC_STRUCTURE = registerType("mod_nether_relic_structure", () -> () -> ModNetherRelicStructure.CODEC);

public static final DeferredHolder<StructureType<?>, StructureType<ModOceanRelicStructure>> MOD_OCEAN_RELIC_STRUCTURE = registerType("mod_ocean_relic_structure", () -> () -> ModOceanRelicStructure.CODEC);

public static final DeferredHolder<StructureType<?>, StructureType<ModSoulRelicStructure>> MOD_SOUL_RELIC_STRUCTURE = registerType("mod_soul_relic_structure", () -> () -> ModSoulRelicStructure.CODEC);

public static final DeferredHolder<StructureType<?>, StructureType<ModVitalityRelicStructure>> MOD_VITALITY_RELIC_STRUCTURE = registerType("mod_vitality_relic_structure", () -> () -> ModVitalityRelicStructure.CODEC);

private static <P extends Structure> DeferredHolder<StructureType<?>, StructureType<P>> registerType(String name, Supplier<StructureType<P>> factory) {
return STRUCTURE_TYPES.register(name, factory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.GenerationStep;
Expand Down Expand Up @@ -36,6 +37,11 @@ private static Structure.StructureSettings structure(HolderSet<Biome > pBiomes,


public static final ResourceKey<Structure> MOD_DESERT_RELIC_STRUCTURE = registerKey("mod_desert_relic_structure");
public static final ResourceKey<Structure> MOD_END_RELIC_STRUCTURE = registerKey("mod_end_relic_structure");
public static final ResourceKey<Structure> MOD_NETHER_RELIC_STRUCTURE = registerKey("mod_nether_relic_structure");
public static final ResourceKey<Structure> MOD_OCEAN_RELIC_STRUCTURE = registerKey("mod_ocean_relic_structure");
public static final ResourceKey<Structure> MOD_SOUL_RELIC_STRUCTURE = registerKey("mod_soul_relic_structure");
public static final ResourceKey<Structure> MOD_VITALITY_RELIC_STRUCTURE = registerKey("mod_vitality_relic_structure");

public static ResourceKey<Structure> registerKey(String name) {
return ResourceKey.create(Registries.STRUCTURE, new ResourceLocation(ExampleMod.MODID,name));
Expand All @@ -48,6 +54,26 @@ public static void bootstrap(BootstapContext<Structure> context) {
ModStructures.MOD_DESERT_RELIC_STRUCTURE,
new ModDesertRelicStructure(structure(biomeHolderGetter.getOrThrow(Tags.Biomes.IS_DESERT), TerrainAdjustment.NONE))
);
context.register(
ModStructures.MOD_END_RELIC_STRUCTURE,
new ModDesertRelicStructure(structure(biomeHolderGetter.getOrThrow(Tags.Biomes.IS_COLD_END), TerrainAdjustment.NONE))
);
context.register(
ModStructures.MOD_NETHER_RELIC_STRUCTURE,
new ModDesertRelicStructure(structure(biomeHolderGetter.getOrThrow(Tags.Biomes.IS_DRY_NETHER), TerrainAdjustment.NONE))
);
context.register(
ModStructures.MOD_OCEAN_RELIC_STRUCTURE,
new ModDesertRelicStructure(structure(biomeHolderGetter.getOrThrow(BiomeTags.HAS_RUINED_PORTAL_OCEAN), TerrainAdjustment.NONE))
);
context.register(
ModStructures.MOD_SOUL_RELIC_STRUCTURE,
new ModDesertRelicStructure(structure(biomeHolderGetter.getOrThrow(Tags.Biomes.IS_DRY_NETHER), TerrainAdjustment.NONE))
);
context.register(
ModStructures.MOD_VITALITY_RELIC_STRUCTURE,
new ModDesertRelicStructure(structure(biomeHolderGetter.getOrThrow(BiomeTags.IS_FOREST), TerrainAdjustment.NONE))
);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package net.rswfb.enhancedstonebricks.world.structure.piece;

import com.google.common.collect.ImmutableMap;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructurePieceAccessor;
import net.minecraft.world.level.levelgen.structure.TemplateStructurePiece;
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.rswfb.enhancedstonebricks.ExampleMod;
import net.rswfb.enhancedstonebricks.world.structure.*;

import java.util.Map;

public class ModEndRelicStructurePieces {
static final ResourceLocation STRUCTURE_LOCATION_MOD_END_RELIC_STRUCTURE = new ResourceLocation(ExampleMod.MODID,"mod_end_relic_structure");
static final Map<ResourceLocation, BlockPos> PIVOTS = ImmutableMap.of(
STRUCTURE_LOCATION_MOD_END_RELIC_STRUCTURE, new BlockPos(4, 0, 4)
);
static final Map<ResourceLocation, BlockPos> OFFSETS = ImmutableMap.of(
STRUCTURE_LOCATION_MOD_END_RELIC_STRUCTURE, BlockPos.ZERO
);

public static void addPieces(
StructureTemplateManager pStructureTemplateManager, BlockPos pStartPos, Rotation pRotation, StructurePieceAccessor pPieces, RandomSource pRandom
) {
pPieces.addPiece(new ModEndRelicStructurePieces.ModEndRelicStructurePiece(pStructureTemplateManager, STRUCTURE_LOCATION_MOD_END_RELIC_STRUCTURE, pStartPos, pRotation, 0));
}

public static class ModEndRelicStructurePiece extends TemplateStructurePiece {

public ModEndRelicStructurePiece(StructureTemplateManager pStructureTemplateManager, ResourceLocation pLocation, BlockPos pStartPos, Rotation pRotation, int pDown) {
super(ModStructurePieceTypes.MOD_END_RELIC_STRUCTURE_PIECE.get(), 0, pStructureTemplateManager, pLocation, pLocation.toString(),
makeSettings(pRotation, pLocation),
makePosition(pLocation, pStartPos, pDown)
);
}


public ModEndRelicStructurePiece(StructureTemplateManager pStructureTemplateManager, CompoundTag pTag) {
super(ModStructurePieceTypes.MOD_END_RELIC_STRUCTURE_PIECE.get(), pTag, pStructureTemplateManager, resourceLocation -> makeSettings(Rotation.valueOf(pTag.getString("Rot")), resourceLocation));
}

private static StructurePlaceSettings makeSettings(Rotation pRotation, ResourceLocation pLocation) {
return new StructurePlaceSettings()
.setRotation(pRotation)
.setMirror(Mirror.NONE)
.setRotationPivot(ModEndRelicStructurePieces.PIVOTS.get(pLocation))
.addProcessor(BlockIgnoreProcessor.STRUCTURE_BLOCK);
}

private static BlockPos makePosition(ResourceLocation pLocation, BlockPos pPos, int pDown) {
return pPos.offset(ModEndRelicStructurePieces.OFFSETS.get(pLocation)).below(pDown);
}
@Override
protected void addAdditionalSaveData(StructurePieceSerializationContext pContext, CompoundTag pTag) {
super.addAdditionalSaveData(pContext, pTag);
pTag.putString("Rot", this.placeSettings.getRotation().name());
}

@Override
protected void handleDataMarker(String pName, BlockPos pPos, ServerLevelAccessor pLevel, RandomSource pRandom, BoundingBox pBox) {
if ("chest".equals(pName)) {
pLevel.setBlock(pPos, Blocks.AIR.defaultBlockState(), 3);
BlockEntity blockentity = pLevel.getBlockEntity(pPos.below());
if (blockentity instanceof ChestBlockEntity) {
((ChestBlockEntity)blockentity).setLootTable(BuiltInLootTables.IGLOO_CHEST, pRandom.nextLong());
}
}
}

@Override
public void postProcess(
WorldGenLevel pLevel,
StructureManager pStructureManager,
ChunkGenerator pGenerator,
RandomSource pRandom,
BoundingBox pBox,
ChunkPos pChunkPos,
BlockPos pPos
) {
ResourceLocation resourceLocation = new ResourceLocation(this.templateName);
StructurePlaceSettings structureplacesettings = makeSettings(this.placeSettings.getRotation(), resourceLocation);
BlockPos blockpos = ModEndRelicStructurePieces.OFFSETS.get(resourceLocation);
BlockPos blockpos1 = this.templatePosition
.offset(StructureTemplate.calculateRelativePosition(structureplacesettings, new BlockPos(3 - blockpos.getX(), 0, -blockpos.getZ())));
int i = pLevel.getHeight(Heightmap.Types.WORLD_SURFACE_WG, blockpos1.getX(), blockpos1.getZ());
BlockPos blockpos2 = this.templatePosition;
this.templatePosition = this.templatePosition.offset(0, i - 90 - 1, 0);
super.postProcess(pLevel, pStructureManager, pGenerator, pRandom, pBox, pChunkPos, pPos);
this.templatePosition = blockpos2;
}
}
}
Loading

0 comments on commit 896724a

Please sign in to comment.