vassdeniss Posted August 14, 2021 Posted August 14, 2021 (edited) 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 August 15, 2021 by vassdeniss Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 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 Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 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? Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 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) Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 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) how do i make it common? The .chance? Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 (edited) yes, a larger value makes the feature more common Edited August 15, 2021 by Luis_ST Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 4 minutes ago, Luis_ST said: yes Im missing some of the code youre using. Im using MCP i think it uses different functions? Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 Specifically noProjection and HEIGHTMAP_DOUBLE_SQUARE Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 noProjection -> func_227317b HEIGHTMAP_DOUBLE_SQUARE -> PATCH_PLACEMENT Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 4 minutes ago, Luis_ST said: noProjection -> func_227317b HEIGHTMAP_DOUBLE_SQUARE -> PATCH_PLACEMENT Youve been of amazing help! Ill try to see if it generates now. I believe i shall also update my mappings Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 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 Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 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 Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 no idea what is wrong, i can not reproduce the error with your code Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 2 minutes ago, Luis_ST said: no idea what is wrong, i can not reproduce the error with your code It spawns in all biomes right? Ill check again.. Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 How can I look at what unmapped function does what? Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 in every biome which has grass as top block layer Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 Just now, vassdeniss said: How can I look at what unmapped function does what? you can look where they located and where they called from vanilla code use your ide Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 (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 August 15, 2021 by vassdeniss Fixed mistake Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 looks okay can you post a git repo of your mod so i can use debugger Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 Fixed it. Just looked at how vanilla does it in the Features class and implemented it in my own generation class Quote
vassdeniss Posted August 15, 2021 Author Posted August 15, 2021 How to I mark as solved i forgot Quote
Luis_ST Posted August 15, 2021 Posted August 15, 2021 (edited) edit the title of the this thread Edited August 15, 2021 by Luis_ST Quote
Recommended Posts
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.