Skip to content

Commit

Permalink
feat: Register wild and village waystones as POIs #753
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 24, 2024
1 parent bf38684 commit 65b4711
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import net.blay09.mods.balm.api.world.BalmWorldGen;
import net.blay09.mods.balm.api.world.BiomePredicate;
import net.blay09.mods.waystones.Waystones;
import net.blay09.mods.waystones.api.WaystoneOrigin;
import net.blay09.mods.waystones.block.ModBlocks;
import net.blay09.mods.waystones.block.WaystoneBlock;
import net.blay09.mods.waystones.config.WaystonesConfig;
import net.blay09.mods.waystones.config.WaystonesConfigData;
import net.blay09.mods.waystones.config.WorldGenStyle;
Expand All @@ -21,7 +23,9 @@
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.placement.PlacementModifierType;
Expand All @@ -32,6 +36,8 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class ModWorldGen {
private static final ResourceLocation waystone = ResourceLocation.fromNamespaceAndPath("waystones", "waystone");
Expand Down Expand Up @@ -74,10 +80,25 @@ public static void initialize(BalmWorldGen worldGen) {
GenerationStep.Decoration.VEGETAL_DECORATION,
getWaystoneFeature(WorldGenStyle.DEFAULT));

worldGen.registerPoiType(id("wild_waystone"), () -> new PoiType(gatherWaystonesOfOrigin(WaystoneOrigin.WILDERNESS), 1, 1));
worldGen.registerPoiType(id("village_waystone"), () -> new PoiType(gatherWaystonesOfOrigin(WaystoneOrigin.VILLAGE), 1, 1));

Balm.getEvents().onEvent(ServerStartedEvent.class, event -> setupDynamicRegistries(event.getServer().registryAccess()));
Balm.getEvents().onEvent(ServerReloadedEvent.class, event -> setupDynamicRegistries(event.getServer().registryAccess()));
}

private static Set<BlockState> gatherWaystonesOfOrigin(WaystoneOrigin origin) {
final var sourceBlocks = List.of(ModBlocks.waystone,
ModBlocks.sandyWaystone,
ModBlocks.mossyWaystone,
ModBlocks.blackstoneWaystone,
ModBlocks.endStoneWaystone);
return sourceBlocks.stream()
.flatMap(it -> it.getStateDefinition().getPossibleStates().stream())
.filter(it -> it.getValue(WaystoneBlock.ORIGIN) == origin)
.collect(Collectors.toSet());
}

private static BiomePredicate matchesTag(TagKey<Biome> tag) {
return (resourceLocation, biome) -> biome.is(tag);
}
Expand Down

0 comments on commit 65b4711

Please sign in to comment.