diff options
author | miozune <miozune@gmail.com> | 2022-09-02 20:57:30 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-02 13:57:30 +0200 |
commit | 41d1832928fb89accc49b384ddec71375daaed71 (patch) | |
tree | cb2cc16e52458a892b2798f28c3305d3b3f05a9f /src/main/java/gregtech/api/interfaces | |
parent | 233b0f321a0d0b9594f6e0f55dd0d7ae789f9c31 (diff) | |
download | GT5-Unofficial-41d1832928fb89accc49b384ddec71375daaed71.tar.gz GT5-Unofficial-41d1832928fb89accc49b384ddec71375daaed71.tar.bz2 GT5-Unofficial-41d1832928fb89accc49b384ddec71375daaed71.zip |
Add Drag-And-Drop support for digital tank (#1333)
* Add Drag-And-Drop support for digital tank
* lockedFluidName is null in old save
Diffstat (limited to 'src/main/java/gregtech/api/interfaces')
-rw-r--r-- | src/main/java/gregtech/api/interfaces/IDragAndDropSupport.java | 53 | ||||
-rw-r--r-- | src/main/java/gregtech/api/interfaces/metatileentity/IFluidLockable.java | 29 |
2 files changed, 82 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/interfaces/IDragAndDropSupport.java b/src/main/java/gregtech/api/interfaces/IDragAndDropSupport.java new file mode 100644 index 0000000000..53b3a2b059 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/IDragAndDropSupport.java @@ -0,0 +1,53 @@ +package gregtech.api.interfaces; + +import codechicken.nei.NEIClientUtils; +import codechicken.nei.VisiblityData; +import codechicken.nei.api.INEIGuiHandler; +import codechicken.nei.api.TaggedInventoryArea; +import cpw.mods.fml.common.Optional; +import java.util.Collections; +import java.util.List; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; + +/** + * Implement this interface if your GuiContainer supports Drag-And-Drop behavior on NEI. + */ +@Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler") +public interface IDragAndDropSupport extends INEIGuiHandler { + + /** + * Implement this to handle Drag-And-Drop behavior. + * This may be invoked on normal click too ({@code isGhost==false}), so be careful + * if your slot supports both Drag-And-Drop and other behaviors e.g. fluid I/O with FluidDisplay click + * @param gui Current gui instance. Make sure to check if it is an instance of your GuiContainer. + * @param mousex X position of the mouse + * @param mousey Y position of the mouse + * @param draggedStack ItemStack user is holding on cursor + * @param button 0 = left click, 1 = right click + * @param isGhost Whether {@code draggedStack} is dragged from ItemPanel/BookmarkPanel, or actual item player holds + * @return True if success + */ + boolean handleDragAndDropGT( + GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button, boolean isGhost); + + default boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { + return handleDragAndDropGT(gui, mousex, mousey, draggedStack, button, NEIClientUtils.getHeldItem() == null); + } + + default VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { + return currentVisibility; + } + + default Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) { + return Collections.emptyList(); + } + + default List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) { + return null; + } + + default boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) { + return false; + } +} diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IFluidLockable.java b/src/main/java/gregtech/api/interfaces/metatileentity/IFluidLockable.java new file mode 100644 index 0000000000..688a85b521 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IFluidLockable.java @@ -0,0 +1,29 @@ +package gregtech.api.interfaces.metatileentity; + +import net.minecraftforge.fluids.Fluid; + +/** + * Implement this interface if your MetaTileEntity supports fluid lock mechanism. + */ +@SuppressWarnings({"BooleanMethodIsAlwaysInverted", "unused"}) +public interface IFluidLockable { + + /** + * Use {@link Fluid#getName()} instead of {@link Fluid#getUnlocalizedName()} for fluid name + */ + void setLockedFluidName(String name); + + String getLockedFluidName(); + + /** + * Set fluid lock state. + * Would be useful when you don't necessarily want to change mode when locked fluid is changed. + */ + void lockFluid(boolean lock); + + boolean isFluidLocked(); + + boolean allowChangingLockedFluid(String name); + + default void onFluidLockPacketReceived(String name) {} +} |