Exemplo n.º 1
0
 /**
  * Gets the Collision Mode for colliding with the Entity specified
  *
  * @param entity to collide with
  * @return Collision Mode
  */
 public CollisionMode getCollisionMode(Entity entity) {
   if (!this.getColliding() || entity.isDead()) {
     return CollisionMode.CANCEL;
   }
   MinecartMember<?> member = MinecartMemberStore.get(entity);
   if (member != null) {
     if (this.trainCollision == CollisionMode.LINK) {
       if (member.getGroup().getProperties().trainCollision == CollisionMode.LINK) {
         return CollisionMode.LINK;
       } else {
         return CollisionMode.CANCEL;
       }
     } else {
       return this.trainCollision;
     }
   } else if (entity instanceof Player) {
     if (TrainCarts.collisionIgnoreOwners && this.playerCollision != CollisionMode.DEFAULT) {
       if (TrainCarts.collisionIgnoreGlobalOwners) {
         if (CartProperties.hasGlobalOwnership((Player) entity)) {
           return CollisionMode.DEFAULT;
         }
       }
       if (this.hasOwnership((Player) entity)) {
         return CollisionMode.DEFAULT;
       }
     }
     return this.playerCollision;
   } else if (EntityUtil.isMob(entity)) {
     return this.mobCollision;
   } else {
     return this.miscCollision;
   }
 }
Exemplo n.º 2
0
 public static MinecartMember get(Object o) {
   if (o == null) return null;
   if (o instanceof UUID) {
     o = findByID((UUID) o);
     if (o == null) return null;
   }
   if (o instanceof Minecart) {
     o = EntityUtil.getNative((Minecart) o);
   }
   if (o instanceof MinecartMember) {
     return (MinecartMember) o;
   } else {
     return null;
   }
 }
Exemplo n.º 3
0
 public static MinecartMember convert(Object o) {
   if (o == null) return null;
   if (o instanceof UUID) {
     o = findByID((UUID) o);
     if (o == null) return null;
   }
   if (o instanceof Minecart) {
     o = EntityUtil.getNative((Minecart) o);
   }
   if (o instanceof MinecartMember) {
     return (MinecartMember) o;
   }
   if (!o.getClass().equals(EntityMinecart.class)) {
     return null;
   }
   EntityMinecart em = (EntityMinecart) o;
   if (em.dead) return null; // prevent conversion of dead entities
   // not found, conversion allowed?
   if (denyConversion) return null;
   // convert
   MinecartMember mm = new MinecartMember(em.world, em.lastX, em.lastY, em.lastZ, em.type);
   replaceMinecarts(em, mm);
   return mm;
 }