Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I've created custom tree "Feature"s and registered them to the forge Feature registry, but I don't know what to do after this. I deally I'd like to override the vanilla trees, or tell the game not to place vanilla trees and to place mine instead. I checked the different available Events provided by forge but I didn't see any that jumped put to me as being related to world generation. If there is no Event to subscribe to for world generation, how would I go about doing this? Forge 1.15

Edited by Jkmcameron

  • Author

Ok somehow I spent hours looking into this with no progress, but just when I give up and make a thread about it I sort of figure it out. Is the following code viable? 

 

@SubscribeEvent
public void worldGeneration(WorldEvent event)
{
	Collection<Biome> biomes = ForgeRegistries.BIOMES.getValues();

	for (Biome biome : biomes)
	{
	    List<ConfiguredFeature<?, ?>> configuredFeatures = biome.getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION);

	    for (ConfiguredFeature<?, ?> configuredFeature : configuredFeatures)
	    {
		switch (configuredFeature.feature.getRegistryName().getPath())
		{
		    case "normal_tree":
		    case "acacia_tree":
		    case "fancy_tree":
		    case "dark_oak_tree":
		    case "mega_jungle_tree":
		    case "mega_spruce_tree":

			configuredFeatures.remove(configuredFeature);
		}
	    }

	    biome.getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).clear();

	    for (ConfiguredFeature<?, ?> configuredFeature : configuredFeatures)
	    {
		biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, configuredFeature);
	    }

	    // Add custom trees

	    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, MY_CUSTOM_FEATURE);
	}
}

I assume this would have the intended effect, but what would be the correct Event to fire this code at? Obviously it has to be done after RegistryEvent.Register<Feature<?>> is called

Edited by Jkmcameron

  • Author
2 hours ago, Jkmcameron said:

Ok somehow I spent hours looking into this with no progress, but just when I give up and make a thread about it I sort of figure it out. Is the following code viable? 

 


@SubscribeEvent
public void worldGeneration(WorldEvent event)
{
	Collection<Biome> biomes = ForgeRegistries.BIOMES.getValues();

	for (Biome biome : biomes)
	{
	    List<ConfiguredFeature<?, ?>> configuredFeatures = biome.getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION);

	    for (ConfiguredFeature<?, ?> configuredFeature : configuredFeatures)
	    {
		switch (configuredFeature.feature.getRegistryName().getPath())
		{
		    case "normal_tree":
		    case "acacia_tree":
		    case "fancy_tree":
		    case "dark_oak_tree":
		    case "mega_jungle_tree":
		    case "mega_spruce_tree":

			configuredFeatures.remove(configuredFeature);
		}
	    }

	    biome.getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).clear();

	    for (ConfiguredFeature<?, ?> configuredFeature : configuredFeatures)
	    {
		biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, configuredFeature);
	    }

	    // Add custom trees

	    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, MY_CUSTOM_FEATURE);
	}
}

I assume this would have the intended effect, but what would be the correct Event to fire this code at? Obviously it has to be done after RegistryEvent.Register<Feature<?>> is called

 

Ok the event was RegistryEvent.Register<Biome> (duh), after dealing with some BS that was preventing RegistryEvent from firing I got it to work, code is good. Not a tree in sight. Close the thread

Edited by Jkmcameron

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.