Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallen Trunk #2321

Merged
merged 63 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7ee34f9
Register FallenTrunkStructure
Sleepy-Horse Oct 28, 2024
f6740ad
Generate FallenTrunkStructure; place sponge as a placeholder
Sleepy-Horse Oct 31, 2024
3612d20
Spawn trunk
Sleepy-Horse Oct 31, 2024
a4ba5a8
Generate log trunk with moss patches, chests, a spawner, and holes
Sleepy-Horse Nov 2, 2024
c5a6584
Make hole's shape a sphere
Sleepy-Horse Nov 6, 2024
7d425c0
Add the small trunk
Sleepy-Horse Nov 6, 2024
47ea25b
Change hole generation algorithm
Sleepy-Horse Nov 15, 2024
57d16d7
Add eroded ends to small trunk; rework the generation of trunk
Sleepy-Horse Nov 22, 2024
60a567a
Merge branch '1.21.1' into no-build/1.21.1-fallen-trunk
Sleepy-Horse Nov 23, 2024
092b8fc
Run datagen
Sleepy-Horse Nov 25, 2024
fc94679
Stop placing spawner outside the chunk
Sleepy-Horse Nov 25, 2024
5065e9b
Fix connection of moss patches
Sleepy-Horse Nov 25, 2024
75f6fa7
Fix bounding box of the FallenTrunkStructure
Sleepy-Horse Nov 25, 2024
35aa326
Replace flowers during the generation of FallenTrunkPiece
Sleepy-Horse Nov 25, 2024
cdcd602
Add mounds(prototype); don't spawn fallen trunks in incorrect biomes;…
Sleepy-Horse Dec 9, 2024
c457d0e
Fix a bug, where eroded end wasn't generate properly; remove warnings
Sleepy-Horse Dec 10, 2024
0cc30ac
Don't create hollow hill functions for every block for fallen trunk's…
Sleepy-Horse Dec 13, 2024
e53dc6b
Make mounds depend on the radius of the trunk
Sleepy-Horse Dec 13, 2024
4db34a0
Reduce the height of mounds
Sleepy-Horse Dec 18, 2024
e8eebdf
Rename variable d for better readability
Sleepy-Horse Dec 18, 2024
ab0f273
Remove magic number
Sleepy-Horse Dec 18, 2024
4b1e35e
Fix a bug where a mound could be too close to the ends of its trunk.
Sleepy-Horse Dec 18, 2024
1f0ec0a
Generate several mounds
Sleepy-Horse Dec 18, 2024
f165918
Randomize side of the mounds correctly
Sleepy-Horse Dec 19, 2024
88e53e0
Increase amount of mounds for big trunks
Sleepy-Horse Dec 19, 2024
8df01e5
Comment debugging printHole
Sleepy-Horse Dec 19, 2024
e00983b
Comment debugging blockEdges
Sleepy-Horse Dec 19, 2024
7313b41
Refactor moundApex to a constant
Sleepy-Horse Dec 19, 2024
ceb15e7
Remove blockEdges form FallenTrunkPiece
Sleepy-Horse Dec 19, 2024
0e4c903
Use random.nextBoolean() for trunk holes
Sleepy-Horse Dec 20, 2024
d3e59c0
Reduce copy-paste
Sleepy-Horse Dec 20, 2024
334a0f1
Send blockPos in logger report
Sleepy-Horse Dec 22, 2024
79b9963
Remove debug function placeBlockEdges
Sleepy-Horse Dec 23, 2024
23a51cc
Change fields from private to protected
Sleepy-Horse Dec 23, 2024
96d8079
Make the hole a field in FallenTrunkPiece; remove magic number in Hol…
Sleepy-Horse Dec 23, 2024
82b2298
Avoid generation of big mounds next to trunk holes
Sleepy-Horse Dec 28, 2024
7549c4f
Add support for different trunk rotations in mound generation
Sleepy-Horse Dec 29, 2024
e5e4465
Add zOffset
Sleepy-Horse Dec 29, 2024
4c32b8c
Add orientation support correctly
Sleepy-Horse Dec 29, 2024
228f724
Call random.next() constant amount of times in placeLog()
Sleepy-Horse Dec 29, 2024
78026dc
Fix a double rotation bug
Sleepy-Horse Dec 29, 2024
7285179
Randomize size of mounds
Sleepy-Horse Dec 29, 2024
afa6989
Merge branch '1.21.1' into no-build/1.21.1-fallen-trunk
Sleepy-Horse Dec 29, 2024
5266a88
Remove unused import
Sleepy-Horse Dec 29, 2024
d73afdd
Run datagen
Sleepy-Horse Dec 29, 2024
839cdf6
Remove debug line
Sleepy-Horse Dec 29, 2024
89a9fd7
Use Objects.requireNonNull
Sleepy-Horse Dec 30, 2024
3a56ae4
Update error message to direct users to github issues
Sleepy-Horse Dec 30, 2024
3268e3d
Avoid a double compute
Sleepy-Horse Dec 30, 2024
9bbb842
Remove System.out.println
Sleepy-Horse Dec 30, 2024
67dee4f
Add a new loot table for FallenTrunkStructure to exclude magic tree s…
Sleepy-Horse Dec 31, 2024
ffe0409
Randomize chests positions in FallenTrunkPiece
Sleepy-Horse Dec 31, 2024
8d8ba28
Merge remote-tracking branch 'origin/no-build/1.21.1-fallen-trunk' in…
Sleepy-Horse Dec 31, 2024
02449d1
Use TWILIGHT_OAK_CHEST instead of vanilla one
Sleepy-Horse Dec 31, 2024
7d85bd4
Create chests and a spawner in FallenTrunkPiece with 50% chance
Sleepy-Horse Dec 31, 2024
d6ad37a
Remove double chest from FallenTrunkPiece
Sleepy-Horse Dec 31, 2024
53c42ab
Randomize monster in spawner; make SPAWNER_MONSTERS a protected stati…
Sleepy-Horse Dec 31, 2024
b3338ec
Simplify possibleChestsOffsets generation
Sleepy-Horse Dec 31, 2024
27d2fd9
Return 0 when we calculate mound contribution inside the trunk
Sleepy-Horse Jan 1, 2025
f2e2f1a
Run datagen
Sleepy-Horse Jan 1, 2025
6ffaa29
Fix map-save bug for terraforming piece
Drullkus Jan 3, 2025
854fa6e
Merge branch '1.21.1' into no-build/1.21.1-fallen-trunk
Sleepy-Horse Jan 4, 2025
0116338
Run datagen
Sleepy-Horse Jan 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Register FallenTrunkStructure
  • Loading branch information
Sleepy-Horse committed Oct 28, 2024
commit 7ee34f912bc7e6d968779e627d44e1b72ab3fa74

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/main/java/twilightforest/init/TFStructureTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TFStructureTypes {
public static final DeferredRegister<StructureType<?>> STRUCTURE_TYPES = DeferredRegister.create(Registries.STRUCTURE_TYPE, TwilightForestMod.ID);

public static final DeferredHolder<StructureType<?>, StructureType<ProgressionWrappedStructure>> PROGRESSION_WRAPPED = registerType("progression", () -> () -> ProgressionWrappedStructure.CODEC);
public static final DeferredHolder<StructureType<?>, StructureType<FallenTrunkStructure>> FALLEN_TRUNK = registerType("fallen_trunk", () -> () -> FallenTrunkStructure.CODEC);
public static final DeferredHolder<StructureType<?>, StructureType<HollowTreeStructure>> HOLLOW_TREE = registerType("hollow_tree", () -> () -> HollowTreeStructure.CODEC);
public static final DeferredHolder<StructureType<?>, StructureType<HedgeMazeStructure>> HEDGE_MAZE = registerType("hedge_maze", () -> () -> HedgeMazeStructure.CODEC);
public static final DeferredHolder<StructureType<?>, StructureType<HollowHillStructure>> HOLLOW_HILL = registerType("hollow_hill", () -> () -> HollowHillStructure.CODEC);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/twilightforest/init/TFStructures.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class TFStructures {
public static final ResourceKey<Structure> GIANT_HOUSE = registerKey("giant_house");
public static final ResourceKey<Structure> FINAL_CASTLE = registerKey("final_castle");

public static final ResourceKey<Structure> FALLEN_TRUNK = registerKey("fallen_trunk");
public static final ResourceKey<Structure> HOLLOW_TREE = registerKey("hollow_tree");
public static final ResourceKey<Structure> SWAMP_HOLLOW_TREE = registerKey("swamp_hollow_tree");
public static final ResourceKey<Structure> MUSHROOM_TOWER = registerKey("mushroom_tower");
Expand All @@ -41,6 +42,7 @@ public static ResourceKey<Structure> registerKey(String name) {
}

public static void bootstrap(BootstrapContext<Structure> context) {
context.register(FALLEN_TRUNK, FallenTrunkStructure.buildStructureConfig(context.lookup(Registries.BIOME).getOrThrow(BiomeTagGenerator.VALID_HOLLOW_TREE_BIOMES)));
context.register(HOLLOW_TREE, HollowTreeStructure.buildStructureConfig(false, context.lookup(Registries.BIOME).getOrThrow(BiomeTagGenerator.VALID_HOLLOW_TREE_BIOMES)));
context.register(SWAMP_HOLLOW_TREE, HollowTreeStructure.buildStructureConfig(true, HolderSet.direct(context.lookup(Registries.BIOME).getOrThrow(TFBiomes.SWAMP))));
context.register(HEDGE_MAZE, HedgeMazeStructure.buildStructureConfig(context));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package twilightforest.world.components.structures.type;

import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.RegistryFixedCodec;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.random.WeightedRandomList;
import net.minecraft.util.valueproviders.IntProvider;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
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.feature.stateproviders.BlockStateProvider;
import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.structure.StructureSpawnOverride;
import net.minecraft.world.level.levelgen.structure.StructureType;
import net.minecraft.world.level.levelgen.structure.TerrainAdjustment;
import net.minecraft.world.level.storage.loot.LootTable;
import twilightforest.init.TFBlocks;
import twilightforest.init.TFEntities;
import twilightforest.init.TFStructureTypes;
import twilightforest.loot.TFLootTables;

import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Collectors;

public class FallenTrunkStructure extends Structure {
public static final MapCodec<FallenTrunkStructure> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
Structure.settingsCodec(instance),
IntProvider.codec(8, 32).fieldOf("length").forGetter(s -> s.length),
BlockStateProvider.CODEC.fieldOf("log").forGetter(s -> s.log),
ResourceKey.codec(Registries.LOOT_TABLE).fieldOf("chest_loot_table").forGetter(s -> s.chestLootTable),
RegistryFixedCodec.create(Registries.ENTITY_TYPE).fieldOf("spawner_monster").forGetter(s -> s.spawnerMonster)
).apply(instance, FallenTrunkStructure::new));

private final IntProvider length;
private final BlockStateProvider log;
private final ResourceKey<LootTable> chestLootTable;
private final Holder<EntityType<?>> spawnerMonster;

protected FallenTrunkStructure(StructureSettings settings, IntProvider length, BlockStateProvider log, ResourceKey<LootTable> chestLootTable, Holder<EntityType<?>> spawnerMonster) {
super(settings);
this.length = length;
this.log = log;
this.chestLootTable = chestLootTable;
this.spawnerMonster = spawnerMonster;
}

@Override
public Optional<GenerationStub> findGenerationPoint(GenerationContext context) {
return onTopOfChunkCenter(context, Heightmap.Types.WORLD_SURFACE_WG, p_227598_ -> this.findGenerationPoint(context));
}

@Override
public StructureType<?> type() {
return TFStructureTypes.FALLEN_TRUNK.get();
}

public static FallenTrunkStructure buildStructureConfig(HolderSet<Biome> biomes) {
return new FallenTrunkStructure(
new Structure.StructureSettings(
biomes,
Arrays.stream(MobCategory.values()).collect(Collectors.toMap(category -> category, category -> new StructureSpawnOverride(StructureSpawnOverride.BoundingBoxType.STRUCTURE, WeightedRandomList.create()))), // Landmarks have Controlled Mob spawning
GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE
),
UniformInt.of(10, 20), BlockStateProvider.simple(TFBlocks.TWILIGHT_OAK_LOG.get()), TFLootTables.TREE_CACHE, TFEntities.SWARM_SPIDER
);
}
}