Posted March 15, 20205 yr 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 March 15, 20205 yr by Jkmcameron
March 15, 20205 yr 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 March 15, 20205 yr by Jkmcameron
March 15, 20205 yr 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 March 15, 20205 yr 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.