diff --git a/common/mekanism/common/tileentity/TileEntityElectricChest.java b/common/mekanism/common/tileentity/TileEntityElectricChest.java index 1b0d7911e..e61bcdc45 100644 --- a/common/mekanism/common/tileentity/TileEntityElectricChest.java +++ b/common/mekanism/common/tileentity/TileEntityElectricChest.java @@ -138,9 +138,9 @@ public class TileEntityElectricChest extends TileEntityElectricBlock implements @Override public int[] getAccessibleSlotsFromSide(int side) { - if(side == 0) + if(side == 0 || !canAccess()) { - return new int[] {54}; + return new int[] {55}; } else { int[] ret = new int[55]; diff --git a/common/mekanism/common/tileentity/TileEntityEnergyCube.java b/common/mekanism/common/tileentity/TileEntityEnergyCube.java index 7482b316e..20fa2066d 100644 --- a/common/mekanism/common/tileentity/TileEntityEnergyCube.java +++ b/common/mekanism/common/tileentity/TileEntityEnergyCube.java @@ -96,7 +96,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn for(ForgeDirection dir : ForgeDirection.values()) { - if(dir != ForgeDirection.getOrientation(facing)) + if(dir != getOutputtingSide()) { set.add(dir); } diff --git a/common/mekanism/common/transporter/TransporterPathfinder.java b/common/mekanism/common/transporter/TransporterPathfinder.java index 785108e87..d97dd88f7 100644 --- a/common/mekanism/common/transporter/TransporterPathfinder.java +++ b/common/mekanism/common/transporter/TransporterPathfinder.java @@ -14,6 +14,7 @@ import mekanism.common.tileentity.TileEntityLogisticalTransporter; import mekanism.common.transporter.TransporterPathfinder.Pathfinder.DestChecker; import mekanism.common.transporter.TransporterStack.Path; import mekanism.common.util.TransporterUtils; +import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; @@ -69,7 +70,7 @@ public final class TransporterPathfinder if(!found) { - destinations.add(new Destination(currentPath, dist)); + destinations.add(new Destination(currentPath, dist, true)); } } @@ -104,9 +105,15 @@ public final class TransporterPathfinder public List path = new ArrayList(); public double score; - public Destination(ArrayList list, double d) + public Destination(ArrayList list, double d, boolean inv) { path = (List)list.clone(); + + if(inv) + { + Collections.reverse(path); + } + score = d; } @@ -128,11 +135,11 @@ public final class TransporterPathfinder @Override public int compareTo(Destination dest) { - if(dest.score < score) + if(score < dest.score) { return -1; } - else if(dest.score > score) + else if(score > dest.score) { return 1; } @@ -174,13 +181,21 @@ public final class TransporterPathfinder { TileEntity tile = pointer.getFromSide(side).getTileEntity(worldObj); - if(TransporterUtils.canInsert(tile, transportStack.color, transportStack.itemStack, side.ordinal(), false) && !(tile instanceof TileEntityLogisticalTransporter)) + if(tile != null) { - destsFound.add(Object3D.get(tile)); - } - else if(transportStack.canInsertToTransporter(tile) && !iterated.contains(Object3D.get(tile))) - { - loop(Object3D.get(tile)); + if(Object3D.get(tile).equals(transportStack.originalLocation)) + { + continue; + } + + if(TransporterUtils.canInsert(tile, transportStack.color, transportStack.itemStack, side.ordinal(), false)) + { + destsFound.add(Object3D.get(tile)); + } + else if(transportStack.canInsertToTransporter(tile) && !iterated.contains(Object3D.get(tile))) + { + loop(Object3D.get(tile)); + } } } } @@ -212,9 +227,9 @@ public final class TransporterPathfinder { Pathfinder p = new Pathfinder(checker, start.worldObj, obj, Object3D.get(start), stack); - if(p.getPath() != null && p.getPath().size() >= 2) + if(p.getPath().size() >= 2) { - paths.add(new Destination(p.getPath(), p.finalScore)); + paths.add(new Destination(p.getPath(), p.finalScore, false)); } } @@ -341,7 +356,7 @@ public final class TransporterPathfinder for(int i = 0; i < 6; i++) { ForgeDirection direction = ForgeDirection.getOrientation(i); - Object3D neighbor = finalNode.translate(direction.offsetX, direction.offsetY, direction.offsetZ); + Object3D neighbor = start.translate(direction.offsetX, direction.offsetY, direction.offsetZ); if(!transportStack.canInsertToTransporter(neighbor.getTileEntity(worldObj)) && (!neighbor.equals(finalNode) || !destChecker.isValid(transportStack, i, neighbor.getTileEntity(worldObj)))) { @@ -474,7 +489,7 @@ public final class TransporterPathfinder Pathfinder p = new Pathfinder(checker, start.worldObj, stack.homeLocation, Object3D.get(start), stack); List path = p.getPath(); - if(path != null) + if(path.size() >= 2) { stack.pathType = Path.HOME; return path; diff --git a/common/mekanism/common/transporter/TransporterStack.java b/common/mekanism/common/transporter/TransporterStack.java index 0c3e3c302..9008c054f 100644 --- a/common/mekanism/common/transporter/TransporterStack.java +++ b/common/mekanism/common/transporter/TransporterStack.java @@ -98,7 +98,7 @@ public class TransporterStack nbtTags.setInteger("progress", progress); nbtTags.setCompoundTag("originalLocation", originalLocation.write(new NBTTagCompound())); - if(nbtTags.hasKey("homeLocation")) + if(homeLocation != null) { nbtTags.setCompoundTag("homeLocation", homeLocation.write(new NBTTagCompound())); } @@ -117,7 +117,7 @@ public class TransporterStack progress = nbtTags.getInteger("progress"); originalLocation = Object3D.read(nbtTags.getCompoundTag("originalLocation")); - if(homeLocation != null) + if(nbtTags.hasKey("homeLocation")) { homeLocation = Object3D.read(nbtTags.getCompoundTag("homeLocation")); }