-
Notifications
You must be signed in to change notification settings - Fork 204
Port/Rework Crafting Station to MUI2 + Misc Fixes #2455
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
Merged
ghzdude
merged 180 commits into
GregTechCEu:master
from
ghzdude:gh-crafting-station-mui-port
Feb 19, 2025
Merged
Changes from all commits
Commits
Show all changes
180 commits
Select commit
Hold shift + click to select a range
9fe3ca0
initial work on workbench port
ghzdude 15e1a2e
make crafting logic not server only
ghzdude 7244de3
fix crafting output slot
ghzdude f321ece
add class for jei recipe transfer
ghzdude 5534582
update recipe appropriately
ghzdude 571aec8
more work on ui
ghzdude 9cacb7f
wrap InventoryCrafting
ghzdude bf72c78
more work on output crafting slot
ghzdude 0d43da0
test extending modularslot
ghzdude ff8a469
more work on crafting logic
ghzdude b3b32f2
add method to get inventory
ghzdude bf035b6
implement method
ghzdude 2f23636
sync crafting matrix
ghzdude c9ed5a9
fix some issues with the output slot
ghzdude 849594a
more work on crafting logic woo
ghzdude 7589dae
crafting logic mostly done now?
ghzdude 6a8cd1f
work on workbench ui
ghzdude 8842db7
make handlerlist nonfinal
ghzdude 2c11ebe
add method to update cache handler
ghzdude c01808c
even more ui work
ghzdude 6787f7c
the great commenting of 2024
ghzdude 2da5cf1
update stack index
ghzdude 18d1f57
revert change to itemCrafting
ghzdude 380447b
simplify crafting logic slightly
ghzdude 29acb35
more work on recipe logic
ghzdude 98a7c71
move logic/fields in CachedRecipeData to CraftingRecipeLogic
ghzdude 3ea0800
fix sync issue
ghzdude 40d2372
properly fix sync issues
ghzdude 7abfa4b
remove GregTechGuiTransferrableScreen.java and usages
ghzdude 33561e1
implement jei compat directly
ghzdude 2e0ac1a
add slot group for crafting matrix
ghzdude 489af03
uncomment a portion of code
ghzdude e98c1bd
add recipe transferring from JEI
ghzdude 07ec049
remove todo
ghzdude 2a1b990
update handler on client
ghzdude 2006809
remove available item map
ghzdude 29e13bc
unique sync codes
ghzdude 9593818
try implement storage view
ghzdude 33dfea6
fully implement storage view
ghzdude 640aff5
add method to get result stack
ghzdude 7b6b2d0
fix issues with tools being damages
ghzdude 1d0ce69
more work on ui
ghzdude db6bdc2
help me
ghzdude a1a86d8
only set stack if item is different from current
ghzdude 45f90d6
don't throw exception
ghzdude c6f3d7d
notify neighbors on slot change
ghzdude 9d219e0
make handler modifiable
ghzdude b3b9800
sync on contents change
ghzdude 6143c41
don't call change on init
ghzdude b48304f
start work on recipe memorization
ghzdude 2c4c4c1
small work
ghzdude eca5c00
add handler wrapper to handle incorrect slot gracefully
ghzdude e33263e
spotless
ghzdude f9116ae
add bogosorter as api
ghzdude 41cf9aa
remove commented out code
ghzdude 84f731c
ui testing
ghzdude bc86fbf
more ui testing
ghzdude feafa79
fixed(?) the grid
ghzdude 55993b7
grid fixed
ghzdude 1e512bb
more work on syncing and recipe logic
ghzdude 375ab38
more work on syncing and recipe logic part 2 + spotless
ghzdude dad6f8d
simplify client syncing
ghzdude e2a2049
move crafting output slot into own class
ghzdude 8606c55
we do a little refactoring
ghzdude 99a4f8e
remove unused class
ghzdude f1d4655
move inventory wrapper class
ghzdude 029ef96
collect items before each craft
ghzdude 4e096ea
small fixes
ghzdude e0a9b41
small fixes part 2
ghzdude 37703d2
small fixes part 3
ghzdude b4edef9
initial work on recipe memory
ghzdude c4698b3
make memory a sync handler
ghzdude f994568
more syncing fixes
ghzdude 6b6f6ae
just crafting station things
ghzdude 8548a20
improve crafting logic
ghzdude bdc5bbf
small rendering changes and other fixes
ghzdude a798ed3
fix rendering issues
ghzdude 525781c
add locking rendering to memory slots
ghzdude eaba7ae
spotless
ghzdude 92157a6
add crafting input slot
ghzdude 620036c
work on various custom slots
ghzdude 1136702
display and sync recipe memory times used
ghzdude 8f9de58
fix tooltips for output and memory slots
ghzdude 9479c89
sbobl
ghzdude eb34ae3
move changes to item handler list
ghzdude 16b45dd
collect shift click slots manually
ghzdude a6aed65
integrate input slots with JEI
ghzdude 30aa8a9
delete unused classes
ghzdude 6877c8b
sboblss
ghzdude 1ed3333
handle buckets properly
ghzdude 1f4ea14
imrove wrapper and some javadocs
ghzdude 3c8118f
Tinting (#2)
bruberu f096b03
fix overlay
ghzdude fbec6ad
casually rewrite recipe logic a bit :handsom:
ghzdude b16c5be
even more work on recipe logic
ghzdude 86b1190
update todo
ghzdude 7004a9a
make sure to use copy
ghzdude b210279
try and fail at shift transfer
ghzdude cc042d9
consume items correctly
ghzdude 8b8eae6
sbobless
ghzdude 055b86a
small fixes
ghzdude e29c370
add jei support for output slot
ghzdude 7b5c11e
remove comment
ghzdude 3a0b94c
make strategy ignore tag
ghzdude adc147f
remove the recipe on client
ghzdude 88ff083
mostly fix recipe memory
ghzdude 39d9627
add metadata to hash strategy
ghzdude 2b9977f
minor fixes
ghzdude 0476ce2
fix: all the bugs (#3)
bruberu f9530b6
fix rebase
ghzdude 782d195
sootless
ghzdude 53f1edd
epic rebase + spotless
ghzdude 85ed6d5
improve recipe logic slightly
ghzdude 7f273da
a few more optimizations
ghzdude 72babe5
spblss
ghzdude dae5726
allow cache miss to set any stack it comes across, instead of just th…
ghzdude 3cc5336
remove stack key if int set is empty
ghzdude 572721b
fix rebase
ghzdude ddcf9a0
fix crafting widgets
ghzdude 9f8aefb
missed a column
ghzdude dd973b3
use mui2 methods to draw item
ghzdude fa9557f
remove unneeded method
ghzdude 4bf95a3
add todo lang
ghzdude 627d2c1
cleanup CraftingOutputSlot
ghzdude 1eda013
spotless
ghzdude 595e3c6
remove workbench from JEI module
ghzdude a2da02b
remove unneeded override
ghzdude cf4bf30
name internal ids
ghzdude a411120
make constructor private
ghzdude 71f5281
rename and cleanup
ghzdude e0933bc
cleanup and sort inventory list
ghzdude 00cb341
fix lock not syncing
ghzdude 2c7e4c8
oops
ghzdude 1e6fc59
add button to clear grid
ghzdude 5261d3a
implement multi-crafting with shift
ghzdude 2f6b663
fix off by one crafting
ghzdude ac2b1e9
use modified draw item method
ghzdude a518150
reset ingredients
ghzdude f90dbf1
improve recipe memory offsetting
ghzdude 1154606
no need to move recipes at index 0
ghzdude 631ec1d
check and simulate if output can be inserted
ghzdude baccef0
clear and refresh the lookup map every tick
ghzdude 5905980
fix issue with output slot not crafting when not holding shift
ghzdude 0b5caea
more lang, remove todo
ghzdude f784b29
implement dragging for input slots
ghzdude dc2bf71
add todo
ghzdude ea54e87
fix toolbelt slot group
ghzdude 5305077
fix tools not making crafting sounds
ghzdude 213b735
fix item overlay rendering
ghzdude 24f3e46
don't transfer if not in workbench
ghzdude 98c17ed
make RecipeMemorySlot a jei ingredient provider
ghzdude 2ac7f5d
fix duplicate recipe memory
ghzdude 9148c5d
implement the fixes for phantom slots from mui2 master
ghzdude 6ce953e
fix compile and add note
ghzdude 8fa76a6
fix stack syncing
ghzdude 4d062c2
fix scroll bar covering slots
ghzdude 0d5d3b8
spotless
ghzdude 0b013ec
fix substitute searching and finding required items
ghzdude dc6bb1f
only cast ingredient if enabled
ghzdude e85f863
don't set z level
ghzdude 3b015b9
set active page to crafting when setting recipe from JEI
ghzdude b580b57
notify recipe logic when loading memorized recipes
ghzdude 1079bca
sync handler on recipe logic construction
ghzdude d60abe1
simplify ToolItemStackHandler
ghzdude b34d7c9
sync slot and player for toolbelt
ghzdude e6589f0
don't reset selected slot in toolbelt
ghzdude 95aea37
fix and improve the recipe repair mixin
ghzdude c6e68f3
send handler updates on network rebuild
ghzdude 3cf0134
format amount crafted better
ghzdude ca9996e
add line for removing recipe
ghzdude d793acf
only sync mouse click if recipe is valid
ghzdude 845c974
fix output slot shift clicking with full cursor item
ghzdude 5443fb9
merge if statements
ghzdude b488da6
improve and clarify sync cursor item
ghzdude 2f2df84
annotations
ghzdude f750d95
improve formatting a bit more
ghzdude 36d713c
simplify CraftingOutputSlot MS and SH constructor
ghzdude aabe723
remove unused method
ghzdude 4018512
fix oversight in ItemHandlerList
ghzdude a6dbac5
clarify gui actions and simplify syncing changes
ghzdude 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
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
68 changes: 0 additions & 68 deletions
68
src/main/java/gregtech/api/gui/widgets/CraftingStationInputWidgetGroup.java
This file was deleted.
Oops, something went wrong.
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: 69 additions & 0 deletions
69
src/main/java/gregtech/api/mui/GregTechGuiTransferHandler.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,69 @@ | ||
| package gregtech.api.mui; | ||
|
|
||
| import gregtech.api.mui.sync.PagedWidgetSyncHandler; | ||
| import gregtech.common.metatileentities.storage.CraftingRecipeLogic; | ||
|
|
||
| import net.minecraft.entity.player.EntityPlayer; | ||
| import net.minecraft.item.ItemStack; | ||
|
|
||
| import com.cleanroommc.modularui.screen.ModularContainer; | ||
| import com.cleanroommc.modularui.value.sync.PanelSyncManager; | ||
| import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; | ||
| import it.unimi.dsi.fastutil.ints.Int2ObjectMap; | ||
| import mezz.jei.api.gui.IGuiItemStackGroup; | ||
| import mezz.jei.api.gui.IRecipeLayout; | ||
| import mezz.jei.api.recipe.transfer.IRecipeTransferError; | ||
| import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; | ||
| import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| public class GregTechGuiTransferHandler implements IRecipeTransferHandler<ModularContainer> { | ||
|
|
||
| private final IRecipeTransferHandlerHelper handlerHelper; | ||
|
|
||
| public GregTechGuiTransferHandler(IRecipeTransferHandlerHelper handlerHelper) { | ||
| this.handlerHelper = handlerHelper; | ||
| } | ||
|
|
||
| @Override | ||
| public @NotNull Class<ModularContainer> getContainerClass() { | ||
| return ModularContainer.class; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable IRecipeTransferError transferRecipe(ModularContainer container, | ||
| @NotNull IRecipeLayout recipeLayout, | ||
| @NotNull EntityPlayer player, boolean maxTransfer, | ||
| boolean doTransfer) { | ||
| if (!container.getSyncManager().isOpen("workbench")) { | ||
| return null; | ||
| } | ||
| PanelSyncManager syncManager = container.getSyncManager().getPanelSyncManager("workbench"); | ||
| var recipeLogic = (CraftingRecipeLogic) syncManager.getSyncHandler("recipe_logic:0"); | ||
| var pageController = (PagedWidgetSyncHandler) syncManager.getSyncHandler("page_controller:0"); | ||
|
|
||
| if (!doTransfer) { | ||
| // todo highlighting in JEI? | ||
| return null; | ||
| } | ||
|
|
||
| var matrix = extractMatrix(recipeLayout.getItemStacks()); | ||
| recipeLogic.fillCraftingGrid(matrix); | ||
| pageController.setPage(0); | ||
| return null; | ||
| } | ||
|
|
||
| private Int2ObjectMap<ItemStack> extractMatrix(IGuiItemStackGroup stackGroup) { | ||
| var ingredients = stackGroup.getGuiIngredients(); | ||
| Int2ObjectMap<ItemStack> matrix = new Int2ObjectArrayMap<>(9); | ||
| for (var slot : ingredients.keySet()) { | ||
| if (slot != 0) { | ||
| var ing = ingredients.get(slot).getDisplayedIngredient(); | ||
| if (ing == null) continue; | ||
| matrix.put(slot - 1, ingredients.get(slot).getDisplayedIngredient()); | ||
| } | ||
| } | ||
| return matrix; | ||
| } | ||
| } |
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,23 @@ | ||
| package gregtech.api.mui; | ||
|
|
||
| import com.cleanroommc.modularui.api.widget.Interactable; | ||
| import com.cleanroommc.modularui.screen.viewport.LocatedWidget; | ||
|
|
||
| // todo remove on next mui2 update | ||
| // this can't be a true accessor because of illegal classloading | ||
| public interface InputAccessor { | ||
|
|
||
| boolean held(); | ||
|
|
||
| void held(boolean held); | ||
|
|
||
| void timeHeld(long a); | ||
|
|
||
| LocatedWidget lastPressed(); | ||
|
|
||
| void lastPressed(LocatedWidget last); | ||
|
|
||
| void lastButton(int b); | ||
|
|
||
| void addInteractable(Interactable i); | ||
| } |
45 changes: 45 additions & 0 deletions
45
src/main/java/gregtech/api/mui/sync/PagedWidgetSyncHandler.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,45 @@ | ||
| package gregtech.api.mui.sync; | ||
|
|
||
| import net.minecraft.network.PacketBuffer; | ||
|
|
||
| import com.cleanroommc.modularui.value.sync.SyncHandler; | ||
| import com.cleanroommc.modularui.widgets.PagedWidget; | ||
|
|
||
| public class PagedWidgetSyncHandler extends SyncHandler { | ||
|
|
||
| private final PagedWidget.Controller controller; | ||
| public static final int SET_PAGE = 0; | ||
|
|
||
| public PagedWidgetSyncHandler(PagedWidget.Controller controller) { | ||
| this.controller = controller; | ||
| } | ||
|
|
||
| @Override | ||
| public void readOnClient(int id, PacketBuffer buf) { | ||
| if (id == SET_PAGE) { | ||
| setPage(buf.readVarInt(), false); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void readOnServer(int id, PacketBuffer buf) { | ||
| if (id == SET_PAGE) { | ||
| setPage(buf.readVarInt(), false); | ||
| } | ||
| } | ||
|
|
||
| public void setPage(int page) { | ||
| setPage(page, true); | ||
| } | ||
|
|
||
| public void setPage(int page, boolean sync) { | ||
| if (controller.isInitialised() && page != getPage()) { | ||
| controller.setPage(page); | ||
| if (sync) sync(SET_PAGE, buffer -> buffer.writeVarInt(page)); | ||
| } | ||
| } | ||
|
|
||
| public int getPage() { | ||
| return controller.getActivePageIndex(); | ||
| } | ||
| } |
This file was deleted.
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.
Uh oh!
There was an error while loading. Please reload this page.