Advertisement
jadenquinn

ILinkageManager.java

Sep 28th, 2018
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.43 KB | None | 0 0
  1. /*------------------------------------------------------------------------------
  2.  Copyright (c) CovertJaguar, 2011-2017
  3.  
  4.  This work (the API) is licensed under the "MIT" License,
  5.  see LICENSE.md for details.
  6.  -----------------------------------------------------------------------------*/
  7.  
  8. package mods.railcraft.api.carts;
  9.  
  10. import net.minecraft.entity.item.EntityMinecart;
  11.  
  12. import javax.annotation.Nullable;
  13. import java.util.UUID;
  14.  
  15. /**
  16.  * The LinkageManager contains all the functions needed to link and interact
  17.  * with linked carts.
  18.  * <p/>
  19.  * To obtain an instance of this interface, call CartTools.getLinkageManager().
  20.  * <p/>
  21.  * Each cart can up to two links. They are called Link A and Link B. Some carts
  22.  * will have only Link A, for example the Tunnel Bore.
  23.  *
  24.  * @author CovertJaguar <http://www.railcraft.info>
  25.  * @see CartToolsAPI , ILinkableCart
  26.  */
  27. public interface ILinkageManager {
  28.  
  29.     /**
  30.      * The default max distance at which carts can be linked, divided by 2.
  31.      */
  32.     float LINKAGE_DISTANCE = 1.25f;
  33.     /**
  34.      * The default distance at which linked carts are maintained, divided by 2.
  35.      */
  36.     float OPTIMAL_DISTANCE = 0.78f;
  37.  
  38.     boolean setAutoLink(EntityMinecart cart, boolean autoLink);
  39.  
  40.     boolean hasAutoLink(EntityMinecart cart);
  41.  
  42.     boolean tryAutoLink(EntityMinecart cart1, EntityMinecart cart2);
  43.  
  44.     /**
  45.      * Creates a link between two carts, but only if there is nothing preventing
  46.      * such a link.
  47.      *
  48.      * @return True if the link succeeded.
  49.      */
  50.     boolean createLink(EntityMinecart cart1, EntityMinecart cart2);
  51.  
  52.     boolean hasFreeLink(EntityMinecart cart);
  53.  
  54.     /**
  55.      * Returns the cart linked to Link A or null if nothing is currently
  56.      * occupying Link A.
  57.      *
  58.      * @param cart The cart for which to get the link
  59.      * @return The linked cart or null
  60.      */
  61.     @Nullable
  62.     EntityMinecart getLinkedCartA(EntityMinecart cart);
  63.  
  64.     /**
  65.      * Returns the cart linked to Link B or null if nothing is currently
  66.      * occupying Link B.
  67.      *
  68.      * @param cart The cart for which to get the link
  69.      * @return The linked cart or null
  70.      */
  71.     @Nullable
  72.     EntityMinecart getLinkedCartB(EntityMinecart cart);
  73.  
  74.     /**
  75.      * Returns true if the two carts are linked to each other.
  76.      *
  77.      * @return True if linked
  78.      */
  79.     boolean areLinked(EntityMinecart cart1, EntityMinecart cart2);
  80.  
  81.     /**
  82.      * Breaks a link between two carts, if any link exists.
  83.      */
  84.     void breakLink(EntityMinecart cart1, EntityMinecart cart2);
  85.  
  86.     /**
  87.      * Breaks all links the cart has.
  88.      */
  89.     void breakLinks(EntityMinecart cart);
  90.  
  91.     /**
  92.      * Break only link A.
  93.      */
  94.     void breakLinkA(EntityMinecart cart);
  95.  
  96.     /**
  97.      * Break only link B.
  98.      */
  99.     void breakLinkB(EntityMinecart cart);
  100.  
  101.     /**
  102.      * Counts how many carts are in the train.
  103.      *
  104.      * @param cart Any cart in the train
  105.      * @return The number of carts in the train
  106.      */
  107.     @SuppressWarnings("unused")
  108.     int countCartsInTrain(EntityMinecart cart);
  109.  
  110.     /**
  111.      * Returns an iterator which will iterate over every cart in the provided cart's train.
  112.      *
  113.      * There is no guarantee of order.
  114.      */
  115.     Iterable<EntityMinecart> trainIterator(EntityMinecart cart);
  116.  
  117.     /**
  118.      * Replaced with WorldServer#getEntityFromUuid.
  119.      */
  120.     @Nullable
  121.     @Deprecated
  122.     EntityMinecart getCartFromUUID(UUID id);
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement