Jump to content

[Solved] [1.16.4] Can't get custom plants to generate


vassdeniss

Recommended Posts

Am i doing something wrong?

@Mod.EventBusSubscriber
public class DecorationGeneration {
    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public static void generateBushes(BiomeLoadingEvent event) {
        BiomeGenerationSettingsBuilder generation = event.getGeneration();

        BlockClusterFeatureConfig MINT_BUSH_CONFIG = (new BlockClusterFeatureConfig.Builder(
                    new SimpleBlockStateProvider(
                            RegistryHandler.MINT_BUSH_BLOCK.get().getDefaultState().with(MintBush.AGE, 3)
                    ), SimpleBlockPlacer.PLACER
                )
        ).tries(64).whitelist(ImmutableSet.of(
                Blocks.GRASS_BLOCK.getDefaultState().getBlock()
        )).func_227317_b_().build();

        ConfiguredFeature<?, ?> MINT_BUSH = Feature.RANDOM_PATCH.withConfiguration(MINT_BUSH_CONFIG);
        ConfiguredFeature<?, ?> MINT_BUSH_DECORATED = MINT_BUSH.withPlacement(Features.Placements.PATCH_PLACEMENT).chance(24);

        if (event.getCategory().equals(Biome.Category.PLAINS)) {
            generation.withFeature(
                    GenerationStage.Decoration.VEGETAL_DECORATION, MINT_BUSH_DECORATED
            );
        }
    }
}

 

Edited by vassdeniss
Link to comment
Share on other sites

first of all you can't create the ConfiguredFeature inside the event because you need to register them
second, take a look at the vanilla Features class how to create ConfiguredFeature,
then copy the vanilla registry and do this for your ConfiguredFeature inside FMLCommonSetupEvent

Link to comment
Share on other sites

23 minutes ago, Luis_ST said:

first of all you can't create the ConfiguredFeature inside the event because you need to register them
second, take a look at the vanilla Features class how to create ConfiguredFeature,
then copy the vanilla registry and do this for your ConfiguredFeature inside FMLCommonSetupEvent

private void setup(final FMLCommonSetupEvent event) {
        DecorationGeneration.registerBushes();
}
@Mod.EventBusSubscriber
public class DecorationGeneration {
    private static final ArrayList<ConfiguredFeature<?, ?>> overworldDeco = new ArrayList<ConfiguredFeature<?, ?>>();

    public static void registerBushes() {
        overworldDeco.add(register("mint", Feature.RANDOM_PATCH.withConfiguration(new BlockClusterFeatureConfig
                .Builder(new SimpleBlockStateProvider(RegistryHandler.MINT_BUSH_BLOCK.get().getDefaultState().with(MintBush.AGE, 3)),
                SimpleBlockPlacer.PLACER).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock()))
                .func_227317_b_().build()
        )).withPlacement(Features.Placements.PATCH_PLACEMENT).chance(24));
    }

    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public static void gen(BiomeLoadingEvent event) {
        BiomeGenerationSettingsBuilder generation = event.getGeneration();
        for (ConfiguredFeature<?, ?> bush : overworldDeco){
            if (bush != null) generation.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, bush);
        }
    }

    private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String name, ConfiguredFeature<FC, ?> configuredFeature) {
        return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, MakoRuMod.MOD_ID + ":" + name, configuredFeature);
    }
}

I did something like this. I believe im getting closer but still it doesn't work?

Link to comment
Share on other sites

the ConfiguredFeature works i copied your code and i found the feature, but it's very rare, rare than the pumpkin feature

	private void setup(final FMLCommonSetupEvent event) {
		MINT = register("mint", Feature.RANDOM_PATCH.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.BARREL.defaultBlockState()), SimpleBlockPlacer.INSTANCE))
				.tries(64).noProjection().whitelist(Sets.newHashSet(Blocks.GRASS_BLOCK)).build()).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE).chance(24));
	}
	
	private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String name, ConfiguredFeature<FC, ?> configuredFeature) {
		return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("examplemod", name), configuredFeature);
	}
	
	public static ConfiguredFeature<?, ?> MINT;
	
	@SubscribeEvent(priority = EventPriority.HIGH)
	public static void name(BiomeLoadingEvent event) {
		if (MINT != null) {
			event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, MINT);
		}
	}

and (I had to scale down the picture because it was too big)
2021-08-15_11_45_51.png.0d346f45de56cb2f11c284dbc7491365.png

Link to comment
Share on other sites

Just now, Luis_ST said:

the ConfiguredFeature works i copied your code and i found the feature, but it's very rare, rare than the pumpkin feature


	private void setup(final FMLCommonSetupEvent event) {
		MINT = register("mint", Feature.RANDOM_PATCH.configured((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.BARREL.defaultBlockState()), SimpleBlockPlacer.INSTANCE))
				.tries(64).noProjection().whitelist(Sets.newHashSet(Blocks.GRASS_BLOCK)).build()).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE).chance(24));
	}
	
	private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String name, ConfiguredFeature<FC, ?> configuredFeature) {
		return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("examplemod", name), configuredFeature);
	}
	
	public static ConfiguredFeature<?, ?> MINT;
	
	@SubscribeEvent(priority = EventPriority.HIGH)
	public static void name(BiomeLoadingEvent event) {
		if (MINT != null) {
			event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, MINT);
		}
	}

and (I had to scale down the picture because it was too big)
2021-08-15_11_45_51.png.0d346f45de56cb2f11c284dbc7491365.png

how do i make it common? The .chance?

Link to comment
Share on other sites

        MINT = register("mint",
                Feature.RANDOM_PATCH.withConfiguration(
                        new BlockClusterFeatureConfig.Builder(
                                new SimpleBlockStateProvider(
                                        RegistryHandler.MINT_BUSH_BLOCK.get().getDefaultState().with(MintBush.AGE, 3)),
                                SimpleBlockPlacer.PLACER)
                                .tries(64).func_227317_b_()
                                .whitelist(Sets.newHashSet(Blocks.GRASS_BLOCK)).build())
                        .withPlacement(Features.Placements.PATCH_PLACEMENT).chance(80)
        );

Still not seeing it :/

Everything seems correct i don't get it

Link to comment
Share on other sites

2 minutes ago, Luis_ST said:

show all relevant classes (Events)

@Mod.EventBusSubscriber
public class DecorationGeneration {
    public static ConfiguredFeature<?, ?> MINT;

    public static void registerBushes() {
        MINT = register("mint",
                Feature.RANDOM_PATCH.withConfiguration(
                        new BlockClusterFeatureConfig.Builder(
                                new SimpleBlockStateProvider(
                                        RegistryHandler.MINT_BUSH_BLOCK.get().getDefaultState().with(MintBush.AGE, 3)),
                                SimpleBlockPlacer.PLACER)
                                .tries(64).func_227317_b_()
                                .whitelist(Sets.newHashSet(Blocks.GRASS_BLOCK)).build())
                        .withPlacement(Features.Placements.PATCH_PLACEMENT).chance(80)
        );
    }

    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public static void gen(BiomeLoadingEvent event) {
        if (MINT != null) {
            event.getGeneration().withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, MINT);
        }
    }

    private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String name, ConfiguredFeature<FC, ?> configuredFeature) {
        return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("makoru", name), configuredFeature);
    }
}

DecoGeneration

 

    private void setup(final FMLCommonSetupEvent event) {
        OreGeneration.registerOres();
        DecorationGeneration.registerBushes();
        DeferredWorkQueue.runLater(() -> {
            GlobalEntityTypeAttributes.put(RegistryHandler.NIMBAT.get(), NimbatEntity.setCustomAttributes().create());
        });
    }

Main Class

Link to comment
Share on other sites

Still no. Jesus i have no idea

heres my registry line

public static final RegistryObject<Block> MINT_BUSH_BLOCK = BLOCKS.register("mint_bush_block", MintBush::new);

 

and the mint bush class itself

public class MintBush extends SweetBerryBushBlock {
    public MintBush() {
        super(Block.Properties.create(Material.PLANTS)
                .hardnessAndResistance(0, 0)
                .doesNotBlockMovement()
                .tickRandomly()
                .sound(SoundType.PLANT)
        );
    }

    @Override
    public ItemStack getItem(IBlockReader worldIn, BlockPos pos, BlockState state) {
        return new ItemStack(RegistryHandler.MINT.get());
    }

    @Override
    public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
        int i = state.get(AGE);
        boolean flag = i == 3;

        if (!flag && player.getHeldItem(handIn).getItem() == Items.BONE_MEAL) {
            return ActionResultType.PASS;
        } else if (i > 1) {
            int j = 1 + worldIn.rand.nextInt(2);
            spawnAsEntity(worldIn, pos, new ItemStack(RegistryHandler.MINT.get(), j + (flag ? 1 : 0)));
            worldIn.playSound((PlayerEntity) null, pos, SoundEvents.ITEM_SWEET_BERRIES_PICK_FROM_BUSH,
                    SoundCategory.BLOCKS, 1, 0.8f + worldIn.rand.nextFloat() * 0.4f
            );
            worldIn.setBlockState(pos, state.with(AGE, 1), 2);
            return ActionResultType.SUCCESS;
        } else {
            return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
        }
    }

    @Override
    public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
        super.onEntityCollision(state, worldIn, pos, entityIn);
    }
}

maybe its something there but I doubt it

Edited by vassdeniss
Fixed mistake
Link to comment
Share on other sites

  • vassdeniss changed the title to [Solved] [1.16.4] Can't get custom plants to generate

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
    • Hi, I'm trying to use datagen to create json files in my own mod. This is my ModRecipeProvider class. public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { public ModRecipeProvider(PackOutput pOutput) { super(pOutput); } @Override protected void buildRecipes(Consumer<FinishedRecipe> pWriter) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', ModItems.COMPRESSED_DIAMOND.get()) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get(),9) .requires(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .unlockedBy(getHasName(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()), has(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get())) .save(pWriter); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', Blocks.DIAMOND_BLOCK) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); } } When I try to run the runData client, it shows an error:  Caused by: java.lang.IllegalStateException: Duplicate recipe compressed:compressed_diamond I know that it's caused by the fact that there are two recipes for the ModItems.COMPRESSED_DIAMOND. But I need both of these recipes, because I need a way to craft ModItems.COMPRESSED_DIAMOND_BLOCK and restore 9 diamond blocks from ModItems.COMPRESSED_DIAMOND. Is there a way to solve this?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.