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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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