Merge branch 'master' into development

* master:
  Fix a small transporter bug
This commit is contained in:
aidancbrady 2016-01-18 17:18:12 -05:00
commit 17425b998f
2 changed files with 19 additions and 15 deletions

View file

@ -24,6 +24,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import com.mojang.realmsclient.util.Pair;
public final class TransporterPathfinder public final class TransporterPathfinder
{ {
public static class IdlePath public static class IdlePath
@ -541,7 +543,7 @@ public final class TransporterPathfinder
} }
} }
public static List<Coord4D> getIdlePath(ILogisticalTransporter start, TransporterStack stack) public static Pair<List<Coord4D>, Path> getIdlePath(ILogisticalTransporter start, TransporterStack stack)
{ {
if(stack.homeLocation != null) if(stack.homeLocation != null)
{ {
@ -559,8 +561,7 @@ public final class TransporterPathfinder
if(path.size() >= 2) if(path.size() >= 2)
{ {
stack.pathType = Path.HOME; return Pair.of(path, Path.HOME);
return path;
} }
else { else {
stack.homeLocation = null; stack.homeLocation = null;
@ -575,8 +576,6 @@ public final class TransporterPathfinder
return null; return null;
} }
stack.pathType = dest.pathType; return Pair.of(dest.path, dest.pathType);
return dest.path;
} }
} }

View file

@ -18,6 +18,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import com.mojang.realmsclient.util.Pair;
public class TransporterStack public class TransporterStack
{ {
public ItemStack itemStack; public ItemStack itemStack;
@ -150,11 +152,16 @@ public class TransporterStack
return stack; return stack;
} }
public void setPath(List<Coord4D> path) public void setPath(List<Coord4D> path, Path type)
{ {
TransporterManager.remove(this); //Make sure old path isn't null
if(pathType != Path.NONE)
{
TransporterManager.remove(this);
}
pathToTarget = path; pathToTarget = path;
pathType = type;
if(pathType != Path.NONE) if(pathType != Path.NONE)
{ {
@ -181,9 +188,8 @@ public class TransporterStack
return itemStack; return itemStack;
} }
pathType = Path.DEST;
idleDir = ForgeDirection.UNKNOWN; idleDir = ForgeDirection.UNKNOWN;
setPath(newPath.path); setPath(newPath.path, Path.DEST);
initiatedPath = true; initiatedPath = true;
return newPath.rejected; return newPath.rejected;
@ -198,9 +204,8 @@ public class TransporterStack
return itemStack; return itemStack;
} }
pathType = Path.DEST;
idleDir = ForgeDirection.UNKNOWN; idleDir = ForgeDirection.UNKNOWN;
setPath(newPath.path); setPath(newPath.path, Path.DEST);
initiatedPath = true; initiatedPath = true;
return newPath.rejected; return newPath.rejected;
@ -208,19 +213,19 @@ public class TransporterStack
public boolean calculateIdle(ILogisticalTransporter transporter) public boolean calculateIdle(ILogisticalTransporter transporter)
{ {
List<Coord4D> newPath = TransporterPathfinder.getIdlePath(transporter, this); Pair<List<Coord4D>, Path> newPath = TransporterPathfinder.getIdlePath(transporter, this);
if(newPath == null) if(newPath == null)
{ {
return false; return false;
} }
if(pathType == Path.HOME) if(newPath.second() == Path.HOME)
{ {
idleDir = ForgeDirection.UNKNOWN; idleDir = ForgeDirection.UNKNOWN;
} }
setPath(newPath); setPath(newPath.first(), newPath.second());
originalLocation = transporter.coord(); originalLocation = transporter.coord();
initiatedPath = true; initiatedPath = true;