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 5242892
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 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

1 comment on commit 5242892

@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.

Failed to publish to Pages. Check Action logs for more details.

Please sign in to comment.