Skip to content

Commit

Permalink
Customize pokeshops and marts for desert biome
Browse files Browse the repository at this point in the history
  • Loading branch information
JT122406 committed Feb 5, 2024
1 parent 1d3ceb4 commit 6eb5c3b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"processors": [
{
"processor_type": "generations_structures:pokecenter_processor"
},
{
"processor_type": "generations_structures:pokecenter_mart_desert_processor"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import com.google.common.collect.ImmutableList;
import generations.gg.generations.structures.generationsstructures.GenerationsStructures;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.pokevillage.PokeCenterMartDesertProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.fiery.FieryShrineProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.fiery.FieryShrineRandomizerProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.frozen.FrozenShrineProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.frozen.FrozenShrineRandomizerProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.GymProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.PokeCenterProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.pokevillage.PokeCenterProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.ScarletPokeShopProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.lugia.LugiaShrineRandomizerProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.staticShrine.StaticShrineProcessor;
Expand Down Expand Up @@ -41,7 +42,7 @@ public static void bootstrap(BootstapContext<StructureProcessorList> context) {
StructureProcessors.init();
register(context, SCARLET_POKESHOP_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new ScarletPokeShopProcessor())));
register(context, GYM_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new GymProcessor())));
register(context, POKECENTER_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new PokeCenterProcessor())));
register(context, POKECENTER_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new PokeCenterProcessor(), new PokeCenterMartDesertProcessor())));
register(context, FROZEN_SHRINE_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new FrozenShrineRandomizerProcessor(), new FrozenShrineProcessor())));
register(context, FIERY_SHRINE_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new FieryShrineRandomizerProcessor(), new FieryShrineProcessor())));
register(context, STATIC_SHRINE_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new StaticShrineRandomizerProcessor(), new StaticShrineProcessor())));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package generations.gg.generations.structures.generationsstructures.processors;

import generations.gg.generations.structures.generationsstructures.GenerationsStructures;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.pokevillage.PokeCenterMartDesertProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.fiery.FieryShrineProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.fiery.FieryShrineRandomizerProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.frozen.FrozenShrineProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.frozen.FrozenShrineRandomizerProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.GymProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.PokeCenterProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.pokevillage.PokeCenterProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.ScarletPokeShopProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.lugia.LugiaShrineRandomizerProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.staticShrine.StaticShrineProcessor;
Expand All @@ -24,6 +25,7 @@ public class StructureProcessors {
public static StructureProcessorType<ScarletPokeShopProcessor> SCARLET_POKESHOP_PROCESSOR = () -> ScarletPokeShopProcessor.CODEC;
public static StructureProcessorType<GymProcessor> GYM_PROCESSOR = () -> GymProcessor.CODEC;
public static StructureProcessorType<PokeCenterProcessor> POKECENTER_PROCESSOR = () -> PokeCenterProcessor.CODEC;
public static StructureProcessorType<PokeCenterMartDesertProcessor> POKECENTER_MART_DESERT_PROCESSOR = () -> PokeCenterMartDesertProcessor.CODEC;
public static StructureProcessorType<FrozenShrineRandomizerProcessor> FROZEN_SHRINE_RANDOMIZER_PROCESSOR = () -> FrozenShrineRandomizerProcessor.CODEC;
public static StructureProcessorType<FrozenShrineProcessor> FROZEN_SHRINE_PROCESSOR = () -> FrozenShrineProcessor.CODEC;
public static StructureProcessorType<FieryShrineRandomizerProcessor> FIERY_SHRINE_RANDOMIZER_PROCESSOR = () -> FieryShrineRandomizerProcessor.CODEC;
Expand All @@ -41,6 +43,7 @@ public static void init() {
register("scarlet_pokeshop_processor", SCARLET_POKESHOP_PROCESSOR);
register("gym_processor", GYM_PROCESSOR);
register("pokecenter_processor", POKECENTER_PROCESSOR);
register("pokecenter_mart_desert_processor", POKECENTER_MART_DESERT_PROCESSOR);
register("shrines/frozen_shrine_randomizer_processor", FROZEN_SHRINE_RANDOMIZER_PROCESSOR);
register("shrines/frozen_shrine_processor", FROZEN_SHRINE_PROCESSOR);
register("shrines/fiery_shrine_randomizer_processor", FIERY_SHRINE_RANDOMIZER_PROCESSOR);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package generations.gg.generations.structures.generationsstructures.processors.structure_processors.pokevillage;

import com.mojang.serialization.Codec;
import generations.gg.generations.structures.generationsstructures.processors.StructureProcessors;
import generations.gg.generations.structures.generationsstructures.village.VanillaVillages;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class PokeCenterMartDesertProcessor extends StructureProcessor {

public static final PokeCenterMartDesertProcessor INSTANCE = new PokeCenterMartDesertProcessor();
public static final Codec<PokeCenterMartDesertProcessor> CODEC = Codec.unit(() -> INSTANCE);

@Nullable
@Override
public StructureTemplate.StructureBlockInfo processBlock(@NotNull LevelReader level, @NotNull BlockPos blockPos, @NotNull BlockPos pos, StructureTemplate.@NotNull StructureBlockInfo blockInfo, StructureTemplate.@NotNull StructureBlockInfo relativeBlockInfo, @NotNull StructurePlaceSettings settings) {
if (level.getBiome(blockPos).is(VanillaVillages.DESERT.getVillageTag())) {
Block block = relativeBlockInfo.state().getBlock();
if (block.defaultBlockState().is(BlockTags.LEAVES))
return new StructureTemplate.StructureBlockInfo(relativeBlockInfo.pos(), Blocks.CACTUS.withPropertiesOf(relativeBlockInfo.state()), relativeBlockInfo.nbt());
else if (block.defaultBlockState().is(BlockTags.FLOWER_POTS))
return new StructureTemplate.StructureBlockInfo(relativeBlockInfo.pos(), Blocks.POTTED_CACTUS.defaultBlockState(), relativeBlockInfo.nbt());
}

return relativeBlockInfo;
}

@Override
protected @NotNull StructureProcessorType<?> getType() {
return StructureProcessors.POKECENTER_MART_DESERT_PROCESSOR;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package generations.gg.generations.structures.generationsstructures.processors.structure_processors;
package generations.gg.generations.structures.generationsstructures.processors.structure_processors.pokevillage;

import com.mojang.serialization.Codec;
import generations.gg.generations.core.generationscore.world.level.block.GenerationsBlocks;
import generations.gg.generations.structures.generationsstructures.GenerationsStructures;
import generations.gg.generations.structures.generationsstructures.integration.Integration;
import generations.gg.generations.structures.generationsstructures.processors.StructureProcessors;
import generations.gg.generations.structures.generationsstructures.village.VanillaVillages;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,30 @@
import generations.gg.generations.structures.generationsstructures.worldgen.template_pool.GenerationsTemplatePools;
import net.minecraft.data.worldgen.ProcessorLists;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
import org.jetbrains.annotations.NotNull;

public enum VanillaVillages {
PLAINS("plains", ProcessorLists.STREET_PLAINS, GenerationsTemplatePools.GENERATIONS_PLAINS_STREET),
DESERT("desert", ProcessorLists.EMPTY, GenerationsTemplatePools.GENERATIONS_DESERT_STREET),
SAVANNA("savanna", ProcessorLists.STREET_SAVANNA, null),
SNOWY("snowy", ProcessorLists.STREET_SNOWY_OR_TAIGA, null),
TAIGA("taiga", ProcessorLists.STREET_SNOWY_OR_TAIGA, null);
PLAINS("plains", ProcessorLists.STREET_PLAINS, GenerationsTemplatePools.GENERATIONS_PLAINS_STREET, BiomeTags.HAS_VILLAGE_PLAINS),
DESERT("desert", ProcessorLists.EMPTY, GenerationsTemplatePools.GENERATIONS_DESERT_STREET, BiomeTags.HAS_VILLAGE_DESERT),
SAVANNA("savanna", ProcessorLists.STREET_SAVANNA, null, BiomeTags.HAS_VILLAGE_SAVANNA),
SNOWY("snowy", ProcessorLists.STREET_SNOWY_OR_TAIGA, null, BiomeTags.HAS_VILLAGE_SNOWY),
TAIGA("taiga", ProcessorLists.STREET_SNOWY_OR_TAIGA, null, BiomeTags.HAS_VILLAGE_TAIGA);

private final String name;
private final ResourceKey<StructureProcessorList> processorList;
private final ResourceKey<StructureTemplatePool> pool;
private final TagKey<Biome> hasVillage;

VanillaVillages(String name, ResourceKey<StructureProcessorList> processorList, ResourceKey<StructureTemplatePool> pool) {
VanillaVillages(String name, ResourceKey<StructureProcessorList> processorList, ResourceKey<StructureTemplatePool> pool, TagKey<Biome> hasVillage) {
this.name = name;
this.processorList = processorList;
this.pool = pool;
this.hasVillage = hasVillage;
}

public String getName() {
Expand All @@ -33,10 +38,14 @@ public String getName() {
return processorList;
}

public ResourceKey<StructureTemplatePool> getPool() {
public @NotNull ResourceKey<StructureTemplatePool> getPool() {
return pool;
}

public @NotNull TagKey<Biome> getVillageTag() {
return hasVillage;
}

private static final VanillaVillages[] VALUES = values();

public static VanillaVillages byName(String name) {
Expand Down

0 comments on commit 6eb5c3b

Please sign in to comment.