Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
4e2b59e
start on input bus
Zorbatron May 11, 2025
7ace9e0
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron May 19, 2025
b911ee4
Item Input: extra slot, circuit, arrow
Zorbatron May 19, 2025
4ea4d7a
Item Input: extra slot, circuit, arrow
Zorbatron May 19, 2025
035b97b
Finalize AEHostablePart split
Zorbatron May 19, 2025
86431e7
Fix TOP/WAILA providers
Zorbatron May 19, 2025
673a818
Wrong super call from ctrl c+v :icant:
Zorbatron May 19, 2025
292edfe
Add if the part can connect from all sides to TOP/WAILA
Zorbatron May 19, 2025
29b3661
Start on config and display widget
Zorbatron May 20, 2025
89d276a
Sprinkle in some nullables
Zorbatron May 20, 2025
0d62422
Item slot jei dragging (ish, just logging for now :troll:)
Zorbatron May 20, 2025
bc1ccf1
Use the probably more proper tooltip making method
Zorbatron May 20, 2025
1118599
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron May 20, 2025
2a9d4ba
This doesn't need to be dynamic
Zorbatron May 20, 2025
1027d09
JEI dropping works (no item rendering yet)
Zorbatron May 20, 2025
05e49ec
Chat we're rending items now :caught:
Zorbatron May 20, 2025
b38b8a6
Item tooltips (not dynamic oops)
Zorbatron May 20, 2025
2c3b55f
Extract the sync handler out pt1
Zorbatron May 20, 2025
501314b
Sync work pt2
Zorbatron May 20, 2025
009447e
Sync work pt3 and tooltips that actually work
Zorbatron May 20, 2025
ba1c854
Remove redundant code, remove MUI0 code from ME Input Buses, and impl…
Zorbatron May 21, 2025
14f6f12
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron May 21, 2025
58b0362
Scrolling (almost why no sync ug)
Zorbatron May 21, 2025
c2da636
Fix the cache not being set to a copy which caused scrolling to get a…
Zorbatron May 21, 2025
9e70ef5
Set MTE dirty when setting the config to prevent it from being lost i…
Zorbatron May 21, 2025
ff3e645
Stocking auto pull
Zorbatron May 21, 2025
727566d
Fluid display slot
Zorbatron May 21, 2025
30de112
Fluid config slot
Zorbatron May 21, 2025
6cedd49
More fluid stuff, a couple fixes. Um it almost works but the renderin…
Zorbatron May 21, 2025
dae9d07
wowie spotless
Zorbatron May 21, 2025
9814db3
Fix wrong child ordering in fluid hatch
Zorbatron May 21, 2025
4b47b31
Slot hover overlay
Zorbatron May 21, 2025
07c000a
Fix stocking auto pull button size
Zorbatron May 21, 2025
00f65fe
Proper spacing on the center widgets
Zorbatron May 21, 2025
09c8491
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron May 21, 2025
1a19ecb
Erm tons of sync handler changes
Zorbatron May 23, 2025
4e621c6
Code dedup pt2
Zorbatron May 23, 2025
4a02368
Sync work pt4 (use one sync handler for all 16 config slots instead o…
Zorbatron May 24, 2025
d5f2839
Move overlay stuff into drawOverlay
Zorbatron May 24, 2025
b1e6851
Amount select popup
Zorbatron May 26, 2025
dc84c37
better drawing widget
Zorbatron May 26, 2025
0aef783
Better amount entering
Zorbatron May 27, 2025
301f9e0
more popup changes
Zorbatron May 27, 2025
87ce226
popup changes pt2 - better drawer again
Zorbatron May 27, 2025
d6462c9
popup changes pt3 - proper draw-er
Zorbatron May 27, 2025
eb83040
Various tooltip changes, and give the popup slot tooltips
Zorbatron May 28, 2025
2b39f26
Logo was the wrong size in the hatches
Zorbatron May 28, 2025
b0938a9
Don't allot amount popup to be opened if stocking
Zorbatron May 28, 2025
6583559
Use better ID name
Zorbatron May 28, 2025
ec253b7
Move cache and byte buf adapter initialization into AESyncHandler cli…
Zorbatron May 28, 2025
0a237f0
Remove unused onClient field
Zorbatron May 28, 2025
04a00bf
Set IDs manually
Zorbatron May 28, 2025
75e107e
Port only allowing a stack if no other slot in the bus/hatch if no ot…
Zorbatron May 29, 2025
a911fab
Remove redundant constructor for me input bus and hatch
Zorbatron May 31, 2025
1872e45
Setting popup start
Zorbatron May 31, 2025
d02ae2a
Simpler amount panel syncing
Zorbatron May 31, 2025
091a3b8
Actually good settings popup
Zorbatron Jun 1, 2025
fcf4218
Use the proper method for creating popup panels (that share the sync …
Zorbatron Jun 1, 2025
071b3fa
YAY NO MORE DESYNCING!! WOOHOO HEEHEEHAA!!!
Zorbatron Jun 1, 2025
d820421
Remove useless override
Zorbatron Jun 2, 2025
4c5bc26
Merge remote-tracking branch 'origin/zb/me-hatch-mui2' into zb/me-hat…
Zorbatron Jun 2, 2025
90d7865
Remove tooltip since it didn't even work somehow
Zorbatron Jun 2, 2025
7e73d0f
spotbees
Zorbatron Jun 2, 2025
02ae4b2
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron Jun 2, 2025
173134e
Fix margin being off by 1px
Zorbatron Jun 2, 2025
4060f82
Start on JEI recipe transfer refactor
Zorbatron Jun 2, 2025
94f8edc
mixin stuff
Zorbatron Jun 2, 2025
79b9ae3
Progress I think
Zorbatron Jun 3, 2025
c82070c
more mixin stuff
Zorbatron Jun 3, 2025
bf840f0
Hoo-rah it works
Zorbatron Jun 3, 2025
181d916
Make only crafting recipes have the + button in the crafting station
Zorbatron Jun 3, 2025
b37ee24
Probably works
Zorbatron Jun 4, 2025
c4c55a3
Separate the MUI2 accessor methods out into a utility class
Zorbatron Jun 4, 2025
ecedea2
Spotless
Zorbatron Jun 4, 2025
e376f17
Fix critical math error in collapseItemList
Zorbatron Jun 4, 2025
b36f631
Clear unused slots
Zorbatron Jun 4, 2025
a490d62
Do recipe transfer stuff for fluids
Zorbatron Jun 4, 2025
5862646
Check that the stack isn't empty before adding it to the inputs list
Zorbatron Jun 4, 2025
6c9534e
Fix grammatical error in javadoc
Zorbatron Jun 4, 2025
a7242a0
Remove unused data codes since I used MUI2 SyncHandlers for them instead
Zorbatron Jun 4, 2025
08787b7
Rename IAEStackByteBufAdapter to AEStackByteBufAdapter since it's a c…
Zorbatron Jun 4, 2025
2978b24
Use `GTUtility.safeCastLongToInt` in `AESyncHandler#getConfigAmount(i…
Zorbatron Jun 4, 2025
8707fa5
Use the bus/hatch item as the settings popup icon
Zorbatron Jun 4, 2025
7cbf921
Pull the preview widget implementations into their own class
Zorbatron Jun 4, 2025
8c50044
Delete the old MUI0 AE2 widgets
Zorbatron Jun 4, 2025
765f255
Improve JEIUtil and collapse methods. Separate ghost circuit items out.
Zorbatron Jun 6, 2025
ad31cc7
Slightly more efficient config setting from recipe transfer
Zorbatron Jun 6, 2025
1d9f1b5
Remove duplicate call and redundant method
Zorbatron Jun 11, 2025
55b574c
use hasconfig
Zorbatron Jun 11, 2025
1b7140f
Reduce copying and use override convenience method
Zorbatron Jun 11, 2025
267b9d0
Spotless
Zorbatron Jun 11, 2025
63106cc
Move the tier of the stocking parts into the constructor too
Zorbatron Jun 11, 2025
331e14b
Fix usage of I18n on servers
Zorbatron Jun 11, 2025
2feeffe
Fix regression in 55b574c4 which broke scrolling
Zorbatron Jun 11, 2025
97e7904
Use childIf
Zorbatron Jun 12, 2025
ce3aae6
Use RecipeTransferErrorInternal#INSTANCE for hiding the + button
Zorbatron Jun 12, 2025
3bdd129
Delete EmptyWidget
Zorbatron Jun 12, 2025
de60ad0
Doubling and dividing, no texture or lang
Zorbatron Jun 13, 2025
9d1033e
Minor SH changes
Zorbatron Jun 14, 2025
2308b1e
Work on better multiplier controls
Zorbatron Jun 14, 2025
ec62614
Fix that opening JEI would brick popup panels
Zorbatron Jun 15, 2025
ed2f617
Use / instead of ÷ because it wasn't centered in the button
Zorbatron Jun 15, 2025
b730d76
Add overlay to multiplier button (looks kinda ugly tbh)
Zorbatron Jun 15, 2025
3e6f5ed
spotless
Zorbatron Jun 15, 2025
3b0d467
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron Jun 18, 2025
2f0e868
Post merge shenanigans
Zorbatron Jun 18, 2025
2b022ad
Do todo after mui2 multis merged
Zorbatron Jun 18, 2025
5b8e431
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron Jun 18, 2025
2ac3140
spotless
Zorbatron Jun 18, 2025
0f3a919
Port ME output parts pt1
Zorbatron Sep 19, 2025
d9f8842
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron Sep 19, 2025
7f0747c
Add .run to gitignore
Zorbatron Sep 19, 2025
d944751
Post merge spotless
Zorbatron Sep 19, 2025
f852cff
Post merge fixes
Zorbatron Sep 19, 2025
54c9b80
Just write amount next to item
Zorbatron Sep 19, 2025
77ed01b
change comment wording
Zorbatron Sep 19, 2025
61ff047
Fix text lines getting cut off
Zorbatron Sep 19, 2025
59e3eec
exposed outside its defined visibility scope!!!
Zorbatron Sep 19, 2025
681adcd
Fix the extra slot item in input buses not dropping
Zorbatron Sep 19, 2025
debdba8
Fix the width of the online text widget being too thin if the gui was…
Zorbatron Sep 20, 2025
c4564be
Use L instead of x for the amount in ME output hatches
Zorbatron Sep 20, 2025
d8d2a82
Revert nullability change to IntCircuitIngredient
Zorbatron Sep 20, 2025
64bca50
Address TODO in GTUtility
Zorbatron Sep 20, 2025
654e3f4
Check NBT in `WrappedItemStack#equals`
Zorbatron Sep 20, 2025
4002e42
Fix the amount text and always show the scroll tooltip
Zorbatron Sep 21, 2025
e4666ef
Add line separator between fluid/item description and scroll control …
Zorbatron Sep 21, 2025
274c4b9
Add mod name to item tooltips
Zorbatron Sep 21, 2025
0656f02
Add the mod name to all MUI2 item slots and our fluid slots
Zorbatron Sep 22, 2025
cb63af8
Input parts code dedup pt1
Zorbatron Sep 22, 2025
9b3e7fc
Fix handler init stuff
Zorbatron Sep 22, 2025
2d2c600
Circuit slot in input hatches
Zorbatron Sep 22, 2025
ecaeafc
Actually add the circuit handler to the multiblock abilities list
Zorbatron Sep 22, 2025
e02acdd
Fix notifiables
Zorbatron Sep 22, 2025
0a4bf36
addline and lang
Zorbatron Sep 24, 2025
1ce17aa
Fix stocking hatches duping like crazy (Agh I want to redo how ARL se…
Zorbatron Sep 24, 2025
e929025
visibility change of getAEHandler
Zorbatron Sep 24, 2025
a62f2f2
Add fluid name (fogor) to tooltip on amount popup and mod name
Zorbatron Sep 25, 2025
5f213f9
Support `long`s in input parts (only in buffering)
Zorbatron Sep 25, 2025
97e6990
create RecipeSyncHandler to simplify recipe transfer in GregTechGuiSc…
ghzdude Oct 3, 2025
4f43375
remove mixins that are now unused
ghzdude Oct 3, 2025
c766a6d
Merge branch 'master' into zb/me-hatch-mui2
Zorbatron Nov 29, 2025
013a3b5
Just get it compiling again
Zorbatron Nov 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraftforge.items.IItemHandlerModifiable;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -29,8 +30,15 @@ public class GhostCircuitItemStackHandler extends GTItemStackHandler
private int circuitValue = NO_CONFIG;
private ItemStack circuitStack = ItemStack.EMPTY;

public GhostCircuitItemStackHandler(MetaTileEntity metaTileEntity) {
public GhostCircuitItemStackHandler(@NotNull MetaTileEntity metaTileEntity) {
this(metaTileEntity, metaTileEntity);
}

public GhostCircuitItemStackHandler(@NotNull MetaTileEntity metaTileEntity, @Nullable MetaTileEntity mteToNotify) {
super(metaTileEntity);
if (mteToNotify != null) {
notifiableEntities.add(mteToNotify);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ public class ItemHandlerList implements IItemHandlerModifiable {
private final Int2ObjectMap<IItemHandler> handlerBySlotIndex = new Int2ObjectOpenHashMap<>();
private final Object2IntMap<IItemHandler> baseIndexOffset = new Object2IntArrayMap<>();

public ItemHandlerList(List<? extends IItemHandler> itemHandlerList) {
public ItemHandlerList(@NotNull List<? extends @NotNull IItemHandler> itemHandlerList) {
int currentSlotIndex = 0;
for (IItemHandler itemHandler : itemHandlerList) {
Objects.requireNonNull(itemHandler, "Handler passed to ItemHandlerList was null.");

if (baseIndexOffset.containsKey(itemHandler)) {
throw new IllegalArgumentException("Attempted to add item handler " + itemHandler + " twice");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gregtech/api/gui/widgets/TankWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public static void addIngotMolFluidTooltip(FluidStack fluidStack, List<String> t
if (extra != 0) {
fluidAmount += String.format(" + %d L", extra);
}
tooltip.add(TextFormatting.GRAY + LocalizationUtils.format("gregtech.gui.amount_raw") + fluidAmount);
tooltip.add(TextFormatting.GRAY + LocalizationUtils.format("gregtech.gui.amount_raw", fluidAmount));
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/gregtech/api/items/metaitem/MetaItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ public ItemStack getStackForm(int amount) {
return new ItemStack(MetaItem.this, amount, metaItemOffset + metaValue);
}

public boolean isItemEqual(ItemStack itemStack) {
public boolean isItemEqual(@NotNull ItemStack itemStack) {
return itemStack.getItem() == MetaItem.this && itemStack.getItemDamage() == (metaItemOffset + metaValue);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package gregtech.api.metatileentity;

public interface IAEStatusProvider {

boolean isOnline();

boolean allowsExtraConnections();
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ protected void initializeInventory() {
this.outputFluidInventory = new FluidHandlerProxy(new FluidTankList(false), exportFluids);
if (this.hasGhostCircuitInventory()) {
this.circuitInventory = new GhostCircuitItemStackHandler(this);
this.circuitInventory.addNotifiableMetaTileEntity(this);
}

this.actualImportItems = null;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/gregtech/api/mui/GTByteBufAdapters.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import gregtech.api.recipes.chance.output.impl.ChancedFluidOutput;
import gregtech.api.recipes.chance.output.impl.ChancedItemOutput;
import gregtech.api.util.NetworkUtil;
import gregtech.common.metatileentities.multi.multiblockpart.appeng.stack.WrappedFluidStack;
import gregtech.common.metatileentities.multi.multiblockpart.appeng.stack.WrappedItemStack;

import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fluids.Fluid;

import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import com.cleanroommc.modularui.utils.serialization.*;
import org.jetbrains.annotations.NotNull;

Expand All @@ -23,6 +27,12 @@ public class GTByteBufAdapters {

public static final IByteBufAdapter<Fluid> FLUID = makeAdapter(NetworkUtil::readFluid, NetworkUtil::writeFluid);

public static final IByteBufAdapter<IAEItemStack> WRAPPED_ITEM_STACK = makeAdapter(WrappedItemStack::fromPacket,
(buffer, value) -> value.writeToPacket(buffer));

public static final IByteBufAdapter<IAEFluidStack> WRAPPED_FLUID_STACK = makeAdapter(
WrappedFluidStack::fromPacket, (buffer, value) -> value.writeToPacket(buffer));

public static <T> IByteBufAdapter<T> makeAdapter(@NotNull IByteBufDeserializer<T> deserializer,
@NotNull IByteBufSerializer<T> serializer) {
return makeAdapter(deserializer, serializer, IEquals.defaultTester());
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/gregtech/api/mui/GTGuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static class IDs {
public static final String PRIMITIVE_BACKGROUND = id("primitive_bg");

public static final String STANDARD_SLOT = id("standard_slot");
public static final String DARK_SLOT = id("dark_slot");
public static final String BRONZE_SLOT = id("bronze_slot");
public static final String STEEL_SLOT = id("steel_slot");
public static final String PRIMITIVE_SLOT = id("primitive_slot");
Expand Down Expand Up @@ -159,6 +160,14 @@ private static String id(String path) {
.canApplyTheme()
.build();

public static final UITexture SLOT_DARK = new UITexture.Builder()
.location(GTValues.MODID, "textures/gui/base/slot_dark.png")
.imageSize(18, 18)
.adaptable(1)
.name(IDs.DARK_SLOT)
.canApplyTheme()
.build();

public static final UITexture SLOT_BRONZE = new UITexture.Builder()
.location(GTValues.MODID, "textures/gui/base/slot_bronze.png")
.imageSize(18, 18)
Expand Down Expand Up @@ -709,6 +718,17 @@ private static String id(String path) {

// MISC

// ME hatch/bus
public static final UITexture NUMBER_BACKGROUND = fullImage("textures/gui/widget/number_background.png");
public static final UITexture CONFIG_ARROW = fullImage("textures/gui/widget/config_arrow.png");
public static final UITexture CONFIG_ARROW_DARK = fullImage("textures/gui/widget/config_arrow_dark.png");
public static final UITexture SELECT_BOX = fullImage("textures/gui/widget/select_box.png");
public static final UITexture BUTTON_AUTO_PULL = fullImage("textures/gui/widget/button_me_auto_pull.png");
public static final UITexture ARROW_DOUBLE = fullImage("textures/gui/widget/arrow_double.png");
public static final UITexture ARROW_OPPOSITE = fullImage("textures/gui/widget/opposite_arrows.png");
public static final UITexture[] AUTO_PULL = slice("textures/gui/widget/button_me_auto_pull.png",
16, 32, 16, 16, ColorType.DEFAULT);

public static void init() {/**/}

private static UITexture fullImage(String path) {
Expand Down
39 changes: 31 additions & 8 deletions src/main/java/gregtech/api/mui/GTGuis.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
import com.cleanroommc.modularui.widgets.ButtonWidget;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class GTGuis {

public static final int DEFAULT_WIDTH = 176, DEFAULT_HIEGHT = 166;
public static final int DEFAULT_WIDTH = 176, DEFAULT_HEIGHT = 166;

@ApiStatus.Internal
public static void registerFactories() {
Expand Down Expand Up @@ -53,7 +54,7 @@ public static ModularPanel createPanel(ItemStack stack, int width, int height) {
}

public static ModularPanel createPanel(String name) {
return ModularPanel.defaultPanel(name, DEFAULT_WIDTH, DEFAULT_HIEGHT);
return ModularPanel.defaultPanel(name, DEFAULT_WIDTH, DEFAULT_HEIGHT);
}

public static ModularPanel defaultPanel(MetaTileEntity mte) {
Expand All @@ -65,7 +66,7 @@ public static ModularPanel defaultPanel(Cover cover) {
}

public static ModularPanel defaultPanel(ItemStack stack) {
return createPanel(stack, DEFAULT_WIDTH, DEFAULT_HIEGHT);
return createPanel(stack, DEFAULT_WIDTH, DEFAULT_HEIGHT);
}

public static ModularPanel defaultPanel(MetaItem<?>.MetaValueItem valueItem) {
Expand All @@ -83,8 +84,17 @@ public static PopupPanel createPopupPanel(String name, int width, int height, bo
}

public static PopupPanel defaultPopupPanel(String name) {
return new PopupPanel(name)
.size(DEFAULT_WIDTH, DEFAULT_HIEGHT);
return new PopupPanel(name, true)
.size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
}

public static PopupPanel blankPopupPanel(String name, int width, int height) {
return new PopupPanel(name, false)
.size(width, height);
}

public static PopupPanel blankPopupPanel(String name) {
return blankPopupPanel(name, DEFAULT_WIDTH, DEFAULT_HEIGHT);
}

public static PopupPanel defaultPopupPanel(String name, boolean disableBelow,
Expand All @@ -100,17 +110,21 @@ public static class PopupPanel extends ModularPanel {
private boolean disableBelow;
private boolean closeOnOutsideClick;
private boolean deleteCachedPanel;
@Nullable
private Runnable closeListener;

private PopupPanel(@NotNull String name) {
private PopupPanel(@NotNull String name, boolean addCloseButton) {
super(name);
align(Alignment.Center);
background(GTGuiTextures.BACKGROUND_POPUP);
child(ButtonWidget.panelCloseButton().top(5).right(5)
childIf(addCloseButton, () -> ButtonWidget.panelCloseButton()
.top(5).right(5)
.onMousePressed(mouseButton -> {
if (mouseButton == 0 || mouseButton == 1) {
this.closeIfOpen();
closeIfOpen();
return true;
}

return false;
}));
}
Expand All @@ -121,6 +135,10 @@ public void onClose() {
if (deleteCachedPanel && isSynced() && getSyncHandler() instanceof IPanelHandler handler) {
handler.deleteCachedPanel();
}

if (closeListener != null) {
closeListener.run();
}
}

public PopupPanel disablePanelsBelow(boolean disableBelow) {
Expand Down Expand Up @@ -159,5 +177,10 @@ public boolean disablePanelsBelow() {
public boolean closeOnOutOfBoundsClick() {
return closeOnOutsideClick;
}

public PopupPanel closeListener(@Nullable Runnable closeListener) {
this.closeListener = closeListener;
return this;
}
}
}
28 changes: 27 additions & 1 deletion src/main/java/gregtech/api/mui/GregTechGuiScreen.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
package gregtech.api.mui;

import gregtech.api.GTValues;
import gregtech.integration.jei.JustEnoughItemsModule;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.cleanroommc.modularui.integration.recipeviewer.RecipeViewerRecipeTransferHandler;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.screen.ModularScreen;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;

@SuppressWarnings("UnstableApiUsage")
@SideOnly(Side.CLIENT)
public class GregTechGuiScreen extends ModularScreen {
public class GregTechGuiScreen extends ModularScreen implements RecipeViewerRecipeTransferHandler {

private static final Object2ObjectMap<String, IJEIRecipeReceiver> knownRecipeReceivers = new Object2ObjectOpenHashMap<>();

public GregTechGuiScreen(ModularPanel mainPanel) {
this(mainPanel, GTGuiTheme.STANDARD);
Expand All @@ -27,4 +36,21 @@ public GregTechGuiScreen(String owner, ModularPanel mainPanel, String themeId) {
super(owner, mainPanel);
useTheme(themeId);
}

@Override
public IRecipeTransferError transferRecipe(IRecipeLayout recipeLayout, boolean maxTransfer, boolean simulate) {
for (IJEIRecipeReceiver handler : knownRecipeReceivers.values()) {
IRecipeTransferError error = handler.receiveRecipe(recipeLayout, maxTransfer, simulate);
if (error == null) return null;
}
return JustEnoughItemsModule.transferHelper.createInternalError();
}

public static void registerRecipeReceiver(String key, IJEIRecipeReceiver receiver) {
knownRecipeReceivers.put(key, receiver);
}

public static void removeRecipeReceiver(String key) {
knownRecipeReceivers.remove(key);
}
}
69 changes: 0 additions & 69 deletions src/main/java/gregtech/api/mui/GregTechGuiTransferHandler.java

This file was deleted.

33 changes: 33 additions & 0 deletions src/main/java/gregtech/api/mui/IJEIRecipeReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package gregtech.api.mui;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import org.jetbrains.annotations.NotNull;

/**
* For receiving a JEI recipe transfer (the + button in a recipe). <br>
* Implement this on a {@link com.cleanroommc.modularui.value.sync.SyncHandler} and ensure it's registered to the
* {@link com.cleanroommc.modularui.value.sync.PanelSyncManager}. <br>
* If there are multiple sync handlers implementing this, the handler that will be used to receive the recipe is
* indeterminate.
*/
public interface IJEIRecipeReceiver {

/**
* Returning an {@link IRecipeTransferError} with a type of {@link IRecipeTransferError.Type#INTERNAL} will hide the
* + button. <br>
* JEI has a static instance available at {@link mezz.jei.transfer.RecipeTransferErrorInternal#INSTANCE} for this
* purpose.
*
* @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
* a crafting table
* @param simulate if this recipe should only be simulated being transferred
* @return a {@link IRecipeTransferError} if something isn't right, or null if it's okay to transfer this recipe
*/
@SideOnly(Side.CLIENT)
IRecipeTransferError receiveRecipe(@NotNull IRecipeLayout recipeLayout, boolean maxTransfer, boolean simulate);
}
Loading
Loading