Adding logic to choose next ItemRailing for IItemRailingTransfer to go to next

This commit is contained in:
tgame14 2014-04-17 13:41:53 +03:00
parent 4395c9ec55
commit c78cd153e6
5 changed files with 27 additions and 3 deletions

View file

@ -39,4 +39,11 @@ public class GridRailing extends NodeGrid<NodeRailing>
Arrays.sort(arr, new RailingDistanceComparator.RailingColoredDistanceComparator(itemwrapper.getRailing(), itemwrapper.getColor()));
return arr[0];
}
public IItemRailing chooseNextGoal(IItemRailingTransfer itemwrapper)
{
IItemRailing[] arr = (IItemRailing[]) itemwrapper.getRailing().getConnectionMap().entrySet().toArray();
Arrays.sort(arr, new RailingDistanceComparator(itemwrapper.getEndGoal()));
return arr[0];
}
}

View file

@ -14,13 +14,14 @@ import universalelectricity.api.vector.VectorWorld;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @author tgame14
* @since 18/03/14
*/
public class NodeRailing extends Node<PartRailing, GridRailing, NodeRailing> implements IVectorWorld, IItemRailing
public class NodeRailing extends Node<PartRailing, GridRailing, IItemRailing> implements IVectorWorld, IItemRailing
{
private EnumColor color;
private Set<IItemRailingTransfer> itemNodeSet;
@ -93,6 +94,12 @@ public class NodeRailing extends Node<PartRailing, GridRailing, NodeRailing> imp
return parent.getWorldPos();
}
@Override
public Map<IItemRailing, ForgeDirection> getConnectionMap()
{
return this.getConnections();
}
@Override
public IInventory[] getInventoriesNearby()
{
@ -112,4 +119,6 @@ public class NodeRailing extends Node<PartRailing, GridRailing, NodeRailing> imp
{
return parent.getConnections().length < 2;
}
}

View file

@ -9,7 +9,7 @@ import java.util.Comparator;
* @author tgame14
* @since 16/04/14
*/
public abstract class RailingDistanceComparator implements Comparator<IItemRailing>
public class RailingDistanceComparator implements Comparator<IItemRailing>
{
private IItemRailing source;

View file

@ -1,17 +1,20 @@
package resonantinduction.electrical.itemrailing.interfaces;
import calclavia.lib.grid.INode;
import calclavia.lib.render.EnumColor;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.vector.VectorWorld;
import java.util.Map;
/**
* implement on Part Railings.
*
* @since 16/03/14
* @author tgame14
*/
public interface IItemRailing
public interface IItemRailing extends INode
{
public boolean canItemEnter (IItemRailingTransfer item);
@ -23,6 +26,8 @@ public interface IItemRailing
public VectorWorld getWorldPos();
public Map<IItemRailing, ForgeDirection> getConnectionMap();
public IInventory[] getInventoriesNearby();
public boolean isLeaf();

View file

@ -1,9 +1,12 @@
package resonantinduction.electrical.itemrailing.interfaces;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.electrical.itemrailing.PartRailing;
import calclavia.lib.render.EnumColor;
import java.util.Map;
/**
* the object that functions as a Wrapper for items and handles the items that flow through Railings
*