Advertisement
jadenquinn

ILinkableCart.java

Sep 28th, 2018
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.22 KB | None | 0 0
  1. /*******************************************************************************
  2.  Copyright (c) CovertJaguar, 2011-2016
  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. /**
  13.  * This interface should be implemented by any minecart that wishes
  14.  * to change the default linkage behavior.
  15.  * It is NOT required to be able to link a cart,
  16.  * it merely gives you more control over the process.
  17.  *
  18.  * @author CovertJaguar <http://www.railcraft.info>
  19.  */
  20. public interface ILinkableCart {
  21.  
  22.     /**
  23.      * To disable linking altogether, return false here.
  24.      *
  25.      * @return True if this cart is linkable.
  26.      */
  27.     default boolean isLinkable() {
  28.         return true;
  29.     }
  30.  
  31.     /**
  32.      * Check called when attempting to link carts.
  33.      *
  34.      * @param cart The cart that we are attempting to link with.
  35.      * @return True if we can link with this cart.
  36.      */
  37.     default boolean canLinkWithCart(EntityMinecart cart) {
  38.         return true;
  39.     }
  40.  
  41.     /**
  42.      * Returns true if this cart has two links
  43.      * or false if it can only link with one cart.
  44.      *
  45.      * @return True if two links
  46.      */
  47.     default boolean hasTwoLinks() {
  48.         return true;
  49.     }
  50.  
  51.     /**
  52.      * Gets the distance at which this cart can be linked.
  53.      * This is called on both carts and added together to determine
  54.      * how close two carts need to be for a successful link.
  55.      * Default = LinkageManager.LINKAGE_DISTANCE
  56.      *
  57.      * @param cart The cart that you are attempting to link with.
  58.      * @return The linkage distance
  59.      */
  60.     default float getLinkageDistance(EntityMinecart cart) {
  61.         return ILinkageManager.LINKAGE_DISTANCE;
  62.     }
  63.  
  64.     /**
  65.      * Gets the optimal distance between linked carts.
  66.      * This is called on both carts and added together to determine
  67.      * the optimal rest distance between linked carts.
  68.      * The LinkageManager will attempt to maintain this distance
  69.      * between linked carts at all times.
  70.      * Default = LinkageManager.OPTIMAL_DISTANCE
  71.      *
  72.      * @param cart The cart that you are linked with.
  73.      * @return The optimal rest distance
  74.      */
  75.     default float getOptimalDistance(EntityMinecart cart) {
  76.         return ILinkageManager.OPTIMAL_DISTANCE;
  77.     }
  78.  
  79.     /**
  80.      * Return false if linked carts have no effect on the velocity of this cart.
  81.      * Use carefully, if you link two carts that can't be adjusted,
  82.      * it will behave as if they are not linked.
  83.      *
  84.      * @param cart The cart doing the adjusting.
  85.      * @return Whether the cart can have its velocity adjusted.
  86.      */
  87.     default boolean canBeAdjusted(EntityMinecart cart) {
  88.         return true;
  89.     }
  90.  
  91.     /**
  92.      * Called upon successful link creation.
  93.      *
  94.      * @param cart The cart we linked with.
  95.      */
  96.     default void onLinkCreated(EntityMinecart cart) {
  97.     }
  98.  
  99.     /**
  100.      * Called when a link is broken (usually).
  101.      *
  102.      * @param cart The cart we were linked with.
  103.      */
  104.     default void onLinkBroken(EntityMinecart cart) {
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement