Jump to content

Jkmcameron

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Jkmcameron

  1. How in the entire hell am I supposed to register Features to Biomes if the biomes are registered first
  2. I don't understand why this isn't already the case, but I'm trying to add my custom world gen features into vanilla biomes and I am getting the error "Registry Object not present". The features are being registered in the same exact way as my blocks and items. In my Features class: public static final DeferredRegister<Feature<?>> FEATURES = new DeferredRegister<>(ForgeRegistries.FEATURES, T3L.MODID); public static final RegistryObject<Feature<TreeFeatureConfig>> WHITE_OAK_TREE = FEATURES.register("quercus_alba", () -> new TreeFeature(TreeFeatureConfig::deserialize)); In my Main class: @Mod(T3L.MODID) public class T3L { public static final String MODID = "t3l"; public T3L() { IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); eventBus.register(this); Fluids.FLUIDS.register(eventBus); Blocks.BLOCKS.register(eventBus); Items.VANILLA_ITEMS.register(eventBus); Items.T3L_ITEMS.register(eventBus); Features.FEATURES.register(eventBus); } @SubscribeEvent public void biomeGeneration(RegistryEvent.Register<Biome> event) { Collection<Biome> biomes = event.getRegistry().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); } //biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.WHITE_OAK_TREE.get().withConfiguration(Features.WHITE_OAK_CONFIG).withPlacement(Placement.COUNT_EXTRA_HEIGHTMAP.configure(new AtSurfaceWithExtraConfig(10, 0.1F, 1)))); } } } The line I commented out is the problem line. The rest of the code you see in the biome registration event handler is a test, it removes all of the tree generation from every biome, and works as intended. If I run the program with the line uncommented I'll get an error on WHITE_OAK_TREE that says "Registry Object not present" which could only possibly mean that RegistryEvent.Register<Biome> is firing before RegistryEvent.Register<Feature<?>> and I dont know how to make that not happen
  3. 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
  4. 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
  5. 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
×
×
  • Create New...

Important Information

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