|
1 | 1 | package gregtech.common.mui.widget; |
2 | 2 |
|
3 | 3 | import gregtech.api.mui.sync.GTFluidSyncHandler; |
4 | | -import gregtech.api.util.GTUtility; |
5 | 4 | import gregtech.client.utils.RenderUtil; |
6 | 5 |
|
7 | 6 | import net.minecraft.item.ItemStack; |
8 | 7 | import net.minecraftforge.fluids.FluidStack; |
| 8 | +import net.minecraftforge.fluids.FluidUtil; |
9 | 9 | import net.minecraftforge.fluids.IFluidTank; |
10 | | -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; |
11 | 10 |
|
12 | 11 | import com.cleanroommc.modularui.api.ITheme; |
13 | 12 | import com.cleanroommc.modularui.api.widget.Interactable; |
@@ -119,7 +118,8 @@ public void draw(ModularGuiContext context, WidgetSlotTheme widgetTheme) { |
119 | 118 | @Override |
120 | 119 | public @NotNull Result onMousePressed(int mouseButton) { |
121 | 120 | var data = MouseData.create(mouseButton); |
122 | | - if (this.syncHandler.canFillSlot() || this.syncHandler.canDrainSlot()) { |
| 121 | + if (this.syncHandler.isPhantom() || |
| 122 | + this.syncHandler.canFillSlot() || this.syncHandler.canDrainSlot()) { |
123 | 123 | this.syncHandler.handleClick(data); |
124 | 124 |
|
125 | 125 | if (this.syncHandler.canLockFluid()) |
@@ -164,13 +164,12 @@ public void setGhostIngredient(@NotNull FluidStack ingredient) { |
164 | 164 |
|
165 | 165 | if (ingredient instanceof FluidStack stack) { |
166 | 166 | return stack; |
167 | | - } else if (ingredient instanceof ItemStack stack && |
168 | | - stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) { |
169 | | - if (stack.getCount() > 1) stack = GTUtility.copy(1, stack); |
| 167 | + } |
| 168 | + |
| 169 | + if (ingredient instanceof ItemStack stack) { |
| 170 | + return FluidUtil.getFluidContained(stack); |
| 171 | + } |
170 | 172 |
|
171 | | - var handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); |
172 | | - return handler == null ? null : handler.drain(Integer.MAX_VALUE, true); |
173 | | - } |
174 | 173 | return null; |
175 | 174 | } |
176 | 175 |
|
|
0 commit comments