mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
Merge pull request #21 from GTNewHorizons/eio-compact-fix
eio conduct compact and fix transfer item and fluid in different dirs
This commit is contained in:
3 files changed
+81
-9
No files matched your search
@@ -2,15 +2,19 @@ package com.glodblock.github.inventory;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.InsertionMode;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
import cofh.api.transport.IItemDuct;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -34,20 +38,34 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
return InventoryAdaptor.getAdaptor(capProvider, f);
|
||||
InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, f);
|
||||
IFluidHandler fluid = capProvider instanceof IFluidHandler ? (IFluidHandler) capProvider : null;
|
||||
return new FluidConvertingInventoryAdaptor(item, fluid, face);
|
||||
boolean onmi = false;
|
||||
if (inter instanceof TileInterface) {
|
||||
onmi = ((TileInterface) inter).getTargets().size() > 1;
|
||||
}
|
||||
Object conduct = null;
|
||||
if (ModAndClassUtil.COFH && capProvider instanceof IItemDuct) {
|
||||
conduct = capProvider;
|
||||
}
|
||||
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi, conduct);
|
||||
}
|
||||
|
||||
private final InventoryAdaptor invItems;
|
||||
private final IFluidHandler invFluids;
|
||||
private final ForgeDirection side;
|
||||
private final BlockPos posInterface;
|
||||
private final Object eioDuct;
|
||||
private final boolean onmi;
|
||||
|
||||
public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids, EnumFacing facing) {
|
||||
public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids, EnumFacing facing, BlockPos pos, boolean isOnmi, Object eioConduct) {
|
||||
this.invItems = invItems;
|
||||
this.invFluids = invFluids;
|
||||
this.side = Util.from(facing);
|
||||
this.posInterface = pos;
|
||||
this.eioDuct = eioConduct;
|
||||
this.onmi = isOnmi;
|
||||
}
|
||||
|
||||
public ItemStack addItems( ItemStack toBeAdded,InsertionMode insertionMode ) {
|
||||
public ItemStack addItems( ItemStack toBeAdded, InsertionMode insertionMode ) {
|
||||
if (toBeAdded.getItem() instanceof ItemFluidPacket) {
|
||||
if (invFluids != null) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(toBeAdded);
|
||||
@@ -61,20 +79,44 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
return toBeAdded;
|
||||
}
|
||||
if (eioDuct != null) {
|
||||
return ((IItemDuct) eioDuct).insertItem(side, toBeAdded);
|
||||
}
|
||||
return invItems != null ? invItems.addItems(toBeAdded,insertionMode) : toBeAdded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack addItems(ItemStack toBeAdded) {
|
||||
return addItems(toBeAdded,InsertionMode.DEFAULT);
|
||||
return addItems(toBeAdded, InsertionMode.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateAdd(ItemStack toBeSimulated) {
|
||||
return simulateAdd(toBeSimulated,InsertionMode.DEFAULT);
|
||||
return simulateAdd(toBeSimulated, InsertionMode.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateAdd(ItemStack toBeSimulated,InsertionMode insertionMode) {
|
||||
public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) {
|
||||
if (toBeSimulated.getItem() instanceof ItemFluidPacket) {
|
||||
if (onmi) {
|
||||
boolean sus = false;
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
|
||||
if (fluid != null) {
|
||||
for (ForgeDirection dir : ForgeDirection.values()) {
|
||||
TileEntity te = posInterface.getOffSet(dir).getTileEntity();
|
||||
if (te instanceof IFluidHandler) {
|
||||
int filled = ((IFluidHandler) te).fill(dir.getOpposite(), fluid, false);
|
||||
if (filled > 0) {
|
||||
sus = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sus = true;
|
||||
}
|
||||
return sus ? null : toBeSimulated;
|
||||
}
|
||||
if (invFluids != null) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
|
||||
if (fluid != null) {
|
||||
@@ -87,7 +129,11 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
return toBeSimulated;
|
||||
}
|
||||
return invItems != null ? invItems.simulateAdd(toBeSimulated,insertionMode) : toBeSimulated;
|
||||
//Assert EIO conduct can hold all item, as it is the origin practice in AE2
|
||||
if (eioDuct != null) {
|
||||
return null;
|
||||
}
|
||||
return invItems != null ? invItems.simulateAdd(toBeSimulated, insertionMode) : toBeSimulated;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,30 +1,49 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockPos {
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private final World w;
|
||||
|
||||
public BlockPos(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = null;
|
||||
}
|
||||
|
||||
public BlockPos(int x, int y, int z, World w) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public BlockPos(@Nonnull TileEntity te) {
|
||||
this.x = te.xCoord;
|
||||
this.y = te.yCoord;
|
||||
this.z = te.zCoord;
|
||||
this.w = te.getWorldObj();
|
||||
}
|
||||
|
||||
public BlockPos getOffSet(ForgeDirection face) {
|
||||
return new BlockPos(this.x + face.offsetX, this.y + face.offsetY, this.z + face.offsetZ);
|
||||
return new BlockPos(this.x + face.offsetX, this.y + face.offsetY, this.z + face.offsetZ, this.w);
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity() {
|
||||
if (w != null) {
|
||||
return w.getTileEntity(x, y, z);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
@@ -39,11 +58,15 @@ public class BlockPos {
|
||||
return z;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof BlockPos) {
|
||||
BlockPos pos = (BlockPos) obj;
|
||||
return pos.x == x && pos.y == y && pos.z == z;
|
||||
return pos.x == x && pos.y == y && pos.z == z && Objects.equals(pos.w, w);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public final class ModAndClassUtil {
|
||||
public static boolean WCT = false;
|
||||
public static boolean IC2 = false;
|
||||
public static boolean NEI = false;
|
||||
public static boolean COFH = false;
|
||||
public static boolean GTPP = false;
|
||||
|
||||
public static boolean isDoubleButton;
|
||||
@@ -119,6 +120,8 @@ public final class ModAndClassUtil {
|
||||
IC2 = true;
|
||||
if (Loader.isModLoaded("NotEnoughItems"))
|
||||
NEI = true;
|
||||
if (Loader.isModLoaded("CoFHCore"))
|
||||
COFH = true;
|
||||
if (Loader.isModLoaded("miscutils"))
|
||||
GTPP = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user