Skip to content

Commit

Permalink
Fix names of wild catnip generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyhedral committed Mar 20, 2022
1 parent 2d7434a commit 0044f20
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void init(final FMLCommonSetupEvent event) {
CatRespawnCommand.registerSerilizers();
CatEntity.initDataParameters();

WildCropGeneration.registerWildCropGeneration();
WildCropGeneration.registerWildCatnipGeneration();

registerCompostables();
registerDispenserBehaviors();
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/sweetrpg/catherder/common/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<RandomPatchConfiguration, ?> 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()));
}

}

0 comments on commit 0044f20

Please sign in to comment.