Skip to content

Commit

Permalink
Update MenuType example
Browse files Browse the repository at this point in the history
  • Loading branch information
ApexModder committed Nov 13, 2024
1 parent 81dc669 commit a684159
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions docs/advanced/featureflags.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ In order to flag a given `FeatureElement` as requiring your Feature Flag, you si
- `Item`: `Item.Properties#requiredFeatures`
- `Block`: `BlockBehaviour.Properties#requiredFeatures`
- `EntityType`: `EntityType.Builder#requiredFeatures`
- `MenuType`: `IMenuTypeExtension#create`
- `MenuType`: `MenuType#new`
- `Potion`: `Potion#requiredFeatures`
- `MobEffect`: `MobEffect#requiredFeatures`

Expand Down Expand Up @@ -89,9 +89,18 @@ DeferredHolder<EntityType<?>, EntityType<ExperimentalEntity>> EXPERIMENTAL_ENTIT

// MenuType
DeferredRegister<MenuType<?>> MENU_TYPES = DeferredRegister.create(Registries.MENU, "examplemod");
DeferredHolder<MenuType<?>, MenuType<ExperimentalMenu>> EXPERIMENTAL_MENU = MENU_TYPES.register("experimental", () -> IMenuTypeExtension.create(
ExperimentalMenu::new,
EXPERIMENTAL // mark as requiring the 'EXPERIMENTAL' flag
DeferredHolder<MenuType<?>, MenuType<ExperimentalMenu>> EXPERIMENTAL_MENU = MENU_TYPES.register("experimental", () -> new MenuType<>(
// Using Vanilla MenuSupplier
// This is used when your menu is not encoding complex data during `player.openMenu`
// (windowId, inventory) -> new ExperimentalMenu(windowId, inventory),

// Using NeoForge IContainerFactory
// This is used when you wish to read complex data encoded during `player.openMenu`
// Casting here is important as `MenuType` specificly wants `MenuSupplier`
(IContainerFactory<ExperimentalMenu>) (windowId, inventory, buffer) -> new ExperimentalMenu(windowId, inventory, buffer),

// mark as requiring the 'EXPERIMENTAL' flag
FeatureFlagSet.of(EXPERIMENTAL)
));

// MobEffect
Expand Down Expand Up @@ -248,11 +257,20 @@ public static void gatherData(final GatherDataEvent event) {
var generator = event.getGenerator();
// The generate a Feature Pack you must first obtain a pack generator instance for the desired pack.
// make use of provided utility method
// generator.getBuiltinDatapack(<shouldGenerate>, <namespace>, <path>);
// this will generate the feature pack into the following path
// ./data/<namespace>/datapacks/<path>
var featurePack = generator.getBuiltinDatapack(true, "examplemod", "experimental");
// construct the pack generator your self
// this allows generating your feature pack into a custom location
// new DataGenerator.PackGenerator(<shouldGenerator>, <namespace>, generator.getPackOutput(<path>));
// this will generate the feature pack into the following path
// ./<path>
// var featurePack = new DataGenerator.PackGenerator(true, "examplemod", generator.getPackOutput("experimental"));
// Do take note of the generated pack location, as this is where Built-In packs should point their `packLocation` towards.
// register a provider to generate the `pack.mcmeta` file
Expand Down

1 comment on commit a684159

@neoforged-pages-deployments
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploying with Cloudflare Pages

Name Result
Last commit: a684159357971a7b358dae882d006d61e86099a3
Status: ✅ Deploy successful!
Preview URL: https://1f5894b2.neoforged-docs-previews.pages.dev
PR Preview URL: https://pr-184.neoforged-docs-previews.pages.dev

Please sign in to comment.