Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


vassdeniss
 Share

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

Posted (edited)

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.