From 0044f2062d4649187791b2244d016cce79e17748 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Sun, 20 Mar 2022 11:00:55 -0700 Subject: [PATCH] Fix names of wild catnip generator. --- .../catherder/common/CommonSetup.java | 2 +- .../sweetrpg/catherder/common/util/Util.java | 8 +++++++ .../common/world/WildCropGeneration.java | 24 ++++++++++--------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/sweetrpg/catherder/common/CommonSetup.java b/src/main/java/com/sweetrpg/catherder/common/CommonSetup.java index 27907f7a..b0a7abaa 100644 --- a/src/main/java/com/sweetrpg/catherder/common/CommonSetup.java +++ b/src/main/java/com/sweetrpg/catherder/common/CommonSetup.java @@ -27,7 +27,7 @@ public static void init(final FMLCommonSetupEvent event) { CatRespawnCommand.registerSerilizers(); CatEntity.initDataParameters(); - WildCropGeneration.registerWildCropGeneration(); + WildCropGeneration.registerWildCatnipGeneration(); registerCompostables(); registerDispenserBehaviors(); diff --git a/src/main/java/com/sweetrpg/catherder/common/util/Util.java b/src/main/java/com/sweetrpg/catherder/common/util/Util.java index aa9c5302..ad34433d 100644 --- a/src/main/java/com/sweetrpg/catherder/common/util/Util.java +++ b/src/main/java/com/sweetrpg/catherder/common/util/Util.java @@ -112,6 +112,14 @@ public static String getResourcePath(String name) { return getResourcePath(Constants.MOD_ID, name); } + public static ResourceLocation modLoc(String name) { + return new ResourceLocation(Constants.MOD_ID, name); + } + + public static ResourceLocation mcLoc(String name) { + return new ResourceLocation(name); + } + /** * @param modId The namespace * @param name The path diff --git a/src/main/java/com/sweetrpg/catherder/common/world/WildCropGeneration.java b/src/main/java/com/sweetrpg/catherder/common/world/WildCropGeneration.java index 1e1da16d..07e52def 100644 --- a/src/main/java/com/sweetrpg/catherder/common/world/WildCropGeneration.java +++ b/src/main/java/com/sweetrpg/catherder/common/world/WildCropGeneration.java @@ -1,13 +1,12 @@ package com.sweetrpg.catherder.common.world; import com.sweetrpg.catherder.common.config.ConfigHandler; -import com.sweetrpg.catherder.common.lib.Constants; import com.sweetrpg.catherder.common.registry.ModBlocks; +import com.sweetrpg.catherder.common.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.data.BuiltinRegistries; import net.minecraft.data.worldgen.placement.PlacementUtils; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; @@ -24,25 +23,28 @@ import java.util.Arrays; public class WildCropGeneration { + public static final BlockPos BLOCK_BELOW = new BlockPos(0, -1, 0); + public static ConfiguredFeature FEATURE_PATCH_WILD_CATNIP; public static PlacedFeature PATCH_WILD_CATNIP; - public static RandomPatchConfiguration getWildCropConfiguration(Block block, int tries, int xzSpread, BlockPredicate plantedOn) { - return new RandomPatchConfiguration(tries, xzSpread, 3, () -> - Feature.SIMPLE_BLOCK.configured(new SimpleBlockConfiguration(BlockStateProvider.simple(block))) - .filtered(BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, plantedOn))); + public static RandomPatchConfiguration getWildCropConfiguration(Block block, int tries, int xzSpread, int ySpread, BlockPredicate plantedOn) { + return new RandomPatchConfiguration(tries, xzSpread, ySpread, + () -> Feature.SIMPLE_BLOCK.configured(new SimpleBlockConfiguration(BlockStateProvider.simple(block))) + .filtered(BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, plantedOn))); } - public static void registerWildCropGeneration() { + public static void registerWildCatnipGeneration() { FEATURE_PATCH_WILD_CATNIP = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, - new ResourceLocation(Constants.MOD_ID, "patch_wild_catnip"), - Feature.RANDOM_PATCH.configured(getWildCropConfiguration(ModBlocks.WILD_CATNIP.get(), 64, 4, - BlockPredicate.matchesBlocks(Arrays.asList(Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.PODZOL), BLOCK_BELOW)))); + Util.modLoc("patch_wild_catnip"), + Feature.RANDOM_PATCH.configured(getWildCropConfiguration(ModBlocks.WILD_CATNIP.get(), 64, 6, 3, + BlockPredicate.matchesBlocks(Arrays.asList(Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL), BLOCK_BELOW)))); PATCH_WILD_CATNIP = Registry.register(BuiltinRegistries.PLACED_FEATURE, - new ResourceLocation(Constants.MOD_ID, "patch_wild_catnip"), + Util.modLoc("patch_wild_catnip"), FEATURE_PATCH_WILD_CATNIP.placed(RarityFilter.onAverageOnceEvery(ConfigHandler.SERVER.CHANCE_WILD_CATNIP.get()), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, BiomeFilter.biome())); } + }