-
Notifications
You must be signed in to change notification settings - Fork 180
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
Port/Rework Crafting Station to MUI2 #2455
base: master
Are you sure you want to change the base?
Changes from 137 commits
038b268
0937104
3acd0e3
4363a18
e2f9ae1
9fc9a8e
ec22458
71a3b66
ebd88df
e732e90
74b92db
5b9400f
56e7a4b
50624a1
51a279a
ecce71f
ba8857a
2417953
2edbafc
6207fc2
f97a9b9
ee3304c
0ed6d7e
a05dd05
d4c0347
5123332
37e7d14
bc857c2
b0d714b
125d674
19ff620
6bb5e75
f59bdd0
b14764d
54dd165
e97a609
764ffff
3879d17
989eea3
23e2bcf
c210058
8140c03
7e5c6a5
7d79d71
a7d046f
4bbea34
7ab4294
3fdbd22
45def91
b5ceb78
c8206a1
ab9c9a1
f1bc271
ea1ee98
e2d9cbf
706c75c
037ab09
e529cf0
f5d2a30
e10a620
f93e80e
7977dbc
708a839
4ba7bb8
bf2bb21
e29f315
eff13d0
ecd7a13
96e8704
4490b41
c887610
819729c
11e8abc
195c39a
03184d4
2a8631c
7c20265
d4233dd
f99dde1
e7bed88
9fe4db5
c258ff8
a96d5aa
2498d17
37c0979
27eeb2c
d4598dd
bbc385d
13fa0a6
ccd41a4
4278d0a
c45ad6b
06c81a7
809596c
1abd515
a9702b5
f14f4c6
2963bcd
af7fc40
d8a0adc
e27d620
be88e55
0e6d154
94d092c
c296eed
e83f40a
0dd7249
2b5c151
26f2c74
67f0cb4
9123ddd
3e10b99
0a7d0dc
bb6fdbc
73f8bb4
55b29c8
0e20b05
3548eaf
64fec77
35aed6e
88c2492
e217b29
c06c1d8
c8960c8
f42df8c
a3ee25f
58328de
f1b262d
b545de7
647a14f
87b8c48
492286f
478a54d
876b785
8d92a30
9dda6ae
e3039a6
e59aebd
585bdd4
f84a3a9
e7a875d
6dacf63
445c94c
fb29c8f
eb43be9
4d8b07f
0852124
367ea78
8f42a8e
a0cb66b
09a8ee5
6162861
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package gregtech.api.mui; | ||
|
||
import gregtech.common.metatileentities.storage.CraftingRecipeLogic; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.inventory.InventoryCrafting; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.network.PacketBuffer; | ||
|
||
import com.cleanroommc.modularui.network.NetworkUtils; | ||
import com.cleanroommc.modularui.screen.ModularContainer; | ||
import com.cleanroommc.modularui.value.sync.PanelSyncManager; | ||
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; | ||
private InventoryCrafting craftingMatrix; | ||
|
||
public GregTechGuiTransferHandler(IRecipeTransferHandlerHelper handlerHelper) { | ||
this.handlerHelper = handlerHelper; | ||
} | ||
|
||
@Override | ||
public @NotNull Class<ModularContainer> getContainerClass() { | ||
return ModularContainer.class; | ||
} | ||
|
||
@Override | ||
public @Nullable IRecipeTransferError transferRecipe(ModularContainer container, IRecipeLayout recipeLayout, | ||
EntityPlayer player, boolean maxTransfer, boolean doTransfer) { | ||
String key = PanelSyncManager.makeSyncKey("recipe_logic", 0); | ||
CraftingRecipeLogic recipeLogic = (CraftingRecipeLogic) container.getSyncManager() | ||
.getSyncHandler("workbench", key); | ||
|
||
if (!doTransfer) { | ||
// todo highlighting in JEI? | ||
return null; | ||
} | ||
|
||
var ingredients = recipeLayout.getItemStacks().getGuiIngredients(); | ||
this.craftingMatrix = recipeLogic.getCraftingMatrix(); | ||
|
||
for (int i = 0; i < craftingMatrix.getSizeInventory(); i++) { | ||
var ing = ingredients.get(i + 1).getDisplayedIngredient(); | ||
this.craftingMatrix.setInventorySlotContents(i, ing == null ? ItemStack.EMPTY : ing); | ||
} | ||
|
||
recipeLogic.syncToServer(CraftingRecipeLogic.UPDATE_MATRIX, this::writeCraftingMatrix); | ||
recipeLogic.updateCurrentRecipe(); | ||
return null; | ||
} | ||
|
||
private void writeCraftingMatrix(PacketBuffer buffer) { | ||
buffer.writeVarInt(this.craftingMatrix.getSizeInventory()); | ||
for (int i = 0; i < this.craftingMatrix.getSizeInventory(); i++) { | ||
var stack = this.craftingMatrix.getStackInSlot(i); | ||
NetworkUtils.writeItemStack(buffer, stack); | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ static ItemStackHashStrategy comparingItemDamageCount() { | |
*/ | ||
class ItemStackHashStrategyBuilder { | ||
|
||
private boolean item, count, damage, tag; | ||
private boolean item, count, damage, tag, meta; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is damage not enough? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iirc because of GT Tools or something like that, i made this change a long time ago. |
||
|
||
/** | ||
* Defines whether the Item type should be considered for equality. | ||
|
@@ -93,6 +93,17 @@ public ItemStackHashStrategyBuilder compareDamage(boolean choice) { | |
return this; | ||
} | ||
|
||
/** | ||
* Defines whether metadata values should be considered for equality. | ||
* | ||
* @param choice {@code true} to consider this property, {@code false} to ignore it. | ||
* @return {@code this} | ||
*/ | ||
public ItemStackHashStrategyBuilder compareMetadata(boolean choice) { | ||
meta = choice; | ||
return this; | ||
} | ||
|
||
/** | ||
* Defines whether NBT Tags should be considered for equality. | ||
* | ||
|
@@ -116,7 +127,8 @@ public int hashCode(@Nullable ItemStack o) { | |
item ? o.getItem() : null, | ||
count ? o.getCount() : null, | ||
damage ? o.getItemDamage() : null, | ||
tag ? o.getTagCompound() : null); | ||
tag ? o.getTagCompound() : null, | ||
meta ? o.getMetadata() : null); | ||
} | ||
|
||
@Override | ||
|
@@ -127,6 +139,7 @@ public boolean equals(@Nullable ItemStack a, @Nullable ItemStack b) { | |
return (!item || a.getItem() == b.getItem()) && | ||
(!count || a.getCount() == b.getCount()) && | ||
(!damage || a.getItemDamage() == b.getItemDamage()) && | ||
(!meta || a.getMetadata() == b.getMetadata()) && | ||
(!tag || Objects.equals(a.getTagCompound(), b.getTagCompound())); | ||
} | ||
}; | ||
|
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.
This is added as a dep, but nothing is done with it in this PR that I can see, do we still need it?
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.
this is required due to ModularContainer implementing a bogosorter interface, which is loaded from
GregTechGuiTransferHandler