mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-05 11:39:57 -04:00
Item Group API: Expose shouldShowOpRestrictedItems (#2637)
This commit is contained in:
parent
0d6838e783
commit
136255bb19
2 changed files with 12 additions and 2 deletions
fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric
|
@ -38,11 +38,14 @@ public class FabricItemGroupEntries implements ItemGroup.Entries {
|
|||
private final List<ItemStack> displayStacks;
|
||||
private final List<ItemStack> searchTabStacks;
|
||||
|
||||
private final boolean showOpRestrictedItems;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public FabricItemGroupEntries(FeatureSet enabledFeatures, List<ItemStack> displayStacks, List<ItemStack> searchTabStacks) {
|
||||
public FabricItemGroupEntries(FeatureSet enabledFeatures, List<ItemStack> displayStacks, List<ItemStack> searchTabStacks, boolean showOpRestrictedItems) {
|
||||
this.enabledFeatures = enabledFeatures;
|
||||
this.displayStacks = displayStacks;
|
||||
this.searchTabStacks = searchTabStacks;
|
||||
this.showOpRestrictedItems = showOpRestrictedItems;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,6 +55,13 @@ public class FabricItemGroupEntries implements ItemGroup.Entries {
|
|||
return enabledFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether to show items restricted to operators, such as command blocks.
|
||||
*/
|
||||
public boolean shouldShowOpRestrictedItems() {
|
||||
return showOpRestrictedItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The stacks that will be shown in the tab in the creative mode inventory. This list can be modified.
|
||||
*/
|
||||
|
|
|
@ -74,7 +74,7 @@ abstract class ItemGroupMixin implements IdentifiableItemGroup, FabricItemGroup
|
|||
// Convert the entries to lists
|
||||
var mutableDisplayStacks = new LinkedList<>(displayStacks);
|
||||
var mutableSearchTabStacks = new LinkedList<>(searchTabStacks);
|
||||
var entries = new FabricItemGroupEntries(enabledFeatures, mutableDisplayStacks, mutableSearchTabStacks);
|
||||
var entries = new FabricItemGroupEntries(enabledFeatures, mutableDisplayStacks, mutableSearchTabStacks, operatorEnabled);
|
||||
|
||||
final Event<ItemGroupEvents.ModifyEntries> modifyEntriesEvent = ItemGroupEventsImpl.getModifyEntriesEvent(getId());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue