Package mods.railcraft.api.carts

Examples of mods.railcraft.api.carts.ILinkageManager


  public static void breakLinks(World world, EntityMinecart cart) {
    if(world == null || cart == null) {
      return;
    }
    ILinkageManager linkMan = CartTools.getLinkageManager(world);
    if(linkMan == null) {
      return;
    }
    linkMan.breakLinks(cart);
  }
View Full Code Here


  public static void recreateLink(EntityMinecart existingCart, EntityMinecart newCart) {
    if(existingCart == null || newCart == null) {
      return;
    }
    ILinkageManager linkMan = CartTools.getLinkageManager(existingCart.worldObj);
    if(linkMan == null) {
      return;
    }
    UUID linkA = getLinkA(newCart);
    if(linkA != null && linkA.equals(existingCart.getPersistentID())) {
      if(!linkMan.areLinked(existingCart, newCart)) {
        boolean res = linkMan.createLink(existingCart, newCart);
      }
      return;
    }
    UUID linkB = getLinkB(newCart);
    if(linkB != null && linkB.equals(existingCart.getPersistentID())) {
      if(!linkMan.areLinked(existingCart, newCart)) {
        boolean res = linkMan.createLink(existingCart, newCart);
      }
      return;
    }
  }
View Full Code Here

      return;
    }
  }

  public static void updateCartLinks(World world, EntityMinecart cart) {
    ILinkageManager linkMan = CartTools.getLinkageManager(cart.worldObj);
    if(linkMan == null || linkMan.countCartsInTrain(cart) <= 1) {
      return;
    }
    Iterable<EntityMinecart> allCarts = linkMan.getCartsInTrain(cart);
    for (EntityMinecart aCart : allCarts) {
      if(aCart != null) {
        updateLink("a", aCart, linkMan.getLinkedCartA(aCart));
        updateLink("b", aCart, linkMan.getLinkedCartB(aCart));
      }
    }
  }
View Full Code Here

  public static int getNumberOfCartsInTrain(EntityMinecart cart) {
    if(cart == null) {
      return 0;
    }
    ILinkageManager linkMan = CartTools.getLinkageManager(cart.worldObj);
    if(linkMan == null) {
      return 1;
    }
    return linkMan.countCartsInTrain(cart);
  }
View Full Code Here

  public static List<EntityMinecart> getCartsInTrain(EntityMinecart cart) {
    if(cart == null) {
      Collections.emptyList();
    }
    List<EntityMinecart> result = new ArrayList<EntityMinecart>();
    ILinkageManager linkMan = CartTools.getLinkageManager(cart.worldObj);
    if(linkMan == null) {
      result.add(cart);
      return result;
    }

    Iterable<EntityMinecart> iter = linkMan.getCartsInTrain(cart);
    for (EntityMinecart cartInTrain : iter) {
      if(cartInTrain != null) {
        result.add(cartInTrain);
      }
    }
View Full Code Here

    Collections.sort(result, new TrainOrderComparator(cart));
    return result;
  }

  public static void recreateLinks(EntityMinecart cart) {
    ILinkageManager linkMan = CartTools.getLinkageManager(cart.worldObj);
    if(linkMan == null) {
      return;
    }
    recreateLink(cart, linkMan, getLinkA(cart));
    recreateLink(cart, linkMan, getLinkB(cart));
View Full Code Here

                if (crowbar.canLink(thePlayer, stack, cart)) {
                    boolean linkable = cart instanceof ILinkableCart;
                    if (!linkable || (linkable && ((ILinkableCart) cart).isLinkable()))
                        if (linkMap.containsKey(thePlayer)) {
                            ILinkageManager lm = LinkageManager.instance();
                            EntityMinecart last = linkMap.remove(thePlayer);
                            if (lm.areLinked(cart, last)) {
                                lm.breakLink(cart, last);
                                used = true;
                                ChatPlugin.sendLocalizedChat(thePlayer, "railcraft.gui.link.broken");
                                LinkageManager.printDebug("Reason For Broken Link: User removed link.");
                            } else {
                                used = lm.createLink((EntityMinecart) entity, (EntityMinecart) last);
                                if (used)
                                    ChatPlugin.sendLocalizedChat(thePlayer, "railcraft.gui.link.created");
                            }
                            if (!used)
                                ChatPlugin.sendLocalizedChat(thePlayer, "railcraft.gui.link.failed");
View Full Code Here

    private short trainSize = 5;

    @Override
    public int testCarts(List<EntityMinecart> carts) {
        ILinkageManager lm = LinkageManager.instance();
        for (EntityMinecart cart : carts) {
            int count = lm.countCartsInTrain(cart);
            int size = getTrainSize();
            if (count >= size) {
                return FULL_POWER;
            }
        }
View Full Code Here

    @Override
    public void onEntityCollision(EntityMinecart cart, Entity other) {
        if (Game.isNotHost(cart.worldObj) || other == cart.riddenByEntity || other.isDead || cart.isDead)
            return;

        ILinkageManager lm = LinkageManager.instance();
        EntityMinecart link = lm.getLinkedCartA(cart);
        if (link != null && (link == other || other == link.riddenByEntity))
            return;
        link = lm.getLinkedCartB(cart);
        if (link != null && (link == other || other == link.riddenByEntity))
            return;

        boolean isLiving = other instanceof EntityLivingBase;
        boolean isPlayer = other instanceof EntityPlayer;
View Full Code Here

    }

    private void testHighSpeedCollision(EntityMinecart cart, Entity other) {
        boolean highSpeed = cart.getEntityData().getBoolean("HighSpeed");
        if (highSpeed) {
            ILinkageManager lm = LinkageManager.instance();
            if (other instanceof EntityMinecart && lm.areLinked(cart, (EntityMinecart) other))
                return;
            EntityMinecart link = lm.getLinkedCartA(cart);
            if (link != null && other == link.riddenByEntity)
                return;
            link = lm.getLinkedCartB(cart);
            if (link != null && other == link.riddenByEntity)
                return;

            if (other instanceof EntityMinecart) {
                boolean otherHighSpeed = other.getEntityData().getBoolean("HighSpeed");
View Full Code Here

TOP

Related Classes of mods.railcraft.api.carts.ILinkageManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.