-
Notifications
You must be signed in to change notification settings - Fork 204
Update to MUI 3.0.6 and generify recipe transfers from JEI #2900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Zorbatron
wants to merge
13
commits into
master
Choose a base branch
from
zb/mui-universal-recipe-transferring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d6cdaad
Reimplement `IRecipeTransferReceiver`
Zorbatron 93917c3
skip on any internal error
Zorbatron 0107888
Add RecipeTransferSyncHandler
Zorbatron b8d6a3a
Refactor CraftingRecipeLogic to use RecipeTransferSyncHandler
Zorbatron 5ad8370
Remove reference map because the fastutils reference maps don't clear…
Zorbatron 930935b
Wrap (un)registration in a client-side check
Zorbatron f9a10b5
Only clear the receivers when the UI is actually being closed
Zorbatron 79403b7
Update to MUI 3.0.5
Zorbatron 80cdbb1
Reword IRecipeTransferReceiver javadoc
Zorbatron 633ae5a
Reword IRecipeTransferReceiver javadoc pt2
Zorbatron 9243635
MUI 3.0.6
Zorbatron 4363e27
touch up IRecipeTransferReceiver javadoc
Zorbatron f6943c1
Remove name set from panel in MultiblockUIFactory
Zorbatron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
69 changes: 0 additions & 69 deletions
69
src/main/java/gregtech/api/mui/GregTechGuiTransferHandler.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
src/main/java/gregtech/api/mui/IRecipeTransferReceiver.java
This file contains hidden or 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,53 @@ | ||
| package gregtech.api.mui; | ||
|
|
||
| import gregtech.api.mui.sync.RecipeTransferSyncHandler; | ||
| import gregtech.integration.jei.JustEnoughItemsModule; | ||
|
|
||
| import net.minecraftforge.fml.relauncher.Side; | ||
| import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
|
||
| import com.cleanroommc.modularui.value.sync.SyncHandler; | ||
| import com.cleanroommc.modularui.widget.Widget; | ||
| import mezz.jei.api.gui.IRecipeLayout; | ||
| import mezz.jei.api.recipe.transfer.IRecipeTransferError; | ||
| import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| import java.util.Collection; | ||
|
|
||
| /** | ||
| * An interface for receiving a recipe from a recipe viewer to anything on the panel, such as a {@link Widget} or | ||
| * {@link SyncHandler}. <br/> | ||
| * Register it via {@link GregTechGuiScreen#registerRecipeTransferHandler(String, IRecipeTransferReceiver)} or | ||
| * {@link GregTechGuiScreen#registerRecipeTransferHandler(String, IRecipeTransferReceiver, int)} if you want to | ||
| * prioritize checking a certain handler first. <br/> | ||
| * If you're implementing this on a {@link SyncHandler}, it's recommended to extend {@link RecipeTransferSyncHandler} | ||
| * instead as registering and unregistering from {@link GregTechGuiScreen} is done for you. | ||
| */ | ||
| public interface IRecipeTransferReceiver { | ||
|
|
||
| /** | ||
| * Attempt or simulate transferring a recipe from a recipe viewer like JEI or HEI. <br/> | ||
| * A factory for default {@link IRecipeTransferError}s is available at {@link JustEnoughItemsModule#transferHelper}. | ||
| * There are three default options for errors: <br/> | ||
| * - {@link IRecipeTransferHandlerHelper#createInternalError()}: mark the recipe as invalid for transferring by | ||
| * graying out the + button. <br/> | ||
| * - {@link IRecipeTransferHandlerHelper#createUserErrorWithTooltip(String)}: the same as above, but also display a | ||
| * message when hovering over the + button. <br/> | ||
| * - {@link IRecipeTransferHandlerHelper#createUserErrorForSlots(String, Collection)}: the same as above, but | ||
| * additionally highlight certain slots in the recipe to, for example, mark missing ingredients. <b>Important: will | ||
| * throw {@link IllegalArgumentException} if the supplied {@link Collection} is empty!</b> | ||
| * | ||
| * @param recipeLayout the recipe layout that contains the recipe category, and the item and fluid stacks. | ||
| * @param maxTransfer if the receiver should try to move as many ingredients as possible to the crafting slots, ie | ||
| * shift clicking a recipe into a crafting table. | ||
| * @param simulate if this recipe should only simulate being transferred | ||
| * @return {@code null} if the transfer should succeed or an {@link IRecipeTransferError} if not. If there are | ||
| * multiple registered recipe transfer receivers on the same panel, returning an error with type | ||
| * {@link IRecipeTransferError.Type#INTERNAL} will skip this and attempt the next one. | ||
| */ | ||
| @Nullable | ||
| @SideOnly(Side.CLIENT) | ||
| IRecipeTransferError receiveRecipe(@NotNull IRecipeLayout recipeLayout, boolean maxTransfer, boolean simulate); | ||
| } |
This file contains hidden or 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
40 changes: 40 additions & 0 deletions
40
src/main/java/gregtech/api/mui/sync/RecipeTransferSyncHandler.java
This file contains hidden or 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,40 @@ | ||
| package gregtech.api.mui.sync; | ||
|
|
||
| import gregtech.api.mui.GregTechGuiScreen; | ||
| import gregtech.api.mui.IRecipeTransferReceiver; | ||
|
|
||
| import com.cleanroommc.modularui.value.sync.PanelSyncManager; | ||
| import com.cleanroommc.modularui.value.sync.SyncHandler; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.MustBeInvokedByOverriders; | ||
|
|
||
| /** | ||
| * A base class for to handle implementing {@link IRecipeTransferReceiver} on a {@link SyncHandler}s to automatically | ||
| * register and unregister it from the map of valid handlers in {@link GregTechGuiScreen}. | ||
| */ | ||
| public abstract class RecipeTransferSyncHandler extends SyncHandler implements IRecipeTransferReceiver { | ||
|
|
||
| @ApiStatus.OverrideOnly | ||
| @MustBeInvokedByOverriders | ||
| @Override | ||
| public void init(String key, PanelSyncManager syncManager) { | ||
| super.init(key, syncManager); | ||
| if (syncManager.isClient()) { | ||
| GregTechGuiScreen.registerRecipeTransferHandler(getKey(), this, getTransferHandlerPriority()); | ||
| } | ||
| } | ||
|
|
||
| protected int getTransferHandlerPriority() { | ||
| return 0; | ||
| } | ||
|
|
||
| @ApiStatus.OverrideOnly | ||
| @MustBeInvokedByOverriders | ||
| @Override | ||
| public void dispose() { | ||
| if (getSyncManager().isClient()) { | ||
| GregTechGuiScreen.removeRecipeTransferHandler(getKey()); | ||
| } | ||
| super.dispose(); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class is already annotated side only client, do we need to annotate this field as well?