Changes

903 bytes removed ,  12:06, 22 March 2022
Update to 1.18.2
Line 131: Line 131:     
{{Template:Tabs/Code_Snippets
 
{{Template:Tabs/Code_Snippets
|java=public static final Lazy<ConfiguredFeature<?, ?>> EXAMPLE_CONFIGURED_FEATURE = Lazy.of(() ->
+
|java=public static final Lazy<Holder<ConfiguredFeature<NoneFeatureConfiguration, ?>>> EXAMPLE_CONFIGURED_FEATURE = Lazy.of(() -> FeatureUtils.register("examplemod:example_configured_feature", Feature.NO_OP));
    register("example_configured_feature",
  −
        Feature.NO_OP.configured(NoneFeatureConfiguration.INSTANCE)
  −
            .decorated(FeatureDecorator.NOPE.configured(NoneDecoratorConfiguration.INSTANCE))
  −
    )
  −
);
      
@SubscribeEvent(priority = EventPriority.HIGHEST)
 
@SubscribeEvent(priority = EventPriority.HIGHEST)
Line 142: Line 137:  
     event.enqueueWork(EXAMPLE_CONFIGURED_FEATURE::get);
 
     event.enqueueWork(EXAMPLE_CONFIGURED_FEATURE::get);
 
}
 
}
 
+
|kotlin=val EXAMPLE_CONFIGURED_FEATURE: ConfiguredFeature<NoneFeatureConfiguration, *> by lazy {
private static <T extends ConfiguredFeature<?, ?>> T register(String name, T value) {
+
     FeatureUtils.register("examplemod:example_configured_feature", Feature.NO_OP)
    return Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(MODID, name), value);
  −
}
  −
|kotlin=val EXAMPLE_CONFIGURED_FEATURE: ConfiguredFeature<*, *> by lazy {
  −
     register("example_configured_feature",  
  −
        Feature.NO_OP.configured(NoneFeatureConfiguration.INSTANCE)
  −
            .decorated(FeatureDecorator.NOPE.configured(NoneDecoratorConfiguration.INSTANCE)))
   
}
 
}
   Line 156: Line 145:  
     @SubscribeEvent(priority = EventPriority.HIGHEST)
 
     @SubscribeEvent(priority = EventPriority.HIGHEST)
 
     fun register(event: FMLCommonSetupEvent) {
 
     fun register(event: FMLCommonSetupEvent) {
         event.enqueueWork(EXAMPLE_CONFIGURED_FEATURE::getConfig)
+
         event.enqueueWork(EXAMPLE_CONFIGURED_FEATURE::config)
 
     }
 
     }
 
}
 
}
  −
private fun <T: ConfiguredFeature<*, *>> register(name: String, value: T): T =
  −
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, ResourceLocation(MODID, name), value)
   
|scala=class Events {
 
|scala=class Events {
 
     @SubscribeEvent(priority = EventPriority.HIGHEST)
 
     @SubscribeEvent(priority = EventPriority.HIGHEST)
 
     def register(event: FMLCommonSetupEvent): Unit = {
 
     def register(event: FMLCommonSetupEvent): Unit = {
         event.enqueueWork(Events.EXAMPLE_CONFIGURED_FEATURE.getConfig _)
+
         event.enqueueWork(Events.EXAMPLE_CONFIGURED_FEATURE.config _)
 
     }
 
     }
 
}
 
}
 
object Events {
 
object Events {
     final lazy val EXAMPLE_CONFIGURED_FEATURE = register("example_configured_feature",
+
     final lazy val EXAMPLE_CONFIGURED_FEATURE = FeatureUtils.register("examplemod:example_configured_feature", Feature.NO_OP)
        Feature.NO_OP.configured(NoneFeatureConfiguration.INSTANCE)
  −
            .decorated(FeatureDecorator.NOPE.configured(NoneDecoratorConfiguration.INSTANCE)))
  −
 
  −
    private def register[T <: ConfiguredFeature[_, _]](name: String, value: T): T =
  −
        Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(MODID, name), value)
   
}
 
}
 
|}}
 
|}}