Changes
From Forge Community Wiki
420 bytes added
, 02:13, 19 May 2021
Line 348: |
Line 348: |
| Here is an example: | | Here is an example: |
| | | |
− | <syntaxhighlight lang="Java">
| + | {{Template:Tabs/Code_Snippets |
− | public static final DeferredRegister<ExampleRegistry> EXAMPLE = DeferredRegister.create(ExampleRegistry.class, MODID); | + | |java=public static final DeferredRegister<ExampleRegistry> EXAMPLE = DeferredRegister.create(ExampleRegistry.class, MODID); |
| | | |
| public static final Lazy<IForgeRegistry<ExampleRegistry>> REGISTRY = Lazy.of(EXAMPLE.makeRegistry("example_registry", RegistryBuilder::new)); | | public static final Lazy<IForgeRegistry<ExampleRegistry>> REGISTRY = Lazy.of(EXAMPLE.makeRegistry("example_registry", RegistryBuilder::new)); |
− | </syntaxhighlight> | + | |kotlin=val EXAMPLE: DeferredRegister<ExampleRegistry> = DeferredRegister.create(ExampleRegistry::class.java, MODID) |
| + | |
| + | val REGISTRY: IForgeRegistry<ExampleRegistry> by lazy { |
| + | EXAMPLE.makeRegistry("example_registry", ::RegistryBuilder).get() |
| + | } |
| + | |scala=final val EXAMPLE = DeferredRegister.create(classOf[ExampleRegistry], MODID) |
| + | |
| + | final lazy val REGISTRY = EXAMPLE.makeRegistry("example_registry", () => new RegistryBuilder).get |
| + | |}} |
| | | |
| === Using RegistryEvent$NewRegistry === | | === Using RegistryEvent$NewRegistry === |