-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API to control creative inventory screen (#3814)
* Add API to control creative inventory screen * Rename methods * Apply suggestions from code review Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Update fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/api/client/itemgroup/v1/FabricCreativeInventoryScreen.java Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> --------- Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> (cherry picked from commit 00ab0a6)
- Loading branch information
Showing
8 changed files
with
257 additions
and
127 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
...lient/java/net/fabricmc/fabric/api/client/itemgroup/v1/FabricCreativeInventoryScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.api.client.itemgroup.v1; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; | ||
import net.minecraft.item.ItemGroup; | ||
|
||
/** | ||
* Fabric provided extensions to {@link CreativeInventoryScreen}. | ||
* This interface is automatically implemented on all creative inventory screens via Mixin and interface injection. | ||
*/ | ||
public interface FabricCreativeInventoryScreen { | ||
/** | ||
* Switches to the page with the given index if it exists. | ||
* | ||
* @param page the index of the page to switch to | ||
* @return Returns true when the page was changed | ||
*/ | ||
default boolean switchToPage(int page) { | ||
throw new AssertionError("Implemented by mixin"); | ||
} | ||
|
||
/** | ||
* Switches to the next page if it exists. | ||
* | ||
* @return Returns true when the page was changed | ||
*/ | ||
default boolean switchToNextPage() { | ||
return switchToPage(getCurrentPage() + 1); | ||
} | ||
|
||
/** | ||
* Switches to the previous page if it exists. | ||
* | ||
* @return Returns true when the page was changed | ||
*/ | ||
default boolean switchToPreviousPage() { | ||
return switchToPage(getCurrentPage() - 1); | ||
} | ||
|
||
/** | ||
* Returns the index of the current page. | ||
*/ | ||
default int getCurrentPage() { | ||
throw new AssertionError("Implemented by mixin"); | ||
} | ||
|
||
/** | ||
* Returns the total number of pages. | ||
*/ | ||
default int getPageCount() { | ||
throw new AssertionError("Implemented by mixin"); | ||
} | ||
|
||
/** | ||
* Returns an ordered list containing the item groups on the requested page. | ||
*/ | ||
default List<ItemGroup> getItemGroupsOnPage(int page) { | ||
throw new AssertionError("Implemented by mixin"); | ||
} | ||
|
||
/** | ||
* Returns the page index of the given item group. | ||
* | ||
* <p>Item groups appearing on every page always return the current page index. | ||
* | ||
* @param itemGroup the item group to get the page index for | ||
* @return the page index of the item group | ||
*/ | ||
default int getPage(ItemGroup itemGroup) { | ||
throw new AssertionError("Implemented by mixin"); | ||
} | ||
|
||
/** | ||
* Returns whether there are additional pages to show on top of the default vanilla pages. | ||
* | ||
* @return true if there are additional pages | ||
*/ | ||
default boolean hasAdditionalPages() { | ||
throw new AssertionError("Implemented by mixin"); | ||
} | ||
|
||
/** | ||
* Returns the {@link ItemGroup} that is associated with the currently selected tab. | ||
* | ||
* @return the currently selected {@link ItemGroup} | ||
*/ | ||
default ItemGroup getSelectedItemGroup() { | ||
throw new AssertionError("Implemented by mixin"); | ||
} | ||
|
||
/** | ||
* Sets the currently selected tab to the given {@link ItemGroup}. | ||
* | ||
* @param itemGroup the {@link ItemGroup} to select | ||
* @return true if the tab was successfully selected | ||
*/ | ||
default boolean setSelectedItemGroup(ItemGroup itemGroup) { | ||
throw new AssertionError("Implemented by mixin"); | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
...i-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/CreativeGuiExtensions.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.