diff --git a/docs/network/getting-started/Installation.md b/docs/network/getting-started/Installation.md index e69de29b..43886357 100644 --- a/docs/network/getting-started/Installation.md +++ b/docs/network/getting-started/Installation.md @@ -0,0 +1,11 @@ +## Architectury + +tbd + +## Fabric + +tbd + +## NeoForge + +tbd \ No newline at end of file diff --git a/docs/storage/getting-started/Installation.md b/docs/storage/getting-started/Installation.md index e69de29b..43886357 100644 --- a/docs/storage/getting-started/Installation.md +++ b/docs/storage/getting-started/Installation.md @@ -0,0 +1,11 @@ +## Architectury + +tbd + +## Fabric + +tbd + +## NeoForge + +tbd \ No newline at end of file diff --git a/docs/storage/getting-started/registering-storages.md b/docs/storage/getting-started/registering-storages.md new file mode 100644 index 00000000..a4600131 --- /dev/null +++ b/docs/storage/getting-started/registering-storages.md @@ -0,0 +1,156 @@ +# Registering Storages + +Registering a custom Storage attaches an instance of your custom Storage class to a specific object. + +To register a custom Storage, you need to choose where to attach your data to. +This can be an [Entity](#registering-a-storage-to-an-entity), a [Chunk](#registering-a-storage-to-a-chunk) or a [World / Level](#registering-a-storage-to-a-level). + +## Registering a Storage to an Entity + +### Architectury +To register a Storage to an Entity in Architectury, you need to listen to the `StorageEvents.REGISTER_ENTITY_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_ENTITY_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the common package at entrypoint invocation (In fabric the `ModInitializer#onInitialize` and on NeoForge the mod constructor). + +### Fabric +To register a Storage to an Entity in Fabric, you need to listen to the `StorageEvents.REGISTER_ENTITY_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_ENTITY_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the `ModInitializer#onInitialize` method. + +### NeoForge +To register a Storage to an Entity in NeoForge, you need to listen to the `StorageEvents.REGISTER_ENTITY_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_ENTITY_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the mod constructor. + +## Registering a Storage to a Chunk + +### Architectury +To register a Storage to an Entity in Architectury, you need to listen to the `StorageEvents.REGISTER_CHUNK_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_CHUNK_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the common package at entrypoint invocation (In fabric the `ModInitializer#onInitialize` and on NeoForge the mod constructor). + +### Fabric +To register a Storage to an Entity in Fabric, you need to listen to the `StorageEvents.REGISTER_CHUNK_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_CHUNK_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the `ModInitializer#onInitialize` method. + +### NeoForge +To register a Storage to an Entity in NeoForge, you need to listen to the `StorageEvents.REGISTER_CHUNK_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_CHUNK_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the mod constructor. + +## Registering a Storage to a World + +### Architectury +To register a Storage to an Entity in Architectury, you need to listen to the `StorageEvents.REGISTER_WORLD_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_WORLD_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the common package at entrypoint invocation (In fabric the `ModInitializer#onInitialize` and on NeoForge the mod constructor). + +### Fabric +To register a Storage to an Entity in Fabric, you need to listen to the `StorageEvents.REGISTER_WORLD_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_WORLD_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the `ModInitializer#onInitialize` method. + +### NeoForge +To register a Storage to an Entity in NeoForge, you need to listen to the `StorageEvents.REGISTER_WORLD_STORAGE` Event. +```java +StorageKey STORAGE_KEY; + +StorageEvents.REGISTER_WORLD_STORAGE.register(registry -> { + STORAGE_KEY = registry.register( + ResourceLocation.fromNamespaceAndPath(MOD_ID, STORAGE_ID), // Your custom Storage ID + ExampleStorage.class, // Your custom Storage class + entity -> entity instanceof Player, // Predicate to check if the Storage should be attached to the Entity + ExampleStorage::new // Supplier to create a new instance of your custom Storage + ); +}); +``` +This should be done in the mod constructor. \ No newline at end of file diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 7c089bd4..c0464745 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -71,6 +71,7 @@ const config: Config = { prism: { theme: prismThemes.github, darkTheme: prismThemes.dracula, + additionalLanguages: ['java'] }, } satisfies Preset.ThemeConfig, };