diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java index baeaaeb6f0..b208a0f118 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java @@ -72,7 +72,7 @@ default Object convertIngredient(Object ingredient) { } if (LDLib.isJeiLoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { - ingredient = FluidStack.create(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); + ingredient = new FluidStack(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); } return ingredient; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java index ff507739e1..35b5090ff9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java @@ -89,16 +89,6 @@ public static FluidStack drainFrom(Object ingredient) { if (ingredient instanceof ItemStack itemStack) { var handler = FluidUtil.getFluidHandler(itemStack); return handler.map(h -> h.drain(Integer.MAX_VALUE, FluidAction.SIMULATE)).orElse(FluidStack.EMPTY); - // var stack = new ItemStackHandler(NonNullList.of(ItemStack.EMPTY, itemStack)).getStackInSlot(0); - // if(!stack.isEmpty()) { - // var h = stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).resolve(); - // if(h.isPresent()) return h.get().drain(Integer.MAX_VALUE, FluidAction.SIMULATE); - // } - // var handler = FluidTransferHelper.getFluidTransfer(new ItemStackHandler(NonNullList.of(ItemStack.EMPTY, - // itemStack)), 0); - // if (handler != null) { - // return handler.drain(Integer.MAX_VALUE, FluidAction.SIMULATE); - // } } return FluidStack.EMPTY; } @@ -208,18 +198,6 @@ private void handlePhantomClick() { var stack = FluidUtil.getFluidHandler(gui.getModularUIContainer().getCarried()) .map(h -> h.drain(Integer.MAX_VALUE, FluidAction.EXECUTE)).orElse(FluidStack.EMPTY); if (phantomFluidSetter != null) phantomFluidSetter.accept(stack); - // var handler = FluidUtil.getFluidHandler(gui.getModularUIContainer().getCarried()).resolve(); - // if(handler.isPresent()) { - // FluidStack result = handler.get().drain(Integer.MAX_VALUE, FluidAction.EXECUTE); - // if(phantomFluidSetter != null) phantomFluidSetter.accept(result); - // } - // var handler = FluidTransferHelper.getFluidTransfer(gui.entityPlayer, gui.getModularUIContainer()); - // if (handler != null) { - // FluidStack resultFluid = handler.drain(Integer.MAX_VALUE, FluidAction.EXECUTE); - // if (phantomFluidSetter != null) { - // phantomFluidSetter.accept(resultFluid); - // } - // } } else { if (phantomFluidSetter != null) { phantomFluidSetter.accept(FluidStack.EMPTY); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java index 9c0bd5cfe7..d853cf230e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java @@ -19,8 +19,6 @@ import com.lowdragmc.lowdraglib.jei.ClickableIngredient; import com.lowdragmc.lowdraglib.jei.IngredientIO; import com.lowdragmc.lowdraglib.jei.JEIPlugin; -import com.lowdragmc.lowdraglib.side.fluid.FluidHelper; -import com.lowdragmc.lowdraglib.side.fluid.FluidTransferHelper; import com.lowdragmc.lowdraglib.side.fluid.forge.FluidHelperImpl; import com.lowdragmc.lowdraglib.utils.CycleFluidTransfer; import com.lowdragmc.lowdraglib.utils.Position; @@ -253,7 +251,7 @@ public List getXEIIngredients() { } private List getXEIIngredientsFromCycleTransfer(CycleFluidTransfer transfer, int index) { - var stream = transfer.getStackList(index).stream().map(FluidHelper::toRealFluidStack) + var stream = transfer.getStackList(index).stream().map(FluidHelperImpl::toRealFluidStack) .map(FluidStack.class::cast); if (LDLib.isJeiLoaded()) { return stream.filter(fluid -> !fluid.isEmpty()).map(JEICallWrapper::getPlatformFluidTypeForJEI).toList(); @@ -266,7 +264,7 @@ private List getXEIIngredientsFromCycleTransfer(CycleFluidTransfer trans } private List getXEIIngredientsFromCycleTransferClickable(CycleFluidTransfer transfer, int index) { - var stream = transfer.getStackList(index).stream().map(FluidHelper::toRealFluidStack) + var stream = transfer.getStackList(index).stream().map(FluidHelperImpl::toRealFluidStack) .map(FluidStack.class::cast); if (LDLib.isJeiLoaded()) { return stream @@ -376,16 +374,6 @@ private List getToolTips(List list) { return list; } - @Override - public void addTooltipCallback(Consumer> callback) { - this.tooltipCallback.add(callback); - } - - @Override - public void clearTooltipCallback() { - this.tooltipCallback.clear(); - } - @Override @OnlyIn(Dist.CLIENT) public void drawInBackground(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { @@ -570,7 +558,7 @@ private int tryClickContainer(boolean isShiftKeyDown) { if (fluidTank == null) return -1; Player player = gui.entityPlayer; ItemStack currentStack = gui.getModularUIContainer().getCarried(); - var handler = FluidTransferHelper.getFluidTransfer(gui.entityPlayer, gui.getModularUIContainer()); + var handler = FluidUtil.getFluidHandler(currentStack).resolve().orElse(null); if (handler == null) return -1; int maxAttempts = isShiftKeyDown ? currentStack.getCount() : 1; FluidStack initialFluid = fluidTank.getFluidInTank(tank); @@ -636,7 +624,7 @@ private int tryClickContainer(boolean isShiftKeyDown) { public boolean mouseClicked(double mouseX, double mouseY, int button) { if ((allowClickDrained || allowClickFilled) && isMouseOverElement(mouseX, mouseY)) { if (button == 0) { - if (FluidTransferHelper.getFluidTransfer(gui.entityPlayer, gui.getModularUIContainer()) != null) { + if (FluidUtil.getFluidHandler(gui.getModularUIContainer().getCarried()).isPresent()) { boolean isShiftKeyDown = isShiftDown(); writeClientAction(1, writer -> writer.writeBoolean(isShiftKeyDown)); playButtonClickSound(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamSolidBoilerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamSolidBoilerMachine.java index 392f3d700c..a5acbd8293 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamSolidBoilerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamSolidBoilerMachine.java @@ -18,7 +18,6 @@ import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture; import com.lowdragmc.lowdraglib.gui.widget.ProgressWidget; import com.lowdragmc.lowdraglib.gui.widget.SlotWidget; -import com.lowdragmc.lowdraglib.side.fluid.FluidTransferHelper; import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; @@ -26,6 +25,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.fluids.FluidUtil; import it.unimi.dsi.fastutil.objects.Object2BooleanMap; import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap; @@ -54,7 +54,7 @@ public class SteamSolidBoilerMachine extends SteamBoilerMachine implements IMach public SteamSolidBoilerMachine(IMachineBlockEntity holder, boolean isHighPressure, Object... args) { super(holder, isHighPressure, args); this.fuelHandler = createFuelHandler(args).setFilter(itemStack -> { - if (FluidTransferHelper.getFluidContained(itemStack) != null) { + if (FluidUtil.getFluidContained(itemStack).isPresent()) { return false; } return FUEL_CACHE.computeIfAbsent(itemStack.getItem(), item -> { diff --git a/src/main/java/com/gregtechceu/gtceu/common/pipelike/fluidpipe/PipeNetRoutePath.java b/src/main/java/com/gregtechceu/gtceu/common/pipelike/fluidpipe/PipeNetRoutePath.java index 1777dfdf63..89d94566d4 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/pipelike/fluidpipe/PipeNetRoutePath.java +++ b/src/main/java/com/gregtechceu/gtceu/common/pipelike/fluidpipe/PipeNetRoutePath.java @@ -1,20 +1,19 @@ package com.gregtechceu.gtceu.common.pipelike.fluidpipe; import com.gregtechceu.gtceu.api.pipenet.IRoutePath; - -import com.lowdragmc.lowdraglib.side.fluid.FluidTransferHelper; -import com.lowdragmc.lowdraglib.side.fluid.IFluidTransfer; +import com.gregtechceu.gtceu.utils.GTTransferUtils; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.Level; +import net.minecraftforge.fluids.capability.IFluidHandler; import lombok.Getter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import oshi.util.tuples.Pair; -public class PipeNetRoutePath implements IRoutePath { +public class PipeNetRoutePath implements IRoutePath { @Getter private final BlockPos pipePos; @@ -43,7 +42,7 @@ public BlockPos getTargetPipePos() { } @Nullable - public IFluidTransfer getHandler(Level world) { - return FluidTransferHelper.getFluidTransfer(world, getTargetPipePos(), targetFacing.getOpposite()); + public IFluidHandler getHandler(Level world) { + return GTTransferUtils.getAdjacentFluidHandler(world, pipePos, targetFacing).resolve().orElse(null); } }