Skip to content

Commit

Permalink
Update LDLib overrides
Browse files Browse the repository at this point in the history
Also clean up some lingering references
  • Loading branch information
krossgg committed Sep 22, 2024
1 parent 11b347f commit a42cdaf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 4 additions & 16 deletions src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -253,7 +251,7 @@ public List<Object> getXEIIngredients() {
}

private List<Object> 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();
Expand All @@ -266,7 +264,7 @@ private List<Object> getXEIIngredientsFromCycleTransfer(CycleFluidTransfer trans
}

private List<Object> 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
Expand Down Expand Up @@ -376,16 +374,6 @@ private List<Component> getToolTips(List<Component> list) {
return list;
}

@Override
public void addTooltipCallback(Consumer<List<Component>> 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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
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;

import net.minecraft.MethodsReturnNonnullByDefault;
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;
Expand Down Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<IFluidTransfer> {
public class PipeNetRoutePath implements IRoutePath<IFluidHandler> {

@Getter
private final BlockPos pipePos;
Expand Down Expand Up @@ -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);
}
}

0 comments on commit a42cdaf

Please sign in to comment.